Oops.
[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/PassSupport.h"
21 #include "llvm/ADT/StringMap.h"
22 #include "llvm/System/DataTypes.h"
23 #include "llvm/System/Mutex.h"
24 #include <map>
25 #include <set>
26
27 using namespace llvm;
28
29 namespace llvm {
30
31 class PassRegistry {
32   /// Guards the contents of this class.
33   mutable sys::SmartMutex<true> Lock;
34   
35   /// PassInfoMap - Keep track of the PassInfo object for each registered pass.
36   typedef std::map<intptr_t, const PassInfo*> MapType;
37   MapType PassInfoMap;
38   
39   typedef StringMap<const PassInfo*> StringMapType;
40   StringMapType PassInfoStringMap;
41   
42   /// AnalysisGroupInfo - Keep track of information for each analysis group.
43   struct AnalysisGroupInfo {
44     std::set<const PassInfo *> Implementations;
45   };
46   std::map<const PassInfo*, AnalysisGroupInfo> AnalysisGroupInfoMap;
47
48 public:
49   static PassRegistry *getPassRegistry();
50   
51   const PassInfo *getPassInfo(intptr_t TI) const;
52   const PassInfo *getPassInfo(StringRef Arg) const;
53   
54   void registerPass(const PassInfo &PI);
55   void unregisterPass(const PassInfo &PI);
56   
57   /// Analysis Group Mechanisms.
58   void registerAnalysisGroup(PassInfo *InterfaceInfo,
59                              const PassInfo *ImplementationInfo,
60                              bool isDefault);
61   
62   void enumerateWith(PassRegistrationListener *L);
63 };
64
65 }
66
67 #endif