mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Removing the silly CHelpers header by rolling wrap and unwrap into the C
bindings headers themselves, hidden behind #ifdef __cplusplus. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42666 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bf287b63b3
commit
acd96191cd
@ -170,8 +170,6 @@
|
|||||||
9FE25D940CAB16FB005383FC /* RegisterCoalescer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterCoalescer.cpp; sourceTree = "<group>"; };
|
9FE25D940CAB16FB005383FC /* RegisterCoalescer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterCoalescer.cpp; sourceTree = "<group>"; };
|
||||||
9FE25D950CAB1724005383FC /* APFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APFloat.cpp; sourceTree = "<group>"; };
|
9FE25D950CAB1724005383FC /* APFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APFloat.cpp; sourceTree = "<group>"; };
|
||||||
9FE25D960CAB1759005383FC /* TargetCallingConv.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TargetCallingConv.td; sourceTree = "<group>"; };
|
9FE25D960CAB1759005383FC /* TargetCallingConv.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TargetCallingConv.td; sourceTree = "<group>"; };
|
||||||
9FE25D970CAB17F9005383FC /* DominatorCalculation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DominatorCalculation.h; path = ../lib/VMCore/DominatorCalculation.h; sourceTree = SOURCE_ROOT; };
|
|
||||||
9FE25D980CAB17F9005383FC /* DominatorInternals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DominatorInternals.cpp; path = ../lib/VMCore/DominatorInternals.cpp; sourceTree = SOURCE_ROOT; };
|
|
||||||
9FE4508B0C77A77000C4FEA4 /* ARMCodeEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ARMCodeEmitter.cpp; sourceTree = "<group>"; };
|
9FE4508B0C77A77000C4FEA4 /* ARMCodeEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ARMCodeEmitter.cpp; sourceTree = "<group>"; };
|
||||||
9FE4508C0C77A77000C4FEA4 /* ARMGenAsmWriter.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenAsmWriter.inc; sourceTree = "<group>"; };
|
9FE4508C0C77A77000C4FEA4 /* ARMGenAsmWriter.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenAsmWriter.inc; sourceTree = "<group>"; };
|
||||||
9FE4508D0C77A77000C4FEA4 /* ARMGenDAGISel.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenDAGISel.inc; sourceTree = "<group>"; };
|
9FE4508D0C77A77000C4FEA4 /* ARMGenDAGISel.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenDAGISel.inc; sourceTree = "<group>"; };
|
||||||
@ -1345,8 +1343,6 @@
|
|||||||
9F77937D0C73C4F400551F9C /* ConstantFold.h */,
|
9F77937D0C73C4F400551F9C /* ConstantFold.h */,
|
||||||
DE66EC6008ABE86A00323D32 /* Constants.cpp */,
|
DE66EC6008ABE86A00323D32 /* Constants.cpp */,
|
||||||
9FD3E5900CA0129D00E54D15 /* Core.cpp */,
|
9FD3E5900CA0129D00E54D15 /* Core.cpp */,
|
||||||
9FE25D970CAB17F9005383FC /* DominatorCalculation.h */,
|
|
||||||
9FE25D980CAB17F9005383FC /* DominatorInternals.cpp */,
|
|
||||||
DE66EC6108ABE86A00323D32 /* Dominators.cpp */,
|
DE66EC6108ABE86A00323D32 /* Dominators.cpp */,
|
||||||
DE66EC6208ABE86A00323D32 /* Function.cpp */,
|
DE66EC6208ABE86A00323D32 /* Function.cpp */,
|
||||||
DE66EC6308ABE86A00323D32 /* Globals.cpp */,
|
DE66EC6308ABE86A00323D32 /* Globals.cpp */,
|
||||||
|
@ -23,12 +23,23 @@
|
|||||||
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|
||||||
|* tools written in such languages. *|
|
|* 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. *|
|
||||||
|
|* *|
|
||||||
\*===----------------------------------------------------------------------===*/
|
\*===----------------------------------------------------------------------===*/
|
||||||
|
|
||||||
#ifndef LLVM_C_CORE_H
|
#ifndef LLVM_C_CORE_H
|
||||||
#define LLVM_C_CORE_H
|
#define LLVM_C_CORE_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
/* 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"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -412,6 +423,94 @@ LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
/* Opaque module conversions
|
||||||
|
*/
|
||||||
|
inline Module *unwrap(LLVMModuleRef M) {
|
||||||
|
return reinterpret_cast<Module*>(M);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LLVMModuleRef wrap(Module *M) {
|
||||||
|
return reinterpret_cast<LLVMModuleRef>(M);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Opaque type conversions
|
||||||
|
*/
|
||||||
|
inline Type *unwrap(LLVMTypeRef Ty) {
|
||||||
|
return reinterpret_cast<Type*>(Ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T *unwrap(LLVMTypeRef Ty) {
|
||||||
|
return cast<T>(unwrap(Ty));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Type **unwrap(LLVMTypeRef* Tys) {
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
inline Value *unwrap(LLVMValueRef Val) {
|
||||||
|
return reinterpret_cast<Value*>(Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T *unwrap(LLVMValueRef Val) {
|
||||||
|
return cast<T>(unwrap(Val));
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
#endif
|
||||||
|
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) */
|
||||||
|
|
||||||
|
#endif /* !defined(LLVM_C_CORE_H) */
|
||||||
|
@ -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<Module*>(M);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LLVMModuleRef wrap(Module *M) {
|
|
||||||
return reinterpret_cast<LLVMModuleRef>(M);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Opaque type conversions
|
|
||||||
///
|
|
||||||
inline Type *unwrap(LLVMTypeRef Ty) {
|
|
||||||
return reinterpret_cast<Type*>(Ty);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline T *unwrap(LLVMTypeRef Ty) {
|
|
||||||
return cast<T>(unwrap(Ty));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Type **unwrap(LLVMTypeRef* Tys) {
|
|
||||||
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
|
|
||||||
///
|
|
||||||
inline Value *unwrap(LLVMValueRef Val) {
|
|
||||||
return reinterpret_cast<Value*>(Val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline T *unwrap(LLVMValueRef Val) {
|
|
||||||
return cast<T>(unwrap(Val));
|
|
||||||
}
|
|
||||||
|
|
||||||
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 *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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include "llvm-c/BitWriter.h"
|
#include "llvm-c/BitWriter.h"
|
||||||
#include "llvm/Bitcode/ReaderWriter.h"
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Support/CHelpers.h"
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
@ -17,25 +17,11 @@
|
|||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/GlobalVariable.h"
|
#include "llvm/GlobalVariable.h"
|
||||||
#include "llvm/Support/CHelpers.h"
|
|
||||||
#include "llvm/Support/LLVMBuilder.h"
|
|
||||||
#include "llvm/TypeSymbolTable.h"
|
#include "llvm/TypeSymbolTable.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
|
||||||
/// Opaque builder conversions.
|
|
||||||
///
|
|
||||||
inline LLVMBuilder *unwrap(LLVMBuilderRef B) {
|
|
||||||
return reinterpret_cast<LLVMBuilder*>(B);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LLVMBuilderRef wrap(LLVMBuilder *B) {
|
|
||||||
return reinterpret_cast<LLVMBuilderRef>(B);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*===-- Operations on modules ---------------------------------------------===*/
|
/*===-- Operations on modules ---------------------------------------------===*/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user