aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xparse.py38
1 files changed, 33 insertions, 5 deletions
diff --git a/parse.py b/parse.py
index c389eb8..2cf1e7e 100755
--- a/parse.py
+++ b/parse.py
@@ -133,6 +133,16 @@ def process_enc_line(line, ext):
return (name, single_dict)
+def same_base_ext (ext_name, ext_name_list):
+ type1 = ext_name.split("_")[0]
+ for ext_name1 in ext_name_list:
+ type2 = ext_name1.split("_")[0]
+ # "rv" mean insn for rv32 and rv64
+ if (type1 == type2 or
+ (type2 == "rv" and (type1 == "rv32" or type1 == "rv64")) or
+ (type1 == "rv" and (type2 == "rv32" or type2 == "rv64"))):
+ return True
+ return False
def create_inst_dict(file_filter, include_pseudo=False, include_pseudo_ops=[]):
'''
@@ -205,20 +215,38 @@ def create_inst_dict(file_filter, include_pseudo=False, include_pseudo_ops=[]):
# call process_enc_line to get the data about the current
# instruction
(name, single_dict) = process_enc_line(line, f)
+ ext_name = f.split("/")[-1]
# if an instruction has already been added to the filtered
# instruction dictionary throw an error saying the given
# instruction is already imported and raise SystemExit
if name in instr_dict:
var = instr_dict[name]["extension"]
- if instr_dict[name]['encoding'] != single_dict['encoding']:
+ if same_base_ext(ext_name, var):
+ # disable same names on the same base extensions
err_msg = f'instruction : {name} from '
- err_msg += f'{f.split("/")[-1]} is already '
- err_msg += f'added from {var} but each have different encodings for the same instruction'
+ err_msg += f'{ext_name} is already '
+ err_msg += f'added from {var} in same base extensions'
logging.error(err_msg)
raise SystemExit(1)
- instr_dict[name]['extension'].append(single_dict['extension'])
-
+ elif instr_dict[name]['encoding'] != single_dict['encoding']:
+ # disable same names with different encodings on different base extensions
+ err_msg = f'instruction : {name} from '
+ err_msg += f'{ext_name} is already '
+ err_msg += f'added from {var} but each have different encodings in different base extensions'
+ logging.error(err_msg)
+ raise SystemExit(1)
+ instr_dict[name]['extension'].extend(single_dict['extension'])
+ else:
+ for key in instr_dict:
+ item = instr_dict[key]
+ if item["encoding"] == single_dict['encoding'] and same_base_ext(ext_name, item["extension"]):
+ # disable different names with same encodings on the same base extensions
+ err_msg = f'instruction : {name} from '
+ err_msg += f'{ext_name} has the same encoding with instruction {key} '
+ err_msg += f'added from {item["extension"]} in same base extensions'
+ logging.error(err_msg)
+ raise SystemExit(1)
# update the final dict with the instruction
instr_dict[name] = single_dict