LLVM 19.0.0git
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 <memory>
24#include <vector>
25
26namespace llvm {
27
28class PassInfo;
29struct PassRegistrationListener;
30
31/// PassRegistry - This class manages the registration and intitialization of
32/// the pass subsystem as application startup, and assists the PassManager
33/// in resolving pass dependencies.
34/// NOTE: PassRegistry is NOT thread-safe. If you want to use LLVM on multiple
35/// threads simultaneously, you will need to use a separate PassRegistry on
36/// each thread.
38 mutable sys::SmartRWMutex<true> Lock;
39
40 /// PassInfoMap - Keep track of the PassInfo object for each registered pass.
42 MapType PassInfoMap;
43
45 StringMapType PassInfoStringMap;
46
47 std::vector<std::unique_ptr<const PassInfo>> ToFree;
48 std::vector<PassRegistrationListener *> Listeners;
49
50public:
51 PassRegistry() = default;
53
54 /// getPassRegistry - Access the global registry object, which is
55 /// automatically initialized at application launch and destroyed by
56 /// llvm_shutdown.
58
59 /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
60 /// type identifier (&MyPass::ID).
61 const PassInfo *getPassInfo(const void *TI) const;
62
63 /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
64 /// argument string.
65 const PassInfo *getPassInfo(StringRef Arg) const;
66
67 /// registerPass - Register a pass (by means of its PassInfo) with the
68 /// registry. Required in order to use the pass with a PassManager.
69 void registerPass(const PassInfo &PI, bool ShouldFree = false);
70
71 /// registerAnalysisGroup - Register an analysis group (or a pass implementing
72 // an analysis group) with the registry. Like registerPass, this is required
73 // in order for a PassManager to be able to use this group/pass.
74 void registerAnalysisGroup(const void *InterfaceID, const void *PassID,
75 PassInfo &Registeree, bool isDefault,
76 bool ShouldFree = false);
77
78 /// enumerateWith - Enumerate the registered passes, calling the provided
79 /// PassRegistrationListener's passEnumerate() callback on each of them.
81
82 /// addRegistrationListener - Register the given PassRegistrationListener
83 /// to receive passRegistered() callbacks whenever a new pass is registered.
85
86 /// removeRegistrationListener - Unregister a PassRegistrationListener so that
87 /// it no longer receives passRegistered() callbacks.
89};
90
91} // end namespace llvm
92
93#endif // LLVM_PASSREGISTRY_H
This file defines the StringMap class.
This file defines the DenseMap class.
PassInfo class - An instance of this class exists for every pass known by the system,...
Definition: PassInfo.h:30
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:37
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void addRegistrationListener(PassRegistrationListener *L)
addRegistrationListener - Register the given PassRegistrationListener to receive passRegistered() cal...
void removeRegistrationListener(PassRegistrationListener *L)
removeRegistrationListener - Unregister a PassRegistrationListener so that it no longer receives pass...
void registerPass(const PassInfo &PI, bool ShouldFree=false)
registerPass - Register a pass (by means of its PassInfo) with the registry.
void enumerateWith(PassRegistrationListener *L)
enumerateWith - Enumerate the registered passes, calling the provided PassRegistrationListener's pass...
const PassInfo * getPassInfo(const void *TI) const
getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass' type identifier (&MyPass::...
PassRegistry()=default
void registerAnalysisGroup(const void *InterfaceID, const void *PassID, PassInfo &Registeree, bool isDefault, bool ShouldFree=false)
registerAnalysisGroup - Register an analysis group (or a pass implementing
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
SmartMutex - An R/W mutex with a compile time constant parameter that indicates whether this mutex sh...
Definition: RWMutex.h:91
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
PassRegistrationListener class - This class is meant to be derived from by clients that are intereste...
Definition: PassSupport.h:215