1 //===-- JIT.cpp - MC-based Just-in-Time Compiler --------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "llvm/ExecutionEngine/GenericValue.h"
12 #include "llvm/ExecutionEngine/MCJIT.h"
13 #include "llvm/Support/ErrorHandling.h"
14 #include "llvm/System/DynamicLibrary.h"
20 static struct RegisterJIT {
21 RegisterJIT() { MCJIT::Register(); }
26 extern "C" void LLVMLinkInMCJIT() {
29 ExecutionEngine *MCJIT::createJIT(Module *M,
30 std::string *ErrorStr,
31 JITMemoryManager *JMM,
32 CodeGenOpt::Level OptLevel,
37 const SmallVectorImpl<std::string>& MAttrs) {
38 // Try to register the program as a source of symbols to resolve against.
40 // FIXME: Don't do this here.
41 sys::DynamicLibrary::LoadLibraryPermanently(0, NULL);
43 // Pick a target either via -march or by guessing the native arch.
45 // FIXME: This should be lifted out of here, it isn't something which should
46 // be part of the JIT policy, rather the burden for this selection should be
48 TargetMachine *TM = MCJIT::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr);
49 if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
50 TM->setCodeModel(CMM);
52 // If the target supports JIT code generation, create the JIT.
53 if (TargetJITInfo *TJ = TM->getJITInfo())
54 return new MCJIT(M, *TM, *TJ, JMM, OptLevel, GVsWithCode);
57 *ErrorStr = "target does not support JIT code generation";
61 MCJIT::MCJIT(Module *M, TargetMachine &tm, TargetJITInfo &tji,
62 JITMemoryManager *JMM, CodeGenOpt::Level OptLevel,
63 bool AllocateGVsWithCode)
64 : ExecutionEngine(M) {
70 void *MCJIT::getPointerToBasicBlock(BasicBlock *BB) {
71 report_fatal_error("not yet implemented");
75 void *MCJIT::getPointerToFunction(Function *F) {
76 report_fatal_error("not yet implemented");
80 void *MCJIT::recompileAndRelinkFunction(Function *F) {
81 report_fatal_error("not yet implemented");
84 void MCJIT::freeMachineCodeForFunction(Function *F) {
85 report_fatal_error("not yet implemented");
88 GenericValue MCJIT::runFunction(Function *F,
89 const std::vector<GenericValue> &ArgValues) {
90 report_fatal_error("not yet implemented");
91 return GenericValue();