Make LLVMConstInt transparently work with bignums.
[cl-llvm.git] / src / generated / llvm-extras.lisp
blob86526d9ec0ae3bef1fd1932e91e241f46e5c2971
1 ;;; This file was automatically generated by SWIG (http://www.swig.org).
2 ;;; Version 1.3.40
3 ;;;
4 ;;; Do not make changes to this file unless you know what you are doing--modify
5 ;;; the SWIG interface file instead.
7 (in-package :llvm)
10 (cffi:defcfun ("CLLLVM_LLVMInitializeNativeTarget" CLLLVM_LLVMInitializeNativeTarget) :int)
12 (cffi:defcfun ("CLLLVM_LLVMModuleProviderGetModule" CLLLVM_LLVMModuleProviderGetModule) LLVMModuleRef
13 (modprovider LLVMModuleProviderRef))
15 (cffi:defcfun ("CLLLVM_LLVMParseAssemblyString" CLLLVM_LLVMParseAssemblyString) LLVMModuleRef
16 (AsmString :string)
17 (M LLVMModuleRef)
18 (Context LLVMContextRef))
20 (cffi:defcfun ("CLLLVM_LLVMIntPtrTypeInContext" CLLLVM_LLVMIntPtrTypeInContext) LLVMTypeRef
21 (Context LLVMContextRef)
22 (TD LLVMTargetDataRef))
24 (cffi:defcfun ("CLLLVM_LLVMDumpModuleToString" CLLLVM_LLVMDumpModuleToString) :string
25 (module LLVMModuleRef))
27 (cffi:defcfun ("CLLLVM_LLVMDumpTypeToString" CLLLVM_LLVMDumpTypeToString) :string
28 (type LLVMTypeRef))
30 (cffi:defcfun ("CLLLVM_LLVMDumpValueToString" CLLLVM_LLVMDumpValueToString) :string
31 (value LLVMValueRef))
33 (cffi:defcfun ("CLLLVM_LLVMAddFunctionAttr" LLVMAddFunctionAttr) :void
34 (Fn LLVMValueRef)
35 (PA LLVMAttribute))
37 (cffi:defcfun ("CLLLVM_LLVMRemoveFunctionAttr" LLVMRemoveFunctionAttr) :void
38 (Fn LLVMValueRef)
39 (PA LLVMAttribute))
41 (cffi:defcfun ("CLLLVM_LLVMAddRetAttr" LLVMAddRetAttr) :void
42 (Fn LLVMValueRef)
43 (PA LLVMAttribute))
45 (cffi:defcfun ("CLLLVM_LLVMRemoveRetAttr" LLVMRemoveRetAttr) :void
46 (Fn LLVMValueRef)
47 (PA LLVMAttribute))
49 (cffi:defcfun ("CLLLVM_LLVMGetRetAttr" LLVMGetRetAttr) LLVMAttribute
50 (Fn LLVMValueRef))
52 (cffi:defcfun ("CLLLVM_LLVMConstIntOfBigVal" LLVMConstIntOfBigVal) LLVMValueRef
53 (IntTy LLVMTypeRef)
54 (numWords :unsigned-int)
55 (bigVal :pointer))
57 (cffi:defcfun ("CLLLVM_AddPrintAsmPass" CLLLVM_AddPrintAsmPass) :void
58 (PM LLVMPassManagerRef)
59 (Banner :string))
61 (defun LLVMConstInt (Ty Num)
62 (declare (type integer Num))
63 ;; If the type is <= 64 bits, it's easy: we can just pass the
64 ;; (truncated) number into %LLVMConstInt directly. Otherwise,
65 ;; convert the number to a bunch of 64-bit words, and pass those to
66 ;; LLVMConstIntOfBigVal.
67 (let ((bitwidth (LLVMGetIntTypeWidth Ty)))
68 (if (< bitwidth 65)
69 (%LLVMConstInt Ty (logand Num #xffffffffffffffff) 0)
70 (let ((n-words (ceiling bitwidth 64)))
71 (cffi:with-foreign-object (array :unsigned-long-long n-words)
72 (loop for i from 0 below n-words
74 (setf (cffi:mem-aref array :unsigned-long-long i)
75 (logand Num #xffffffffffffffff))
76 (setf Num (ash Num -64)))
77 (LLVMConstIntOfBigVal Ty n-words array))))))