From: Gordon Henriksen Date: Sat, 29 Sep 2007 01:38:42 +0000 (+0000) Subject: Demoting CHelpers.h to include/llvm/Support. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=d070d1e56fbfdad752342838dda39e14582ccad5;p=oota-llvm.git Demoting CHelpers.h to include/llvm/Support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42465 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CHelpers.h b/include/llvm/CHelpers.h deleted file mode 100644 index 0ae7503ab07..00000000000 --- a/include/llvm/CHelpers.h +++ /dev/null @@ -1,104 +0,0 @@ -//===-- Support/CHelpers.h - Utilities for writing C bindings -------------===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// These opaque reference<-->pointer conversions are shorter and more tightly -// typed than writing the casts by hand in C bindings. In assert builds, they -// will do type checking. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_CHELPERS_H -#define LLVM_SUPPORT_CHELPERS_H - -#include "llvm/Module.h" -#include "llvm/Type.h" -#include "llvm/Value.h" - -typedef struct LLVMOpaqueModule *LLVMModuleRef; -typedef struct LLVMOpaqueType *LLVMTypeRef; -typedef struct LLVMOpaqueValue *LLVMValueRef; - -namespace llvm { - /// Opaque module conversions - /// - inline Module *unwrap(LLVMModuleRef M) { - return reinterpret_cast(M); - } - - inline LLVMModuleRef wrap(Module *M) { - return reinterpret_cast(M); - } - - /// Opaque type conversions - /// - inline Type *unwrap(LLVMTypeRef Ty) { - return reinterpret_cast(Ty); - } - - template - inline T *unwrap(LLVMTypeRef Ty) { - return cast(unwrap(Ty)); - } - - inline Type **unwrap(LLVMTypeRef* Tys) { - 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 - /// - inline Value *unwrap(LLVMValueRef Val) { - return reinterpret_cast(Val); - } - - template - inline T *unwrap(LLVMValueRef Val) { - return cast(unwrap(Val)); - } - - inline Value **unwrap(LLVMValueRef *Vals) { - return reinterpret_cast(Vals); - } - - template - inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { - #if DEBUG - for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I) - cast(*I); - #endif - 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)); - } -} - -#endif diff --git a/include/llvm/Support/CHelpers.h b/include/llvm/Support/CHelpers.h new file mode 100644 index 00000000000..0ae7503ab07 --- /dev/null +++ b/include/llvm/Support/CHelpers.h @@ -0,0 +1,104 @@ +//===-- Support/CHelpers.h - Utilities for writing C bindings -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// These opaque reference<-->pointer conversions are shorter and more tightly +// typed than writing the casts by hand in C bindings. In assert builds, they +// will do type checking. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_CHELPERS_H +#define LLVM_SUPPORT_CHELPERS_H + +#include "llvm/Module.h" +#include "llvm/Type.h" +#include "llvm/Value.h" + +typedef struct LLVMOpaqueModule *LLVMModuleRef; +typedef struct LLVMOpaqueType *LLVMTypeRef; +typedef struct LLVMOpaqueValue *LLVMValueRef; + +namespace llvm { + /// Opaque module conversions + /// + inline Module *unwrap(LLVMModuleRef M) { + return reinterpret_cast(M); + } + + inline LLVMModuleRef wrap(Module *M) { + return reinterpret_cast(M); + } + + /// Opaque type conversions + /// + inline Type *unwrap(LLVMTypeRef Ty) { + return reinterpret_cast(Ty); + } + + template + inline T *unwrap(LLVMTypeRef Ty) { + return cast(unwrap(Ty)); + } + + inline Type **unwrap(LLVMTypeRef* Tys) { + 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 + /// + inline Value *unwrap(LLVMValueRef Val) { + return reinterpret_cast(Val); + } + + template + inline T *unwrap(LLVMValueRef Val) { + return cast(unwrap(Val)); + } + + inline Value **unwrap(LLVMValueRef *Vals) { + return reinterpret_cast(Vals); + } + + template + inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { + #if DEBUG + for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I) + cast(*I); + #endif + 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)); + } +} + +#endif diff --git a/lib/Bitcode/Writer/BitWriter.cpp b/lib/Bitcode/Writer/BitWriter.cpp index 7b90586fd70..b2e7ac2ec0f 100644 --- a/lib/Bitcode/Writer/BitWriter.cpp +++ b/lib/Bitcode/Writer/BitWriter.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// #include "llvm-c/BitWriter.h" -#include "llvm/CHelpers.h" #include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/Support/CHelpers.h" #include using namespace llvm; diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index 9fc4d40746c..f35951d45b0 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -14,10 +14,10 @@ #include "llvm-c/Core.h" #include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/CHelpers.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/GlobalVariable.h" +#include "llvm/Support/CHelpers.h" #include "llvm/Support/LLVMBuilder.h" #include "llvm/TypeSymbolTable.h" #include