mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-08-03 04:50:05 +02:00
Committing LLVM binding for D as it currently exists in the SVN repository.
This commit is contained in:
42
tools/binding/llvm/c/Analysis.d
Normal file
42
tools/binding/llvm/c/Analysis.d
Normal file
@@ -0,0 +1,42 @@
|
||||
// Converted to the D programming language by Tomas Lindquist Olsen 2008
|
||||
// Original file header:
|
||||
/*===-- llvm-c/Analysis.h - Analysis Library C Interface --------*- C++ -*-===*\
|
||||
|* *|
|
||||
|* The LLVM Compiler Infrastructure *|
|
||||
|* *|
|
||||
|* This file is distributed under the University of Illinois Open Source *|
|
||||
|* License. See LICENSE.TXT for details. *|
|
||||
|* *|
|
||||
|*===----------------------------------------------------------------------===*|
|
||||
|* *|
|
||||
|* This header declares the C interface to libLLVMAnalysis.a, which *|
|
||||
|* implements various analyses of the LLVM IR. *|
|
||||
|* *|
|
||||
|* 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. *|
|
||||
|* *|
|
||||
\*===----------------------------------------------------------------------===*/
|
||||
|
||||
module llvm.c.Analysis;
|
||||
|
||||
import llvm.c.Core;
|
||||
|
||||
extern(C):
|
||||
|
||||
enum LLVMVerifierFailureAction {
|
||||
AbortProcess, /* verifier will print to stderr and abort() */
|
||||
PrintMessage, /* verifier will print to stderr and return 1 */
|
||||
ReturnStatus /* verifier will just return 1 */
|
||||
}
|
||||
|
||||
|
||||
/* Verifies that a module is valid, taking the specified action if not.
|
||||
Optionally returns a human-readable description of any invalid constructs.
|
||||
OutMessage must be disposed with LLVMDisposeMessage. */
|
||||
int LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
|
||||
char **OutMessage);
|
||||
|
||||
/* Verifies that a single function is valid, taking the specified action. Useful
|
||||
for debugging. */
|
||||
int LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action);
|
||||
38
tools/binding/llvm/c/BitReader.d
Normal file
38
tools/binding/llvm/c/BitReader.d
Normal file
@@ -0,0 +1,38 @@
|
||||
// Converted to the D programming language by Tomas Lindquist Olsen 2008
|
||||
// Original file header:
|
||||
/*===-- llvm-c/BitReader.h - BitReader Library C Interface ------*- C++ -*-===*\
|
||||
|* *|
|
||||
|* The LLVM Compiler Infrastructure *|
|
||||
|* *|
|
||||
|* This file is distributed under the University of Illinois Open Source *|
|
||||
|* License. See LICENSE.TXT for details. *|
|
||||
|* *|
|
||||
|*===----------------------------------------------------------------------===*|
|
||||
|* *|
|
||||
|* This header declares the C interface to libLLVMBitReader.a, which *|
|
||||
|* implements input of the LLVM bitcode format. *|
|
||||
|* *|
|
||||
|* 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. *|
|
||||
|* *|
|
||||
\*===----------------------------------------------------------------------===*/
|
||||
|
||||
module llvm.c.BitReader;
|
||||
|
||||
import llvm.c.Core;
|
||||
|
||||
extern(C):
|
||||
|
||||
/* Builds a module from the bitcode in the specified memory buffer, returning a
|
||||
reference to the module via the OutModule parameter. Returns 0 on success.
|
||||
Optionally returns a human-readable error message via OutMessage. */
|
||||
int LLVMParseBitcode(LLVMMemoryBufferRef MemBuf,
|
||||
LLVMModuleRef *OutModule, char **OutMessage);
|
||||
|
||||
/* Reads a module from the specified path, returning via the OutMP parameter
|
||||
a module provider which performs lazy deserialization. Returns 0 on success.
|
||||
Optionally returns a human-readable error message via OutMessage. */
|
||||
int LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf,
|
||||
LLVMModuleProviderRef *OutMP,
|
||||
char **OutMessage);
|
||||
33
tools/binding/llvm/c/BitWriter.d
Normal file
33
tools/binding/llvm/c/BitWriter.d
Normal file
@@ -0,0 +1,33 @@
|
||||
// Converted to the D programming language by Tomas Lindquist Olsen 2008
|
||||
// Original file header:
|
||||
/*===-- llvm-c/BitWriter.h - BitWriter Library C Interface ------*- C++ -*-===*\
|
||||
|* *|
|
||||
|* The LLVM Compiler Infrastructure *|
|
||||
|* *|
|
||||
|* This file is distributed under the University of Illinois Open Source *|
|
||||
|* License. See LICENSE.TXT for details. *|
|
||||
|* *|
|
||||
|*===----------------------------------------------------------------------===*|
|
||||
|* *|
|
||||
|* This header declares the C interface to libLLVMBitWriter.a, which *|
|
||||
|* implements output of the LLVM bitcode format. *|
|
||||
|* *|
|
||||
|* 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. *|
|
||||
|* *|
|
||||
\*===----------------------------------------------------------------------===*/
|
||||
|
||||
module llvm.c.BitWriter;
|
||||
|
||||
import llvm.c.Core;
|
||||
|
||||
extern(C):
|
||||
|
||||
/*===-- Operations on modules ---------------------------------------------===*/
|
||||
|
||||
/** Writes a module to an open file descriptor. Returns 0 on success. */
|
||||
int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int Handle);
|
||||
|
||||
/** Writes a module to the specified path. Returns 0 on success. */
|
||||
int LLVMWriteBitcodeToFile(LLVMModuleRef M, /*const*/ char *Path);
|
||||
670
tools/binding/llvm/c/Core.d
Normal file
670
tools/binding/llvm/c/Core.d
Normal file
@@ -0,0 +1,670 @@
|
||||
// Converted to the D programming language by Tomas Lindquist Olsen 2008
|
||||
// Original file header:
|
||||
/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
|
||||
|* *|
|
||||
|* The LLVM Compiler Infrastructure *|
|
||||
|* *|
|
||||
|* This file is distributed under the University of Illinois Open Source *|
|
||||
|* License. See LICENSE.TXT for details. *|
|
||||
|* *|
|
||||
|*===----------------------------------------------------------------------===*|
|
||||
|* *|
|
||||
|* 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. *|
|
||||
|* *|
|
||||
|* 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. *|
|
||||
|* *|
|
||||
\*===----------------------------------------------------------------------===*/
|
||||
module llvm.c.Core;
|
||||
|
||||
extern(C):
|
||||
|
||||
/* Opaque types. */
|
||||
|
||||
private
|
||||
{
|
||||
struct LLVM_OpaqueModule {}
|
||||
struct LLVM_OpaqueType {}
|
||||
struct LLVM_OpaqueTypeHandle {}
|
||||
struct LLVM_OpaqueValue {}
|
||||
struct LLVM_OpaqueBasicBlock {}
|
||||
struct LLVM_OpaqueBuilder {}
|
||||
struct LLVM_OpaqueModuleProvider {}
|
||||
struct LLVM_OpaqueMemoryBuffer {}
|
||||
struct LLVM_OpaquePassManager {}
|
||||
}
|
||||
|
||||
/**
|
||||
* The top-level container for all other LLVM Intermediate Representation (IR)
|
||||
* objects. See the llvm::Module class.
|
||||
*/
|
||||
typedef LLVM_OpaqueModule* LLVMModuleRef;
|
||||
|
||||
/**
|
||||
* Each value in the LLVM IR has a type, an instance of [lltype]. See the
|
||||
* llvm::Type class.
|
||||
*/
|
||||
typedef LLVM_OpaqueType* LLVMTypeRef;
|
||||
|
||||
/**
|
||||
* When building recursive types using [refine_type], [lltype] values may become
|
||||
* invalid; use [lltypehandle] to resolve this problem. See the
|
||||
* llvm::AbstractTypeHolder] class.
|
||||
*/
|
||||
typedef LLVM_OpaqueTypeHandle* LLVMTypeHandleRef;
|
||||
|
||||
typedef LLVM_OpaqueValue* LLVMValueRef;
|
||||
typedef LLVM_OpaqueBasicBlock* LLVMBasicBlockRef;
|
||||
typedef LLVM_OpaqueBuilder* LLVMBuilderRef;
|
||||
|
||||
/* Used to provide a module to JIT or interpreter.
|
||||
* See the llvm::ModuleProvider class.
|
||||
*/
|
||||
typedef LLVM_OpaqueModuleProvider* LLVMModuleProviderRef;
|
||||
|
||||
/* Used to provide a module to JIT or interpreter.
|
||||
* See the llvm::MemoryBuffer class.
|
||||
*/
|
||||
typedef LLVM_OpaqueMemoryBuffer* LLVMMemoryBufferRef;
|
||||
|
||||
/** See the llvm::PassManagerBase class. */
|
||||
typedef LLVM_OpaquePassManager* LLVMPassManagerRef;
|
||||
|
||||
enum LLVMParamAttr {
|
||||
ZExt = 1<<0,
|
||||
SExt = 1<<1,
|
||||
NoReturn = 1<<2,
|
||||
InReg = 1<<3,
|
||||
StructRet = 1<<4,
|
||||
NoUnwind = 1<<5,
|
||||
NoAlias = 1<<6,
|
||||
ByVal = 1<<7,
|
||||
Nest = 1<<8,
|
||||
ReadNone = 1<<9,
|
||||
ReadOnly = 1<<10
|
||||
}
|
||||
|
||||
enum LLVMTypeKind {
|
||||
Void, /**< type with no size */
|
||||
Float, /**< 32 bit floating point type */
|
||||
Double, /**< 64 bit floating point type */
|
||||
X86_FP80, /**< 80 bit floating point type (X87) */
|
||||
FP128, /**< 128 bit floating point type (112-bit mantissa)*/
|
||||
PPC_FP128, /**< 128 bit floating point type (two 64-bits) */
|
||||
Label, /**< Labels */
|
||||
Integer, /**< Arbitrary bit width integers */
|
||||
Function, /**< Functions */
|
||||
Struct, /**< Structures */
|
||||
Array, /**< Arrays */
|
||||
Pointer, /**< Pointers */
|
||||
Opaque, /**< Opaque: type with unknown structure */
|
||||
Vector /**< SIMD 'packed' format, or other vector type */
|
||||
}
|
||||
|
||||
enum LLVMLinkage {
|
||||
External, /**< Externally visible function */
|
||||
LinkOnce, /**< Keep one copy of function when linking (inline)*/
|
||||
Weak, /**< Keep one copy of function when linking (weak) */
|
||||
Appending, /**< Special purpose, only applies to global arrays */
|
||||
Internal, /**< Rename collisions when linking (static functions) */
|
||||
DLLImport, /**< Function to be imported from DLL */
|
||||
DLLExport, /**< Function to be accessible from DLL */
|
||||
ExternalWeak,/**< ExternalWeak linkage description */
|
||||
Ghost /**< Stand-in functions for streaming fns from bitcode */
|
||||
}
|
||||
|
||||
enum LLVMVisibility {
|
||||
Default, /**< The GV is visible */
|
||||
Hidden, /**< The GV is hidden */
|
||||
Protected/**< The GV is protected */
|
||||
}
|
||||
|
||||
enum LLVMCallConv {
|
||||
C = 0,
|
||||
Fast = 8,
|
||||
Cold = 9,
|
||||
X86Stdcall = 64,
|
||||
X86Fastcall= 65
|
||||
}
|
||||
|
||||
enum LLVMIntPredicate {
|
||||
EQ = 32, /**< equal */
|
||||
NE, /**< not equal */
|
||||
UGT, /**< uint greater than */
|
||||
UGE, /**< uint greater or equal */
|
||||
ULT, /**< uint less than */
|
||||
ULE, /**< uint less or equal */
|
||||
SGT, /**< signed greater than */
|
||||
SGE, /**< signed greater or equal */
|
||||
SLT, /**< signed less than */
|
||||
SLE /**< signed less or equal */
|
||||
}
|
||||
|
||||
enum LLVMRealPredicate {
|
||||
False, /**< Always false (always folded) */
|
||||
OEQ, /**< True if ordered and equal */
|
||||
OGT, /**< True if ordered and greater than */
|
||||
OGE, /**< True if ordered and greater than or equal */
|
||||
OLT, /**< True if ordered and less than */
|
||||
OLE, /**< True if ordered and less than or equal */
|
||||
ONE, /**< True if ordered and operands are unequal */
|
||||
ORD, /**< True if ordered (no nans) */
|
||||
UNO, /**< True if unordered: isnan(X) | isnan(Y) */
|
||||
UEQ, /**< True if unordered or equal */
|
||||
UGT, /**< True if unordered or greater than */
|
||||
UGE, /**< True if unordered, greater than, or equal */
|
||||
ULT, /**< True if unordered or less than */
|
||||
ULE, /**< True if unordered, less than, or equal */
|
||||
UNE, /**< True if unordered or not equal */
|
||||
True /**< Always true (always folded) */
|
||||
}
|
||||
|
||||
/*===-- Error handling ----------------------------------------------------===*/
|
||||
|
||||
void LLVMDisposeMessage(char *Message);
|
||||
|
||||
|
||||
/*===-- Modules -----------------------------------------------------------===*/
|
||||
|
||||
/* Create and destroy modules. */
|
||||
/** See llvm::Module::Module. */
|
||||
LLVMModuleRef LLVMModuleCreateWithName(/*const*/ char *ModuleID);
|
||||
|
||||
/** See llvm::Module::~Module. */
|
||||
void LLVMDisposeModule(LLVMModuleRef M);
|
||||
|
||||
/** Data layout. See Module::getDataLayout. */
|
||||
/*const*/ char *LLVMGetDataLayout(LLVMModuleRef M);
|
||||
void LLVMSetDataLayout(LLVMModuleRef M, /*const*/ char *Triple);
|
||||
|
||||
/** Target triple. See Module::getTargetTriple. */
|
||||
/*const*/ char *LLVMGetTarget(LLVMModuleRef M);
|
||||
void LLVMSetTarget(LLVMModuleRef M, /*const*/ char *Triple);
|
||||
|
||||
/** See Module::addTypeName. */
|
||||
int LLVMAddTypeName(LLVMModuleRef M, /*const*/ char *Name, LLVMTypeRef Ty);
|
||||
void LLVMDeleteTypeName(LLVMModuleRef M, /*const*/ char *Name);
|
||||
|
||||
/** See Module::dump. */
|
||||
void LLVMDumpModule(LLVMModuleRef M);
|
||||
|
||||
/*===-- Types -------------------------------------------------------------===*/
|
||||
|
||||
/* 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
|
||||
*/
|
||||
|
||||
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
|
||||
void LLVMRefineAbstractType(LLVMTypeRef AbstractType, LLVMTypeRef ConcreteType);
|
||||
|
||||
/* Operations on integer types */
|
||||
LLVMTypeRef LLVMInt1Type();
|
||||
LLVMTypeRef LLVMInt8Type();
|
||||
LLVMTypeRef LLVMInt16Type();
|
||||
LLVMTypeRef LLVMInt32Type();
|
||||
LLVMTypeRef LLVMInt64Type();
|
||||
LLVMTypeRef LLVMIntType(uint NumBits);
|
||||
uint LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
|
||||
|
||||
/* Operations on real types */
|
||||
LLVMTypeRef LLVMFloatType();
|
||||
LLVMTypeRef LLVMDoubleType();
|
||||
LLVMTypeRef LLVMX86FP80Type();
|
||||
LLVMTypeRef LLVMFP128Type();
|
||||
LLVMTypeRef LLVMPPCFP128Type();
|
||||
|
||||
/* Operations on function types */
|
||||
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
|
||||
LLVMTypeRef *ParamTypes, uint ParamCount,
|
||||
int IsVarArg);
|
||||
int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
|
||||
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
|
||||
uint LLVMCountParamTypes(LLVMTypeRef FunctionTy);
|
||||
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
|
||||
|
||||
/* Operations on struct types */
|
||||
LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, uint ElementCount,
|
||||
int Packed);
|
||||
uint LLVMCountStructElementTypes(LLVMTypeRef StructTy);
|
||||
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
|
||||
int LLVMIsPackedStruct(LLVMTypeRef StructTy);
|
||||
|
||||
/* Operations on array, pointer, and vector types (sequence types) */
|
||||
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, uint ElementCount);
|
||||
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, uint AddressSpace);
|
||||
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, uint ElementCount);
|
||||
|
||||
LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
|
||||
uint LLVMGetArrayLength(LLVMTypeRef ArrayTy);
|
||||
uint LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
|
||||
uint LLVMGetVectorSize(LLVMTypeRef VectorTy);
|
||||
|
||||
/* Operations on other types */
|
||||
LLVMTypeRef LLVMVoidType();
|
||||
LLVMTypeRef LLVMLabelType();
|
||||
LLVMTypeRef LLVMOpaqueType();
|
||||
|
||||
/* Operations on type handles */
|
||||
LLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy);
|
||||
void LLVMRefineType(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy);
|
||||
LLVMTypeRef LLVMResolveTypeHandle(LLVMTypeHandleRef TypeHandle);
|
||||
void LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle);
|
||||
|
||||
|
||||
/*===-- 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
|
||||
* basic blocks
|
||||
*/
|
||||
|
||||
/* Operations on all values */
|
||||
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
|
||||
/*const*/ char *LLVMGetValueName(LLVMValueRef Val);
|
||||
void LLVMSetValueName(LLVMValueRef Val, /*const*/ char *Name);
|
||||
void LLVMDumpValue(LLVMValueRef Val);
|
||||
|
||||
/* Operations on constants of any type */
|
||||
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
|
||||
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */
|
||||
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
|
||||
int LLVMIsConstant(LLVMValueRef Val);
|
||||
int LLVMIsNull(LLVMValueRef Val);
|
||||
int LLVMIsUndef(LLVMValueRef Val);
|
||||
|
||||
/* Operations on scalar constants */
|
||||
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, ulong N,
|
||||
int SignExtend);
|
||||
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
|
||||
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, /*const*/ char *Text);
|
||||
|
||||
/* Operations on composite constants */
|
||||
LLVMValueRef LLVMConstString(/*const*/ char *Str, uint Length,
|
||||
int DontNullTerminate);
|
||||
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
|
||||
LLVMValueRef *ConstantVals, uint Length);
|
||||
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, uint Count,
|
||||
int packed);
|
||||
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, uint Size);
|
||||
|
||||
/* 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, uint 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);
|
||||
|
||||
/* Operations on global variables, functions, and aliases (globals) */
|
||||
LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
|
||||
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);
|
||||
uint LLVMGetAlignment(LLVMValueRef Global);
|
||||
void LLVMSetAlignment(LLVMValueRef Global, uint Bytes);
|
||||
|
||||
/* Operations on global variables */
|
||||
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, /*const*/ char *Name);
|
||||
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, /*const*/ char *Name);
|
||||
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
|
||||
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
|
||||
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
|
||||
LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
|
||||
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);
|
||||
int LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
|
||||
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, int IsConstant);
|
||||
|
||||
/* Operations on functions */
|
||||
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, /*const*/ char *Name,
|
||||
LLVMTypeRef FunctionTy);
|
||||
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, /*const*/ char *Name);
|
||||
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
|
||||
LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
|
||||
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
|
||||
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
|
||||
void LLVMDeleteFunction(LLVMValueRef Fn);
|
||||
uint LLVMGetIntrinsicID(LLVMValueRef Fn);
|
||||
uint LLVMGetFunctionCallConv(LLVMValueRef Fn);
|
||||
void LLVMSetFunctionCallConv(LLVMValueRef Fn, uint CC);
|
||||
/*const*/ char *LLVMGetCollector(LLVMValueRef Fn);
|
||||
void LLVMSetCollector(LLVMValueRef Fn, /*const*/ char *Coll);
|
||||
|
||||
/* Operations on parameters */
|
||||
uint LLVMCountParams(LLVMValueRef Fn);
|
||||
void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
|
||||
LLVMValueRef LLVMGetParam(LLVMValueRef Fn, uint Index);
|
||||
LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
|
||||
LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
|
||||
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
|
||||
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
|
||||
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
|
||||
void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr PA);
|
||||
void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr PA);
|
||||
void LLVMSetParamAlignment(LLVMValueRef Arg, uint alignm);
|
||||
|
||||
|
||||
/* Operations on basic blocks */
|
||||
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef Bb);
|
||||
int LLVMValueIsBasicBlock(LLVMValueRef Val);
|
||||
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
|
||||
LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
|
||||
uint LLVMCountBasicBlocks(LLVMValueRef Fn);
|
||||
void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
|
||||
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
|
||||
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
|
||||
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
|
||||
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
|
||||
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
|
||||
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, /*const*/ char *Name);
|
||||
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
|
||||
/*const*/ char *Name);
|
||||
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
|
||||
|
||||
/* Operations on instructions */
|
||||
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
|
||||
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
|
||||
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
|
||||
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
|
||||
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
|
||||
|
||||
/* Operations on call sites */
|
||||
void LLVMSetInstructionCallConv(LLVMValueRef Instr, uint CC);
|
||||
uint LLVMGetInstructionCallConv(LLVMValueRef Instr);
|
||||
void LLVMAddInstrParamAttr(LLVMValueRef Instr, uint index, LLVMParamAttr);
|
||||
void LLVMRemoveInstrParamAttr(LLVMValueRef Instr, uint index,
|
||||
LLVMParamAttr);
|
||||
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, uint index,
|
||||
uint alignm);
|
||||
|
||||
|
||||
/* Operations on phi nodes */
|
||||
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
|
||||
LLVMBasicBlockRef *IncomingBlocks, uint Count);
|
||||
uint LLVMCountIncoming(LLVMValueRef PhiNode);
|
||||
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, uint Index);
|
||||
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, uint Index);
|
||||
|
||||
/*===-- 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 LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
|
||||
LLVMValueRef Instr);
|
||||
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
|
||||
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
|
||||
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
|
||||
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, uint NumCases);
|
||||
LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
|
||||
LLVMValueRef *Args, uint NumArgs,
|
||||
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
|
||||
/*const*/ char *Name);
|
||||
LLVMValueRef LLVMBuildUnwind(LLVMBuilderRef);
|
||||
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
|
||||
|
||||
/* Add a case to the switch instruction */
|
||||
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
|
||||
LLVMBasicBlockRef Dest);
|
||||
|
||||
/* 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, uint 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, uint 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);
|
||||
|
||||
|
||||
/*===-- 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);
|
||||
|
||||
|
||||
/*===-- Memory buffers ----------------------------------------------------===*/
|
||||
|
||||
int LLVMCreateMemoryBufferWithContentsOfFile(/*const*/ char *Path,
|
||||
LLVMMemoryBufferRef *OutMemBuf,
|
||||
char **OutMessage);
|
||||
int LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
|
||||
char **OutMessage);
|
||||
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
|
||||
|
||||
/*===-- 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);
|
||||
94
tools/binding/llvm/c/ExecutionEngine.d
Normal file
94
tools/binding/llvm/c/ExecutionEngine.d
Normal file
@@ -0,0 +1,94 @@
|
||||
// Converted to the D programming language by Tomas Lindquist Olsen 2008
|
||||
// Original file header:
|
||||
/*===-- llvm-c/ExecutionEngine.h - ExecutionEngine Lib C Iface --*- C++ -*-===*\
|
||||
|* *|
|
||||
|* The LLVM Compiler Infrastructure *|
|
||||
|* *|
|
||||
|* This file is distributed under the University of Illinois Open Source *|
|
||||
|* License. See LICENSE.TXT for details. *|
|
||||
|* *|
|
||||
|*===----------------------------------------------------------------------===*|
|
||||
|* *|
|
||||
|* This header declares the C interface to libLLVMExecutionEngine.o, which *|
|
||||
|* implements various analyses of the LLVM IR. *|
|
||||
|* *|
|
||||
|* 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. *|
|
||||
|* *|
|
||||
\*===----------------------------------------------------------------------===*/
|
||||
|
||||
module llvm.c.ExecutionEngine;
|
||||
|
||||
import llvm.c.Core;
|
||||
|
||||
extern(C):
|
||||
|
||||
private
|
||||
{
|
||||
struct LLVM_OpaqueGenericValue {}
|
||||
struct LLVM_OpaqueExecutionEngine {}
|
||||
}
|
||||
|
||||
typedef LLVM_OpaqueGenericValue* LLVMGenericValueRef;
|
||||
typedef LLVM_OpaqueExecutionEngine* LLVMExecutionEngineRef;
|
||||
|
||||
/*===-- Operations on generic values --------------------------------------===*/
|
||||
|
||||
LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
|
||||
ulong N,
|
||||
int IsSigned);
|
||||
|
||||
LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P);
|
||||
|
||||
LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N);
|
||||
|
||||
uint LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef);
|
||||
|
||||
ulong LLVMGenericValueToInt(LLVMGenericValueRef GenVal,
|
||||
int IsSigned);
|
||||
|
||||
void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal);
|
||||
|
||||
double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal);
|
||||
|
||||
void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal);
|
||||
|
||||
/*===-- Operations on execution engines -----------------------------------===*/
|
||||
|
||||
int LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
|
||||
LLVMModuleProviderRef MP,
|
||||
char **OutError);
|
||||
|
||||
int LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
|
||||
LLVMModuleProviderRef MP,
|
||||
char **OutError);
|
||||
|
||||
int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
|
||||
LLVMModuleProviderRef MP,
|
||||
char **OutError);
|
||||
|
||||
void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE);
|
||||
|
||||
void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE);
|
||||
|
||||
void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE);
|
||||
|
||||
int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F,
|
||||
uint ArgC, /*const*/ char * /*const*/ *ArgV,
|
||||
/*const*/ char * /*const*/ *EnvP);
|
||||
|
||||
LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F,
|
||||
uint NumArgs,
|
||||
LLVMGenericValueRef *Args);
|
||||
|
||||
void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);
|
||||
|
||||
void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP);
|
||||
|
||||
int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
|
||||
LLVMModuleProviderRef MP,
|
||||
LLVMModuleRef *OutMod, char **OutError);
|
||||
|
||||
int LLVMFindFunction(LLVMExecutionEngineRef EE, /*const*/ char *Name,
|
||||
LLVMValueRef *OutFn);
|
||||
62
tools/binding/llvm/c/Ext.d
Normal file
62
tools/binding/llvm/c/Ext.d
Normal file
@@ -0,0 +1,62 @@
|
||||
// Written in the D programming language by Tomas Lindquist Olsen 2008
|
||||
// Extensions to the LLVM C interface for the D binding.
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
module llvm.c.Ext;
|
||||
|
||||
import llvm.c.Core;
|
||||
|
||||
// taken from llvm/Value.h
|
||||
/// An enumeration for keeping track of the concrete subclass of Value that
|
||||
/// is actually instantiated. Values of this enumeration are kept in the
|
||||
/// Value classes SubclassID field. They are used for concrete type
|
||||
/// identification.
|
||||
enum LLVMValueKind : uint
|
||||
{
|
||||
Argument, /// This is an instance of Argument
|
||||
BasicBlock, /// This is an instance of BasicBlock
|
||||
Function, /// This is an instance of Function
|
||||
GlobalAlias, /// This is an instance of GlobalAlias
|
||||
GlobalVariable, /// This is an instance of GlobalVariable
|
||||
UndefValue, /// This is an instance of UndefValue
|
||||
ConstantExpr, /// This is an instance of ConstantExpr
|
||||
ConstantAggregateZero, /// This is an instance of ConstantAggregateNull
|
||||
ConstantInt, /// This is an instance of ConstantInt
|
||||
ConstantFP, /// This is an instance of ConstantFP
|
||||
ConstantArray, /// This is an instance of ConstantArray
|
||||
ConstantStruct, /// This is an instance of ConstantStruct
|
||||
ConstantVector, /// This is an instance of ConstantVector
|
||||
ConstantPointerNull, /// This is an instance of ConstantPointerNull
|
||||
InlineAsm, /// This is an instance of InlineAsm
|
||||
Instruction /// This is an instance of Instruction
|
||||
}
|
||||
|
||||
extern(C)
|
||||
{
|
||||
void LLVMEraseFromParent(LLVMValueRef I);
|
||||
int LLVMIsTerminated(LLVMBasicBlockRef BB);
|
||||
int LLVMHasPredecessors(LLVMBasicBlockRef BB);
|
||||
int LLVMIsBasicBlockEmpty(LLVMBasicBlockRef BB);
|
||||
void LLVMReplaceAllUsesWith(LLVMValueRef V, LLVMValueRef W);
|
||||
|
||||
void LLVMOptimizeModule(LLVMModuleRef M, int doinline);
|
||||
void LLVMDumpType(LLVMTypeRef T);
|
||||
|
||||
LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M, char* Name, LLVMTypeRef Type);
|
||||
|
||||
/// Return a strdup()ed string which must be free()ed
|
||||
char* LLVMValueToString(LLVMValueRef v);
|
||||
char* LLVMTypeToString(LLVMTypeRef ty); /// ditto
|
||||
|
||||
LLVMValueKind LLVMGetValueKind(LLVMValueRef Value);
|
||||
|
||||
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, char* Name);
|
||||
int LLVMIsTypeAbstract(LLVMTypeRef T);
|
||||
|
||||
alias void function(void* handle, LLVMTypeRef newT) RefineCallback;
|
||||
void LLVMRegisterAbstractTypeCallback(LLVMTypeRef T,
|
||||
void* handle,
|
||||
RefineCallback callback);
|
||||
}
|
||||
115
tools/binding/llvm/c/Target.d
Normal file
115
tools/binding/llvm/c/Target.d
Normal file
@@ -0,0 +1,115 @@
|
||||
// Converted to the D programming language by Tomas Lindquist Olsen 2008
|
||||
// Original file header:
|
||||
/*===-- llvm-c/Target.h - Target Lib C Iface --------------------*- C++ -*-===*\
|
||||
|* *|
|
||||
|* The LLVM Compiler Infrastructure *|
|
||||
|* *|
|
||||
|* This file is distributed under the University of Illinois Open Source *|
|
||||
|* License. See LICENSE.TXT for details. *|
|
||||
|* *|
|
||||
|*===----------------------------------------------------------------------===*|
|
||||
|* *|
|
||||
|* This header declares the C interface to libLLVMTarget.a, which *|
|
||||
|* implements target information. *|
|
||||
|* *|
|
||||
|* 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. *|
|
||||
|* *|
|
||||
\*===----------------------------------------------------------------------===*/
|
||||
|
||||
module llvm.c.Target;
|
||||
|
||||
import llvm.c.Core;
|
||||
|
||||
extern(C):
|
||||
|
||||
enum { LLVMBigEndian, LLVMLittleEndian };
|
||||
alias int LLVMByteOrdering;
|
||||
|
||||
private
|
||||
{
|
||||
struct LLVM_OpaqueTargetData {}
|
||||
struct LLVM_OpaqueStructLayout {}
|
||||
}
|
||||
typedef LLVM_OpaqueTargetData* LLVMTargetDataRef;
|
||||
typedef LLVM_OpaqueStructLayout* LLVMStructLayoutRef;
|
||||
|
||||
|
||||
/*===-- Target Data -------------------------------------------------------===*/
|
||||
|
||||
/** Creates target data from a target layout string.
|
||||
See the constructor llvm::TargetData::TargetData. */
|
||||
LLVMTargetDataRef LLVMCreateTargetData( /*const*/ char *StringRep);
|
||||
|
||||
/** Adds target data information to a pass manager. This does not take ownership
|
||||
of the target data.
|
||||
See the method llvm::PassManagerBase::add. */
|
||||
void LLVMAddTargetData(LLVMTargetDataRef, LLVMPassManagerRef);
|
||||
|
||||
/** Converts target data to a target layout string. The string must be disposed
|
||||
with LLVMDisposeMessage.
|
||||
See the constructor llvm::TargetData::TargetData. */
|
||||
char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef);
|
||||
|
||||
/** Returns the byte order of a target, either LLVMBigEndian or
|
||||
LLVMLittleEndian.
|
||||
See the method llvm::TargetData::isLittleEndian. */
|
||||
LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef);
|
||||
|
||||
/** Returns the pointer size in bytes for a target.
|
||||
See the method llvm::TargetData::getPointerSize. */
|
||||
uint LLVMPointerSize(LLVMTargetDataRef);
|
||||
|
||||
/** Returns the integer type that is the same size as a pointer on a target.
|
||||
See the method llvm::TargetData::getIntPtrType. */
|
||||
LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef);
|
||||
|
||||
/** Computes the size of a type in bytes for a target.
|
||||
See the method llvm::TargetData::getTypeSizeInBits. */
|
||||
ulong LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef);
|
||||
|
||||
/** Computes the storage size of a type in bytes for a target.
|
||||
See the method llvm::TargetData::getTypeStoreSize. */
|
||||
ulong LLVMStoreSizeOfType(LLVMTargetDataRef, LLVMTypeRef);
|
||||
|
||||
/** Computes the ABI size of a type in bytes for a target.
|
||||
See the method llvm::TargetData::getABITypeSize. */
|
||||
ulong LLVMABISizeOfType(LLVMTargetDataRef, LLVMTypeRef);
|
||||
|
||||
/** Computes the ABI alignment of a type in bytes for a target.
|
||||
See the method llvm::TargetData::getTypeABISize. */
|
||||
uint LLVMABIAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
|
||||
|
||||
/** Computes the call frame alignment of a type in bytes for a target.
|
||||
See the method llvm::TargetData::getTypeABISize. */
|
||||
uint LLVMCallFrameAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
|
||||
|
||||
/** Computes the preferred alignment of a type in bytes for a target.
|
||||
See the method llvm::TargetData::getTypeABISize. */
|
||||
uint LLVMPreferredAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef);
|
||||
|
||||
/** Computes the preferred alignment of a global variable in bytes for a target.
|
||||
See the method llvm::TargetData::getPreferredAlignment. */
|
||||
uint LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef,
|
||||
LLVMValueRef GlobalVar);
|
||||
|
||||
/** Computes the structure element that contains the byte offset for a target.
|
||||
See the method llvm::StructLayout::getElementContainingOffset. */
|
||||
uint LLVMElementAtOffset(LLVMTargetDataRef, LLVMTypeRef StructTy,
|
||||
ulong Offset);
|
||||
|
||||
/** Computes the byte offset of the indexed struct element for a target.
|
||||
See the method llvm::StructLayout::getElementContainingOffset. */
|
||||
ulong LLVMOffsetOfElement(LLVMTargetDataRef, LLVMTypeRef StructTy,
|
||||
uint Element);
|
||||
|
||||
/** Struct layouts are speculatively cached. If a TargetDataRef is alive when
|
||||
types are being refined and removed, this method must be called whenever a
|
||||
struct type is removed to avoid a dangling pointer in this cache.
|
||||
See the method llvm::TargetData::InvalidateStructLayoutInfo. */
|
||||
void LLVMInvalidateStructLayout(LLVMTargetDataRef, LLVMTypeRef StructTy);
|
||||
|
||||
/** Deallocates a TargetData.
|
||||
See the destructor llvm::TargetData::~TargetData. */
|
||||
void LLVMDisposeTargetData(LLVMTargetDataRef);
|
||||
Reference in New Issue
Block a user