(define impc:ir:compiler:zone-alloc-with-size
(lambda (ast types hint?)
(let* ((os (make-string 0)))
(let* ((idx-str (impc:ir:compiler (cadr ast) types))
(idx (impc:ir:gname))
(t (impc:ir:get-type-from-str (cadr idx)))
(tt (impc:ir:pointer-- (car hint?)))
(typesize (number->string (impc:ir:get-type-size tt))))
;;(impc:ir:convert-from-pretty-types (car hint?)))))
;; (tt (if (null? (cddr ast))
;; (impc:ir:pointer-- (impc:ir:convert-from-pretty-types (car hint?)))
;; (impc:ir:convert-from-pretty-types (caddr ast)))))
(if (not (impc:ir:fixed-point? t))
(impc:compiler:print-bad-type-error-with-ast (impc:ir:get-type-str t) "alloc size must be an integer" ast))
(emit idx-str os)
(if (not (member t (list *impc:ir:si64* *impc:ir:ui64*)))
(begin (emit (string-append (impc:ir:gname "tmp" "i64") " = zext " (impc:ir:get-type-str t) " "
(car idx) " to i64\n") os)
(set! idx (impc:ir:gname))))
(emit (impc:ir:gname "val" "i8*") " = getelementptr " (impc:ir:get-type-str t) ", " (impc:ir:get-type-str t) "* null, i32 1\n" os)
;; (emit (impc:ir:gname "typesize" *impc:ir:size_t_str*) " = ptrtoint " (impc:ir:get-type-str t) "* "
;; (car (impc:ir:gname 1)) " to " *impc:ir:size_t_str* "\n" os)
;;
;; (emit (impc:ir:gname "zonesize" "i64") " = mul "
;; (cadr (impc:ir:gname "typesize")) " " (car (impc:ir:gname "typesize")) ", "
;; (car idx) "\n" os)
(emit (impc:ir:gname "zonesize" "i64") " = mul " (cadr idx) " " typesize ", " (car idx) "\n" os)