aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-10-12 19:48:12 +0000
committerOwen Anderson <resistor@mac.com>2010-10-12 19:48:12 +0000
commit2ab36d350293c77fc8941ce1023e4899df7e3a82 (patch)
tree3d927ef6d1022512fda69b1ac7d010a9bee3a0ce /include
parent52b45056b2dc9246f732aa9cf655b6b2cb355c93 (diff)
downloadexternal_llvm-2ab36d350293c77fc8941ce1023e4899df7e3a82.zip
external_llvm-2ab36d350293c77fc8941ce1023e4899df7e3a82.tar.gz
external_llvm-2ab36d350293c77fc8941ce1023e4899df7e3a82.tar.bz2
Begin adding static dependence information to passes, which will allow us to
perform initialization without static constructors AND without explicit initialization by the client. For the moment, passes are required to initialize both their (potential) dependencies and any passes they preserve. I hope to be able to relax the latter requirement in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116334 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/PassSupport.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h
index 37010ed..006fefa 100644
--- a/include/llvm/PassSupport.h
+++ b/include/llvm/PassSupport.h
@@ -130,12 +130,32 @@ private:
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
+ static bool initialized = false; \
+ if (initialized) return; \
+ initialized = true; \
+ PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
+ PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
+ Registry.registerPass(*PI); \
+ } \
+ static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis);
+
+#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
+ void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
+ static bool initialized = false; \
+ if (initialized) return; \
+ initialized = true;
+
+#define INITIALIZE_PASS_DEPENDENCY(depName) \
+ initialize##depName##Pass(Registry);
+#define INITIALIZE_AG_DEPENDENCY(depName) \
+ initialize##depName##AnalysisGroup(Registry);
+
+#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis) \
PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
Registry.registerPass(*PI); \
} \
static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis);
-
template<typename PassName>
Pass *callDefaultCtor() { return new PassName(); }
@@ -220,6 +240,7 @@ struct RegisterAnalysisGroup : public RegisterAGBase {
#define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
+ initialize##agName##AnalysisGroup(Registry); \
PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
Registry.registerPass(*PI); \
@@ -230,6 +251,21 @@ struct RegisterAnalysisGroup : public RegisterAGBase {
static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis); \
static RegisterAnalysisGroup<agName, def> passName ## _ag(passName ## _info);
+#define INITIALIZE_AG_PASS_BEGIN(passName, agName, arg, n, cfg, analysis, def) \
+ void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
+ initialize##agName##AnalysisGroup(Registry);
+
+#define INITIALIZE_AG_PASS_END(passName, agName, arg, n, cfg, analysis, def) \
+ PassInfo *PI = new PassInfo(n, arg, & passName ::ID, \
+ PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis); \
+ Registry.registerPass(*PI); \
+ \
+ PassInfo *AI = new PassInfo(n, & agName :: ID); \
+ Registry.registerAnalysisGroup(& agName ::ID, & passName ::ID, *AI, def); \
+ } \
+ static RegisterPass<passName> passName ## _info(arg, n, cfg, analysis); \
+ static RegisterAnalysisGroup<agName, def> passName ## _ag(passName ## _info);
+
//===---------------------------------------------------------------------------
/// PassRegistrationListener class - This class is meant to be derived from by
/// clients that are interested in which passes get registered and unregistered