//===- 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;
//===---------------------------------------------------------------------------
/// PassInfo ctor - Do not call this directly, this should only be invoked
/// through RegisterPass.
PassInfo(const char *name, const char *arg, const std::type_info &ti,
- unsigned pt, Pass *(*normal)() = 0,
+ unsigned char pt, Pass *(*normal)() = 0,
Pass *(*targetctor)(TargetMachine &) = 0)
: PassName(name), PassArgument(arg), TypeInfo(ti), PassType(pt),
NormalCtor(normal), TargetCtor(targetctor) {
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>
struct RegisterPass : public RegisterPassBase {
// Register Pass using default constructor...
- RegisterPass(const char *PassArg, const char *Name, unsigned PassTy = 0) {
+ RegisterPass(const char *PassArg, const char *Name, unsigned char PassTy = 0){
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
callDefaultCtor<PassName>));
}
// Register Pass using default constructor explicitly...
- RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
+ RegisterPass(const char *PassArg, const char *Name, unsigned char PassTy,
Pass *(*ctor)()) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, ctor));
}
// Register Pass using TargetMachine constructor...
- RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
+ RegisterPass(const char *PassArg, const char *Name, unsigned char PassTy,
Pass *(*targetctor)(TargetMachine &)) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
0, targetctor));
// Generic constructor version that has an unknown ctor type...
template<typename CtorType>
- RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
+ RegisterPass(const char *PassArg, const char *Name, unsigned char PassTy,
CtorType *Fn) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, 0));
}
///
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