RV64 as a host: run-time encoders made from the DEFRV encodings, and the emitter.
(defmacro define-rv64-encoders) source(defmacro define-rv64-encoders ()
`(progn
,@(loop for i in (isa-insn-list 'rv64)
collect `(defun ,(rv64-encoder-name (insn-name i)) ,(mapcar #'first (insn-fields i))
(declare ,@(mapcar (lambda (f) `(type (unsigned-byte 64) ,(first f))) (insn-fields i)))
(logior ,(insn-match i)
,@(mapcar (lambda (f)
`(ash (ldb (byte ,(third f) 0) ,(first f)) ,(second f)))
(insn-fields i)))))))(defun rv64-emit32) source(defun rv64-emit32 (code pos word)
"write WORD at POS of CODE, little-endian ([RVUNPRIV] 1.5: instructions
are stored as little-endian parcels); -> POS + 4"
(declare (type (simple-array (unsigned-byte 8) (16384)) code)
(type (unsigned-byte 32) pos word))
(dotimes (i 4)
(setf (aref code (+ pos i)) (ldb (byte 8 (* 8 i)) word)))
(+ pos 4))Made from xspe at b2fac33349db by tools/gen-xspe.py. xspe is GPL-3.0-or-later.