mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-17 00:50:58 +00:00
[PM] Add a nice low-tech registry of passes as a boring macro expansion
file. This will make it easy to scale up the number of passes supported. Currently, it just supports the function and module transformation passes that were already supported in the opt tool explicitly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206737 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
81549a0a39
commit
a21cd0433e
30
tools/opt/PassRegistry.def
Normal file
30
tools/opt/PassRegistry.def
Normal file
@ -0,0 +1,30 @@
|
||||
//===- PassRegistry.def - Registry of passes --------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file is used as the registry of passes that are part of the core LLVM
|
||||
// libraries. This file describes both transformation passes and analyses
|
||||
// Analyses are registered while transformation passes have names registered
|
||||
// that can be used when providing a textual pass pipeline.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// NOTE: NO INCLUDE GUARD DESIRED!
|
||||
|
||||
#ifndef MODULE_PASS
|
||||
#define MODULE_PASS(NAME, CREATE_PASS)
|
||||
#endif
|
||||
MODULE_PASS("print", PrintModulePass(dbgs()))
|
||||
MODULE_PASS("print-cg", LazyCallGraphPrinterPass(dbgs()))
|
||||
#undef MODULE_PASS
|
||||
|
||||
#ifndef FUNCTION_PASS
|
||||
#define FUNCTION_PASS(NAME, CREATE_PASS)
|
||||
#endif
|
||||
FUNCTION_PASS("print", PrintFunctionPass(dbgs()))
|
||||
#undef FUNCTION_PASS
|
@ -39,19 +39,20 @@ struct NoOpFunctionPass {
|
||||
|
||||
} // End anonymous namespace.
|
||||
|
||||
// FIXME: Factor all of the parsing logic into a .def file that we include
|
||||
// under different macros.
|
||||
static bool isModulePassName(StringRef Name) {
|
||||
if (Name == "no-op-module") return true;
|
||||
if (Name == "print") return true;
|
||||
if (Name == "print-cg") return true;
|
||||
|
||||
#define MODULE_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
|
||||
#include "PassRegistry.def"
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isFunctionPassName(StringRef Name) {
|
||||
if (Name == "no-op-function") return true;
|
||||
if (Name == "print") return true;
|
||||
|
||||
#define FUNCTION_PASS(NAME, CREATE_PASS) if (Name == NAME) return true;
|
||||
#include "PassRegistry.def"
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -61,14 +62,14 @@ static bool parseModulePassName(ModulePassManager &MPM, StringRef Name) {
|
||||
MPM.addPass(NoOpModulePass());
|
||||
return true;
|
||||
}
|
||||
if (Name == "print") {
|
||||
MPM.addPass(PrintModulePass(dbgs()));
|
||||
return true;
|
||||
}
|
||||
if (Name == "print-cg") {
|
||||
MPM.addPass(LazyCallGraphPrinterPass(dbgs()));
|
||||
return true;
|
||||
|
||||
#define MODULE_PASS(NAME, CREATE_PASS) \
|
||||
if (Name == NAME) { \
|
||||
MPM.addPass(CREATE_PASS); \
|
||||
return true; \
|
||||
}
|
||||
#include "PassRegistry.def"
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -77,10 +78,14 @@ static bool parseFunctionPassName(FunctionPassManager &FPM, StringRef Name) {
|
||||
FPM.addPass(NoOpFunctionPass());
|
||||
return true;
|
||||
}
|
||||
if (Name == "print") {
|
||||
FPM.addPass(PrintFunctionPass(dbgs()));
|
||||
return true;
|
||||
|
||||
#define FUNCTION_PASS(NAME, CREATE_PASS) \
|
||||
if (Name == NAME) { \
|
||||
FPM.addPass(CREATE_PASS); \
|
||||
return true; \
|
||||
}
|
||||
#include "PassRegistry.def"
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user