llvm.org GIT mirror llvm / 502f20b
Add new parameter Fast to createJIT to enable the fast codegen path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54523 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 12 years ago
8 changed file(s) with 31 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
7878 // To avoid having libexecutionengine depend on the JIT and interpreter
7979 // libraries, the JIT and Interpreter set these functions to ctor pointers
8080 // at startup time if they are linked in.
81 typedef ExecutionEngine *(*EECtorFn)(ModuleProvider*, std::string*);
81 typedef ExecutionEngine *(*EECtorFn)(ModuleProvider*, std::string*,
82 bool Fast);
8283 static EECtorFn JITCtor, InterpCtor;
8384
8485 /// LazyFunctionCreator - If an unknown function is needed, this function
107108 /// module provider.
108109 static ExecutionEngine *create(ModuleProvider *MP,
109110 bool ForceInterpreter = false,
110 std::string *ErrorStr = 0);
111 std::string *ErrorStr = 0,
112 bool Fast = false);
111113
112114 /// create - This is the factory method for creating an execution engine which
113115 /// is appropriate for the current machine. This takes ownership of the
119121 /// of the ModuleProvider and JITMemoryManager if successful.
120122 static ExecutionEngine *createJIT(ModuleProvider *MP,
121123 std::string *ErrorStr = 0,
122 JITMemoryManager *JMM = 0);
124 JITMemoryManager *JMM = 0,
125 bool Fast = false);
123126
124127
125128
344344 ///
345345 ExecutionEngine *ExecutionEngine::create(ModuleProvider *MP,
346346 bool ForceInterpreter,
347 std::string *ErrorStr) {
347 std::string *ErrorStr,
348 bool Fast) {
348349 ExecutionEngine *EE = 0;
349350
350351 // Make sure we can resolve symbols in the program as well. The zero arg
354355
355356 // Unless the interpreter was explicitly selected, try making a JIT.
356357 if (!ForceInterpreter && JITCtor)
357 EE = JITCtor(MP, ErrorStr);
358 EE = JITCtor(MP, ErrorStr, Fast);
358359
359360 // If we can't make a JIT, make an interpreter instead.
360361 if (EE == 0 && InterpCtor)
361 EE = InterpCtor(MP, ErrorStr);
362 EE = InterpCtor(MP, ErrorStr, Fast);
362363
363364 return EE;
364365 }
113113
114114 int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
115115 LLVMModuleProviderRef MP,
116 char **OutError) {
117 std::string Error;
118 if (ExecutionEngine *JIT = ExecutionEngine::createJIT(unwrap(MP), &Error)) {
116 char **OutError,
117 bool Fast = false) {
118 std::string Error;
119 if (ExecutionEngine *JIT = ExecutionEngine::createJIT(unwrap(MP), &Error, 0,
120 Fast)) {
119121 *OutJIT = wrap(JIT);
120122 return 0;
121123 }
3535
3636 /// create - Create a new interpreter object. This can never fail.
3737 ///
38 ExecutionEngine *Interpreter::create(ModuleProvider *MP, std::string* ErrStr) {
38 ExecutionEngine *Interpreter::create(ModuleProvider *MP, std::string* ErrStr,
39 bool Fast /*unused*/) {
3940 // Tell this ModuleProvide to materialize and release the module
4041 if (!MP->materializeModule(ErrStr))
4142 // We got an error, just return 0
107107
108108 /// create - Create an interpreter ExecutionEngine. This can never fail.
109109 ///
110 static ExecutionEngine *create(ModuleProvider *M, std::string *ErrorStr = 0);
110 static ExecutionEngine *create(ModuleProvider *M, std::string *ErrorStr = 0,
111 bool Fast /*unused*/ = 0);
111112
112113 /// run - Start execution with the specified function and arguments.
113114 ///
7272 /// of the module provider.
7373 ExecutionEngine *ExecutionEngine::createJIT(ModuleProvider *MP,
7474 std::string *ErrorStr,
75 JITMemoryManager *JMM) {
76 ExecutionEngine *EE = JIT::createJIT(MP, ErrorStr, JMM);
75 JITMemoryManager *JMM,
76 bool Fast) {
77 ExecutionEngine *EE = JIT::createJIT(MP, ErrorStr, JMM, Fast);
7778 if (!EE) return 0;
7879
7980 // Register routine for informing unwinding runtime about new EH frames
8889 }
8990
9091 JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
91 JITMemoryManager *JMM)
92 JITMemoryManager *JMM, bool Fast)
9293 : ExecutionEngine(MP), TM(tm), TJI(tji) {
9394 setTargetData(TM.getTargetData());
9495
104105
105106 // Turn the machine code intermediate representation into bytes in memory that
106107 // may be executed.
107 if (TM.addPassesToEmitMachineCode(PM, *MCE, false /*fast*/)) {
108 if (TM.addPassesToEmitMachineCode(PM, *MCE, Fast)) {
108109 cerr << "Target does not support machine code emission!\n";
109110 abort();
110111 }
5555 JITState *jitstate;
5656
5757 JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
58 JITMemoryManager *JMM);
58 JITMemoryManager *JMM, bool Fast);
5959 public:
6060 ~JIT();
6161
7070 /// create - Create an return a new JIT compiler if there is one available
7171 /// for the current target. Otherwise, return null.
7272 ///
73 static ExecutionEngine *create(ModuleProvider *MP, std::string *Err) {
74 return createJIT(MP, Err, 0);
73 static ExecutionEngine *create(ModuleProvider *MP, std::string *Err,
74 bool Fast = false) {
75 return createJIT(MP, Err, 0, Fast);
7576 }
7677
7778 virtual void addModuleProvider(ModuleProvider *MP);
127128 MachineCodeEmitter *getCodeEmitter() const { return MCE; }
128129
129130 static ExecutionEngine *createJIT(ModuleProvider *MP, std::string *Err,
130 JITMemoryManager *JMM);
131 JITMemoryManager *JMM, bool Fast);
131132
132133 private:
133134 static MachineCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM);
4040 /// available for the current target. Otherwise, return null.
4141 ///
4242 ExecutionEngine *JIT::createJIT(ModuleProvider *MP, std::string *ErrorStr,
43 JITMemoryManager *JMM) {
43 JITMemoryManager *JMM, bool Fast) {
4444 const TargetMachineRegistry::entry *TheArch = MArch;
4545 if (TheArch == 0) {
4646 std::string Error;
7272
7373 // If the target supports JIT code generation, return a new JIT now.
7474 if (TargetJITInfo *TJ = Target->getJITInfo())
75 return new JIT(MP, *Target, *TJ, JMM);
75 return new JIT(MP, *Target, *TJ, JMM, Fast);
7676
7777 if (ErrorStr)
7878 *ErrorStr = "target does not support JIT code generation";