<commit_before>(in-package :llvm)

(defcfun* "LLVMTypeOf" type (val value))
(defcfun (value-name "LLVMGetValueName") :string (val value))
(defcfun* "LLVMSetValueName" :void (val value) (name :string))
(defun (setf value-name) (name val)
  (set-value-name val name)
  name)
(defcfun (%dump-value "LLVMDumpValue") :void (val value))
(defun dump-value (val)
  (finish-output *error-output*)
  (%dump-value val))

(defcfun* "LLVMConstNull" value (ty type))
(defcfun* "LLVMConstAllOnes" value (ty type))
(defcfun* "LLVMGetUndef" value (ty type))
(defcfun (constantp "LLVMIsConstant") :boolean (val value))
(defcfun (nullp "LLVMIsNull") :boolean (val value))
(defcfun (undefp "LLVMIsUndef") :boolean (val value))
(defcfun* "LLVMConstPointerNull" value (ty type))

(defcfun (%const-int "LLVMConstInt") value
  (int-ty type) (n :unsigned-long-long) (sign-extend :boolean))
(defcfun* "LLVMConstIntOfString" value
  (int-ty type) (text :string) (radix :uint8))
;; NOTE: This is only available in SVN as of revision 119989, and releases after
;;       1.8.
(defcfun* "LLVMConstIntOfArbitraryPrecision" value
  (int-ty type) (num-words :unsigned-int) (words (carray :uint64)))
(defun const-int (int-ty value &optional radix)
  (if (typep value 'string)
      (const-int-of-string int-ty value radix)
      (let* ((+max-primitive-width+ 64)
             (bitmask (1- (expt 2 +max-primitive-width+)))
             (width (width int-ty)))
        (if (<= width +max-primitive-width+)
            (%const-int int-ty (logand value bitmask) nil)
            (let* ((length (ceiling width +max-primitive-width+))
                   (words (loop for num = value
                             then (ash num (- +max-primitive-width+))
                             while (< 0 num)
                             collect (logand num bitmask))))
              (const-int-of-arbitrary-precision int-ty length words))))))
(defcfun (%const-real "LLVMConstReal") value (real-ty type) (n real-double))<commit_msg>Bind LLVMGetUndef to the exported lisp name.<commit_after>(in-package :llvm)

(defcfun* "LLVMTypeOf" type (val value))
(defcfun (value-name "LLVMGetValueName") :string (val value))
(defcfun* "LLVMSetValueName" :void (val value) (name :string))
(defun (setf value-name) (name val)
  (set-value-name val name)
  name)
(defcfun (%dump-value "LLVMDumpValue") :void (val value))
(defun dump-value (val)
  (finish-output *error-output*)
  (%dump-value val))

(defcfun* "LLVMConstNull" value (ty type))
(defcfun* "LLVMConstAllOnes" value (ty type))
(defcfun (undef "LLVMGetUndef") value (ty type))
(defcfun (constantp "LLVMIsConstant") :boolean (val value))
(defcfun (nullp "LLVMIsNull") :boolean (val value))
(defcfun (undefp "LLVMIsUndef") :boolean (val value))
(defcfun* "LLVMConstPointerNull" value (ty type))

(defcfun (%const-int "LLVMConstInt") value
  (int-ty type) (n :unsigned-long-long) (sign-extend :boolean))
(defcfun* "LLVMConstIntOfString" value
  (int-ty type) (text :string) (radix :uint8))
;; NOTE: This is only available in SVN as of revision 119989, and releases after
;;       1.8.
(defcfun* "LLVMConstIntOfArbitraryPrecision" value
  (int-ty type) (num-words :unsigned-int) (words (carray :uint64)))
(defun const-int (int-ty value &optional radix)
  (if (typep value 'string)
      (const-int-of-string int-ty value radix)
      (let* ((+max-primitive-width+ 64)
             (bitmask (1- (expt 2 +max-primitive-width+)))
             (width (width int-ty)))
        (if (<= width +max-primitive-width+)
            (%const-int int-ty (logand value bitmask) nil)
            (let* ((length (ceiling width +max-primitive-width+))
                   (words (loop for num = value
                             then (ash num (- +max-primitive-width+))
                             while (< 0 num)
                             collect (logand num bitmask))))
              (const-int-of-arbitrary-precision int-ty length words))))))
(defcfun (%const-real "LLVMConstReal") value (real-ty type) (n real-double))
{'fraction_non_alphanumeric': 0.15157578789394696, 'fraction_numerical': 0.0080040020010005, 'mean_word_length': 3.2953813104189043, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7109530', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1376, 'n_words': 388}