mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
Use new instructions for less-than, etc
* module/language/cps/compile-bytecode.scm (compile-function): Use new instructions for generic numeric comparisons (< <= = >= >).
This commit is contained in:
parent
056914b555
commit
f8ac680965
1 changed files with 15 additions and 12 deletions
|
@ -394,24 +394,27 @@
|
|||
;; Otherwise prefer a backwards
|
||||
;; branch or a near jump.
|
||||
(< kt kf)))
|
||||
(define (emit-branch-for-test)
|
||||
(define (emit-branch emit-jt emit-jf)
|
||||
(cond
|
||||
((eq? kt next-label)
|
||||
(emit-jne asm kf))
|
||||
(emit-jf asm kf))
|
||||
((eq? kf next-label)
|
||||
(emit-je asm kt))
|
||||
(emit-jt asm kt))
|
||||
((prefer-true?)
|
||||
(emit-je asm kt)
|
||||
(emit-jt asm kt)
|
||||
(emit-j asm kf))
|
||||
(else
|
||||
(emit-jne asm kf)
|
||||
(emit-jf asm kf)
|
||||
(emit-j asm kt))))
|
||||
(define (unary op a)
|
||||
(op asm (from-sp (slot a)))
|
||||
(emit-branch-for-test))
|
||||
(emit-branch emit-je emit-jne))
|
||||
(define (binary-test op a b)
|
||||
(op asm (from-sp (slot a)) (from-sp (slot b)))
|
||||
(emit-branch-for-test))
|
||||
(emit-branch emit-je emit-jne))
|
||||
(define (binary* op emit-jt emit-jf a b)
|
||||
(op asm (from-sp (slot a)) (from-sp (slot b)))
|
||||
(emit-branch emit-jt emit-jf))
|
||||
(define (binary op a b)
|
||||
(cond
|
||||
((eq? kt next-label)
|
||||
|
@ -443,11 +446,11 @@
|
|||
;; the set of macro-instructions in assembly.scm.
|
||||
(($ $primcall 'eq? (a b)) (binary-test emit-eq? a b))
|
||||
(($ $primcall 'eqv? (a b)) (binary emit-br-if-eqv a b))
|
||||
(($ $primcall '< (a b)) (binary emit-br-if-< a b))
|
||||
(($ $primcall '<= (a b)) (binary emit-br-if-<= a b))
|
||||
(($ $primcall '= (a b)) (binary emit-br-if-= a b))
|
||||
(($ $primcall '>= (a b)) (binary emit-br-if-<= b a))
|
||||
(($ $primcall '> (a b)) (binary emit-br-if-< b a))
|
||||
(($ $primcall '< (a b)) (binary* emit-<? emit-jl emit-jnl a b))
|
||||
(($ $primcall '<= (a b)) (binary* emit-<? emit-jge emit-jnge b a))
|
||||
(($ $primcall '= (a b)) (binary-test emit-=? a b))
|
||||
(($ $primcall '>= (a b)) (binary* emit-<? emit-jge emit-jnge a b))
|
||||
(($ $primcall '> (a b)) (binary* emit-<? emit-jl emit-jnl b a))
|
||||
(($ $primcall 'u64-< (a b)) (binary emit-br-if-u64-< a b))
|
||||
(($ $primcall 'u64-<= (a b)) (binary emit-br-if-u64-<= a b))
|
||||
(($ $primcall 'u64-= (a b)) (binary emit-br-if-u64-= a b))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue