コード例 #1
0
/* llmodule -> ExecutionEngine.t */
CAMLprim LLVMExecutionEngineRef
llvm_ee_create_interpreter(LLVMModuleRef M) {
  LLVMExecutionEngineRef Interp;
  char *Error;
  if (LLVMCreateInterpreterForModule(&Interp, M, &Error))
    llvm_raise(*caml_named_value("Llvm_executionengine.Error"), Error);
  return Interp;
}
コード例 #2
0
/* llmodule -> ExecutionEngine.t */
CAMLprim LLVMExecutionEngineRef
llvm_ee_create_interpreter(LLVMModuleRef M) {
  LLVMExecutionEngineRef Interp;
  char *Error;
  if (LLVMCreateInterpreterForModule(&Interp, M, &Error))
    llvm_raise(llvm_ee_error_exn, Error);
  return Interp;
}
コード例 #3
0
ファイル: ExecutionEngine_wrap.c プロジェクト: hardvain/jllvm
SWIGEXPORT jint JNICALL Java_org_jllvm_bindings_ExecutionEngineJNI_LLVMCreateInterpreterForModule(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  jint jresult = 0 ;
  LLVMExecutionEngineRef *arg1 = (LLVMExecutionEngineRef *) 0 ;
  LLVMModuleRef arg2 = (LLVMModuleRef) 0 ;
  char **arg3 = (char **) 0 ;
  LLVMBool result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(LLVMExecutionEngineRef **)&jarg1; 
  arg2 = *(LLVMModuleRef *)&jarg2; 
  arg3 = *(char ***)&jarg3; 
  result = (LLVMBool)LLVMCreateInterpreterForModule(arg1,arg2,arg3);
  jresult = (jint)result; 
  return jresult;
}
コード例 #4
0
ファイル: llvm-fib.c プロジェクト: qeedquan/misc_utilities
int
main(int argc, char **argv)
{
	int n = argc > 1 ? atol(argv[1]) : 24;

	LLVMInitializeNativeTarget();
	LLVMLinkInInterpreter();

	LLVMContextRef Context = LLVMContextCreate();

	// Create some module to put our function into it.
	LLVMModuleRef M = LLVMModuleCreateWithNameInContext("test", Context);

	// We are about to create the "fib" function:
	LLVMValueRef FibF = CreateFibFunction(M, Context);

	// Now we going to create JIT
	LLVMExecutionEngineRef EE;
	char *                 outError;

	if (LLVMCreateInterpreterForModule(&EE, M, &outError) != 0) {
		printf("%s\n", outError);
		return 1;
	}

	printf("verifying...\n");
	if (LLVMVerifyModule(M, LLVMReturnStatusAction, &outError) != 0) {
		printf("%s\n", outError);
		return 1;
	}

	printf("OK\n");
	printf("We just constructed this LLVM module:\n\n---------\n");
	printf("%s\n", LLVMPrintModuleToString(M));

	LLVMGenericValueRef Args   = LLVMCreateGenericValueOfInt(LLVMInt32TypeInContext(Context), n, 0);
	LLVMGenericValueRef Result = LLVMRunFunction(EE, FibF, 1, &Args);

	printf("Result: %llu\n", LLVMGenericValueToInt(Result, 0));

	return 0;
}