LLVM API Documentation
00001 //===- llvm/PassRegistry.h - Pass Information Registry ----------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines PassRegistry, a class that is used in the initialization 00011 // and registration of passes. At application startup, passes are registered 00012 // with the PassRegistry, which is later provided to the PassManager for 00013 // dependency resolution and similar tasks. 00014 // 00015 //===----------------------------------------------------------------------===// 00016 00017 #ifndef LLVM_PASSREGISTRY_H 00018 #define LLVM_PASSREGISTRY_H 00019 00020 #include "llvm/ADT/StringRef.h" 00021 #include "llvm/Support/CBindingWrapping.h" 00022 #include "llvm-c/Core.h" 00023 00024 namespace llvm { 00025 00026 class PassInfo; 00027 struct PassRegistrationListener; 00028 00029 /// PassRegistry - This class manages the registration and intitialization of 00030 /// the pass subsystem as application startup, and assists the PassManager 00031 /// in resolving pass dependencies. 00032 /// NOTE: PassRegistry is NOT thread-safe. If you want to use LLVM on multiple 00033 /// threads simultaneously, you will need to use a separate PassRegistry on 00034 /// each thread. 00035 class PassRegistry { 00036 mutable void *pImpl; 00037 void *getImpl() const; 00038 00039 public: 00040 PassRegistry() : pImpl(0) { } 00041 ~PassRegistry(); 00042 00043 /// getPassRegistry - Access the global registry object, which is 00044 /// automatically initialized at application launch and destroyed by 00045 /// llvm_shutdown. 00046 static PassRegistry *getPassRegistry(); 00047 00048 /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass' 00049 /// type identifier (&MyPass::ID). 00050 const PassInfo *getPassInfo(const void *TI) const; 00051 00052 /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass' 00053 /// argument string. 00054 const PassInfo *getPassInfo(StringRef Arg) const; 00055 00056 /// registerPass - Register a pass (by means of its PassInfo) with the 00057 /// registry. Required in order to use the pass with a PassManager. 00058 void registerPass(const PassInfo &PI, bool ShouldFree = false); 00059 00060 /// registerPass - Unregister a pass (by means of its PassInfo) with the 00061 /// registry. 00062 void unregisterPass(const PassInfo &PI); 00063 00064 /// registerAnalysisGroup - Register an analysis group (or a pass implementing 00065 // an analysis group) with the registry. Like registerPass, this is required 00066 // in order for a PassManager to be able to use this group/pass. 00067 void registerAnalysisGroup(const void *InterfaceID, const void *PassID, 00068 PassInfo& Registeree, bool isDefault, 00069 bool ShouldFree = false); 00070 00071 /// enumerateWith - Enumerate the registered passes, calling the provided 00072 /// PassRegistrationListener's passEnumerate() callback on each of them. 00073 void enumerateWith(PassRegistrationListener *L); 00074 00075 /// addRegistrationListener - Register the given PassRegistrationListener 00076 /// to receive passRegistered() callbacks whenever a new pass is registered. 00077 void addRegistrationListener(PassRegistrationListener *L); 00078 00079 /// removeRegistrationListener - Unregister a PassRegistrationListener so that 00080 /// it no longer receives passRegistered() callbacks. 00081 void removeRegistrationListener(PassRegistrationListener *L); 00082 }; 00083 00084 // Create wrappers for C Binding types (see CBindingWrapping.h). 00085 DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef) 00086 00087 } 00088 00089 #endif