aboutsummaryrefslogtreecommitdiff
path: root/parse.py
diff options
context:
space:
mode:
Diffstat (limited to 'parse.py')
-rwxr-xr-xparse.py36
1 files changed, 25 insertions, 11 deletions
diff --git a/parse.py b/parse.py
index 47976d7..fb0c2e7 100755
--- a/parse.py
+++ b/parse.py
@@ -113,16 +113,25 @@ def process_enc_line(line, ext):
encoding_args = encoding.copy()
for a in args:
if a not in arg_lut:
- logging.error(f' Found variable {a} in instruction {name} whose mapping in arg_lut does not exist')
- raise SystemExit(1)
- else:
- (msb, lsb) = arg_lut[a]
- for ind in range(lsb, msb + 1):
- # overlapping bits
- if encoding_args[31 - ind] != '-':
- logging.error(f' Found variable {a} in instruction {name} overlapping {encoding_args[31 - ind]} variable in bit {ind}')
+ if len(parts := a.split('=')) == 2:
+ existing_arg, new_arg = parts
+ if existing_arg in arg_lut:
+ arg_lut[a] = arg_lut[existing_arg]
+
+ else:
+ logging.error(f' Found field {existing_arg} in variable {a} in instruction {name} whose mapping in arg_lut does not exist')
raise SystemExit(1)
- encoding_args[31 - ind] = a
+ else:
+ logging.error(f' Found variable {a} in instruction {name} whose mapping in arg_lut does not exist')
+ raise SystemExit(1)
+ (msb, lsb) = arg_lut[a]
+ for ind in range(lsb, msb + 1):
+ # overlapping bits
+ if encoding_args[31 - ind] != '-':
+ logging.error(f' Found variable {a} in instruction {name} overlapping {encoding_args[31 - ind]} variable in bit {ind}')
+ raise SystemExit(1)
+ encoding_args[31 - ind] = a
+
# update the fields of the instruction as a dict and return back along with
# the name of the instruction
@@ -369,11 +378,16 @@ def create_inst_dict(file_filter, include_pseudo=False, include_pseudo_ops=[]):
instr_dict[name] = single_dict
logging.debug(f' including pseudo_ops:{name}')
else:
+ if(single_dict['match'] != instr_dict[name]['match']):
+ instr_dict[name + '_pseudo'] = single_dict
+
# if a pseudo instruction has already been added to the filtered
# instruction dictionary but the extension is not in the current
# list, add it
- ext_name = single_dict['extension']
- if ext_name not in instr_dict[name]['extension']:
+ else:
+ ext_name = single_dict['extension']
+
+ if (ext_name not in instr_dict[name]['extension']) & (name + '_pseudo' not in instr_dict):
instr_dict[name]['extension'].extend(ext_name)
else:
logging.debug(f' Skipping pseudo_op {pseudo_inst} since original instruction {orig_inst} already selected in list')