impc:ir:compiler:pref   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/llvmir.xtm

Implementation

;; returns a ptr to ptr
(define impc:ir:compiler:pref
  (lambda (ast types)
    (let* ((os (make-string 0))
           (val-str (impc:ir:compiler (cadr ast) types))
           (val (impc:ir:gname)))
      (emit val-str os)
      (if *WINDOWS_ALLOC_BUG*
          (begin
            (emit (impc:ir:gname "dat" "i8*") " = call i8* @llvm_zone_malloc(%mzone* " (car (impc:ir:gname "zone")) ", i64 "
                  *impc:ir:pointer_size_bytes_str* ")\n" os)
            (emit (impc:ir:gname "val" (string-append (cadr val) "*"))
                  " = bitcast i8* " (car (impc:ir:gname "dat"))
                  " to " (cadr val) "*\n" os))
          (begin
            (emit (impc:ir:gname "val" (string-append (cadr val) "*"))
                  " = alloca " (cadr val) "\n" os)))
      (emit "store " (cadr val) " " (car val) ", " (cadr val) "* " (car (impc:ir:gname)))
      (impc:ir:strip-space os))))


Back to Index

Similar Entries