[llvm] r180063 - Move C++ code out of the C headers and into either C++ headers
Eric Christopher
echristo at gmail.com
Mon Apr 22 15:47:23 PDT 2013
Author: echristo
Date: Mon Apr 22 17:47:22 2013
New Revision: 180063
URL: http://llvm.org/viewvc/llvm-project?rev=180063&view=rev
Log:
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.
Added:
llvm/trunk/include/llvm/Wrap.h
Modified:
llvm/trunk/include/llvm-c/Core.h
llvm/trunk/include/llvm-c/ExecutionEngine.h
llvm/trunk/include/llvm-c/Object.h
llvm/trunk/include/llvm-c/Target.h
llvm/trunk/include/llvm-c/TargetMachine.h
llvm/trunk/include/llvm-c/Transforms/PassManagerBuilder.h
llvm/trunk/include/llvm/Target/TargetMachine.h
llvm/trunk/lib/Analysis/Analysis.cpp
llvm/trunk/lib/Analysis/IPA/IPA.cpp
llvm/trunk/lib/Bitcode/Reader/BitReader.cpp
llvm/trunk/lib/Bitcode/Writer/BitWriter.cpp
llvm/trunk/lib/CodeGen/CodeGen.cpp
llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp
llvm/trunk/lib/IR/Core.cpp
llvm/trunk/lib/Linker/LinkModules.cpp
llvm/trunk/lib/Object/Object.cpp
llvm/trunk/lib/Target/Target.cpp
llvm/trunk/lib/Target/TargetMachineC.cpp
llvm/trunk/lib/Transforms/IPO/IPO.cpp
llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp
llvm/trunk/lib/Transforms/ObjCARC/ObjCARC.cpp
llvm/trunk/lib/Transforms/Scalar/Scalar.cpp
llvm/trunk/lib/Transforms/Utils/Utils.cpp
llvm/trunk/lib/Transforms/Vectorize/Vectorize.cpp
Modified: llvm/trunk/include/llvm-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Mon Apr 22 17:47:22 2013
@@ -18,13 +18,6 @@
#include "llvm/Support/DataTypes.h"
#ifdef __cplusplus
-
-/* Need these includes to support the LLVM 'cast' template for the C++ 'wrap'
- and 'unwrap' conversion functions. */
-#include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/Module.h"
-#include "llvm/PassRegistry.h"
-
extern "C" {
#endif
@@ -60,11 +53,6 @@ extern "C" {
* with C++ due to name mangling. So in addition to C, this interface enables
* 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.
- *
* @{
*/
@@ -2690,100 +2678,6 @@ LLVMBool LLVMIsMultithreaded();
#ifdef __cplusplus
}
-
-namespace llvm {
- class MemoryBuffer;
- class PassManagerBase;
-
- #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)); \
- }
-
- #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
- \
- template<typename T> \
- inline T *unwrap(ref P) { \
- return cast<T>(unwrap(P)); \
- }
-
- #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
- \
- template<typename T> \
- inline T *unwrap(ref P) { \
- T *Q = (T*)unwrap(P); \
- assert(Q && "Invalid cast!"); \
- return Q; \
- }
-
- DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef )
- DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef )
- DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef )
- DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef )
- /* LLVMModuleProviderRef exists for historical reasons, but now just holds a
- * Module.
- */
- inline Module *unwrap(LLVMModuleProviderRef MP) {
- return reinterpret_cast<Module*>(MP);
- }
-
- #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS
- #undef DEFINE_ISA_CONVERSION_FUNCTIONS
- #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
-
- /* Specialized opaque context conversions.
- */
- inline LLVMContext **unwrap(LLVMContextRef* Tys) {
- return reinterpret_cast<LLVMContext**>(Tys);
- }
-
- inline LLVMContextRef *wrap(const LLVMContext **Tys) {
- return reinterpret_cast<LLVMContextRef*>(const_cast<LLVMContext**>(Tys));
- }
-
- /* Specialized opaque type conversions.
- */
- inline Type **unwrap(LLVMTypeRef* Tys) {
- return reinterpret_cast<Type**>(Tys);
- }
-
- inline LLVMTypeRef *wrap(Type **Tys) {
- return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
- }
-
- /* Specialized opaque value conversions.
- */
- inline Value **unwrap(LLVMValueRef *Vals) {
- return reinterpret_cast<Value**>(Vals);
- }
-
- template<typename T>
- inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
- #ifdef DEBUG
- for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
- cast<T>(*I);
- #endif
- (void)Length;
- return reinterpret_cast<T**>(Vals);
- }
-
- inline LLVMValueRef *wrap(const Value **Vals) {
- return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
- }
-}
-
#endif /* !defined(__cplusplus) */
#endif /* !defined(LLVM_C_CORE_H) */
Modified: llvm/trunk/include/llvm-c/ExecutionEngine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/ExecutionEngine.h?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/ExecutionEngine.h (original)
+++ llvm/trunk/include/llvm-c/ExecutionEngine.h Mon Apr 22 17:47:22 2013
@@ -137,27 +137,7 @@ void *LLVMGetPointerToGlobal(LLVMExecuti
*/
#ifdef __cplusplus
-}
-
-namespace llvm {
- struct GenericValue;
- class ExecutionEngine;
-
- #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)); \
- }
-
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue, LLVMGenericValueRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
-
- #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
-}
-
+}
#endif /* defined(__cplusplus) */
#endif
Modified: llvm/trunk/include/llvm-c/Object.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Object.h?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Object.h (original)
+++ llvm/trunk/include/llvm-c/Object.h Mon Apr 22 17:47:22 2013
@@ -23,8 +23,6 @@
#include "llvm/Config/llvm-config.h"
#ifdef __cplusplus
-#include "llvm/Object/ObjectFile.h"
-
extern "C" {
#endif
@@ -99,50 +97,6 @@ const char *LLVMGetRelocationValueString
#ifdef __cplusplus
}
-
-namespace llvm {
- namespace object {
- inline ObjectFile *unwrap(LLVMObjectFileRef OF) {
- return reinterpret_cast<ObjectFile*>(OF);
- }
-
- inline LLVMObjectFileRef wrap(const ObjectFile *OF) {
- return reinterpret_cast<LLVMObjectFileRef>(const_cast<ObjectFile*>(OF));
- }
-
- inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
- return reinterpret_cast<section_iterator*>(SI);
- }
-
- inline LLVMSectionIteratorRef
- wrap(const section_iterator *SI) {
- return reinterpret_cast<LLVMSectionIteratorRef>
- (const_cast<section_iterator*>(SI));
- }
-
- inline symbol_iterator *unwrap(LLVMSymbolIteratorRef SI) {
- return reinterpret_cast<symbol_iterator*>(SI);
- }
-
- inline LLVMSymbolIteratorRef
- wrap(const symbol_iterator *SI) {
- return reinterpret_cast<LLVMSymbolIteratorRef>
- (const_cast<symbol_iterator*>(SI));
- }
-
- inline relocation_iterator *unwrap(LLVMRelocationIteratorRef SI) {
- return reinterpret_cast<relocation_iterator*>(SI);
- }
-
- inline LLVMRelocationIteratorRef
- wrap(const relocation_iterator *SI) {
- return reinterpret_cast<LLVMRelocationIteratorRef>
- (const_cast<relocation_iterator*>(SI));
- }
-
- }
-}
-
#endif /* defined(__cplusplus) */
#endif
Modified: llvm/trunk/include/llvm-c/Target.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Target.h?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Target.h (original)
+++ llvm/trunk/include/llvm-c/Target.h Mon Apr 22 17:47:22 2013
@@ -235,29 +235,6 @@ void LLVMDisposeTargetData(LLVMTargetDat
#ifdef __cplusplus
}
-
-namespace llvm {
- class DataLayout;
- class TargetLibraryInfo;
-
- inline DataLayout *unwrap(LLVMTargetDataRef P) {
- return reinterpret_cast<DataLayout*>(P);
- }
-
- inline LLVMTargetDataRef wrap(const DataLayout *P) {
- return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout*>(P));
- }
-
- inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) {
- return reinterpret_cast<TargetLibraryInfo*>(P);
- }
-
- inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) {
- TargetLibraryInfo *X = const_cast<TargetLibraryInfo*>(P);
- return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
- }
-}
-
#endif /* defined(__cplusplus) */
#endif
Modified: llvm/trunk/include/llvm-c/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/TargetMachine.h?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/TargetMachine.h (original)
+++ llvm/trunk/include/llvm-c/TargetMachine.h Mon Apr 22 17:47:22 2013
@@ -117,30 +117,8 @@ LLVMBool LLVMTargetMachineEmitToFile(LLV
/** Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf. */
LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M,
LLVMCodeGenFileType codegen, char** ErrorMessage, LLVMMemoryBufferRef *OutMemBuf);
-
-
-
#ifdef __cplusplus
}
-
-namespace llvm {
- class TargetMachine;
- class Target;
-
- inline TargetMachine *unwrap(LLVMTargetMachineRef P) {
- return reinterpret_cast<TargetMachine*>(P);
- }
- inline Target *unwrap(LLVMTargetRef P) {
- return reinterpret_cast<Target*>(P);
- }
- inline LLVMTargetMachineRef wrap(const TargetMachine *P) {
- return reinterpret_cast<LLVMTargetMachineRef>(
- const_cast<TargetMachine*>(P));
- }
- inline LLVMTargetRef wrap(const Target * P) {
- return reinterpret_cast<LLVMTargetRef>(const_cast<Target*>(P));
- }
-}
#endif
#endif
Modified: llvm/trunk/include/llvm-c/Transforms/PassManagerBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Transforms/PassManagerBuilder.h?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Transforms/PassManagerBuilder.h (original)
+++ llvm/trunk/include/llvm-c/Transforms/PassManagerBuilder.h Mon Apr 22 17:47:22 2013
@@ -86,16 +86,6 @@ void LLVMPassManagerBuilderPopulateLTOPa
#ifdef __cplusplus
}
-
-namespace llvm {
- inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
- return reinterpret_cast<PassManagerBuilder*>(P);
- }
-
- inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
- return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
- }
-}
#endif
#endif
Modified: llvm/trunk/include/llvm/Target/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetMachine.h (original)
+++ llvm/trunk/include/llvm/Target/TargetMachine.h Mon Apr 22 17:47:22 2013
@@ -32,6 +32,7 @@ class MCContext;
class PassManagerBase;
class Target;
class DataLayout;
+class TargetLibraryInfo;
class TargetFrameLowering;
class TargetInstrInfo;
class TargetIntrinsicInfo;
Added: llvm/trunk/include/llvm/Wrap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Wrap.h?rev=180063&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Wrap.h (added)
+++ llvm/trunk/include/llvm/Wrap.h Mon Apr 22 17:47:22 2013
@@ -0,0 +1,119 @@
+//===- llvm/Wrap.h - C++ Type Wrapping for the C Interface -----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the wrapping functions for the C interface.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm-c/Core.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Type.h"
+#include "llvm/PassRegistry.h"
+
+/* 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.
+
+ Need these includes to support the LLVM 'cast' template for the C++ 'wrap'
+ and 'unwrap' conversion functions. */
+
+namespace llvm {
+ class MemoryBuffer;
+ class PassManagerBase;
+ struct GenericValue;
+ class ExecutionEngine;
+
+ #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)); \
+ }
+
+ #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
+ \
+ template<typename T> \
+ inline T *unwrap(ref P) { \
+ return cast<T>(unwrap(P)); \
+ }
+
+ #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
+ \
+ template<typename T> \
+ inline T *unwrap(ref P) { \
+ T *Q = (T*)unwrap(P); \
+ assert(Q && "Invalid cast!"); \
+ return Q; \
+ }
+
+ DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef )
+ DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef )
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef )
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef )
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef )
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef )
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef )
+ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef )
+ DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef )
+ DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef )
+
+ /* LLVMModuleProviderRef exists for historical reasons, but now just holds a
+ * Module.
+ */
+ inline Module *unwrap(LLVMModuleProviderRef MP) {
+ return reinterpret_cast<Module*>(MP);
+ }
+
+ /* Specialized opaque context conversions.
+ */
+ inline LLVMContext **unwrap(LLVMContextRef* Tys) {
+ return reinterpret_cast<LLVMContext**>(Tys);
+ }
+
+ inline LLVMContextRef *wrap(const LLVMContext **Tys) {
+ return reinterpret_cast<LLVMContextRef*>(const_cast<LLVMContext**>(Tys));
+ }
+
+ /* Specialized opaque type conversions.
+ */
+ inline Type **unwrap(LLVMTypeRef* Tys) {
+ return reinterpret_cast<Type**>(Tys);
+ }
+
+ inline LLVMTypeRef *wrap(Type **Tys) {
+ return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
+ }
+
+ /* Specialized opaque value conversions.
+ */
+ inline Value **unwrap(LLVMValueRef *Vals) {
+ return reinterpret_cast<Value**>(Vals);
+ }
+
+ template<typename T>
+ inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
+ #ifdef DEBUG
+ for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
+ cast<T>(*I);
+ #endif
+ (void)Length;
+ return reinterpret_cast<T**>(Vals);
+ }
+
+ inline LLVMValueRef *wrap(const Value **Vals) {
+ return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
+ }
+}
Modified: llvm/trunk/lib/Analysis/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Analysis.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Analysis.cpp (original)
+++ llvm/trunk/lib/Analysis/Analysis.cpp Mon Apr 22 17:47:22 2013
@@ -9,6 +9,7 @@
#include "llvm-c/Analysis.h"
#include "llvm-c/Initialization.h"
+#include "llvm/Wrap.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/InitializePasses.h"
#include <cstring>
Modified: llvm/trunk/lib/Analysis/IPA/IPA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/IPA.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/IPA/IPA.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/IPA.cpp Mon Apr 22 17:47:22 2013
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/InitializePasses.h"
+#include "llvm/Wrap.h"
#include "llvm-c/Initialization.h"
using namespace llvm;
Modified: llvm/trunk/lib/Bitcode/Reader/BitReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitReader.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitReader.cpp Mon Apr 22 17:47:22 2013
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm-c/BitReader.h"
+#include "llvm/Wrap.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/MemoryBuffer.h"
Modified: llvm/trunk/lib/Bitcode/Writer/BitWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitWriter.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitWriter.cpp Mon Apr 22 17:47:22 2013
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm-c/BitWriter.h"
+#include "llvm/Wrap.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
Modified: llvm/trunk/lib/CodeGen/CodeGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGen.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGen.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGen.cpp Mon Apr 22 17:47:22 2013
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/InitializePasses.h"
+#include "llvm/Wrap.h"
#include "llvm-c/Initialization.h"
using namespace llvm;
Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp Mon Apr 22 17:47:22 2013
@@ -16,10 +16,32 @@
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Wrap.h"
#include <cstring>
using namespace llvm;
+// Wrapping the C bindings types.
+DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue, LLVMGenericValueRef )
+DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
+
+inline DataLayout *unwrap(LLVMTargetDataRef P) {
+ return reinterpret_cast<DataLayout*>(P);
+}
+
+inline LLVMTargetDataRef wrap(const DataLayout *P) {
+ return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout*>(P));
+}
+
+inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) {
+ return reinterpret_cast<TargetLibraryInfo*>(P);
+}
+
+inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) {
+ TargetLibraryInfo *X = const_cast<TargetLibraryInfo*>(P);
+ return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
+}
+
/*===-- Operations on generic values --------------------------------------===*/
LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
Modified: llvm/trunk/lib/IR/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Core.cpp (original)
+++ llvm/trunk/lib/IR/Core.cpp Mon Apr 22 17:47:22 2013
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm-c/Core.h"
+#include "llvm/Wrap.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Constants.h"
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Mon Apr 22 17:47:22 2013
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Linker.h"
+#include "llvm/Wrap.h"
#include "llvm-c/Linker.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/Optional.h"
Modified: llvm/trunk/lib/Object/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Object.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Object.cpp (original)
+++ llvm/trunk/lib/Object/Object.cpp Mon Apr 22 17:47:22 2013
@@ -14,10 +14,49 @@
#include "llvm/Object/ObjectFile.h"
#include "llvm-c/Object.h"
+#include "llvm/Wrap.h"
using namespace llvm;
using namespace object;
+inline ObjectFile *unwrap(LLVMObjectFileRef OF) {
+ return reinterpret_cast<ObjectFile*>(OF);
+}
+
+inline LLVMObjectFileRef wrap(const ObjectFile *OF) {
+ return reinterpret_cast<LLVMObjectFileRef>(const_cast<ObjectFile*>(OF));
+}
+
+inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
+ return reinterpret_cast<section_iterator*>(SI);
+}
+
+inline LLVMSectionIteratorRef
+wrap(const section_iterator *SI) {
+ return reinterpret_cast<LLVMSectionIteratorRef>
+ (const_cast<section_iterator*>(SI));
+}
+
+inline symbol_iterator *unwrap(LLVMSymbolIteratorRef SI) {
+ return reinterpret_cast<symbol_iterator*>(SI);
+}
+
+inline LLVMSymbolIteratorRef
+wrap(const symbol_iterator *SI) {
+ return reinterpret_cast<LLVMSymbolIteratorRef>
+ (const_cast<symbol_iterator*>(SI));
+}
+
+inline relocation_iterator *unwrap(LLVMRelocationIteratorRef SI) {
+ return reinterpret_cast<relocation_iterator*>(SI);
+}
+
+inline LLVMRelocationIteratorRef
+wrap(const relocation_iterator *SI) {
+ return reinterpret_cast<LLVMRelocationIteratorRef>
+ (const_cast<relocation_iterator*>(SI));
+}
+
// ObjectFile creation
LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) {
return wrap(ObjectFile::createObjectFile(unwrap(MemBuf)));
Modified: llvm/trunk/lib/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Target.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Target.cpp (original)
+++ llvm/trunk/lib/Target/Target.cpp Mon Apr 22 17:47:22 2013
@@ -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 <cstring>
using namespace llvm;
+inline DataLayout *unwrap(LLVMTargetDataRef P) {
+ return reinterpret_cast<DataLayout*>(P);
+}
+
+inline LLVMTargetDataRef wrap(const DataLayout *P) {
+ return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout*>(P));
+}
+
+inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) {
+ return reinterpret_cast<TargetLibraryInfo*>(P);
+}
+
+inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) {
+ TargetLibraryInfo *X = const_cast<TargetLibraryInfo*>(P);
+ return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
+}
+
void llvm::initializeTarget(PassRegistry &Registry) {
initializeDataLayoutPass(Registry);
initializeTargetLibraryInfoPass(Registry);
Modified: llvm/trunk/lib/Target/TargetMachineC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachineC.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachineC.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachineC.cpp Mon Apr 22 17:47:22 2013
@@ -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<DataLayout*>(P);
+}
+inline LLVMTargetDataRef wrap(const DataLayout *P) {
+ return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout*>(P));
+}
+
+inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) {
+ return reinterpret_cast<TargetLibraryInfo*>(P);
+}
+
+inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) {
+ TargetLibraryInfo *X = const_cast<TargetLibraryInfo*>(P);
+ return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
+}
+
+inline TargetMachine *unwrap(LLVMTargetMachineRef P) {
+ return reinterpret_cast<TargetMachine*>(P);
+}
+inline Target *unwrap(LLVMTargetRef P) {
+ return reinterpret_cast<Target*>(P);
+}
+inline LLVMTargetMachineRef wrap(const TargetMachine *P) {
+ return
+ reinterpret_cast<LLVMTargetMachineRef>(const_cast<TargetMachine*>(P));
+}
+inline LLVMTargetRef wrap(const Target * P) {
+ return reinterpret_cast<LLVMTargetRef>(const_cast<Target*>(P));
+}
LLVMTargetRef LLVMGetFirstTarget() {
const Target* target = &*TargetRegistry::begin();
Modified: llvm/trunk/lib/Transforms/IPO/IPO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IPO.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IPO.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IPO.cpp Mon Apr 22 17:47:22 2013
@@ -17,6 +17,7 @@
#include "llvm-c/Transforms/IPO.h"
#include "llvm/InitializePasses.h"
#include "llvm/PassManager.h"
+#include "llvm/Wrap.h"
#include "llvm/Transforms/IPO.h"
using namespace llvm;
Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Mon Apr 22 17:47:22 2013
@@ -19,6 +19,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/PassManager.h"
+#include "llvm/Wrap.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Target/TargetLibraryInfo.h"
@@ -330,6 +331,14 @@ void PassManagerBuilder::populateLTOPass
PM.add(createGlobalDCEPass());
}
+inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
+ return reinterpret_cast<PassManagerBuilder*>(P);
+}
+
+inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
+ return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
+}
+
LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() {
PassManagerBuilder *PMB = new PassManagerBuilder();
return wrap(PMB);
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Mon Apr 22 17:47:22 2013
@@ -53,6 +53,7 @@
#include "llvm/Support/ValueHandle.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Transforms/Utils/Local.h"
+#include "llvm/Wrap.h"
#include <algorithm>
#include <climits>
using namespace llvm;
Modified: llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp Mon Apr 22 17:47:22 2013
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/InitializePasses.h"
+#include "llvm/Wrap.h"
#include "llvm-c/Initialization.h"
using namespace llvm;
Modified: llvm/trunk/lib/Transforms/ObjCARC/ObjCARC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ObjCARC.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ObjCARC.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/ObjCARC.cpp Mon Apr 22 17:47:22 2013
@@ -17,6 +17,7 @@
#include "llvm-c/Core.h"
#include "llvm-c/Initialization.h"
#include "llvm/InitializePasses.h"
+#include "llvm/Wrap.h"
#include "llvm/Support/CommandLine.h"
namespace llvm {
Modified: llvm/trunk/lib/Transforms/Scalar/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Scalar.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Scalar.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Mon Apr 22 17:47:22 2013
@@ -21,6 +21,7 @@
#include "llvm/IR/DataLayout.h"
#include "llvm/InitializePasses.h"
#include "llvm/PassManager.h"
+#include "llvm/Wrap.h"
using namespace llvm;
Modified: llvm/trunk/lib/Transforms/Utils/Utils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Utils.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Utils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Utils.cpp Mon Apr 22 17:47:22 2013
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/InitializePasses.h"
+#include "llvm/Wrap.h"
#include "llvm-c/Initialization.h"
using namespace llvm;
Modified: llvm/trunk/lib/Transforms/Vectorize/Vectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/Vectorize.cpp?rev=180063&r1=180062&r2=180063&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/Vectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/Vectorize.cpp Mon Apr 22 17:47:22 2013
@@ -20,6 +20,7 @@
#include "llvm/Analysis/Verifier.h"
#include "llvm/InitializePasses.h"
#include "llvm/PassManager.h"
+#include "llvm/Wrap.h"
using namespace llvm;
More information about the llvm-commits
mailing list