From 4e0cc51d7974029aa2bbffce08e2c878f529f98a Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Mon, 28 Apr 2014 18:19:25 +0000 Subject: [PM] Add pass run listeners to the pass manager. This commit provides the necessary C/C++ APIs and infastructure to enable fine- grain progress report and safe suspension points after each pass in the pass manager. Clients can provide a callback function to the pass manager to call after each pass. This can be used in a variety of ways (progress report, dumping of IR between passes, safe suspension of threads, etc). The run listener list is maintained in the LLVMContext, which allows a multi- threaded client to be only informed for it's own thread. This of course assumes that the client created a LLVMContext for each thread. This fixes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207430 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'include/llvm-c/Core.h') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index df2de2441a..f7121a5c61 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -112,12 +112,23 @@ typedef struct LLVMOpaqueBuilder *LLVMBuilderRef; */ typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef; +/** @see llvm::Pass */ +typedef struct LLVMOpaquePass *LLVMPassRef; + /** @see llvm::PassManagerBase */ typedef struct LLVMOpaquePassManager *LLVMPassManagerRef; /** @see llvm::PassRegistry */ typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef; +/** @see llvm::PassRunListener */ +typedef struct LLVMOpaquePassRunListener *LLVMPassRunListenerRef; + +/** @see llvm::LLVMPassRunListener */ +typedef void (*LLVMPassRunListenerHandlerTy)(LLVMContextRef, LLVMPassRef, + LLVMModuleRef, LLVMValueRef, + LLVMBasicBlockRef); + /** * Used to get the users and usees of a Value. * @@ -515,6 +526,10 @@ unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name, unsigned SLen); unsigned LLVMGetMDKindID(const char* Name, unsigned SLen); +LLVMPassRunListenerRef LLVMAddPassRunListener(LLVMContextRef, + LLVMPassRunListenerHandlerTy); +void LLVMRemovePassRunListener(LLVMContextRef, LLVMPassRunListenerRef); + /** * @} */ @@ -2759,6 +2774,18 @@ const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf); size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf); void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); +/** + * @} + */ + +/** + * @defgroup LLVMCCorePass Pass + * + * @{ + */ + +const char *LLVMGetPassName(LLVMPassRef); + /** * @} */ -- cgit v1.2.3