/* Opaque types. */
typedef struct LLVMOpaqueModule *LLVMModuleRef;
typedef struct LLVMOpaqueType *LLVMTypeRef;
+typedef struct LLVMOpaqueTypeHandle *LLVMTypeHandleRef;
typedef struct LLVMOpaqueValue *LLVMValueRef;
typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
+/* Used to provide a module to JIT or interpreter.
+ * See the llvm::ModuleProvider class.
+ */
+typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
+
+/* Used to provide a module to JIT or interpreter.
+ * See the llvm::MemoryBuffer class.
+ */
+typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
+
typedef enum {
LLVMVoidTypeKind, /* type with no size */
LLVMFloatTypeKind, /* 32 bit floating point type */
} LLVMRealPredicate;
+/*===-- Error handling ----------------------------------------------------===*/
+
+void LLVMDisposeMessage(char *Message);
+
+
/*===-- Modules -----------------------------------------------------------===*/
/* Create and destroy modules. */
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
void LLVMDisposeModule(LLVMModuleRef M);
+/* Data layout */
+const char *LLVMGetDataLayout(LLVMModuleRef M);
+void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
+
+/* Target triple */
+const char *LLVMGetTarget(LLVMModuleRef M);
+void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
+
/* Same as Module::addTypeName. */
int LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty);
void LLVMDeleteTypeName(LLVMModuleRef M, const char *Name);
LLVMTypeRef LLVMInt16Type();
LLVMTypeRef LLVMInt32Type();
LLVMTypeRef LLVMInt64Type();
-LLVMTypeRef LLVMCreateIntType(unsigned NumBits);
+LLVMTypeRef LLVMIntType(unsigned NumBits);
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
/* Operations on real types */
LLVMTypeRef LLVMPPCFP128Type();
/* Operations on function types */
-LLVMTypeRef LLVMCreateFunctionType(LLVMTypeRef ReturnType,
- LLVMTypeRef *ParamTypes, unsigned ParamCount,
- int IsVarArg);
+LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
+ LLVMTypeRef *ParamTypes, unsigned ParamCount,
+ int IsVarArg);
int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
/* Operations on struct types */
-LLVMTypeRef LLVMCreateStructType(LLVMTypeRef *ElementTypes,
- unsigned ElementCount, int Packed);
+LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
+ int Packed);
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
int LLVMIsPackedStruct(LLVMTypeRef StructTy);
/* Operations on array, pointer, and vector types (sequence types) */
-LLVMTypeRef LLVMCreateArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
-LLVMTypeRef LLVMCreatePointerType(LLVMTypeRef ElementType);
-LLVMTypeRef LLVMCreateVectorType(LLVMTypeRef ElementType,unsigned ElementCount);
+LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
+LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
+LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
+unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
/* Operations on other types */
LLVMTypeRef LLVMVoidType();
LLVMTypeRef LLVMLabelType();
-LLVMTypeRef LLVMCreateOpaqueType();
+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 ------------------------------------------------------------===*/
/* Operations on global variables */
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
+LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
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);
void LLVMDeleteFunction(LLVMValueRef Fn);
unsigned LLVMCountParams(LLVMValueRef Fn);
void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
+const char *LLVMGetCollector(LLVMValueRef Fn);
+void LLVMSetCollector(LLVMValueRef Fn, const char *Coll);
/* Operations on basic blocks */
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef Bb);
const char *Name);
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
+/* 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);
/*===-- Instruction builders ----------------------------------------------===*/
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);
+
#ifdef __cplusplus
}
namespace llvm {
- /* Opaque module conversions
- */
- inline Module *unwrap(LLVMModuleRef M) {
- return reinterpret_cast<Module*>(M);
- }
+ class ModuleProvider;
+ class MemoryBuffer;
- inline LLVMModuleRef wrap(Module *M) {
- return reinterpret_cast<LLVMModuleRef>(M);
- }
+ #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)); \
+ }
- /* Opaque type conversions
- */
- inline Type *unwrap(LLVMTypeRef Ty) {
- return reinterpret_cast<Type*>(Ty);
- }
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Type, LLVMTypeRef )
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Value, LLVMValueRef )
+ 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 )
+ #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
+
+ /* Specialized opaque type conversions.
+ */
template<typename T>
inline T *unwrap(LLVMTypeRef Ty) {
return cast<T>(unwrap(Ty));
return reinterpret_cast<Type**>(Tys);
}
- inline LLVMTypeRef wrap(const Type *Ty) {
- return reinterpret_cast<LLVMTypeRef>(const_cast<Type*>(Ty));
- }
-
inline LLVMTypeRef *wrap(const Type **Tys) {
return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
}
- /* Opaque value conversions
+ /* Specialized opaque value conversions.
*/
- inline Value *unwrap(LLVMValueRef Val) {
- return reinterpret_cast<Value*>(Val);
- }
-
template<typename T>
inline T *unwrap(LLVMValueRef Val) {
return cast<T>(unwrap(Val));
return reinterpret_cast<T**>(Vals);
}
- inline LLVMValueRef wrap(const Value *Val) {
- return reinterpret_cast<LLVMValueRef>(const_cast<Value*>(Val));
- }
-
inline LLVMValueRef *wrap(const Value **Vals) {
return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
}
-
- /* Basic block conversions
- */
- inline BasicBlock *unwrap(LLVMBasicBlockRef BBRef) {
- return reinterpret_cast<BasicBlock*>(BBRef);
- }
-
- inline LLVMBasicBlockRef wrap(const BasicBlock *BB) {
- return reinterpret_cast<LLVMBasicBlockRef>(const_cast<BasicBlock*>(BB));
- }
-
- /* Opaque builder conversions.
- */
- inline LLVMBuilder *unwrap(LLVMBuilderRef B) {
- return reinterpret_cast<LLVMBuilder*>(B);
- }
-
- inline LLVMBuilderRef wrap(LLVMBuilder *B) {
- return reinterpret_cast<LLVMBuilderRef>(B);
- }
}
#endif /* !defined(__cplusplus) */