continue # skip pseudo-alias lxxxbr
if insn_name in ['mcrxr', 'mcrxrx', 'darn']:
continue
- if insn_name in ['bctar', 'bcctr']:
+ if insn_name in ['bctar', 'bcctr']: # for now. TODO
continue
if 'rfid' in insn_name:
continue
- if 'addpcis' in insn_name: # skip for now
- continue
- if insn_name in ['setvl', ]: # SVP64 opcodes
+ if 'addpcis' in insn_name: # skip for now
continue
+ # sv.bc is being classified as 2P-2S-1D by mistake due to SPRs
+ if insn_name.startswith('bc'):
+ # whoops: remove out reg (SPRs CTR etc)
+ row['in1'] = 'NONE'
+ row['in2'] = 'NONE'
+ row['in3'] = 'NONE'
+ row['out'] = 'NONE'
+
insns[(insn_name, condition)] = row # accumulate csv data
insn_to_csv[insn_name] = csvname_ # CSV file name by instruction
dkey = create_key(row)
primarykeys.sort()
return (csvs, csvs_svp64, primarykeys, bykey, insn_to_csv, insns,
- dictkeys, immediates)
+ dictkeys, immediates)
def regs_profile(insn, res):
# if regs == ['RA', '', '', 'RT', '', '']:
# is in the order in1 in2 in3 out1 out2 Rc=1
- #********
+ # ********
# start with LD/ST
if value == 'LDSTRM-2P-1S1D':
elif value == 'LDSTRM-2P-3S':
res['Etype'] = 'EXTRA2' # RM EXTRA2 type
if 'cx' in insn_name:
- res['0'] = "%s;%s" % (sRS, dCR) # RS: Rsrc1_EXTRA2 CR0: dest
+ res['0'] = "%s;%s" % (sRS, dCR) # RS: Rsrc1_EXTRA2 CR0: dest
else:
res['0'] = sRS # RS: Rsrc1_EXTRA2
res['1'] = 's:RA' # RA: Rsrc2_EXTRA2
res['2'] = 's:RB' # RA: Rsrc3_EXTRA2
- #**********
+ # **********
# now begins,arithmetic
elif value == 'RM-2P-1S1D':
elif regs == ['', 'FRB', '', 'FRT', '', 'CR1']:
res['0'] = 'd:FRT;d:CR1' # FRT,CR1: Rdest1_EXTRA3
res['1'] = 's:FRB' # FRB: Rsrc1_EXTRA3
- elif insn_name.startswith('bc'):
- res['0'] = 'd:BI' # BI: Rdest1_EXTRA3
- res['1'] = 's:BI' # BI: Rsrc1_EXTRA3
elif insn_name == 'fishmv':
- # an overwrite ibstruction
+ # an overwrite instruction
res['0'] = 'd:FRS' # FRS: Rdest1_EXTRA3
res['1'] = 's:FRS' # FRS: Rsrc1_EXTRA3
+ elif insn_name == 'setvl':
+ res['0'] = 'd:RT' # RT: Rdest1_EXTRA3
+ res['1'] = 's:RA' # RS: Rsrc1_EXTRA3
else:
res['0'] = 'TODO'
print("regs TODO", insn_name, regs)
res['0'] = 'd:FRT;d:CR1' # FRT,CR1: Rdest1_EXTRA3
res['1'] = 's:FRA' # FRA: Rsrc1_EXTRA3
res['2'] = 's:FRB' # FRB: Rsrc1_EXTRA3
+ elif regs == ['FRA', 'RB', '', 'FRT', '', 'CR1']:
+ res['0'] = 'd:FRT;d:CR1' # FRT,CR1: Rdest1_EXTRA3
+ res['1'] = 's:FRA' # FRA: Rsrc1_EXTRA3
+ res['2'] = 's:RB' # RB: Rsrc1_EXTRA3
elif name == '2R-1W' or insn_name == 'cmpb': # cmpb
if insn_name in ['bpermd', 'cmpb']:
res['0'] = 'd:RA' # RA: Rdest1_EXTRA3
elif value == 'RM-1P-3S1D':
res['Etype'] = 'EXTRA2' # RM EXTRA2 type
- if regs == ['RA', 'RB', 'RT', 'RT', '', 'CR0']:
+ if regs == ['RA', 'RB', 'RC', 'RT', '', '']: # madd*
+ res['0'] = 'd:RT' # RT,CR0: Rdest1_EXTRA2
+ res['1'] = 's:RA' # RA: Rsrc1_EXTRA2
+ res['2'] = 's:RB' # RT: Rsrc2_EXTRA2
+ res['3'] = 's:RC' # RT: Rsrc3_EXTRA2
+ elif regs == ['RA', 'RB', 'RC', 'RT', '', 'CR0']: # pcdec
+ res['0'] = 'd:RT;d:CR0' # RT,CR0: Rdest1_EXTRA2
+ res['1'] = 's:RA' # RA: Rsrc1_EXTRA2
+ res['2'] = 's:RB' # RT: Rsrc2_EXTRA2
+ res['3'] = 's:RC' # RT: Rsrc3_EXTRA2
+ elif regs == ['RA', 'RB', 'RT', 'RT', '', 'CR0']: # overwrite 3-in
res['0'] = 'd:RT;d:CR0' # RT,CR0: Rdest1_EXTRA2
res['1'] = 's:RA' # RA: Rsrc1_EXTRA2
res['2'] = 's:RB' # RT: Rsrc2_EXTRA2
res['1'] = 's:RA' # RA: Rsrc1_EXTRA2
res['2'] = 's:RB' # RT: Rsrc2_EXTRA2
res['3'] = 's:BC' # BC: Rsrc3_EXTRA2
- else:
+ else: # fmadd*
res['0'] = 'd:FRT;d:CR1' # FRT, CR1: Rdest1_EXTRA2
res['1'] = 's:FRA' # FRA: Rsrc1_EXTRA2
res['2'] = 's:FRB' # FRB: Rsrc2_EXTRA2
if insn_name == 'fmvis':
res['0'] = 'd:FRS' # FRS: Rdest1_EXTRA3
+ # HACK! thos should be RM-1P-1S butvthere is a bug with sv.bc
+ elif value == 'RM-2P-1S':
+ res['Etype'] = 'EXTRA3' # RM EXTRA3 type
+ if insn_name.startswith('bc'):
+ res['0'] = 's:BI' # BI: Rsrc1_EXTRA3
+
def process_csvs(format):
print('')
(csvs, csvs_svp64, primarykeys, bykey, insn_to_csv, insns,
- dictkeys, immediates) = read_csvs()
+ dictkeys, immediates) = read_csvs()
# mapping to old SVPrefix "Forms"
mapsto = {'3R-1W-CRo': 'RM-1P-3S1D',
+ '3R-1W': 'RM-1P-3S1D',
'2R-1W-CRio': 'RM-1P-2S1D',
'2R-1W-CRi': 'RM-1P-3S1D',
'2R-1W-CRo': 'RM-1P-2S1D',
'1W-CRi': 'RM-2P-1S1D',
'CRio': 'RM-2P-1S1D',
'CR=2R1W': 'RM-1P-2S1D',
- 'CRi': 'non-SV',
+ 'CRi': 'RM-2P-1S', # HACK, bc here, it should be 1P
'imm': 'non-SV',
'': 'non-SV',
'LDST-2R-imm': 'LDSTRM-2P-2S',
# create a CSV file, per category, with SV "augmentation" info
# XXX note: 'out2' not added here, needs to be added to CSV files
# KEEP TRACK OF THESE https://bugs.libre-soc.org/show_bug.cgi?id=619
- csvcols = ['insn', 'mode', 'CONDITIONS', 'Ptype', 'Etype',]
+ csvcols = ['insn', 'mode', 'CONDITIONS', 'Ptype', 'Etype', 'SM']
csvcols += ['0', '1', '2', '3']
csvcols += ['in1', 'in2', 'in3', 'out', 'CR in', 'CR out'] # temporary
for key in primarykeys:
# set the SVP64 mode to NORMAL, LDST, BRANCH or CR
crops = ['mfcr', 'mfocrf', 'mtcrf', 'mtocrf',
- ]
+ ]
mode = 'NORMAL'
if value.startswith('LDST'):
- if 'x' in insn_name: # Indexed detection
+ if 'x' in insn_name: # Indexed detection
mode = 'LDST_IDX'
else:
mode = 'LDST_IMM'
elif insn_name.startswith('bc'):
mode = 'BRANCH'
- elif insn_name.startswith('cr') or insn_name in crops:
+ elif insn_name.startswith('cmp') or insn_name.startswith('cr') or insn_name in crops:
mode = 'CROP'
res['mode'] = mode
#print("regs", insn_name, regs)
extra_classifier(insn_name, value, name, res, regs)
+ # source-mask is hard to detect, it's part of RM-nn-nn.
+ # to make disassembler easier, create a yes/no decision here
+ # see https://libre-soc.org/openpower/sv/svp64/#extra_remap
+ # MASK_SRC
+ vstripped = value.replace("LDST", "")
+ if vstripped in ['RM-2P-1S1D', 'RM-2P-2S',
+ 'RM-2P-2S1D', 'RM-2P-1S2D', 'RM-2P-3S',
+ ]:
+ res['SM'] = 'EN'
+ else:
+ res['SM'] = 'NO'
# add to svp64 csvs
# for k in ['in1', 'in2', 'in3', 'out', 'CR in', 'CR out']:
# del res[k]
if value == '-':
continue
from time import sleep
- print ("WARNING, filename '-' should NOT exist. instrs missing")
- print ("TODO: fix this (and put in the bugreport number here)")
+ print("WARNING, filename '-' should NOT exist. instrs missing")
+ print("TODO: fix this (and put in the bugreport number here)")
sleep(2)
# print out svp64 tables by category
print("## %s" % value)
for fname in glob_valid_csvs(pth):
svp64_csv = svt.get_svp64_csv(fname)
- csvcols = ['insn', 'mode', 'Ptype', 'Etype']
+ csvcols = ['insn', 'mode', 'Ptype', 'Etype', 'SM']
csvcols += ['in1', 'in2', 'in3', 'out', 'out2', 'CR in', 'CR out']
if format is Format.VHDL: