the one MIPS state every model runs on, and the accessors every semantics body uses.
(defstruct mips) source(defstruct (mips (:conc-name mips-))
(gpr (make-array 32 :element-type '(unsigned-byte 64) :initial-element 0)
:type (simple-array (unsigned-byte 64) (32)))
(gprhi (make-array 32 :element-type '(unsigned-byte 64) :initial-element 0)
:type (simple-array (unsigned-byte 64) (32)))
(hi 0 :type (unsigned-byte 64))
(lo 0 :type (unsigned-byte 64))
(hi1 0 :type (unsigned-byte 64))
(lo1 0 :type (unsigned-byte 64))
(sa 0 :type (unsigned-byte 32))
(pc 0 :type (unsigned-byte 32))
(npc 4 :type (unsigned-byte 32))
(nnpc 8 :type (unsigned-byte 32))
(bd 0 :type (unsigned-byte 8))
(jmp 0 :type (unsigned-byte 8))
(ldr 0 :type (unsigned-byte 8))
(ldv 0 :type (unsigned-byte 64))
(cop0 (make-array 32 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (32)))
(fpr (make-array 32 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (32)))
(fcr31 0 :type (unsigned-byte 32))
(facc 0 :type (unsigned-byte 32))
(cop2d (make-array 32 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (32)))
(cop2c (make-array 32 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (32)))
(vf (make-array 128 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (128)))
(exc 0 :type (unsigned-byte 8))
(lfr 0 :type (unsigned-byte 8))
(lfv 0 :type (unsigned-byte 64))
(bt 0 :type (unsigned-byte 8))
;; the R5900's (cop0.lisp, vu0.lisp)
(cpcond0 0 :type (unsigned-byte 8))
(cop0x (make-array 16 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (16)))
(tlb (make-array 192 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (192)))
(vacc (make-array 4 :element-type '(unsigned-byte 32) :initial-element 0)
:type (simple-array (unsigned-byte 32) (4))))(defconstant +exc-none+) source(defconstant +exc-none+ 0)(defconstant +exc-illegal+) source(defconstant +exc-illegal+ 1)(defconstant +exc-syscall+) source(defconstant +exc-syscall+ 2)(defconstant +exc-break+) source(defconstant +exc-break+ 3)(defconstant +exc-overflow+) source(defconstant +exc-overflow+ 4)(defconstant +exc-adel+) source(defconstant +exc-adel+ 5)(defconstant +exc-ades+) source(defconstant +exc-ades+ 6)(defconstant +exc-trap+) source(defconstant +exc-trap+ 7)(defconstant +exc-cpu+) source(defconstant +exc-cpu+ 8)(defconstant +exc-interrupt+) source(defconstant +exc-interrupt+ 9)(defconstant +exc-ibe+) source(defconstant +exc-ibe+ 10)(defconstant +exc-dbe+) source(defconstant +exc-dbe+ 11)(defmacro gpr) source(defmacro gpr (n) `(aref (mips-gpr cpu) ,n))(defmacro set-gpr) source(defmacro set-gpr (n v) `(unless (= ,n 0) (setf (gpr ,n) ,v)))(defmipsmacro xgpr) source(defmipsmacro xgpr (n)
(if (= (mips-model-prop :xlen) 32) `(wrap 32 (gpr ,n)) `(wrap 64 (gpr ,n))))(defmipsmacro sgpr) source(defmipsmacro sgpr (n) `(sext ,(mips-model-prop :xlen) (gpr ,n)))(defmipsmacro set-gpr32) source(defmipsmacro set-gpr32 (n v)
(if (= (mips-model-prop :xlen) 32)
`(set-gpr ,n (wrap 32 ,v))
`(set-gpr ,n (wrap 64 (sext 32 ,v)))))(defmipsmacro set-gprx) source(defmipsmacro set-gprx (n v) `(set-gpr ,n (wrap ,(mips-model-prop :xlen) ,v)))(defmipsmacro reg32) source(defmipsmacro reg32 (v)
(if (= (mips-model-prop :xlen) 32) `(wrap 32 ,v) `(wrap 64 (sext 32 ,v))))(defmipsmacro set-gpr-load) source(defmipsmacro set-gpr-load (n v)
(if (member :load-delay (mips-model-features))
`(unless (= ,n 0) (setf (mips-ldr cpu) ,n (mips-ldv cpu) ,v))
`(set-gpr ,n ,v)))(defmacro hi) source(defmacro hi () `(mips-hi cpu))(defmacro lo) source(defmacro lo () `(mips-lo cpu))(defmacro mips-load) source(defmacro mips-load (n a)
(if (= n 8) `(mem-read 8 ,a) `(bswap ,n (mem-read ,n ,a))))(defmacro mips-store) source(defmacro mips-store (n a v)
(if (= n 8) `(mem-write 8 ,a ,v) `(mem-write ,n ,a (bswap ,n (wrap ,n ,v)))))(defmacro vaddr) source(defmacro vaddr (base offset) `(wrap 32 (+ (gpr ,base) (sext 16 ,offset))))(defmacro branch-to) source(defmacro branch-to (target)
`(setf (mips-nnpc cpu) (wrap 32 ,target) (mips-jmp cpu) 1))(defmacro branch-target) source(defmacro branch-target (offset) `(+ (mips-pc cpu) 4 (ash (sext 16 ,offset) 2)))(defmacro nullify) source(defmacro nullify ()
`(setf (mips-npc cpu) (mips-nnpc cpu) (mips-nnpc cpu) (wrap 32 (+ (mips-nnpc cpu) 4))))(defmacro link-address) source(defmacro link-address () `(+ (mips-pc cpu) 8))(defmacro raise) source(defmacro raise (code) `(setf (mips-exc cpu) ,code))Made from xspe at b2fac33349db by tools/gen-xspe.py. xspe is GPL-3.0-or-later.