2007-09-18 05:18:57 +02:00
|
|
|
/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
|
|
|
|
|* *|
|
|
|
|
|* The LLVM Compiler Infrastructure *|
|
|
|
|
|* *|
|
2007-12-29 20:59:42 +01:00
|
|
|
|* This file is distributed under the University of Illinois Open Source *|
|
|
|
|
|* License. See LICENSE.TXT for details. *|
|
2007-09-18 05:18:57 +02:00
|
|
|
|* *|
|
|
|
|
|*===----------------------------------------------------------------------===*|
|
|
|
|
|* *|
|
|
|
|
|* This header declares the C interface to libLLVMCore.a, which implements *|
|
|
|
|
|* the LLVM intermediate representation. *|
|
|
|
|
|* *|
|
|
|
|
|* LLVM uses a polymorphic type hierarchy which C cannot represent, therefore *|
|
|
|
|
|* parameters must be passed as base types. Despite the declared types, most *|
|
|
|
|
|* of the functions provided operate only on branches of the type hierarchy. *|
|
|
|
|
|* The declared parameter names are descriptive and specify which type is *|
|
|
|
|
|* required. Additionally, each type hierarchy is documented along with the *|
|
|
|
|
|* functions that operate upon it. For more detail, refer to LLVM's C++ code. *|
|
|
|
|
|* If in doubt, refer to Core.cpp, which performs paramter downcasts in the *|
|
|
|
|
|* form unwrap<RequiredType>(Param). *|
|
|
|
|
|* *|
|
|
|
|
|* Many exotic languages can interoperate with C code but have a harder time *|
|
|
|
|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|
|
|
|
|* tools written in such languages. *|
|
|
|
|
|* *|
|
2007-10-06 01:59:36 +02:00
|
|
|
|* When included into a C++ source file, also declares 'wrap' and 'unwrap' *|
|
|
|
|
|* helpers to perform opaque reference<-->pointer conversions. These helpers *|
|
|
|
|
|* are shorter and more tightly typed than writing the casts by hand when *|
|
|
|
|
|* authoring bindings. In assert builds, they will do runtime type checking. *|
|
|
|
|
|* *|
|
2007-09-18 05:18:57 +02:00
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
#ifndef LLVM_C_CORE_H
|
|
|
|
#define LLVM_C_CORE_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2007-10-06 01:59:36 +02:00
|
|
|
|
|
|
|
/* Need these includes to support the LLVM 'cast' template for the C++ 'wrap'
|
|
|
|
and 'unwrap' conversion functions. */
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/Support/LLVMBuilder.h"
|
|
|
|
|
2007-09-18 05:18:57 +02:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Opaque types. */
|
2007-12-30 18:46:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The top-level container for all other LLVM Intermediate Representation (IR)
|
|
|
|
* objects. See the llvm::Module class.
|
|
|
|
*/
|
2007-09-18 05:18:57 +02:00
|
|
|
typedef struct LLVMOpaqueModule *LLVMModuleRef;
|
2007-12-30 18:46:33 +01:00
|
|
|
|
|
|
|
/**
|
2008-03-07 20:13:06 +01:00
|
|
|
* Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type
|
|
|
|
* class.
|
2007-12-30 18:46:33 +01:00
|
|
|
*/
|
2007-09-18 05:18:57 +02:00
|
|
|
typedef struct LLVMOpaqueType *LLVMTypeRef;
|
2007-12-30 18:46:33 +01:00
|
|
|
|
|
|
|
/**
|
2008-03-07 20:13:06 +01:00
|
|
|
* When building recursive types using LLVMRefineType, LLVMTypeRef values may
|
|
|
|
* become invalid; use LLVMTypeHandleRef to resolve this problem. See the
|
|
|
|
* llvm::AbstractTypeHolder class.
|
2007-12-30 18:46:33 +01:00
|
|
|
*/
|
2007-10-07 02:13:35 +02:00
|
|
|
typedef struct LLVMOpaqueTypeHandle *LLVMTypeHandleRef;
|
2007-12-30 18:46:33 +01:00
|
|
|
|
2007-09-18 05:18:57 +02:00
|
|
|
typedef struct LLVMOpaqueValue *LLVMValueRef;
|
2007-09-26 22:56:12 +02:00
|
|
|
typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
|
|
|
|
typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
|
2007-12-19 23:30:40 +01:00
|
|
|
|
|
|
|
/* Used to provide a module to JIT or interpreter.
|
|
|
|
* See the llvm::ModuleProvider class.
|
|
|
|
*/
|
2007-12-12 02:04:30 +01:00
|
|
|
typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
|
2007-09-18 05:18:57 +02:00
|
|
|
|
2007-12-19 23:30:40 +01:00
|
|
|
/* Used to provide a module to JIT or interpreter.
|
|
|
|
* See the llvm::MemoryBuffer class.
|
|
|
|
*/
|
|
|
|
typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
|
|
|
|
|
2008-03-16 05:20:44 +01:00
|
|
|
/** See the llvm::PassManagerBase class. */
|
|
|
|
typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
|
|
|
|
|
2007-09-18 05:18:57 +02:00
|
|
|
typedef enum {
|
2007-12-30 18:46:33 +01:00
|
|
|
LLVMVoidTypeKind, /**< type with no size */
|
|
|
|
LLVMFloatTypeKind, /**< 32 bit floating point type */
|
|
|
|
LLVMDoubleTypeKind, /**< 64 bit floating point type */
|
|
|
|
LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
|
|
|
|
LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
|
|
|
|
LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
|
|
|
|
LLVMLabelTypeKind, /**< Labels */
|
|
|
|
LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
|
|
|
|
LLVMFunctionTypeKind, /**< Functions */
|
|
|
|
LLVMStructTypeKind, /**< Structures */
|
|
|
|
LLVMArrayTypeKind, /**< Arrays */
|
|
|
|
LLVMPointerTypeKind, /**< Pointers */
|
|
|
|
LLVMOpaqueTypeKind, /**< Opaque: type with unknown structure */
|
|
|
|
LLVMVectorTypeKind /**< SIMD 'packed' format, or other vector type */
|
2007-09-18 05:18:57 +02:00
|
|
|
} LLVMTypeKind;
|
|
|
|
|
|
|
|
typedef enum {
|
2007-12-30 18:46:33 +01:00
|
|
|
LLVMExternalLinkage, /**< Externally visible function */
|
|
|
|
LLVMLinkOnceLinkage, /**< Keep one copy of function when linking (inline)*/
|
|
|
|
LLVMWeakLinkage, /**< Keep one copy of function when linking (weak) */
|
|
|
|
LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
|
|
|
|
LLVMInternalLinkage, /**< Rename collisions when linking (static
|
|
|
|
functions) */
|
|
|
|
LLVMDLLImportLinkage, /**< Function to be imported from DLL */
|
|
|
|
LLVMDLLExportLinkage, /**< Function to be accessible from DLL */
|
|
|
|
LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
|
|
|
|
LLVMGhostLinkage /**< Stand-in functions for streaming fns from
|
|
|
|
bitcode */
|
2007-09-18 05:18:57 +02:00
|
|
|
} LLVMLinkage;
|
|
|
|
|
|
|
|
typedef enum {
|
2007-12-30 18:46:33 +01:00
|
|
|
LLVMDefaultVisibility, /**< The GV is visible */
|
|
|
|
LLVMHiddenVisibility, /**< The GV is hidden */
|
|
|
|
LLVMProtectedVisibility /**< The GV is protected */
|
2007-09-18 05:18:57 +02:00
|
|
|
} LLVMVisibility;
|
|
|
|
|
2007-09-26 22:56:12 +02:00
|
|
|
typedef enum {
|
|
|
|
LLVMCCallConv = 0,
|
|
|
|
LLVMFastCallConv = 8,
|
|
|
|
LLVMColdCallConv = 9,
|
|
|
|
LLVMX86StdcallCallConv = 64,
|
|
|
|
LLVMX86FastcallCallConv = 65
|
|
|
|
} LLVMCallConv;
|
|
|
|
|
|
|
|
typedef enum {
|
2007-12-30 18:46:33 +01:00
|
|
|
LLVMIntEQ = 32, /**< equal */
|
|
|
|
LLVMIntNE, /**< not equal */
|
|
|
|
LLVMIntUGT, /**< unsigned greater than */
|
|
|
|
LLVMIntUGE, /**< unsigned greater or equal */
|
|
|
|
LLVMIntULT, /**< unsigned less than */
|
|
|
|
LLVMIntULE, /**< unsigned less or equal */
|
|
|
|
LLVMIntSGT, /**< signed greater than */
|
|
|
|
LLVMIntSGE, /**< signed greater or equal */
|
|
|
|
LLVMIntSLT, /**< signed less than */
|
|
|
|
LLVMIntSLE /**< signed less or equal */
|
2007-09-26 22:56:12 +02:00
|
|
|
} LLVMIntPredicate;
|
|
|
|
|
|
|
|
typedef enum {
|
2007-12-30 18:46:33 +01:00
|
|
|
LLVMRealPredicateFalse, /**< Always false (always folded) */
|
|
|
|
LLVMRealOEQ, /**< True if ordered and equal */
|
|
|
|
LLVMRealOGT, /**< True if ordered and greater than */
|
|
|
|
LLVMRealOGE, /**< True if ordered and greater than or equal */
|
|
|
|
LLVMRealOLT, /**< True if ordered and less than */
|
|
|
|
LLVMRealOLE, /**< True if ordered and less than or equal */
|
|
|
|
LLVMRealONE, /**< True if ordered and operands are unequal */
|
|
|
|
LLVMRealORD, /**< True if ordered (no nans) */
|
|
|
|
LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
|
|
|
|
LLVMRealUEQ, /**< True if unordered or equal */
|
|
|
|
LLVMRealUGT, /**< True if unordered or greater than */
|
|
|
|
LLVMRealUGE, /**< True if unordered, greater than, or equal */
|
|
|
|
LLVMRealULT, /**< True if unordered or less than */
|
|
|
|
LLVMRealULE, /**< True if unordered, less than, or equal */
|
|
|
|
LLVMRealUNE, /**< True if unordered or not equal */
|
|
|
|
LLVMRealPredicateTrue /**< Always true (always folded) */
|
2007-09-26 22:56:12 +02:00
|
|
|
} LLVMRealPredicate;
|
|
|
|
|
2007-09-18 05:18:57 +02:00
|
|
|
|
2007-12-19 23:30:40 +01:00
|
|
|
/*===-- Error handling ----------------------------------------------------===*/
|
|
|
|
|
|
|
|
void LLVMDisposeMessage(char *Message);
|
|
|
|
|
|
|
|
|
2007-09-18 05:18:57 +02:00
|
|
|
/*===-- Modules -----------------------------------------------------------===*/
|
|
|
|
|
|
|
|
/* Create and destroy modules. */
|
2008-03-07 20:13:06 +01:00
|
|
|
/** See llvm::Module::Module. */
|
2007-09-18 05:18:57 +02:00
|
|
|
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
|
2008-03-07 20:13:06 +01:00
|
|
|
|
|
|
|
/** See llvm::Module::~Module. */
|
2007-09-18 05:18:57 +02:00
|
|
|
void LLVMDisposeModule(LLVMModuleRef M);
|
|
|
|
|
2008-03-07 20:13:06 +01:00
|
|
|
/** Data layout. See Module::getDataLayout. */
|
2007-12-27 21:13:47 +01:00
|
|
|
const char *LLVMGetDataLayout(LLVMModuleRef M);
|
|
|
|
void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
|
|
|
|
|
2008-03-07 20:13:06 +01:00
|
|
|
/** Target triple. See Module::getTargetTriple. */
|
2007-12-27 21:13:47 +01:00
|
|
|
const char *LLVMGetTarget(LLVMModuleRef M);
|
|
|
|
void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
|
|
|
|
|
2008-03-07 20:13:06 +01:00
|
|
|
/** See Module::addTypeName. */
|
2007-09-18 05:18:57 +02:00
|
|
|
int LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty);
|
2007-09-26 22:56:12 +02:00
|
|
|
void LLVMDeleteTypeName(LLVMModuleRef M, const char *Name);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
2008-03-15 00:58:56 +01:00
|
|
|
/** See Module::dump. */
|
|
|
|
void LLVMDumpModule(LLVMModuleRef M);
|
|
|
|
|
2007-09-18 05:18:57 +02:00
|
|
|
|
2007-09-26 22:56:12 +02:00
|
|
|
/*===-- Types -------------------------------------------------------------===*/
|
2007-09-18 05:18:57 +02:00
|
|
|
|
|
|
|
/* LLVM types conform to the following hierarchy:
|
|
|
|
*
|
|
|
|
* types:
|
|
|
|
* integer type
|
|
|
|
* real type
|
|
|
|
* function type
|
|
|
|
* sequence types:
|
|
|
|
* array type
|
|
|
|
* pointer type
|
|
|
|
* vector type
|
|
|
|
* void type
|
|
|
|
* label type
|
|
|
|
* opaque type
|
|
|
|
*/
|
|
|
|
|
2008-03-07 20:13:06 +01:00
|
|
|
/** See llvm::LLVMTypeKind::getTypeID. */
|
2007-09-18 05:18:57 +02:00
|
|
|
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
|
2008-03-07 20:13:06 +01:00
|
|
|
|
|
|
|
/** See llvm::DerivedType::refineAbstractTypeTo. */
|
2007-09-18 05:18:57 +02:00
|
|
|
void LLVMRefineAbstractType(LLVMTypeRef AbstractType, LLVMTypeRef ConcreteType);
|
|
|
|
|
|
|
|
/* Operations on integer types */
|
|
|
|
LLVMTypeRef LLVMInt1Type();
|
|
|
|
LLVMTypeRef LLVMInt8Type();
|
|
|
|
LLVMTypeRef LLVMInt16Type();
|
|
|
|
LLVMTypeRef LLVMInt32Type();
|
|
|
|
LLVMTypeRef LLVMInt64Type();
|
2007-10-06 18:05:20 +02:00
|
|
|
LLVMTypeRef LLVMIntType(unsigned NumBits);
|
2007-09-26 22:56:12 +02:00
|
|
|
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
|
|
|
/* Operations on real types */
|
|
|
|
LLVMTypeRef LLVMFloatType();
|
|
|
|
LLVMTypeRef LLVMDoubleType();
|
|
|
|
LLVMTypeRef LLVMX86FP80Type();
|
|
|
|
LLVMTypeRef LLVMFP128Type();
|
|
|
|
LLVMTypeRef LLVMPPCFP128Type();
|
|
|
|
|
|
|
|
/* Operations on function types */
|
2007-10-06 18:05:20 +02:00
|
|
|
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
|
|
|
|
LLVMTypeRef *ParamTypes, unsigned ParamCount,
|
|
|
|
int IsVarArg);
|
2007-09-18 05:18:57 +02:00
|
|
|
int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
|
2007-09-26 22:56:12 +02:00
|
|
|
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
|
|
|
|
unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
|
|
|
|
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
|
|
|
/* Operations on struct types */
|
2007-10-06 18:05:20 +02:00
|
|
|
LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
|
|
|
|
int Packed);
|
2007-09-26 22:56:12 +02:00
|
|
|
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
|
2007-09-18 05:18:57 +02:00
|
|
|
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
|
|
|
|
int LLVMIsPackedStruct(LLVMTypeRef StructTy);
|
|
|
|
|
|
|
|
/* Operations on array, pointer, and vector types (sequence types) */
|
2007-10-06 18:05:20 +02:00
|
|
|
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
|
2007-12-17 17:08:32 +01:00
|
|
|
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
|
2007-10-06 18:05:20 +02:00
|
|
|
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
|
|
|
LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
|
|
|
|
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
|
2007-12-17 17:08:32 +01:00
|
|
|
unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
|
2007-09-18 05:18:57 +02:00
|
|
|
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
|
|
|
|
|
|
|
|
/* Operations on other types */
|
|
|
|
LLVMTypeRef LLVMVoidType();
|
|
|
|
LLVMTypeRef LLVMLabelType();
|
2007-10-06 18:05:20 +02:00
|
|
|
LLVMTypeRef LLVMOpaqueType();
|
2007-09-18 05:18:57 +02:00
|
|
|
|
2007-10-07 02:13:35 +02:00
|
|
|
/* Operations on type handles */
|
|
|
|
LLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy);
|
|
|
|
void LLVMRefineType(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy);
|
|
|
|
LLVMTypeRef LLVMResolveTypeHandle(LLVMTypeHandleRef TypeHandle);
|
|
|
|
void LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle);
|
|
|
|
|
2007-09-18 05:18:57 +02:00
|
|
|
|
|
|
|
/*===-- Values ------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
/* The bulk of LLVM's object model consists of values, which comprise a very
|
|
|
|
* rich type hierarchy.
|
|
|
|
*
|
|
|
|
* values:
|
|
|
|
* constants:
|
|
|
|
* scalar constants
|
|
|
|
* composite contants
|
|
|
|
* globals:
|
|
|
|
* global variable
|
|
|
|
* function
|
|
|
|
* alias
|
2007-09-26 22:56:12 +02:00
|
|
|
* basic blocks
|
2007-09-18 05:18:57 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Operations on all values */
|
2007-09-26 22:56:12 +02:00
|
|
|
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
|
2007-09-18 05:18:57 +02:00
|
|
|
const char *LLVMGetValueName(LLVMValueRef Val);
|
|
|
|
void LLVMSetValueName(LLVMValueRef Val, const char *Name);
|
2007-10-06 02:08:49 +02:00
|
|
|
void LLVMDumpValue(LLVMValueRef Val);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
|
|
|
/* Operations on constants of any type */
|
2007-10-06 17:11:06 +02:00
|
|
|
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
|
|
|
|
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */
|
2007-09-18 05:18:57 +02:00
|
|
|
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
|
2007-09-18 20:07:51 +02:00
|
|
|
int LLVMIsConstant(LLVMValueRef Val);
|
2007-09-18 05:18:57 +02:00
|
|
|
int LLVMIsNull(LLVMValueRef Val);
|
2007-09-18 20:07:51 +02:00
|
|
|
int LLVMIsUndef(LLVMValueRef Val);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
|
|
|
/* Operations on scalar constants */
|
2007-10-06 17:11:06 +02:00
|
|
|
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
|
|
|
|
int SignExtend);
|
|
|
|
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
|
2008-02-02 02:07:50 +01:00
|
|
|
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
|
|
|
/* Operations on composite constants */
|
2007-10-06 17:11:06 +02:00
|
|
|
LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
|
|
|
|
int DontNullTerminate);
|
|
|
|
LLVMValueRef LLVMConstArray(LLVMTypeRef ArrayTy,
|
|
|
|
LLVMValueRef *ConstantVals, unsigned Length);
|
|
|
|
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
|
|
|
|
int packed);
|
|
|
|
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
2007-10-06 16:29:36 +02:00
|
|
|
/* Constant expressions */
|
|
|
|
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
|
|
|
|
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
|
|
|
|
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
|
|
|
|
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
|
|
|
|
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
|
|
|
|
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
|
|
|
LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
|
|
|
|
LLVMValueRef *ConstantIndices, unsigned NumIndices);
|
|
|
|
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
|
|
|
LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
|
|
|
|
LLVMValueRef ConstantIfTrue,
|
|
|
|
LLVMValueRef ConstantIfFalse);
|
|
|
|
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
|
|
|
|
LLVMValueRef IndexConstant);
|
|
|
|
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
|
|
|
|
LLVMValueRef ElementValueConstant,
|
|
|
|
LLVMValueRef IndexConstant);
|
|
|
|
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
|
|
|
|
LLVMValueRef VectorBConstant,
|
|
|
|
LLVMValueRef MaskConstant);
|
|
|
|
|
2007-09-18 05:18:57 +02:00
|
|
|
/* Operations on global variables, functions, and aliases (globals) */
|
|
|
|
int LLVMIsDeclaration(LLVMValueRef Global);
|
|
|
|
LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
|
|
|
|
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
|
|
|
|
const char *LLVMGetSection(LLVMValueRef Global);
|
|
|
|
void LLVMSetSection(LLVMValueRef Global, const char *Section);
|
|
|
|
LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
|
|
|
|
void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
|
|
|
|
unsigned LLVMGetAlignment(LLVMValueRef Global);
|
|
|
|
void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes);
|
|
|
|
|
|
|
|
/* Operations on global variables */
|
|
|
|
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
|
2007-10-08 05:45:09 +02:00
|
|
|
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
|
2007-09-18 05:18:57 +02:00
|
|
|
void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
|
|
|
|
int LLVMHasInitializer(LLVMValueRef GlobalVar);
|
|
|
|
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
|
|
|
|
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
|
|
|
|
int LLVMIsThreadLocal(LLVMValueRef GlobalVar);
|
|
|
|
void LLVMSetThreadLocal(LLVMValueRef GlobalVar, int IsThreadLocal);
|
2007-10-07 19:31:42 +02:00
|
|
|
int LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
|
|
|
|
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, int IsConstant);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
2007-09-26 22:56:12 +02:00
|
|
|
/* Operations on functions */
|
|
|
|
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
|
|
|
|
LLVMTypeRef FunctionTy);
|
2007-10-08 05:45:09 +02:00
|
|
|
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
|
2007-09-26 22:56:12 +02:00
|
|
|
void LLVMDeleteFunction(LLVMValueRef Fn);
|
|
|
|
unsigned LLVMCountParams(LLVMValueRef Fn);
|
|
|
|
void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
|
|
|
|
LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
|
|
|
|
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
|
|
|
|
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
|
|
|
|
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
|
2007-12-10 04:18:06 +01:00
|
|
|
const char *LLVMGetCollector(LLVMValueRef Fn);
|
|
|
|
void LLVMSetCollector(LLVMValueRef Fn, const char *Coll);
|
2007-09-26 22:56:12 +02:00
|
|
|
|
|
|
|
/* Operations on basic blocks */
|
|
|
|
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef Bb);
|
|
|
|
int LLVMValueIsBasicBlock(LLVMValueRef Val);
|
|
|
|
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
|
|
|
|
unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
|
|
|
|
void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
|
|
|
|
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
|
|
|
|
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
|
|
|
|
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
|
|
|
|
const char *Name);
|
|
|
|
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
|
|
|
|
|
2007-12-29 21:45:00 +01:00
|
|
|
/* Operations on call sites */
|
|
|
|
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
|
|
|
|
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
|
|
|
|
|
2007-10-08 20:14:39 +02:00
|
|
|
/* Operations on phi nodes */
|
|
|
|
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
|
|
|
|
LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
|
|
|
|
unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
|
|
|
|
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
|
|
|
|
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
|
2007-09-26 22:56:12 +02:00
|
|
|
|
|
|
|
/*===-- Instruction builders ----------------------------------------------===*/
|
|
|
|
|
|
|
|
/* An instruction builder represents a point within a basic block, and is the
|
|
|
|
* exclusive means of building instructions using the C interface.
|
|
|
|
*/
|
|
|
|
|
|
|
|
LLVMBuilderRef LLVMCreateBuilder();
|
|
|
|
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
|
|
|
|
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
|
|
|
|
void LLVMDisposeBuilder(LLVMBuilderRef Builder);
|
|
|
|
|
|
|
|
/* Terminators */
|
|
|
|
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
|
|
|
|
LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
|
|
|
|
LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
|
|
|
|
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
|
|
|
|
LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
|
|
|
|
LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
|
|
|
|
LLVMBasicBlockRef Else, unsigned NumCases);
|
|
|
|
LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
|
|
|
|
LLVMValueRef *Args, unsigned NumArgs,
|
|
|
|
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildUnwind(LLVMBuilderRef);
|
|
|
|
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
|
|
|
|
|
2008-01-01 06:50:53 +01:00
|
|
|
/* Add a case to the switch instruction */
|
|
|
|
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
|
|
|
|
LLVMBasicBlockRef Dest);
|
|
|
|
|
2007-09-26 22:56:12 +02:00
|
|
|
/* Arithmetic */
|
|
|
|
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
|
|
|
|
|
|
|
|
/* Memory */
|
|
|
|
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
|
|
|
|
LLVMValueRef Val, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
|
|
|
|
LLVMValueRef Val, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
|
|
|
|
LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
|
|
|
|
LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
|
|
|
|
LLVMValueRef *Indices, unsigned NumIndices,
|
|
|
|
const char *Name);
|
|
|
|
|
|
|
|
/* Casts */
|
|
|
|
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
|
|
|
|
LLVMTypeRef DestTy, const char *Name);
|
|
|
|
|
|
|
|
/* Comparisons */
|
|
|
|
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
|
|
|
|
LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
|
|
|
|
LLVMValueRef LHS, LLVMValueRef RHS,
|
|
|
|
const char *Name);
|
|
|
|
|
|
|
|
/* Miscellaneous instructions */
|
|
|
|
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
|
|
|
|
LLVMValueRef *Args, unsigned NumArgs,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
|
|
|
|
LLVMValueRef Then, LLVMValueRef Else,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
|
|
|
|
LLVMValueRef Index, const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
|
|
|
|
LLVMValueRef EltVal, LLVMValueRef Index,
|
|
|
|
const char *Name);
|
|
|
|
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
|
|
|
|
LLVMValueRef V2, LLVMValueRef Mask,
|
|
|
|
const char *Name);
|
2007-09-18 05:18:57 +02:00
|
|
|
|
2007-12-19 23:30:40 +01:00
|
|
|
|
2007-12-12 02:04:30 +01:00
|
|
|
/*===-- Module providers --------------------------------------------------===*/
|
|
|
|
|
|
|
|
/* Encapsulates the module M in a module provider, taking ownership of the
|
|
|
|
* module.
|
|
|
|
* See the constructor llvm::ExistingModuleProvider::ExistingModuleProvider.
|
|
|
|
*/
|
|
|
|
LLVMModuleProviderRef
|
|
|
|
LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
|
|
|
|
|
|
|
|
/* Destroys the module provider MP as well as the contained module.
|
|
|
|
* See the destructor llvm::ModuleProvider::~ModuleProvider.
|
|
|
|
*/
|
|
|
|
void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP);
|
|
|
|
|
2007-12-19 23:30:40 +01:00
|
|
|
|
|
|
|
/*===-- Memory buffers ----------------------------------------------------===*/
|
|
|
|
|
|
|
|
int LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
|
|
|
|
LLVMMemoryBufferRef *OutMemBuf,
|
|
|
|
char **OutMessage);
|
|
|
|
int LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
|
|
|
|
char **OutMessage);
|
|
|
|
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
|
|
|
|
|
2008-03-16 05:20:44 +01:00
|
|
|
|
|
|
|
/*===-- Pass Managers -----------------------------------------------------===*/
|
|
|
|
|
|
|
|
/** Constructs a new whole-module pass pipeline. This type of pipeline is
|
|
|
|
suitable for link-time optimization and whole-module transformations.
|
|
|
|
See llvm::PassManager::PassManager. */
|
|
|
|
LLVMPassManagerRef LLVMCreatePassManager();
|
|
|
|
|
|
|
|
/** Constructs a new function-by-function pass pipeline over the module
|
|
|
|
provider. It does not take ownership of the module provider. This type of
|
|
|
|
pipeline is suitable for code generation and JIT compilation tasks.
|
|
|
|
See llvm::FunctionPassManager::FunctionPassManager. */
|
|
|
|
LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
|
|
|
|
|
|
|
|
/** Initializes, executes on the provided module, and finalizes all of the
|
|
|
|
passes scheduled in the pass manager. Returns 1 if any of the passes
|
|
|
|
modified the module, 0 otherwise. See llvm::PassManager::run(Module&). */
|
|
|
|
int LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
|
|
|
|
|
|
|
|
/** Initializes all of the function passes scheduled in the function pass
|
|
|
|
manager. Returns 1 if any of the passes modified the module, 0 otherwise.
|
|
|
|
See llvm::FunctionPassManager::doInitialization. */
|
|
|
|
int LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
|
|
|
|
|
|
|
|
/** Executes all of the function passes scheduled in the function pass manager
|
|
|
|
on the provided function. Returns 1 if any of the passes modified the
|
|
|
|
function, false otherwise.
|
|
|
|
See llvm::FunctionPassManager::run(Function&). */
|
|
|
|
int LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
|
|
|
|
|
|
|
|
/** Finalizes all of the function passes scheduled in in the function pass
|
|
|
|
manager. Returns 1 if any of the passes modified the module, 0 otherwise.
|
|
|
|
See llvm::FunctionPassManager::doFinalization. */
|
|
|
|
int LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
|
|
|
|
|
|
|
|
/** Frees the memory of a pass pipeline. For function pipelines, does not free
|
|
|
|
the module provider.
|
|
|
|
See llvm::PassManagerBase::~PassManagerBase. */
|
|
|
|
void LLVMDisposePassManager(LLVMPassManagerRef PM);
|
|
|
|
|
|
|
|
|
2007-09-18 05:18:57 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
|
2007-10-06 01:59:36 +02:00
|
|
|
namespace llvm {
|
2007-12-12 02:04:30 +01:00
|
|
|
class ModuleProvider;
|
2007-12-19 23:30:40 +01:00
|
|
|
class MemoryBuffer;
|
2008-03-16 16:55:43 +01:00
|
|
|
class PassManagerBase;
|
2007-12-12 02:04:30 +01:00
|
|
|
|
2007-12-19 23:30:40 +01:00
|
|
|
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
|
|
|
|
inline ty *unwrap(ref P) { \
|
|
|
|
return reinterpret_cast<ty*>(P); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
inline ref wrap(const ty *P) { \
|
|
|
|
return reinterpret_cast<ref>(const_cast<ty*>(P)); \
|
|
|
|
}
|
2007-10-06 01:59:36 +02:00
|
|
|
|
2008-03-16 05:20:44 +01:00
|
|
|
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
|
|
|
|
\
|
|
|
|
template<typename T> \
|
|
|
|
inline T *unwrap(ref P) { \
|
|
|
|
return cast<T>(unwrap(P)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
|
|
|
|
\
|
|
|
|
template<typename T> \
|
|
|
|
inline T *unwrap(ref P) { \
|
|
|
|
T *Q = dynamic_cast<T*>(unwrap(P)); \
|
|
|
|
assert(Q && "Invalid cast!"); \
|
|
|
|
return Q; \
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef )
|
|
|
|
DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef )
|
2007-12-27 19:25:59 +01:00
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef )
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef )
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMFoldingBuilder, LLVMBuilderRef )
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef )
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef)
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef )
|
2008-03-16 05:20:44 +01:00
|
|
|
DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef )
|
2007-10-06 01:59:36 +02:00
|
|
|
|
2008-03-16 05:20:44 +01:00
|
|
|
#undef DEFINE_STDCXX_CONVERSION_FUNCTIONS
|
|
|
|
#undef DEFINE_ISA_CONVERSION_FUNCTIONS
|
2007-12-19 23:30:40 +01:00
|
|
|
#undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
|
2007-10-06 01:59:36 +02:00
|
|
|
|
2007-12-19 23:30:40 +01:00
|
|
|
/* Specialized opaque type conversions.
|
|
|
|
*/
|
2007-10-06 01:59:36 +02:00
|
|
|
inline Type **unwrap(LLVMTypeRef* Tys) {
|
|
|
|
return reinterpret_cast<Type**>(Tys);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline LLVMTypeRef *wrap(const Type **Tys) {
|
|
|
|
return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
|
|
|
|
}
|
|
|
|
|
2007-12-19 23:30:40 +01:00
|
|
|
/* Specialized opaque value conversions.
|
2007-10-06 01:59:36 +02:00
|
|
|
*/
|
|
|
|
inline Value **unwrap(LLVMValueRef *Vals) {
|
|
|
|
return reinterpret_cast<Value**>(Vals);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
|
|
|
|
#if DEBUG
|
|
|
|
for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I)
|
|
|
|
cast<T>(*I);
|
|
|
|
#endif
|
|
|
|
return reinterpret_cast<T**>(Vals);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline LLVMValueRef *wrap(const Value **Vals) {
|
|
|
|
return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !defined(__cplusplus) */
|
|
|
|
|
|
|
|
#endif /* !defined(LLVM_C_CORE_H) */
|