[llvm-commits] [llvm] r116334 - in /llvm/trunk: include/llvm/ lib/Analysis/ lib/Analysis/IPA/ lib/CodeGen/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/
Andy Trick
atrick at apple.com
Tue Oct 12 14:31:13 PDT 2010
If you want to avoid some of the redundancy and macro ugliness, you might consider this idiom:
#define INITIALIZE_PASS_DEPENDENCY(depName) \
initialize##depName##Pass();
#define INITIALIZE_PASS(passName, args, deps) \
void initialize##passName##Pass() { \
foo(args); \
deps(INITIALIZE_PASS_DEPENDENCY); \
} \
static Foo(args);
....
#define PASS_DEPS(DEP) DEP(ModA) DEP(ModB)
INITIALIZE_PASS(ModC, args, PASS_DEPS)
-Andy
On Oct 12, 2010, at 12:48 PM, Owen Anderson wrote:
> Modified: llvm/trunk/include/llvm/PassSupport.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassSupport.h?rev=116334&r1=116333&r2=116334&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/PassSupport.h (original)
> +++ llvm/trunk/include/llvm/PassSupport.h Tue Oct 12 14:48:12 2010
> @@ -130,12 +130,32 @@
>
> #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);
> -
More information about the llvm-commits
mailing list