mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-21 03:32:21 +00:00
Add support for passes that use a TargetMachine object.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3748 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
504fc5b7b5
commit
a081baac77
@ -33,7 +33,8 @@ class PassInfo {
|
|||||||
std::vector<const PassInfo*> ItfImpl;// Interfaces implemented by this pass
|
std::vector<const PassInfo*> ItfImpl;// Interfaces implemented by this pass
|
||||||
|
|
||||||
Pass *(*NormalCtor)(); // No argument ctor
|
Pass *(*NormalCtor)(); // No argument ctor
|
||||||
Pass *(*DataCtor)(const TargetData&);// Ctor taking TargetData object...
|
Pass *(*DataCtor)(const TargetData&);// Ctor taking const TargetData object...
|
||||||
|
Pass *(*TargetCtor)(TargetMachine&); // Ctor taking TargetMachine object...
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// PassType - Define symbolic constants that can be used to test to see if
|
/// PassType - Define symbolic constants that can be used to test to see if
|
||||||
@ -48,9 +49,11 @@ public:
|
|||||||
/// PassInfo ctor - Do not call this directly, this should only be invoked
|
/// PassInfo ctor - Do not call this directly, this should only be invoked
|
||||||
/// through RegisterPass.
|
/// through RegisterPass.
|
||||||
PassInfo(const char *name, const char *arg, const std::type_info &ti,
|
PassInfo(const char *name, const char *arg, const std::type_info &ti,
|
||||||
unsigned pt, Pass *(*normal)(), Pass *(*data)(const TargetData &))
|
unsigned pt, Pass *(*normal)() = 0,
|
||||||
|
Pass *(*datactor)(const TargetData &) = 0,
|
||||||
|
Pass *(*targetctor)(TargetMachine &) = 0)
|
||||||
: PassName(name), PassArgument(arg), TypeInfo(ti), PassType(pt),
|
: PassName(name), PassArgument(arg), TypeInfo(ti), PassType(pt),
|
||||||
NormalCtor(normal), DataCtor(data) {
|
NormalCtor(normal), DataCtor(datactor), TargetCtor(targetctor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getPassName - Return the friendly name for the pass, never returns null
|
/// getPassName - Return the friendly name for the pass, never returns null
|
||||||
@ -96,12 +99,20 @@ public:
|
|||||||
|
|
||||||
/// getDataCtor - Return a pointer to a function that creates an instance of
|
/// getDataCtor - Return a pointer to a function that creates an instance of
|
||||||
/// the pass and returns it. This returns a constructor for a version of the
|
/// the pass and returns it. This returns a constructor for a version of the
|
||||||
/// pass that takes a TArgetData object as a parameter.
|
/// pass that takes a TargetData object as a parameter.
|
||||||
///
|
///
|
||||||
Pass *(*getDataCtor() const)(const TargetData &) {
|
Pass *(*getDataCtor() const)(const TargetData &) {
|
||||||
return DataCtor;
|
return DataCtor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getTargetCtor - Return a pointer to a function that creates an instance of
|
||||||
|
/// the pass and returns it. This returns a constructor for a version of the
|
||||||
|
/// pass that takes a TargetMachine object as a parameter.
|
||||||
|
///
|
||||||
|
Pass *(*getTargetCtor() const)(TargetMachine &) {
|
||||||
|
return TargetCtor;
|
||||||
|
}
|
||||||
|
|
||||||
/// addInterfaceImplemented - This method is called when this pass is
|
/// addInterfaceImplemented - This method is called when this pass is
|
||||||
/// registered as a member of an analysis group with the RegisterAnalysisGroup
|
/// registered as a member of an analysis group with the RegisterAnalysisGroup
|
||||||
/// template.
|
/// template.
|
||||||
@ -167,13 +178,13 @@ struct RegisterPass : public RegisterPassBase {
|
|||||||
// Register Pass using default constructor...
|
// Register Pass using default constructor...
|
||||||
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy = 0) {
|
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy = 0) {
|
||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
|
||||||
callDefaultCtor<PassName>, 0));
|
callDefaultCtor<PassName>));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register Pass using default constructor explicitly...
|
// Register Pass using default constructor explicitly...
|
||||||
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
|
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
|
||||||
Pass *(*ctor)()) {
|
Pass *(*ctor)()) {
|
||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, ctor,0));
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, ctor));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register Pass using TargetData constructor...
|
// Register Pass using TargetData constructor...
|
||||||
@ -183,11 +194,18 @@ struct RegisterPass : public RegisterPassBase {
|
|||||||
0, datactor));
|
0, datactor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register Pass using TargetMachine constructor...
|
||||||
|
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
|
||||||
|
Pass *(*targetctor)(TargetMachine &)) {
|
||||||
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
|
||||||
|
0, 0, targetctor));
|
||||||
|
}
|
||||||
|
|
||||||
// Generic constructor version that has an unknown ctor type...
|
// Generic constructor version that has an unknown ctor type...
|
||||||
template<typename CtorType>
|
template<typename CtorType>
|
||||||
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
|
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
|
||||||
CtorType *Fn) {
|
CtorType *Fn) {
|
||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, 0, 0));
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, 0));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -199,14 +217,14 @@ struct RegisterOpt : public RegisterPassBase {
|
|||||||
RegisterOpt(const char *PassArg, const char *Name) {
|
RegisterOpt(const char *PassArg, const char *Name) {
|
||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
||||||
PassInfo::Optimization,
|
PassInfo::Optimization,
|
||||||
callDefaultCtor<PassName>, 0));
|
callDefaultCtor<PassName>));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register Pass using default constructor explicitly...
|
/// Register Pass using default constructor explicitly...
|
||||||
///
|
///
|
||||||
RegisterOpt(const char *PassArg, const char *Name, Pass *(*ctor)()) {
|
RegisterOpt(const char *PassArg, const char *Name, Pass *(*ctor)()) {
|
||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
||||||
PassInfo::Optimization, ctor, 0));
|
PassInfo::Optimization, ctor));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register Pass using TargetData constructor...
|
/// Register Pass using TargetData constructor...
|
||||||
@ -216,6 +234,14 @@ struct RegisterOpt : public RegisterPassBase {
|
|||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
||||||
PassInfo::Optimization, 0, datactor));
|
PassInfo::Optimization, 0, datactor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Register Pass using TargetMachine constructor...
|
||||||
|
///
|
||||||
|
RegisterOpt(const char *PassArg, const char *Name,
|
||||||
|
Pass *(*targetctor)(TargetMachine &)) {
|
||||||
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
||||||
|
PassInfo::Optimization, 0, 0, targetctor));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// RegisterAnalysis - Register something that is to show up in Analysis, this
|
/// RegisterAnalysis - Register something that is to show up in Analysis, this
|
||||||
@ -230,7 +256,7 @@ struct RegisterAnalysis : public RegisterPassBase {
|
|||||||
bool CFGOnly = false) {
|
bool CFGOnly = false) {
|
||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
||||||
PassInfo::Analysis,
|
PassInfo::Analysis,
|
||||||
callDefaultCtor<PassName>, 0));
|
callDefaultCtor<PassName>));
|
||||||
if (CFGOnly)
|
if (CFGOnly)
|
||||||
setPreservesCFG();
|
setPreservesCFG();
|
||||||
}
|
}
|
||||||
@ -244,14 +270,14 @@ struct RegisterLLC : public RegisterPassBase {
|
|||||||
RegisterLLC(const char *PassArg, const char *Name) {
|
RegisterLLC(const char *PassArg, const char *Name) {
|
||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
||||||
PassInfo::LLC,
|
PassInfo::LLC,
|
||||||
callDefaultCtor<PassName>, 0));
|
callDefaultCtor<PassName>));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register Pass using default constructor explicitly...
|
/// Register Pass using default constructor explicitly...
|
||||||
///
|
///
|
||||||
RegisterLLC(const char *PassArg, const char *Name, Pass *(*ctor)()) {
|
RegisterLLC(const char *PassArg, const char *Name, Pass *(*ctor)()) {
|
||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
||||||
PassInfo::LLC, ctor, 0));
|
PassInfo::LLC, ctor));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register Pass using TargetData constructor...
|
/// Register Pass using TargetData constructor...
|
||||||
@ -267,7 +293,7 @@ struct RegisterLLC : public RegisterPassBase {
|
|||||||
RegisterLLC(const char *PassArg, const char *Name,
|
RegisterLLC(const char *PassArg, const char *Name,
|
||||||
Pass *(*datactor)(TargetMachine &)) {
|
Pass *(*datactor)(TargetMachine &)) {
|
||||||
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
|
||||||
PassInfo::LLC, 0, 0));
|
PassInfo::LLC));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user