mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-15 19:24:33 +00:00
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
This commit is contained in:
@@ -163,6 +163,8 @@ void *LLVMRecompileAndRelinkFunction(LLVMExecutionEngineRef EE,
|
|||||||
LLVMValueRef Fn);
|
LLVMValueRef Fn);
|
||||||
|
|
||||||
LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
|
LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
|
||||||
|
LLVMTargetMachineRef
|
||||||
|
LLVMGetExecutionEngineTargetMachine(LLVMExecutionEngineRef EE);
|
||||||
|
|
||||||
void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
|
void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
|
||||||
void* Addr);
|
void* Addr);
|
||||||
|
@@ -137,6 +137,9 @@ LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleR
|
|||||||
disposed with LLVMDisposeMessage. */
|
disposed with LLVMDisposeMessage. */
|
||||||
char* LLVMGetDefaultTargetTriple(void);
|
char* LLVMGetDefaultTargetTriple(void);
|
||||||
|
|
||||||
|
/** Adds the target-specific analysis passes to the pass manager. */
|
||||||
|
void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -462,6 +462,9 @@ public:
|
|||||||
llvm_unreachable("No support for an object cache");
|
llvm_unreachable("No support for an object cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the target machine (if available).
|
||||||
|
virtual TargetMachine *getTargetMachine() { return NULL; }
|
||||||
|
|
||||||
/// DisableLazyCompilation - When lazy compilation is off (the default), the
|
/// DisableLazyCompilation - When lazy compilation is off (the default), the
|
||||||
/// JIT will eagerly compile every function reachable from the argument to
|
/// JIT will eagerly compile every function reachable from the argument to
|
||||||
/// getPointerToFunction. If lazy compilation is turned on, the JIT will only
|
/// getPointerToFunction. If lazy compilation is turned on, the JIT will only
|
||||||
|
@@ -92,6 +92,9 @@ static MCContext *addPassesToGenerateCode(LLVMTargetMachine *TM,
|
|||||||
bool DisableVerify,
|
bool DisableVerify,
|
||||||
AnalysisID StartAfter,
|
AnalysisID StartAfter,
|
||||||
AnalysisID StopAfter) {
|
AnalysisID StopAfter) {
|
||||||
|
// Add internal analysis passes from the target machine.
|
||||||
|
TM->addAnalysisPasses(PM);
|
||||||
|
|
||||||
// Targets may override createPassConfig to provide a target-specific sublass.
|
// Targets may override createPassConfig to provide a target-specific sublass.
|
||||||
TargetPassConfig *PassConfig = TM->createPassConfig(PM);
|
TargetPassConfig *PassConfig = TM->createPassConfig(PM);
|
||||||
PassConfig->setStartStopPasses(StartAfter, StopAfter);
|
PassConfig->setStartStopPasses(StartAfter, StopAfter);
|
||||||
|
@@ -43,6 +43,11 @@ inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) {
|
|||||||
return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
|
return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline LLVMTargetMachineRef wrap(const TargetMachine *P) {
|
||||||
|
return
|
||||||
|
reinterpret_cast<LLVMTargetMachineRef>(const_cast<TargetMachine*>(P));
|
||||||
|
}
|
||||||
|
|
||||||
/*===-- Operations on generic values --------------------------------------===*/
|
/*===-- Operations on generic values --------------------------------------===*/
|
||||||
|
|
||||||
LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
|
LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
|
||||||
@@ -323,6 +328,11 @@ LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE) {
|
|||||||
return wrap(unwrap(EE)->getDataLayout());
|
return wrap(unwrap(EE)->getDataLayout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LLVMTargetMachineRef
|
||||||
|
LLVMGetExecutionEngineTargetMachine(LLVMExecutionEngineRef EE) {
|
||||||
|
return wrap(unwrap(EE)->getTargetMachine());
|
||||||
|
}
|
||||||
|
|
||||||
void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
|
void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
|
||||||
void* Addr) {
|
void* Addr) {
|
||||||
unwrap(EE)->addGlobalMapping(unwrap<GlobalValue>(Global), Addr);
|
unwrap(EE)->addGlobalMapping(unwrap<GlobalValue>(Global), Addr);
|
||||||
|
@@ -193,6 +193,9 @@ public:
|
|||||||
|
|
||||||
virtual void RegisterJITEventListener(JITEventListener *L);
|
virtual void RegisterJITEventListener(JITEventListener *L);
|
||||||
virtual void UnregisterJITEventListener(JITEventListener *L);
|
virtual void UnregisterJITEventListener(JITEventListener *L);
|
||||||
|
|
||||||
|
virtual TargetMachine *getTargetMachine() { return &TM; }
|
||||||
|
|
||||||
/// These functions correspond to the methods on JITEventListener. They
|
/// These functions correspond to the methods on JITEventListener. They
|
||||||
/// iterate over the registered listeners and call the corresponding method on
|
/// iterate over the registered listeners and call the corresponding method on
|
||||||
/// each.
|
/// each.
|
||||||
|
@@ -301,6 +301,8 @@ public:
|
|||||||
virtual uint64_t getGlobalValueAddress(const std::string &Name);
|
virtual uint64_t getGlobalValueAddress(const std::string &Name);
|
||||||
virtual uint64_t getFunctionAddress(const std::string &Name);
|
virtual uint64_t getFunctionAddress(const std::string &Name);
|
||||||
|
|
||||||
|
virtual TargetMachine *getTargetMachine() { return TM; }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name (Private) Registration Interfaces
|
/// @name (Private) Registration Interfaces
|
||||||
/// @{
|
/// @{
|
||||||
|
@@ -498,7 +498,6 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
|
|||||||
PassManager codeGenPasses;
|
PassManager codeGenPasses;
|
||||||
|
|
||||||
codeGenPasses.add(new DataLayout(*TargetMach->getDataLayout()));
|
codeGenPasses.add(new DataLayout(*TargetMach->getDataLayout()));
|
||||||
TargetMach->addAnalysisPasses(codeGenPasses);
|
|
||||||
|
|
||||||
formatted_raw_ostream Out(out);
|
formatted_raw_ostream Out(out);
|
||||||
|
|
||||||
|
@@ -267,3 +267,7 @@ LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T,
|
|||||||
char *LLVMGetDefaultTargetTriple(void) {
|
char *LLVMGetDefaultTargetTriple(void) {
|
||||||
return strdup(sys::getDefaultTargetTriple().c_str());
|
return strdup(sys::getDefaultTargetTriple().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM) {
|
||||||
|
unwrap(T)->addAnalysisPasses(*unwrap(PM));
|
||||||
|
}
|
||||||
|
@@ -319,9 +319,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
|||||||
TLI->disableAllFunctions();
|
TLI->disableAllFunctions();
|
||||||
PM.add(TLI);
|
PM.add(TLI);
|
||||||
|
|
||||||
// Add intenal analysis passes from the target machine.
|
|
||||||
Target.addAnalysisPasses(PM);
|
|
||||||
|
|
||||||
// Add the target data from the target machine, if it exists, or the module.
|
// Add the target data from the target machine, if it exists, or the module.
|
||||||
if (const DataLayout *TD = Target.getDataLayout())
|
if (const DataLayout *TD = Target.getDataLayout())
|
||||||
PM.add(new DataLayout(*TD));
|
PM.add(new DataLayout(*TD));
|
||||||
|
Reference in New Issue
Block a user