LLVM  8.0.1
PassRegistry.h
Go to the documentation of this file.
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 application startup, passes are registered
12 // with the PassRegistry, which is later provided to the PassManager for
13 // dependency resolution and similar tasks.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_PASSREGISTRY_H
18 #define LLVM_PASSREGISTRY_H
19 
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/StringMap.h"
22 #include "llvm/ADT/StringRef.h"
24 #include "llvm/Support/RWMutex.h"
25 #include <memory>
26 #include <vector>
27 
28 namespace llvm {
29 
30 class PassInfo;
31 struct PassRegistrationListener;
32 
33 /// PassRegistry - This class manages the registration and intitialization of
34 /// the pass subsystem as application startup, and assists the PassManager
35 /// in resolving pass dependencies.
36 /// NOTE: PassRegistry is NOT thread-safe. If you want to use LLVM on multiple
37 /// threads simultaneously, you will need to use a separate PassRegistry on
38 /// each thread.
39 class PassRegistry {
40  mutable sys::SmartRWMutex<true> Lock;
41 
42  /// PassInfoMap - Keep track of the PassInfo object for each registered pass.
44  MapType PassInfoMap;
45 
47  StringMapType PassInfoStringMap;
48 
49  std::vector<std::unique_ptr<const PassInfo>> ToFree;
50  std::vector<PassRegistrationListener *> Listeners;
51 
52 public:
53  PassRegistry() = default;
54  ~PassRegistry();
55 
56  /// getPassRegistry - Access the global registry object, which is
57  /// automatically initialized at application launch and destroyed by
58  /// llvm_shutdown.
59  static PassRegistry *getPassRegistry();
60 
61  /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
62  /// type identifier (&MyPass::ID).
63  const PassInfo *getPassInfo(const void *TI) const;
64 
65  /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
66  /// argument string.
67  const PassInfo *getPassInfo(StringRef Arg) const;
68 
69  /// registerPass - Register a pass (by means of its PassInfo) with the
70  /// registry. Required in order to use the pass with a PassManager.
71  void registerPass(const PassInfo &PI, bool ShouldFree = false);
72 
73  /// registerAnalysisGroup - Register an analysis group (or a pass implementing
74  // an analysis group) with the registry. Like registerPass, this is required
75  // in order for a PassManager to be able to use this group/pass.
76  void registerAnalysisGroup(const void *InterfaceID, const void *PassID,
77  PassInfo &Registeree, bool isDefault,
78  bool ShouldFree = false);
79 
80  /// enumerateWith - Enumerate the registered passes, calling the provided
81  /// PassRegistrationListener's passEnumerate() callback on each of them.
83 
84  /// addRegistrationListener - Register the given PassRegistrationListener
85  /// to receive passRegistered() callbacks whenever a new pass is registered.
87 
88  /// removeRegistrationListener - Unregister a PassRegistrationListener so that
89  /// it no longer receives passRegistered() callbacks.
91 };
92 
93 // Create wrappers for C Binding types (see CBindingWrapping.h).
95 
96 } // end namespace llvm
97 
98 #endif // LLVM_PASSREGISTRY_H
const PassInfo * getPassInfo(const void *TI) const
getPassInfo - Look up a pass&#39; corresponding PassInfo, indexed by the pass&#39; type identifier (&MyPass::...
void registerAnalysisGroup(const void *InterfaceID, const void *PassID, PassInfo &Registeree, bool isDefault, bool ShouldFree=false)
registerAnalysisGroup - Register an analysis group (or a pass implementing
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void enumerateWith(PassRegistrationListener *L)
enumerateWith - Enumerate the registered passes, calling the provided PassRegistrationListener&#39;s pass...
This class represents lattice values for constants.
Definition: AllocatorList.h:24
#define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref)
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: Types.h:131
void removeRegistrationListener(PassRegistrationListener *L)
removeRegistrationListener - Unregister a PassRegistrationListener so that it no longer receives pass...
void addRegistrationListener(PassRegistrationListener *L)
addRegistrationListener - Register the given PassRegistrationListener to receive passRegistered() cal...
PassInfo class - An instance of this class exists for every pass known by the system, and can be obtained from a live Pass by calling its getPassInfo() method.
Definition: PassInfo.h:31
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:220
amdgpu Simplify well known AMD library false Value Value * Arg
PassRegistrationListener class - This class is meant to be derived from by clients that are intereste...
Definition: PassSupport.h:197
PassRegistry()=default
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:39
void registerPass(const PassInfo &PI, bool ShouldFree=false)
registerPass - Register a pass (by means of its PassInfo) with the registry.