diff options
author | Milosz Moscicki <Milosz.Moscicki@imgtec.com> | 2024-07-31 10:27:53 +0100 |
---|---|---|
committer | Milosz Moscicki <Milosz.Moscicki@imgtec.com> | 2024-07-31 10:27:53 +0100 |
commit | 9b1f211298d19d9c252b63f8f854437a155afcdd (patch) | |
tree | 9d94e1b79d0191fa6a4fd10ce174be53e0002ec5 | |
parent | 07b21cc5143a15959eda12e30aa40cea0971efe0 (diff) | |
download | riscv-opcodes-9b1f211298d19d9c252b63f8f854437a155afcdd.zip riscv-opcodes-9b1f211298d19d9c252b63f8f854437a155afcdd.tar.gz riscv-opcodes-9b1f211298d19d9c252b63f8f854437a155afcdd.tar.bz2 |
Expand nf fields in instr_dict.yaml
parse.py has been edited to expand nf field for segmented vector load
store instructions. For backwards compatibility this only applies to
instr_dict.yaml.
-rwxr-xr-x | parse.py | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -1,6 +1,7 @@ #!/usr/bin/env python3 from constants import * +import copy import re import glob import os @@ -164,6 +165,37 @@ def extension_overlap_allowed(x, y): def instruction_overlap_allowed(x, y): return overlap_allowed(overlapping_instructions, x, y) +def add_segmented_vls_insn(instr_dict): + updated_dict = {} + for k, v in instr_dict.items(): + if "nf" in v['variable_fields']: + for new_key, new_value in expand_nf_field(k,v): + updated_dict[new_key] = new_value + else: + updated_dict[k] = v + return updated_dict + +def expand_nf_field(name, single_dict): + if "nf" not in single_dict['variable_fields']: + logging.error(f"Cannot expand nf field for instruction {name}") + raise SystemExit(1) + + # nf no longer a variable field + single_dict['variable_fields'].remove("nf") + # include nf in mask + single_dict['mask'] = hex(int(single_dict['mask'],16) | 0b111 << 29) + + name_expand_index = name.find('e') + expanded_instructions = [] + for nf in range(0,8): + new_single_dict = copy.deepcopy(single_dict) + new_single_dict['match'] = hex(int(single_dict['match'],16) | nf << 29) + new_single_dict['encoding'] = format(nf, '03b') + single_dict['encoding'][3:] + new_name = name if nf == 0 else name[:name_expand_index] + "seg" + str(nf+1) + name[name_expand_index:] + expanded_instructions.append((new_name, new_single_dict)) + return expanded_instructions + + def create_inst_dict(file_filter, include_pseudo=False, include_pseudo_ops=[]): ''' This function return a dictionary containing all instructions associated @@ -1008,8 +1040,9 @@ if __name__ == "__main__": include_pseudo = True instr_dict = create_inst_dict(extensions, include_pseudo) + with open('instr_dict.yaml', 'w') as outfile: - yaml.dump(instr_dict, outfile, default_flow_style=False) + yaml.dump(add_segmented_vls_insn(instr_dict), outfile, default_flow_style=False) instr_dict = collections.OrderedDict(sorted(instr_dict.items())) if '-c' in sys.argv[1:]: |