From ddc2574f128b9df994d73aef1b8d6a24ac215b9b Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 15 Dec 2009 05:58:47 -0500 Subject: [PATCH 1/8] Initial revision. --- Makefile | 20 ++++++++++++ Target.i | 26 +++++++++++++++ cl-llvm.asd | 17 ++++++++++ examples/test.lisp | 81 ++++++++++++++++++++++++++++++++++++++++++++++ examples/test.ll | 30 +++++++++++++++++ llvm-extras.cpp | 27 ++++++++++++++++ src/stuff.lisp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 296 insertions(+) create mode 100644 Makefile create mode 100644 Target.i create mode 100644 cl-llvm.asd create mode 100644 examples/test.lisp create mode 100644 examples/test.ll create mode 100644 llvm-extras.cpp create mode 100644 src/stuff.lisp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..05e494f --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +all: cl-llvm.so + +bindings: + swig -cffi -noswig-lisp -outdir src/generated -module core /usr/include/llvm-c/Core.h + swig -cffi -noswig-lisp -outdir src/generated -module analysis /usr/include/llvm-c/Analysis.h + swig -cffi -noswig-lisp -outdir src/generated -module execution-engine /usr/include/llvm-c/ExecutionEngine.h + swig -cffi -noswig-lisp -outdir src/generated -module target Target.i + swig -cffi -noswig-lisp -outdir src/generated -module transforms-scalar /usr/include/llvm-c/Transforms/Scalar.h + +CFLAGS=$(shell llvm-config --cflags) +CXXFLAGS=$(CFLAGS) +LDFLAGS=$(shell llvm-config --ldflags) +LINKER=g++ + +LIBS=-Wl,--whole-archive $(shell llvm-config --libs core jit interpreter native asmparser) -Wl,--no-whole-archive + +llvm-extras.o: llvm-extras.cpp + +cl-llvm.so: llvm-extras.o + $(LINKER) -shared -o $@ $(LDFLAGS) $^ $(LIBS) diff --git a/Target.i b/Target.i new file mode 100644 index 0000000..e300d7e --- /dev/null +++ b/Target.i @@ -0,0 +1,26 @@ + // Target is annoying, handle it manually. :( +%{ +#include "/usr/include/llvm-c/Target.h" +%} + +LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep); + +void LLVMAddTargetData(LLVMTargetDataRef, LLVMPassManagerRef); +char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef); +LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef); +unsigned LLVMPointerSize(LLVMTargetDataRef); +LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef); +unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef); +unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned long long LLVMABISizeOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef, + LLVMValueRef GlobalVar); +unsigned LLVMElementAtOffset(LLVMTargetDataRef, LLVMTypeRef StructTy, + unsigned long long Offset); +unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef, LLVMTypeRef StructTy, + unsigned Element); +void LLVMInvalidateStructLayout(LLVMTargetDataRef, LLVMTypeRef StructTy); +void LLVMDisposeTargetData(LLVMTargetDataRef); diff --git a/cl-llvm.asd b/cl-llvm.asd new file mode 100644 index 0000000..cd9b03a --- /dev/null +++ b/cl-llvm.asd @@ -0,0 +1,17 @@ +;; -*- Lisp -*- + +(defsystem :cl-llvm + :author "James Knight" + :depends-on (:cffi) + :version "0.1" + :components + ((:module "src" + :serial t + :components ((:file "load-c-lib") + (:module "generated" + :components ((:file "core") + (:file "analysis") + (:file "execution-engine") + (:file "target") + (:file "transforms-scalar"))) + (:file "stuff"))))) diff --git a/examples/test.lisp b/examples/test.lisp new file mode 100644 index 0000000..53ab927 --- /dev/null +++ b/examples/test.lisp @@ -0,0 +1,81 @@ +(require 'cl-llvm) + +;;; HACK! make sigabrt not abort. +(defun sigabrt-handler (signal info context) + (declare (ignore signal info)) + (declare (type system-area-pointer context)) + (sb-sys:with-interrupts + (error "sigabrt at #X~X" + (with-alien ((context (* sb-sys:os-context-t) context)) + (sb-sys:sap-int (sb-vm:context-pc context)))))) +(sb-sys:enable-interrupt sb-posix:sigabrt #'sigabrt-handler) + +;; Make a factorial function! +(defun build-fac-fun () + (let* ((mod *jit-module*)) + ;; Build it + (let* ((fac_args (list (LLVMInt32TypeInContext *llvm-context*))) + (fac (LLVMAddFunction mod "fac" (LLVMFunctionType* (LLVMInt32TypeInContext *llvm-context*) + fac_args 0))) + ;; Create code-builder object; this is reused throughout the rest of the function. + (builder (LLVMCreateBuilderInContext *llvm-context*))) + + ;; Use the c-call calling convention (the default) + (LLVMSetFunctionCallConv fac (cffi:foreign-enum-value 'LLVMCallConv :LLVMCCallConv)) + + ;; Create 4 new basic blocks: entry, iftrue, iffalse, end + (let* ((entry (LLVMAppendBasicBlockInContext *llvm-context* fac "entry")) + (iftrue (LLVMAppendBasicBlockInContext *llvm-context* fac "iftrue")) + (iffalse (LLVMAppendBasicBlockInContext *llvm-context* fac "iffalse")) + (end (LLVMAppendBasicBlock fac "end")) + ;; get 0th function argument + (n (LLVMGetParam fac 0)) + ;; make some extra vars to stick stuff in + res-iftrue res-iffalse) + + ;; Create entry BB + (LLVMPositionBuilderAtEnd builder entry) + (let* ((IfNode (LLVMBuildICmp builder :LLVMIntEQ n + (LLVMConstInt (LLVMInt32TypeInContext *llvm-context*) 0 0) + "n == 0"))) + (LLVMBuildCondBr builder IfNode iftrue iffalse)) + + ;; Create true BB + (LLVMPositionBuilderAtEnd builder iftrue) + (setf res-iftrue (LLVMConstInt (LLVMInt32TypeInContext *llvm-context*) 1 0)) + (LLVMBuildBr builder end) + + ;; Create false BB + (LLVMPositionBuilderAtEnd builder iffalse) + (let* ((n-minus (LLVMBuildSub builder n (LLVMConstInt (LLVMInt32TypeInContext *llvm-context*) 1 0) "n - 1")) + (call-fac (LLVMBuildCall* builder fac (list n-minus) "fac(n - 1)"))) + (setf res-iffalse (LLVMBuildMul builder n call-fac "n * fac(n - 1)"))) + (LLVMBuildBr builder end) + + ;; Create end BB + (LLVMPositionBuilderAtEnd builder end) + (let ((res (LLVMBuildPhi builder (LLVMInt32TypeInContext *llvm-context*) "result"))) + (LLVMAddIncoming* res res-iftrue iftrue) + (LLVMAddIncoming* res res-iffalse iffalse) + (LLVMBuildRet builder res))) + + ;; Verify that module is valid + (when (/= 0 (LLVMVerifyModule mod :LLVMPrintMessageAction (cffi:null-pointer))) + (error "Module didn't verify!")) + + ;; Dump textual description for debugging purposes + (LLVMDumpValue fac) + ;; Run some optimizations + (LLVMRunFunctionPassManager *jit-pass-manager* fac) + (LLVMDumpValue fac) + + ;; Clean up + (LLVMDisposeBuilder builder) + fac))) + +;; Run the code! +(defun run-fun (fun n) + (let ((fun-ptr (LLVMGetPointerToGlobal *jit-execution-engine* fun))) + (cffi:foreign-funcall-pointer fun-ptr () :int64 n :int64))) + + diff --git a/examples/test.ll b/examples/test.ll new file mode 100644 index 0000000..eceaca6 --- /dev/null +++ b/examples/test.ll @@ -0,0 +1,30 @@ +declare {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) + +define i32 @add(i32, i32) { + %l = and i32 %0, 3 + %l0 = icmp ne i32 %l, 0 + br i1 %l0, label %undef, label %go1 +go1: + %r = and i32 %1, 3 + %r0 = icmp ne i32 %r, 0 + br i1 %r0, label %undef, label %go2 +go2: + %3 = lshr i32 %0, 2 + %4 = lshr i32 %1, 2 + %res = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %3, i32 %4) + %5 = extractvalue {i32, i1} %res, 0 + %ov = extractvalue {i32, i1} %res, 1 + br i1 %ov, label %undef, label %go3 +go3: + %6 = shl i32 %5, 2 + ret i32 %6 +undef: + unreachable +} + + +define i32 @add3(i32, i32, i32) { + %4 = call i32 @add(i32 %0, i32 %1) + %5 = call i32 @add(i32 %4, i32 %2) + ret i32 %5 +} diff --git a/llvm-extras.cpp b/llvm-extras.cpp new file mode 100644 index 0000000..b04a08b --- /dev/null +++ b/llvm-extras.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include + +extern "C" { +// Declare here so the inline definition gets into the lib. Why is +// there an inline function in a binding header anyways. :( +int CLLLVM_LLVMInitializeNativeTarget() { + LLVMInitializeNativeTarget(); +} + +LLVMModuleRef CLLLVM_LLVMModuleProviderGetModule(LLVMModuleProviderRef modprovider) { + return llvm::wrap(llvm::unwrap(modprovider)->getModule()); +} + +LLVMModuleRef CLLLVM_LLVMParseAssemblyString(const char *AsmString, + LLVMModuleRef M, + LLVMContextRef Context) { + class llvm::SMDiagnostic Error; + LLVMModuleRef res = + llvm::wrap(llvm::ParseAssemblyString(AsmString, llvm::unwrap(M), Error, *llvm::unwrap(Context))); + Error.Print("sbcl", llvm::errs()); +} + +} diff --git a/src/stuff.lisp b/src/stuff.lisp new file mode 100644 index 0000000..dee0aaf --- /dev/null +++ b/src/stuff.lisp @@ -0,0 +1,95 @@ +;; Define some wrappers around the low-level C API functions to make them easier to use. + +(defun LLVMFunctionType* (ret params is-var-arg) + (let ((len (length params))) + (cffi:with-foreign-object (array :pointer len) + (loop for param in params + for i from 0 + do + (setf (cffi:mem-aref array :pointer i) param)) + (LLVMFunctionType ret array len is-var-arg)))) + +(defun LLVMBuildCall* (builder fn args name) + (let ((len (length args))) + (cffi:with-foreign-object (array :pointer len) + (loop for arg in args + for i from 0 + do + (setf (cffi:mem-aref array :pointer i) arg)) + (LLVMBuildCall builder fn array len name)))) + +(defun LLVMAddIncoming* (phi-node incoming-val incoming-block) + (cffi:with-foreign-objects ((incoming-vals :pointer) + (incoming-blocks :pointer)) + (setf (cffi:mem-aref incoming-vals :pointer 0) incoming-val) + (setf (cffi:mem-aref incoming-blocks :pointer 0) incoming-block) + (LLVMAddIncoming phi-node incoming-vals incoming-blocks 1))) + +(defun LLVMCreateJITCompiler* (provider opt) + (cffi:with-foreign-objects ((out-engine :pointer) + (out-error-str :pointer)) + (if (= 0 (LLVMCreateJITCompiler out-engine provider opt out-error-str)) + (cffi:mem-ref out-engine :pointer) + (let* ((error-str (cffi:mem-ref out-error-str :pointer)) + (error-str-lisp (cffi:foreign-string-to-lisp error-str))) + (LLVMDisposeMessage error-str) + (error "LLVMCreateJITCompiler: ~s" error-str-lisp))))) + + +(defun LLVMBuildGEP* (builder ptr indices) + (let ((len (length indices))) + (cffi:with-foreign-object (array :pointer len) + (loop for arg in indices + for i from 0 + do + (setf (cffi:mem-aref array :pointer i) arg)) + (LLVMBuildGEP builder ptr array len "")))) + + + + +;; Load up the native codegen. +(cffi:defcfun ("CLLLVM_LLVMInitializeNativeTarget" CLLLVM_LLVMInitializeNativeTarget) :int) +(cffi:defcfun ("CLLLVM_LLVMModuleProviderGetModule" CLLLVM_LLVMModuleProviderGetModule) :pointer + (modprovider :pointer)) +(cffi:defcfun ("CLLLVM_LLVMParseAssemblyString" CLLLVM_LLVMParseAssemblyString) :pointer + (asm-string :string) + (module :pointer) + (context :pointer)) + +(CLLLVM_LLVMInitializeNativeTarget) + +;; A global context. Most of LLVM is only thread-safe within a single "context". There is an +;; internal-to-LLVM C default global context, implicitly used by a number of functions like +;; LLVM*Type (without InContext on the end), but I make a lisp-side global context here for clarity. +;; +;; Delete with LLVMContextDispose when done. +;; +;; ...FIXME...or not. For some reason making a custom context makes things fail to verify, stating +;; that I've mixed contexts. Need to figure out if this is my fault or a bug in LLVM. +;; +;; So just use the standard global context +;; (defvar *llvm-context* (LLVMContextCreate)) +(defvar *llvm-context* (LLVMGetGlobalContext)) + +;; Top-level LLVM module for running the JIT in. Other modules can be made for codegen-to-disk, but +;; only a single module for JIT execution can exist in the process. +(defvar *jit-module* (LLVMModuleCreateWithNameInContext "jit-module" *llvm-context*)) + +;; Module provider...dunno what the purpose of this is, it wraps the module +;; Delete with LLVMDisposeModuleProvider; don't delete the wrapped module +(defvar *jit-module-provider* (LLVMCreateModuleProviderForExistingModule *jit-module*)) + +;; Create the JIT compiler, optimization level 2 (whatever that means). This call fails if you run +;; it twice in a process. (which is why we can have only one module for JIT code) +(defvar *jit-execution-engine* (LLVMCreateJITCompiler* *jit-module-provider* 2)) + +;; Optimization passes. Cleanup with LLVMDisposePassManager. +(defvar *jit-pass-manager* (LLVMCreateFunctionPassManager *jit-module-provider*)) +(let ((pass *jit-pass-manager*)) + (LLVMAddTargetData (LLVMGetExecutionEngineTargetData *jit-execution-engine*) pass) + (LLVMAddConstantPropagationPass pass) + (LLVMAddInstructionCombiningPass pass) + (LLVMAddPromoteMemoryToRegisterPass pass) + (LLVMAddGVNPass pass) + (LLVMAddCFGSimplificationPass pass)) -- 2.11.4.GIT From b1f402eb535644bac6e75e3d52f8c4429f0dcc1b Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 15 Dec 2009 05:58:47 -0500 Subject: [PATCH 2/8] Initial revision. --- Makefile | 20 +++++++++++ Target.i | 26 +++++++++++++++ cl-llvm.asd | 17 ++++++++++ examples/test.lisp | 81 +++++++++++++++++++++++++++++++++++++++++++++ examples/test.ll | 30 +++++++++++++++++ llvm-extras.cpp | 27 +++++++++++++++ src/load-c-lib.lisp | 7 ++++ src/stuff.lisp | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 303 insertions(+) create mode 100644 Makefile create mode 100644 Target.i create mode 100644 cl-llvm.asd create mode 100644 examples/test.lisp create mode 100644 examples/test.ll create mode 100644 llvm-extras.cpp create mode 100644 src/load-c-lib.lisp create mode 100644 src/stuff.lisp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..05e494f --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +all: cl-llvm.so + +bindings: + swig -cffi -noswig-lisp -outdir src/generated -module core /usr/include/llvm-c/Core.h + swig -cffi -noswig-lisp -outdir src/generated -module analysis /usr/include/llvm-c/Analysis.h + swig -cffi -noswig-lisp -outdir src/generated -module execution-engine /usr/include/llvm-c/ExecutionEngine.h + swig -cffi -noswig-lisp -outdir src/generated -module target Target.i + swig -cffi -noswig-lisp -outdir src/generated -module transforms-scalar /usr/include/llvm-c/Transforms/Scalar.h + +CFLAGS=$(shell llvm-config --cflags) +CXXFLAGS=$(CFLAGS) +LDFLAGS=$(shell llvm-config --ldflags) +LINKER=g++ + +LIBS=-Wl,--whole-archive $(shell llvm-config --libs core jit interpreter native asmparser) -Wl,--no-whole-archive + +llvm-extras.o: llvm-extras.cpp + +cl-llvm.so: llvm-extras.o + $(LINKER) -shared -o $@ $(LDFLAGS) $^ $(LIBS) diff --git a/Target.i b/Target.i new file mode 100644 index 0000000..e300d7e --- /dev/null +++ b/Target.i @@ -0,0 +1,26 @@ + // Target is annoying, handle it manually. :( +%{ +#include "/usr/include/llvm-c/Target.h" +%} + +LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep); + +void LLVMAddTargetData(LLVMTargetDataRef, LLVMPassManagerRef); +char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef); +LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef); +unsigned LLVMPointerSize(LLVMTargetDataRef); +LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef); +unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef); +unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned long long LLVMABISizeOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef, + LLVMValueRef GlobalVar); +unsigned LLVMElementAtOffset(LLVMTargetDataRef, LLVMTypeRef StructTy, + unsigned long long Offset); +unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef, LLVMTypeRef StructTy, + unsigned Element); +void LLVMInvalidateStructLayout(LLVMTargetDataRef, LLVMTypeRef StructTy); +void LLVMDisposeTargetData(LLVMTargetDataRef); diff --git a/cl-llvm.asd b/cl-llvm.asd new file mode 100644 index 0000000..cd9b03a --- /dev/null +++ b/cl-llvm.asd @@ -0,0 +1,17 @@ +;; -*- Lisp -*- + +(defsystem :cl-llvm + :author "James Knight" + :depends-on (:cffi) + :version "0.1" + :components + ((:module "src" + :serial t + :components ((:file "load-c-lib") + (:module "generated" + :components ((:file "core") + (:file "analysis") + (:file "execution-engine") + (:file "target") + (:file "transforms-scalar"))) + (:file "stuff"))))) diff --git a/examples/test.lisp b/examples/test.lisp new file mode 100644 index 0000000..53ab927 --- /dev/null +++ b/examples/test.lisp @@ -0,0 +1,81 @@ +(require 'cl-llvm) + +;;; HACK! make sigabrt not abort. +(defun sigabrt-handler (signal info context) + (declare (ignore signal info)) + (declare (type system-area-pointer context)) + (sb-sys:with-interrupts + (error "sigabrt at #X~X" + (with-alien ((context (* sb-sys:os-context-t) context)) + (sb-sys:sap-int (sb-vm:context-pc context)))))) +(sb-sys:enable-interrupt sb-posix:sigabrt #'sigabrt-handler) + +;; Make a factorial function! +(defun build-fac-fun () + (let* ((mod *jit-module*)) + ;; Build it + (let* ((fac_args (list (LLVMInt32TypeInContext *llvm-context*))) + (fac (LLVMAddFunction mod "fac" (LLVMFunctionType* (LLVMInt32TypeInContext *llvm-context*) + fac_args 0))) + ;; Create code-builder object; this is reused throughout the rest of the function. + (builder (LLVMCreateBuilderInContext *llvm-context*))) + + ;; Use the c-call calling convention (the default) + (LLVMSetFunctionCallConv fac (cffi:foreign-enum-value 'LLVMCallConv :LLVMCCallConv)) + + ;; Create 4 new basic blocks: entry, iftrue, iffalse, end + (let* ((entry (LLVMAppendBasicBlockInContext *llvm-context* fac "entry")) + (iftrue (LLVMAppendBasicBlockInContext *llvm-context* fac "iftrue")) + (iffalse (LLVMAppendBasicBlockInContext *llvm-context* fac "iffalse")) + (end (LLVMAppendBasicBlock fac "end")) + ;; get 0th function argument + (n (LLVMGetParam fac 0)) + ;; make some extra vars to stick stuff in + res-iftrue res-iffalse) + + ;; Create entry BB + (LLVMPositionBuilderAtEnd builder entry) + (let* ((IfNode (LLVMBuildICmp builder :LLVMIntEQ n + (LLVMConstInt (LLVMInt32TypeInContext *llvm-context*) 0 0) + "n == 0"))) + (LLVMBuildCondBr builder IfNode iftrue iffalse)) + + ;; Create true BB + (LLVMPositionBuilderAtEnd builder iftrue) + (setf res-iftrue (LLVMConstInt (LLVMInt32TypeInContext *llvm-context*) 1 0)) + (LLVMBuildBr builder end) + + ;; Create false BB + (LLVMPositionBuilderAtEnd builder iffalse) + (let* ((n-minus (LLVMBuildSub builder n (LLVMConstInt (LLVMInt32TypeInContext *llvm-context*) 1 0) "n - 1")) + (call-fac (LLVMBuildCall* builder fac (list n-minus) "fac(n - 1)"))) + (setf res-iffalse (LLVMBuildMul builder n call-fac "n * fac(n - 1)"))) + (LLVMBuildBr builder end) + + ;; Create end BB + (LLVMPositionBuilderAtEnd builder end) + (let ((res (LLVMBuildPhi builder (LLVMInt32TypeInContext *llvm-context*) "result"))) + (LLVMAddIncoming* res res-iftrue iftrue) + (LLVMAddIncoming* res res-iffalse iffalse) + (LLVMBuildRet builder res))) + + ;; Verify that module is valid + (when (/= 0 (LLVMVerifyModule mod :LLVMPrintMessageAction (cffi:null-pointer))) + (error "Module didn't verify!")) + + ;; Dump textual description for debugging purposes + (LLVMDumpValue fac) + ;; Run some optimizations + (LLVMRunFunctionPassManager *jit-pass-manager* fac) + (LLVMDumpValue fac) + + ;; Clean up + (LLVMDisposeBuilder builder) + fac))) + +;; Run the code! +(defun run-fun (fun n) + (let ((fun-ptr (LLVMGetPointerToGlobal *jit-execution-engine* fun))) + (cffi:foreign-funcall-pointer fun-ptr () :int64 n :int64))) + + diff --git a/examples/test.ll b/examples/test.ll new file mode 100644 index 0000000..eceaca6 --- /dev/null +++ b/examples/test.ll @@ -0,0 +1,30 @@ +declare {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) + +define i32 @add(i32, i32) { + %l = and i32 %0, 3 + %l0 = icmp ne i32 %l, 0 + br i1 %l0, label %undef, label %go1 +go1: + %r = and i32 %1, 3 + %r0 = icmp ne i32 %r, 0 + br i1 %r0, label %undef, label %go2 +go2: + %3 = lshr i32 %0, 2 + %4 = lshr i32 %1, 2 + %res = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %3, i32 %4) + %5 = extractvalue {i32, i1} %res, 0 + %ov = extractvalue {i32, i1} %res, 1 + br i1 %ov, label %undef, label %go3 +go3: + %6 = shl i32 %5, 2 + ret i32 %6 +undef: + unreachable +} + + +define i32 @add3(i32, i32, i32) { + %4 = call i32 @add(i32 %0, i32 %1) + %5 = call i32 @add(i32 %4, i32 %2) + ret i32 %5 +} diff --git a/llvm-extras.cpp b/llvm-extras.cpp new file mode 100644 index 0000000..b04a08b --- /dev/null +++ b/llvm-extras.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include + +extern "C" { +// Declare here so the inline definition gets into the lib. Why is +// there an inline function in a binding header anyways. :( +int CLLLVM_LLVMInitializeNativeTarget() { + LLVMInitializeNativeTarget(); +} + +LLVMModuleRef CLLLVM_LLVMModuleProviderGetModule(LLVMModuleProviderRef modprovider) { + return llvm::wrap(llvm::unwrap(modprovider)->getModule()); +} + +LLVMModuleRef CLLLVM_LLVMParseAssemblyString(const char *AsmString, + LLVMModuleRef M, + LLVMContextRef Context) { + class llvm::SMDiagnostic Error; + LLVMModuleRef res = + llvm::wrap(llvm::ParseAssemblyString(AsmString, llvm::unwrap(M), Error, *llvm::unwrap(Context))); + Error.Print("sbcl", llvm::errs()); +} + +} diff --git a/src/load-c-lib.lisp b/src/load-c-lib.lisp new file mode 100644 index 0000000..fb93c68 --- /dev/null +++ b/src/load-c-lib.lisp @@ -0,0 +1,7 @@ +;; HACK, how do you really do this? +(require :cffi) + +(cffi:define-foreign-library cl-llvm + (t (:default "/home/jknight/Projects/llvm/cl-llvm/cl-llvm"))) + +(cffi:use-foreign-library cl-llvm) diff --git a/src/stuff.lisp b/src/stuff.lisp new file mode 100644 index 0000000..dee0aaf --- /dev/null +++ b/src/stuff.lisp @@ -0,0 +1,95 @@ +;; Define some wrappers around the low-level C API functions to make them easier to use. + +(defun LLVMFunctionType* (ret params is-var-arg) + (let ((len (length params))) + (cffi:with-foreign-object (array :pointer len) + (loop for param in params + for i from 0 + do + (setf (cffi:mem-aref array :pointer i) param)) + (LLVMFunctionType ret array len is-var-arg)))) + +(defun LLVMBuildCall* (builder fn args name) + (let ((len (length args))) + (cffi:with-foreign-object (array :pointer len) + (loop for arg in args + for i from 0 + do + (setf (cffi:mem-aref array :pointer i) arg)) + (LLVMBuildCall builder fn array len name)))) + +(defun LLVMAddIncoming* (phi-node incoming-val incoming-block) + (cffi:with-foreign-objects ((incoming-vals :pointer) + (incoming-blocks :pointer)) + (setf (cffi:mem-aref incoming-vals :pointer 0) incoming-val) + (setf (cffi:mem-aref incoming-blocks :pointer 0) incoming-block) + (LLVMAddIncoming phi-node incoming-vals incoming-blocks 1))) + +(defun LLVMCreateJITCompiler* (provider opt) + (cffi:with-foreign-objects ((out-engine :pointer) + (out-error-str :pointer)) + (if (= 0 (LLVMCreateJITCompiler out-engine provider opt out-error-str)) + (cffi:mem-ref out-engine :pointer) + (let* ((error-str (cffi:mem-ref out-error-str :pointer)) + (error-str-lisp (cffi:foreign-string-to-lisp error-str))) + (LLVMDisposeMessage error-str) + (error "LLVMCreateJITCompiler: ~s" error-str-lisp))))) + + +(defun LLVMBuildGEP* (builder ptr indices) + (let ((len (length indices))) + (cffi:with-foreign-object (array :pointer len) + (loop for arg in indices + for i from 0 + do + (setf (cffi:mem-aref array :pointer i) arg)) + (LLVMBuildGEP builder ptr array len "")))) + + + + +;; Load up the native codegen. +(cffi:defcfun ("CLLLVM_LLVMInitializeNativeTarget" CLLLVM_LLVMInitializeNativeTarget) :int) +(cffi:defcfun ("CLLLVM_LLVMModuleProviderGetModule" CLLLVM_LLVMModuleProviderGetModule) :pointer + (modprovider :pointer)) +(cffi:defcfun ("CLLLVM_LLVMParseAssemblyString" CLLLVM_LLVMParseAssemblyString) :pointer + (asm-string :string) + (module :pointer) + (context :pointer)) + +(CLLLVM_LLVMInitializeNativeTarget) + +;; A global context. Most of LLVM is only thread-safe within a single "context". There is an +;; internal-to-LLVM C default global context, implicitly used by a number of functions like +;; LLVM*Type (without InContext on the end), but I make a lisp-side global context here for clarity. +;; +;; Delete with LLVMContextDispose when done. +;; +;; ...FIXME...or not. For some reason making a custom context makes things fail to verify, stating +;; that I've mixed contexts. Need to figure out if this is my fault or a bug in LLVM. +;; +;; So just use the standard global context +;; (defvar *llvm-context* (LLVMContextCreate)) +(defvar *llvm-context* (LLVMGetGlobalContext)) + +;; Top-level LLVM module for running the JIT in. Other modules can be made for codegen-to-disk, but +;; only a single module for JIT execution can exist in the process. +(defvar *jit-module* (LLVMModuleCreateWithNameInContext "jit-module" *llvm-context*)) + +;; Module provider...dunno what the purpose of this is, it wraps the module +;; Delete with LLVMDisposeModuleProvider; don't delete the wrapped module +(defvar *jit-module-provider* (LLVMCreateModuleProviderForExistingModule *jit-module*)) + +;; Create the JIT compiler, optimization level 2 (whatever that means). This call fails if you run +;; it twice in a process. (which is why we can have only one module for JIT code) +(defvar *jit-execution-engine* (LLVMCreateJITCompiler* *jit-module-provider* 2)) + +;; Optimization passes. Cleanup with LLVMDisposePassManager. +(defvar *jit-pass-manager* (LLVMCreateFunctionPassManager *jit-module-provider*)) +(let ((pass *jit-pass-manager*)) + (LLVMAddTargetData (LLVMGetExecutionEngineTargetData *jit-execution-engine*) pass) + (LLVMAddConstantPropagationPass pass) + (LLVMAddInstructionCombiningPass pass) + (LLVMAddPromoteMemoryToRegisterPass pass) + (LLVMAddGVNPass pass) + (LLVMAddCFGSimplificationPass pass)) -- 2.11.4.GIT From 5d010254cf66150f48360cabc279b0175a356254 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Sun, 20 Dec 2009 21:00:50 -0500 Subject: [PATCH 3/8] Start to clean things up to get into a state usable by others. --- .gitignore | 3 + Makefile | 20 - README | 59 + Target.i | 26 - cl-llvm.asd | 50 +- examples/test.lisp | 52 +- src/Makefile | 32 + src/analysis.i | 6 + src/core.i | 257 +++++ src/execution-engine.i | 21 + src/generated/analysis.lisp | 30 + src/generated/core.lisp | 1893 ++++++++++++++++++++++++++++++++ src/generated/execution-engine.lisp | 129 +++ src/generated/target.lisp | 89 ++ src/generated/transforms-scalar.lisp | 76 ++ llvm-extras.cpp => src/llvm-extras.cpp | 7 + src/load-c-lib.lisp | 7 - src/packages-post.lisp | 13 + src/packages.lisp | 4 + src/stuff.lisp | 55 +- src/target.i | 8 + src/transforms-scalar.i | 3 + src/typemaps.i | 47 + 23 files changed, 2757 insertions(+), 130 deletions(-) create mode 100644 .gitignore delete mode 100644 Makefile create mode 100644 README delete mode 100644 Target.i rewrite cl-llvm.asd (69%) create mode 100644 src/Makefile create mode 100644 src/analysis.i create mode 100644 src/core.i create mode 100644 src/execution-engine.i create mode 100644 src/generated/analysis.lisp create mode 100644 src/generated/core.lisp create mode 100644 src/generated/execution-engine.lisp create mode 100644 src/generated/target.lisp create mode 100644 src/generated/transforms-scalar.lisp rename llvm-extras.cpp => src/llvm-extras.cpp (79%) create mode 100644 src/packages-post.lisp create mode 100644 src/packages.lisp create mode 100644 src/target.i create mode 100644 src/transforms-scalar.i create mode 100644 src/typemaps.i diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ce68fe8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.so +*~ diff --git a/Makefile b/Makefile deleted file mode 100644 index 05e494f..0000000 --- a/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -all: cl-llvm.so - -bindings: - swig -cffi -noswig-lisp -outdir src/generated -module core /usr/include/llvm-c/Core.h - swig -cffi -noswig-lisp -outdir src/generated -module analysis /usr/include/llvm-c/Analysis.h - swig -cffi -noswig-lisp -outdir src/generated -module execution-engine /usr/include/llvm-c/ExecutionEngine.h - swig -cffi -noswig-lisp -outdir src/generated -module target Target.i - swig -cffi -noswig-lisp -outdir src/generated -module transforms-scalar /usr/include/llvm-c/Transforms/Scalar.h - -CFLAGS=$(shell llvm-config --cflags) -CXXFLAGS=$(CFLAGS) -LDFLAGS=$(shell llvm-config --ldflags) -LINKER=g++ - -LIBS=-Wl,--whole-archive $(shell llvm-config --libs core jit interpreter native asmparser) -Wl,--no-whole-archive - -llvm-extras.o: llvm-extras.cpp - -cl-llvm.so: llvm-extras.o - $(LINKER) -shared -o $@ $(LDFLAGS) $^ $(LIBS) diff --git a/README b/README new file mode 100644 index 0000000..13281fe --- /dev/null +++ b/README @@ -0,0 +1,59 @@ +This is a wrapper around the LLVM C API. The design is to be a fairly +thin wrapper, without much lispification. + +NOTE: currently I've checked in the generated bindings in +src/generated/*.lisp. These are autogenerated with SWIG, but with +slightly modified versions of the LLVM .h files to make them work +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. :) + +USING +===== + +1) Build the shared library. + + Ensure you have llvm installed (including llvm-dev if applicable + for your distribution), then run: + + $ make -C src build + +2) Make the asdf system available. + + The way I do that is like this: + + $ ln -s $PWD/cl-llvm.asd ~/.sbcl/systems + +3) (require 'cl-llvm) + +NOTES +===== + +There are a few things which I have adjusted in the wrapper: + +1) The LLVM C API has a concept of a global context. I do not use the + C-level global context in the Lisp bindings, but instead have a + lisp-level dynamic variable *llvm-context*, which you may + rebind. (e.g. if you want to use LLVM from multiple threads without + locking, give each thread its own *llvm-context*). + + Whenever the LLVM C API has a pair of functions like + "LLVMInt32Type" and "LLVMInt32TypeInContext", I have instead + created a single function "LLVMInt32Type", which takes the same + arguments as the C function, but also takes an extra optional + argument for the context that defaults to *llvm-context*. + +2) Where the C API takes a pointer and a count for an array of values, + such as LLVMFunctionType, I have replaced the pointer/length + arguments with a list argument, in the same position. + +3) ...Except for LLVMAddIncoming, which in the C API, took an array of + incoming values/blocks to add to the PHI node. I simplified it to + take one at a time: call it multiple times to add multiple incoming + values. + +4) Where the C API uses an output array argument, such as + LLVMGetStructElementTypes, I instead return a list. + +5) Where the C API takes a pointer to a char *ErrorMsg, ...FIXME + something... diff --git a/Target.i b/Target.i deleted file mode 100644 index e300d7e..0000000 --- a/Target.i +++ /dev/null @@ -1,26 +0,0 @@ - // Target is annoying, handle it manually. :( -%{ -#include "/usr/include/llvm-c/Target.h" -%} - -LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep); - -void LLVMAddTargetData(LLVMTargetDataRef, LLVMPassManagerRef); -char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef); -LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef); -unsigned LLVMPointerSize(LLVMTargetDataRef); -LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef); -unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef); -unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef, LLVMTypeRef); -unsigned long long LLVMABISizeOfType(LLVMTargetDataRef, LLVMTypeRef); -unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); -unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); -unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); -unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef, - LLVMValueRef GlobalVar); -unsigned LLVMElementAtOffset(LLVMTargetDataRef, LLVMTypeRef StructTy, - unsigned long long Offset); -unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef, LLVMTypeRef StructTy, - unsigned Element); -void LLVMInvalidateStructLayout(LLVMTargetDataRef, LLVMTypeRef StructTy); -void LLVMDisposeTargetData(LLVMTargetDataRef); diff --git a/cl-llvm.asd b/cl-llvm.asd dissimilarity index 69% index cd9b03a..c385548 100644 --- a/cl-llvm.asd +++ b/cl-llvm.asd @@ -1,17 +1,33 @@ -;; -*- Lisp -*- - -(defsystem :cl-llvm - :author "James Knight" - :depends-on (:cffi) - :version "0.1" - :components - ((:module "src" - :serial t - :components ((:file "load-c-lib") - (:module "generated" - :components ((:file "core") - (:file "analysis") - (:file "execution-engine") - (:file "target") - (:file "transforms-scalar"))) - (:file "stuff"))))) +;; -*- Lisp -*- + +(defsystem :cl-llvm + :author "James Y Knight" + :depends-on (:cffi) + :version "0.1" + :components + ((:module "src" + :serial t + :components ((:file "packages") + (:file "load-c-lib") + (:module "generated" + :serial t + :components ((:file "core") + (:file "analysis") + (:file "target") + (:file "execution-engine") + (:file "transforms-scalar"))) + (:file "stuff") + (:file "packages-post"))))) + +;; HACK, how do you really do this? Presumably there's a way with ASDF +;; to note that a shared lib should be loaded? + +(require :cffi) + +(pushnew (merge-pathnames "src/" (make-pathname :name nil :type nil :defaults *load-truename*)) + cffi:*foreign-library-directories*) + +(cffi:define-foreign-library cl-llvm + (t (:or (:default "cl-llvm") "cl-llvm.so"))) + +(cffi:use-foreign-library cl-llvm) diff --git a/examples/test.lisp b/examples/test.lisp index 53ab927..f320aba 100644 --- a/examples/test.lisp +++ b/examples/test.lisp @@ -1,14 +1,14 @@ (require 'cl-llvm) ;;; HACK! make sigabrt not abort. -(defun sigabrt-handler (signal info context) - (declare (ignore signal info)) - (declare (type system-area-pointer context)) - (sb-sys:with-interrupts - (error "sigabrt at #X~X" - (with-alien ((context (* sb-sys:os-context-t) context)) - (sb-sys:sap-int (sb-vm:context-pc context)))))) -(sb-sys:enable-interrupt sb-posix:sigabrt #'sigabrt-handler) +;; (defun sigabrt-handler (signal info context) +;; (declare (ignore signal info)) +;; (declare (type system-area-pointer context)) +;; (sb-sys:with-interrupts +;; (error "sigabrt at #X~X" +;; (with-alien ((context (* sb-sys:os-context-t) context)) +;; (sb-sys:sap-int (sb-vm:context-pc context)))))) +;; (sb-sys:enable-interrupt sb-posix:sigabrt #'sigabrt-handler) ;; Make a factorial function! (defun build-fac-fun () @@ -73,6 +73,42 @@ (LLVMDisposeBuilder builder) fac))) +(defun build-string-fun () + (let* ((mod *jit-module*)) + ;; Build it + (let* ((fac_args (list (LLVMInt32TypeInContext *llvm-context*))) + (fac (LLVMAddFunction mod "fac" (LLVMFunctionType* (LLVMInt32TypeInContext *llvm-context*) + fac_args 0))) + ;; Create code-builder object; this is reused throughout the rest of the function. + (builder (LLVMCreateBuilderInContext *llvm-context*))) + + ;; Use the c-call calling convention (the default) + (LLVMSetFunctionCallConv fac (cffi:foreign-enum-value 'LLVMCallConv :LLVMCCallConv)) + + ;; Create 4 new basic blocks: entry, iftrue, iffalse, end + (let* ((entry (LLVMAppendBasicBlockInContext *llvm-context* fac "entry"))) + (LLVMPositionBuilderAtEnd builder entry) + (let ((global (LLVMAddGlobal mod (LLVMArrayType (LLVMInt8Type) 5) ".str"))) + (LLVMSetInitializer global (LLVMConstStringInContext *llvm-context* "asdf" 4 0)) + (LLVMSetGlobalConstant global 1) + (LLVMBuildRet builder (LLVMBuildGEP* builder global (list (LLVMConstInt (LLVMInt32Type) 0 0) + (LLVMConstInt (LLVMInt32Type) 0 0)))))) + + ;; Dump textual description for debugging purposes + (LLVMDumpValue fac) + + ;; Verify that module is valid + (when (/= 0 (LLVMVerifyModule mod :LLVMPrintMessageAction (cffi:null-pointer))) + (error "Module didn't verify!")) + + ;; Run some optimizations +; (LLVMRunFunctionPassManager *jit-pass-manager* fac) +; (LLVMDumpValue fac) + + ;; Clean up + (LLVMDisposeBuilder builder) + fac))) + ;; Run the code! (defun run-fun (fun n) (let ((fun-ptr (LLVMGetPointerToGlobal *jit-execution-engine* fun))) diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..379978e --- /dev/null +++ b/src/Makefile @@ -0,0 +1,32 @@ +#LLVM_HEADERS=/usr/include/ +SWIG=swig +SWIGFLAGS=-cffi -noswig-lisp -generate-typedef -I$(LLVM_HEADERS) + +CFLAGS=$(shell llvm-config --cflags) +CXXFLAGS=$(CFLAGS) +LDFLAGS=$(shell llvm-config --ldflags) +LINKER=g++ +LLVM_LIBS=-Wl,--whole-archive $(shell llvm-config --libs core jit interpreter native asmparser) -Wl,--no-whole-archive + +BINDINGS_FILES=$(addprefix generated/,\ + core.lisp \ + analysis.lisp \ + execution-engine.lisp \ + target.lisp \ + transforms-scalar.lisp) + +all: build + +build: cl-llvm.so +bindings: $(BINDINGS_FILES) + +generated/%.lisp: %.i + $(SWIG) $(SWIGFLAGS) -o $@ -module $* $< + +llvm-extras.o: llvm-extras.cpp + +cl-llvm.so: llvm-extras.o + $(LINKER) -shared -o $@ $(LDFLAGS) $^ $(LLVM_LIBS) + +clean: + rm $(BINDINGS_FILES) cl-llvm.so llvm-extras.o diff --git a/src/analysis.i b/src/analysis.i new file mode 100644 index 0000000..b3d4a37 --- /dev/null +++ b/src/analysis.i @@ -0,0 +1,6 @@ +%include "typemaps.i" + +%include "llvm-c/Analysis.h" + +// TODO: +// LLVMVerifyModule has OutMessage diff --git a/src/core.i b/src/core.i new file mode 100644 index 0000000..ee5c2c0 --- /dev/null +++ b/src/core.i @@ -0,0 +1,257 @@ +%include "typemaps.i" + +typedef unsigned char uint8_t; + +// Rename/wrap functions that take pointer arguments + +%rename LLVMFunctionType "%%LLVMFunctionType"; +%rename LLVMGetParamTypes "%%LLVMGetParamTypes"; +%rename LLVMGetStructElementTypes "%%LLVMGetStructElementTypes"; +%rename LLVMConstArray "%%LLVMConstArray"; +%rename LLVMConstVector "%%LLVMConstVector"; +%rename LLVMConstGEP "%%LLVMConstGEP"; +%rename LLVMConstInBoundsGEP "%%LLVMConstInBoundsGEP"; +%rename LLVMConstExtractValue "%%LLVMConstExtractValue"; +%rename LLVMConstInsertValue "%%LLVMConstInsertValue"; +%rename LLVMGetParams "%%LLVMGetParams"; +%rename LLVMAddIncoming "%%LLVMAddIncoming"; +%rename LLVMBuildAggregateRet "%%LLVMBuildAggregateRet"; +%rename LLVMBuildInvoke "%%LLVMBuildInvoke"; +%rename LLVMBuildGEP "%%LLVMBuildGEP"; +%rename LLVMBuildInBoundsGEP "%%LLVMBuildInBoundsGEP"; +%rename LLVMBuildCall "%%LLVMBuildCall"; + +// Rename/wrap "InContext" functions. +%ignore LLVMModuleCreateWithName; +%rename LLVMModuleCreateWithNameInContext "%%LLVMModuleCreateWithNameInContext"; +%ignore LLVMInt1Type; +%rename LLVMInt1TypeInContext "%%LLVMInt1TypeInContext"; +%ignore LLVMInt8Type; +%rename LLVMInt8TypeInContext "%%LLVMInt8TypeInContext"; +%ignore LLVMInt16Type; +%rename LLVMInt16TypeInContext "%%LLVMInt16TypeInContext"; +%ignore LLVMInt32Type; +%rename LLVMInt32TypeInContext "%%LLVMInt32TypeInContext"; +%ignore LLVMInt64Type; +%rename LLVMInt64TypeInContext "%%LLVMInt64TypeInContext"; +%ignore LLVMIntType; +%rename LLVMIntTypeInContext "%%LLVMIntTypeInContext"; +%ignore LLVMFloatType; +%rename LLVMFloatTypeInContext "%%LLVMFloatTypeInContext"; + +%ignore LLVMDoubleType; +%rename LLVMDoubleTypeInContext "%%LLVMDoubleTypeInContext"; +%ignore LLVMX86FP80Type; +%rename LLVMX86FP80TypeInContext "%%LLVMX86FP80TypeInContext"; +%ignore LLVMFP128Type; +%rename LLVMFP128TypeInContext "%%LLVMFP128TypeInContext"; +%ignore LLVMPPCFP128Type; + +%rename LLVMPPCFP128TypeInContext "%%LLVMPPCFP128TypeInContext"; +%ignore LLVMStructType; +%rename LLVMStructTypeInContext "%%LLVMStructTypeInContext"; +%ignore LLVMVoidType; + +%rename LLVMVoidTypeInContext "%%LLVMVoidTypeInContext"; +%ignore LLVMLabelType; +%rename LLVMLabelTypeInContext "%%LLVMLabelTypeInContext"; +%ignore LLVMOpaqueType; +%rename LLVMOpaqueTypeInContext "%%LLVMOpaqueTypeInContext"; + +%ignore LLVMConstString; +%rename LLVMConstStringInContext "%%LLVMConstStringInContext"; +%ignore LLVMConstStruct; +%rename LLVMConstStructInContext "%%LLVMConstStructInContext"; +%ignore LLVMAppendBasicBlock; +%rename LLVMAppendBasicBlockInContext "%%LLVMAppendBasicBlockInContext"; +%ignore LLVMInsertBasicBlock; +%rename LLVMInsertBasicBlockInContext "%%LLVMInsertBasicBlockInContext"; +%ignore LLVMCreateBuilder; +%rename LLVMCreateBuilderInContext "%%LLVMCreateBuilderInContext"; + +%include "llvm-c/Core.h" + + +%insert("swiglisp") %{ +;;; The wrappers to expose the "InContext" versions of the functions +;;; in a more lispy way. +(declaim (special *llvm-context*)) + +(defun LLVMModuleCreateWithName (ModuleId &optional (context *llvm-context*)) + (%LLVMModuleCreateWithNameInContext ModuleId context)) + +(defun LLVMInt1Type (&optional (context *llvm-context*)) + (%LLVMInt1TypeInContext context)) + +(defun LLVMInt8Type (&optional (context *llvm-context*)) + (%LLVMInt8TypeInContext context)) + +(defun LLVMInt16Type (&optional (context *llvm-context*)) + (%LLVMInt16TypeInContext context)) + +(defun LLVMInt32Type (&optional (context *llvm-context*)) + (%LLVMInt32TypeInContext context)) + +(defun LLVMInt64Type (&optional (context *llvm-context*)) + (%LLVMInt64TypeInContext context)) + +(defun LLVMIntType (NumBits &optional (context *llvm-context*)) + (%LLVMIntTypeInContext context NumBits)) + +(defun LLVMFloatType (&optional (context *llvm-context*)) + (%LLVMFloatTypeInContext context)) + +(defun LLVMDoubleType (&optional (context *llvm-context*)) + (%LLVMDoubleTypeInContext context)) + +(defun LLVMX86FP80Type (&optional (context *llvm-context*)) + (%LLVMX86FP80TypeInContext context)) + +(defun LLVMFP128Type (&optional (context *llvm-context*)) + (%LLVMFP128TypeInContext context)) + +(defun LLVMPPCFP128Type (&optional (context *llvm-context*)) + (%LLVMPPCFP128TypeInContext context)) + +;; LLVMStructTypeInContext handled below. + +(defun LLVMVoidType (&optional (context *llvm-context*)) + (%LLVMVoidTypeInContext context)) + +(defun LLVMLabelType (&optional (context *llvm-context*)) + (%LLVMLabelTypeInContext context)) + +(defun LLVMOpaqueType (&optional (context *llvm-context*)) + (%LLVMOpaqueTypeInContext context)) + +;; LLVMConstStringInContext handled below +;; LLVMConstStructInContext handled below + +(defun LLVMAppendBasicBlock (Fn Name &optional (context *llvm-context*)) + (%LLVMAppendBasicBlockInContext context Fn Name)) + +(defun LLVMInsertBasicBlock (BB Name &optional (context *llvm-context*)) + (%LLVMInsertBasicBlockInContext context BB Name)) + +(defun LLVMCreateBuilder (&optional (context *llvm-context*)) + (%LLVMCreateBuilderInContext context)) + + +;; More complex wrappers for dealing with pointers. + +(defmacro with-array-and-length ((array len list) &body body) + (let ((list-v (gensym "list"))) + `(let* ((,list-v ,list) + (,len (length ,list-v))) + (cffi:with-foreign-object (,array :pointer ,len) + (loop for l in ,list-v + for i from 0 + do + (setf (cffi:mem-aref ,array :pointer i) l)) + (progn ,@body))))) + +(defun LLVMFunctionType (ret params is-var-arg) + "Combines the C API's ParamTypes array and ParamCount arguments into +a single list PARAMS." + (with-array-and-length (array len params) + (%LLVMFunctionType ret array len is-var-arg))) + +(defun LLVMGetParamTypes (function-type) + "Returns a list of param types rather than filling out a Dest pointer argument" + (let ((len (LLVMCountParamTypes function-type))) + (cffi:with-foreign-object (array :pointer len) + (%LLVMGetParamTypes function-type array) + (loop for i from 0 below len + collect + (cffi:mem-aref array :pointer i))))) + +(defun LLVMStructType (element-types is-packed &optional (context *llvm-context*)) + (with-array-and-length (array len element-types) + (%LLVMStructTypeInContext context array len is-packed))) + +(defun LLVMGetStructElementTypes (struct-type) + "Returns a list of param types rather than filling out a Dest pointer argument" + (let ((len (LLVMCountStructElementTypes struct-type))) + (cffi:with-foreign-object (array :pointer len) + (%LLVMGetStructElementTypes struct-type array) + (loop for i from 0 below len + collect + (cffi:mem-aref array :pointer i))))) + +(defun LLVMConstString (str dont-null-terminate &optional (context *llvm-context*)) + (cffi:with-foreign-string ((foreign-string num-bytes) str) + (%LLVMConstStringInContext context foreign-string num-bytes dont-null-terminate))) + +(defun LLVMConstStruct (vals packed-p &optional (context *llvm-context*)) + (with-array-and-length (array len vals) + (%LLVMConstStructInContext context array len packed-p))) + +(defun LLVMConstArray (type vals) + (with-array-and-length (array len vals) + (%LLVMConstArray type array len))) + +(defun LLVMConstVector (vals) + (with-array-and-length (array len vals) + (%LLVMConstVector array len))) + +(defun LLVMConstGEP (ptr indices) + (with-array-and-length (array len indices) + (%LLVMConstGEP ptr array len))) + +(defun LLVMConstInBoundsGEP (ptr indices) + (with-array-and-length (array len indices) + (%LLVMConstInBoundsGEP ptr array len))) + +(defun LLVMConstExtractValue (AggConstant indices) + (with-array-and-length (array len indices) + (%LLVMConstExtractValue AggConstant array len))) + +(defun LLVMConstInsertValue (AggConstant ValConstant indices) + (with-array-and-length (array len indices) + (%LLVMConstInsertValue AggConstant ValConstant array len))) + +(defun LLVMGetParams (fn) + "Returns a list of params rather than filling out a Dest pointer argument." + (let ((len (LLVMCountParams fn))) + (cffi:with-foreign-object (array :pointer len) + (%LLVMGetParams fn array) + (loop for i from 0 below len + collect + (cffi:mem-aref array :pointer i))))) + +(defun LLVMAddIncoming (phi-node incoming-val incoming-block) + "Unlike the C API (but like the C++ API...), takes only a single +incoming val and incoming block. Call multiple times if you want to +add multiple incoming values." + (cffi:with-foreign-objects ((incoming-vals :pointer) + (incoming-blocks :pointer)) + (setf (cffi:mem-aref incoming-vals :pointer 0) incoming-val) + (setf (cffi:mem-aref incoming-blocks :pointer 0) incoming-block) + (%LLVMAddIncoming phi-node incoming-vals incoming-blocks 1))) + +(defun LLVMBuildAggregateRet (builder vals) + (with-array-and-length (array len vals) + (%LLVMBuildAggregateRet builder array len))) + +(defun LLVMBuildInvoke (builder fn args then catch name) + (with-array-and-length (array len args) + (%LLVMBuildInvoke builder fn array len then catch name))) + +(defun LLVMBuildGEP (builder ptr indices name) + (with-array-and-length (array len indices) + (%LLVMBuildGEP builder ptr array len name))) + +(defun LLVMBuildInBoundsGEP (builder ptr indices name) + (with-array-and-length (array len indices) + (%LLVMBuildInBoundsGEP builder ptr array len name))) + +(defun LLVMBuildCall (builder fn args name) + "Combines the C API's Args array and NumArgs arguments into a single +list ARGS." + (with-array-and-length (array len args) + (%LLVMBuildCall builder fn array len name))) + +;; TODO: +;; LLVMCreateMemoryBufferWithContentsOfFile has OutMemBuf, OutMessage +;; LLVMCreateMemoryBufferWithSTDIN has OutMemBuf, OutMessage +%} diff --git a/src/execution-engine.i b/src/execution-engine.i new file mode 100644 index 0000000..0ccd949 --- /dev/null +++ b/src/execution-engine.i @@ -0,0 +1,21 @@ +%include "typemaps.i" + +%rename LLVMCreateJITCompiler "%%LLVMCreateJITCompiler"; + +%include "llvm-c/ExecutionEngine.h" + +%insert("swiglisp") %{ + +(defun LLVMCreateJITCompiler (provider opt) + (cffi:with-foreign-objects ((out-engine :pointer) + (out-error-str :pointer)) + (if (null (%LLVMCreateJITCompiler out-engine provider opt out-error-str)) + (cffi:mem-ref out-engine :pointer) + (let* ((error-str (cffi:mem-ref out-error-str :pointer)) + (error-str-lisp (cffi:foreign-string-to-lisp error-str))) + (LLVMDisposeMessage error-str) + (error "LLVMCreateJITCompiler: ~s" error-str-lisp))))) + +%} + +// TODO: lots of functions that need special wrappings diff --git a/src/generated/analysis.lisp b/src/generated/analysis.lisp new file mode 100644 index 0000000..b0adf6a --- /dev/null +++ b/src/generated/analysis.lisp @@ -0,0 +1,30 @@ +;;; This file was automatically generated by SWIG (http://www.swig.org). +;;; Version 1.3.40 +;;; +;;; Do not make changes to this file unless you know what you are doing--modify +;;; the SWIG interface file instead. + +(in-package :llvm) + + +(cffi:defcenum LLVMVerifierFailureAction + :LLVMAbortProcessAction + :LLVMPrintMessageAction + :LLVMReturnStatusAction) + +(cffi:defcfun ("LLVMVerifyModule" LLVMVerifyModule) :boolean + (M LLVMModuleRef) + (Action LLVMVerifierFailureAction) + (OutMessage :pointer)) + +(cffi:defcfun ("LLVMVerifyFunction" LLVMVerifyFunction) :boolean + (Fn LLVMValueRef) + (Action LLVMVerifierFailureAction)) + +(cffi:defcfun ("LLVMViewFunctionCFG" LLVMViewFunctionCFG) :void + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMViewFunctionCFGOnly" LLVMViewFunctionCFGOnly) :void + (Fn LLVMValueRef)) + + diff --git a/src/generated/core.lisp b/src/generated/core.lisp new file mode 100644 index 0000000..605d318 --- /dev/null +++ b/src/generated/core.lisp @@ -0,0 +1,1893 @@ +;;; This file was automatically generated by SWIG (http://www.swig.org). +;;; Version 1.3.40 +;;; +;;; Do not make changes to this file unless you know what you are doing--modify +;;; the SWIG interface file instead. + +(in-package :llvm) + + +(cffi:defctype uint8_t :unsigned-char) + +(cffi:defctype LLVMBool :int) + +(cffi:defctype LLVMContextRef :pointer) + +(cffi:defctype LLVMModuleRef :pointer) + +(cffi:defctype LLVMTypeRef :pointer) + +(cffi:defctype LLVMTypeHandleRef :pointer) + +(cffi:defctype LLVMValueRef :pointer) + +(cffi:defctype LLVMBasicBlockRef :pointer) + +(cffi:defctype LLVMBuilderRef :pointer) + +(cffi:defctype LLVMModuleProviderRef :pointer) + +(cffi:defctype LLVMMemoryBufferRef :pointer) + +(cffi:defctype LLVMPassManagerRef :pointer) + +(cffi:defctype LLVMUseIteratorRef :pointer) + +(cffi:defcenum LLVMAttribute + (:LLVMZExtAttribute #.(cl:ash 1 0)) + (:LLVMSExtAttribute #.(cl:ash 1 1)) + (:LLVMNoReturnAttribute #.(cl:ash 1 2)) + (:LLVMInRegAttribute #.(cl:ash 1 3)) + (:LLVMStructRetAttribute #.(cl:ash 1 4)) + (:LLVMNoUnwindAttribute #.(cl:ash 1 5)) + (:LLVMNoAliasAttribute #.(cl:ash 1 6)) + (:LLVMByValAttribute #.(cl:ash 1 7)) + (:LLVMNestAttribute #.(cl:ash 1 8)) + (:LLVMReadNoneAttribute #.(cl:ash 1 9)) + (:LLVMReadOnlyAttribute #.(cl:ash 1 10)) + (:LLVMNoInlineAttribute #.(cl:ash 1 11)) + (:LLVMAlwaysInlineAttribute #.(cl:ash 1 12)) + (:LLVMOptimizeForSizeAttribute #.(cl:ash 1 13)) + (:LLVMStackProtectAttribute #.(cl:ash 1 14)) + (:LLVMStackProtectReqAttribute #.(cl:ash 1 15)) + (:LLVMNoCaptureAttribute #.(cl:ash 1 21)) + (:LLVMNoRedZoneAttribute #.(cl:ash 1 22)) + (:LLVMNoImplicitFloatAttribute #.(cl:ash 1 23)) + (:LLVMNakedAttribute #.(cl:ash 1 24)) + (:LLVMInlineHintAttribute #.(cl:ash 1 25))) + +(cffi:defcenum LLVMOpcode + (:LLVMRet #.1) + (:LLVMBr #.2) + (:LLVMSwitch #.3) + (:LLVMInvoke #.4) + (:LLVMUnwind #.5) + (:LLVMUnreachable #.6) + (:LLVMAdd #.7) + (:LLVMFAdd #.8) + (:LLVMSub #.9) + (:LLVMFSub #.10) + (:LLVMMul #.11) + (:LLVMFMul #.12) + (:LLVMUDiv #.13) + (:LLVMSDiv #.14) + (:LLVMFDiv #.15) + (:LLVMURem #.16) + (:LLVMSRem #.17) + (:LLVMFRem #.18) + (:LLVMShl #.19) + (:LLVMLShr #.20) + (:LLVMAShr #.21) + (:LLVMAnd #.22) + (:LLVMOr #.23) + (:LLVMXor #.24) + (:LLVMMalloc #.25) + (:LLVMFree #.26) + (:LLVMAlloca #.27) + (:LLVMLoad #.28) + (:LLVMStore #.29) + (:LLVMGetElementPtr #.30) + (:LLVMTrunk #.31) + (:LLVMZExt #.32) + (:LLVMSExt #.33) + (:LLVMFPToUI #.34) + (:LLVMFPToSI #.35) + (:LLVMUIToFP #.36) + (:LLVMSIToFP #.37) + (:LLVMFPTrunc #.38) + (:LLVMFPExt #.39) + (:LLVMPtrToInt #.40) + (:LLVMIntToPtr #.41) + (:LLVMBitCast #.42) + (:LLVMICmp #.43) + (:LLVMFCmp #.44) + (:LLVMPHI #.45) + (:LLVMCall #.46) + (:LLVMSelect #.47) + (:LLVMVAArg #.50) + (:LLVMExtractElement #.51) + (:LLVMInsertElement #.52) + (:LLVMShuffleVector #.53) + (:LLVMExtractValue #.54) + (:LLVMInsertValue #.55)) + +(cffi:defcenum LLVMTypeKind + :LLVMVoidTypeKind + :LLVMFloatTypeKind + :LLVMDoubleTypeKind + :LLVMX86_FP80TypeKind + :LLVMFP128TypeKind + :LLVMPPC_FP128TypeKind + :LLVMLabelTypeKind + :LLVMIntegerTypeKind + :LLVMFunctionTypeKind + :LLVMStructTypeKind + :LLVMArrayTypeKind + :LLVMPointerTypeKind + :LLVMOpaqueTypeKind + :LLVMVectorTypeKind + :LLVMMetadataTypeKind) + +(cffi:defcenum LLVMLinkage + :LLVMExternalLinkage + :LLVMAvailableExternallyLinkage + :LLVMLinkOnceAnyLinkage + :LLVMLinkOnceODRLinkage + :LLVMWeakAnyLinkage + :LLVMWeakODRLinkage + :LLVMAppendingLinkage + :LLVMInternalLinkage + :LLVMPrivateLinkage + :LLVMDLLImportLinkage + :LLVMDLLExportLinkage + :LLVMExternalWeakLinkage + :LLVMGhostLinkage + :LLVMCommonLinkage + :LLVMLinkerPrivateLinkage) + +(cffi:defcenum LLVMVisibility + :LLVMDefaultVisibility + :LLVMHiddenVisibility + :LLVMProtectedVisibility) + +(cffi:defcenum LLVMCallConv + (:LLVMCCallConv #.0) + (:LLVMFastCallConv #.8) + (:LLVMColdCallConv #.9) + (:LLVMX86StdcallCallConv #.64) + (:LLVMX86FastcallCallConv #.65)) + +(cffi:defcenum LLVMIntPredicate + (:LLVMIntEQ #.32) + :LLVMIntNE + :LLVMIntUGT + :LLVMIntUGE + :LLVMIntULT + :LLVMIntULE + :LLVMIntSGT + :LLVMIntSGE + :LLVMIntSLT + :LLVMIntSLE) + +(cffi:defcenum LLVMRealPredicate + :LLVMRealPredicateFalse + :LLVMRealOEQ + :LLVMRealOGT + :LLVMRealOGE + :LLVMRealOLT + :LLVMRealOLE + :LLVMRealONE + :LLVMRealORD + :LLVMRealUNO + :LLVMRealUEQ + :LLVMRealUGT + :LLVMRealUGE + :LLVMRealULT + :LLVMRealULE + :LLVMRealUNE + :LLVMRealPredicateTrue) + +(cffi:defcfun ("LLVMDisposeMessage" LLVMDisposeMessage) :void + (Message :string)) + +(cffi:defcfun ("LLVMContextCreate" LLVMContextCreate) LLVMContextRef) + +(cffi:defcfun ("LLVMGetGlobalContext" LLVMGetGlobalContext) LLVMContextRef) + +(cffi:defcfun ("LLVMContextDispose" LLVMContextDispose) :void + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMModuleCreateWithNameInContext" %LLVMModuleCreateWithNameInContext) LLVMModuleRef + (ModuleID :string) + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMDisposeModule" LLVMDisposeModule) :void + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMGetDataLayout" LLVMGetDataLayout) :string + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMSetDataLayout" LLVMSetDataLayout) :void + (M LLVMModuleRef) + (Triple :string)) + +(cffi:defcfun ("LLVMGetTarget" LLVMGetTarget) :string + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMSetTarget" LLVMSetTarget) :void + (M LLVMModuleRef) + (Triple :string)) + +(cffi:defcfun ("LLVMAddTypeName" LLVMAddTypeName) :boolean + (M LLVMModuleRef) + (Name :string) + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMDeleteTypeName" LLVMDeleteTypeName) :void + (M LLVMModuleRef) + (Name :string)) + +(cffi:defcfun ("LLVMGetTypeByName" LLVMGetTypeByName) LLVMTypeRef + (M LLVMModuleRef) + (Name :string)) + +(cffi:defcfun ("LLVMDumpModule" LLVMDumpModule) :void + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMGetTypeKind" LLVMGetTypeKind) LLVMTypeKind + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMGetTypeContext" LLVMGetTypeContext) LLVMContextRef + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMInt1TypeInContext" %LLVMInt1TypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMInt8TypeInContext" %LLVMInt8TypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMInt16TypeInContext" %LLVMInt16TypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMInt32TypeInContext" %LLVMInt32TypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMInt64TypeInContext" %LLVMInt64TypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMIntTypeInContext" %LLVMIntTypeInContext) LLVMTypeRef + (C LLVMContextRef) + (NumBits :unsigned-int)) + +(cffi:defcfun ("LLVMGetIntTypeWidth" LLVMGetIntTypeWidth) :unsigned-int + (IntegerTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMFloatTypeInContext" %LLVMFloatTypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMDoubleTypeInContext" %LLVMDoubleTypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMX86FP80TypeInContext" %LLVMX86FP80TypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMFP128TypeInContext" %LLVMFP128TypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMPPCFP128TypeInContext" %LLVMPPCFP128TypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMFunctionType" %LLVMFunctionType) LLVMTypeRef + (ReturnType LLVMTypeRef) + (ParamTypes :pointer) + (ParamCount :unsigned-int) + (IsVarArg :boolean)) + +(cffi:defcfun ("LLVMIsFunctionVarArg" LLVMIsFunctionVarArg) :boolean + (FunctionTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMGetReturnType" LLVMGetReturnType) LLVMTypeRef + (FunctionTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMCountParamTypes" LLVMCountParamTypes) :unsigned-int + (FunctionTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMGetParamTypes" %LLVMGetParamTypes) :void + (FunctionTy LLVMTypeRef) + (Dest :pointer)) + +(cffi:defcfun ("LLVMStructTypeInContext" %LLVMStructTypeInContext) LLVMTypeRef + (C LLVMContextRef) + (ElementTypes :pointer) + (ElementCount :unsigned-int) + (Packed :boolean)) + +(cffi:defcfun ("LLVMCountStructElementTypes" LLVMCountStructElementTypes) :unsigned-int + (StructTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMGetStructElementTypes" %LLVMGetStructElementTypes) :void + (StructTy LLVMTypeRef) + (Dest :pointer)) + +(cffi:defcfun ("LLVMIsPackedStruct" LLVMIsPackedStruct) :boolean + (StructTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMArrayType" LLVMArrayType) LLVMTypeRef + (ElementType LLVMTypeRef) + (ElementCount :unsigned-int)) + +(cffi:defcfun ("LLVMPointerType" LLVMPointerType) LLVMTypeRef + (ElementType LLVMTypeRef) + (AddressSpace :unsigned-int)) + +(cffi:defcfun ("LLVMVectorType" LLVMVectorType) LLVMTypeRef + (ElementType LLVMTypeRef) + (ElementCount :unsigned-int)) + +(cffi:defcfun ("LLVMGetElementType" LLVMGetElementType) LLVMTypeRef + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMGetArrayLength" LLVMGetArrayLength) :unsigned-int + (ArrayTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMGetPointerAddressSpace" LLVMGetPointerAddressSpace) :unsigned-int + (PointerTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMGetVectorSize" LLVMGetVectorSize) :unsigned-int + (VectorTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMVoidTypeInContext" %LLVMVoidTypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMLabelTypeInContext" %LLVMLabelTypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMOpaqueTypeInContext" %LLVMOpaqueTypeInContext) LLVMTypeRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMCreateTypeHandle" LLVMCreateTypeHandle) LLVMTypeHandleRef + (PotentiallyAbstractTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMRefineType" LLVMRefineType) :void + (AbstractTy LLVMTypeRef) + (ConcreteTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMResolveTypeHandle" LLVMResolveTypeHandle) LLVMTypeRef + (TypeHandle LLVMTypeHandleRef)) + +(cffi:defcfun ("LLVMDisposeTypeHandle" LLVMDisposeTypeHandle) :void + (TypeHandle LLVMTypeHandleRef)) + +(cffi:defcfun ("LLVMTypeOf" LLVMTypeOf) LLVMTypeRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMGetValueName" LLVMGetValueName) :string + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMSetValueName" LLVMSetValueName) :void + (Val LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMDumpValue" LLVMDumpValue) :void + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMReplaceAllUsesWith" LLVMReplaceAllUsesWith) :void + (OldVal LLVMValueRef) + (NewVal LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAArgument" LLVMIsAArgument) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsABasicBlock" LLVMIsABasicBlock) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAInlineAsm" LLVMIsAInlineAsm) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAUser" LLVMIsAUser) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAConstant" LLVMIsAConstant) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAConstantAggregateZero" LLVMIsAConstantAggregateZero) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAConstantArray" LLVMIsAConstantArray) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAConstantExpr" LLVMIsAConstantExpr) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAConstantFP" LLVMIsAConstantFP) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAConstantInt" LLVMIsAConstantInt) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAConstantPointerNull" LLVMIsAConstantPointerNull) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAConstantStruct" LLVMIsAConstantStruct) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAConstantVector" LLVMIsAConstantVector) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAGlobalValue" LLVMIsAGlobalValue) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAFunction" LLVMIsAFunction) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAGlobalAlias" LLVMIsAGlobalAlias) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAGlobalVariable" LLVMIsAGlobalVariable) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAUndefValue" LLVMIsAUndefValue) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAInstruction" LLVMIsAInstruction) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsABinaryOperator" LLVMIsABinaryOperator) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsACallInst" LLVMIsACallInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAIntrinsicInst" LLVMIsAIntrinsicInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsADbgInfoIntrinsic" LLVMIsADbgInfoIntrinsic) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsADbgDeclareInst" LLVMIsADbgDeclareInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsADbgFuncStartInst" LLVMIsADbgFuncStartInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsADbgRegionEndInst" LLVMIsADbgRegionEndInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsADbgRegionStartInst" LLVMIsADbgRegionStartInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsADbgStopPointInst" LLVMIsADbgStopPointInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAEHSelectorInst" LLVMIsAEHSelectorInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAMemIntrinsic" LLVMIsAMemIntrinsic) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAMemCpyInst" LLVMIsAMemCpyInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAMemMoveInst" LLVMIsAMemMoveInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAMemSetInst" LLVMIsAMemSetInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsACmpInst" LLVMIsACmpInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAFCmpInst" LLVMIsAFCmpInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAICmpInst" LLVMIsAICmpInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAExtractElementInst" LLVMIsAExtractElementInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAGetElementPtrInst" LLVMIsAGetElementPtrInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAInsertElementInst" LLVMIsAInsertElementInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAInsertValueInst" LLVMIsAInsertValueInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAPHINode" LLVMIsAPHINode) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsASelectInst" LLVMIsASelectInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAShuffleVectorInst" LLVMIsAShuffleVectorInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAStoreInst" LLVMIsAStoreInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsATerminatorInst" LLVMIsATerminatorInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsABranchInst" LLVMIsABranchInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAInvokeInst" LLVMIsAInvokeInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAReturnInst" LLVMIsAReturnInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsASwitchInst" LLVMIsASwitchInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAUnreachableInst" LLVMIsAUnreachableInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAUnwindInst" LLVMIsAUnwindInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAUnaryInstruction" LLVMIsAUnaryInstruction) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAAllocaInst" LLVMIsAAllocaInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsACastInst" LLVMIsACastInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsABitCastInst" LLVMIsABitCastInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAFPExtInst" LLVMIsAFPExtInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAFPToSIInst" LLVMIsAFPToSIInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAFPToUIInst" LLVMIsAFPToUIInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAFPTruncInst" LLVMIsAFPTruncInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAIntToPtrInst" LLVMIsAIntToPtrInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAPtrToIntInst" LLVMIsAPtrToIntInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsASExtInst" LLVMIsASExtInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsASIToFPInst" LLVMIsASIToFPInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsATruncInst" LLVMIsATruncInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAUIToFPInst" LLVMIsAUIToFPInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAZExtInst" LLVMIsAZExtInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAExtractValueInst" LLVMIsAExtractValueInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsALoadInst" LLVMIsALoadInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsAVAArgInst" LLVMIsAVAArgInst) LLVMValueRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMGetFirstUse" LLVMGetFirstUse) LLVMUseIteratorRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMGetNextUse" LLVMGetNextUse) LLVMUseIteratorRef + (U LLVMUseIteratorRef)) + +(cffi:defcfun ("LLVMGetUser" LLVMGetUser) LLVMValueRef + (U LLVMUseIteratorRef)) + +(cffi:defcfun ("LLVMGetUsedValue" LLVMGetUsedValue) LLVMValueRef + (U LLVMUseIteratorRef)) + +(cffi:defcfun ("LLVMGetOperand" LLVMGetOperand) LLVMValueRef + (Val LLVMValueRef) + (Index :unsigned-int)) + +(cffi:defcfun ("LLVMConstNull" LLVMConstNull) LLVMValueRef + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstAllOnes" LLVMConstAllOnes) LLVMValueRef + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMGetUndef" LLVMGetUndef) LLVMValueRef + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMIsConstant" LLVMIsConstant) :boolean + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsNull" LLVMIsNull) :boolean + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMIsUndef" LLVMIsUndef) :boolean + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMConstPointerNull" LLVMConstPointerNull) LLVMValueRef + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstInt" LLVMConstInt) LLVMValueRef + (IntTy LLVMTypeRef) + (N :unsigned-long-long) + (SignExtend :boolean)) + +(cffi:defcfun ("LLVMConstIntOfString" LLVMConstIntOfString) LLVMValueRef + (IntTy LLVMTypeRef) + (Text :string) + (Radix :unsigned-char)) + +(cffi:defcfun ("LLVMConstIntOfStringAndSize" LLVMConstIntOfStringAndSize) LLVMValueRef + (IntTy LLVMTypeRef) + (Text :string) + (SLen :unsigned-int) + (Radix :unsigned-char)) + +(cffi:defcfun ("LLVMConstReal" LLVMConstReal) LLVMValueRef + (RealTy LLVMTypeRef) + (N :double)) + +(cffi:defcfun ("LLVMConstRealOfString" LLVMConstRealOfString) LLVMValueRef + (RealTy LLVMTypeRef) + (Text :string)) + +(cffi:defcfun ("LLVMConstRealOfStringAndSize" LLVMConstRealOfStringAndSize) LLVMValueRef + (RealTy LLVMTypeRef) + (Text :string) + (SLen :unsigned-int)) + +(cffi:defcfun ("LLVMConstIntGetZExtValue" LLVMConstIntGetZExtValue) :unsigned-long-long + (ConstantVal LLVMValueRef)) + +(cffi:defcfun ("LLVMConstIntGetSExtValue" LLVMConstIntGetSExtValue) :long-long + (ConstantVal LLVMValueRef)) + +(cffi:defcfun ("LLVMConstStringInContext" %LLVMConstStringInContext) LLVMValueRef + (C LLVMContextRef) + (Str :string) + (Length :unsigned-int) + (DontNullTerminate :boolean)) + +(cffi:defcfun ("LLVMConstStructInContext" %LLVMConstStructInContext) LLVMValueRef + (C LLVMContextRef) + (ConstantVals :pointer) + (Count :unsigned-int) + (Packed :boolean)) + +(cffi:defcfun ("LLVMConstArray" %LLVMConstArray) LLVMValueRef + (ElementTy LLVMTypeRef) + (ConstantVals :pointer) + (Length :unsigned-int)) + +(cffi:defcfun ("LLVMConstVector" %LLVMConstVector) LLVMValueRef + (ScalarConstantVals :pointer) + (Size :unsigned-int)) + +(cffi:defcfun ("LLVMGetConstOpcode" LLVMGetConstOpcode) LLVMOpcode + (ConstantVal LLVMValueRef)) + +(cffi:defcfun ("LLVMAlignOf" LLVMAlignOf) LLVMValueRef + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMSizeOf" LLVMSizeOf) LLVMValueRef + (Ty LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstNeg" LLVMConstNeg) LLVMValueRef + (ConstantVal LLVMValueRef)) + +(cffi:defcfun ("LLVMConstFNeg" LLVMConstFNeg) LLVMValueRef + (ConstantVal LLVMValueRef)) + +(cffi:defcfun ("LLVMConstNot" LLVMConstNot) LLVMValueRef + (ConstantVal LLVMValueRef)) + +(cffi:defcfun ("LLVMConstAdd" LLVMConstAdd) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstNSWAdd" LLVMConstNSWAdd) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstFAdd" LLVMConstFAdd) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstSub" LLVMConstSub) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstFSub" LLVMConstFSub) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstMul" LLVMConstMul) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstFMul" LLVMConstFMul) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstUDiv" LLVMConstUDiv) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstSDiv" LLVMConstSDiv) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstExactSDiv" LLVMConstExactSDiv) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstFDiv" LLVMConstFDiv) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstURem" LLVMConstURem) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstSRem" LLVMConstSRem) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstFRem" LLVMConstFRem) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstAnd" LLVMConstAnd) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstOr" LLVMConstOr) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstXor" LLVMConstXor) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstICmp" LLVMConstICmp) LLVMValueRef + (Predicate LLVMIntPredicate) + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstFCmp" LLVMConstFCmp) LLVMValueRef + (Predicate LLVMRealPredicate) + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstShl" LLVMConstShl) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstLShr" LLVMConstLShr) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstAShr" LLVMConstAShr) LLVMValueRef + (LHSConstant LLVMValueRef) + (RHSConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstGEP" %LLVMConstGEP) LLVMValueRef + (ConstantVal LLVMValueRef) + (ConstantIndices :pointer) + (NumIndices :unsigned-int)) + +(cffi:defcfun ("LLVMConstInBoundsGEP" %LLVMConstInBoundsGEP) LLVMValueRef + (ConstantVal LLVMValueRef) + (ConstantIndices :pointer) + (NumIndices :unsigned-int)) + +(cffi:defcfun ("LLVMConstTrunc" LLVMConstTrunc) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstSExt" LLVMConstSExt) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstZExt" LLVMConstZExt) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstFPTrunc" LLVMConstFPTrunc) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstFPExt" LLVMConstFPExt) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstUIToFP" LLVMConstUIToFP) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstSIToFP" LLVMConstSIToFP) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstFPToUI" LLVMConstFPToUI) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstFPToSI" LLVMConstFPToSI) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstPtrToInt" LLVMConstPtrToInt) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstIntToPtr" LLVMConstIntToPtr) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstBitCast" LLVMConstBitCast) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstZExtOrBitCast" LLVMConstZExtOrBitCast) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstSExtOrBitCast" LLVMConstSExtOrBitCast) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstTruncOrBitCast" LLVMConstTruncOrBitCast) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstPointerCast" LLVMConstPointerCast) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstIntCast" LLVMConstIntCast) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef) + (isSigned :boolean)) + +(cffi:defcfun ("LLVMConstFPCast" LLVMConstFPCast) LLVMValueRef + (ConstantVal LLVMValueRef) + (ToType LLVMTypeRef)) + +(cffi:defcfun ("LLVMConstSelect" LLVMConstSelect) LLVMValueRef + (ConstantCondition LLVMValueRef) + (ConstantIfTrue LLVMValueRef) + (ConstantIfFalse LLVMValueRef)) + +(cffi:defcfun ("LLVMConstExtractElement" LLVMConstExtractElement) LLVMValueRef + (VectorConstant LLVMValueRef) + (IndexConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstInsertElement" LLVMConstInsertElement) LLVMValueRef + (VectorConstant LLVMValueRef) + (ElementValueConstant LLVMValueRef) + (IndexConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstShuffleVector" LLVMConstShuffleVector) LLVMValueRef + (VectorAConstant LLVMValueRef) + (VectorBConstant LLVMValueRef) + (MaskConstant LLVMValueRef)) + +(cffi:defcfun ("LLVMConstExtractValue" %LLVMConstExtractValue) LLVMValueRef + (AggConstant LLVMValueRef) + (IdxList :pointer) + (NumIdx :unsigned-int)) + +(cffi:defcfun ("LLVMConstInsertValue" %LLVMConstInsertValue) LLVMValueRef + (AggConstant LLVMValueRef) + (ElementValueConstant LLVMValueRef) + (IdxList :pointer) + (NumIdx :unsigned-int)) + +(cffi:defcfun ("LLVMConstInlineAsm" LLVMConstInlineAsm) LLVMValueRef + (Ty LLVMTypeRef) + (AsmString :string) + (Constraints :string) + (HasSideEffects :boolean)) + +(cffi:defcfun ("LLVMGetGlobalParent" LLVMGetGlobalParent) LLVMModuleRef + (Global LLVMValueRef)) + +(cffi:defcfun ("LLVMIsDeclaration" LLVMIsDeclaration) :boolean + (Global LLVMValueRef)) + +(cffi:defcfun ("LLVMGetLinkage" LLVMGetLinkage) LLVMLinkage + (Global LLVMValueRef)) + +(cffi:defcfun ("LLVMSetLinkage" LLVMSetLinkage) :void + (Global LLVMValueRef) + (Linkage LLVMLinkage)) + +(cffi:defcfun ("LLVMGetSection" LLVMGetSection) :string + (Global LLVMValueRef)) + +(cffi:defcfun ("LLVMSetSection" LLVMSetSection) :void + (Global LLVMValueRef) + (Section :string)) + +(cffi:defcfun ("LLVMGetVisibility" LLVMGetVisibility) LLVMVisibility + (Global LLVMValueRef)) + +(cffi:defcfun ("LLVMSetVisibility" LLVMSetVisibility) :void + (Global LLVMValueRef) + (Viz LLVMVisibility)) + +(cffi:defcfun ("LLVMGetAlignment" LLVMGetAlignment) :unsigned-int + (Global LLVMValueRef)) + +(cffi:defcfun ("LLVMSetAlignment" LLVMSetAlignment) :void + (Global LLVMValueRef) + (Bytes :unsigned-int)) + +(cffi:defcfun ("LLVMAddGlobal" LLVMAddGlobal) LLVMValueRef + (M LLVMModuleRef) + (Ty LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMGetNamedGlobal" LLVMGetNamedGlobal) LLVMValueRef + (M LLVMModuleRef) + (Name :string)) + +(cffi:defcfun ("LLVMGetFirstGlobal" LLVMGetFirstGlobal) LLVMValueRef + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMGetLastGlobal" LLVMGetLastGlobal) LLVMValueRef + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMGetNextGlobal" LLVMGetNextGlobal) LLVMValueRef + (GlobalVar LLVMValueRef)) + +(cffi:defcfun ("LLVMGetPreviousGlobal" LLVMGetPreviousGlobal) LLVMValueRef + (GlobalVar LLVMValueRef)) + +(cffi:defcfun ("LLVMDeleteGlobal" LLVMDeleteGlobal) :void + (GlobalVar LLVMValueRef)) + +(cffi:defcfun ("LLVMGetInitializer" LLVMGetInitializer) LLVMValueRef + (GlobalVar LLVMValueRef)) + +(cffi:defcfun ("LLVMSetInitializer" LLVMSetInitializer) :void + (GlobalVar LLVMValueRef) + (ConstantVal LLVMValueRef)) + +(cffi:defcfun ("LLVMIsThreadLocal" LLVMIsThreadLocal) :boolean + (GlobalVar LLVMValueRef)) + +(cffi:defcfun ("LLVMSetThreadLocal" LLVMSetThreadLocal) :void + (GlobalVar LLVMValueRef) + (IsThreadLocal :boolean)) + +(cffi:defcfun ("LLVMIsGlobalConstant" LLVMIsGlobalConstant) :boolean + (GlobalVar LLVMValueRef)) + +(cffi:defcfun ("LLVMSetGlobalConstant" LLVMSetGlobalConstant) :void + (GlobalVar LLVMValueRef) + (IsConstant :boolean)) + +(cffi:defcfun ("LLVMAddAlias" LLVMAddAlias) LLVMValueRef + (M LLVMModuleRef) + (Ty LLVMTypeRef) + (Aliasee LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMAddFunction" LLVMAddFunction) LLVMValueRef + (M LLVMModuleRef) + (Name :string) + (FunctionTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMGetNamedFunction" LLVMGetNamedFunction) LLVMValueRef + (M LLVMModuleRef) + (Name :string)) + +(cffi:defcfun ("LLVMGetFirstFunction" LLVMGetFirstFunction) LLVMValueRef + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMGetLastFunction" LLVMGetLastFunction) LLVMValueRef + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMGetNextFunction" LLVMGetNextFunction) LLVMValueRef + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMGetPreviousFunction" LLVMGetPreviousFunction) LLVMValueRef + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMDeleteFunction" LLVMDeleteFunction) :void + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMGetIntrinsicID" LLVMGetIntrinsicID) :unsigned-int + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMGetFunctionCallConv" LLVMGetFunctionCallConv) :unsigned-int + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMSetFunctionCallConv" LLVMSetFunctionCallConv) :void + (Fn LLVMValueRef) + (CC :unsigned-int)) + +(cffi:defcfun ("LLVMGetGC" LLVMGetGC) :string + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMSetGC" LLVMSetGC) :void + (Fn LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMAddFunctionAttr" LLVMAddFunctionAttr) :void + (Fn LLVMValueRef) + (PA LLVMAttribute)) + +(cffi:defcfun ("LLVMGetFunctionAttr" LLVMGetFunctionAttr) LLVMAttribute + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMRemoveFunctionAttr" LLVMRemoveFunctionAttr) :void + (Fn LLVMValueRef) + (PA LLVMAttribute)) + +(cffi:defcfun ("LLVMCountParams" LLVMCountParams) :unsigned-int + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMGetParams" %LLVMGetParams) :void + (Fn LLVMValueRef) + (Params :pointer)) + +(cffi:defcfun ("LLVMGetParam" LLVMGetParam) LLVMValueRef + (Fn LLVMValueRef) + (Index :unsigned-int)) + +(cffi:defcfun ("LLVMGetParamParent" LLVMGetParamParent) LLVMValueRef + (Inst LLVMValueRef)) + +(cffi:defcfun ("LLVMGetFirstParam" LLVMGetFirstParam) LLVMValueRef + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMGetLastParam" LLVMGetLastParam) LLVMValueRef + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMGetNextParam" LLVMGetNextParam) LLVMValueRef + (Arg LLVMValueRef)) + +(cffi:defcfun ("LLVMGetPreviousParam" LLVMGetPreviousParam) LLVMValueRef + (Arg LLVMValueRef)) + +(cffi:defcfun ("LLVMAddAttribute" LLVMAddAttribute) :void + (Arg LLVMValueRef) + (PA LLVMAttribute)) + +(cffi:defcfun ("LLVMRemoveAttribute" LLVMRemoveAttribute) :void + (Arg LLVMValueRef) + (PA LLVMAttribute)) + +(cffi:defcfun ("LLVMGetAttribute" LLVMGetAttribute) LLVMAttribute + (Arg LLVMValueRef)) + +(cffi:defcfun ("LLVMSetParamAlignment" LLVMSetParamAlignment) :void + (Arg LLVMValueRef) + (align :unsigned-int)) + +(cffi:defcfun ("LLVMBasicBlockAsValue" LLVMBasicBlockAsValue) LLVMValueRef + (BB LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMValueIsBasicBlock" LLVMValueIsBasicBlock) :boolean + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMValueAsBasicBlock" LLVMValueAsBasicBlock) LLVMBasicBlockRef + (Val LLVMValueRef)) + +(cffi:defcfun ("LLVMGetBasicBlockParent" LLVMGetBasicBlockParent) LLVMValueRef + (BB LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMCountBasicBlocks" LLVMCountBasicBlocks) :unsigned-int + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMGetBasicBlocks" LLVMGetBasicBlocks) :void + (Fn LLVMValueRef) + (BasicBlocks :pointer)) + +(cffi:defcfun ("LLVMGetFirstBasicBlock" LLVMGetFirstBasicBlock) LLVMBasicBlockRef + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMGetLastBasicBlock" LLVMGetLastBasicBlock) LLVMBasicBlockRef + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMGetNextBasicBlock" LLVMGetNextBasicBlock) LLVMBasicBlockRef + (BB LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMGetPreviousBasicBlock" LLVMGetPreviousBasicBlock) LLVMBasicBlockRef + (BB LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMGetEntryBasicBlock" LLVMGetEntryBasicBlock) LLVMBasicBlockRef + (Fn LLVMValueRef)) + +(cffi:defcfun ("LLVMAppendBasicBlockInContext" %LLVMAppendBasicBlockInContext) LLVMBasicBlockRef + (C LLVMContextRef) + (Fn LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMInsertBasicBlockInContext" %LLVMInsertBasicBlockInContext) LLVMBasicBlockRef + (C LLVMContextRef) + (BB LLVMBasicBlockRef) + (Name :string)) + +(cffi:defcfun ("LLVMDeleteBasicBlock" LLVMDeleteBasicBlock) :void + (BB LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMGetInstructionParent" LLVMGetInstructionParent) LLVMBasicBlockRef + (Inst LLVMValueRef)) + +(cffi:defcfun ("LLVMGetFirstInstruction" LLVMGetFirstInstruction) LLVMValueRef + (BB LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMGetLastInstruction" LLVMGetLastInstruction) LLVMValueRef + (BB LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMGetNextInstruction" LLVMGetNextInstruction) LLVMValueRef + (Inst LLVMValueRef)) + +(cffi:defcfun ("LLVMGetPreviousInstruction" LLVMGetPreviousInstruction) LLVMValueRef + (Inst LLVMValueRef)) + +(cffi:defcfun ("LLVMSetInstructionCallConv" LLVMSetInstructionCallConv) :void + (Instr LLVMValueRef) + (CC :unsigned-int)) + +(cffi:defcfun ("LLVMGetInstructionCallConv" LLVMGetInstructionCallConv) :unsigned-int + (Instr LLVMValueRef)) + +(cffi:defcfun ("LLVMAddInstrAttribute" LLVMAddInstrAttribute) :void + (Instr LLVMValueRef) + (index :unsigned-int) + (arg2 LLVMAttribute)) + +(cffi:defcfun ("LLVMRemoveInstrAttribute" LLVMRemoveInstrAttribute) :void + (Instr LLVMValueRef) + (index :unsigned-int) + (arg2 LLVMAttribute)) + +(cffi:defcfun ("LLVMSetInstrParamAlignment" LLVMSetInstrParamAlignment) :void + (Instr LLVMValueRef) + (index :unsigned-int) + (align :unsigned-int)) + +(cffi:defcfun ("LLVMIsTailCall" LLVMIsTailCall) :boolean + (CallInst LLVMValueRef)) + +(cffi:defcfun ("LLVMSetTailCall" LLVMSetTailCall) :void + (CallInst LLVMValueRef) + (IsTailCall :boolean)) + +(cffi:defcfun ("LLVMAddIncoming" %LLVMAddIncoming) :void + (PhiNode LLVMValueRef) + (IncomingValues :pointer) + (IncomingBlocks :pointer) + (Count :unsigned-int)) + +(cffi:defcfun ("LLVMCountIncoming" LLVMCountIncoming) :unsigned-int + (PhiNode LLVMValueRef)) + +(cffi:defcfun ("LLVMGetIncomingValue" LLVMGetIncomingValue) LLVMValueRef + (PhiNode LLVMValueRef) + (Index :unsigned-int)) + +(cffi:defcfun ("LLVMGetIncomingBlock" LLVMGetIncomingBlock) LLVMBasicBlockRef + (PhiNode LLVMValueRef) + (Index :unsigned-int)) + +(cffi:defcfun ("LLVMCreateBuilderInContext" %LLVMCreateBuilderInContext) LLVMBuilderRef + (C LLVMContextRef)) + +(cffi:defcfun ("LLVMPositionBuilder" LLVMPositionBuilder) :void + (Builder LLVMBuilderRef) + (Block LLVMBasicBlockRef) + (Instr LLVMValueRef)) + +(cffi:defcfun ("LLVMPositionBuilderBefore" LLVMPositionBuilderBefore) :void + (Builder LLVMBuilderRef) + (Instr LLVMValueRef)) + +(cffi:defcfun ("LLVMPositionBuilderAtEnd" LLVMPositionBuilderAtEnd) :void + (Builder LLVMBuilderRef) + (Block LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMGetInsertBlock" LLVMGetInsertBlock) LLVMBasicBlockRef + (Builder LLVMBuilderRef)) + +(cffi:defcfun ("LLVMClearInsertionPosition" LLVMClearInsertionPosition) :void + (Builder LLVMBuilderRef)) + +(cffi:defcfun ("LLVMInsertIntoBuilder" LLVMInsertIntoBuilder) :void + (Builder LLVMBuilderRef) + (Instr LLVMValueRef)) + +(cffi:defcfun ("LLVMInsertIntoBuilderWithName" LLVMInsertIntoBuilderWithName) :void + (Builder LLVMBuilderRef) + (Instr LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMDisposeBuilder" LLVMDisposeBuilder) :void + (Builder LLVMBuilderRef)) + +(cffi:defcfun ("LLVMBuildRetVoid" LLVMBuildRetVoid) LLVMValueRef + (arg0 LLVMBuilderRef)) + +(cffi:defcfun ("LLVMBuildRet" LLVMBuildRet) LLVMValueRef + (arg0 LLVMBuilderRef) + (V LLVMValueRef)) + +(cffi:defcfun ("LLVMBuildAggregateRet" %LLVMBuildAggregateRet) LLVMValueRef + (arg0 LLVMBuilderRef) + (RetVals :pointer) + (N :unsigned-int)) + +(cffi:defcfun ("LLVMBuildBr" LLVMBuildBr) LLVMValueRef + (arg0 LLVMBuilderRef) + (Dest LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMBuildCondBr" LLVMBuildCondBr) LLVMValueRef + (arg0 LLVMBuilderRef) + (If LLVMValueRef) + (Then LLVMBasicBlockRef) + (Else LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMBuildSwitch" LLVMBuildSwitch) LLVMValueRef + (arg0 LLVMBuilderRef) + (V LLVMValueRef) + (Else LLVMBasicBlockRef) + (NumCases :unsigned-int)) + +(cffi:defcfun ("LLVMBuildInvoke" %LLVMBuildInvoke) LLVMValueRef + (arg0 LLVMBuilderRef) + (Fn LLVMValueRef) + (Args :pointer) + (NumArgs :unsigned-int) + (Then LLVMBasicBlockRef) + (Catch LLVMBasicBlockRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildUnwind" LLVMBuildUnwind) LLVMValueRef + (arg0 LLVMBuilderRef)) + +(cffi:defcfun ("LLVMBuildUnreachable" LLVMBuildUnreachable) LLVMValueRef + (arg0 LLVMBuilderRef)) + +(cffi:defcfun ("LLVMAddCase" LLVMAddCase) :void + (Switch LLVMValueRef) + (OnVal LLVMValueRef) + (Dest LLVMBasicBlockRef)) + +(cffi:defcfun ("LLVMBuildAdd" LLVMBuildAdd) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildNSWAdd" LLVMBuildNSWAdd) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFAdd" LLVMBuildFAdd) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildSub" LLVMBuildSub) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFSub" LLVMBuildFSub) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildMul" LLVMBuildMul) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFMul" LLVMBuildFMul) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildUDiv" LLVMBuildUDiv) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildSDiv" LLVMBuildSDiv) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildExactSDiv" LLVMBuildExactSDiv) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFDiv" LLVMBuildFDiv) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildURem" LLVMBuildURem) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildSRem" LLVMBuildSRem) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFRem" LLVMBuildFRem) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildShl" LLVMBuildShl) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildLShr" LLVMBuildLShr) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildAShr" LLVMBuildAShr) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildAnd" LLVMBuildAnd) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildOr" LLVMBuildOr) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildXor" LLVMBuildXor) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildNeg" LLVMBuildNeg) LLVMValueRef + (arg0 LLVMBuilderRef) + (V LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFNeg" LLVMBuildFNeg) LLVMValueRef + (arg0 LLVMBuilderRef) + (V LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildNot" LLVMBuildNot) LLVMValueRef + (arg0 LLVMBuilderRef) + (V LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildMalloc" LLVMBuildMalloc) LLVMValueRef + (arg0 LLVMBuilderRef) + (Ty LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildArrayMalloc" LLVMBuildArrayMalloc) LLVMValueRef + (arg0 LLVMBuilderRef) + (Ty LLVMTypeRef) + (Val LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildAlloca" LLVMBuildAlloca) LLVMValueRef + (arg0 LLVMBuilderRef) + (Ty LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildArrayAlloca" LLVMBuildArrayAlloca) LLVMValueRef + (arg0 LLVMBuilderRef) + (Ty LLVMTypeRef) + (Val LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFree" LLVMBuildFree) LLVMValueRef + (arg0 LLVMBuilderRef) + (PointerVal LLVMValueRef)) + +(cffi:defcfun ("LLVMBuildLoad" LLVMBuildLoad) LLVMValueRef + (arg0 LLVMBuilderRef) + (PointerVal LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildStore" LLVMBuildStore) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (Ptr LLVMValueRef)) + +(cffi:defcfun ("LLVMBuildGEP" %LLVMBuildGEP) LLVMValueRef + (B LLVMBuilderRef) + (Pointer LLVMValueRef) + (Indices :pointer) + (NumIndices :unsigned-int) + (Name :string)) + +(cffi:defcfun ("LLVMBuildInBoundsGEP" %LLVMBuildInBoundsGEP) LLVMValueRef + (B LLVMBuilderRef) + (Pointer LLVMValueRef) + (Indices :pointer) + (NumIndices :unsigned-int) + (Name :string)) + +(cffi:defcfun ("LLVMBuildStructGEP" LLVMBuildStructGEP) LLVMValueRef + (B LLVMBuilderRef) + (Pointer LLVMValueRef) + (Idx :unsigned-int) + (Name :string)) + +(cffi:defcfun ("LLVMBuildGlobalString" LLVMBuildGlobalString) LLVMValueRef + (B LLVMBuilderRef) + (Str :string) + (Name :string)) + +(cffi:defcfun ("LLVMBuildGlobalStringPtr" LLVMBuildGlobalStringPtr) LLVMValueRef + (B LLVMBuilderRef) + (Str :string) + (Name :string)) + +(cffi:defcfun ("LLVMBuildTrunc" LLVMBuildTrunc) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildZExt" LLVMBuildZExt) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildSExt" LLVMBuildSExt) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFPToUI" LLVMBuildFPToUI) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFPToSI" LLVMBuildFPToSI) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildUIToFP" LLVMBuildUIToFP) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildSIToFP" LLVMBuildSIToFP) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFPTrunc" LLVMBuildFPTrunc) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFPExt" LLVMBuildFPExt) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildPtrToInt" LLVMBuildPtrToInt) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildIntToPtr" LLVMBuildIntToPtr) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildBitCast" LLVMBuildBitCast) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildZExtOrBitCast" LLVMBuildZExtOrBitCast) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildSExtOrBitCast" LLVMBuildSExtOrBitCast) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildTruncOrBitCast" LLVMBuildTruncOrBitCast) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildPointerCast" LLVMBuildPointerCast) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildIntCast" LLVMBuildIntCast) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFPCast" LLVMBuildFPCast) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (DestTy LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildICmp" LLVMBuildICmp) LLVMValueRef + (arg0 LLVMBuilderRef) + (Op LLVMIntPredicate) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildFCmp" LLVMBuildFCmp) LLVMValueRef + (arg0 LLVMBuilderRef) + (Op LLVMRealPredicate) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildPhi" LLVMBuildPhi) LLVMValueRef + (arg0 LLVMBuilderRef) + (Ty LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildCall" %LLVMBuildCall) LLVMValueRef + (arg0 LLVMBuilderRef) + (Fn LLVMValueRef) + (Args :pointer) + (NumArgs :unsigned-int) + (Name :string)) + +(cffi:defcfun ("LLVMBuildSelect" LLVMBuildSelect) LLVMValueRef + (arg0 LLVMBuilderRef) + (If LLVMValueRef) + (Then LLVMValueRef) + (Else LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildVAArg" LLVMBuildVAArg) LLVMValueRef + (arg0 LLVMBuilderRef) + (List LLVMValueRef) + (Ty LLVMTypeRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildExtractElement" LLVMBuildExtractElement) LLVMValueRef + (arg0 LLVMBuilderRef) + (VecVal LLVMValueRef) + (Index LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildInsertElement" LLVMBuildInsertElement) LLVMValueRef + (arg0 LLVMBuilderRef) + (VecVal LLVMValueRef) + (EltVal LLVMValueRef) + (Index LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildShuffleVector" LLVMBuildShuffleVector) LLVMValueRef + (arg0 LLVMBuilderRef) + (V1 LLVMValueRef) + (V2 LLVMValueRef) + (Mask LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildExtractValue" LLVMBuildExtractValue) LLVMValueRef + (arg0 LLVMBuilderRef) + (AggVal LLVMValueRef) + (Index :unsigned-int) + (Name :string)) + +(cffi:defcfun ("LLVMBuildInsertValue" LLVMBuildInsertValue) LLVMValueRef + (arg0 LLVMBuilderRef) + (AggVal LLVMValueRef) + (EltVal LLVMValueRef) + (Index :unsigned-int) + (Name :string)) + +(cffi:defcfun ("LLVMBuildIsNull" LLVMBuildIsNull) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildIsNotNull" LLVMBuildIsNotNull) LLVMValueRef + (arg0 LLVMBuilderRef) + (Val LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMBuildPtrDiff" LLVMBuildPtrDiff) LLVMValueRef + (arg0 LLVMBuilderRef) + (LHS LLVMValueRef) + (RHS LLVMValueRef) + (Name :string)) + +(cffi:defcfun ("LLVMCreateModuleProviderForExistingModule" LLVMCreateModuleProviderForExistingModule) LLVMModuleProviderRef + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMDisposeModuleProvider" LLVMDisposeModuleProvider) :void + (MP LLVMModuleProviderRef)) + +(cffi:defcfun ("LLVMCreateMemoryBufferWithContentsOfFile" LLVMCreateMemoryBufferWithContentsOfFile) :boolean + (Path :string) + (OutMemBuf :pointer) + (OutMessage :pointer)) + +(cffi:defcfun ("LLVMCreateMemoryBufferWithSTDIN" LLVMCreateMemoryBufferWithSTDIN) :boolean + (OutMemBuf :pointer) + (OutMessage :pointer)) + +(cffi:defcfun ("LLVMDisposeMemoryBuffer" LLVMDisposeMemoryBuffer) :void + (MemBuf LLVMMemoryBufferRef)) + +(cffi:defcfun ("LLVMCreatePassManager" LLVMCreatePassManager) LLVMPassManagerRef) + +(cffi:defcfun ("LLVMCreateFunctionPassManager" LLVMCreateFunctionPassManager) LLVMPassManagerRef + (MP LLVMModuleProviderRef)) + +(cffi:defcfun ("LLVMRunPassManager" LLVMRunPassManager) :boolean + (PM LLVMPassManagerRef) + (M LLVMModuleRef)) + +(cffi:defcfun ("LLVMInitializeFunctionPassManager" LLVMInitializeFunctionPassManager) :boolean + (FPM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMRunFunctionPassManager" LLVMRunFunctionPassManager) :boolean + (FPM LLVMPassManagerRef) + (F LLVMValueRef)) + +(cffi:defcfun ("LLVMFinalizeFunctionPassManager" LLVMFinalizeFunctionPassManager) :boolean + (FPM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMDisposePassManager" LLVMDisposePassManager) :void + (PM LLVMPassManagerRef)) + +;;; The wrappers to expose the "InContext" versions of the functions +;;; in a more lispy way. +(declaim (special *llvm-context*)) + +(defun LLVMModuleCreateWithName (ModuleId &optional (context *llvm-context*)) + (%LLVMModuleCreateWithNameInContext ModuleId context)) + +(defun LLVMInt1Type (&optional (context *llvm-context*)) + (%LLVMInt1TypeInContext context)) + +(defun LLVMInt8Type (&optional (context *llvm-context*)) + (%LLVMInt8TypeInContext context)) + +(defun LLVMInt16Type (&optional (context *llvm-context*)) + (%LLVMInt16TypeInContext context)) + +(defun LLVMInt32Type (&optional (context *llvm-context*)) + (%LLVMInt32TypeInContext context)) + +(defun LLVMInt64Type (&optional (context *llvm-context*)) + (%LLVMInt64TypeInContext context)) + +(defun LLVMIntType (NumBits &optional (context *llvm-context*)) + (%LLVMIntTypeInContext context NumBits)) + +(defun LLVMFloatType (&optional (context *llvm-context*)) + (%LLVMFloatTypeInContext context)) + +(defun LLVMDoubleType (&optional (context *llvm-context*)) + (%LLVMDoubleTypeInContext context)) + +(defun LLVMX86FP80Type (&optional (context *llvm-context*)) + (%LLVMX86FP80TypeInContext context)) + +(defun LLVMFP128Type (&optional (context *llvm-context*)) + (%LLVMFP128TypeInContext context)) + +(defun LLVMPPCFP128Type (&optional (context *llvm-context*)) + (%LLVMPPCFP128TypeInContext context)) + +;; LLVMStructTypeInContext handled below. + +(defun LLVMVoidType (&optional (context *llvm-context*)) + (%LLVMVoidTypeInContext context)) + +(defun LLVMLabelType (&optional (context *llvm-context*)) + (%LLVMLabelTypeInContext context)) + +(defun LLVMOpaqueType (&optional (context *llvm-context*)) + (%LLVMOpaqueTypeInContext context)) + +;; LLVMConstStringInContext handled below +;; LLVMConstStructInContext handled below + +(defun LLVMAppendBasicBlock (Fn Name &optional (context *llvm-context*)) + (%LLVMAppendBasicBlockInContext context Fn Name)) + +(defun LLVMInsertBasicBlock (BB Name &optional (context *llvm-context*)) + (%LLVMInsertBasicBlockInContext context BB Name)) + +(defun LLVMCreateBuilder (&optional (context *llvm-context*)) + (%LLVMCreateBuilderInContext context)) + + +;; More complex wrappers for dealing with pointers. + +(defmacro with-array-and-length ((array len list) &body body) + (let ((list-v (gensym "list"))) + `(let* ((,list-v ,list) + (,len (length ,list-v))) + (cffi:with-foreign-object (,array :pointer ,len) + (loop for l in ,list-v + for i from 0 + do + (setf (cffi:mem-aref ,array :pointer i) l)) + (progn ,@body))))) + +(defun LLVMFunctionType (ret params is-var-arg) + "Combines the C API's ParamTypes array and ParamCount arguments into +a single list PARAMS." + (with-array-and-length (array len params) + (%LLVMFunctionType ret array len is-var-arg))) + +(defun LLVMGetParamTypes (function-type) + "Returns a list of param types rather than filling out a Dest pointer argument" + (let ((len (LLVMCountParamTypes function-type))) + (cffi:with-foreign-object (array :pointer len) + (%LLVMGetParamTypes function-type array) + (loop for i from 0 below len + collect + (cffi:mem-aref array :pointer i))))) + +(defun LLVMStructType (element-types is-packed &optional (context *llvm-context*)) + (with-array-and-length (array len element-types) + (%LLVMStructTypeInContext context array len is-packed))) + +(defun LLVMGetStructElementTypes (struct-type) + "Returns a list of param types rather than filling out a Dest pointer argument" + (let ((len (LLVMCountStructElementTypes struct-type))) + (cffi:with-foreign-object (array :pointer len) + (%LLVMGetStructElementTypes struct-type array) + (loop for i from 0 below len + collect + (cffi:mem-aref array :pointer i))))) + +(defun LLVMConstString (str dont-null-terminate &optional (context *llvm-context*)) + (cffi:with-foreign-string ((foreign-string num-bytes) str) + (%LLVMConstStringInContext context foreign-string num-bytes dont-null-terminate))) + +(defun LLVMConstStruct (vals packed-p &optional (context *llvm-context*)) + (with-array-and-length (array len vals) + (%LLVMConstStructInContext context array len packed-p))) + +(defun LLVMConstArray (type vals) + (with-array-and-length (array len vals) + (%LLVMConstArray type array len))) + +(defun LLVMConstVector (vals) + (with-array-and-length (array len vals) + (%LLVMConstVector array len))) + +(defun LLVMConstGEP (ptr indices) + (with-array-and-length (array len indices) + (%LLVMConstGEP ptr array len))) + +(defun LLVMConstInBoundsGEP (ptr indices) + (with-array-and-length (array len indices) + (%LLVMConstInBoundsGEP ptr array len))) + +(defun LLVMConstExtractValue (AggConstant indices) + (with-array-and-length (array len indices) + (%LLVMConstExtractValue AggConstant array len))) + +(defun LLVMConstInsertValue (AggConstant ValConstant indices) + (with-array-and-length (array len indices) + (%LLVMConstInsertValue AggConstant ValConstant array len))) + +(defun LLVMGetParams (fn) + "Returns a list of params rather than filling out a Dest pointer argument." + (let ((len (LLVMCountParams fn))) + (cffi:with-foreign-object (array :pointer len) + (%LLVMGetParams fn array) + (loop for i from 0 below len + collect + (cffi:mem-aref array :pointer i))))) + +(defun LLVMAddIncoming (phi-node incoming-val incoming-block) + "Unlike the C API (but like the C++ API...), takes only a single +incoming val and incoming block. Call multiple times if you want to +add multiple incoming values." + (cffi:with-foreign-objects ((incoming-vals :pointer) + (incoming-blocks :pointer)) + (setf (cffi:mem-aref incoming-vals :pointer 0) incoming-val) + (setf (cffi:mem-aref incoming-blocks :pointer 0) incoming-block) + (%LLVMAddIncoming phi-node incoming-vals incoming-blocks 1))) + +(defun LLVMBuildAggregateRet (builder vals) + (with-array-and-length (array len vals) + (%LLVMBuildAggregateRet builder array len))) + +(defun LLVMBuildInvoke (builder fn args then catch name) + (with-array-and-length (array len args) + (%LLVMBuildInvoke builder fn array len then catch name))) + +(defun LLVMBuildGEP (builder ptr indices name) + (with-array-and-length (array len indices) + (%LLVMBuildGEP builder ptr array len name))) + +(defun LLVMBuildInBoundsGEP (builder ptr indices name) + (with-array-and-length (array len indices) + (%LLVMBuildInBoundsGEP builder ptr array len name))) + +(defun LLVMBuildCall (builder fn args name) + "Combines the C API's Args array and NumArgs arguments into a single +list ARGS." + (with-array-and-length (array len args) + (%LLVMBuildCall builder fn array len name))) + +;; TODO: +;; LLVMCreateMemoryBufferWithContentsOfFile has OutMemBuf, OutMessage +;; LLVMCreateMemoryBufferWithSTDIN has OutMemBuf, OutMessage + + + diff --git a/src/generated/execution-engine.lisp b/src/generated/execution-engine.lisp new file mode 100644 index 0000000..18c24f1 --- /dev/null +++ b/src/generated/execution-engine.lisp @@ -0,0 +1,129 @@ +;;; This file was automatically generated by SWIG (http://www.swig.org). +;;; Version 1.3.40 +;;; +;;; Do not make changes to this file unless you know what you are doing--modify +;;; the SWIG interface file instead. + +(in-package :llvm) + + +(cffi:defcfun ("LLVMLinkInJIT" LLVMLinkInJIT) :void) + +(cffi:defcfun ("LLVMLinkInInterpreter" LLVMLinkInInterpreter) :void) + +(cffi:defctype LLVMGenericValueRef :pointer) + +(cffi:defctype LLVMExecutionEngineRef :pointer) + +(cffi:defcfun ("LLVMCreateGenericValueOfInt" LLVMCreateGenericValueOfInt) LLVMGenericValueRef + (Ty LLVMTypeRef) + (N :unsigned-long-long) + (IsSigned :boolean)) + +(cffi:defcfun ("LLVMCreateGenericValueOfPointer" LLVMCreateGenericValueOfPointer) LLVMGenericValueRef + (P :pointer)) + +(cffi:defcfun ("LLVMCreateGenericValueOfFloat" LLVMCreateGenericValueOfFloat) LLVMGenericValueRef + (Ty LLVMTypeRef) + (N :double)) + +(cffi:defcfun ("LLVMGenericValueIntWidth" LLVMGenericValueIntWidth) :unsigned-int + (GenValRef LLVMGenericValueRef)) + +(cffi:defcfun ("LLVMGenericValueToInt" LLVMGenericValueToInt) :unsigned-long-long + (GenVal LLVMGenericValueRef) + (IsSigned :boolean)) + +(cffi:defcfun ("LLVMGenericValueToPointer" LLVMGenericValueToPointer) :pointer + (GenVal LLVMGenericValueRef)) + +(cffi:defcfun ("LLVMGenericValueToFloat" LLVMGenericValueToFloat) :double + (TyRef LLVMTypeRef) + (GenVal LLVMGenericValueRef)) + +(cffi:defcfun ("LLVMDisposeGenericValue" LLVMDisposeGenericValue) :void + (GenVal LLVMGenericValueRef)) + +(cffi:defcfun ("LLVMCreateExecutionEngine" LLVMCreateExecutionEngine) :boolean + (OutEE :pointer) + (MP LLVMModuleProviderRef) + (OutError :pointer)) + +(cffi:defcfun ("LLVMCreateInterpreter" LLVMCreateInterpreter) :boolean + (OutInterp :pointer) + (MP LLVMModuleProviderRef) + (OutError :pointer)) + +(cffi:defcfun ("LLVMCreateJITCompiler" %LLVMCreateJITCompiler) :boolean + (OutJIT :pointer) + (MP LLVMModuleProviderRef) + (OptLevel :unsigned-int) + (OutError :pointer)) + +(cffi:defcfun ("LLVMDisposeExecutionEngine" LLVMDisposeExecutionEngine) :void + (EE LLVMExecutionEngineRef)) + +(cffi:defcfun ("LLVMRunStaticConstructors" LLVMRunStaticConstructors) :void + (EE LLVMExecutionEngineRef)) + +(cffi:defcfun ("LLVMRunStaticDestructors" LLVMRunStaticDestructors) :void + (EE LLVMExecutionEngineRef)) + +(cffi:defcfun ("LLVMRunFunctionAsMain" LLVMRunFunctionAsMain) :boolean + (EE LLVMExecutionEngineRef) + (F LLVMValueRef) + (ArgC :unsigned-int) + (ArgV :pointer) + (EnvP :pointer)) + +(cffi:defcfun ("LLVMRunFunction" LLVMRunFunction) LLVMGenericValueRef + (EE LLVMExecutionEngineRef) + (F LLVMValueRef) + (NumArgs :unsigned-int) + (Args :pointer)) + +(cffi:defcfun ("LLVMFreeMachineCodeForFunction" LLVMFreeMachineCodeForFunction) :void + (EE LLVMExecutionEngineRef) + (F LLVMValueRef)) + +(cffi:defcfun ("LLVMAddModuleProvider" LLVMAddModuleProvider) :void + (EE LLVMExecutionEngineRef) + (MP LLVMModuleProviderRef)) + +(cffi:defcfun ("LLVMRemoveModuleProvider" LLVMRemoveModuleProvider) :boolean + (EE LLVMExecutionEngineRef) + (MP LLVMModuleProviderRef) + (OutMod :pointer) + (OutError :pointer)) + +(cffi:defcfun ("LLVMFindFunction" LLVMFindFunction) :boolean + (EE LLVMExecutionEngineRef) + (Name :string) + (OutFn :pointer)) + +(cffi:defcfun ("LLVMGetExecutionEngineTargetData" LLVMGetExecutionEngineTargetData) LLVMTargetDataRef + (EE LLVMExecutionEngineRef)) + +(cffi:defcfun ("LLVMAddGlobalMapping" LLVMAddGlobalMapping) :void + (EE LLVMExecutionEngineRef) + (Global LLVMValueRef) + (Addr :pointer)) + +(cffi:defcfun ("LLVMGetPointerToGlobal" LLVMGetPointerToGlobal) :pointer + (EE LLVMExecutionEngineRef) + (Global LLVMValueRef)) + + +(defun LLVMCreateJITCompiler (provider opt) + (cffi:with-foreign-objects ((out-engine :pointer) + (out-error-str :pointer)) + (if (null (%LLVMCreateJITCompiler out-engine provider opt out-error-str)) + (cffi:mem-ref out-engine :pointer) + (let* ((error-str (cffi:mem-ref out-error-str :pointer)) + (error-str-lisp (cffi:foreign-string-to-lisp error-str))) + (LLVMDisposeMessage error-str) + (error "LLVMCreateJITCompiler: ~s" error-str-lisp))))) + + + + diff --git a/src/generated/target.lisp b/src/generated/target.lisp new file mode 100644 index 0000000..89d6f36 --- /dev/null +++ b/src/generated/target.lisp @@ -0,0 +1,89 @@ +;;; This file was automatically generated by SWIG (http://www.swig.org). +;;; Version 1.3.40 +;;; +;;; Do not make changes to this file unless you know what you are doing--modify +;;; the SWIG interface file instead. + +(in-package :llvm) + + +(cffi:defcenum LLVMByteOrdering + :LLVMBigEndian + :LLVMLittleEndian) + +(cffi:defctype LLVMTargetDataRef :pointer) + +(cffi:defctype LLVMStructLayoutRef :pointer) + +(cffi:defcfun ("LLVMInitializeAllTargetInfos" LLVMInitializeAllTargetInfos) :void) + +(cffi:defcfun ("LLVMInitializeAllTargets" LLVMInitializeAllTargets) :void) + +(cffi:defcfun ("LLVMInitializeNativeTarget" LLVMInitializeNativeTarget) :boolean) + +(cffi:defcfun ("LLVMCreateTargetData" LLVMCreateTargetData) LLVMTargetDataRef + (StringRep :string)) + +(cffi:defcfun ("LLVMAddTargetData" LLVMAddTargetData) :void + (arg0 LLVMTargetDataRef) + (arg1 LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMCopyStringRepOfTargetData" LLVMCopyStringRepOfTargetData) :string + (arg0 LLVMTargetDataRef)) + +(cffi:defcfun ("LLVMByteOrder" LLVMByteOrder) LLVMByteOrdering + (arg0 LLVMTargetDataRef)) + +(cffi:defcfun ("LLVMPointerSize" LLVMPointerSize) :unsigned-int + (arg0 LLVMTargetDataRef)) + +(cffi:defcfun ("LLVMSizeOfTypeInBits" LLVMSizeOfTypeInBits) :unsigned-long-long + (arg0 LLVMTargetDataRef) + (arg1 LLVMTypeRef)) + +(cffi:defcfun ("LLVMStoreSizeOfType" LLVMStoreSizeOfType) :unsigned-long-long + (arg0 LLVMTargetDataRef) + (arg1 LLVMTypeRef)) + +(cffi:defcfun ("LLVMABISizeOfType" LLVMABISizeOfType) :unsigned-long-long + (arg0 LLVMTargetDataRef) + (arg1 LLVMTypeRef)) + +(cffi:defcfun ("LLVMABIAlignmentOfType" LLVMABIAlignmentOfType) :unsigned-int + (arg0 LLVMTargetDataRef) + (arg1 LLVMTypeRef)) + +(cffi:defcfun ("LLVMCallFrameAlignmentOfType" LLVMCallFrameAlignmentOfType) :unsigned-int + (arg0 LLVMTargetDataRef) + (arg1 LLVMTypeRef)) + +(cffi:defcfun ("LLVMPreferredAlignmentOfType" LLVMPreferredAlignmentOfType) :unsigned-int + (arg0 LLVMTargetDataRef) + (arg1 LLVMTypeRef)) + +(cffi:defcfun ("LLVMPreferredAlignmentOfGlobal" LLVMPreferredAlignmentOfGlobal) :unsigned-int + (arg0 LLVMTargetDataRef) + (GlobalVar LLVMValueRef)) + +(cffi:defcfun ("LLVMElementAtOffset" LLVMElementAtOffset) :unsigned-int + (arg0 LLVMTargetDataRef) + (StructTy LLVMTypeRef) + (Offset :unsigned-long-long)) + +(cffi:defcfun ("LLVMOffsetOfElement" LLVMOffsetOfElement) :unsigned-long-long + (arg0 LLVMTargetDataRef) + (StructTy LLVMTypeRef) + (Element :unsigned-int)) + +(cffi:defcfun ("LLVMInvalidateStructLayout" LLVMInvalidateStructLayout) :void + (arg0 LLVMTargetDataRef) + (StructTy LLVMTypeRef)) + +(cffi:defcfun ("LLVMDisposeTargetData" LLVMDisposeTargetData) :void + (arg0 LLVMTargetDataRef)) + +(cffi:defcfun ("CLLLVM_LLVMIntPtrTypeInContext" %LLVMIntPtrTypeInContext) LLVMTypeRef + (Context LLVMContextRef) + (TD LLVMTargetDataRef)) + + diff --git a/src/generated/transforms-scalar.lisp b/src/generated/transforms-scalar.lisp new file mode 100644 index 0000000..147e3a8 --- /dev/null +++ b/src/generated/transforms-scalar.lisp @@ -0,0 +1,76 @@ +;;; This file was automatically generated by SWIG (http://www.swig.org). +;;; Version 1.3.40 +;;; +;;; Do not make changes to this file unless you know what you are doing--modify +;;; the SWIG interface file instead. + +(in-package :llvm) + + +(cffi:defcfun ("LLVMAddAggressiveDCEPass" LLVMAddAggressiveDCEPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddCFGSimplificationPass" LLVMAddCFGSimplificationPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddDeadStoreEliminationPass" LLVMAddDeadStoreEliminationPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddGVNPass" LLVMAddGVNPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddIndVarSimplifyPass" LLVMAddIndVarSimplifyPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddInstructionCombiningPass" LLVMAddInstructionCombiningPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddJumpThreadingPass" LLVMAddJumpThreadingPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddLICMPass" LLVMAddLICMPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddLoopDeletionPass" LLVMAddLoopDeletionPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddLoopIndexSplitPass" LLVMAddLoopIndexSplitPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddLoopRotatePass" LLVMAddLoopRotatePass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddLoopUnrollPass" LLVMAddLoopUnrollPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddLoopUnswitchPass" LLVMAddLoopUnswitchPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddMemCpyOptPass" LLVMAddMemCpyOptPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddPromoteMemoryToRegisterPass" LLVMAddPromoteMemoryToRegisterPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddReassociatePass" LLVMAddReassociatePass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddSCCPPass" LLVMAddSCCPPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddScalarReplAggregatesPass" LLVMAddScalarReplAggregatesPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddSimplifyLibCallsPass" LLVMAddSimplifyLibCallsPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddTailCallEliminationPass" LLVMAddTailCallEliminationPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddConstantPropagationPass" LLVMAddConstantPropagationPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddDemoteMemoryToRegisterPass" LLVMAddDemoteMemoryToRegisterPass) :void + (PM LLVMPassManagerRef)) + + diff --git a/llvm-extras.cpp b/src/llvm-extras.cpp similarity index 79% rename from llvm-extras.cpp rename to src/llvm-extras.cpp index b04a08b..273d5e7 100644 --- a/llvm-extras.cpp +++ b/src/llvm-extras.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -11,6 +12,8 @@ int CLLLVM_LLVMInitializeNativeTarget() { LLVMInitializeNativeTarget(); } +// Functions missing in the LLVM C API + LLVMModuleRef CLLLVM_LLVMModuleProviderGetModule(LLVMModuleProviderRef modprovider) { return llvm::wrap(llvm::unwrap(modprovider)->getModule()); } @@ -24,4 +27,8 @@ LLVMModuleRef CLLLVM_LLVMParseAssemblyString(const char *AsmString, Error.Print("sbcl", llvm::errs()); } +LLVMTypeRef CLLLVM_LLVMIntPtrTypeInContext(LLVMContextRef Context, LLVMTargetDataRef TD) { + return llvm::wrap(llvm::unwrap(TD)->getIntPtrType(*llvm::unwrap(Context))); +} + } diff --git a/src/load-c-lib.lisp b/src/load-c-lib.lisp index fb93c68..e69de29 100644 --- a/src/load-c-lib.lisp +++ b/src/load-c-lib.lisp @@ -1,7 +0,0 @@ -;; HACK, how do you really do this? -(require :cffi) - -(cffi:define-foreign-library cl-llvm - (t (:default "/home/jknight/Projects/llvm/cl-llvm/cl-llvm"))) - -(cffi:use-foreign-library cl-llvm) diff --git a/src/packages-post.lisp b/src/packages-post.lisp new file mode 100644 index 0000000..f7f348c --- /dev/null +++ b/src/packages-post.lisp @@ -0,0 +1,13 @@ +(in-package :llvm) + +;; Export all symbols starting with "LLVM". + +(labels ((starts-with (s prefix) + (let* ((x (mismatch s prefix))) + (or (null x) (= x (length prefix)))))) + (do-symbols (symbol (find-package :llvm)) + (let ((symbol-name (symbol-name symbol))) + (when (or (starts-with symbol-name "LLVM") (starts-with symbol-name "CLLLVM")) + (export symbol))))) + +(export '(*llvm-context* *jit-module* *jit-module-provider* *jit-execution-engine* *jit-pass-manager*)) diff --git a/src/packages.lisp b/src/packages.lisp new file mode 100644 index 0000000..6e879df --- /dev/null +++ b/src/packages.lisp @@ -0,0 +1,4 @@ +(cl:defpackage :llvm + (:use + #:common-lisp)) + diff --git a/src/stuff.lisp b/src/stuff.lisp index dee0aaf..f0b12c6 100644 --- a/src/stuff.lisp +++ b/src/stuff.lisp @@ -1,53 +1,4 @@ -;; Define some wrappers around the low-level C API functions to make them easier to use. - -(defun LLVMFunctionType* (ret params is-var-arg) - (let ((len (length params))) - (cffi:with-foreign-object (array :pointer len) - (loop for param in params - for i from 0 - do - (setf (cffi:mem-aref array :pointer i) param)) - (LLVMFunctionType ret array len is-var-arg)))) - -(defun LLVMBuildCall* (builder fn args name) - (let ((len (length args))) - (cffi:with-foreign-object (array :pointer len) - (loop for arg in args - for i from 0 - do - (setf (cffi:mem-aref array :pointer i) arg)) - (LLVMBuildCall builder fn array len name)))) - -(defun LLVMAddIncoming* (phi-node incoming-val incoming-block) - (cffi:with-foreign-objects ((incoming-vals :pointer) - (incoming-blocks :pointer)) - (setf (cffi:mem-aref incoming-vals :pointer 0) incoming-val) - (setf (cffi:mem-aref incoming-blocks :pointer 0) incoming-block) - (LLVMAddIncoming phi-node incoming-vals incoming-blocks 1))) - -(defun LLVMCreateJITCompiler* (provider opt) - (cffi:with-foreign-objects ((out-engine :pointer) - (out-error-str :pointer)) - (if (= 0 (LLVMCreateJITCompiler out-engine provider opt out-error-str)) - (cffi:mem-ref out-engine :pointer) - (let* ((error-str (cffi:mem-ref out-error-str :pointer)) - (error-str-lisp (cffi:foreign-string-to-lisp error-str))) - (LLVMDisposeMessage error-str) - (error "LLVMCreateJITCompiler: ~s" error-str-lisp))))) - - -(defun LLVMBuildGEP* (builder ptr indices) - (let ((len (length indices))) - (cffi:with-foreign-object (array :pointer len) - (loop for arg in indices - for i from 0 - do - (setf (cffi:mem-aref array :pointer i) arg)) - (LLVMBuildGEP builder ptr array len "")))) - - - - +(in-package :llvm) ;; Load up the native codegen. (cffi:defcfun ("CLLLVM_LLVMInitializeNativeTarget" CLLLVM_LLVMInitializeNativeTarget) :int) (cffi:defcfun ("CLLLVM_LLVMModuleProviderGetModule" CLLLVM_LLVMModuleProviderGetModule) :pointer @@ -74,7 +25,7 @@ ;; Top-level LLVM module for running the JIT in. Other modules can be made for codegen-to-disk, but ;; only a single module for JIT execution can exist in the process. -(defvar *jit-module* (LLVMModuleCreateWithNameInContext "jit-module" *llvm-context*)) +(defvar *jit-module* (LLVMModuleCreateWithName "jit-module")) ;; Module provider...dunno what the purpose of this is, it wraps the module ;; Delete with LLVMDisposeModuleProvider; don't delete the wrapped module @@ -82,7 +33,7 @@ ;; Create the JIT compiler, optimization level 2 (whatever that means). This call fails if you run ;; it twice in a process. (which is why we can have only one module for JIT code) -(defvar *jit-execution-engine* (LLVMCreateJITCompiler* *jit-module-provider* 2)) +(defvar *jit-execution-engine* (LLVMCreateJITCompiler *jit-module-provider* 2)) ;; Optimization passes. Cleanup with LLVMDisposePassManager. (defvar *jit-pass-manager* (LLVMCreateFunctionPassManager *jit-module-provider*)) diff --git a/src/target.i b/src/target.i new file mode 100644 index 0000000..7fad340 --- /dev/null +++ b/src/target.i @@ -0,0 +1,8 @@ +%include "typemaps.i" + +%ignore LLVMIntPtrType; +%rename CLLLVM_LLVMIntPtrTypeInContext "%%LLVMIntPtrTypeInContext"; + +%include "llvm-c/Target.h" + +LLVMTypeRef CLLLVM_LLVMIntPtrTypeInContext(LLVMContextRef Context, LLVMTargetDataRef TD); diff --git a/src/transforms-scalar.i b/src/transforms-scalar.i new file mode 100644 index 0000000..f11a2f9 --- /dev/null +++ b/src/transforms-scalar.i @@ -0,0 +1,3 @@ +%include "typemaps.i" + +%include "llvm-c/Transforms/Scalar.h" diff --git a/src/typemaps.i b/src/typemaps.i new file mode 100644 index 0000000..4f14467 --- /dev/null +++ b/src/typemaps.i @@ -0,0 +1,47 @@ + +// Put everything in a package +%insert("lisphead") %{ +(in-package :llvm)%} + +%typemap(cin) LLVMBool ":boolean"; +%typemap(cout) LLVMBool ":boolean"; + +// These typemaps are a bit silly: all they do is provide +// documentation in the interfaces. All the actual types degenerate into +// :pointer, in any case, via defctype. + +// For Core.h +%typemap(cin) LLVMContextRef "LLVMContextRef"; +%typemap(cout) LLVMContextRef "LLVMContextRef"; +%typemap(cin) LLVMModuleRef "LLVMModuleRef"; +%typemap(cout) LLVMModuleRef "LLVMModuleRef"; +%typemap(cin) LLVMTypeRef "LLVMTypeRef"; +%typemap(cout) LLVMTypeRef "LLVMTypeRef"; +%typemap(cin) LLVMTypeHandleRef "LLVMTypeHandleRef"; +%typemap(cout) LLVMTypeHandleRef "LLVMTypeHandleRef"; +%typemap(cin) LLVMValueRef "LLVMValueRef"; +%typemap(cout) LLVMValueRef "LLVMValueRef"; +%typemap(cin) LLVMBasicBlockRef "LLVMBasicBlockRef"; +%typemap(cout) LLVMBasicBlockRef "LLVMBasicBlockRef"; +%typemap(cin) LLVMBuilderRef "LLVMBuilderRef"; +%typemap(cout) LLVMBuilderRef "LLVMBuilderRef"; +%typemap(cin) LLVMModuleProviderRef "LLVMModuleProviderRef"; +%typemap(cout) LLVMModuleProviderRef "LLVMModuleProviderRef"; +%typemap(cin) LLVMMemoryBufferRef "LLVMMemoryBufferRef"; +%typemap(cout) LLVMMemoryBufferRef "LLVMMemoryBufferRef"; +%typemap(cin) LLVMPassManagerRef "LLVMPassManagerRef"; +%typemap(cout) LLVMPassManagerRef "LLVMPassManagerRef"; +%typemap(cin) LLVMUseIteratorRef "LLVMUseIteratorRef"; +%typemap(cout) LLVMUseIteratorRef "LLVMUseIteratorRef"; + +// For ExecutionEngine.h +%typemap(cin) LLVMGenericValueRef "LLVMGenericValueRef"; +%typemap(cout) LLVMGenericValueRef "LLVMGenericValueRef"; +%typemap(cin) LLVMExecutionEngineRef "LLVMExecutionEngineRef"; +%typemap(cout) LLVMExecutionEngineRef "LLVMExecutionEngineRef"; + +// For Target.h +%typemap(cin) LLVMTargetDataRef "LLVMTargetDataRef"; +%typemap(cout) LLVMTargetDataRef "LLVMTargetDataRef"; +%typemap(cin) LLVMStructLayoutRef "LLVMStructLayoutRef"; +%typemap(cout) LLVMStructLayoutRef "LLVMStructLayoutRef"; -- 2.11.4.GIT From 5203ba6a765fa1e34e0d5e717cb66d8ef9b1f12d Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Mon, 21 Dec 2009 18:53:04 -0500 Subject: [PATCH 4/8] Update example so it works again. --- README | 7 ++ examples/test.lisp | 198 ++++++++++++++++++++++------------------------------- 2 files changed, 88 insertions(+), 117 deletions(-) rewrite examples/test.lisp (63%) diff --git a/README b/README index 13281fe..25f52dc 100644 --- a/README +++ b/README @@ -26,6 +26,13 @@ USING 3) (require 'cl-llvm) + +There's an example of usage in examples/test.lisp. + +A more substantial example of usage is my work to port SBCL itself to +support an LLVM backend, available at: +http://repo.or.cz/w/sbcl/llvm.git/ + NOTES ===== diff --git a/examples/test.lisp b/examples/test.lisp dissimilarity index 63% index f320aba..0bb2fb3 100644 --- a/examples/test.lisp +++ b/examples/test.lisp @@ -1,117 +1,81 @@ -(require 'cl-llvm) - -;;; HACK! make sigabrt not abort. -;; (defun sigabrt-handler (signal info context) -;; (declare (ignore signal info)) -;; (declare (type system-area-pointer context)) -;; (sb-sys:with-interrupts -;; (error "sigabrt at #X~X" -;; (with-alien ((context (* sb-sys:os-context-t) context)) -;; (sb-sys:sap-int (sb-vm:context-pc context)))))) -;; (sb-sys:enable-interrupt sb-posix:sigabrt #'sigabrt-handler) - -;; Make a factorial function! -(defun build-fac-fun () - (let* ((mod *jit-module*)) - ;; Build it - (let* ((fac_args (list (LLVMInt32TypeInContext *llvm-context*))) - (fac (LLVMAddFunction mod "fac" (LLVMFunctionType* (LLVMInt32TypeInContext *llvm-context*) - fac_args 0))) - ;; Create code-builder object; this is reused throughout the rest of the function. - (builder (LLVMCreateBuilderInContext *llvm-context*))) - - ;; Use the c-call calling convention (the default) - (LLVMSetFunctionCallConv fac (cffi:foreign-enum-value 'LLVMCallConv :LLVMCCallConv)) - - ;; Create 4 new basic blocks: entry, iftrue, iffalse, end - (let* ((entry (LLVMAppendBasicBlockInContext *llvm-context* fac "entry")) - (iftrue (LLVMAppendBasicBlockInContext *llvm-context* fac "iftrue")) - (iffalse (LLVMAppendBasicBlockInContext *llvm-context* fac "iffalse")) - (end (LLVMAppendBasicBlock fac "end")) - ;; get 0th function argument - (n (LLVMGetParam fac 0)) - ;; make some extra vars to stick stuff in - res-iftrue res-iffalse) - - ;; Create entry BB - (LLVMPositionBuilderAtEnd builder entry) - (let* ((IfNode (LLVMBuildICmp builder :LLVMIntEQ n - (LLVMConstInt (LLVMInt32TypeInContext *llvm-context*) 0 0) - "n == 0"))) - (LLVMBuildCondBr builder IfNode iftrue iffalse)) - - ;; Create true BB - (LLVMPositionBuilderAtEnd builder iftrue) - (setf res-iftrue (LLVMConstInt (LLVMInt32TypeInContext *llvm-context*) 1 0)) - (LLVMBuildBr builder end) - - ;; Create false BB - (LLVMPositionBuilderAtEnd builder iffalse) - (let* ((n-minus (LLVMBuildSub builder n (LLVMConstInt (LLVMInt32TypeInContext *llvm-context*) 1 0) "n - 1")) - (call-fac (LLVMBuildCall* builder fac (list n-minus) "fac(n - 1)"))) - (setf res-iffalse (LLVMBuildMul builder n call-fac "n * fac(n - 1)"))) - (LLVMBuildBr builder end) - - ;; Create end BB - (LLVMPositionBuilderAtEnd builder end) - (let ((res (LLVMBuildPhi builder (LLVMInt32TypeInContext *llvm-context*) "result"))) - (LLVMAddIncoming* res res-iftrue iftrue) - (LLVMAddIncoming* res res-iffalse iffalse) - (LLVMBuildRet builder res))) - - ;; Verify that module is valid - (when (/= 0 (LLVMVerifyModule mod :LLVMPrintMessageAction (cffi:null-pointer))) - (error "Module didn't verify!")) - - ;; Dump textual description for debugging purposes - (LLVMDumpValue fac) - ;; Run some optimizations - (LLVMRunFunctionPassManager *jit-pass-manager* fac) - (LLVMDumpValue fac) - - ;; Clean up - (LLVMDisposeBuilder builder) - fac))) - -(defun build-string-fun () - (let* ((mod *jit-module*)) - ;; Build it - (let* ((fac_args (list (LLVMInt32TypeInContext *llvm-context*))) - (fac (LLVMAddFunction mod "fac" (LLVMFunctionType* (LLVMInt32TypeInContext *llvm-context*) - fac_args 0))) - ;; Create code-builder object; this is reused throughout the rest of the function. - (builder (LLVMCreateBuilderInContext *llvm-context*))) - - ;; Use the c-call calling convention (the default) - (LLVMSetFunctionCallConv fac (cffi:foreign-enum-value 'LLVMCallConv :LLVMCCallConv)) - - ;; Create 4 new basic blocks: entry, iftrue, iffalse, end - (let* ((entry (LLVMAppendBasicBlockInContext *llvm-context* fac "entry"))) - (LLVMPositionBuilderAtEnd builder entry) - (let ((global (LLVMAddGlobal mod (LLVMArrayType (LLVMInt8Type) 5) ".str"))) - (LLVMSetInitializer global (LLVMConstStringInContext *llvm-context* "asdf" 4 0)) - (LLVMSetGlobalConstant global 1) - (LLVMBuildRet builder (LLVMBuildGEP* builder global (list (LLVMConstInt (LLVMInt32Type) 0 0) - (LLVMConstInt (LLVMInt32Type) 0 0)))))) - - ;; Dump textual description for debugging purposes - (LLVMDumpValue fac) - - ;; Verify that module is valid - (when (/= 0 (LLVMVerifyModule mod :LLVMPrintMessageAction (cffi:null-pointer))) - (error "Module didn't verify!")) - - ;; Run some optimizations -; (LLVMRunFunctionPassManager *jit-pass-manager* fac) -; (LLVMDumpValue fac) - - ;; Clean up - (LLVMDisposeBuilder builder) - fac))) - -;; Run the code! -(defun run-fun (fun n) - (let ((fun-ptr (LLVMGetPointerToGlobal *jit-execution-engine* fun))) - (cffi:foreign-funcall-pointer fun-ptr () :int64 n :int64))) - - +;; To run the example: +;; (load (compile-file "test.lisp")) +;; (let ((fac (build-fac-fun))) +;; (run-fun fac 5)) +;; +;; TADA! it outputs 120. + +(require 'cl-llvm) +(use-package :llvm) + +;; Make a factorial function! +(defun build-fac-fun () + (let* ((mod *jit-module*)) + ;; Build it + (let* ((fac_args (list (LLVMInt32Type))) + (fac (LLVMAddFunction mod "fac" (LLVMFunctionType (LLVMInt32Type) + fac_args nil))) + ;; Create code-builder object; this is reused throughout the + ;; rest of the function. + (builder (LLVMCreateBuilder))) + + ;; Use the c-call calling convention (the default) + (LLVMSetFunctionCallConv fac (cffi:foreign-enum-value 'LLVMCallConv + :LLVMCCallConv)) + + ;; Create 4 new basic blocks: entry, iftrue, iffalse, end + (let* ((entry (LLVMAppendBasicBlock fac "entry")) + (iftrue (LLVMAppendBasicBlock fac "iftrue")) + (iffalse (LLVMAppendBasicBlock fac "iffalse")) + (end (LLVMAppendBasicBlock fac "end")) + ;; get 0th function argument + (n (LLVMGetParam fac 0)) + ;; make some extra vars to stick stuff in + res-iftrue res-iffalse) + + ;; Create entry BB + (LLVMPositionBuilderAtEnd builder entry) + (let* ((IfNode (LLVMBuildICmp builder :LLVMIntEQ n + (LLVMConstInt (LLVMInt32Type) 0 nil) + "n == 0"))) + (LLVMBuildCondBr builder IfNode iftrue iffalse)) + + ;; Create true BB + (LLVMPositionBuilderAtEnd builder iftrue) + (setf res-iftrue (LLVMConstInt (LLVMInt32Type) 1 nil)) + (LLVMBuildBr builder end) + + ;; Create false BB + (LLVMPositionBuilderAtEnd builder iffalse) + (let* ((n-minus (LLVMBuildSub builder n (LLVMConstInt (LLVMInt32Type) 1 nil) "n - 1")) + (call-fac (LLVMBuildCall builder fac (list n-minus) "fac(n - 1)"))) + (setf res-iffalse (LLVMBuildMul builder n call-fac "n * fac(n - 1)"))) + (LLVMBuildBr builder end) + + ;; Create end BB + (LLVMPositionBuilderAtEnd builder end) + (let ((res (LLVMBuildPhi builder (LLVMInt32Type) "result"))) + (LLVMAddIncoming res res-iftrue iftrue) + (LLVMAddIncoming res res-iffalse iffalse) + (LLVMBuildRet builder res))) + + ;; Verify that module is valid + (when (LLVMVerifyModule mod :LLVMPrintMessageAction (cffi:null-pointer)) + (error "Module didn't verify!")) + + ;; Dump textual description for debugging purposes + (LLVMDumpValue fac) + ;; Run some optimizations + (LLVMRunFunctionPassManager *jit-pass-manager* fac) + (LLVMDumpValue fac) + + ;; Clean up + (LLVMDisposeBuilder builder) + fac))) + +;; Run the function! +(defun run-fun (fun n) + (let ((fun-ptr (LLVMGetPointerToGlobal *jit-execution-engine* fun))) + (cffi:foreign-funcall-pointer fun-ptr () :int64 n :int64))) + + -- 2.11.4.GIT From 4af7b4d6688f2999b3114f8f6f6637569448e79e Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Tue, 29 Dec 2009 18:01:06 -0500 Subject: [PATCH 5/8] Mark LLVMAttribute as a bitfield, add some missing functions, note URLs for upstreamed SWIG/LLVM patches. --- README | 6 ++++++ src/core.i | 3 +++ src/generated/core.lisp | 5 +++-- src/generated/execution-engine.lisp | 2 +- src/llvm-extras.cpp | 28 ++++++++++++++++++++++++++++ src/stuff.lisp | 6 ++++++ 6 files changed, 47 insertions(+), 3 deletions(-) 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) -- 2.11.4.GIT From 9aea1d086521b297ead0b27b36497c01a6860b23 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Wed, 30 Dec 2009 13:51:12 -0500 Subject: [PATCH 6/8] Wrap more stuff, move some things around. --- cl-llvm.asd | 4 ++- src/Makefile | 12 ++++---- src/core.i | 5 ++++ src/generated/core.lisp | 8 ----- src/generated/llvm-extras.lisp | 52 +++++++++++++++++++++++++++++++++ src/generated/transforms-ipo.lisp | 52 +++++++++++++++++++++++++++++++++ src/llvm-extras.cpp | 61 ++++++++++++++++++++++++++++++++------- src/llvm-extras.i | 9 ++++++ src/stuff.lisp | 14 --------- src/transforms-ipo.i | 3 ++ src/typemaps.i | 17 +++++++++++ 11 files changed, 198 insertions(+), 39 deletions(-) create mode 100644 src/generated/llvm-extras.lisp create mode 100644 src/generated/transforms-ipo.lisp create mode 100644 src/llvm-extras.i create mode 100644 src/transforms-ipo.i diff --git a/cl-llvm.asd b/cl-llvm.asd index c385548..8d7b9ee 100644 --- a/cl-llvm.asd +++ b/cl-llvm.asd @@ -15,7 +15,9 @@ (:file "analysis") (:file "target") (:file "execution-engine") - (:file "transforms-scalar"))) + (:file "transforms-scalar") + (:file "transforms-ipo") + (:file "llvm-extras"))) (:file "stuff") (:file "packages-post"))))) diff --git a/src/Makefile b/src/Makefile index 379978e..5bf54b7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,11 +9,13 @@ LINKER=g++ LLVM_LIBS=-Wl,--whole-archive $(shell llvm-config --libs core jit interpreter native asmparser) -Wl,--no-whole-archive BINDINGS_FILES=$(addprefix generated/,\ - core.lisp \ - analysis.lisp \ - execution-engine.lisp \ - target.lisp \ - transforms-scalar.lisp) + core.lisp \ + analysis.lisp \ + execution-engine.lisp \ + target.lisp \ + transforms-scalar.lisp \ + transforms-ipo.lisp \ + llvm-extras.lisp) all: build diff --git a/src/core.i b/src/core.i index baabe7a..fec951d 100644 --- a/src/core.i +++ b/src/core.i @@ -72,6 +72,11 @@ typedef unsigned char uint8_t; %ignore LLVMCreateBuilder; %rename LLVMCreateBuilderInContext "%%LLVMCreateBuilderInContext"; + +// Discard broken functions, in favor of those defined in llvm-extras.cpp +%ignore LLVMAddFunctionAttr; +%ignore LLVMRemoveFunctionAttr; + %include "llvm-c/Core.h" diff --git a/src/generated/core.lisp b/src/generated/core.lisp index f745d19..17fb9a8 100644 --- a/src/generated/core.lisp +++ b/src/generated/core.lisp @@ -1029,17 +1029,9 @@ (Fn LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMAddFunctionAttr" LLVMAddFunctionAttr) :void - (Fn LLVMValueRef) - (PA LLVMAttribute)) - (cffi:defcfun ("LLVMGetFunctionAttr" LLVMGetFunctionAttr) LLVMAttribute (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMRemoveFunctionAttr" LLVMRemoveFunctionAttr) :void - (Fn LLVMValueRef) - (PA LLVMAttribute)) - (cffi:defcfun ("LLVMCountParams" LLVMCountParams) :unsigned-int (Fn LLVMValueRef)) diff --git a/src/generated/llvm-extras.lisp b/src/generated/llvm-extras.lisp new file mode 100644 index 0000000..30d484c --- /dev/null +++ b/src/generated/llvm-extras.lisp @@ -0,0 +1,52 @@ +;;; This file was automatically generated by SWIG (http://www.swig.org). +;;; Version 1.3.40 +;;; +;;; Do not make changes to this file unless you know what you are doing--modify +;;; the SWIG interface file instead. + +(in-package :llvm) + + +(cffi:defcfun ("CLLLVM_LLVMInitializeNativeTarget" CLLLVM_LLVMInitializeNativeTarget) :int) + +(cffi:defcfun ("CLLLVM_LLVMModuleProviderGetModule" CLLLVM_LLVMModuleProviderGetModule) LLVMModuleRef + (modprovider LLVMModuleProviderRef)) + +(cffi:defcfun ("CLLLVM_LLVMParseAssemblyString" CLLLVM_LLVMParseAssemblyString) LLVMModuleRef + (AsmString :string) + (M LLVMModuleRef) + (Context LLVMContextRef)) + +(cffi:defcfun ("CLLLVM_LLVMIntPtrTypeInContext" CLLLVM_LLVMIntPtrTypeInContext) LLVMTypeRef + (Context LLVMContextRef) + (TD LLVMTargetDataRef)) + +(cffi:defcfun ("CLLLVM_LLVMDumpModuleToString" CLLLVM_LLVMDumpModuleToString) :string + (module LLVMModuleRef)) + +(cffi:defcfun ("CLLLVM_LLVMDumpTypeToString" CLLLVM_LLVMDumpTypeToString) :string + (type LLVMTypeRef)) + +(cffi:defcfun ("CLLLVM_LLVMDumpValueToString" CLLLVM_LLVMDumpValueToString) :string + (value LLVMValueRef)) + +(cffi:defcfun ("CLLLVM_LLVMAddFunctionAttr" LLVMAddFunctionAttr) :void + (Fn LLVMValueRef) + (PA LLVMAttribute)) + +(cffi:defcfun ("CLLLVM_LLVMRemoveFunctionAttr" LLVMRemoveFunctionAttr) :void + (Fn LLVMValueRef) + (PA LLVMAttribute)) + +(cffi:defcfun ("CLLLVM_LLVMAddRetAttr" LLVMAddRetAttr) :void + (Fn LLVMValueRef) + (PA LLVMAttribute)) + +(cffi:defcfun ("CLLLVM_LLVMRemoveRetAttr" LLVMRemoveRetAttr) :void + (Fn LLVMValueRef) + (PA LLVMAttribute)) + +(cffi:defcfun ("CLLLVM_LLVMGetRetAttr" LLVMGetRetAttr) LLVMAttribute + (Fn LLVMValueRef)) + + diff --git a/src/generated/transforms-ipo.lisp b/src/generated/transforms-ipo.lisp new file mode 100644 index 0000000..e074137 --- /dev/null +++ b/src/generated/transforms-ipo.lisp @@ -0,0 +1,52 @@ +;;; This file was automatically generated by SWIG (http://www.swig.org). +;;; Version 1.3.40 +;;; +;;; Do not make changes to this file unless you know what you are doing--modify +;;; the SWIG interface file instead. + +(in-package :llvm) + + +(cffi:defcfun ("LLVMAddArgumentPromotionPass" LLVMAddArgumentPromotionPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddConstantMergePass" LLVMAddConstantMergePass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddDeadArgEliminationPass" LLVMAddDeadArgEliminationPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddDeadTypeEliminationPass" LLVMAddDeadTypeEliminationPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddFunctionAttrsPass" LLVMAddFunctionAttrsPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddFunctionInliningPass" LLVMAddFunctionInliningPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddGlobalDCEPass" LLVMAddGlobalDCEPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddGlobalOptimizerPass" LLVMAddGlobalOptimizerPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddIPConstantPropagationPass" LLVMAddIPConstantPropagationPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddLowerSetJmpPass" LLVMAddLowerSetJmpPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddPruneEHPass" LLVMAddPruneEHPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddRaiseAllocationsPass" LLVMAddRaiseAllocationsPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddStripDeadPrototypesPass" LLVMAddStripDeadPrototypesPass) :void + (PM LLVMPassManagerRef)) + +(cffi:defcfun ("LLVMAddStripSymbolsPass" LLVMAddStripSymbolsPass) :void + (PM LLVMPassManagerRef)) + + diff --git a/src/llvm-extras.cpp b/src/llvm-extras.cpp index b9643ce..2348bb6 100644 --- a/src/llvm-extras.cpp +++ b/src/llvm-extras.cpp @@ -5,6 +5,10 @@ #include #include +#ifndef SWIG +using namespace llvm; +#endif + extern "C" { // Declare here so the inline definition gets into the lib. Why is // there an inline function in a binding header anyways. :( @@ -17,46 +21,81 @@ int CLLLVM_LLVMInitializeNativeTarget() { LLVMModuleRef CLLLVM_LLVMModuleProviderGetModule(LLVMModuleProviderRef modprovider) { - return llvm::wrap(llvm::unwrap(modprovider)->getModule()); + return wrap(unwrap(modprovider)->getModule()); } LLVMModuleRef CLLLVM_LLVMParseAssemblyString(const char *AsmString, LLVMModuleRef M, LLVMContextRef Context) { - class llvm::SMDiagnostic Error; + class SMDiagnostic Error; LLVMModuleRef res = - llvm::wrap(llvm::ParseAssemblyString(AsmString, llvm::unwrap(M), Error, *llvm::unwrap(Context))); - Error.Print("sbcl", llvm::errs()); + wrap(ParseAssemblyString(AsmString, unwrap(M), Error, *unwrap(Context))); + Error.Print("sbcl", errs()); } LLVMTypeRef CLLLVM_LLVMIntPtrTypeInContext(LLVMContextRef Context, LLVMTargetDataRef TD) { - return llvm::wrap(llvm::unwrap(TD)->getIntPtrType(*llvm::unwrap(Context))); + return wrap(unwrap(TD)->getIntPtrType(*unwrap(Context))); } char *CLLLVM_LLVMDumpModuleToString(LLVMModuleRef module) { std::string s; - llvm::raw_string_ostream buf(s); - llvm::unwrap(module)->print(buf, NULL); + raw_string_ostream buf(s); + 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); + raw_string_ostream buf(s); + 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); + raw_string_ostream buf(s); + unwrap(value)->print(buf); return strdup(buf.str().c_str()); } + +// These are buggy in LLVM: they affect the return value attributes, +// not the fn attributes. +void CLLLVM_LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) { + Function *Func = unwrap(Fn); + const AttrListPtr PAL = Func->getAttributes(); + const AttrListPtr PALnew = PAL.addAttr(~0, PA); + Func->setAttributes(PALnew); } +void CLLLVM_LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) { + Function *Func = unwrap(Fn); + const AttrListPtr PAL = Func->getAttributes(); + const AttrListPtr PALnew = PAL.removeAttr(~0, PA); + Func->setAttributes(PALnew); +} +void CLLLVM_LLVMAddRetAttr(LLVMValueRef Fn, LLVMAttribute PA) { + Function *Func = unwrap(Fn); + const AttrListPtr PAL = Func->getAttributes(); + const AttrListPtr PALnew = PAL.addAttr(0, PA); + Func->setAttributes(PALnew); +} +void CLLLVM_LLVMRemoveRetAttr(LLVMValueRef Fn, LLVMAttribute PA) { + Function *Func = unwrap(Fn); + const AttrListPtr PAL = Func->getAttributes(); + const AttrListPtr PALnew = PAL.removeAttr(0, PA); + Func->setAttributes(PALnew); +} + +LLVMAttribute CLLLVM_LLVMGetRetAttr(LLVMValueRef Fn) { + Function *Func = unwrap(Fn); + const AttrListPtr PAL = Func->getAttributes(); + Attributes attr = PAL.getRetAttributes(); + return (LLVMAttribute)attr; +} + +} diff --git a/src/llvm-extras.i b/src/llvm-extras.i new file mode 100644 index 0000000..f6248da --- /dev/null +++ b/src/llvm-extras.i @@ -0,0 +1,9 @@ +%include "typemaps.i" + +%rename CLLLVM_LLVMAddFunctionAttr "LLVMAddFunctionAttr"; +%rename CLLLVM_LLVMRemoveFunctionAttr "LLVMRemoveFunctionAttr"; +%rename CLLLVM_LLVMAddRetAttr "LLVMAddRetAttr"; +%rename CLLLVM_LLVMRemoveRetAttr "LLVMRemoveRetAttr"; +%rename CLLLVM_LLVMGetRetAttr "LLVMGetRetAttr"; + +%include "./llvm-extras.cpp" diff --git a/src/stuff.lisp b/src/stuff.lisp index b5c0540..266deef 100644 --- a/src/stuff.lisp +++ b/src/stuff.lisp @@ -1,19 +1,5 @@ (in-package :llvm) ;; Load up the native codegen. -(cffi:defcfun ("CLLLVM_LLVMInitializeNativeTarget" CLLLVM_LLVMInitializeNativeTarget) :int) -(cffi:defcfun ("CLLLVM_LLVMModuleProviderGetModule" CLLLVM_LLVMModuleProviderGetModule) :pointer - (modprovider :pointer)) -(cffi:defcfun ("CLLLVM_LLVMParseAssemblyString" CLLLVM_LLVMParseAssemblyString) :pointer - (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) ;; A global context. Most of LLVM is only thread-safe within a single "context". There is an diff --git a/src/transforms-ipo.i b/src/transforms-ipo.i new file mode 100644 index 0000000..3deaabc --- /dev/null +++ b/src/transforms-ipo.i @@ -0,0 +1,3 @@ +%include "typemaps.i" + +%include "llvm-c/Transforms/IPO.h" diff --git a/src/typemaps.i b/src/typemaps.i index 4f14467..6bcbde6 100644 --- a/src/typemaps.i +++ b/src/typemaps.i @@ -11,6 +11,23 @@ // :pointer, in any case, via defctype. // For Core.h +%typemap(cin) LLVMAttribute "LLVMAttribute"; +%typemap(cout) LLVMAttribute "LLVMAttribute"; +%typemap(cin) LLVMOpcode "LLVMOpcode"; +%typemap(cout) LLVMOpcode "LLVMOpcode"; +%typemap(cin) LLVMTypeKind "LLVMTypeKind"; +%typemap(cout) LLVMTypeKind "LLVMTypeKind"; +%typemap(cin) LLVMLinkage "LLVMLinkage"; +%typemap(cout) LLVMLinkage "LLVMLinkage"; +%typemap(cin) LLVMVisibility "LLVMVisibility"; +%typemap(cout) LLVMVisibility "LLVMVisibility"; +%typemap(cin) LLVMCallConv "LLVMCallConv"; +%typemap(cout) LLVMCallConv "LLVMCallConv"; +%typemap(cin) LLVMIntPredicate "LLVMIntPredicate"; +%typemap(cout) LLVMIntPredicate "LLVMIntPredicate"; +%typemap(cin) LLVMRealPredicate "LLVMRealPredicate"; +%typemap(cout) LLVMRealPredicate "LLVMRealPredicate"; + %typemap(cin) LLVMContextRef "LLVMContextRef"; %typemap(cout) LLVMContextRef "LLVMContextRef"; %typemap(cin) LLVMModuleRef "LLVMModuleRef"; -- 2.11.4.GIT From 61fb1da43763707ce29905263209559edeee297e Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Fri, 1 Jan 2010 22:06:45 -0500 Subject: [PATCH 7/8] Make the "name" argument of LLVMBuild* an optional argument, defaulting to "". It'd be nice if CFFI's defcfun supported &optional itself. --- README | 10 +- src/Makefile | 6 +- src/core.i | 23 +- src/generated/core.lisp | 785 +++++++++++++++++++++-------------------- src/generated/llvm-extras.lisp | 4 + src/llvm-extras.cpp | 6 + src/stuff.lisp | 6 + 7 files changed, 448 insertions(+), 392 deletions(-) diff --git a/README b/README index 9f66de8..fd21e58 100644 --- a/README +++ b/README @@ -65,8 +65,14 @@ There are a few things which I have adjusted in the wrapper: take one at a time: call it multiple times to add multiple incoming values. -4) Where the C API uses an output array argument, such as +4) In LLVMBuild*, where the last argument is a "char *Name", I have + arranged to make that an optional argument, defaulting to the empty + string. The name is only used to give a human-understandable name + to the LHS of the assignment in the LLVM IR. If it is omitted, LLVM + has the sane default of an auto-incrementing integer. + +5) Where the C API uses an output array argument, such as LLVMGetStructElementTypes, I instead return a list. -5) Where the C API takes a pointer to a char *ErrorMsg, ...FIXME +6) Where the C API takes a pointer to a char *ErrorMsg, ...FIXME something... diff --git a/src/Makefile b/src/Makefile index 5bf54b7..ba06f9d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,7 +6,7 @@ CFLAGS=$(shell llvm-config --cflags) CXXFLAGS=$(CFLAGS) LDFLAGS=$(shell llvm-config --ldflags) LINKER=g++ -LLVM_LIBS=-Wl,--whole-archive $(shell llvm-config --libs core jit interpreter native asmparser) -Wl,--no-whole-archive +LLVM_LIBS=-Wl,--whole-archive $(shell llvm-config --libs core jit interpreter native asmparser ipo) -Wl,--no-whole-archive BINDINGS_FILES=$(addprefix generated/,\ core.lisp \ @@ -25,6 +25,10 @@ bindings: $(BINDINGS_FILES) generated/%.lisp: %.i $(SWIG) $(SWIGFLAGS) -o $@ -module $* $< +generated/core.lisp: core.i + $(SWIG) $(SWIGFLAGS) -o $@ -module core $< + sed 's/(cffi:defcfun/(wrap-defcfun/' -i generated/core.lisp + llvm-extras.o: llvm-extras.cpp cl-llvm.so: llvm-extras.o diff --git a/src/core.i b/src/core.i index fec951d..169af63 100644 --- a/src/core.i +++ b/src/core.i @@ -77,6 +77,21 @@ typedef unsigned char uint8_t; %ignore LLVMAddFunctionAttr; %ignore LLVMRemoveFunctionAttr; +%insert("swiglisp") %{ +;; A little hack make the Name argument for LLVMBuild* be optional and +;; default to the empty string. +(defmacro wrap-defcfun ((c-name lisp-name &rest options) return-type &body args) + (if (and (eql (mismatch "LLVMBuild" c-name) 9) + (equal (last args) '((Name :string)))) + (let ((real-lisp-name (intern (concatenate 'string "%" (symbol-name lisp-name)) + (symbol-package lisp-name))) + (mod-args (map 'list #'car (butlast args)))) + `(progn + ( cffi:defcfun (,c-name ,real-lisp-name ,@options) ,return-type ,@args) + (defmacro ,lisp-name (,@mod-args &optional (name "")) + `(,',real-lisp-name ,,@mod-args ,name)))) + `( cffi:defcfun (,c-name ,lisp-name ,@options) ,return-type ,@args))) +%} %include "llvm-c/Core.h" @@ -241,19 +256,19 @@ add multiple incoming values." (with-array-and-length (array len vals) (%LLVMBuildAggregateRet builder array len))) -(defun LLVMBuildInvoke (builder fn args then catch name) +(defun LLVMBuildInvoke (builder fn args then catch &optional (name "")) (with-array-and-length (array len args) (%LLVMBuildInvoke builder fn array len then catch name))) -(defun LLVMBuildGEP (builder ptr indices name) +(defun LLVMBuildGEP (builder ptr indices &optional (name "")) (with-array-and-length (array len indices) (%LLVMBuildGEP builder ptr array len name))) -(defun LLVMBuildInBoundsGEP (builder ptr indices name) +(defun LLVMBuildInBoundsGEP (builder ptr indices &optional (name "")) (with-array-and-length (array len indices) (%LLVMBuildInBoundsGEP builder ptr array len name))) -(defun LLVMBuildCall (builder fn args name) +(defun LLVMBuildCall (builder fn args &optional (name "")) "Combines the C API's Args array and NumArgs arguments into a single list ARGS." (with-array-and-length (array len args) diff --git a/src/generated/core.lisp b/src/generated/core.lisp index 17fb9a8..d078792 100644 --- a/src/generated/core.lisp +++ b/src/generated/core.lisp @@ -9,6 +9,21 @@ (cffi:defctype uint8_t :unsigned-char) +;; A little hack make the Name argument for LLVMBuild* be optional and +;; default to the empty string. +(defmacro wrap-defcfun ((c-name lisp-name &rest options) return-type &body args) + (if (and (eql (mismatch "LLVMBuild" c-name) 9) + (equal (last args) '((Name :string)))) + (let ((real-lisp-name (intern (concatenate 'string "%" (symbol-name lisp-name)) + (symbol-package lisp-name))) + (mod-args (map 'list #'car (butlast args)))) + `(progn + ( cffi:defcfun (,c-name ,real-lisp-name ,@options) ,return-type ,@args) + (defmacro ,lisp-name (,@mod-args &optional (name "")) + `(,',real-lisp-name ,,@mod-args ,name)))) + `( cffi:defcfun (,c-name ,lisp-name ,@options) ,return-type ,@args))) + + (cffi:defctype LLVMBool :int) (cffi:defctype LLVMContextRef :pointer) @@ -187,1063 +202,1063 @@ :LLVMRealUNE :LLVMRealPredicateTrue) -(cffi:defcfun ("LLVMDisposeMessage" LLVMDisposeMessage) :void +(wrap-defcfun ("LLVMDisposeMessage" LLVMDisposeMessage) :void (Message :string)) -(cffi:defcfun ("LLVMContextCreate" LLVMContextCreate) LLVMContextRef) +(wrap-defcfun ("LLVMContextCreate" LLVMContextCreate) LLVMContextRef) -(cffi:defcfun ("LLVMGetGlobalContext" LLVMGetGlobalContext) LLVMContextRef) +(wrap-defcfun ("LLVMGetGlobalContext" LLVMGetGlobalContext) LLVMContextRef) -(cffi:defcfun ("LLVMContextDispose" LLVMContextDispose) :void +(wrap-defcfun ("LLVMContextDispose" LLVMContextDispose) :void (C LLVMContextRef)) -(cffi:defcfun ("LLVMModuleCreateWithNameInContext" %LLVMModuleCreateWithNameInContext) LLVMModuleRef +(wrap-defcfun ("LLVMModuleCreateWithNameInContext" %LLVMModuleCreateWithNameInContext) LLVMModuleRef (ModuleID :string) (C LLVMContextRef)) -(cffi:defcfun ("LLVMDisposeModule" LLVMDisposeModule) :void +(wrap-defcfun ("LLVMDisposeModule" LLVMDisposeModule) :void (M LLVMModuleRef)) -(cffi:defcfun ("LLVMGetDataLayout" LLVMGetDataLayout) :string +(wrap-defcfun ("LLVMGetDataLayout" LLVMGetDataLayout) :string (M LLVMModuleRef)) -(cffi:defcfun ("LLVMSetDataLayout" LLVMSetDataLayout) :void +(wrap-defcfun ("LLVMSetDataLayout" LLVMSetDataLayout) :void (M LLVMModuleRef) (Triple :string)) -(cffi:defcfun ("LLVMGetTarget" LLVMGetTarget) :string +(wrap-defcfun ("LLVMGetTarget" LLVMGetTarget) :string (M LLVMModuleRef)) -(cffi:defcfun ("LLVMSetTarget" LLVMSetTarget) :void +(wrap-defcfun ("LLVMSetTarget" LLVMSetTarget) :void (M LLVMModuleRef) (Triple :string)) -(cffi:defcfun ("LLVMAddTypeName" LLVMAddTypeName) :boolean +(wrap-defcfun ("LLVMAddTypeName" LLVMAddTypeName) :boolean (M LLVMModuleRef) (Name :string) (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMDeleteTypeName" LLVMDeleteTypeName) :void +(wrap-defcfun ("LLVMDeleteTypeName" LLVMDeleteTypeName) :void (M LLVMModuleRef) (Name :string)) -(cffi:defcfun ("LLVMGetTypeByName" LLVMGetTypeByName) LLVMTypeRef +(wrap-defcfun ("LLVMGetTypeByName" LLVMGetTypeByName) LLVMTypeRef (M LLVMModuleRef) (Name :string)) -(cffi:defcfun ("LLVMDumpModule" LLVMDumpModule) :void +(wrap-defcfun ("LLVMDumpModule" LLVMDumpModule) :void (M LLVMModuleRef)) -(cffi:defcfun ("LLVMGetTypeKind" LLVMGetTypeKind) LLVMTypeKind +(wrap-defcfun ("LLVMGetTypeKind" LLVMGetTypeKind) LLVMTypeKind (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMGetTypeContext" LLVMGetTypeContext) LLVMContextRef +(wrap-defcfun ("LLVMGetTypeContext" LLVMGetTypeContext) LLVMContextRef (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMInt1TypeInContext" %LLVMInt1TypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMInt1TypeInContext" %LLVMInt1TypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMInt8TypeInContext" %LLVMInt8TypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMInt8TypeInContext" %LLVMInt8TypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMInt16TypeInContext" %LLVMInt16TypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMInt16TypeInContext" %LLVMInt16TypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMInt32TypeInContext" %LLVMInt32TypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMInt32TypeInContext" %LLVMInt32TypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMInt64TypeInContext" %LLVMInt64TypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMInt64TypeInContext" %LLVMInt64TypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMIntTypeInContext" %LLVMIntTypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMIntTypeInContext" %LLVMIntTypeInContext) LLVMTypeRef (C LLVMContextRef) (NumBits :unsigned-int)) -(cffi:defcfun ("LLVMGetIntTypeWidth" LLVMGetIntTypeWidth) :unsigned-int +(wrap-defcfun ("LLVMGetIntTypeWidth" LLVMGetIntTypeWidth) :unsigned-int (IntegerTy LLVMTypeRef)) -(cffi:defcfun ("LLVMFloatTypeInContext" %LLVMFloatTypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMFloatTypeInContext" %LLVMFloatTypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMDoubleTypeInContext" %LLVMDoubleTypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMDoubleTypeInContext" %LLVMDoubleTypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMX86FP80TypeInContext" %LLVMX86FP80TypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMX86FP80TypeInContext" %LLVMX86FP80TypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMFP128TypeInContext" %LLVMFP128TypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMFP128TypeInContext" %LLVMFP128TypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMPPCFP128TypeInContext" %LLVMPPCFP128TypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMPPCFP128TypeInContext" %LLVMPPCFP128TypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMFunctionType" %LLVMFunctionType) LLVMTypeRef +(wrap-defcfun ("LLVMFunctionType" %LLVMFunctionType) LLVMTypeRef (ReturnType LLVMTypeRef) (ParamTypes :pointer) (ParamCount :unsigned-int) (IsVarArg :boolean)) -(cffi:defcfun ("LLVMIsFunctionVarArg" LLVMIsFunctionVarArg) :boolean +(wrap-defcfun ("LLVMIsFunctionVarArg" LLVMIsFunctionVarArg) :boolean (FunctionTy LLVMTypeRef)) -(cffi:defcfun ("LLVMGetReturnType" LLVMGetReturnType) LLVMTypeRef +(wrap-defcfun ("LLVMGetReturnType" LLVMGetReturnType) LLVMTypeRef (FunctionTy LLVMTypeRef)) -(cffi:defcfun ("LLVMCountParamTypes" LLVMCountParamTypes) :unsigned-int +(wrap-defcfun ("LLVMCountParamTypes" LLVMCountParamTypes) :unsigned-int (FunctionTy LLVMTypeRef)) -(cffi:defcfun ("LLVMGetParamTypes" %LLVMGetParamTypes) :void +(wrap-defcfun ("LLVMGetParamTypes" %LLVMGetParamTypes) :void (FunctionTy LLVMTypeRef) (Dest :pointer)) -(cffi:defcfun ("LLVMStructTypeInContext" %LLVMStructTypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMStructTypeInContext" %LLVMStructTypeInContext) LLVMTypeRef (C LLVMContextRef) (ElementTypes :pointer) (ElementCount :unsigned-int) (Packed :boolean)) -(cffi:defcfun ("LLVMCountStructElementTypes" LLVMCountStructElementTypes) :unsigned-int +(wrap-defcfun ("LLVMCountStructElementTypes" LLVMCountStructElementTypes) :unsigned-int (StructTy LLVMTypeRef)) -(cffi:defcfun ("LLVMGetStructElementTypes" %LLVMGetStructElementTypes) :void +(wrap-defcfun ("LLVMGetStructElementTypes" %LLVMGetStructElementTypes) :void (StructTy LLVMTypeRef) (Dest :pointer)) -(cffi:defcfun ("LLVMIsPackedStruct" LLVMIsPackedStruct) :boolean +(wrap-defcfun ("LLVMIsPackedStruct" LLVMIsPackedStruct) :boolean (StructTy LLVMTypeRef)) -(cffi:defcfun ("LLVMArrayType" LLVMArrayType) LLVMTypeRef +(wrap-defcfun ("LLVMArrayType" LLVMArrayType) LLVMTypeRef (ElementType LLVMTypeRef) (ElementCount :unsigned-int)) -(cffi:defcfun ("LLVMPointerType" LLVMPointerType) LLVMTypeRef +(wrap-defcfun ("LLVMPointerType" LLVMPointerType) LLVMTypeRef (ElementType LLVMTypeRef) (AddressSpace :unsigned-int)) -(cffi:defcfun ("LLVMVectorType" LLVMVectorType) LLVMTypeRef +(wrap-defcfun ("LLVMVectorType" LLVMVectorType) LLVMTypeRef (ElementType LLVMTypeRef) (ElementCount :unsigned-int)) -(cffi:defcfun ("LLVMGetElementType" LLVMGetElementType) LLVMTypeRef +(wrap-defcfun ("LLVMGetElementType" LLVMGetElementType) LLVMTypeRef (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMGetArrayLength" LLVMGetArrayLength) :unsigned-int +(wrap-defcfun ("LLVMGetArrayLength" LLVMGetArrayLength) :unsigned-int (ArrayTy LLVMTypeRef)) -(cffi:defcfun ("LLVMGetPointerAddressSpace" LLVMGetPointerAddressSpace) :unsigned-int +(wrap-defcfun ("LLVMGetPointerAddressSpace" LLVMGetPointerAddressSpace) :unsigned-int (PointerTy LLVMTypeRef)) -(cffi:defcfun ("LLVMGetVectorSize" LLVMGetVectorSize) :unsigned-int +(wrap-defcfun ("LLVMGetVectorSize" LLVMGetVectorSize) :unsigned-int (VectorTy LLVMTypeRef)) -(cffi:defcfun ("LLVMVoidTypeInContext" %LLVMVoidTypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMVoidTypeInContext" %LLVMVoidTypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMLabelTypeInContext" %LLVMLabelTypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMLabelTypeInContext" %LLVMLabelTypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMOpaqueTypeInContext" %LLVMOpaqueTypeInContext) LLVMTypeRef +(wrap-defcfun ("LLVMOpaqueTypeInContext" %LLVMOpaqueTypeInContext) LLVMTypeRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMCreateTypeHandle" LLVMCreateTypeHandle) LLVMTypeHandleRef +(wrap-defcfun ("LLVMCreateTypeHandle" LLVMCreateTypeHandle) LLVMTypeHandleRef (PotentiallyAbstractTy LLVMTypeRef)) -(cffi:defcfun ("LLVMRefineType" LLVMRefineType) :void +(wrap-defcfun ("LLVMRefineType" LLVMRefineType) :void (AbstractTy LLVMTypeRef) (ConcreteTy LLVMTypeRef)) -(cffi:defcfun ("LLVMResolveTypeHandle" LLVMResolveTypeHandle) LLVMTypeRef +(wrap-defcfun ("LLVMResolveTypeHandle" LLVMResolveTypeHandle) LLVMTypeRef (TypeHandle LLVMTypeHandleRef)) -(cffi:defcfun ("LLVMDisposeTypeHandle" LLVMDisposeTypeHandle) :void +(wrap-defcfun ("LLVMDisposeTypeHandle" LLVMDisposeTypeHandle) :void (TypeHandle LLVMTypeHandleRef)) -(cffi:defcfun ("LLVMTypeOf" LLVMTypeOf) LLVMTypeRef +(wrap-defcfun ("LLVMTypeOf" LLVMTypeOf) LLVMTypeRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMGetValueName" LLVMGetValueName) :string +(wrap-defcfun ("LLVMGetValueName" LLVMGetValueName) :string (Val LLVMValueRef)) -(cffi:defcfun ("LLVMSetValueName" LLVMSetValueName) :void +(wrap-defcfun ("LLVMSetValueName" LLVMSetValueName) :void (Val LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMDumpValue" LLVMDumpValue) :void +(wrap-defcfun ("LLVMDumpValue" LLVMDumpValue) :void (Val LLVMValueRef)) -(cffi:defcfun ("LLVMReplaceAllUsesWith" LLVMReplaceAllUsesWith) :void +(wrap-defcfun ("LLVMReplaceAllUsesWith" LLVMReplaceAllUsesWith) :void (OldVal LLVMValueRef) (NewVal LLVMValueRef)) -(cffi:defcfun ("LLVMIsAArgument" LLVMIsAArgument) LLVMValueRef +(wrap-defcfun ("LLVMIsAArgument" LLVMIsAArgument) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsABasicBlock" LLVMIsABasicBlock) LLVMValueRef +(wrap-defcfun ("LLVMIsABasicBlock" LLVMIsABasicBlock) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAInlineAsm" LLVMIsAInlineAsm) LLVMValueRef +(wrap-defcfun ("LLVMIsAInlineAsm" LLVMIsAInlineAsm) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAUser" LLVMIsAUser) LLVMValueRef +(wrap-defcfun ("LLVMIsAUser" LLVMIsAUser) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAConstant" LLVMIsAConstant) LLVMValueRef +(wrap-defcfun ("LLVMIsAConstant" LLVMIsAConstant) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAConstantAggregateZero" LLVMIsAConstantAggregateZero) LLVMValueRef +(wrap-defcfun ("LLVMIsAConstantAggregateZero" LLVMIsAConstantAggregateZero) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAConstantArray" LLVMIsAConstantArray) LLVMValueRef +(wrap-defcfun ("LLVMIsAConstantArray" LLVMIsAConstantArray) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAConstantExpr" LLVMIsAConstantExpr) LLVMValueRef +(wrap-defcfun ("LLVMIsAConstantExpr" LLVMIsAConstantExpr) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAConstantFP" LLVMIsAConstantFP) LLVMValueRef +(wrap-defcfun ("LLVMIsAConstantFP" LLVMIsAConstantFP) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAConstantInt" LLVMIsAConstantInt) LLVMValueRef +(wrap-defcfun ("LLVMIsAConstantInt" LLVMIsAConstantInt) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAConstantPointerNull" LLVMIsAConstantPointerNull) LLVMValueRef +(wrap-defcfun ("LLVMIsAConstantPointerNull" LLVMIsAConstantPointerNull) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAConstantStruct" LLVMIsAConstantStruct) LLVMValueRef +(wrap-defcfun ("LLVMIsAConstantStruct" LLVMIsAConstantStruct) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAConstantVector" LLVMIsAConstantVector) LLVMValueRef +(wrap-defcfun ("LLVMIsAConstantVector" LLVMIsAConstantVector) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAGlobalValue" LLVMIsAGlobalValue) LLVMValueRef +(wrap-defcfun ("LLVMIsAGlobalValue" LLVMIsAGlobalValue) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAFunction" LLVMIsAFunction) LLVMValueRef +(wrap-defcfun ("LLVMIsAFunction" LLVMIsAFunction) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAGlobalAlias" LLVMIsAGlobalAlias) LLVMValueRef +(wrap-defcfun ("LLVMIsAGlobalAlias" LLVMIsAGlobalAlias) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAGlobalVariable" LLVMIsAGlobalVariable) LLVMValueRef +(wrap-defcfun ("LLVMIsAGlobalVariable" LLVMIsAGlobalVariable) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAUndefValue" LLVMIsAUndefValue) LLVMValueRef +(wrap-defcfun ("LLVMIsAUndefValue" LLVMIsAUndefValue) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAInstruction" LLVMIsAInstruction) LLVMValueRef +(wrap-defcfun ("LLVMIsAInstruction" LLVMIsAInstruction) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsABinaryOperator" LLVMIsABinaryOperator) LLVMValueRef +(wrap-defcfun ("LLVMIsABinaryOperator" LLVMIsABinaryOperator) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsACallInst" LLVMIsACallInst) LLVMValueRef +(wrap-defcfun ("LLVMIsACallInst" LLVMIsACallInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAIntrinsicInst" LLVMIsAIntrinsicInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAIntrinsicInst" LLVMIsAIntrinsicInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsADbgInfoIntrinsic" LLVMIsADbgInfoIntrinsic) LLVMValueRef +(wrap-defcfun ("LLVMIsADbgInfoIntrinsic" LLVMIsADbgInfoIntrinsic) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsADbgDeclareInst" LLVMIsADbgDeclareInst) LLVMValueRef +(wrap-defcfun ("LLVMIsADbgDeclareInst" LLVMIsADbgDeclareInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsADbgFuncStartInst" LLVMIsADbgFuncStartInst) LLVMValueRef +(wrap-defcfun ("LLVMIsADbgFuncStartInst" LLVMIsADbgFuncStartInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsADbgRegionEndInst" LLVMIsADbgRegionEndInst) LLVMValueRef +(wrap-defcfun ("LLVMIsADbgRegionEndInst" LLVMIsADbgRegionEndInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsADbgRegionStartInst" LLVMIsADbgRegionStartInst) LLVMValueRef +(wrap-defcfun ("LLVMIsADbgRegionStartInst" LLVMIsADbgRegionStartInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsADbgStopPointInst" LLVMIsADbgStopPointInst) LLVMValueRef +(wrap-defcfun ("LLVMIsADbgStopPointInst" LLVMIsADbgStopPointInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAEHSelectorInst" LLVMIsAEHSelectorInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAEHSelectorInst" LLVMIsAEHSelectorInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAMemIntrinsic" LLVMIsAMemIntrinsic) LLVMValueRef +(wrap-defcfun ("LLVMIsAMemIntrinsic" LLVMIsAMemIntrinsic) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAMemCpyInst" LLVMIsAMemCpyInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAMemCpyInst" LLVMIsAMemCpyInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAMemMoveInst" LLVMIsAMemMoveInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAMemMoveInst" LLVMIsAMemMoveInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAMemSetInst" LLVMIsAMemSetInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAMemSetInst" LLVMIsAMemSetInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsACmpInst" LLVMIsACmpInst) LLVMValueRef +(wrap-defcfun ("LLVMIsACmpInst" LLVMIsACmpInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAFCmpInst" LLVMIsAFCmpInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAFCmpInst" LLVMIsAFCmpInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAICmpInst" LLVMIsAICmpInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAICmpInst" LLVMIsAICmpInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAExtractElementInst" LLVMIsAExtractElementInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAExtractElementInst" LLVMIsAExtractElementInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAGetElementPtrInst" LLVMIsAGetElementPtrInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAGetElementPtrInst" LLVMIsAGetElementPtrInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAInsertElementInst" LLVMIsAInsertElementInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAInsertElementInst" LLVMIsAInsertElementInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAInsertValueInst" LLVMIsAInsertValueInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAInsertValueInst" LLVMIsAInsertValueInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAPHINode" LLVMIsAPHINode) LLVMValueRef +(wrap-defcfun ("LLVMIsAPHINode" LLVMIsAPHINode) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsASelectInst" LLVMIsASelectInst) LLVMValueRef +(wrap-defcfun ("LLVMIsASelectInst" LLVMIsASelectInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAShuffleVectorInst" LLVMIsAShuffleVectorInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAShuffleVectorInst" LLVMIsAShuffleVectorInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAStoreInst" LLVMIsAStoreInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAStoreInst" LLVMIsAStoreInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsATerminatorInst" LLVMIsATerminatorInst) LLVMValueRef +(wrap-defcfun ("LLVMIsATerminatorInst" LLVMIsATerminatorInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsABranchInst" LLVMIsABranchInst) LLVMValueRef +(wrap-defcfun ("LLVMIsABranchInst" LLVMIsABranchInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAInvokeInst" LLVMIsAInvokeInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAInvokeInst" LLVMIsAInvokeInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAReturnInst" LLVMIsAReturnInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAReturnInst" LLVMIsAReturnInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsASwitchInst" LLVMIsASwitchInst) LLVMValueRef +(wrap-defcfun ("LLVMIsASwitchInst" LLVMIsASwitchInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAUnreachableInst" LLVMIsAUnreachableInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAUnreachableInst" LLVMIsAUnreachableInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAUnwindInst" LLVMIsAUnwindInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAUnwindInst" LLVMIsAUnwindInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAUnaryInstruction" LLVMIsAUnaryInstruction) LLVMValueRef +(wrap-defcfun ("LLVMIsAUnaryInstruction" LLVMIsAUnaryInstruction) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAAllocaInst" LLVMIsAAllocaInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAAllocaInst" LLVMIsAAllocaInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsACastInst" LLVMIsACastInst) LLVMValueRef +(wrap-defcfun ("LLVMIsACastInst" LLVMIsACastInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsABitCastInst" LLVMIsABitCastInst) LLVMValueRef +(wrap-defcfun ("LLVMIsABitCastInst" LLVMIsABitCastInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAFPExtInst" LLVMIsAFPExtInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAFPExtInst" LLVMIsAFPExtInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAFPToSIInst" LLVMIsAFPToSIInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAFPToSIInst" LLVMIsAFPToSIInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAFPToUIInst" LLVMIsAFPToUIInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAFPToUIInst" LLVMIsAFPToUIInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAFPTruncInst" LLVMIsAFPTruncInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAFPTruncInst" LLVMIsAFPTruncInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAIntToPtrInst" LLVMIsAIntToPtrInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAIntToPtrInst" LLVMIsAIntToPtrInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAPtrToIntInst" LLVMIsAPtrToIntInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAPtrToIntInst" LLVMIsAPtrToIntInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsASExtInst" LLVMIsASExtInst) LLVMValueRef +(wrap-defcfun ("LLVMIsASExtInst" LLVMIsASExtInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsASIToFPInst" LLVMIsASIToFPInst) LLVMValueRef +(wrap-defcfun ("LLVMIsASIToFPInst" LLVMIsASIToFPInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsATruncInst" LLVMIsATruncInst) LLVMValueRef +(wrap-defcfun ("LLVMIsATruncInst" LLVMIsATruncInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAUIToFPInst" LLVMIsAUIToFPInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAUIToFPInst" LLVMIsAUIToFPInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAZExtInst" LLVMIsAZExtInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAZExtInst" LLVMIsAZExtInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAExtractValueInst" LLVMIsAExtractValueInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAExtractValueInst" LLVMIsAExtractValueInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsALoadInst" LLVMIsALoadInst) LLVMValueRef +(wrap-defcfun ("LLVMIsALoadInst" LLVMIsALoadInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsAVAArgInst" LLVMIsAVAArgInst) LLVMValueRef +(wrap-defcfun ("LLVMIsAVAArgInst" LLVMIsAVAArgInst) LLVMValueRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMGetFirstUse" LLVMGetFirstUse) LLVMUseIteratorRef +(wrap-defcfun ("LLVMGetFirstUse" LLVMGetFirstUse) LLVMUseIteratorRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMGetNextUse" LLVMGetNextUse) LLVMUseIteratorRef +(wrap-defcfun ("LLVMGetNextUse" LLVMGetNextUse) LLVMUseIteratorRef (U LLVMUseIteratorRef)) -(cffi:defcfun ("LLVMGetUser" LLVMGetUser) LLVMValueRef +(wrap-defcfun ("LLVMGetUser" LLVMGetUser) LLVMValueRef (U LLVMUseIteratorRef)) -(cffi:defcfun ("LLVMGetUsedValue" LLVMGetUsedValue) LLVMValueRef +(wrap-defcfun ("LLVMGetUsedValue" LLVMGetUsedValue) LLVMValueRef (U LLVMUseIteratorRef)) -(cffi:defcfun ("LLVMGetOperand" LLVMGetOperand) LLVMValueRef +(wrap-defcfun ("LLVMGetOperand" LLVMGetOperand) LLVMValueRef (Val LLVMValueRef) (Index :unsigned-int)) -(cffi:defcfun ("LLVMConstNull" LLVMConstNull) LLVMValueRef +(wrap-defcfun ("LLVMConstNull" LLVMConstNull) LLVMValueRef (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMConstAllOnes" LLVMConstAllOnes) LLVMValueRef +(wrap-defcfun ("LLVMConstAllOnes" LLVMConstAllOnes) LLVMValueRef (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMGetUndef" LLVMGetUndef) LLVMValueRef +(wrap-defcfun ("LLVMGetUndef" LLVMGetUndef) LLVMValueRef (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMIsConstant" LLVMIsConstant) :boolean +(wrap-defcfun ("LLVMIsConstant" LLVMIsConstant) :boolean (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsNull" LLVMIsNull) :boolean +(wrap-defcfun ("LLVMIsNull" LLVMIsNull) :boolean (Val LLVMValueRef)) -(cffi:defcfun ("LLVMIsUndef" LLVMIsUndef) :boolean +(wrap-defcfun ("LLVMIsUndef" LLVMIsUndef) :boolean (Val LLVMValueRef)) -(cffi:defcfun ("LLVMConstPointerNull" LLVMConstPointerNull) LLVMValueRef +(wrap-defcfun ("LLVMConstPointerNull" LLVMConstPointerNull) LLVMValueRef (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMConstInt" LLVMConstInt) LLVMValueRef +(wrap-defcfun ("LLVMConstInt" LLVMConstInt) LLVMValueRef (IntTy LLVMTypeRef) (N :unsigned-long-long) (SignExtend :boolean)) -(cffi:defcfun ("LLVMConstIntOfString" LLVMConstIntOfString) LLVMValueRef +(wrap-defcfun ("LLVMConstIntOfString" LLVMConstIntOfString) LLVMValueRef (IntTy LLVMTypeRef) (Text :string) (Radix :unsigned-char)) -(cffi:defcfun ("LLVMConstIntOfStringAndSize" LLVMConstIntOfStringAndSize) LLVMValueRef +(wrap-defcfun ("LLVMConstIntOfStringAndSize" LLVMConstIntOfStringAndSize) LLVMValueRef (IntTy LLVMTypeRef) (Text :string) (SLen :unsigned-int) (Radix :unsigned-char)) -(cffi:defcfun ("LLVMConstReal" LLVMConstReal) LLVMValueRef +(wrap-defcfun ("LLVMConstReal" LLVMConstReal) LLVMValueRef (RealTy LLVMTypeRef) (N :double)) -(cffi:defcfun ("LLVMConstRealOfString" LLVMConstRealOfString) LLVMValueRef +(wrap-defcfun ("LLVMConstRealOfString" LLVMConstRealOfString) LLVMValueRef (RealTy LLVMTypeRef) (Text :string)) -(cffi:defcfun ("LLVMConstRealOfStringAndSize" LLVMConstRealOfStringAndSize) LLVMValueRef +(wrap-defcfun ("LLVMConstRealOfStringAndSize" LLVMConstRealOfStringAndSize) LLVMValueRef (RealTy LLVMTypeRef) (Text :string) (SLen :unsigned-int)) -(cffi:defcfun ("LLVMConstIntGetZExtValue" LLVMConstIntGetZExtValue) :unsigned-long-long +(wrap-defcfun ("LLVMConstIntGetZExtValue" LLVMConstIntGetZExtValue) :unsigned-long-long (ConstantVal LLVMValueRef)) -(cffi:defcfun ("LLVMConstIntGetSExtValue" LLVMConstIntGetSExtValue) :long-long +(wrap-defcfun ("LLVMConstIntGetSExtValue" LLVMConstIntGetSExtValue) :long-long (ConstantVal LLVMValueRef)) -(cffi:defcfun ("LLVMConstStringInContext" %LLVMConstStringInContext) LLVMValueRef +(wrap-defcfun ("LLVMConstStringInContext" %LLVMConstStringInContext) LLVMValueRef (C LLVMContextRef) (Str :string) (Length :unsigned-int) (DontNullTerminate :boolean)) -(cffi:defcfun ("LLVMConstStructInContext" %LLVMConstStructInContext) LLVMValueRef +(wrap-defcfun ("LLVMConstStructInContext" %LLVMConstStructInContext) LLVMValueRef (C LLVMContextRef) (ConstantVals :pointer) (Count :unsigned-int) (Packed :boolean)) -(cffi:defcfun ("LLVMConstArray" %LLVMConstArray) LLVMValueRef +(wrap-defcfun ("LLVMConstArray" %LLVMConstArray) LLVMValueRef (ElementTy LLVMTypeRef) (ConstantVals :pointer) (Length :unsigned-int)) -(cffi:defcfun ("LLVMConstVector" %LLVMConstVector) LLVMValueRef +(wrap-defcfun ("LLVMConstVector" %LLVMConstVector) LLVMValueRef (ScalarConstantVals :pointer) (Size :unsigned-int)) -(cffi:defcfun ("LLVMGetConstOpcode" LLVMGetConstOpcode) LLVMOpcode +(wrap-defcfun ("LLVMGetConstOpcode" LLVMGetConstOpcode) LLVMOpcode (ConstantVal LLVMValueRef)) -(cffi:defcfun ("LLVMAlignOf" LLVMAlignOf) LLVMValueRef +(wrap-defcfun ("LLVMAlignOf" LLVMAlignOf) LLVMValueRef (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMSizeOf" LLVMSizeOf) LLVMValueRef +(wrap-defcfun ("LLVMSizeOf" LLVMSizeOf) LLVMValueRef (Ty LLVMTypeRef)) -(cffi:defcfun ("LLVMConstNeg" LLVMConstNeg) LLVMValueRef +(wrap-defcfun ("LLVMConstNeg" LLVMConstNeg) LLVMValueRef (ConstantVal LLVMValueRef)) -(cffi:defcfun ("LLVMConstFNeg" LLVMConstFNeg) LLVMValueRef +(wrap-defcfun ("LLVMConstFNeg" LLVMConstFNeg) LLVMValueRef (ConstantVal LLVMValueRef)) -(cffi:defcfun ("LLVMConstNot" LLVMConstNot) LLVMValueRef +(wrap-defcfun ("LLVMConstNot" LLVMConstNot) LLVMValueRef (ConstantVal LLVMValueRef)) -(cffi:defcfun ("LLVMConstAdd" LLVMConstAdd) LLVMValueRef +(wrap-defcfun ("LLVMConstAdd" LLVMConstAdd) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstNSWAdd" LLVMConstNSWAdd) LLVMValueRef +(wrap-defcfun ("LLVMConstNSWAdd" LLVMConstNSWAdd) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstFAdd" LLVMConstFAdd) LLVMValueRef +(wrap-defcfun ("LLVMConstFAdd" LLVMConstFAdd) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstSub" LLVMConstSub) LLVMValueRef +(wrap-defcfun ("LLVMConstSub" LLVMConstSub) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstFSub" LLVMConstFSub) LLVMValueRef +(wrap-defcfun ("LLVMConstFSub" LLVMConstFSub) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstMul" LLVMConstMul) LLVMValueRef +(wrap-defcfun ("LLVMConstMul" LLVMConstMul) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstFMul" LLVMConstFMul) LLVMValueRef +(wrap-defcfun ("LLVMConstFMul" LLVMConstFMul) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstUDiv" LLVMConstUDiv) LLVMValueRef +(wrap-defcfun ("LLVMConstUDiv" LLVMConstUDiv) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstSDiv" LLVMConstSDiv) LLVMValueRef +(wrap-defcfun ("LLVMConstSDiv" LLVMConstSDiv) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstExactSDiv" LLVMConstExactSDiv) LLVMValueRef +(wrap-defcfun ("LLVMConstExactSDiv" LLVMConstExactSDiv) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstFDiv" LLVMConstFDiv) LLVMValueRef +(wrap-defcfun ("LLVMConstFDiv" LLVMConstFDiv) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstURem" LLVMConstURem) LLVMValueRef +(wrap-defcfun ("LLVMConstURem" LLVMConstURem) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstSRem" LLVMConstSRem) LLVMValueRef +(wrap-defcfun ("LLVMConstSRem" LLVMConstSRem) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstFRem" LLVMConstFRem) LLVMValueRef +(wrap-defcfun ("LLVMConstFRem" LLVMConstFRem) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstAnd" LLVMConstAnd) LLVMValueRef +(wrap-defcfun ("LLVMConstAnd" LLVMConstAnd) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstOr" LLVMConstOr) LLVMValueRef +(wrap-defcfun ("LLVMConstOr" LLVMConstOr) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstXor" LLVMConstXor) LLVMValueRef +(wrap-defcfun ("LLVMConstXor" LLVMConstXor) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstICmp" LLVMConstICmp) LLVMValueRef +(wrap-defcfun ("LLVMConstICmp" LLVMConstICmp) LLVMValueRef (Predicate LLVMIntPredicate) (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstFCmp" LLVMConstFCmp) LLVMValueRef +(wrap-defcfun ("LLVMConstFCmp" LLVMConstFCmp) LLVMValueRef (Predicate LLVMRealPredicate) (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstShl" LLVMConstShl) LLVMValueRef +(wrap-defcfun ("LLVMConstShl" LLVMConstShl) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstLShr" LLVMConstLShr) LLVMValueRef +(wrap-defcfun ("LLVMConstLShr" LLVMConstLShr) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstAShr" LLVMConstAShr) LLVMValueRef +(wrap-defcfun ("LLVMConstAShr" LLVMConstAShr) LLVMValueRef (LHSConstant LLVMValueRef) (RHSConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstGEP" %LLVMConstGEP) LLVMValueRef +(wrap-defcfun ("LLVMConstGEP" %LLVMConstGEP) LLVMValueRef (ConstantVal LLVMValueRef) (ConstantIndices :pointer) (NumIndices :unsigned-int)) -(cffi:defcfun ("LLVMConstInBoundsGEP" %LLVMConstInBoundsGEP) LLVMValueRef +(wrap-defcfun ("LLVMConstInBoundsGEP" %LLVMConstInBoundsGEP) LLVMValueRef (ConstantVal LLVMValueRef) (ConstantIndices :pointer) (NumIndices :unsigned-int)) -(cffi:defcfun ("LLVMConstTrunc" LLVMConstTrunc) LLVMValueRef +(wrap-defcfun ("LLVMConstTrunc" LLVMConstTrunc) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstSExt" LLVMConstSExt) LLVMValueRef +(wrap-defcfun ("LLVMConstSExt" LLVMConstSExt) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstZExt" LLVMConstZExt) LLVMValueRef +(wrap-defcfun ("LLVMConstZExt" LLVMConstZExt) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstFPTrunc" LLVMConstFPTrunc) LLVMValueRef +(wrap-defcfun ("LLVMConstFPTrunc" LLVMConstFPTrunc) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstFPExt" LLVMConstFPExt) LLVMValueRef +(wrap-defcfun ("LLVMConstFPExt" LLVMConstFPExt) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstUIToFP" LLVMConstUIToFP) LLVMValueRef +(wrap-defcfun ("LLVMConstUIToFP" LLVMConstUIToFP) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstSIToFP" LLVMConstSIToFP) LLVMValueRef +(wrap-defcfun ("LLVMConstSIToFP" LLVMConstSIToFP) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstFPToUI" LLVMConstFPToUI) LLVMValueRef +(wrap-defcfun ("LLVMConstFPToUI" LLVMConstFPToUI) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstFPToSI" LLVMConstFPToSI) LLVMValueRef +(wrap-defcfun ("LLVMConstFPToSI" LLVMConstFPToSI) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstPtrToInt" LLVMConstPtrToInt) LLVMValueRef +(wrap-defcfun ("LLVMConstPtrToInt" LLVMConstPtrToInt) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstIntToPtr" LLVMConstIntToPtr) LLVMValueRef +(wrap-defcfun ("LLVMConstIntToPtr" LLVMConstIntToPtr) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstBitCast" LLVMConstBitCast) LLVMValueRef +(wrap-defcfun ("LLVMConstBitCast" LLVMConstBitCast) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstZExtOrBitCast" LLVMConstZExtOrBitCast) LLVMValueRef +(wrap-defcfun ("LLVMConstZExtOrBitCast" LLVMConstZExtOrBitCast) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstSExtOrBitCast" LLVMConstSExtOrBitCast) LLVMValueRef +(wrap-defcfun ("LLVMConstSExtOrBitCast" LLVMConstSExtOrBitCast) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstTruncOrBitCast" LLVMConstTruncOrBitCast) LLVMValueRef +(wrap-defcfun ("LLVMConstTruncOrBitCast" LLVMConstTruncOrBitCast) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstPointerCast" LLVMConstPointerCast) LLVMValueRef +(wrap-defcfun ("LLVMConstPointerCast" LLVMConstPointerCast) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstIntCast" LLVMConstIntCast) LLVMValueRef +(wrap-defcfun ("LLVMConstIntCast" LLVMConstIntCast) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef) (isSigned :boolean)) -(cffi:defcfun ("LLVMConstFPCast" LLVMConstFPCast) LLVMValueRef +(wrap-defcfun ("LLVMConstFPCast" LLVMConstFPCast) LLVMValueRef (ConstantVal LLVMValueRef) (ToType LLVMTypeRef)) -(cffi:defcfun ("LLVMConstSelect" LLVMConstSelect) LLVMValueRef +(wrap-defcfun ("LLVMConstSelect" LLVMConstSelect) LLVMValueRef (ConstantCondition LLVMValueRef) (ConstantIfTrue LLVMValueRef) (ConstantIfFalse LLVMValueRef)) -(cffi:defcfun ("LLVMConstExtractElement" LLVMConstExtractElement) LLVMValueRef +(wrap-defcfun ("LLVMConstExtractElement" LLVMConstExtractElement) LLVMValueRef (VectorConstant LLVMValueRef) (IndexConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstInsertElement" LLVMConstInsertElement) LLVMValueRef +(wrap-defcfun ("LLVMConstInsertElement" LLVMConstInsertElement) LLVMValueRef (VectorConstant LLVMValueRef) (ElementValueConstant LLVMValueRef) (IndexConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstShuffleVector" LLVMConstShuffleVector) LLVMValueRef +(wrap-defcfun ("LLVMConstShuffleVector" LLVMConstShuffleVector) LLVMValueRef (VectorAConstant LLVMValueRef) (VectorBConstant LLVMValueRef) (MaskConstant LLVMValueRef)) -(cffi:defcfun ("LLVMConstExtractValue" %LLVMConstExtractValue) LLVMValueRef +(wrap-defcfun ("LLVMConstExtractValue" %LLVMConstExtractValue) LLVMValueRef (AggConstant LLVMValueRef) (IdxList :pointer) (NumIdx :unsigned-int)) -(cffi:defcfun ("LLVMConstInsertValue" %LLVMConstInsertValue) LLVMValueRef +(wrap-defcfun ("LLVMConstInsertValue" %LLVMConstInsertValue) LLVMValueRef (AggConstant LLVMValueRef) (ElementValueConstant LLVMValueRef) (IdxList :pointer) (NumIdx :unsigned-int)) -(cffi:defcfun ("LLVMConstInlineAsm" LLVMConstInlineAsm) LLVMValueRef +(wrap-defcfun ("LLVMConstInlineAsm" LLVMConstInlineAsm) LLVMValueRef (Ty LLVMTypeRef) (AsmString :string) (Constraints :string) (HasSideEffects :boolean) (IsAlignStack :boolean)) -(cffi:defcfun ("LLVMGetGlobalParent" LLVMGetGlobalParent) LLVMModuleRef +(wrap-defcfun ("LLVMGetGlobalParent" LLVMGetGlobalParent) LLVMModuleRef (Global LLVMValueRef)) -(cffi:defcfun ("LLVMIsDeclaration" LLVMIsDeclaration) :boolean +(wrap-defcfun ("LLVMIsDeclaration" LLVMIsDeclaration) :boolean (Global LLVMValueRef)) -(cffi:defcfun ("LLVMGetLinkage" LLVMGetLinkage) LLVMLinkage +(wrap-defcfun ("LLVMGetLinkage" LLVMGetLinkage) LLVMLinkage (Global LLVMValueRef)) -(cffi:defcfun ("LLVMSetLinkage" LLVMSetLinkage) :void +(wrap-defcfun ("LLVMSetLinkage" LLVMSetLinkage) :void (Global LLVMValueRef) (Linkage LLVMLinkage)) -(cffi:defcfun ("LLVMGetSection" LLVMGetSection) :string +(wrap-defcfun ("LLVMGetSection" LLVMGetSection) :string (Global LLVMValueRef)) -(cffi:defcfun ("LLVMSetSection" LLVMSetSection) :void +(wrap-defcfun ("LLVMSetSection" LLVMSetSection) :void (Global LLVMValueRef) (Section :string)) -(cffi:defcfun ("LLVMGetVisibility" LLVMGetVisibility) LLVMVisibility +(wrap-defcfun ("LLVMGetVisibility" LLVMGetVisibility) LLVMVisibility (Global LLVMValueRef)) -(cffi:defcfun ("LLVMSetVisibility" LLVMSetVisibility) :void +(wrap-defcfun ("LLVMSetVisibility" LLVMSetVisibility) :void (Global LLVMValueRef) (Viz LLVMVisibility)) -(cffi:defcfun ("LLVMGetAlignment" LLVMGetAlignment) :unsigned-int +(wrap-defcfun ("LLVMGetAlignment" LLVMGetAlignment) :unsigned-int (Global LLVMValueRef)) -(cffi:defcfun ("LLVMSetAlignment" LLVMSetAlignment) :void +(wrap-defcfun ("LLVMSetAlignment" LLVMSetAlignment) :void (Global LLVMValueRef) (Bytes :unsigned-int)) -(cffi:defcfun ("LLVMAddGlobal" LLVMAddGlobal) LLVMValueRef +(wrap-defcfun ("LLVMAddGlobal" LLVMAddGlobal) LLVMValueRef (M LLVMModuleRef) (Ty LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMGetNamedGlobal" LLVMGetNamedGlobal) LLVMValueRef +(wrap-defcfun ("LLVMGetNamedGlobal" LLVMGetNamedGlobal) LLVMValueRef (M LLVMModuleRef) (Name :string)) -(cffi:defcfun ("LLVMGetFirstGlobal" LLVMGetFirstGlobal) LLVMValueRef +(wrap-defcfun ("LLVMGetFirstGlobal" LLVMGetFirstGlobal) LLVMValueRef (M LLVMModuleRef)) -(cffi:defcfun ("LLVMGetLastGlobal" LLVMGetLastGlobal) LLVMValueRef +(wrap-defcfun ("LLVMGetLastGlobal" LLVMGetLastGlobal) LLVMValueRef (M LLVMModuleRef)) -(cffi:defcfun ("LLVMGetNextGlobal" LLVMGetNextGlobal) LLVMValueRef +(wrap-defcfun ("LLVMGetNextGlobal" LLVMGetNextGlobal) LLVMValueRef (GlobalVar LLVMValueRef)) -(cffi:defcfun ("LLVMGetPreviousGlobal" LLVMGetPreviousGlobal) LLVMValueRef +(wrap-defcfun ("LLVMGetPreviousGlobal" LLVMGetPreviousGlobal) LLVMValueRef (GlobalVar LLVMValueRef)) -(cffi:defcfun ("LLVMDeleteGlobal" LLVMDeleteGlobal) :void +(wrap-defcfun ("LLVMDeleteGlobal" LLVMDeleteGlobal) :void (GlobalVar LLVMValueRef)) -(cffi:defcfun ("LLVMGetInitializer" LLVMGetInitializer) LLVMValueRef +(wrap-defcfun ("LLVMGetInitializer" LLVMGetInitializer) LLVMValueRef (GlobalVar LLVMValueRef)) -(cffi:defcfun ("LLVMSetInitializer" LLVMSetInitializer) :void +(wrap-defcfun ("LLVMSetInitializer" LLVMSetInitializer) :void (GlobalVar LLVMValueRef) (ConstantVal LLVMValueRef)) -(cffi:defcfun ("LLVMIsThreadLocal" LLVMIsThreadLocal) :boolean +(wrap-defcfun ("LLVMIsThreadLocal" LLVMIsThreadLocal) :boolean (GlobalVar LLVMValueRef)) -(cffi:defcfun ("LLVMSetThreadLocal" LLVMSetThreadLocal) :void +(wrap-defcfun ("LLVMSetThreadLocal" LLVMSetThreadLocal) :void (GlobalVar LLVMValueRef) (IsThreadLocal :boolean)) -(cffi:defcfun ("LLVMIsGlobalConstant" LLVMIsGlobalConstant) :boolean +(wrap-defcfun ("LLVMIsGlobalConstant" LLVMIsGlobalConstant) :boolean (GlobalVar LLVMValueRef)) -(cffi:defcfun ("LLVMSetGlobalConstant" LLVMSetGlobalConstant) :void +(wrap-defcfun ("LLVMSetGlobalConstant" LLVMSetGlobalConstant) :void (GlobalVar LLVMValueRef) (IsConstant :boolean)) -(cffi:defcfun ("LLVMAddAlias" LLVMAddAlias) LLVMValueRef +(wrap-defcfun ("LLVMAddAlias" LLVMAddAlias) LLVMValueRef (M LLVMModuleRef) (Ty LLVMTypeRef) (Aliasee LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMAddFunction" LLVMAddFunction) LLVMValueRef +(wrap-defcfun ("LLVMAddFunction" LLVMAddFunction) LLVMValueRef (M LLVMModuleRef) (Name :string) (FunctionTy LLVMTypeRef)) -(cffi:defcfun ("LLVMGetNamedFunction" LLVMGetNamedFunction) LLVMValueRef +(wrap-defcfun ("LLVMGetNamedFunction" LLVMGetNamedFunction) LLVMValueRef (M LLVMModuleRef) (Name :string)) -(cffi:defcfun ("LLVMGetFirstFunction" LLVMGetFirstFunction) LLVMValueRef +(wrap-defcfun ("LLVMGetFirstFunction" LLVMGetFirstFunction) LLVMValueRef (M LLVMModuleRef)) -(cffi:defcfun ("LLVMGetLastFunction" LLVMGetLastFunction) LLVMValueRef +(wrap-defcfun ("LLVMGetLastFunction" LLVMGetLastFunction) LLVMValueRef (M LLVMModuleRef)) -(cffi:defcfun ("LLVMGetNextFunction" LLVMGetNextFunction) LLVMValueRef +(wrap-defcfun ("LLVMGetNextFunction" LLVMGetNextFunction) LLVMValueRef (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMGetPreviousFunction" LLVMGetPreviousFunction) LLVMValueRef +(wrap-defcfun ("LLVMGetPreviousFunction" LLVMGetPreviousFunction) LLVMValueRef (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMDeleteFunction" LLVMDeleteFunction) :void +(wrap-defcfun ("LLVMDeleteFunction" LLVMDeleteFunction) :void (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMGetIntrinsicID" LLVMGetIntrinsicID) :unsigned-int +(wrap-defcfun ("LLVMGetIntrinsicID" LLVMGetIntrinsicID) :unsigned-int (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMGetFunctionCallConv" LLVMGetFunctionCallConv) :unsigned-int +(wrap-defcfun ("LLVMGetFunctionCallConv" LLVMGetFunctionCallConv) :unsigned-int (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMSetFunctionCallConv" LLVMSetFunctionCallConv) :void +(wrap-defcfun ("LLVMSetFunctionCallConv" LLVMSetFunctionCallConv) :void (Fn LLVMValueRef) (CC :unsigned-int)) -(cffi:defcfun ("LLVMGetGC" LLVMGetGC) :string +(wrap-defcfun ("LLVMGetGC" LLVMGetGC) :string (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMSetGC" LLVMSetGC) :void +(wrap-defcfun ("LLVMSetGC" LLVMSetGC) :void (Fn LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMGetFunctionAttr" LLVMGetFunctionAttr) LLVMAttribute +(wrap-defcfun ("LLVMGetFunctionAttr" LLVMGetFunctionAttr) LLVMAttribute (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMCountParams" LLVMCountParams) :unsigned-int +(wrap-defcfun ("LLVMCountParams" LLVMCountParams) :unsigned-int (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMGetParams" %LLVMGetParams) :void +(wrap-defcfun ("LLVMGetParams" %LLVMGetParams) :void (Fn LLVMValueRef) (Params :pointer)) -(cffi:defcfun ("LLVMGetParam" LLVMGetParam) LLVMValueRef +(wrap-defcfun ("LLVMGetParam" LLVMGetParam) LLVMValueRef (Fn LLVMValueRef) (Index :unsigned-int)) -(cffi:defcfun ("LLVMGetParamParent" LLVMGetParamParent) LLVMValueRef +(wrap-defcfun ("LLVMGetParamParent" LLVMGetParamParent) LLVMValueRef (Inst LLVMValueRef)) -(cffi:defcfun ("LLVMGetFirstParam" LLVMGetFirstParam) LLVMValueRef +(wrap-defcfun ("LLVMGetFirstParam" LLVMGetFirstParam) LLVMValueRef (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMGetLastParam" LLVMGetLastParam) LLVMValueRef +(wrap-defcfun ("LLVMGetLastParam" LLVMGetLastParam) LLVMValueRef (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMGetNextParam" LLVMGetNextParam) LLVMValueRef +(wrap-defcfun ("LLVMGetNextParam" LLVMGetNextParam) LLVMValueRef (Arg LLVMValueRef)) -(cffi:defcfun ("LLVMGetPreviousParam" LLVMGetPreviousParam) LLVMValueRef +(wrap-defcfun ("LLVMGetPreviousParam" LLVMGetPreviousParam) LLVMValueRef (Arg LLVMValueRef)) -(cffi:defcfun ("LLVMAddAttribute" LLVMAddAttribute) :void +(wrap-defcfun ("LLVMAddAttribute" LLVMAddAttribute) :void (Arg LLVMValueRef) (PA LLVMAttribute)) -(cffi:defcfun ("LLVMRemoveAttribute" LLVMRemoveAttribute) :void +(wrap-defcfun ("LLVMRemoveAttribute" LLVMRemoveAttribute) :void (Arg LLVMValueRef) (PA LLVMAttribute)) -(cffi:defcfun ("LLVMGetAttribute" LLVMGetAttribute) LLVMAttribute +(wrap-defcfun ("LLVMGetAttribute" LLVMGetAttribute) LLVMAttribute (Arg LLVMValueRef)) -(cffi:defcfun ("LLVMSetParamAlignment" LLVMSetParamAlignment) :void +(wrap-defcfun ("LLVMSetParamAlignment" LLVMSetParamAlignment) :void (Arg LLVMValueRef) (align :unsigned-int)) -(cffi:defcfun ("LLVMBasicBlockAsValue" LLVMBasicBlockAsValue) LLVMValueRef +(wrap-defcfun ("LLVMBasicBlockAsValue" LLVMBasicBlockAsValue) LLVMValueRef (BB LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMValueIsBasicBlock" LLVMValueIsBasicBlock) :boolean +(wrap-defcfun ("LLVMValueIsBasicBlock" LLVMValueIsBasicBlock) :boolean (Val LLVMValueRef)) -(cffi:defcfun ("LLVMValueAsBasicBlock" LLVMValueAsBasicBlock) LLVMBasicBlockRef +(wrap-defcfun ("LLVMValueAsBasicBlock" LLVMValueAsBasicBlock) LLVMBasicBlockRef (Val LLVMValueRef)) -(cffi:defcfun ("LLVMGetBasicBlockParent" LLVMGetBasicBlockParent) LLVMValueRef +(wrap-defcfun ("LLVMGetBasicBlockParent" LLVMGetBasicBlockParent) LLVMValueRef (BB LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMCountBasicBlocks" LLVMCountBasicBlocks) :unsigned-int +(wrap-defcfun ("LLVMCountBasicBlocks" LLVMCountBasicBlocks) :unsigned-int (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMGetBasicBlocks" LLVMGetBasicBlocks) :void +(wrap-defcfun ("LLVMGetBasicBlocks" LLVMGetBasicBlocks) :void (Fn LLVMValueRef) (BasicBlocks :pointer)) -(cffi:defcfun ("LLVMGetFirstBasicBlock" LLVMGetFirstBasicBlock) LLVMBasicBlockRef +(wrap-defcfun ("LLVMGetFirstBasicBlock" LLVMGetFirstBasicBlock) LLVMBasicBlockRef (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMGetLastBasicBlock" LLVMGetLastBasicBlock) LLVMBasicBlockRef +(wrap-defcfun ("LLVMGetLastBasicBlock" LLVMGetLastBasicBlock) LLVMBasicBlockRef (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMGetNextBasicBlock" LLVMGetNextBasicBlock) LLVMBasicBlockRef +(wrap-defcfun ("LLVMGetNextBasicBlock" LLVMGetNextBasicBlock) LLVMBasicBlockRef (BB LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMGetPreviousBasicBlock" LLVMGetPreviousBasicBlock) LLVMBasicBlockRef +(wrap-defcfun ("LLVMGetPreviousBasicBlock" LLVMGetPreviousBasicBlock) LLVMBasicBlockRef (BB LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMGetEntryBasicBlock" LLVMGetEntryBasicBlock) LLVMBasicBlockRef +(wrap-defcfun ("LLVMGetEntryBasicBlock" LLVMGetEntryBasicBlock) LLVMBasicBlockRef (Fn LLVMValueRef)) -(cffi:defcfun ("LLVMAppendBasicBlockInContext" %LLVMAppendBasicBlockInContext) LLVMBasicBlockRef +(wrap-defcfun ("LLVMAppendBasicBlockInContext" %LLVMAppendBasicBlockInContext) LLVMBasicBlockRef (C LLVMContextRef) (Fn LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMInsertBasicBlockInContext" %LLVMInsertBasicBlockInContext) LLVMBasicBlockRef +(wrap-defcfun ("LLVMInsertBasicBlockInContext" %LLVMInsertBasicBlockInContext) LLVMBasicBlockRef (C LLVMContextRef) (BB LLVMBasicBlockRef) (Name :string)) -(cffi:defcfun ("LLVMDeleteBasicBlock" LLVMDeleteBasicBlock) :void +(wrap-defcfun ("LLVMDeleteBasicBlock" LLVMDeleteBasicBlock) :void (BB LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMGetInstructionParent" LLVMGetInstructionParent) LLVMBasicBlockRef +(wrap-defcfun ("LLVMGetInstructionParent" LLVMGetInstructionParent) LLVMBasicBlockRef (Inst LLVMValueRef)) -(cffi:defcfun ("LLVMGetFirstInstruction" LLVMGetFirstInstruction) LLVMValueRef +(wrap-defcfun ("LLVMGetFirstInstruction" LLVMGetFirstInstruction) LLVMValueRef (BB LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMGetLastInstruction" LLVMGetLastInstruction) LLVMValueRef +(wrap-defcfun ("LLVMGetLastInstruction" LLVMGetLastInstruction) LLVMValueRef (BB LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMGetNextInstruction" LLVMGetNextInstruction) LLVMValueRef +(wrap-defcfun ("LLVMGetNextInstruction" LLVMGetNextInstruction) LLVMValueRef (Inst LLVMValueRef)) -(cffi:defcfun ("LLVMGetPreviousInstruction" LLVMGetPreviousInstruction) LLVMValueRef +(wrap-defcfun ("LLVMGetPreviousInstruction" LLVMGetPreviousInstruction) LLVMValueRef (Inst LLVMValueRef)) -(cffi:defcfun ("LLVMSetInstructionCallConv" LLVMSetInstructionCallConv) :void +(wrap-defcfun ("LLVMSetInstructionCallConv" LLVMSetInstructionCallConv) :void (Instr LLVMValueRef) (CC :unsigned-int)) -(cffi:defcfun ("LLVMGetInstructionCallConv" LLVMGetInstructionCallConv) :unsigned-int +(wrap-defcfun ("LLVMGetInstructionCallConv" LLVMGetInstructionCallConv) :unsigned-int (Instr LLVMValueRef)) -(cffi:defcfun ("LLVMAddInstrAttribute" LLVMAddInstrAttribute) :void +(wrap-defcfun ("LLVMAddInstrAttribute" LLVMAddInstrAttribute) :void (Instr LLVMValueRef) (index :unsigned-int) (arg2 LLVMAttribute)) -(cffi:defcfun ("LLVMRemoveInstrAttribute" LLVMRemoveInstrAttribute) :void +(wrap-defcfun ("LLVMRemoveInstrAttribute" LLVMRemoveInstrAttribute) :void (Instr LLVMValueRef) (index :unsigned-int) (arg2 LLVMAttribute)) -(cffi:defcfun ("LLVMSetInstrParamAlignment" LLVMSetInstrParamAlignment) :void +(wrap-defcfun ("LLVMSetInstrParamAlignment" LLVMSetInstrParamAlignment) :void (Instr LLVMValueRef) (index :unsigned-int) (align :unsigned-int)) -(cffi:defcfun ("LLVMIsTailCall" LLVMIsTailCall) :boolean +(wrap-defcfun ("LLVMIsTailCall" LLVMIsTailCall) :boolean (CallInst LLVMValueRef)) -(cffi:defcfun ("LLVMSetTailCall" LLVMSetTailCall) :void +(wrap-defcfun ("LLVMSetTailCall" LLVMSetTailCall) :void (CallInst LLVMValueRef) (IsTailCall :boolean)) -(cffi:defcfun ("LLVMAddIncoming" %LLVMAddIncoming) :void +(wrap-defcfun ("LLVMAddIncoming" %LLVMAddIncoming) :void (PhiNode LLVMValueRef) (IncomingValues :pointer) (IncomingBlocks :pointer) (Count :unsigned-int)) -(cffi:defcfun ("LLVMCountIncoming" LLVMCountIncoming) :unsigned-int +(wrap-defcfun ("LLVMCountIncoming" LLVMCountIncoming) :unsigned-int (PhiNode LLVMValueRef)) -(cffi:defcfun ("LLVMGetIncomingValue" LLVMGetIncomingValue) LLVMValueRef +(wrap-defcfun ("LLVMGetIncomingValue" LLVMGetIncomingValue) LLVMValueRef (PhiNode LLVMValueRef) (Index :unsigned-int)) -(cffi:defcfun ("LLVMGetIncomingBlock" LLVMGetIncomingBlock) LLVMBasicBlockRef +(wrap-defcfun ("LLVMGetIncomingBlock" LLVMGetIncomingBlock) LLVMBasicBlockRef (PhiNode LLVMValueRef) (Index :unsigned-int)) -(cffi:defcfun ("LLVMCreateBuilderInContext" %LLVMCreateBuilderInContext) LLVMBuilderRef +(wrap-defcfun ("LLVMCreateBuilderInContext" %LLVMCreateBuilderInContext) LLVMBuilderRef (C LLVMContextRef)) -(cffi:defcfun ("LLVMPositionBuilder" LLVMPositionBuilder) :void +(wrap-defcfun ("LLVMPositionBuilder" LLVMPositionBuilder) :void (Builder LLVMBuilderRef) (Block LLVMBasicBlockRef) (Instr LLVMValueRef)) -(cffi:defcfun ("LLVMPositionBuilderBefore" LLVMPositionBuilderBefore) :void +(wrap-defcfun ("LLVMPositionBuilderBefore" LLVMPositionBuilderBefore) :void (Builder LLVMBuilderRef) (Instr LLVMValueRef)) -(cffi:defcfun ("LLVMPositionBuilderAtEnd" LLVMPositionBuilderAtEnd) :void +(wrap-defcfun ("LLVMPositionBuilderAtEnd" LLVMPositionBuilderAtEnd) :void (Builder LLVMBuilderRef) (Block LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMGetInsertBlock" LLVMGetInsertBlock) LLVMBasicBlockRef +(wrap-defcfun ("LLVMGetInsertBlock" LLVMGetInsertBlock) LLVMBasicBlockRef (Builder LLVMBuilderRef)) -(cffi:defcfun ("LLVMClearInsertionPosition" LLVMClearInsertionPosition) :void +(wrap-defcfun ("LLVMClearInsertionPosition" LLVMClearInsertionPosition) :void (Builder LLVMBuilderRef)) -(cffi:defcfun ("LLVMInsertIntoBuilder" LLVMInsertIntoBuilder) :void +(wrap-defcfun ("LLVMInsertIntoBuilder" LLVMInsertIntoBuilder) :void (Builder LLVMBuilderRef) (Instr LLVMValueRef)) -(cffi:defcfun ("LLVMInsertIntoBuilderWithName" LLVMInsertIntoBuilderWithName) :void +(wrap-defcfun ("LLVMInsertIntoBuilderWithName" LLVMInsertIntoBuilderWithName) :void (Builder LLVMBuilderRef) (Instr LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMDisposeBuilder" LLVMDisposeBuilder) :void +(wrap-defcfun ("LLVMDisposeBuilder" LLVMDisposeBuilder) :void (Builder LLVMBuilderRef)) -(cffi:defcfun ("LLVMBuildRetVoid" LLVMBuildRetVoid) LLVMValueRef +(wrap-defcfun ("LLVMBuildRetVoid" LLVMBuildRetVoid) LLVMValueRef (arg0 LLVMBuilderRef)) -(cffi:defcfun ("LLVMBuildRet" LLVMBuildRet) LLVMValueRef +(wrap-defcfun ("LLVMBuildRet" LLVMBuildRet) LLVMValueRef (arg0 LLVMBuilderRef) (V LLVMValueRef)) -(cffi:defcfun ("LLVMBuildAggregateRet" %LLVMBuildAggregateRet) LLVMValueRef +(wrap-defcfun ("LLVMBuildAggregateRet" %LLVMBuildAggregateRet) LLVMValueRef (arg0 LLVMBuilderRef) (RetVals :pointer) (N :unsigned-int)) -(cffi:defcfun ("LLVMBuildBr" LLVMBuildBr) LLVMValueRef +(wrap-defcfun ("LLVMBuildBr" LLVMBuildBr) LLVMValueRef (arg0 LLVMBuilderRef) (Dest LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMBuildCondBr" LLVMBuildCondBr) LLVMValueRef +(wrap-defcfun ("LLVMBuildCondBr" LLVMBuildCondBr) LLVMValueRef (arg0 LLVMBuilderRef) (If LLVMValueRef) (Then LLVMBasicBlockRef) (Else LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMBuildSwitch" LLVMBuildSwitch) LLVMValueRef +(wrap-defcfun ("LLVMBuildSwitch" LLVMBuildSwitch) LLVMValueRef (arg0 LLVMBuilderRef) (V LLVMValueRef) (Else LLVMBasicBlockRef) (NumCases :unsigned-int)) -(cffi:defcfun ("LLVMBuildInvoke" %LLVMBuildInvoke) LLVMValueRef +(wrap-defcfun ("LLVMBuildInvoke" %LLVMBuildInvoke) LLVMValueRef (arg0 LLVMBuilderRef) (Fn LLVMValueRef) (Args :pointer) @@ -1252,452 +1267,452 @@ (Catch LLVMBasicBlockRef) (Name :string)) -(cffi:defcfun ("LLVMBuildUnwind" LLVMBuildUnwind) LLVMValueRef +(wrap-defcfun ("LLVMBuildUnwind" LLVMBuildUnwind) LLVMValueRef (arg0 LLVMBuilderRef)) -(cffi:defcfun ("LLVMBuildUnreachable" LLVMBuildUnreachable) LLVMValueRef +(wrap-defcfun ("LLVMBuildUnreachable" LLVMBuildUnreachable) LLVMValueRef (arg0 LLVMBuilderRef)) -(cffi:defcfun ("LLVMAddCase" LLVMAddCase) :void +(wrap-defcfun ("LLVMAddCase" LLVMAddCase) :void (Switch LLVMValueRef) (OnVal LLVMValueRef) (Dest LLVMBasicBlockRef)) -(cffi:defcfun ("LLVMBuildAdd" LLVMBuildAdd) LLVMValueRef +(wrap-defcfun ("LLVMBuildAdd" LLVMBuildAdd) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildNSWAdd" LLVMBuildNSWAdd) LLVMValueRef +(wrap-defcfun ("LLVMBuildNSWAdd" LLVMBuildNSWAdd) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFAdd" LLVMBuildFAdd) LLVMValueRef +(wrap-defcfun ("LLVMBuildFAdd" LLVMBuildFAdd) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildSub" LLVMBuildSub) LLVMValueRef +(wrap-defcfun ("LLVMBuildSub" LLVMBuildSub) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFSub" LLVMBuildFSub) LLVMValueRef +(wrap-defcfun ("LLVMBuildFSub" LLVMBuildFSub) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildMul" LLVMBuildMul) LLVMValueRef +(wrap-defcfun ("LLVMBuildMul" LLVMBuildMul) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFMul" LLVMBuildFMul) LLVMValueRef +(wrap-defcfun ("LLVMBuildFMul" LLVMBuildFMul) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildUDiv" LLVMBuildUDiv) LLVMValueRef +(wrap-defcfun ("LLVMBuildUDiv" LLVMBuildUDiv) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildSDiv" LLVMBuildSDiv) LLVMValueRef +(wrap-defcfun ("LLVMBuildSDiv" LLVMBuildSDiv) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildExactSDiv" LLVMBuildExactSDiv) LLVMValueRef +(wrap-defcfun ("LLVMBuildExactSDiv" LLVMBuildExactSDiv) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFDiv" LLVMBuildFDiv) LLVMValueRef +(wrap-defcfun ("LLVMBuildFDiv" LLVMBuildFDiv) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildURem" LLVMBuildURem) LLVMValueRef +(wrap-defcfun ("LLVMBuildURem" LLVMBuildURem) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildSRem" LLVMBuildSRem) LLVMValueRef +(wrap-defcfun ("LLVMBuildSRem" LLVMBuildSRem) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFRem" LLVMBuildFRem) LLVMValueRef +(wrap-defcfun ("LLVMBuildFRem" LLVMBuildFRem) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildShl" LLVMBuildShl) LLVMValueRef +(wrap-defcfun ("LLVMBuildShl" LLVMBuildShl) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildLShr" LLVMBuildLShr) LLVMValueRef +(wrap-defcfun ("LLVMBuildLShr" LLVMBuildLShr) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildAShr" LLVMBuildAShr) LLVMValueRef +(wrap-defcfun ("LLVMBuildAShr" LLVMBuildAShr) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildAnd" LLVMBuildAnd) LLVMValueRef +(wrap-defcfun ("LLVMBuildAnd" LLVMBuildAnd) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildOr" LLVMBuildOr) LLVMValueRef +(wrap-defcfun ("LLVMBuildOr" LLVMBuildOr) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildXor" LLVMBuildXor) LLVMValueRef +(wrap-defcfun ("LLVMBuildXor" LLVMBuildXor) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildNeg" LLVMBuildNeg) LLVMValueRef +(wrap-defcfun ("LLVMBuildNeg" LLVMBuildNeg) LLVMValueRef (arg0 LLVMBuilderRef) (V LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFNeg" LLVMBuildFNeg) LLVMValueRef +(wrap-defcfun ("LLVMBuildFNeg" LLVMBuildFNeg) LLVMValueRef (arg0 LLVMBuilderRef) (V LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildNot" LLVMBuildNot) LLVMValueRef +(wrap-defcfun ("LLVMBuildNot" LLVMBuildNot) LLVMValueRef (arg0 LLVMBuilderRef) (V LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildMalloc" LLVMBuildMalloc) LLVMValueRef +(wrap-defcfun ("LLVMBuildMalloc" LLVMBuildMalloc) LLVMValueRef (arg0 LLVMBuilderRef) (Ty LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildArrayMalloc" LLVMBuildArrayMalloc) LLVMValueRef +(wrap-defcfun ("LLVMBuildArrayMalloc" LLVMBuildArrayMalloc) LLVMValueRef (arg0 LLVMBuilderRef) (Ty LLVMTypeRef) (Val LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildAlloca" LLVMBuildAlloca) LLVMValueRef +(wrap-defcfun ("LLVMBuildAlloca" LLVMBuildAlloca) LLVMValueRef (arg0 LLVMBuilderRef) (Ty LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildArrayAlloca" LLVMBuildArrayAlloca) LLVMValueRef +(wrap-defcfun ("LLVMBuildArrayAlloca" LLVMBuildArrayAlloca) LLVMValueRef (arg0 LLVMBuilderRef) (Ty LLVMTypeRef) (Val LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFree" LLVMBuildFree) LLVMValueRef +(wrap-defcfun ("LLVMBuildFree" LLVMBuildFree) LLVMValueRef (arg0 LLVMBuilderRef) (PointerVal LLVMValueRef)) -(cffi:defcfun ("LLVMBuildLoad" LLVMBuildLoad) LLVMValueRef +(wrap-defcfun ("LLVMBuildLoad" LLVMBuildLoad) LLVMValueRef (arg0 LLVMBuilderRef) (PointerVal LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildStore" LLVMBuildStore) LLVMValueRef +(wrap-defcfun ("LLVMBuildStore" LLVMBuildStore) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (Ptr LLVMValueRef)) -(cffi:defcfun ("LLVMBuildGEP" %LLVMBuildGEP) LLVMValueRef +(wrap-defcfun ("LLVMBuildGEP" %LLVMBuildGEP) LLVMValueRef (B LLVMBuilderRef) (Pointer LLVMValueRef) (Indices :pointer) (NumIndices :unsigned-int) (Name :string)) -(cffi:defcfun ("LLVMBuildInBoundsGEP" %LLVMBuildInBoundsGEP) LLVMValueRef +(wrap-defcfun ("LLVMBuildInBoundsGEP" %LLVMBuildInBoundsGEP) LLVMValueRef (B LLVMBuilderRef) (Pointer LLVMValueRef) (Indices :pointer) (NumIndices :unsigned-int) (Name :string)) -(cffi:defcfun ("LLVMBuildStructGEP" LLVMBuildStructGEP) LLVMValueRef +(wrap-defcfun ("LLVMBuildStructGEP" LLVMBuildStructGEP) LLVMValueRef (B LLVMBuilderRef) (Pointer LLVMValueRef) (Idx :unsigned-int) (Name :string)) -(cffi:defcfun ("LLVMBuildGlobalString" LLVMBuildGlobalString) LLVMValueRef +(wrap-defcfun ("LLVMBuildGlobalString" LLVMBuildGlobalString) LLVMValueRef (B LLVMBuilderRef) (Str :string) (Name :string)) -(cffi:defcfun ("LLVMBuildGlobalStringPtr" LLVMBuildGlobalStringPtr) LLVMValueRef +(wrap-defcfun ("LLVMBuildGlobalStringPtr" LLVMBuildGlobalStringPtr) LLVMValueRef (B LLVMBuilderRef) (Str :string) (Name :string)) -(cffi:defcfun ("LLVMBuildTrunc" LLVMBuildTrunc) LLVMValueRef +(wrap-defcfun ("LLVMBuildTrunc" LLVMBuildTrunc) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildZExt" LLVMBuildZExt) LLVMValueRef +(wrap-defcfun ("LLVMBuildZExt" LLVMBuildZExt) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildSExt" LLVMBuildSExt) LLVMValueRef +(wrap-defcfun ("LLVMBuildSExt" LLVMBuildSExt) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFPToUI" LLVMBuildFPToUI) LLVMValueRef +(wrap-defcfun ("LLVMBuildFPToUI" LLVMBuildFPToUI) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFPToSI" LLVMBuildFPToSI) LLVMValueRef +(wrap-defcfun ("LLVMBuildFPToSI" LLVMBuildFPToSI) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildUIToFP" LLVMBuildUIToFP) LLVMValueRef +(wrap-defcfun ("LLVMBuildUIToFP" LLVMBuildUIToFP) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildSIToFP" LLVMBuildSIToFP) LLVMValueRef +(wrap-defcfun ("LLVMBuildSIToFP" LLVMBuildSIToFP) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFPTrunc" LLVMBuildFPTrunc) LLVMValueRef +(wrap-defcfun ("LLVMBuildFPTrunc" LLVMBuildFPTrunc) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFPExt" LLVMBuildFPExt) LLVMValueRef +(wrap-defcfun ("LLVMBuildFPExt" LLVMBuildFPExt) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildPtrToInt" LLVMBuildPtrToInt) LLVMValueRef +(wrap-defcfun ("LLVMBuildPtrToInt" LLVMBuildPtrToInt) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildIntToPtr" LLVMBuildIntToPtr) LLVMValueRef +(wrap-defcfun ("LLVMBuildIntToPtr" LLVMBuildIntToPtr) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildBitCast" LLVMBuildBitCast) LLVMValueRef +(wrap-defcfun ("LLVMBuildBitCast" LLVMBuildBitCast) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildZExtOrBitCast" LLVMBuildZExtOrBitCast) LLVMValueRef +(wrap-defcfun ("LLVMBuildZExtOrBitCast" LLVMBuildZExtOrBitCast) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildSExtOrBitCast" LLVMBuildSExtOrBitCast) LLVMValueRef +(wrap-defcfun ("LLVMBuildSExtOrBitCast" LLVMBuildSExtOrBitCast) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildTruncOrBitCast" LLVMBuildTruncOrBitCast) LLVMValueRef +(wrap-defcfun ("LLVMBuildTruncOrBitCast" LLVMBuildTruncOrBitCast) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildPointerCast" LLVMBuildPointerCast) LLVMValueRef +(wrap-defcfun ("LLVMBuildPointerCast" LLVMBuildPointerCast) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildIntCast" LLVMBuildIntCast) LLVMValueRef +(wrap-defcfun ("LLVMBuildIntCast" LLVMBuildIntCast) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFPCast" LLVMBuildFPCast) LLVMValueRef +(wrap-defcfun ("LLVMBuildFPCast" LLVMBuildFPCast) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (DestTy LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildICmp" LLVMBuildICmp) LLVMValueRef +(wrap-defcfun ("LLVMBuildICmp" LLVMBuildICmp) LLVMValueRef (arg0 LLVMBuilderRef) (Op LLVMIntPredicate) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildFCmp" LLVMBuildFCmp) LLVMValueRef +(wrap-defcfun ("LLVMBuildFCmp" LLVMBuildFCmp) LLVMValueRef (arg0 LLVMBuilderRef) (Op LLVMRealPredicate) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildPhi" LLVMBuildPhi) LLVMValueRef +(wrap-defcfun ("LLVMBuildPhi" LLVMBuildPhi) LLVMValueRef (arg0 LLVMBuilderRef) (Ty LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildCall" %LLVMBuildCall) LLVMValueRef +(wrap-defcfun ("LLVMBuildCall" %LLVMBuildCall) LLVMValueRef (arg0 LLVMBuilderRef) (Fn LLVMValueRef) (Args :pointer) (NumArgs :unsigned-int) (Name :string)) -(cffi:defcfun ("LLVMBuildSelect" LLVMBuildSelect) LLVMValueRef +(wrap-defcfun ("LLVMBuildSelect" LLVMBuildSelect) LLVMValueRef (arg0 LLVMBuilderRef) (If LLVMValueRef) (Then LLVMValueRef) (Else LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildVAArg" LLVMBuildVAArg) LLVMValueRef +(wrap-defcfun ("LLVMBuildVAArg" LLVMBuildVAArg) LLVMValueRef (arg0 LLVMBuilderRef) (List LLVMValueRef) (Ty LLVMTypeRef) (Name :string)) -(cffi:defcfun ("LLVMBuildExtractElement" LLVMBuildExtractElement) LLVMValueRef +(wrap-defcfun ("LLVMBuildExtractElement" LLVMBuildExtractElement) LLVMValueRef (arg0 LLVMBuilderRef) (VecVal LLVMValueRef) (Index LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildInsertElement" LLVMBuildInsertElement) LLVMValueRef +(wrap-defcfun ("LLVMBuildInsertElement" LLVMBuildInsertElement) LLVMValueRef (arg0 LLVMBuilderRef) (VecVal LLVMValueRef) (EltVal LLVMValueRef) (Index LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildShuffleVector" LLVMBuildShuffleVector) LLVMValueRef +(wrap-defcfun ("LLVMBuildShuffleVector" LLVMBuildShuffleVector) LLVMValueRef (arg0 LLVMBuilderRef) (V1 LLVMValueRef) (V2 LLVMValueRef) (Mask LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildExtractValue" LLVMBuildExtractValue) LLVMValueRef +(wrap-defcfun ("LLVMBuildExtractValue" LLVMBuildExtractValue) LLVMValueRef (arg0 LLVMBuilderRef) (AggVal LLVMValueRef) (Index :unsigned-int) (Name :string)) -(cffi:defcfun ("LLVMBuildInsertValue" LLVMBuildInsertValue) LLVMValueRef +(wrap-defcfun ("LLVMBuildInsertValue" LLVMBuildInsertValue) LLVMValueRef (arg0 LLVMBuilderRef) (AggVal LLVMValueRef) (EltVal LLVMValueRef) (Index :unsigned-int) (Name :string)) -(cffi:defcfun ("LLVMBuildIsNull" LLVMBuildIsNull) LLVMValueRef +(wrap-defcfun ("LLVMBuildIsNull" LLVMBuildIsNull) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildIsNotNull" LLVMBuildIsNotNull) LLVMValueRef +(wrap-defcfun ("LLVMBuildIsNotNull" LLVMBuildIsNotNull) LLVMValueRef (arg0 LLVMBuilderRef) (Val LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMBuildPtrDiff" LLVMBuildPtrDiff) LLVMValueRef +(wrap-defcfun ("LLVMBuildPtrDiff" LLVMBuildPtrDiff) LLVMValueRef (arg0 LLVMBuilderRef) (LHS LLVMValueRef) (RHS LLVMValueRef) (Name :string)) -(cffi:defcfun ("LLVMCreateModuleProviderForExistingModule" LLVMCreateModuleProviderForExistingModule) LLVMModuleProviderRef +(wrap-defcfun ("LLVMCreateModuleProviderForExistingModule" LLVMCreateModuleProviderForExistingModule) LLVMModuleProviderRef (M LLVMModuleRef)) -(cffi:defcfun ("LLVMDisposeModuleProvider" LLVMDisposeModuleProvider) :void +(wrap-defcfun ("LLVMDisposeModuleProvider" LLVMDisposeModuleProvider) :void (MP LLVMModuleProviderRef)) -(cffi:defcfun ("LLVMCreateMemoryBufferWithContentsOfFile" LLVMCreateMemoryBufferWithContentsOfFile) :boolean +(wrap-defcfun ("LLVMCreateMemoryBufferWithContentsOfFile" LLVMCreateMemoryBufferWithContentsOfFile) :boolean (Path :string) (OutMemBuf :pointer) (OutMessage :pointer)) -(cffi:defcfun ("LLVMCreateMemoryBufferWithSTDIN" LLVMCreateMemoryBufferWithSTDIN) :boolean +(wrap-defcfun ("LLVMCreateMemoryBufferWithSTDIN" LLVMCreateMemoryBufferWithSTDIN) :boolean (OutMemBuf :pointer) (OutMessage :pointer)) -(cffi:defcfun ("LLVMDisposeMemoryBuffer" LLVMDisposeMemoryBuffer) :void +(wrap-defcfun ("LLVMDisposeMemoryBuffer" LLVMDisposeMemoryBuffer) :void (MemBuf LLVMMemoryBufferRef)) -(cffi:defcfun ("LLVMCreatePassManager" LLVMCreatePassManager) LLVMPassManagerRef) +(wrap-defcfun ("LLVMCreatePassManager" LLVMCreatePassManager) LLVMPassManagerRef) -(cffi:defcfun ("LLVMCreateFunctionPassManager" LLVMCreateFunctionPassManager) LLVMPassManagerRef +(wrap-defcfun ("LLVMCreateFunctionPassManager" LLVMCreateFunctionPassManager) LLVMPassManagerRef (MP LLVMModuleProviderRef)) -(cffi:defcfun ("LLVMRunPassManager" LLVMRunPassManager) :boolean +(wrap-defcfun ("LLVMRunPassManager" LLVMRunPassManager) :boolean (PM LLVMPassManagerRef) (M LLVMModuleRef)) -(cffi:defcfun ("LLVMInitializeFunctionPassManager" LLVMInitializeFunctionPassManager) :boolean +(wrap-defcfun ("LLVMInitializeFunctionPassManager" LLVMInitializeFunctionPassManager) :boolean (FPM LLVMPassManagerRef)) -(cffi:defcfun ("LLVMRunFunctionPassManager" LLVMRunFunctionPassManager) :boolean +(wrap-defcfun ("LLVMRunFunctionPassManager" LLVMRunFunctionPassManager) :boolean (FPM LLVMPassManagerRef) (F LLVMValueRef)) -(cffi:defcfun ("LLVMFinalizeFunctionPassManager" LLVMFinalizeFunctionPassManager) :boolean +(wrap-defcfun ("LLVMFinalizeFunctionPassManager" LLVMFinalizeFunctionPassManager) :boolean (FPM LLVMPassManagerRef)) -(cffi:defcfun ("LLVMDisposePassManager" LLVMDisposePassManager) :void +(wrap-defcfun ("LLVMDisposePassManager" LLVMDisposePassManager) :void (PM LLVMPassManagerRef)) ;;; The wrappers to expose the "InContext" versions of the functions @@ -1860,19 +1875,19 @@ add multiple incoming values." (with-array-and-length (array len vals) (%LLVMBuildAggregateRet builder array len))) -(defun LLVMBuildInvoke (builder fn args then catch name) +(defun LLVMBuildInvoke (builder fn args then catch &optional (name "")) (with-array-and-length (array len args) (%LLVMBuildInvoke builder fn array len then catch name))) -(defun LLVMBuildGEP (builder ptr indices name) +(defun LLVMBuildGEP (builder ptr indices &optional (name "")) (with-array-and-length (array len indices) (%LLVMBuildGEP builder ptr array len name))) -(defun LLVMBuildInBoundsGEP (builder ptr indices name) +(defun LLVMBuildInBoundsGEP (builder ptr indices &optional (name "")) (with-array-and-length (array len indices) (%LLVMBuildInBoundsGEP builder ptr array len name))) -(defun LLVMBuildCall (builder fn args name) +(defun LLVMBuildCall (builder fn args &optional (name "")) "Combines the C API's Args array and NumArgs arguments into a single list ARGS." (with-array-and-length (array len args) diff --git a/src/generated/llvm-extras.lisp b/src/generated/llvm-extras.lisp index 30d484c..dff0b5e 100644 --- a/src/generated/llvm-extras.lisp +++ b/src/generated/llvm-extras.lisp @@ -49,4 +49,8 @@ (cffi:defcfun ("CLLLVM_LLVMGetRetAttr" LLVMGetRetAttr) LLVMAttribute (Fn LLVMValueRef)) +(cffi:defcfun ("CLLLVM_AddPrintAsmPass" CLLLVM_AddPrintAsmPass) :void + (PM LLVMPassManagerRef) + (Banner :string)) + diff --git a/src/llvm-extras.cpp b/src/llvm-extras.cpp index 2348bb6..79edf56 100644 --- a/src/llvm-extras.cpp +++ b/src/llvm-extras.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #ifndef SWIG using namespace llvm; @@ -98,4 +100,8 @@ LLVMAttribute CLLLVM_LLVMGetRetAttr(LLVMValueRef Fn) { return (LLVMAttribute)attr; } +void CLLLVM_AddPrintAsmPass(LLVMPassManagerRef PM, char *Banner) { + unwrap(PM)->add(createMachineFunctionPrinterPass(errs(), Banner)); +} + } diff --git a/src/stuff.lisp b/src/stuff.lisp index 266deef..caf9365 100644 --- a/src/stuff.lisp +++ b/src/stuff.lisp @@ -1,4 +1,10 @@ (in-package :llvm) + +;; Enable verbose assembly output from codegen +;(cffi::defcvar ("_ZN4llvm16PrintMachineCodeE" *print-machine-code*) :boolean) +;(setf *print-machine-code* t) + + ;; Load up the native codegen. (CLLLVM_LLVMInitializeNativeTarget) -- 2.11.4.GIT From 81a403c7b2ef45a3d9cf49bb7251d98695891d52 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Sat, 2 Jan 2010 02:28:00 -0500 Subject: [PATCH 8/8] Make LLVMConstInt transparently work with bignums. --- README | 14 ++++++++++---- src/core.i | 3 +++ src/generated/core.lisp | 2 +- src/generated/llvm-extras.lisp | 24 ++++++++++++++++++++++++ src/llvm-extras.cpp | 8 ++++++++ src/llvm-extras.i | 22 ++++++++++++++++++++++ 6 files changed, 68 insertions(+), 5 deletions(-) diff --git a/README b/README index fd21e58..5334f4e 100644 --- a/README +++ b/README @@ -65,14 +65,20 @@ There are a few things which I have adjusted in the wrapper: take one at a time: call it multiple times to add multiple incoming values. -4) In LLVMBuild*, where the last argument is a "char *Name", I have +4) Where the C API uses an output array argument, such as + LLVMGetStructElementTypes, I instead return a list. + +5) In LLVMBuild*, where the last argument is a "char *Name", I have arranged to make that an optional argument, defaulting to the empty string. The name is only used to give a human-understandable name to the LHS of the assignment in the LLVM IR. If it is omitted, LLVM has the sane default of an auto-incrementing integer. -5) Where the C API uses an output array argument, such as - LLVMGetStructElementTypes, I instead return a list. +6) "LLVMConstInt(llvm_type ty, uint64 num, bool sign_extend)" has been + wrapped as: "(LLVMConstInt llvm-type arbitrary-width-integer)" + instead, by using the underlying LLVM-side bignum API when + llvm-type is larger than 64 bits. (This is the more intuitive + behavior, and gets rid of the superfluous "sign_extend" argument) -6) Where the C API takes a pointer to a char *ErrorMsg, ...FIXME +7) Where the C API takes a pointer to a char *ErrorMsg, ...FIXME something... diff --git a/src/core.i b/src/core.i index 169af63..20990ee 100644 --- a/src/core.i +++ b/src/core.i @@ -77,6 +77,9 @@ typedef unsigned char uint8_t; %ignore LLVMAddFunctionAttr; %ignore LLVMRemoveFunctionAttr; +// LLVMConstInt is replaced in llvm-extras.i with a bignum-capable fn +%rename LLVMConstInt "%%LLVMConstInt"; + %insert("swiglisp") %{ ;; A little hack make the Name argument for LLVMBuild* be optional and ;; default to the empty string. diff --git a/src/generated/core.lisp b/src/generated/core.lisp index d078792..02ebbb1 100644 --- a/src/generated/core.lisp +++ b/src/generated/core.lisp @@ -634,7 +634,7 @@ (wrap-defcfun ("LLVMConstPointerNull" LLVMConstPointerNull) LLVMValueRef (Ty LLVMTypeRef)) -(wrap-defcfun ("LLVMConstInt" LLVMConstInt) LLVMValueRef +(wrap-defcfun ("LLVMConstInt" %LLVMConstInt) LLVMValueRef (IntTy LLVMTypeRef) (N :unsigned-long-long) (SignExtend :boolean)) diff --git a/src/generated/llvm-extras.lisp b/src/generated/llvm-extras.lisp index dff0b5e..86526d9 100644 --- a/src/generated/llvm-extras.lisp +++ b/src/generated/llvm-extras.lisp @@ -49,8 +49,32 @@ (cffi:defcfun ("CLLLVM_LLVMGetRetAttr" LLVMGetRetAttr) LLVMAttribute (Fn LLVMValueRef)) +(cffi:defcfun ("CLLLVM_LLVMConstIntOfBigVal" LLVMConstIntOfBigVal) LLVMValueRef + (IntTy LLVMTypeRef) + (numWords :unsigned-int) + (bigVal :pointer)) + (cffi:defcfun ("CLLLVM_AddPrintAsmPass" CLLLVM_AddPrintAsmPass) :void (PM LLVMPassManagerRef) (Banner :string)) +(defun LLVMConstInt (Ty Num) + (declare (type integer Num)) + ;; If the type is <= 64 bits, it's easy: we can just pass the + ;; (truncated) number into %LLVMConstInt directly. Otherwise, + ;; convert the number to a bunch of 64-bit words, and pass those to + ;; LLVMConstIntOfBigVal. + (let ((bitwidth (LLVMGetIntTypeWidth Ty))) + (if (< bitwidth 65) + (%LLVMConstInt Ty (logand Num #xffffffffffffffff) 0) + (let ((n-words (ceiling bitwidth 64))) + (cffi:with-foreign-object (array :unsigned-long-long n-words) + (loop for i from 0 below n-words + do + (setf (cffi:mem-aref array :unsigned-long-long i) + (logand Num #xffffffffffffffff)) + (setf Num (ash Num -64))) + (LLVMConstIntOfBigVal Ty n-words array)))))) + + diff --git a/src/llvm-extras.cpp b/src/llvm-extras.cpp index 79edf56..1b36895 100644 --- a/src/llvm-extras.cpp +++ b/src/llvm-extras.cpp @@ -100,6 +100,14 @@ LLVMAttribute CLLLVM_LLVMGetRetAttr(LLVMValueRef Fn) { return (LLVMAttribute)attr; } +LLVMValueRef CLLLVM_LLVMConstIntOfBigVal(LLVMTypeRef IntTy, + unsigned numWords, + const uint64_t bigVal[]) { + IntegerType *Ty = unwrap(IntTy); + return wrap(ConstantInt::get(Ty->getContext(), + APInt(Ty->getBitWidth(), numWords, bigVal))); +} + void CLLLVM_AddPrintAsmPass(LLVMPassManagerRef PM, char *Banner) { unwrap(PM)->add(createMachineFunctionPrinterPass(errs(), Banner)); } diff --git a/src/llvm-extras.i b/src/llvm-extras.i index f6248da..b81775d 100644 --- a/src/llvm-extras.i +++ b/src/llvm-extras.i @@ -6,4 +6,26 @@ %rename CLLLVM_LLVMRemoveRetAttr "LLVMRemoveRetAttr"; %rename CLLLVM_LLVMGetRetAttr "LLVMGetRetAttr"; +%rename CLLLVM_LLVMConstIntOfBigVal "LLVMConstIntOfBigVal"; + %include "./llvm-extras.cpp" + +%insert("swiglisp") %{ +(defun LLVMConstInt (Ty Num) + (declare (type integer Num)) + ;; If the type is <= 64 bits, it's easy: we can just pass the + ;; (truncated) number into %LLVMConstInt directly. Otherwise, + ;; convert the number to a bunch of 64-bit words, and pass those to + ;; LLVMConstIntOfBigVal. + (let ((bitwidth (LLVMGetIntTypeWidth Ty))) + (if (< bitwidth 65) + (%LLVMConstInt Ty (logand Num #xffffffffffffffff) 0) + (let ((n-words (ceiling bitwidth 64))) + (cffi:with-foreign-object (array :unsigned-long-long n-words) + (loop for i from 0 below n-words + do + (setf (cffi:mem-aref array :unsigned-long-long i) + (logand Num #xffffffffffffffff)) + (setf Num (ash Num -64))) + (LLVMConstIntOfBigVal Ty n-words array)))))) +%} -- 2.11.4.GIT