[PM] Add pass run listeners to the pass manager.
[oota-llvm.git] / include / llvm-c / Core.h
index 269869ef0da755fd7c311707ca28cca8feeab44e..f7121a5c61a069f82104bfd234122612bcea6d22 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef LLVM_C_CORE_H
 #define LLVM_C_CORE_H
 
-#include "llvm/Support/DataTypes.h"
+#include "llvm-c/Support.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -62,8 +62,6 @@ extern "C" {
  * @{
  */
 
-typedef int LLVMBool;
-
 /* Opaque types. */
 
 /**
@@ -114,12 +112,8 @@ typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
  */
 typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
 
-/**
- * Used to provide a module to JIT or interpreter.
- *
- * @see llvm::MemoryBuffer
- */
-typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
+/** @see llvm::Pass */
+typedef struct LLVMOpaquePass *LLVMPassRef;
 
 /** @see llvm::PassManagerBase */
 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
@@ -127,12 +121,26 @@ 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.
  *
  * @see llvm::Use */
 typedef struct LLVMOpaqueUse *LLVMUseRef;
 
+
+/**
+ * @see llvm::DiagnosticInfo
+ */
+typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef;
+
 typedef enum {
     LLVMZExtAttribute       = 1<<0,
     LLVMSExtAttribute       = 1<<1,
@@ -284,8 +292,8 @@ typedef enum {
   LLVMInternalLinkage,    /**< Rename collisions when linking (static
                                functions) */
   LLVMPrivateLinkage,     /**< Like Internal, but omit from symbol table */
-  LLVMDLLImportLinkage,   /**< Function to be imported from DLL */
-  LLVMDLLExportLinkage,   /**< Function to be accessible from DLL */
+  LLVMDLLImportLinkage,   /**< Obsolete */
+  LLVMDLLExportLinkage,   /**< Obsolete */
   LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
   LLVMGhostLinkage,       /**< Obsolete */
   LLVMCommonLinkage,      /**< Tentative definitions */
@@ -299,6 +307,12 @@ typedef enum {
   LLVMProtectedVisibility /**< The GV is protected */
 } LLVMVisibility;
 
+typedef enum {
+  LLVMDefaultStorageClass   = 0,
+  LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
+  LLVMDLLExportStorageClass = 2  /**< Function to be accessible from DLL. */
+} LLVMDLLStorageClass;
+
 typedef enum {
   LLVMCCallConv           = 0,
   LLVMFastCallConv        = 8,
@@ -403,6 +417,13 @@ typedef enum {
                              the old one */
 } LLVMAtomicRMWBinOp;
 
+typedef enum {
+    LLVMDSError,
+    LLVMDSWarning,
+    LLVMDSRemark,
+    LLVMDSNote
+} LLVMDiagnosticSeverity;
+
 /**
  * @}
  */
@@ -456,6 +477,8 @@ void LLVMEnablePrettyStackTrace(void);
  * @{
  */
 
+typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
+
 /**
  * Create a new context.
  *
@@ -469,6 +492,13 @@ LLVMContextRef LLVMContextCreate(void);
  */
 LLVMContextRef LLVMGetGlobalContext(void);
 
+/**
+ * Set the diagnostic handler for this context.
+ */
+void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
+                                     LLVMDiagnosticHandler Handler,
+                                     void *DiagnosticContext);
+
 /**
  * Destroy a context instance.
  *
@@ -477,10 +507,29 @@ LLVMContextRef LLVMGetGlobalContext(void);
  */
 void LLVMContextDispose(LLVMContextRef C);
 
+/**
+ * Return a string representation of the DiagnosticInfo. Use
+ * LLVMDisposeMessage to free the string.
+ *
+ * @see DiagnosticInfo::print()
+ */
+char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
+
+/**
+ * Return an enum LLVMDiagnosticSeverity.
+ *
+ * @see DiagnosticInfo::getSeverity()
+ */
+LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
+
 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,
                                   unsigned SLen);
 unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
 
+LLVMPassRunListenerRef LLVMAddPassRunListener(LLVMContextRef,
+                                              LLVMPassRunListenerHandlerTy);
+void LLVMRemovePassRunListener(LLVMContextRef, LLVMPassRunListenerRef);
+
 /**
  * @}
  */
@@ -1689,6 +1738,10 @@ const char *LLVMGetSection(LLVMValueRef Global);
 void LLVMSetSection(LLVMValueRef Global, const char *Section);
 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
+LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
+void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
+LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
+void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
 
 /**
  * @defgroup LLVMCCoreValueWithAlignment Values with alignment
@@ -1699,6 +1752,7 @@ void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
 
 /**
  * Obtain the preferred alignment of the value.
+ * @see llvm::AllocaInst::getAlignment()
  * @see llvm::LoadInst::getAlignment()
  * @see llvm::StoreInst::getAlignment()
  * @see llvm::GlobalValue::getAlignment()
@@ -1707,6 +1761,7 @@ unsigned LLVMGetAlignment(LLVMValueRef V);
 
 /**
  * Set the preferred alignment of the value.
+ * @see llvm::AllocaInst::setAlignment()
  * @see llvm::LoadInst::setAlignment()
  * @see llvm::StoreInst::setAlignment()
  * @see llvm::GlobalValue::setAlignment()
@@ -2719,6 +2774,18 @@ const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
 
+/**
+ * @}
+ */
+
+/**
+ * @defgroup LLVMCCorePass Pass
+ *
+ * @{
+ */
+
+const char *LLVMGetPassName(LLVMPassRef);
+
 /**
  * @}
  */