• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/StringRef.h"
21 
22 namespace llvm {
23 
24 class PassInfo;
25 struct PassRegistrationListener;
26 
27 /// PassRegistry - This class manages the registration and intitialization of
28 /// the pass subsystem as application startup, and assists the PassManager
29 /// in resolving pass dependencies.
30 /// NOTE: PassRegistry is NOT thread-safe.  If you want to use LLVM on multiple
31 /// threads simultaneously, you will need to use a separate PassRegistry on
32 /// each thread.
33 class PassRegistry {
34   mutable void *pImpl;
35   void *getImpl() const;
36 
37 public:
PassRegistry()38   PassRegistry() : pImpl(0) { }
39   ~PassRegistry();
40 
41   /// getPassRegistry - Access the global registry object, which is
42   /// automatically initialized at application launch and destroyed by
43   /// llvm_shutdown.
44   static PassRegistry *getPassRegistry();
45 
46   /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
47   /// type identifier (&MyPass::ID).
48   const PassInfo *getPassInfo(const void *TI) const;
49 
50   /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
51   /// argument string.
52   const PassInfo *getPassInfo(StringRef Arg) const;
53 
54   /// registerPass - Register a pass (by means of its PassInfo) with the
55   /// registry.  Required in order to use the pass with a PassManager.
56   void registerPass(const PassInfo &PI, bool ShouldFree = false);
57 
58   /// registerPass - Unregister a pass (by means of its PassInfo) with the
59   /// registry.
60   void unregisterPass(const PassInfo &PI);
61 
62   /// registerAnalysisGroup - Register an analysis group (or a pass implementing
63   // an analysis group) with the registry.  Like registerPass, this is required
64   // in order for a PassManager to be able to use this group/pass.
65   void registerAnalysisGroup(const void *InterfaceID, const void *PassID,
66                              PassInfo& Registeree, bool isDefault,
67                              bool ShouldFree = false);
68 
69   /// enumerateWith - Enumerate the registered passes, calling the provided
70   /// PassRegistrationListener's passEnumerate() callback on each of them.
71   void enumerateWith(PassRegistrationListener *L);
72 
73   /// addRegistrationListener - Register the given PassRegistrationListener
74   /// to receive passRegistered() callbacks whenever a new pass is registered.
75   void addRegistrationListener(PassRegistrationListener *L);
76 
77   /// removeRegistrationListener - Unregister a PassRegistrationListener so that
78   /// it no longer receives passRegistered() callbacks.
79   void removeRegistrationListener(PassRegistrationListener *L);
80 };
81 
82 }
83 
84 #endif
85