llvm.org GIT mirror llvm / 5e5cb79
The second part of the change from -fast to -O#. This changes the JIT to accept an optimization level instead of a simple boolean telling it to generate code "fast" or the other type of "fast". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70347 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 11 years ago
9 changed file(s) with 24 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
8383 // libraries, the JIT and Interpreter set these functions to ctor pointers
8484 // at startup time if they are linked in.
8585 typedef ExecutionEngine *(*EECtorFn)(ModuleProvider*, std::string*,
86 bool Fast);
86 unsigned OptLevel);
8787 static EECtorFn JITCtor, InterpCtor;
8888
8989 /// LazyFunctionCreator - If an unknown function is needed, this function
113113 static ExecutionEngine *create(ModuleProvider *MP,
114114 bool ForceInterpreter = false,
115115 std::string *ErrorStr = 0,
116 bool Fast = false);
116 unsigned OptLevel = 3);
117117
118118 /// create - This is the factory method for creating an execution engine which
119119 /// is appropriate for the current machine. This takes ownership of the
126126 static ExecutionEngine *createJIT(ModuleProvider *MP,
127127 std::string *ErrorStr = 0,
128128 JITMemoryManager *JMM = 0,
129 bool Fast = false);
129 unsigned OptLevel = 3);
130130
131131
132132
6161
6262 int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
6363 LLVMModuleProviderRef MP,
64 int Fast,
64 unsigned OptLevel,
6565 char **OutError);
6666
6767 void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE);
382382 ExecutionEngine *ExecutionEngine::create(ModuleProvider *MP,
383383 bool ForceInterpreter,
384384 std::string *ErrorStr,
385 bool Fast) {
385 unsigned OptLevel) {
386386 ExecutionEngine *EE = 0;
387387
388388 // Make sure we can resolve symbols in the program as well. The zero arg
392392
393393 // Unless the interpreter was explicitly selected, try making a JIT.
394394 if (!ForceInterpreter && JITCtor)
395 EE = JITCtor(MP, ErrorStr, Fast);
395 EE = JITCtor(MP, ErrorStr, OptLevel);
396396
397397 // If we can't make a JIT, make an interpreter instead.
398398 if (EE == 0 && InterpCtor)
399 EE = InterpCtor(MP, ErrorStr, Fast);
399 EE = InterpCtor(MP, ErrorStr, OptLevel);
400400
401401 return EE;
402402 }
113113
114114 int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
115115 LLVMModuleProviderRef MP,
116 int Fast,
116 unsigned OptLevel,
117117 char **OutError) {
118118 std::string Error;
119119 if (ExecutionEngine *JIT = ExecutionEngine::createJIT(unwrap(MP), &Error, 0,
120 Fast != 0)) {
120 OptLevel)) {
121121 *OutJIT = wrap(JIT);
122122 return 0;
123123 }
3636 /// create - Create a new interpreter object. This can never fail.
3737 ///
3838 ExecutionEngine *Interpreter::create(ModuleProvider *MP, std::string* ErrStr,
39 bool Fast /*unused*/) {
39 unsigned OptLevel /*unused*/) {
4040 // Tell this ModuleProvide to materialize and release the module
4141 if (!MP->materializeModule(ErrStr))
4242 // We got an error, just return 0
107107 /// create - Create an interpreter ExecutionEngine. This can never fail.
108108 ///
109109 static ExecutionEngine *create(ModuleProvider *M, std::string *ErrorStr = 0,
110 bool Fast /*unused*/ = 0);
110 unsigned OptLevel /*unused*/ = 3);
111111
112112 /// run - Start execution with the specified function and arguments.
113113 ///
195195 ExecutionEngine *ExecutionEngine::createJIT(ModuleProvider *MP,
196196 std::string *ErrorStr,
197197 JITMemoryManager *JMM,
198 bool Fast) {
199 ExecutionEngine *EE = JIT::createJIT(MP, ErrorStr, JMM, Fast);
198 unsigned OptLevel) {
199 ExecutionEngine *EE = JIT::createJIT(MP, ErrorStr, JMM, OptLevel);
200200 if (!EE) return 0;
201201
202202 // Make sure we can resolve symbols in the program as well. The zero arg
206206 }
207207
208208 JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
209 JITMemoryManager *JMM, bool Fast)
209 JITMemoryManager *JMM, unsigned OptLevel)
210210 : ExecutionEngine(MP), TM(tm), TJI(tji) {
211211 setTargetData(TM.getTargetData());
212212
222222
223223 // Turn the machine code intermediate representation into bytes in memory that
224224 // may be executed.
225 if (TM.addPassesToEmitMachineCode(PM, *MCE, Fast)) {
225 if (TM.addPassesToEmitMachineCode(PM, *MCE, OptLevel)) {
226226 cerr << "Target does not support machine code emission!\n";
227227 abort();
228228 }
271271
272272 // Turn the machine code intermediate representation into bytes in memory
273273 // that may be executed.
274 if (TM.addPassesToEmitMachineCode(PM, *MCE, false /*fast*/)) {
274 if (TM.addPassesToEmitMachineCode(PM, *MCE, 3 /* OptLevel */)) {
275275 cerr << "Target does not support machine code emission!\n";
276276 abort();
277277 }
304304
305305 // Turn the machine code intermediate representation into bytes in memory
306306 // that may be executed.
307 if (TM.addPassesToEmitMachineCode(PM, *MCE, false /*fast*/)) {
307 if (TM.addPassesToEmitMachineCode(PM, *MCE, 3 /* OptLevel */)) {
308308 cerr << "Target does not support machine code emission!\n";
309309 abort();
310310 }
336336
337337 // Turn the machine code intermediate representation into bytes in memory
338338 // that may be executed.
339 if (TM.addPassesToEmitMachineCode(PM, *MCE, false /*fast*/)) {
339 if (TM.addPassesToEmitMachineCode(PM, *MCE, 3 /* OptLevel */)) {
340340 cerr << "Target does not support machine code emission!\n";
341341 abort();
342342 }
5454 JITState *jitstate;
5555
5656 JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
57 JITMemoryManager *JMM, bool Fast);
57 JITMemoryManager *JMM, unsigned OptLevel);
5858 public:
5959 ~JIT();
6060
7070 /// for the current target. Otherwise, return null.
7171 ///
7272 static ExecutionEngine *create(ModuleProvider *MP, std::string *Err,
73 bool Fast = false) {
74 return createJIT(MP, Err, 0, Fast);
73 unsigned OptLevel = 3) {
74 return createJIT(MP, Err, 0, OptLevel);
7575 }
7676
7777 virtual void addModuleProvider(ModuleProvider *MP);
147147 MachineCodeEmitter *getCodeEmitter() const { return MCE; }
148148
149149 static ExecutionEngine *createJIT(ModuleProvider *MP, std::string *Err,
150 JITMemoryManager *JMM, bool Fast);
150 JITMemoryManager *JMM, unsigned OptLevel);
151151
152152 private:
153153 static MachineCodeEmitter *createEmitter(JIT &J, JITMemoryManager *JMM);
4141 /// available for the current target. Otherwise, return null.
4242 ///
4343 ExecutionEngine *JIT::createJIT(ModuleProvider *MP, std::string *ErrorStr,
44 JITMemoryManager *JMM, bool Fast) {
44 JITMemoryManager *JMM, unsigned OptLevel) {
4545 const TargetMachineRegistry::entry *TheArch = MArch;
4646 if (TheArch == 0) {
4747 std::string Error;
7373
7474 // If the target supports JIT code generation, return a new JIT now.
7575 if (TargetJITInfo *TJ = Target->getJITInfo())
76 return new JIT(MP, *Target, *TJ, JMM, Fast);
76 return new JIT(MP, *Target, *TJ, JMM, OptLevel);
7777
7878 if (ErrorStr)
7979 *ErrorStr = "target does not support JIT code generation";