X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=include%2Fllvm-c%2FCore.h;h=e2165721534610da7369c2c5356db14257651e03;hp=4ed2bd0c60df33beaef8a989881e9b22c0445356;hb=da1435f86ebc9886dd7704294e01d192d79e069c;hpb=696f768daf61044abff279b20326cf0138d02e1a;ds=sidebyside diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 4ed2bd0c60d..e2165721534 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -51,8 +51,17 @@ 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 */ @@ -129,6 +138,11 @@ typedef enum { } LLVMRealPredicate; +/*===-- Error handling ----------------------------------------------------===*/ + +void LLVMDisposeMessage(char *Message); + + /*===-- Modules -----------------------------------------------------------===*/ /* Create and destroy modules. */ @@ -491,6 +505,7 @@ 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 @@ -505,28 +520,45 @@ LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); */ 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 { class ModuleProvider; + class MemoryBuffer; - /* Opaque module conversions - */ - inline Module *unwrap(LLVMModuleRef M) { - return reinterpret_cast(M); - } + #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ + inline ty *unwrap(ref P) { \ + return reinterpret_cast(P); \ + } \ + \ + inline ref wrap(const ty *P) { \ + return reinterpret_cast(const_cast(P)); \ + } - inline LLVMModuleRef wrap(Module *M) { - return reinterpret_cast(M); - } + 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(LLVMBuilder, LLVMBuilderRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) - /* Opaque type conversions - */ - inline Type *unwrap(LLVMTypeRef Ty) { - return reinterpret_cast(Ty); - } + #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS + /* Specialized opaque type conversions. + */ template inline T *unwrap(LLVMTypeRef Ty) { return cast(unwrap(Ty)); @@ -536,20 +568,12 @@ namespace llvm { return reinterpret_cast(Tys); } - inline LLVMTypeRef wrap(const Type *Ty) { - return reinterpret_cast(const_cast(Ty)); - } - inline LLVMTypeRef *wrap(const Type **Tys) { return reinterpret_cast(const_cast(Tys)); } - /* Opaque value conversions + /* Specialized opaque value conversions. */ - inline Value *unwrap(LLVMValueRef Val) { - return reinterpret_cast(Val); - } - template inline T *unwrap(LLVMValueRef Val) { return cast(unwrap(Val)); @@ -568,53 +592,9 @@ namespace llvm { return reinterpret_cast(Vals); } - inline LLVMValueRef wrap(const Value *Val) { - return reinterpret_cast(const_cast(Val)); - } - inline LLVMValueRef *wrap(const Value **Vals) { return reinterpret_cast(const_cast(Vals)); } - - /* Basic block conversions - */ - inline BasicBlock *unwrap(LLVMBasicBlockRef BBRef) { - return reinterpret_cast(BBRef); - } - - inline LLVMBasicBlockRef wrap(const BasicBlock *BB) { - return reinterpret_cast(const_cast(BB)); - } - - /* Opaque builder conversions. - */ - inline LLVMBuilder *unwrap(LLVMBuilderRef B) { - return reinterpret_cast(B); - } - - inline LLVMBuilderRef wrap(LLVMBuilder *B) { - return reinterpret_cast(B); - } - - /* Opaque type handle conversions. - */ - inline PATypeHolder *unwrap(LLVMTypeHandleRef B) { - return reinterpret_cast(B); - } - - inline LLVMTypeHandleRef wrap(PATypeHolder *B) { - return reinterpret_cast(B); - } - - /* Opaque module provider conversions. - */ - inline ModuleProvider *unwrap(LLVMModuleProviderRef P) { - return reinterpret_cast(P); - } - - inline LLVMModuleProviderRef wrap(ModuleProvider *P) { - return reinterpret_cast(P); - } } #endif /* !defined(__cplusplus) */