Beispiel #1
0
func NewMCJITCompiler(m Module, options MCJITCompilerOptions) (ee ExecutionEngine, err error) {
	var cmsg *C.char
	fail := C.LLVMCreateMCJITCompilerForModule(&ee.C, m.C, &options.C, C.size_t(unsafe.Sizeof(C.struct_LLVMMCJITCompilerOptions{})), &cmsg)
	if fail != 0 {
		ee.C = nil
		err = errors.New(C.GoString(cmsg))
		C.LLVMDisposeMessage(cmsg)
	}
	return
}
Beispiel #2
0
func NewExecutionEngine(m Module) (ee ExecutionEngine, err error) {
	var cmsg *C.char
	fail := C.LLVMCreateExecutionEngineForModule(&ee.C, m.C, &cmsg)
	if fail != 0 {
		ee.C = nil
		err = errors.New(C.GoString(cmsg))
		C.LLVMDisposeMessage(cmsg)
	}
	return
}
Beispiel #3
0
func LinkModules(Dest, Src Module, Mode LinkerMode) error {
	var cmsg *C.char
	failed := C.LLVMLinkModules(Dest.C, Src.C, C.LLVMLinkerMode(Mode), &cmsg)
	if failed == 0 {
		return nil
	}
	err := errors.New(C.GoString(cmsg))
	C.LLVMDisposeMessage(cmsg)
	return err
}
Beispiel #4
0
func LinkModules(Dest, Src Module) error {
	var cmsg *C.char
	failed := C.LLVMLinkModules(Dest.C, Src.C, 0, &cmsg)
	if failed != 0 {
		err := errors.New(C.GoString(cmsg))
		C.LLVMDisposeMessage(cmsg)
		return err
	}
	return nil
}
Beispiel #5
0
func NewJITCompiler(m Module, optLevel int) (ee ExecutionEngine, err error) {
	var cmsg *C.char
	fail := C.LLVMCreateJITCompilerForModule(&ee.C, m.C, C.unsigned(optLevel), &cmsg)
	if fail == 0 {
		err = nil
	} else {
		ee.C = nil
		err = errors.New(C.GoString(cmsg))
		C.LLVMDisposeMessage(cmsg)
	}
	return
}
Beispiel #6
0
func NewInterpreter(m Module) (ee ExecutionEngine, err os.Error) {
	var cmsg *C.char
	fail := C.LLVMCreateInterpreterForModule(&ee.C, m.C, &cmsg)
	if fail == 0 {
		err = nil
	} else {
		ee.C = nil
		err = os.NewError(C.GoString(cmsg))
		C.LLVMDisposeMessage(cmsg)
	}
	return
}
Beispiel #7
0
// Verifies that a module is valid, taking the specified action if not.
// Optionally returns a human-readable description of any invalid constructs.
func VerifyModule(m Module, a VerifierFailureAction) error {
	var cmsg *C.char
	broken := C.LLVMVerifyModule(m.C, C.LLVMVerifierFailureAction(a), &cmsg)

	// C++'s verifyModule means isModuleBroken, so it returns false if
	// there are no errors
	if broken != 0 {
		err := errors.New(C.GoString(cmsg))
		C.LLVMDisposeMessage(cmsg)
		return err
	}
	return nil
}
Beispiel #8
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
}
Beispiel #9
0
Datei: core.go Projekt: ssrl/llvm
func DisposeMessage(message string) {
	cmessage := C.CString(message)
	C.LLVMDisposeMessage(cmessage)
	C.free(unsafe.Pointer(cmessage))
}
Beispiel #10
0
// Converts target data to a target layout string. The string must be disposed
// with LLVMDisposeMessage.
// See the constructor llvm::TargetData::TargetData.
func (td TargetData) String() (s string) {
	cmsg := C.LLVMCopyStringRepOfTargetData(td.C)
	s = C.GoString(cmsg)
	C.LLVMDisposeMessage(cmsg)
	return
}