impc:ir:get-alignment   scheme

Defined in:


(define impc:ir:get-alignment
  (lambda (t)
    (let  ((nt (impc:ti:get-namedtype-type t)))
      (if nt (set! t nt)))
    (cond ((impc:ir:pointer? t) (/ (sys:pointer-size) 8))
          ((impc:ir:array? t) (impc:ir:get-type-size (caddr t))) ;; align to array element type
          ((impc:ir:vector? t) (impc:ir:get-type-size t)) ;; align to full size of vector
          ((or  ;; tuples align to their largest internal aligment
            (impc:ir:closure? t)
            (impc:ir:tuple? t))
           (apply max (map (lambda (tt)
                             (impc:ir:get-alignment tt))
                           (cdr t))))
          ;; (else (impc:ir:get-type-size t)))))
          (else ;; under MCJIT i64 appears to be 4-byte aligned, not
           ;; 8-byte aligned. WTF?
           (if (= t 2) 4 (impc:ir:get-type-size t))))))

Back to Index