1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-17 22:42:25 +02:00

Better compiler support for bytevector ops

* module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add emitters
  for bytevector ops.  Add br-if-bytevector emitter.
* module/language/cps/primitives.scm (*branching-primcall-arities*):
  Mark bytevector? as a branching primitive.
* module/system/vm/assembler.scm (br-if-bytevector): New instruction
* module/system/vm/disassembler.scm (code-annotation): Add support for
  bytevector?.
This commit is contained in:
Andy Wingo 2013-10-31 11:39:43 +01:00
parent ecbef96687
commit becce37b58
4 changed files with 47 additions and 2 deletions

View file

@ -215,6 +215,24 @@
(emit-vector-ref asm dst (slot vector) (slot index))))) (emit-vector-ref asm dst (slot vector) (slot index)))))
(($ $primcall 'builtin-ref (name)) (($ $primcall 'builtin-ref (name))
(emit-builtin-ref asm dst (constant name))) (emit-builtin-ref asm dst (constant name)))
(($ $primcall 'bv-u8-ref (bv idx))
(emit-bv-u8-ref asm dst (slot bv) (slot idx)))
(($ $primcall 'bv-u16-ref (bv idx))
(emit-bv-u16-ref asm dst (slot bv) (slot idx)))
(($ $primcall 'bv-s16-ref (bv idx))
(emit-bv-s16-ref asm dst (slot bv) (slot idx)))
(($ $primcall 'bv-u32-ref (bv idx val))
(emit-bv-u32-ref asm dst (slot bv) (slot idx)))
(($ $primcall 'bv-s32-ref (bv idx val))
(emit-bv-s32-ref asm dst (slot bv) (slot idx)))
(($ $primcall 'bv-u64-ref (bv idx val))
(emit-bv-u64-ref asm dst (slot bv) (slot idx)))
(($ $primcall 'bv-s64-ref (bv idx val))
(emit-bv-s64-ref asm dst (slot bv) (slot idx)))
(($ $primcall 'bv-f32-ref (bv idx val))
(emit-bv-f32-ref asm dst (slot bv) (slot idx)))
(($ $primcall 'bv-f64-ref (bv idx val))
(emit-bv-f64-ref asm dst (slot bv) (slot idx)))
(($ $primcall name args) (($ $primcall name args)
;; FIXME: Inline all the cases. ;; FIXME: Inline all the cases.
(let ((inst (prim-rtl-instruction name))) (let ((inst (prim-rtl-instruction name)))
@ -269,6 +287,24 @@
(emit-pop-fluid asm)) (emit-pop-fluid asm))
(($ $primcall 'wind (winder unwinder)) (($ $primcall 'wind (winder unwinder))
(emit-wind asm (slot winder) (slot unwinder))) (emit-wind asm (slot winder) (slot unwinder)))
(($ $primcall 'bv-u8-set! (bv idx val))
(emit-bv-u8-set! asm (slot bv) (slot idx) (slot val)))
(($ $primcall 'bv-u16-set! (bv idx val))
(emit-bv-u16-set! asm (slot bv) (slot idx) (slot val)))
(($ $primcall 'bv-s16-set! (bv idx val))
(emit-bv-s16-set! asm (slot bv) (slot idx) (slot val)))
(($ $primcall 'bv-u32-set! (bv idx val))
(emit-bv-u32-set! asm (slot bv) (slot idx) (slot val)))
(($ $primcall 'bv-s32-set! (bv idx val))
(emit-bv-s32-set! asm (slot bv) (slot idx) (slot val)))
(($ $primcall 'bv-u64-set! (bv idx val))
(emit-bv-u64-set! asm (slot bv) (slot idx) (slot val)))
(($ $primcall 'bv-s64-set! (bv idx val))
(emit-bv-s64-set! asm (slot bv) (slot idx) (slot val)))
(($ $primcall 'bv-f32-set! (bv idx val))
(emit-bv-f32-set! asm (slot bv) (slot idx) (slot val)))
(($ $primcall 'bv-f64-set! (bv idx val))
(emit-bv-f64-set! asm (slot bv) (slot idx) (slot val)))
(($ $primcall 'unwind ()) (($ $primcall 'unwind ())
(emit-unwind asm)) (emit-unwind asm))
(($ $primcall name args) (($ $primcall name args)
@ -319,6 +355,7 @@
(($ $primcall 'variable? (a)) (unary emit-br-if-variable a)) (($ $primcall 'variable? (a)) (unary emit-br-if-variable a))
(($ $primcall 'vector? (a)) (unary emit-br-if-vector a)) (($ $primcall 'vector? (a)) (unary emit-br-if-vector a))
(($ $primcall 'string? (a)) (unary emit-br-if-string a)) (($ $primcall 'string? (a)) (unary emit-br-if-string a))
(($ $primcall 'bytevector? (a)) (unary emit-br-if-bytevector a))
;; Add more TC7 tests here. Keep in sync with ;; Add more TC7 tests here. Keep in sync with
;; *branching-primcall-arities* in (language cps primitives) and ;; *branching-primcall-arities* in (language cps primitives) and
;; the set of macro-instructions in assembly.scm. ;; the set of macro-instructions in assembly.scm.

View file

@ -56,6 +56,7 @@
(vector? . (1 . 1)) (vector? . (1 . 1))
(symbol? . (1 . 1)) (symbol? . (1 . 1))
(variable? . (1 . 1)) (variable? . (1 . 1))
(bytevector? . (1 . 1))
(char? . (1 . 1)) (char? . (1 . 1))
(eq? . (1 . 2)) (eq? . (1 . 2))
(eqv? . (1 . 2)) (eqv? . (1 . 2))

View file

@ -659,7 +659,13 @@ returned instead."
(emit-br-if-tc7 asm slot invert? tc7 label))) (emit-br-if-tc7 asm slot invert? tc7 label)))
;; Keep in sync with tags.h. Part of Guile's ABI. Currently unused ;; Keep in sync with tags.h. Part of Guile's ABI. Currently unused
;; macro assemblers are commented out. ;; macro assemblers are commented out. See also
;; *branching-primcall-arities* in (language cps primitives), the set of
;; macro-instructions in assembly.scm, and
;; disassembler.scm:code-annotation.
;;
;; FIXME: Define all tc7 values in Scheme in one place, derived from
;; tags.h.
(define-tc7-macro-assembler br-if-symbol 5) (define-tc7-macro-assembler br-if-symbol 5)
(define-tc7-macro-assembler br-if-variable 7) (define-tc7-macro-assembler br-if-variable 7)
(define-tc7-macro-assembler br-if-vector 13) (define-tc7-macro-assembler br-if-vector 13)
@ -667,7 +673,7 @@ returned instead."
(define-tc7-macro-assembler br-if-string 21) (define-tc7-macro-assembler br-if-string 21)
;(define-tc7-macro-assembler br-if-heap-number 23) ;(define-tc7-macro-assembler br-if-heap-number 23)
;(define-tc7-macro-assembler br-if-stringbuf 39) ;(define-tc7-macro-assembler br-if-stringbuf 39)
;(define-tc7-macro-assembler br-if-bytevector 77) (define-tc7-macro-assembler br-if-bytevector 77)
;(define-tc7-macro-assembler br-if-pointer 31) ;(define-tc7-macro-assembler br-if-pointer 31)
;(define-tc7-macro-assembler br-if-hashtable 29) ;(define-tc7-macro-assembler br-if-hashtable 29)
;(define-tc7-macro-assembler br-if-fluid 37) ;(define-tc7-macro-assembler br-if-fluid 37)

View file

@ -224,6 +224,7 @@ address of that offset."
((7) "variable?") ((7) "variable?")
((13) "vector?") ((13) "vector?")
((15) "string?") ((15) "string?")
((77) "bytevector?")
(else (number->string tc7))))) (else (number->string tc7)))))
(if invert? (string-append "not " tag) tag)) (if invert? (string-append "not " tag) tag))
(vector-ref labels (- (+ offset target) start)))) (vector-ref labels (- (+ offset target) start))))