From: James Y Knight Date: Tue, 29 Dec 2009 23:01:06 +0000 (-0500) Subject: Mark LLVMAttribute as a bitfield, add some missing functions, note URLs for upstreame... X-Git-Url: https://repo.or.cz/w/cl-llvm.git/commitdiff_plain/4af7b4d6688f2999b3114f8f6f6637569448e79e Mark LLVMAttribute as a bitfield, add some missing functions, note URLs for upstreamed SWIG/LLVM patches. --- diff --git a/README b/README index 25f52dc..9f66de8 100644 --- a/README +++ b/README @@ -8,6 +8,12 @@ better with SWIG. (so you shouldn't rebuild them). I'm working on getting the changes upstream. Oh, and I patched SWIG too because it's got some annoying bugs in its CFFI generator. :) +LLVM patch: +http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091221/092943.html + +SWIG patch: +https://sourceforge.net/tracker/?func=detail&atid=301645&aid=2919048&group_id=1645 + USING ===== diff --git a/src/core.i b/src/core.i index ee5c2c0..baabe7a 100644 --- a/src/core.i +++ b/src/core.i @@ -1,5 +1,8 @@ %include "typemaps.i" + // LLVMAttribute is a bitfield +%feature("bitfield") LLVMAttribute; + typedef unsigned char uint8_t; // Rename/wrap functions that take pointer arguments diff --git a/src/generated/core.lisp b/src/generated/core.lisp index 605d318..f745d19 100644 --- a/src/generated/core.lisp +++ b/src/generated/core.lisp @@ -33,7 +33,7 @@ (cffi:defctype LLVMUseIteratorRef :pointer) -(cffi:defcenum LLVMAttribute +(cffi:defbitfield LLVMAttribute (:LLVMZExtAttribute #.(cl:ash 1 0)) (:LLVMSExtAttribute #.(cl:ash 1 1)) (:LLVMNoReturnAttribute #.(cl:ash 1 2)) @@ -900,7 +900,8 @@ (Ty LLVMTypeRef) (AsmString :string) (Constraints :string) - (HasSideEffects :boolean)) + (HasSideEffects :boolean) + (IsAlignStack :boolean)) (cffi:defcfun ("LLVMGetGlobalParent" LLVMGetGlobalParent) LLVMModuleRef (Global LLVMValueRef)) diff --git a/src/generated/execution-engine.lisp b/src/generated/execution-engine.lisp index 18c24f1..4409747 100644 --- a/src/generated/execution-engine.lisp +++ b/src/generated/execution-engine.lisp @@ -69,7 +69,7 @@ (cffi:defcfun ("LLVMRunStaticDestructors" LLVMRunStaticDestructors) :void (EE LLVMExecutionEngineRef)) -(cffi:defcfun ("LLVMRunFunctionAsMain" LLVMRunFunctionAsMain) :boolean +(cffi:defcfun ("LLVMRunFunctionAsMain" LLVMRunFunctionAsMain) :int (EE LLVMExecutionEngineRef) (F LLVMValueRef) (ArgC :unsigned-int) diff --git a/src/llvm-extras.cpp b/src/llvm-extras.cpp index 273d5e7..b9643ce 100644 --- a/src/llvm-extras.cpp +++ b/src/llvm-extras.cpp @@ -14,6 +14,8 @@ int CLLLVM_LLVMInitializeNativeTarget() { // Functions missing in the LLVM C API + + LLVMModuleRef CLLLVM_LLVMModuleProviderGetModule(LLVMModuleProviderRef modprovider) { return llvm::wrap(llvm::unwrap(modprovider)->getModule()); } @@ -31,4 +33,30 @@ LLVMTypeRef CLLLVM_LLVMIntPtrTypeInContext(LLVMContextRef Context, LLVMTargetDat return llvm::wrap(llvm::unwrap(TD)->getIntPtrType(*llvm::unwrap(Context))); } +char *CLLLVM_LLVMDumpModuleToString(LLVMModuleRef module) +{ + std::string s; + llvm::raw_string_ostream buf(s); + llvm::unwrap(module)->print(buf, NULL); + return strdup(buf.str().c_str()); +} + +char *CLLLVM_LLVMDumpTypeToString(LLVMTypeRef type) +{ + std::string s; + llvm::raw_string_ostream buf(s); + llvm::unwrap(type)->print(buf); + return strdup(buf.str().c_str()); +} + +char *CLLLVM_LLVMDumpValueToString(LLVMValueRef value) +{ + std::string s; + llvm::raw_string_ostream buf(s); + llvm::unwrap(value)->print(buf); + return strdup(buf.str().c_str()); +} } + + + diff --git a/src/stuff.lisp b/src/stuff.lisp index f0b12c6..b5c0540 100644 --- a/src/stuff.lisp +++ b/src/stuff.lisp @@ -7,6 +7,12 @@ (asm-string :string) (module :pointer) (context :pointer)) +(cffi:defcfun ("CLLLVM_LLVMDumpModuleToString" CLLLVM_LLVMDumpModuleToString) :string + (module :pointer)) +(cffi:defcfun ("CLLLVM_LLVMDumpTypeToString" CLLLVM_LLVMDumpTypeToString) :string + (module :pointer)) +(cffi:defcfun ("CLLLVM_LLVMDumpValueToString" CLLLVM_LLVMDumpValueToString) :string + (module :pointer)) (CLLLVM_LLVMInitializeNativeTarget)