/* unit -> bool */ CAMLprim value llvm_initialize_native_target(value Unit) { LLVMLinkInInterpreter(); LLVMLinkInMCJIT(); return Val_bool(!LLVMInitializeNativeTarget() && !LLVMInitializeNativeAsmParser() && !LLVMInitializeNativeAsmPrinter()); }
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; }
/* Force the LLVM interpreter and JIT to be linked in. */ void llvm_initialize(void) { LLVMLinkInInterpreter(); LLVMLinkInJIT(); }
SWIGEXPORT void JNICALL Java_org_jllvm_bindings_ExecutionEngineJNI_LLVMLinkInInterpreter(JNIEnv *jenv, jclass jcls) { (void)jenv; (void)jcls; LLVMLinkInInterpreter(); }