- // Register Pass using default constructor explicitly...
- RegisterOpt(const char *PassArg, const char *Name, Pass *(*ctor)()) {
- registerPass(new PassInfo(Name, PassArg, typeid(PassName),
- PassInfo::Optimization, ctor, 0));
- }
-
- // Register Pass using TargetData constructor...
- RegisterOpt(const char *PassArg, const char *Name,
- Pass *(*datactor)(const TargetData &)) {
- registerPass(new PassInfo(Name, PassArg, typeid(PassName),
- PassInfo::Optimization, 0, datactor));
- }
-};
-
-// RegisterAnalysis - Register something that is to show up in Analysis, this is
-// just a shortcut for specifying RegisterPass... Analyses take a special
-// argument that, when set to true, tells the system that the analysis ONLY
-// depends on the shape of the CFG, so if a transformation preserves the CFG
-// that the analysis is not invalidated.
-//
-template<typename PassName>
-struct RegisterAnalysis : public RegisterPassBase {
- RegisterAnalysis(const char *PassArg, const char *Name,
- bool CFGOnly = false) {
- registerPass(new PassInfo(Name, PassArg, typeid(PassName),
- PassInfo::Analysis,
- callDefaultCtor<PassName>, 0));
- if (CFGOnly)
- setPreservesCFG();
- }
+/// RegisterAnalysisGroup - Register a Pass as a member of an analysis _group_.
+/// Analysis groups are used to define an interface (which need not derive from
+/// Pass) that is required by passes to do their job. Analysis Groups differ
+/// from normal analyses because any available implementation of the group will
+/// be used if it is available.
+///
+/// If no analysis implementing the interface is available, a default
+/// implementation is created and added. A pass registers itself as the default
+/// implementation by specifying 'true' as the third template argument of this
+/// class.
+///
+/// In addition to registering itself as an analysis group member, a pass must
+/// register itself normally as well. Passes may be members of multiple groups
+/// and may still be "required" specifically by name.
+///
+/// The actual interface may also be registered as well (by not specifying the
+/// second template argument). The interface should be registered to associate
+/// a nice name with the interface.
+///
+class RegisterAGBase : public PassInfo {
+ PassInfo *InterfaceInfo;
+ const PassInfo *ImplementationInfo;
+ bool isDefaultImplementation;
+protected:
+ explicit RegisterAGBase(const char *Name,
+ intptr_t InterfaceID,
+ intptr_t PassID = 0,
+ bool isDefault = false);