From 3e39731e88f2d4f597cebc74388fd6650ca4f604 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Mon, 22 Apr 2013 22:47:22 +0000 Subject: Move C++ code out of the C headers and into either C++ headers or the C++ files themselves. This enables people to use just a C compiler to interoperate with LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180063 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Target.cpp | 18 ++++++++++++++++++ lib/Target/TargetMachineC.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) (limited to 'lib/Target') diff --git a/lib/Target/Target.cpp b/lib/Target/Target.cpp index 9a78ebc..c96235c 100644 --- a/lib/Target/Target.cpp +++ b/lib/Target/Target.cpp @@ -18,11 +18,29 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/InitializePasses.h" #include "llvm/PassManager.h" +#include "llvm/Wrap.h" #include "llvm/Target/TargetLibraryInfo.h" #include using namespace llvm; +inline DataLayout *unwrap(LLVMTargetDataRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetDataRef wrap(const DataLayout *P) { + return reinterpret_cast(const_cast(P)); +} + +inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) { + TargetLibraryInfo *X = const_cast(P); + return reinterpret_cast(X); +} + void llvm::initializeTarget(PassRegistry &Registry) { initializeDataLayoutPass(Registry); initializeTargetLibraryInfoPass(Registry); diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp index 11a5d7a..7c644fc 100644 --- a/lib/Target/TargetMachineC.cpp +++ b/lib/Target/TargetMachineC.cpp @@ -17,6 +17,7 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/Module.h" #include "llvm/PassManager.h" +#include "llvm/Wrap.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/TargetRegistry.h" @@ -28,7 +29,36 @@ using namespace llvm; +inline DataLayout *unwrap(LLVMTargetDataRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetDataRef wrap(const DataLayout *P) { + return reinterpret_cast(const_cast(P)); +} +inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) { + return reinterpret_cast(P); +} + +inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) { + TargetLibraryInfo *X = const_cast(P); + return reinterpret_cast(X); +} + +inline TargetMachine *unwrap(LLVMTargetMachineRef P) { + return reinterpret_cast(P); +} +inline Target *unwrap(LLVMTargetRef P) { + return reinterpret_cast(P); +} +inline LLVMTargetMachineRef wrap(const TargetMachine *P) { + return + reinterpret_cast(const_cast(P)); +} +inline LLVMTargetRef wrap(const Target * P) { + return reinterpret_cast(const_cast(P)); +} LLVMTargetRef LLVMGetFirstTarget() { const Target* target = &*TargetRegistry::begin(); -- cgit v1.1