spu: ctl.lisp

SPU branches, hints, stop, halt and the other control insns.

0/1 a fixed bit, name a field,   a bit the decoder ignores

br source

313029282726252423222120191817161514131211109876543210
001100100i16rt
(defspu br :ri16 #x064 ((rel i16)) (branch-to (rel-target)))

bra source

313029282726252423222120191817161514131211109876543210
001100000i16rt
(defspu bra :ri16 #x060 ((abs i16)) (branch-to (abs-target)))

brsl source

313029282726252423222120191817161514131211109876543210
001100110i16rt
(defspu brsl :ri16 #x066 (rt (rel i16))
  (setf (gpr rt) (link-value))
  (branch-to (rel-target)))

brasl source

313029282726252423222120191817161514131211109876543210
001100010i16rt
(defspu brasl :ri16 #x062 (rt (abs i16))
  (setf (gpr rt) (link-value))
  (branch-to (abs-target)))

brz source

313029282726252423222120191817161514131211109876543210
001000000i16rt
(defspu brz :ri16 #x040 (rt (rel i16))
  (when (= (slot32 rt) 0) (branch-to (rel-target))))

brnz source

313029282726252423222120191817161514131211109876543210
001000010i16rt
(defspu brnz :ri16 #x042 (rt (rel i16))
  (when (/= (slot32 rt) 0) (branch-to (rel-target))))

brhz source

313029282726252423222120191817161514131211109876543210
001000100i16rt
(defspu brhz :ri16 #x044 (rt (rel i16))
  (when (= (lane 16 (gpr rt) 1) 0) (branch-to (rel-target))))

brhnz source

313029282726252423222120191817161514131211109876543210
001000110i16rt
(defspu brhnz :ri16 #x046 (rt (rel i16))
  (when (/= (lane 16 (gpr rt) 1) 0) (branch-to (rel-target))))

bi source

313029282726252423222120191817161514131211109876543210
00110101000rbrart
(defspu bi :rr #x1a8 (ra) (branch-to (slot32 ra)))

bisl source

313029282726252423222120191817161514131211109876543210
00110101001rbrart
(defspu bisl :rr #x1a9 (rt ra)
  (let ((target (slot32 ra)))
    (setf (gpr rt) (link-value))
    (branch-to target)))

iret source

313029282726252423222120191817161514131211109876543210
00110101010rbrart
(defspu iret :rr #x1aa () (branch-to (spu-srr0 cpu)))

bisled source

branch indirect and set link if an (unmasked) event is pending
313029282726252423222120191817161514131211109876543210
00110101011rbrart
(defspu bisled :rr #x1ab (rt ra)
  (let ((target (slot32 ra)))
    (setf (gpr rt) (link-value))
    (when (/= (logand (spu-event-stat cpu) (spu-event-mask cpu)) 0)
      (branch-to target))))

biz source

313029282726252423222120191817161514131211109876543210
00100101000rbrart
(defspu biz :rr #x128 (rt ra)
  (when (= (slot32 rt) 0) (branch-to (slot32 ra))))

binz source

313029282726252423222120191817161514131211109876543210
00100101001rbrart
(defspu binz :rr #x129 (rt ra)
  (when (/= (slot32 rt) 0) (branch-to (slot32 ra))))

bihz source

313029282726252423222120191817161514131211109876543210
00100101010rbrart
(defspu bihz :rr #x12a (rt ra)
  (when (= (lane 16 (gpr rt) 1) 0) (branch-to (slot32 ra))))

bihnz source

313029282726252423222120191817161514131211109876543210
00100101011rbrart
(defspu bihnz :rr #x12b (rt ra)
  (when (/= (lane 16 (gpr rt) 1) 0) (branch-to (slot32 ra))))

hbr source

313029282726252423222120191817161514131211109876543210
00110101100rbrart
(defspu hbr :rr #x1ac (rb ra) nil)

hbra source

313029282726252423222120191817161514131211109876543210
0001000i18rt
(defspu hbra :ri18 #x08 (rt i18) nil)

hbrr source

313029282726252423222120191817161514131211109876543210
0001001i18rt
(defspu hbrr :ri18 #x09 (rt i18) nil)

stop source

stop code

313029282726252423222120191817161514131211109876543210
00000000000code
(definsn spu stop "00000000000 ------- code:14"
  (:asm "stop" code)
  (spu-stop cpu code))

stopd source

stop and signal with dependencies: the debugger stop, code 0x3FFF
313029282726252423222120191817161514131211109876543210
00101000000rbrart
(defspu stopd :rr #x140 (rt ra rb)
  (spu-stop cpu #x3FFF))

heq source

313029282726252423222120191817161514131211109876543210
01111011000rbrart
(defspu heq :rr #x3d8 (ra rb)
  (when (= (slot32 ra) (slot32 rb)) (spu-halt cpu)))

hgt source

313029282726252423222120191817161514131211109876543210
01001011000rbrart
(defspu hgt :rr #x258 (ra rb)
  (when (> (sext 32 (slot32 ra)) (sext 32 (slot32 rb))) (spu-halt cpu)))

hlgt source

313029282726252423222120191817161514131211109876543210
01011011000rbrart
(defspu hlgt :rr #x2d8 (ra rb)
  (when (> (slot32 ra) (slot32 rb)) (spu-halt cpu)))

heqi source

313029282726252423222120191817161514131211109876543210
01111111i10rart
(defspu heqi :ri10 #x7f (ra i10)
  (when (= (slot32 ra) (wrap 32 (sext 10 i10))) (spu-halt cpu)))

hgti source

313029282726252423222120191817161514131211109876543210
01001111i10rart
(defspu hgti :ri10 #x4f (ra i10)
  (when (> (sext 32 (slot32 ra)) (sext 10 i10)) (spu-halt cpu)))

hlgti source

313029282726252423222120191817161514131211109876543210
01011111i10rart
(defspu hlgti :ri10 #x5f (ra i10)
  (when (> (slot32 ra) (wrap 32 (sext 10 i10))) (spu-halt cpu)))

lnop source

lnop

313029282726252423222120191817161514131211109876543210
00000000001
(definsn spu lnop "00000000001 ---------------------" (:asm "lnop") nil)

nop source

313029282726252423222120191817161514131211109876543210
01000000001rbrart
(defspu nop :rr #x201 () nil)

sync source

313029282726252423222120191817161514131211109876543210
00000000010rbrart
(defspu sync :rr #x002 () nil)

dsync source

313029282726252423222120191817161514131211109876543210
00000000011rbrart
(defspu dsync :rr #x003 () nil)

mfspr source

the SPU has no readable SPRs in this model: mfspr reads 0, mtspr is ignored
313029282726252423222120191817161514131211109876543210
00000001100rbrart
(defspu mfspr :rr #x00c (rt ra) (setf (gpr rt) 0))

mtspr source

313029282726252423222120191817161514131211109876543210
00100001100rbrart
(defspu mtspr :rr #x10c (ra rt) nil)

Other definitions

(defconstant +spu-bmask+) source
(defconstant +spu-bmask+ #x3FFFC)
(defmacro branch-to) source
(defmacro branch-to (addr) `(setf (spu-npc cpu) (logand ,addr +spu-bmask+)))
(defmacro rel-target) source
(defmacro rel-target () `(+ (spu-pc cpu) (ash (sext 16 i16) 2)))
(defmacro abs-target) source
(defmacro abs-target () `(ash (sext 16 i16) 2))
(defmacro link-value) source
(defmacro link-value () `(pref32 (logand (+ (spu-pc cpu) 4) +spu-lslr+)))
(defun spu-stop) source
(defun spu-stop (cpu code)
  (declare (type spu cpu))
  (setf (spu-stop-code cpu) code
        (spu-status cpu) (logior (logandc2 (spu-status cpu) +spu-running+) +spu-stopped+))
  nil)
(defun spu-halt) source
(defun spu-halt (cpu)
  (declare (type spu cpu))
  (setf (spu-status cpu) (logior (logandc2 (spu-status cpu) +spu-running+) +spu-halted+))
  nil)

Made from xspe at b2fac33349db by tools/gen-xspe.py. xspe is GPL-3.0-or-later.