Some cleanup in compilation of IR-IF to asm

This commit is contained in:
John Lorentzson 2025-07-31 12:49:50 +02:00
parent 4c3a25d5e6
commit e302493800

View file

@ -208,21 +208,21 @@ is the responsibility of the pre-assembly compilation step."
(emit-load-data (input inst))
(let ((prev-is-test-p (eql (strategy (allocation-details (input inst)))
:branch)))
(if prev-is-test-p
;; If previous was a test, this instruction will be skipped if the
;; test succeeds and we fall through to the THEN case. If it fails,
;; this instruction executes, which jumps to the ELSE case.
(emit-asm-instruction :opcode #x4C
:operand else-iblock
:byte-length 3)
;; If the input is a bool value, we have to actually do some work.
(progn
;; BNE +3, if it's Not Equal (zero), then it's true, so we skip...
(emit-asm-instruction :opcode #xD0 :operand 3 :byte-length 2)
;; ...the jump to the ELSE case.
(emit-asm-instruction :opcode #x4C
:operand else-iblock
:byte-length 3))))
(cond (prev-is-test-p
;; If previous was a test, this instruction will be skipped if the
;; test succeeds and we fall through to the THEN case. If it fails,
;; this instruction executes, which jumps to the ELSE case.
(emit-asm-instruction :opcode #x4C
:operand else-iblock
:byte-length 3))
(t
;; If the input is a bool value, we have to actually do some work.
;; BNE +3, if it's Not Equal (zero), then it's true, so we skip...
(emit-asm-instruction :opcode #xD0 :operand 3 :byte-length 2)
;; ...the jump to the ELSE case.
(emit-asm-instruction :opcode #x4C
:operand else-iblock
:byte-length 3))))
(setf *last-instruction* :branch)))
(defun emit-branch-test-code (inputs output branch-opcodes)