LLVM  10.0.0svn
PassRegistry.h
Go to the documentation of this file.
1 //===- llvm/PassRegistry.h - Pass Information Registry ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines PassRegistry, a class that is used in the initialization
10 // and registration of passes. At application startup, passes are registered
11 // with the PassRegistry, which is later provided to the PassManager for
12 // dependency resolution and similar tasks.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_PASSREGISTRY_H
17 #define LLVM_PASSREGISTRY_H
18 
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Support/RWMutex.h"
24 #include <memory>
25 #include <vector>
26 
27 namespace llvm {
28 
29 class PassInfo;
30 struct PassRegistrationListener;
31 
32 /// PassRegistry - This class manages the registration and intitialization of
33 /// the pass subsystem as application startup, and assists the PassManager
34 /// in resolving pass dependencies.
35 /// NOTE: PassRegistry is NOT thread-safe. If you want to use LLVM on multiple
36 /// threads simultaneously, you will need to use a separate PassRegistry on
37 /// each thread.
38 class PassRegistry {
39  mutable sys::SmartRWMutex<true> Lock;
40 
41  /// PassInfoMap - Keep track of the PassInfo object for each registered pass.
43  MapType PassInfoMap;
44 
46  StringMapType PassInfoStringMap;
47 
48  std::vector<std::unique_ptr<const PassInfo>> ToFree;
49  std::vector<PassRegistrationListener *> Listeners;
50 
51 public:
52  PassRegistry() = default;
53  ~PassRegistry();
54 
55  /// getPassRegistry - Access the global registry object, which is
56  /// automatically initialized at application launch and destroyed by
57  /// llvm_shutdown.
58  static PassRegistry *getPassRegistry();
59 
60  /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
61  /// type identifier (&MyPass::ID).
62  const PassInfo *getPassInfo(const void *TI) const;
63 
64  /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
65  /// argument string.
66  const PassInfo *getPassInfo(StringRef Arg) const;
67 
68  /// registerPass - Register a pass (by means of its PassInfo) with the
69  /// registry. Required in order to use the pass with a PassManager.
70  void registerPass(const PassInfo &PI, bool ShouldFree = false);
71 
72  /// registerAnalysisGroup - Register an analysis group (or a pass implementing
73  // an analysis group) with the registry. Like registerPass, this is required
74  // in order for a PassManager to be able to use this group/pass.
75  void registerAnalysisGroup(const void *InterfaceID, const void *PassID,
76  PassInfo &Registeree, bool isDefault,
77  bool ShouldFree = false);
78 
79  /// enumerateWith - Enumerate the registered passes, calling the provided
80  /// PassRegistrationListener's passEnumerate() callback on each of them.
82 
83  /// addRegistrationListener - Register the given PassRegistrationListener
84  /// to receive passRegistered() callbacks whenever a new pass is registered.
86 
87  /// removeRegistrationListener - Unregister a PassRegistrationListener so that
88  /// it no longer receives passRegistered() callbacks.
90 };
91 
92 // Create wrappers for C Binding types (see CBindingWrapping.h).
94 
95 } // end namespace llvm
96 
97 #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:23
#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...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
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:30
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:242
PassRegistrationListener class - This class is meant to be derived from by clients that are intereste...
Definition: PassSupport.h:196
PassRegistry()=default
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:38
void registerPass(const PassInfo &PI, bool ShouldFree=false)
registerPass - Register a pass (by means of its PassInfo) with the registry.