GP0 as an ISA: DEFGP0, the words each command takes, the executor.
(defisa gp0) source(defisa gp0 :width 32 :endian :little :state gpu
:doc "the PS1 GPU's GP0 commands (first word), [PSXSPX] \"GPU Command Summary\"")(defmacro defgp0) source(defmacro defgp0 (name encoding (&key (words 1)) &body body)
`(progn
(eval-when (:compile-toplevel :load-toplevel :execute)
(setq *gp0-words* (cons (cons ',name ',words) (remove ',name *gp0-words* :key #'car))))
(definsn gp0 ,name ,encoding
,@(loop for b in body while (and (consp b) (keywordp (car b))) collect b)
(let ((gfx (gpu-gfx cpu)))
(declare (ignorable gfx))
,@(loop for b on body unless (and (consp (car b)) (keywordp (caar b))) return b)))))(defmacro word) source(defmacro word (i) `(aref (gpu-fifo cpu) ,i))(defmacro define-gp0-words) source(defmacro define-gp0-words ()
`(defun gp0-words (insn)
"the number of words of the GP0 command whose first word is INSN"
(declare (type u32 insn))
,(decode-tree (isa-insn-list 'gp0) 0
(lambda (i)
(let ((form (cdr (assoc (insn-name i) *gp0-words*))))
`(let ,(mapcar (lambda (f) `(,(first f) (ldb (byte ,(third f) ,(second f)) insn)))
(insn-fields i))
(declare (ignorable ,@(mapcar #'first (insn-fields i))))
,form)))
1)))(defmacro define-gp0-names) source(defmacro define-gp0-names ()
`(defun gp0-command-name (insn)
"the index of INSN's command in definition order, or -1 (a NOP)"
(declare (type u32 insn))
,(decode-tree (isa-insn-list 'gp0) 0 (lambda (i) (insn-index i)) -1)))(defun gp0-nop) source(defun gp0-nop (cpu insn)
(declare (type gpu cpu) (type u32 insn) (ignore cpu insn))
nil)Made from xspe at b2fac33349db by tools/gen-xspe.py. xspe is GPL-3.0-or-later.