continue
opcode = opcode[3:] # strip leading "sv."
- # start working on decoding the svp64 op: sv.baseop/vec2.mode
- opcode = opcode.split("/") # split at "/"
- v30b_op = opcode[0] # first is the v3.0B
- if len(opcode) == 1:
- opmodes = [] # no sv modes
- else:
- opmodes = opcode[1].split(".") # second splits by dots
-
+ # start working on decoding the svp64 op: sv.basev30Bop/vec2/mode
+ opmodes = opcode.split("/") # split at "/"
+ v30b_op = opmodes.pop(0) # first is the v3.0B
# check instruction ends with dot
rc_mode = v30b_op.endswith('.')
if rc_mode:
# okaaay now we identify the field value (opcode N,N,N) with
# the pseudo-code info (opcode RT, RA, RB)
+ assert len(fields) == len(v30b_regs), \
+ "length of fields %s must match insn `%s`" % \
+ (str(v30b_regs), insn)
opregfields = zip(fields, v30b_regs) # err that was easy
# now for each of those find its place in the EXTRA encoding
elif encmode == 'svm': # sub-vector mode
mapreduce_svm = True
+ # sanity-check that 2Pred mask is same mode
+ if has_pmask and has_smask:
+ assert smmode == pmmode, \
+ "predicate masks %s and %s must be same reg type" % \
+ (pme, sme)
+
+ # sanity-check that twin-predication mask only specified in 2P mode
+ if ptype == '1P':
+ assert has_smask == False, \
+ "source-mask can only be specified on Twin-predicate ops"
+
# construct the mode field, doing sanity-checking along the way
if mapreduce_svm:
assert sv_mode == 0b00, "sub-vector mode in mapreduce only"
assert subvl != 0, "sub-vector mode not possible on SUBVL=1"
+ if src_zero:
+ assert has_smask, "src zeroing requires a source predicate"
+ if dst_zero:
+ assert has_pmask, "dest zeroing requires a dest predicate"
+
# "normal" mode
if sv_mode is None:
mode |= (src_zero << 3) | (dst_zero << 4) # predicate zeroing
+ sv_mode = 0b00
# "mapreduce" modes
elif sv_mode == 0b00:
# "failfirst" modes
elif sv_mode == 0b01:
assert dst_zero == 0, "dest-zero not allowed in failfirst mode"
- mode |= 0b01 # sets failfirst
if failfirst == 'RC1':
mode |= (0b1<<4) # sets RC1 mode
mode |= (src_zero << 3) # predicate src-zeroing
# "saturation" modes
elif sv_mode == 0b10:
- mode |= 0b10 # sets saturation mode
mode |= (src_zero << 3) | (dst_zero << 4) # predicate zeroing
mode |= (saturation<<2) # sets signed/unsigned saturation
- # sanity-check that 2Pred mask is same mode
- if has_pmask and has_smask:
- assert smmode == pmmode, \
- "predicate masks %s and %s must be same reg type" % \
- (pme, sme)
+ # "predicate-result" modes. err... code-duplication from ffirst
+ elif sv_mode == 0b11:
+ assert dst_zero == 0, "dest-zero not allowed in predresult mode"
+ if predresult == 'RC1':
+ mode |= (0b1<<4) # sets RC1 mode
+ mode |= (src_zero << 3) # predicate src-zeroing
+ assert rc_mode==False, "pr-mode RC1 only possible when Rc=0"
+ elif predresult == '~RC1':
+ mode |= (0b1<<4) # sets RC1 mode...
+ mode |= (src_zero << 3) # predicate src-zeroing
+ mode |= (0b1<<2) # ... with inversion
+ assert rc_mode==False, "pr-mode RC1 only possible when Rc=0"
+ else:
+ assert src_zero == 0, "src-zero not allowed in pr-mode BO"
+ assert rc_mode, "pr-mode BO only possible when Rc=1"
+ mode |= (predresult << 2) # set BO
- # sanity-check that twin-predication mask only specified in 2P mode
- if ptype == '1P':
- assert has_smask == False, \
- "source-mask can only be specified on Twin-predicate ops"
+ # whewww.... modes all done :)
+ # now put into svp64_rm
+ mode |= sv_mode
+ svp64_rm |= (mode << 19) # mode: bits 19-23
# put in predicate masks into svp64_rm
if ptype == '2P':
'sv.cmpi 5, 1, 3, 2',
'sv.setb 5, 31',
'sv.isel 64.v, 3, 2, 65.v',
- 'sv.setb/m=r3.sm=1<<r3 5, 31',
+ 'sv.setb/m=r3/sm=1<<r3 5, 31',
'sv.setb/vec2 5, 31',
- 'sv.setb/sw=8.ew=16 5, 31',
+ 'sv.setb/sw=8/ew=16 5, 31',
'sv.extsw./ff=eq 5, 31',
- 'sv.extsw./satu.sz.dz 5, 31',
+ 'sv.extsw./satu/sz/dz/sm=r3/m=r3 5, 31',
+ 'sv.extsw./pr=eq 5.v, 31',
])
csvs = SVP64RM()