[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 09/16: reify-primitives reifies constants for out-of-ran
From: |
Andy Wingo |
Subject: |
[Guile-commits] 09/16: reify-primitives reifies constants for out-of-range imm params |
Date: |
Sun, 5 Nov 2017 09:00:41 -0500 (EST) |
wingo pushed a commit to branch master
in repository guile.
commit 1160690fde5ae1c49872db159e7960d4d33d16f9
Author: Andy Wingo <address@hidden>
Date: Wed Nov 1 21:23:02 2017 +0100
reify-primitives reifies constants for out-of-range imm params
* module/language/cps/reify-primitives.scm (reify-primitives): Add pass
to re-reify constant arguments for primcalls with immediate parameters
that can't be encoded as bytecode.
---
module/language/cps/reify-primitives.scm | 47 +++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/module/language/cps/reify-primitives.scm
b/module/language/cps/reify-primitives.scm
index 29a78aa..47982ea 100644
--- a/module/language/cps/reify-primitives.scm
+++ b/module/language/cps/reify-primitives.scm
@@ -151,7 +151,52 @@
(cond
((or (prim-instruction name) (branching-primitive? name))
;; Assume arities are correct.
- cps)
+ (let ()
+ (define (u6? val) (and (exact-integer? val) (<= 0 val 63)))
+ (define (u8? val) (and (exact-integer? val) (<= 0 val 255)))
+ (define-syntax-rule (reify-constants wrap
+ ((op (pred? c) in ...) (op* out ...))
+ ...
+ (_ default))
+ (match name
+ ('op
+ (if (pred? param)
+ cps
+ (match args
+ ((in ...)
+ (with-cps cps
+ (letv c)
+ (letk kconst ($kargs ('c) (c)
+ ($continue k src
+ ($primcall 'op* #f (out ...)))))
+ (setk label
+ ($kargs names vars
+ ($continue kconst src wrap))))))))
+ ...
+ (_ default)))
+ (define-syntax-rule (reify-scm-constants clause ...)
+ (reify-constants ($const param) clause ...))
+ (define-syntax-rule (reify-u64-constants clause ...)
+ (reify-constants ($primcall 'load-u64 param ()) clause ...))
+ (reify-scm-constants
+ ((add/immediate (u8? y) x) (add x y))
+ ((sub/immediate (u8? y) x) (sub x y))
+ (_
+ (reify-u64-constants
+ ((make-vector/immediate (u8? size) init) (make-vector size init))
+ ((vector-ref/immediate (u8? idx) v) (vector-ref v idx))
+ ((vector-set!/immediate (u8? idx) v val) (vector-set! v idx val))
+ ((allocate-struct/immediate (u8? size) vt) (allocate-struct vt
size))
+ ((struct-ref/immediate (u8? idx) s) (struct-ref s idx))
+ ((struct-set!/immediate (u8? idx) s val) (struct-set! s idx val))
+ ((uadd/immediate (u8? y) x) (uadd x y))
+ ((usub/immediate (u8? y) x) (usub x y))
+ ((umul/immediate (u8? y) x) (umul x y))
+ ((rsh/immediate (u6? y) x) (rsh x y))
+ ((lsh/immediate (u6? y) x) (lsh x y))
+ ((ursh/immediate (u6? y) x) (ursh x y))
+ ((ulsh/immediate (u6? y) x) (ulsh x y))
+ (_ cps))))))
(param (error "unexpected param to reified primcall" name))
(else
(with-cps cps
- [Guile-commits] branch master updated (2d8c75f -> f96a670), Andy Wingo, 2017/11/05
- [Guile-commits] 10/16: Tweak optimization order, Andy Wingo, 2017/11/05
- [Guile-commits] 12/16: Specialize primcalls more aggressively, Andy Wingo, 2017/11/05
- [Guile-commits] 13/16: Earlier conversion to /imm primcalls, Andy Wingo, 2017/11/05
- [Guile-commits] 02/16: cache-current-module, etc use immediate primcall parameters, Andy Wingo, 2017/11/05
- [Guile-commits] 05/16: Immediate variants of vector-ref, etc use immediate param, Andy Wingo, 2017/11/05
- [Guile-commits] 15/16: error, scm-error primcalls expand to `throw', Andy Wingo, 2017/11/05
- [Guile-commits] 07/16: builtin-ref takes immediate parameter, Andy Wingo, 2017/11/05
- [Guile-commits] 09/16: reify-primitives reifies constants for out-of-range imm params,
Andy Wingo <=
- [Guile-commits] 03/16: load-f64, etc take immediate parameters, Andy Wingo, 2017/11/05
- [Guile-commits] 04/16: free-ref, free-set take immediate parameters, Andy Wingo, 2017/11/05
- [Guile-commits] 11/16: (system base types) uses target's idea of max size_t, Andy Wingo, 2017/11/05
- [Guile-commits] 16/16: Add new "throw" VM ops, Andy Wingo, 2017/11/05
- [Guile-commits] 14/16: Add lsh, rsh instructions, Andy Wingo, 2017/11/05
- [Guile-commits] 06/16: Immediate parameter for struct-ref et al, Andy Wingo, 2017/11/05
- [Guile-commits] 08/16: Remaining /immediate instructions take primcall imm param, Andy Wingo, 2017/11/05
- [Guile-commits] 01/16: $primcall has a "param" member, Andy Wingo, 2017/11/05