1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 13:30:26 +02:00

Add compiler support for fixnum? primcall predicate

* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/type-fold.scm (fixnum?):
* module/language/cps/types.scm (fixnum?):
* module/system/vm/assembler.scm (system): Add cases for fixnum?
  primcall predicate.
This commit is contained in:
Andy Wingo 2017-10-29 19:42:50 +01:00
parent 79a2748f83
commit 31e7f44340
4 changed files with 18 additions and 1 deletions

View file

@ -442,6 +442,7 @@
(($ $primcall 'bitvector? (a)) (unary emit-bitvector? a))
(($ $primcall 'keyword? (a)) (unary emit-keyword? a))
(($ $primcall 'heap-number? (a)) (unary emit-heap-number? a))
(($ $primcall 'fixnum? (a)) (unary emit-fixnum? a))
;; Add more TC7 tests here. Keep in sync with
;; *branching-primcall-arities* in (language cps primitives) and
;; the set of macro-instructions in assembly.scm.

View file

@ -105,6 +105,7 @@
(else (values #f #f))))
;; All the cases that are in compile-bytecode.
(define-unary-type-predicate-folder fixnum? &fixnum)
(define-unary-type-predicate-folder pair? &pair)
(define-unary-type-predicate-folder symbol? &symbol)
(define-unary-type-predicate-folder variable? &box)

View file

@ -603,6 +603,21 @@ minimum, and maximum."
(logand &all-types (lognot &heap-number-types)))
(restrict! val (if true? &heap-number-types &other-types) -inf.0 +inf.0))
(define-predicate-inferrer (fixnum? val true?)
(cond
(true?
(restrict! val &fixnum most-negative-fixnum most-positive-fixnum))
((type<=? (&type val) &exact-integer)
(cond
((<= (&max val) most-positive-fixnum)
(restrict! val &bignum -inf.0 (1- most-negative-fixnum)))
((>= (&min val) most-negative-fixnum)
(restrict! val &bignum most-positive-fixnum +inf.0))
(else
(restrict! val &bignum -inf.0 +inf.0))))
(else
(restrict! val (logand &all-types (lognot &fixnum)) -inf.0 +inf.0))))
(define-syntax-rule (define-simple-predicate-inferrer predicate type)
(define-predicate-inferrer (predicate val true?)
(let ((type (if true?

View file

@ -86,7 +86,7 @@
emit-jge
emit-jnge
emit-inum?
emit-fixnum?
emit-heap-object?
emit-char?
emit-eq-null?