impc:ir:compiler:zone-alloc-without-size   scheme


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

Implementation

(define impc:ir:compiler:zone-alloc-without-size
  (lambda (ast types hint?)
    (let* ((os (make-string 0)))
      (let*      ;((t (impc:ir:convert-from-pretty-types (cadr ast))))
          ((t (impc:ir:pointer-- (car hint?))))
        (emit (impc:ir:gname "tzone" "i8*") " = load i8*, i8** %_impzPtr\n"
              (impc:ir:gname "zone" "%mzone*") " = bitcast i8* " (car (impc:ir:gname "tzone")) " to %mzone*\n"
              os)
        (emit (impc:ir:gname "dat" "i8*") " = call i8* @llvm_zone_malloc(%mzone* " (car (impc:ir:gname "zone")) ", "
              *impc:ir:size_t_str* " " (number->string (impc:ir:get-type-size t)) ")\n" os)
        (emit "call i8* @memset(i8* " (car (impc:ir:gname "dat")) ", i32 0, "
              *impc:ir:size_t_str* " " (number->string (impc:ir:get-type-size t)) ")\n" os)
        (emit (impc:ir:gname "val" (string-append (impc:ir:get-type-str t) "*"))
              " = bitcast i8* " (car (impc:ir:gname "dat"))
              " to " (impc:ir:get-type-str t) "*\n" os)
        (impc:ir:strip-space os)))))


Back to Index