//===- 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!
-class TargetData;
+namespace llvm {
+
class TargetMachine;
//===---------------------------------------------------------------------------
std::vector<const PassInfo*> ItfImpl;// Interfaces implemented by this pass
Pass *(*NormalCtor)(); // No argument ctor
- Pass *(*DataCtor)(const TargetData&);// Ctor taking const TargetData object...
Pass *(*TargetCtor)(TargetMachine&); // Ctor taking TargetMachine object...
public:
/// through RegisterPass.
PassInfo(const char *name, const char *arg, const std::type_info &ti,
unsigned pt, Pass *(*normal)() = 0,
- Pass *(*datactor)(const TargetData &) = 0,
Pass *(*targetctor)(TargetMachine &) = 0)
: PassName(name), PassArgument(arg), TypeInfo(ti), PassType(pt),
- NormalCtor(normal), DataCtor(datactor), TargetCtor(targetctor) {
+ NormalCtor(normal), TargetCtor(targetctor) {
}
/// getPassName - Return the friendly name for the pass, never returns null
return NormalCtor();
}
- /// getDataCtor - Return a pointer to a function that creates an instance of
- /// the pass and returns it. This returns a constructor for a version of the
- /// pass that takes a TargetData object as a parameter.
- ///
- Pass *(*getDataCtor() const)(const TargetData &) {
- return DataCtor;
- }
-
/// getTargetCtor - Return a pointer to a function that creates an instance of
/// the pass and returns it. This returns a constructor for a version of the
/// pass that takes a TargetMachine object as a parameter.
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>
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy, ctor));
}
- // Register Pass using TargetData constructor...
- RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
- Pass *(*datactor)(const TargetData &)) {
- registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
- 0, datactor));
- }
-
// Register Pass using TargetMachine constructor...
RegisterPass(const char *PassArg, const char *Name, unsigned PassTy,
Pass *(*targetctor)(TargetMachine &)) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName), PassTy,
- 0, 0, targetctor));
+ 0, targetctor));
}
// Generic constructor version that has an unknown ctor type...
///
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 Pass using TargetData constructor...
+ /// Register FunctionPass using default constructor explicitly...
///
- RegisterOpt(const char *PassArg, const char *Name,
- Pass *(*datactor)(const TargetData &)) {
+ RegisterOpt(const char *PassArg, const char *Name, FunctionPass *(*ctor)(),
+ bool CFGOnly = false) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
- PassInfo::Optimization, 0, datactor));
+ 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, 0, targetctor));
+ 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();
}
};
PassInfo::LLC, ctor));
}
- /// Register Pass using TargetData constructor...
- ///
- RegisterLLC(const char *PassArg, const char *Name,
- Pass *(*datactor)(const TargetData &)) {
- registerPass(new PassInfo(Name, PassArg, typeid(PassName),
- PassInfo::LLC, 0, datactor));
- }
-
/// Register Pass using TargetMachine constructor...
///
RegisterLLC(const char *PassArg, const char *Name,
struct IncludeFile {
IncludeFile(void *);
};
+
+} // End llvm namespace
+
#endif