[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 20/30: Add &exact-number helper definition
From: |
Andy Wingo |
Subject: |
[Guile-commits] 20/30: Add &exact-number helper definition |
Date: |
Fri, 24 Nov 2017 09:24:22 -0500 (EST) |
wingo pushed a commit to branch master
in repository guile.
commit 6a11fb15325028373c1a6ab334778ee5d3d8a318
Author: Andy Wingo <address@hidden>
Date: Wed Nov 22 15:33:13 2017 +0100
Add &exact-number helper definition
* module/language/cps/types.scm (&exact-number): New union type.
(rational?, exact?):
* module/language/cps/type-fold.scm (mul/immediate): Use the new
definition.
---
module/language/cps/type-fold.scm | 3 +--
module/language/cps/types.scm | 12 +++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/module/language/cps/type-fold.scm
b/module/language/cps/type-fold.scm
index 4fbd5c2..5315e3e 100644
--- a/module/language/cps/type-fold.scm
+++ b/module/language/cps/type-fold.scm
@@ -281,8 +281,7 @@
($ (with-cps-constants ((zero 0))
(build-term
($continue k src ($primcall 'sub #f (zero arg))))))))
- ((and (eqv? constant 0)
- (type<=? type (logior &exact-integer &fraction)))
+ ((and (eqv? constant 0) (type<=? type &exact-number))
;; (* arg 0) -> 0 if arg is exact
(with-cps cps
(build-term ($continue k src ($const 0)))))
diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index 63ee1ce..809b0ec 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -115,7 +115,7 @@
&null &nil &false &true &unspecified &undefined &eof
;; Union types.
- &exact-integer &number &real
+ &exact-integer &exact-number &real &number
;; Untagged types.
&f64
@@ -189,10 +189,12 @@
(define-syntax &exact-integer
(identifier-syntax (logior &fixnum &bignum)))
-(define-syntax &number
- (identifier-syntax (logior &fixnum &bignum &flonum &complex &fraction)))
+(define-syntax &exact-number
+ (identifier-syntax (logior &fixnum &bignum &fraction)))
(define-syntax &real
(identifier-syntax (logior &fixnum &bignum &flonum &fraction)))
+(define-syntax &number
+ (identifier-syntax (logior &fixnum &bignum &flonum &complex &fraction)))
(define-syntax-rule (type<=? x type)
(zero? (logand x (lognot type))))
@@ -1348,7 +1350,7 @@ minimum, and maximum."
(define-type-predicate-result val result type)))
(define-simple-type-predicate-inferrer complex? &number)
(define-simple-type-predicate-inferrer real? &real)
-(define-simple-type-predicate-inferrer rational? (logior &exact-integer
&fraction))
+(define-simple-type-predicate-inferrer rational? &exact-number)
;; FIXME: If it's a flonum it may be an integer, but if it's not an
;; integer it also may be still be a flonum.
;; (define-simple-type-predicate-inferrer integer? (logior &exact-integer
&flonum))
@@ -1356,7 +1358,7 @@ minimum, and maximum."
(define-simple-type-checker (exact? &number))
(define-type-inferrer (exact? val result)
(restrict! val &number -inf.0 +inf.0)
- (define-type-predicate-result val result (logior &exact-integer &fraction)))
+ (define-type-predicate-result val result &exact-number))
(define-simple-type-checker (inexact? &number))
(define-type-inferrer (inexact? val result)
- [Guile-commits] 05/30: Fix s64->scm reducer, (continued)
- [Guile-commits] 05/30: Fix s64->scm reducer, Andy Wingo, 2017/11/24
- [Guile-commits] 02/30: Revert specialization of fixnum phi variables, Andy Wingo, 2017/11/24
- [Guile-commits] 09/30: Fix logand type inference, Andy Wingo, 2017/11/24
- [Guile-commits] 08/30: Revert "Slot allocation allows s64/u64 representations of same var", Andy Wingo, 2017/11/24
- [Guile-commits] 07/30: Fix u64/s64 typesafety around fixnum (un)tagging, Andy Wingo, 2017/11/24
- [Guile-commits] 14/30: Fix type check elision for branches, Andy Wingo, 2017/11/24
- [Guile-commits] 06/30: Separate u64 and s64 type inferrers now that ops are monomorphic, Andy Wingo, 2017/11/24
- [Guile-commits] 18/30: Remove thunk?, integer? simple predicate inferrers, Andy Wingo, 2017/11/24
- [Guile-commits] 17/30: Add support for bignum? CPS primitive., Andy Wingo, 2017/11/24
- [Guile-commits] 22/30: Fix inference of generic < on NaN values, Andy Wingo, 2017/11/24
- [Guile-commits] 20/30: Add &exact-number helper definition,
Andy Wingo <=
- [Guile-commits] 03/30: Better support for unboxed signed arithmetic, Andy Wingo, 2017/11/24
- [Guile-commits] 30/30: Optimize check-urange in assembler.scm, Andy Wingo, 2017/11/24
- [Guile-commits] 27/30: Add integer devirtualization pass., Andy Wingo, 2017/11/24
- [Guile-commits] 12/30: Remove effects-analysis exports that were undefined, Andy Wingo, 2017/11/24
- [Guile-commits] 11/30: Specialize fixnum and s64 phis, Andy Wingo, 2017/11/24
- [Guile-commits] 19/30: Add exact-integer? as interesting Tree-IL effect-free primitive, Andy Wingo, 2017/11/24
- [Guile-commits] 24/30: Declare bignum? as effect-free, Andy Wingo, 2017/11/24
- [Guile-commits] 13/30: Minor compile-cps refactor, Andy Wingo, 2017/11/24
- [Guile-commits] 15/30: DCE eliminates effect-free branches to the same continuation, Andy Wingo, 2017/11/24
- [Guile-commits] 29/30: DCE of branches punches through dead terms, Andy Wingo, 2017/11/24