Daniel Dunbar | 6aec298 | 2010-11-17 16:06:43 +0000 | [diff] [blame] | 1 | //===-- MCJIT.h - Class definition for the MCJIT ----------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_LIB_EXECUTIONENGINE_MCJIT_H |
| 11 | #define LLVM_LIB_EXECUTIONENGINE_MCJIT_H |
| 12 | |
Jim Grosbach | 31649e6 | 2011-03-18 22:48:41 +0000 | [diff] [blame^] | 13 | #include "llvm/PassManager.h" |
Daniel Dunbar | 6aec298 | 2010-11-17 16:06:43 +0000 | [diff] [blame] | 14 | #include "llvm/ExecutionEngine/ExecutionEngine.h" |
Jim Grosbach | 31649e6 | 2011-03-18 22:48:41 +0000 | [diff] [blame^] | 15 | #include "llvm/ADT/SmallVector.h" |
| 16 | #include "llvm/Support/raw_ostream.h" |
Daniel Dunbar | 6aec298 | 2010-11-17 16:06:43 +0000 | [diff] [blame] | 17 | |
| 18 | namespace llvm { |
| 19 | |
Jim Grosbach | 31649e6 | 2011-03-18 22:48:41 +0000 | [diff] [blame^] | 20 | // FIXME: This makes all kinds of horrible assumptions for the time being, |
| 21 | // like only having one module, not needing to worry about multi-threading, |
| 22 | // blah blah. Purely in get-it-up-and-limping mode for now. |
| 23 | |
Daniel Dunbar | 6aec298 | 2010-11-17 16:06:43 +0000 | [diff] [blame] | 24 | class MCJIT : public ExecutionEngine { |
Jim Grosbach | 31649e6 | 2011-03-18 22:48:41 +0000 | [diff] [blame^] | 25 | MCJIT(Module *M, TargetMachine *tm, TargetJITInfo &tji, |
Daniel Dunbar | 6aec298 | 2010-11-17 16:06:43 +0000 | [diff] [blame] | 26 | JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, |
| 27 | bool AllocateGVsWithCode); |
Jim Grosbach | 31649e6 | 2011-03-18 22:48:41 +0000 | [diff] [blame^] | 28 | |
| 29 | TargetMachine *TM; |
| 30 | MCContext *Ctx; |
| 31 | |
| 32 | // FIXME: These may need moved to a separate 'jitstate' member like the |
| 33 | // non-MC JIT does for multithreading and such. Just keep them here for now. |
| 34 | PassManager PM; |
| 35 | Module *M; |
| 36 | // FIXME: This really doesn't belong here. |
| 37 | SmallVector<char, 4096> Buffer; // Working buffer into which we JIT. |
| 38 | raw_svector_ostream OS; |
| 39 | |
Daniel Dunbar | 6aec298 | 2010-11-17 16:06:43 +0000 | [diff] [blame] | 40 | public: |
| 41 | ~MCJIT(); |
| 42 | |
| 43 | /// @name ExecutionEngine interface implementation |
| 44 | /// @{ |
| 45 | |
| 46 | virtual void *getPointerToBasicBlock(BasicBlock *BB); |
| 47 | |
| 48 | virtual void *getPointerToFunction(Function *F); |
| 49 | |
| 50 | virtual void *recompileAndRelinkFunction(Function *F); |
| 51 | |
| 52 | virtual void freeMachineCodeForFunction(Function *F); |
| 53 | |
| 54 | virtual GenericValue runFunction(Function *F, |
| 55 | const std::vector<GenericValue> &ArgValues); |
| 56 | |
| 57 | /// @} |
| 58 | /// @name (Private) Registration Interfaces |
| 59 | /// @{ |
| 60 | |
| 61 | static void Register() { |
| 62 | MCJITCtor = createJIT; |
| 63 | } |
| 64 | |
| 65 | // FIXME: This routine is scheduled for termination. Do not use it. |
| 66 | static TargetMachine *selectTarget(Module *M, |
| 67 | StringRef MArch, |
| 68 | StringRef MCPU, |
| 69 | const SmallVectorImpl<std::string>& MAttrs, |
| 70 | std::string *Err); |
| 71 | |
| 72 | static ExecutionEngine *createJIT(Module *M, |
| 73 | std::string *ErrorStr, |
| 74 | JITMemoryManager *JMM, |
| 75 | CodeGenOpt::Level OptLevel, |
| 76 | bool GVsWithCode, |
| 77 | CodeModel::Model CMM, |
| 78 | StringRef MArch, |
| 79 | StringRef MCPU, |
| 80 | const SmallVectorImpl<std::string>& MAttrs); |
| 81 | |
| 82 | // @} |
| 83 | }; |
| 84 | |
| 85 | } // End llvm namespace |
| 86 | |
| 87 | #endif |