Move the smarts of AnalysisGroup registration into PassRegistry.
[oota-llvm.git] / include / llvm / PassRegistry.h
1 //===- llvm/PassRegistry.h - Pass Information Registry ----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines PassRegistry, a class that is used in the initialization
11 // and registration of passes.  At initialization, passes are registered with
12 // the PassRegistry, which is later provided to the PassManager for dependency
13 // resolution and similar tasks.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_PASSREGISTRY_H
18 #define LLVM_PASSREGISTRY_H
19
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/System/DataTypes.h"
22 #include "llvm/System/Mutex.h"
23 #include <map>
24 #include <set>
25 #include <vector>
26
27 namespace llvm {
28
29 class PassInfo;
30 struct PassRegistrationListener;
31
32 class PassRegistry {
33   /// Guards the contents of this class.
34   mutable sys::SmartMutex<true> Lock;
35   
36   /// PassInfoMap - Keep track of the PassInfo object for each registered pass.
37   typedef std::map<intptr_t, const PassInfo*> MapType;
38   MapType PassInfoMap;
39   
40   typedef StringMap<const PassInfo*> StringMapType;
41   StringMapType PassInfoStringMap;
42   
43   /// AnalysisGroupInfo - Keep track of information for each analysis group.
44   struct AnalysisGroupInfo {
45     std::set<const PassInfo *> Implementations;
46   };
47   std::map<const PassInfo*, AnalysisGroupInfo> AnalysisGroupInfoMap;
48   
49   std::vector<PassRegistrationListener*> Listeners;
50
51 public:
52   static PassRegistry *getPassRegistry();
53   
54   const PassInfo *getPassInfo(intptr_t TI) const;
55   const PassInfo *getPassInfo(StringRef Arg) const;
56   
57   void registerPass(const PassInfo &PI);
58   void unregisterPass(const PassInfo &PI);
59   
60   /// Analysis Group Mechanisms.
61   void registerAnalysisGroup(intptr_t InterfaceID, intptr_t PassID,
62                              PassInfo& Registeree, bool isDefault);
63   
64   void enumerateWith(PassRegistrationListener *L);
65   void addRegistrationListener(PassRegistrationListener* L);
66   void removeRegistrationListener(PassRegistrationListener *L);
67 };
68
69 }
70
71 #endif