1 //===- llvm/PassRegistry.h - Pass Information Registry ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_PASSREGISTRY_H
18 #define LLVM_PASSREGISTRY_H
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/System/DataTypes.h"
22 #include "llvm/System/Mutex.h"
30 struct PassRegistrationListener;
33 /// Guards the contents of this class.
34 mutable sys::SmartMutex<true> Lock;
36 /// PassInfoMap - Keep track of the PassInfo object for each registered pass.
37 typedef std::map<const void*, const PassInfo*> MapType;
40 typedef StringMap<const PassInfo*> StringMapType;
41 StringMapType PassInfoStringMap;
43 /// AnalysisGroupInfo - Keep track of information for each analysis group.
44 struct AnalysisGroupInfo {
45 std::set<const PassInfo *> Implementations;
47 std::map<const PassInfo*, AnalysisGroupInfo> AnalysisGroupInfoMap;
49 std::vector<PassRegistrationListener*> Listeners;
52 static PassRegistry *getPassRegistry();
54 const PassInfo *getPassInfo(const void *TI) const;
55 const PassInfo *getPassInfo(StringRef Arg) const;
57 void registerPass(const PassInfo &PI);
58 void unregisterPass(const PassInfo &PI);
60 /// Analysis Group Mechanisms.
61 void registerAnalysisGroup(const void *InterfaceID, const void *PassID,
62 PassInfo& Registeree, bool isDefault);
64 void enumerateWith(PassRegistrationListener *L);
65 void addRegistrationListener(PassRegistrationListener* L);
66 void removeRegistrationListener(PassRegistrationListener *L);