//===- llvm/PassSupport.h - Pass Support code -------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
// This file defines stuff that is used to define and "use" Passes. This file
// is automatically #included by Pass.h, so:
// No need to include Pass.h, we are being included by it!
+namespace llvm {
+
class TargetMachine;
//===---------------------------------------------------------------------------
void registerPass(PassInfo *);
void unregisterPass(PassInfo *);
- /// setPreservesCFG - Notice that this pass only depends on the CFG, so
+ /// setOnlyUsesCFG - Notice that this pass only depends on the CFG, so
/// transformations that do not modify the CFG do not invalidate this pass.
///
- void setPreservesCFG();
+ void setOnlyUsesCFG();
};
template<typename PassName>
///
template<typename PassName>
struct RegisterOpt : public RegisterPassBase {
- RegisterOpt(const char *PassArg, const char *Name) {
+ RegisterOpt(const char *PassArg, const char *Name, bool CFGOnly = false) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Optimization,
callDefaultCtor<PassName>));
+ if (CFGOnly) setOnlyUsesCFG();
}
/// Register Pass using default constructor explicitly...
///
- RegisterOpt(const char *PassArg, const char *Name, Pass *(*ctor)()) {
+ RegisterOpt(const char *PassArg, const char *Name, Pass *(*ctor)(),
+ bool CFGOnly = false) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Optimization, ctor));
+ if (CFGOnly) setOnlyUsesCFG();
+ }
+
+ /// Register FunctionPass using default constructor explicitly...
+ ///
+ RegisterOpt(const char *PassArg, const char *Name, FunctionPass *(*ctor)(),
+ bool CFGOnly = false) {
+ registerPass(new PassInfo(Name, PassArg, typeid(PassName),
+ PassInfo::Optimization,
+ static_cast<Pass*(*)()>(ctor)));
+ if (CFGOnly) setOnlyUsesCFG();
}
/// Register Pass using TargetMachine constructor...
///
RegisterOpt(const char *PassArg, const char *Name,
- Pass *(*targetctor)(TargetMachine &)) {
+ Pass *(*targetctor)(TargetMachine &), bool CFGOnly = false) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Optimization, 0, targetctor));
+ if (CFGOnly) setOnlyUsesCFG();
+ }
+
+ /// Register FunctionPass using TargetMachine constructor...
+ ///
+ RegisterOpt(const char *PassArg, const char *Name,
+ FunctionPass *(*targetctor)(TargetMachine &),
+ bool CFGOnly = false) {
+ registerPass(new PassInfo(Name, PassArg, typeid(PassName),
+ PassInfo::Optimization, 0,
+ static_cast<Pass*(*)(TargetMachine&)>(targetctor)));
+ if (CFGOnly) setOnlyUsesCFG();
}
};
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Analysis,
callDefaultCtor<PassName>));
- if (CFGOnly)
- setPreservesCFG();
+ if (CFGOnly) setOnlyUsesCFG();
}
};
struct IncludeFile {
IncludeFile(void *);
};
+
+} // End llvm namespace
+
#endif