1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 18:20:22 +02:00

Add sign-extending make-immediate instruction

* doc/ref/vm.texi (Instruction Set, Constant Instructions): Document new
  instruction.
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): New first
  word kind with zi16 operand.
* libguile/jit.c (compile_make_immediate, compile_make_immediate_slow):
  New compilers.
  (COMPILE_X8_S8_ZI16): New operand kind.
* libguile/vm-engine.c (make-immediate): New instruction.
* module/language/bytecode.scm:
* module/system/vm/assembler.scm (encode-X8_S8_ZI16<-/shuffle):
  (signed-bits, load-constant): Support the new instruction kind.
* module/system/vm/disassembler.scm (disassemblers)
  (sign-extended-immediate, code-annotation): Support for zi16
  operands.
This commit is contained in:
Andy Wingo 2020-07-30 17:36:11 +02:00
parent f13b27a4cc
commit 172e5ccfc1
7 changed files with 88 additions and 5 deletions

View file

@ -95,7 +95,7 @@
#'((ash word -8)))
((X8_L24)
#'((unpack-s24 (ash word -8))))
((X8_S8_I16)
((X8_S8_I16 X8_S8_ZI16)
#'((logand (ash word -8) #xff)
(ash word -16)))
((X8_S12_S12
@ -205,6 +205,14 @@ address of that offset."
(visit-heap-tags define-heap-tag-annotation)
(define (sign-extended-immediate uimm n)
(unpack-scm
(if (>= uimm (ash 1 (- n 1)))
(let ((word-bits (* (sizeof '*) 8))) ; FIXME
(logand (1- (ash 1 word-bits))
(- uimm (ash 1 n))))
uimm)))
(define (code-annotation code len offset start labels context push-addr!)
;; FIXME: Print names for register loads and stores that correspond to
;; access to named locals.
@ -227,6 +235,8 @@ address of that offset."
(('prompt tag escape-only? proc-slot handler)
;; The H is for handler.
(list "H -> ~A" (vector-ref labels (- (+ offset handler) start))))
(('make-immediate _ imm)
(list "~S" (sign-extended-immediate imm 16)))
(((or 'make-short-immediate 'make-long-immediate) _ imm)
(list "~S" (unpack-scm imm)))
(('make-long-long-immediate _ high low)