Esempio n. 1
0
// CreateTargetMachine creates a new TargetMachine.
func (t Target) CreateTargetMachine(Triple string, CPU string, Features string,
	Level CodeGenOptLevel, Reloc RelocMode,
	CodeModel CodeModel) (tm TargetMachine) {
	cTriple := C.CString(Triple)
	defer C.free(unsafe.Pointer(cTriple))
	cCPU := C.CString(CPU)
	defer C.free(unsafe.Pointer(cCPU))
	cFeatures := C.CString(Features)
	defer C.free(unsafe.Pointer(cFeatures))
	tm.C = C.LLVMCreateTargetMachine(t.C, cTriple, cCPU, cFeatures,
		C.LLVMCodeGenOptLevel(Level),
		C.LLVMRelocMode(Reloc),
		C.LLVMCodeModel(CodeModel))
	return
}
Esempio n. 2
0
func NewMCJITCompiler(m Module, options MCJITCompilerOptions) (ee ExecutionEngine, err error) {
	var cmsg *C.char
	copts := C.struct_LLVMMCJITCompilerOptions{
		OptLevel:           C.unsigned(options.OptLevel),
		CodeModel:          C.LLVMCodeModel(options.CodeModel),
		NoFramePointerElim: boolToLLVMBool(options.NoFramePointerElim),
		EnableFastISel:     boolToLLVMBool(options.EnableFastISel),
	}
	fail := C.LLVMCreateMCJITCompilerForModule(&ee.C, m.C, &copts, C.size_t(unsafe.Sizeof(copts)), &cmsg)
	if fail != 0 {
		ee.C = nil
		err = errors.New(C.GoString(cmsg))
		C.LLVMDisposeMessage(cmsg)
	}
	return
}
Esempio n. 3
0
func (options *MCJITCompilerOptions) SetMCJITCodeModel(CodeModel CodeModel) {
	options.C.CodeModel = C.LLVMCodeModel(CodeModel)
}