llvm.org GIT mirror llvm / 9ce88db
Add target analysis passes to the codegen pipeline for MCJIT. This patch adds the target analysis passes (usually TargetTransformInfo) to the codgen pipeline. We also expose now the AddAnalysisPasses method through the C API, because the optimizer passes would also benefit from better target-specific cost models. Reviewed by Andrew Kaylor git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199926 91177308-0d34-0410-b5e6-96231b3b80d8 Juergen Ributzka 6 years ago
10 changed file(s) with 30 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
460460 virtual void setObjectCache(ObjectCache *) {
461461 llvm_unreachable("No support for an object cache");
462462 }
463
464 /// Return the target machine (if available).
465 virtual TargetMachine *getTargetMachine() { return NULL; }
463466
464467 /// DisableLazyCompilation - When lazy compilation is off (the default), the
465468 /// JIT will eagerly compile every function reachable from the argument to
162162 LLVMValueRef Fn);
163163
164164 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
165 LLVMTargetMachineRef
166 LLVMGetExecutionEngineTargetMachine(LLVMExecutionEngineRef EE);
165167
166168 void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
167169 void* Addr);
136136 disposed with LLVMDisposeMessage. */
137137 char* LLVMGetDefaultTargetTriple(void);
138138
139 /** Adds the target-specific analysis passes to the pass manager. */
140 void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM);
141
139142 #ifdef __cplusplus
140143 }
141144 #endif
9191 bool DisableVerify,
9292 AnalysisID StartAfter,
9393 AnalysisID StopAfter) {
94 // Add internal analysis passes from the target machine.
95 TM->addAnalysisPasses(PM);
96
9497 // Targets may override createPassConfig to provide a target-specific sublass.
9598 TargetPassConfig *PassConfig = TM->createPassConfig(PM);
9699 PassConfig->setStartStopPasses(StartAfter, StopAfter);
4040 inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) {
4141 TargetLibraryInfo *X = const_cast(P);
4242 return reinterpret_cast(X);
43 }
44
45 inline LLVMTargetMachineRef wrap(const TargetMachine *P) {
46 return
47 reinterpret_cast(const_cast(P));
4348 }
4449
4550 /*===-- Operations on generic values --------------------------------------===*/
322327 return wrap(unwrap(EE)->getDataLayout());
323328 }
324329
330 LLVMTargetMachineRef
331 LLVMGetExecutionEngineTargetMachine(LLVMExecutionEngineRef EE) {
332 return wrap(unwrap(EE)->getTargetMachine());
333 }
334
325335 void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
326336 void* Addr) {
327337 unwrap(EE)->addGlobalMapping(unwrap(Global), Addr);
192192
193193 virtual void RegisterJITEventListener(JITEventListener *L);
194194 virtual void UnregisterJITEventListener(JITEventListener *L);
195
196 virtual TargetMachine *getTargetMachine() { return &TM; }
197
195198 /// These functions correspond to the methods on JITEventListener. They
196199 /// iterate over the registered listeners and call the corresponding method on
197200 /// each.
300300 virtual uint64_t getGlobalValueAddress(const std::string &Name);
301301 virtual uint64_t getFunctionAddress(const std::string &Name);
302302
303 virtual TargetMachine *getTargetMachine() { return TM; }
304
303305 /// @}
304306 /// @name (Private) Registration Interfaces
305307 /// @{
497497 PassManager codeGenPasses;
498498
499499 codeGenPasses.add(new DataLayout(*TargetMach->getDataLayout()));
500 TargetMach->addAnalysisPasses(codeGenPasses);
501500
502501 formatted_raw_ostream Out(out);
503502
266266 char *LLVMGetDefaultTargetTriple(void) {
267267 return strdup(sys::getDefaultTargetTriple().c_str());
268268 }
269
270 void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM) {
271 unwrap(T)->addAnalysisPasses(*unwrap(PM));
272 }
318318 TLI->disableAllFunctions();
319319 PM.add(TLI);
320320
321 // Add intenal analysis passes from the target machine.
322 Target.addAnalysisPasses(PM);
323
324321 // Add the target data from the target machine, if it exists, or the module.
325322 if (const DataLayout *TD = Target.getDataLayout())
326323 PM.add(new DataLayout(*TD));