[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 02/12: Refactor numeric comparison bytecode emission
From: |
Andy Wingo |
Subject: |
[Guile-commits] 02/12: Refactor numeric comparison bytecode emission |
Date: |
Sat, 11 Nov 2017 16:12:24 -0500 (EST) |
wingo pushed a commit to branch master
in repository guile.
commit 8b3258716cc456ad6adeb5c45e6b4910a5e4f4b6
Author: Andy Wingo <address@hidden>
Date: Mon Nov 6 21:44:31 2017 +0100
Refactor numeric comparison bytecode emission
* module/language/cps/compile-bytecode.scm (compile-function): Refactor.
---
module/language/cps/compile-bytecode.scm | 36 ++++++++++++++++++--------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/module/language/cps/compile-bytecode.scm
b/module/language/cps/compile-bytecode.scm
index 1284e65..8e61604 100644
--- a/module/language/cps/compile-bytecode.scm
+++ b/module/language/cps/compile-bytecode.scm
@@ -419,6 +419,10 @@
(emit-branch emit-jt emit-jf))
(define (binary-test op a b)
(binary op emit-je emit-jne a b))
+ (define (binary-< emit-<? a b)
+ (binary emit-<? emit-jl emit-jnl a b))
+ (define (binary->= emit-<? a b)
+ (binary emit-<? emit-jge emit-jnge a b))
(match exp
(($ $primcall 'heap-object? #f (a)) (unary emit-heap-object? a))
(($ $primcall 'null? #f (a)) (unary emit-null? a))
@@ -442,26 +446,26 @@
(($ $primcall 'eq? #f (a b)) (binary-test emit-eq? a b))
(($ $primcall 'heap-numbers-equal? #f (a b))
(binary-test emit-heap-numbers-equal? a b))
- (($ $primcall '< #f (a b)) (binary emit-<? emit-jl emit-jnl a b))
- (($ $primcall '<= #f (a b)) (binary emit-<? emit-jge emit-jnge b a))
+ (($ $primcall '< #f (a b)) (binary-< emit-<? a b))
+ (($ $primcall '<= #f (a b)) (binary->= emit-<? b a))
(($ $primcall '= #f (a b)) (binary-test emit-=? a b))
- (($ $primcall '>= #f (a b)) (binary emit-<? emit-jge emit-jnge a b))
- (($ $primcall '> #f (a b)) (binary emit-<? emit-jl emit-jnl b a))
- (($ $primcall 'u64-< #f (a b)) (binary emit-u64<? emit-jl emit-jnl a
b))
- (($ $primcall 'u64-<= #f (a b)) (binary emit-u64<? emit-jnl emit-jl b
a))
+ (($ $primcall '>= #f (a b)) (binary->= emit-<? a b))
+ (($ $primcall '> #f (a b)) (binary-< emit-<? b a))
+ (($ $primcall 'u64-< #f (a b)) (binary-< emit-u64<? a b))
+ (($ $primcall 'u64-<= #f (a b)) (binary->= emit-u64<? b a))
(($ $primcall 'u64-= #f (a b)) (binary-test emit-u64=? a b))
- (($ $primcall 'u64->= #f (a b)) (binary emit-u64<? emit-jnl emit-jl a
b))
- (($ $primcall 'u64-> #f (a b)) (binary emit-u64<? emit-jl emit-jnl b
a))
- (($ $primcall 's64-< #f (a b)) (binary emit-s64<? emit-jl emit-jnl a
b))
- (($ $primcall 's64-<= #f (a b)) (binary emit-s64<? emit-jnl emit-jl b
a))
+ (($ $primcall 'u64->= #f (a b)) (binary->= emit-u64<? a b))
+ (($ $primcall 'u64-> #f (a b)) (binary-< emit-u64<? b a))
+ (($ $primcall 's64-< #f (a b)) (binary-< emit-s64<? a b))
+ (($ $primcall 's64-<= #f (a b)) (binary->= emit-s64<? b a))
(($ $primcall 's64-= #f (a b)) (binary-test emit-s64=? a b))
- (($ $primcall 's64->= #f (a b)) (binary emit-s64<? emit-jnl emit-jl a
b))
- (($ $primcall 's64-> #f (a b)) (binary emit-s64<? emit-jl emit-jnl b
a))
- (($ $primcall 'f64-< #f (a b)) (binary emit-f64<? emit-jl emit-jnl a
b))
- (($ $primcall 'f64-<= #f (a b)) (binary emit-f64<? emit-jge emit-jnge
b a))
+ (($ $primcall 's64->= #f (a b)) (binary->= emit-s64<? a b))
+ (($ $primcall 's64-> #f (a b)) (binary-< emit-s64<? b a))
+ (($ $primcall 'f64-< #f (a b)) (binary-< emit-f64<? a b))
+ (($ $primcall 'f64-<= #f (a b)) (binary->= emit-f64<? b a))
(($ $primcall 'f64-= #f (a b)) (binary-test emit-f64=? a b))
- (($ $primcall 'f64->= #f (a b)) (binary emit-f64<? emit-jge emit-jnge
a b))
- (($ $primcall 'f64-> #f (a b)) (binary emit-f64<? emit-jl emit-jnl b
a))))
+ (($ $primcall 'f64->= #f (a b)) (binary->= emit-f64<? a b))
+ (($ $primcall 'f64-> #f (a b)) (binary-< emit-f64<? b a))))
(define (compile-trunc label k exp nreq rest-var)
(define (do-call proc args emit-call)
- [Guile-commits] branch master updated (f96a670 -> 83a03a3), Andy Wingo, 2017/11/11
- [Guile-commits] 01/12: Fix effects analysis bug introduced with primcall param, Andy Wingo, 2017/11/11
- [Guile-commits] 02/12: Refactor numeric comparison bytecode emission,
Andy Wingo <=
- [Guile-commits] 05/12: Closure conversion uses immediate variants of vector instructions, Andy Wingo, 2017/11/11
- [Guile-commits] 06/12: Use immediate primcalls when unfolding constructors, Andy Wingo, 2017/11/11
- [Guile-commits] 09/12: Convert "ash" to "lsh"/"rsh" when lowering to CPS, Andy Wingo, 2017/11/11
- [Guile-commits] 12/12: Specialize rsh/lsh, not ash, Andy Wingo, 2017/11/11
- [Guile-commits] 07/12: Add tag-fixnum instruction, Andy Wingo, 2017/11/11
- [Guile-commits] 08/12: Compiler uses target fixnum range, Andy Wingo, 2017/11/11
- [Guile-commits] 03/12: Canonicalize <=, >=, and > primcalls to <, Andy Wingo, 2017/11/11
- [Guile-commits] 11/12: Add missing lsh/immediate, rsh/immediate type inferrers, Andy Wingo, 2017/11/11
- [Guile-commits] 04/12: Specialize comparisons to SCM as s64, Andy Wingo, 2017/11/11
- [Guile-commits] 10/12: Type folding has "macro reduction" phase, Andy Wingo, 2017/11/11