Add compilation method for IR-IF

This commit is contained in:
John Lorentzson 2025-07-03 16:56:32 +02:00
parent 3876801960
commit a24c5353a5

View file

@ -191,6 +191,21 @@
:byte-length 3))
(setf *last-instruction* '(:jump)))
(defmethod compile-ir ((inst ir-if))
(let ((next-iblock (next (iblock inst)))
(then-iblock (first (destinations inst)))
(else-iblock (second (destinations inst))))
;; With how the midstage is built, the true case's block comes immediately
;; after the IF, and therefore we should branch on false. This assert
;; ensures that this assumption become false without us noticing.
;; We implicitly fall through to THEN-BLOCK in the event of no branch.
(assert (eql next-iblock then-iblock))
(emit-load-bool (input inst))
(emit-asm-instruction :opcode #xD0
:operand else-iblock
:byte-length 2)
(setf *last-instruction* '(:conditional))))
(defmethod compile-ir ((inst ir-test-equal))
(emit-load-data (first (inputs inst)))
(if (eql (strategy (allocation-details (second (inputs inst))))