summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/Passes.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-02-15 03:21:47 +0000
committerAndrew Trick <atrick@apple.com>2012-02-15 03:21:47 +0000
commitc9ce9d23151bd12fdabf04aece025b55c3e6c614 (patch)
treed3adc18b57fbfac05e50bd256a310ccefedfeeff /llvm/lib/CodeGen/Passes.cpp
parent031b38b8b23aef9231674db6ab3e2255d4a443c4 (diff)
downloadbcm5719-llvm-c9ce9d23151bd12fdabf04aece025b55c3e6c614.tar.gz
bcm5719-llvm-c9ce9d23151bd12fdabf04aece025b55c3e6c614.zip
Added TargetPassConfig::disablePass/substitutePass as a general mechanism to override specific passes.
llvm-svn: 150562
Diffstat (limited to 'llvm/lib/CodeGen/Passes.cpp')
-rw-r--r--llvm/lib/CodeGen/Passes.cpp48
1 files changed, 42 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/Passes.cpp b/llvm/lib/CodeGen/Passes.cpp
index 285d5df6346..427e4ac327f 100644
--- a/llvm/lib/CodeGen/Passes.cpp
+++ b/llvm/lib/CodeGen/Passes.cpp
@@ -115,16 +115,34 @@ char TargetPassConfig::ID = 0;
static char NoPassIDAnchor = 0;
char &llvm::NoPassID = NoPassIDAnchor;
+namespace llvm {
+class PassConfigImpl {
+public:
+ // List of passes explicitly substituted by this target. Normally this is
+ // empty, but it is a convenient way to suppress or replace specific passes
+ // that are part of a standard pass pipeline without overridding the entire
+ // pipeline. This mechanism allows target options to inherit a standard pass's
+ // user interface. For example, a target may disable a standard pass by
+ // default by substituting NoPass, and the user may still enable that standard
+ // pass with an explicit command line option.
+ DenseMap<AnalysisID,AnalysisID> TargetPasses;
+};
+} // namespace llvm
+
// Out of line virtual method.
-TargetPassConfig::~TargetPassConfig() {}
+TargetPassConfig::~TargetPassConfig() {
+ delete Impl;
+}
// Out of line constructor provides default values for pass options and
// registers all common codegen passes.
TargetPassConfig::TargetPassConfig(TargetMachine *tm, PassManagerBase &pm)
- : ImmutablePass(ID), TM(tm), PM(pm), Initialized(false),
+ : ImmutablePass(ID), TM(tm), PM(pm), Impl(0), Initialized(false),
DisableVerify(false),
EnableTailMerge(true) {
+ Impl = new PassConfigImpl();
+
// Register all target independent codegen passes to activate their PassIDs,
// including this pass itself.
initializeCodeGen(*PassRegistry::getPassRegistry());
@@ -149,15 +167,33 @@ void TargetPassConfig::setOpt(bool &Opt, bool Val) {
Opt = Val;
}
-void TargetPassConfig::addPass(char &ID) {
- if (&ID == &NoPassID)
- return;
+void TargetPassConfig::substitutePass(char &StandardID, char &TargetID) {
+ Impl->TargetPasses[&StandardID] = &TargetID;
+}
+AnalysisID TargetPassConfig::getPassSubstitution(AnalysisID ID) const {
+ DenseMap<AnalysisID, AnalysisID>::const_iterator
+ I = Impl->TargetPasses.find(ID);
+ if (I == Impl->TargetPasses.end())
+ return ID;
+ return I->second;
+}
+
+/// Add a CodeGen pass at this point in the pipeline after checking for target
+/// and command line overrides.
+AnalysisID TargetPassConfig::addPass(char &ID) {
+ assert(!Initialized && "PassConfig is immutable");
+
+ AnalysisID FinalID = getPassSubstitution(&ID);
// FIXME: check user overrides
- Pass *P = Pass::createPass(ID);
+ if (FinalID == &NoPassID)
+ return FinalID;
+
+ Pass *P = Pass::createPass(FinalID);
if (!P)
llvm_unreachable("Pass ID not registered");
PM.add(P);
+ return FinalID;
}
void TargetPassConfig::printNoVerify(const char *Banner) const {
OpenPOWER on IntegriCloud