1212793Sdim//===- llvm/PassRegistry.h - Pass Information Registry ----------*- C++ -*-===//
2212793Sdim//
3212793Sdim//                     The LLVM Compiler Infrastructure
4212793Sdim//
5212793Sdim// This file is distributed under the University of Illinois Open Source
6212793Sdim// License. See LICENSE.TXT for details.
7212793Sdim//
8212793Sdim//===----------------------------------------------------------------------===//
9212793Sdim//
10212793Sdim// This file defines PassRegistry, a class that is used in the initialization
11218893Sdim// and registration of passes.  At application startup, passes are registered
12218893Sdim// with the PassRegistry, which is later provided to the PassManager for
13218893Sdim// dependency resolution and similar tasks.
14212793Sdim//
15212793Sdim//===----------------------------------------------------------------------===//
16212793Sdim
17212793Sdim#ifndef LLVM_PASSREGISTRY_H
18212793Sdim#define LLVM_PASSREGISTRY_H
19212793Sdim
20218893Sdim#include "llvm/ADT/StringRef.h"
21251662Sdim#include "llvm/Support/CBindingWrapping.h"
22251662Sdim#include "llvm-c/Core.h"
23212793Sdim
24212793Sdimnamespace llvm {
25212793Sdim
26212793Sdimclass PassInfo;
27212793Sdimstruct PassRegistrationListener;
28212793Sdim
29218893Sdim/// PassRegistry - This class manages the registration and intitialization of
30218893Sdim/// the pass subsystem as application startup, and assists the PassManager
31218893Sdim/// in resolving pass dependencies.
32218893Sdim/// NOTE: PassRegistry is NOT thread-safe.  If you want to use LLVM on multiple
33218893Sdim/// threads simultaneously, you will need to use a separate PassRegistry on
34218893Sdim/// each thread.
35212793Sdimclass PassRegistry {
36218893Sdim  mutable void *pImpl;
37218893Sdim  void *getImpl() const;
38218893Sdim
39218893Sdimpublic:
40218893Sdim  PassRegistry() : pImpl(0) { }
41218893Sdim  ~PassRegistry();
42212793Sdim
43218893Sdim  /// getPassRegistry - Access the global registry object, which is
44218893Sdim  /// automatically initialized at application launch and destroyed by
45218893Sdim  /// llvm_shutdown.
46212793Sdim  static PassRegistry *getPassRegistry();
47212793Sdim
48218893Sdim  /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
49218893Sdim  /// type identifier (&MyPass::ID).
50212793Sdim  const PassInfo *getPassInfo(const void *TI) const;
51218893Sdim
52218893Sdim  /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
53218893Sdim  /// argument string.
54212793Sdim  const PassInfo *getPassInfo(StringRef Arg) const;
55212793Sdim
56218893Sdim  /// registerPass - Register a pass (by means of its PassInfo) with the
57218893Sdim  /// registry.  Required in order to use the pass with a PassManager.
58218893Sdim  void registerPass(const PassInfo &PI, bool ShouldFree = false);
59218893Sdim
60218893Sdim  /// registerPass - Unregister a pass (by means of its PassInfo) with the
61218893Sdim  /// registry.
62212793Sdim  void unregisterPass(const PassInfo &PI);
63212793Sdim
64218893Sdim  /// registerAnalysisGroup - Register an analysis group (or a pass implementing
65218893Sdim  // an analysis group) with the registry.  Like registerPass, this is required
66218893Sdim  // in order for a PassManager to be able to use this group/pass.
67212793Sdim  void registerAnalysisGroup(const void *InterfaceID, const void *PassID,
68218893Sdim                             PassInfo& Registeree, bool isDefault,
69218893Sdim                             bool ShouldFree = false);
70212793Sdim
71218893Sdim  /// enumerateWith - Enumerate the registered passes, calling the provided
72218893Sdim  /// PassRegistrationListener's passEnumerate() callback on each of them.
73212793Sdim  void enumerateWith(PassRegistrationListener *L);
74218893Sdim
75218893Sdim  /// addRegistrationListener - Register the given PassRegistrationListener
76218893Sdim  /// to receive passRegistered() callbacks whenever a new pass is registered.
77218893Sdim  void addRegistrationListener(PassRegistrationListener *L);
78218893Sdim
79218893Sdim  /// removeRegistrationListener - Unregister a PassRegistrationListener so that
80218893Sdim  /// it no longer receives passRegistered() callbacks.
81212793Sdim  void removeRegistrationListener(PassRegistrationListener *L);
82212793Sdim};
83212793Sdim
84251662Sdim// Create wrappers for C Binding types (see CBindingWrapping.h).
85251662SdimDEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef)
86251662Sdim
87212793Sdim}
88212793Sdim
89212793Sdim#endif
90