[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 10/13: Add assume-u64 and assume-s64 dataflow restrictio
From: |
Andy Wingo |
Subject: |
[Guile-commits] 10/13: Add assume-u64 and assume-s64 dataflow restrictions |
Date: |
Tue, 16 Jan 2018 10:46:30 -0500 (EST) |
wingo pushed a commit to branch master
in repository guile.
commit 4829cb3ce9d80b45d26e4f987d962a089ef74c91
Author: Andy Wingo <address@hidden>
Date: Tue Jan 16 16:19:12 2018 +0100
Add assume-u64 and assume-s64 dataflow restrictions
* module/language/cps/effects-analysis.scm::
* module/language/cps/reify-primitives.scm (reify-primitives):
* module/language/cps/slot-allocation.scm (compute-var-representations):
* module/language/cps/types.scm (assume-u64, assume-s64): Add primitives
that assume the range of a u64 or s64 value is within certain bounds.
This is useful when extracting e.g. a length from a 64-bit word when
you know the length is less than 2**48.
---
module/language/cps/effects-analysis.scm | 2 ++
module/language/cps/reify-primitives.scm | 6 ++++++
module/language/cps/slot-allocation.scm | 2 ++
module/language/cps/types.scm | 9 +++++++++
4 files changed, 19 insertions(+)
diff --git a/module/language/cps/effects-analysis.scm
b/module/language/cps/effects-analysis.scm
index 6038d5a..4fa00db 100644
--- a/module/language/cps/effects-analysis.scm
+++ b/module/language/cps/effects-analysis.scm
@@ -427,6 +427,8 @@ the LABELS that are clobbered by the effects of LABEL."
((s64->scm/unlikely _))
((u64->s64 _))
((s64->u64 _))
+ ((assume-u64 _))
+ ((assume-s64 _))
((untag-fixnum _))
((tag-fixnum _))
((tag-fixnum/unlikely _)))
diff --git a/module/language/cps/reify-primitives.scm
b/module/language/cps/reify-primitives.scm
index 98371b6..327700d 100644
--- a/module/language/cps/reify-primitives.scm
+++ b/module/language/cps/reify-primitives.scm
@@ -268,6 +268,12 @@
($continue k src ($primcall 'mul #f (a b*)))))
(setk label ($kargs names vars
($continue kb src ($const b))))))
+ (($ $kargs names vars
+ ($ $continue k src
+ ($ $primcall (or 'assume-u64 'assume-s64) (lo . hi) (val))))
+ (with-cps cps
+ (setk label ($kargs names vars
+ ($continue k src ($values (val)))))))
(($ $kargs names vars ($ $continue k src ($ $primcall name param args)))
(cond
((hashq-ref *ephemeral-reifiers* name)
diff --git a/module/language/cps/slot-allocation.scm
b/module/language/cps/slot-allocation.scm
index 4a39a89..2729c03 100644
--- a/module/language/cps/slot-allocation.scm
+++ b/module/language/cps/slot-allocation.scm
@@ -754,6 +754,7 @@ are comparable with eqv?. A tmp slot may be used."
(($ $primcall (or 'scm->u64 'scm->u64/truncate 'load-u64
'char->integer 's64->u64
'bv-length 'string-length
+ 'assume-u64
'uadd 'usub 'umul
'ulogand 'ulogior 'ulogxor 'ulogsub 'ursh 'ulsh
'uadd/immediate 'usub/immediate 'umul/immediate
@@ -763,6 +764,7 @@ are comparable with eqv?. A tmp slot may be used."
'word-ref 'word-ref/immediate))
(intmap-add representations var 'u64))
(($ $primcall (or 'untag-fixnum
+ 'assume-s64
'scm->s64 'load-s64 'u64->s64
'srsh 'srsh/immediate
's8-ref 's16-ref 's32-ref 's64-ref
diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index 50f1697..5f15f3a 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -787,6 +787,15 @@ minimum, and maximum."
(define-type-inferrer/param (pointer-ref/immediate param obj result)
(define! result &other-heap-object -inf.0 +inf.0))
+(define-type-inferrer/param (assume-u64 param val result)
+ (match param
+ ((lo . hi)
+ (define! result &u64 (max lo (&min val)) (min hi (&max val))))))
+(define-type-inferrer/param (assume-s64 param val result)
+ (match param
+ ((lo . hi)
+ (define! result &s64 (max lo (&min val)) (min hi (&max val))))))
+
- [Guile-commits] branch master updated (02e52a4 -> 310c34e), Andy Wingo, 2018/01/16
- [Guile-commits] 11/13: Instruction explosion for bv-length, Andy Wingo, 2018/01/16
- [Guile-commits] 01/13: Instruction explosion for struct-vtable, Andy Wingo, 2018/01/16
- [Guile-commits] 12/13: Remove optimizer and backend support for bv-u8-ref et al, Andy Wingo, 2018/01/16
- [Guile-commits] 02/13: Add support for raw gc-managed pointer locals, Andy Wingo, 2018/01/16
- [Guile-commits] 10/13: Add assume-u64 and assume-s64 dataflow restrictions,
Andy Wingo <=
- [Guile-commits] 06/13: Custom bv-u8-ref lowering procedure, Andy Wingo, 2018/01/16
- [Guile-commits] 09/13: Instruction explosion for bytevector setters, Andy Wingo, 2018/01/16
- [Guile-commits] 07/13: Instruction explosion for integer bytevector ref procedures, Andy Wingo, 2018/01/16
- [Guile-commits] 03/13: Add optimizer and backend support for gc-pointer-ref, Andy Wingo, 2018/01/16
- [Guile-commits] 13/13: Remove bytevector instructions from the VM., Andy Wingo, 2018/01/16
- [Guile-commits] 08/13: Add f32-ref, f64-ref lowering procs, Andy Wingo, 2018/01/16
- [Guile-commits] 04/13: Add raw u8-ref, etc instructions, Andy Wingo, 2018/01/16
- [Guile-commits] 05/13: Rename gc-pointer-ref to pointer-ref, Andy Wingo, 2018/01/16