# [DRAFT] Double-width Shift Left Doubleword
-Z23-Form
+VA2-Form
-* dsld RT,RA,RB,sm (Rc=0)
-* dsld. RT,RA,RB,sm (Rc=1)
+* dsld RT,RA,RB,RC (Rc=0)
+* dsld. RT,RA,RB,RC (Rc=1)
Pseudo-code:
- switch(sm)
- case(0):
- hi <- (RT)
- lo <- (RA)
- sh <- (RB)
- case(1):
- hi <- (RA)
- lo <- (RT)
- sh <- (RB)
- case(2):
- hi <- (RA)
- lo <- (RB)
- sh <- (RT)
- default:
- hi <- [0] * 64
- lo <- (RA)
- sh <- (RB)
+ hi <- (RC)
+ lo <- (RA)
+ sh <- (RB)
n <- sh[58:63]
mask[0:63] <- MASK(n, 63)
v[0:63] <- (hi & mask) | (lo & ¬mask)
# [DRAFT] Double-width Shift Right Doubleword
-Z23-Form
+VA2-Form
-* dsrd RT,RA,RB,sm (Rc=0)
-* dsrd. RT,RA,RB,sm (Rc=1)
+* dsrd RT,RA,RB,RC (Rc=0)
+* dsrd. RT,RA,RB,RC (Rc=1)
Pseudo-code:
- switch(sm)
- case(0):
- hi <- (RT)
- lo <- (RA)
- sh <- (RB)
- case(1):
- hi <- (RA)
- lo <- (RT)
- sh <- (RB)
- case(2):
- hi <- (RA)
- lo <- (RB)
- sh <- (RT)
- default:
- hi <- (RA)
- lo <- [0] * 64
- sh <- (RB)
+ hi <- (RC)
+ lo <- (RA)
+ sh <- (RB)
n <- sh[58:63]
mask[0:63] <- MASK(0, 63 - n)
v[0:63] <- (hi & ¬mask) | (lo & mask)
sld,NORMAL,,1P,EXTRA3,NO,d:RA;d:CR0,s:RB,s:RS,0,0,RB,RS,RA,0,CR0,0
and,NORMAL,,1P,EXTRA3,NO,d:RA;d:CR0,s:RB,s:RS,0,RS,RB,0,RA,0,CR0,0
subf,NORMAL,,1P,EXTRA3,NO,d:RT;d:CR0,s:RA,s:RB,0,RA,RB,0,RT,0,CR0,0
-dsld,NORMAL,,1P,EXTRA3,NO,d:RT;d:CR0,s:RA,s:RB,0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AL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RT,RA,RB,RT,RT,0,CR0,0
absdacu,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RT,RA,RB,RT,RT,0,CR0,0
+dsld,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RC,RA,RB,RC,RT,0,CR0,0
+dsld,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RC,RA,RB,RC,RT,0,CR0,0
+dsrd,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RC,RA,RB,RC,RT,0,CR0,0
+dsrd,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RC,RA,RB,RC,RT,0,CR0,0
pcdec,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RC,RA,RB,RC,RT,0,CR0,0
ternlogi,NORMAL,,1P,EXTRA2,NO,d:RT;d:CR0,s:RA,s:RB,s:RT,RA,RB,RT,RT,0,CR0,0
ffmsubs,NORMAL,,1P,EXTRA2,NO,d:FRT;d:CR1,s:FRA,s:FRB,s:FRC,FRA,FRB,FRC,FRT,0,CR1,0
| PO | FRT | TE | FRB |RMC| XO |Rc |
| PO | FRTp| TE | FRBp |RMC| XO |Rc |
| PO | FRT | FRA | FRB |RMC| XO |Rc |
- | PO | RT | RA | RB |sm | XO |Rc |
| PO | RT | RA | RB |CY | XO |Rc |
| PO | FRTp| FRA | FRBp |RMC| XO |Rc |
| PO | FRTp| FRAp | FRBp |RMC| XO |Rc |
SCi (11:31)
SV Context Propagation immediate bitfield
Formats: SVC
- sm (21:22)
- Immediate field used for selecting operands (shift mode)
- Formats: Z23
SRb (11:14)
SV REMAP byte-reversal field.
Formats: SVC
0b1000110110,ALU,OP_NOP,NONE,NONE,NONE,NONE,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,1,tlbsync,X,,,
0b0000011110,ALU,OP_NOP,NONE,NONE,NONE,NONE,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,1,wait,X,,,
0b0100111100,LOGICAL,OP_XOR,RS,RB,NONE,RA,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC,0,0,xor,X,,,
-0b0000111001,SHIFT_ROT,OP_DSHL,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsld,Z23,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-0b0100111001,SHIFT_ROT,OP_DSHL,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsld,Z23,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-0b1000111001,SHIFT_ROT,OP_DSHL,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsld,Z23,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-0b1100111001,SHIFT_ROT,OP_DSHL,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsld,Z23,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-0b0010111001,SHIFT_ROT,OP_DSHR,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsrd,Z23,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-0b0110111001,SHIFT_ROT,OP_DSHR,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsrd,Z23,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-0b1010111001,SHIFT_ROT,OP_DSHR,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsrd,Z23,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-0b1110111001,SHIFT_ROT,OP_DSHR,RA,RB,NONE,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsrd,Z23,,1,unofficial until submitted and approved/renumbered by the opf isa wg
49,ALU,OP_MADDHDU,RA,RB,RC,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,maddhdu,VA,,,
50,ALU,OP_MADDEDU,RA,RB,RC,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,maddedu,VA,,1,unofficial until submitted and approved/renumbered by the opf isa wg
51,ALU,OP_MADDLD,RA,RB,RC,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,maddld,VA,,,
-52,ALU,OP_DIVMOD2DU,RA,RB,RC,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,divmod2du,VA,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+58,ALU,OP_DIVMOD2DU,RA,RB,RC,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,divmod2du,VA,,1,unofficial until submitted and approved/renumbered by the opf isa wg
56,ALU,OP_PCDEC,RA,RB,RC,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,1,0,ONE,0,0,pcdec,VA,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+52,SHIFT_ROT,OP_DSHL,RA,RB,RC,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsld,VA2,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+53,SHIFT_ROT,OP_DSHL,RA,RB,RC,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsld,VA2,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+54,SHIFT_ROT,OP_DSHR,RA,RB,RC,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsrd,VA2,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+55,SHIFT_ROT,OP_DSHR,RA,RB,RC,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,dsrd,VA2,,1,unofficial until submitted and approved/renumbered by the opf isa wg
with m.If((major == 4) & xo6.matches(
'111000', # pcdec
'110010', # maddedu
- '110100', # divmod2du
+ '111010', # divmod2du
)):
comb += self.implicit_rs.eq(1)
comb += self.extend_rc_maxvl.eq(1) # RS=RT+MAXVL or RS=RC
@_custom_insns(
_insn("maddedu", XO=50),
- _insn("divmod2du", XO=52),
+ _insn("divmod2du", XO=58),
_insn("pcdec.", XO=56),
)
def va_form(fields, XO):
@_custom_insns(
- _insn("dsld", XO=0b00111001, Rc=0),
- _insn("dsld.", XO=0b00111001, Rc=1),
- _insn("dsrd", XO=0b10111001, Rc=0),
- _insn("dsrd.", XO=0b10111001, Rc=1),
+ _insn("dsld", XO=26, Rc=0), # minor_4=52 (26<<1 | Rc=0)
+ _insn("dsld.", XO=26, Rc=1), # minor_4=53 (26<<1 | Rc=1)
+ _insn("dsrd", XO=27, Rc=0), # minor_4=54 (27<<1 | Rc=0)
+ _insn("dsrd.", XO=27, Rc=1), # minor_4=55 (27<<1 | Rc=1)
)
def dsld_dsrd(fields, XO, Rc):
# XXX WARNING THESE ARE NOT APPROVED BY OPF ISA WG
- # 1.6.27 Z23-FORM
- # |0 |6 |11 |15 |16 |21 |23 |31 |
- # | PO | RT | RA | RB |sm | XO |Rc |
- PO = 31
- (RT, RA, RB, sm) = fields
+ # 1.6.21.1 VA2-FORM
+ # |0 |6 |11 |16 |21 |26 |31|
+ # | PO | RT | RA | RB | RC | XO |Rc|
+ PO = 4
+ (RT, RA, RB, RC) = fields
return instruction(
(PO, 0, 5),
(RT, 6, 10),
(RA, 11, 15),
(RB, 16, 20),
- (sm, 21, 22),
- (XO, 23, 30),
+ (RC, 21, 25),
+ (XO, 26, 30),
(Rc, 31, 31),
)
'pcdec. 0,0,0,0',
]
lst = [
- "sv.cmp/ff=gt *0,*1,*2,0",
+ #"sv.cmp/ff=gt *0,*1,*2,0",
+ "dsld 5,4,5,3",
+
]
isa = SVP64Asm(lst, macros=macros)
log("list:\n", "\n\t".join(list(isa)))
]
self._do_tst(expected)
+ def test_29_dsld_dsrd(self):
+ expected = [
+ "dsld 5,4,5,3",
+ "dsrd 5,4,5,3",
+ "dsld. 5,4,5,3",
+ "dsrd. 5,4,5,3",
+ "sv.dsld *6,4,5,3",
+ "sv.dsrd *6,4,5,3",
+ "sv.dsld. *6,4,5,3",
+ "sv.dsrd. *6,4,5,3",
+ ]
+ self._do_tst(expected)
+
+ def test_30_divmod2du(self):
+ expected = [
+ "divmod2du 5,4,5,3",
+ ]
+ self._do_tst(expected)
+
if __name__ == "__main__":
unittest.main()
# FIXME: test more divmod2du special cases
def case_dsld0(self):
- prog = Program(list(SVP64Asm(["dsld 3,4,5,0"])), False)
+ prog = Program(list(SVP64Asm(["dsld 3,4,5,3"])), False)
for sh in _SHIFT_TEST_RANGE:
with self.subTest(sh=sh):
gprs = [0] * 32
self.add_case(prog, gprs, expected=e)
def case_dsld1(self):
- prog = Program(list(SVP64Asm(["dsld 3,4,5,1"])), False)
+ prog = Program(list(SVP64Asm(["dsld 3,3,5,4"])), False)
for sh in _SHIFT_TEST_RANGE:
with self.subTest(sh=sh):
gprs = [0] * 32
self.add_case(prog, gprs, expected=e)
def case_dsld2(self):
- prog = Program(list(SVP64Asm(["dsld 3,4,5,2"])), False)
+ prog = Program(list(SVP64Asm(["dsld 3,5,3,4"])), False)
for sh in _SHIFT_TEST_RANGE:
with self.subTest(sh=sh):
gprs = [0] * 32
e.intregs[3] = (v >> 64) % 2 ** 64
self.add_case(prog, gprs, expected=e)
- def case_dsld3(self):
- prog = Program(list(SVP64Asm(["dsld 3,4,5,3"])), False)
- for sh in _SHIFT_TEST_RANGE:
- with self.subTest(sh=sh):
- gprs = [0] * 32
- gprs[3] = 0x123456789ABCDEF
- gprs[4] = 0xFEDCBA9876543210
- gprs[5] = sh % 2 ** 64
- e = ExpectedState(pc=4, int_regs=gprs)
- v = gprs[4]
- v <<= sh % 64
- e.intregs[3] = (v >> 64) % 2 ** 64
- self.add_case(prog, gprs, expected=e)
-
def case_dsrd0(self):
- prog = Program(list(SVP64Asm(["dsrd 3,4,5,0"])), False)
+ prog = Program(list(SVP64Asm(["dsrd 3,4,5,3"])), False)
for sh in _SHIFT_TEST_RANGE:
with self.subTest(sh=sh):
gprs = [0] * 32
self.add_case(prog, gprs, expected=e)
def case_dsrd1(self):
- prog = Program(list(SVP64Asm(["dsrd 3,4,5,1"])), False)
+ prog = Program(list(SVP64Asm(["dsrd 3,3,5,4"])), False)
for sh in _SHIFT_TEST_RANGE:
with self.subTest(sh=sh):
gprs = [0] * 32
self.add_case(prog, gprs, expected=e)
def case_dsrd2(self):
- prog = Program(list(SVP64Asm(["dsrd 3,4,5,2"])), False)
+ prog = Program(list(SVP64Asm(["dsrd 3,5,3,4"])), False)
for sh in _SHIFT_TEST_RANGE:
with self.subTest(sh=sh):
gprs = [0] * 32