From 191123ceb1e403a31d0409b95ce877cc39e71720 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 30 Sep 2024 13:39:10 -0700 Subject: [PATCH] Move INSN_FIELD sanitation to appropriate place The global search-and-replace is a bit worrisome. --- parse.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/parse.py b/parse.py index bf60e682..0038d970 100755 --- a/parse.py +++ b/parse.py @@ -945,10 +945,11 @@ def make_c(instr_dict): arg_str = '' for name, rng in arg_lut.items(): + sanitized_name = name.replace(' ', '_').replace('=', '_eq_') begin = rng[1] end = rng[0] mask = ((1 << (end - begin + 1)) - 1) << begin - arg_str += f"#define INSN_FIELD_{name.upper().replace(' ', '_')} {hex(mask)}\n" + arg_str += f"#define INSN_FIELD_{sanitized_name.upper()} {hex(mask)}\n" with open(f'{os.path.dirname(__file__)}/encoding.h', 'r') as file: enc_header = file.read() @@ -981,9 +982,6 @@ def make_c(instr_dict): {declare_cause_str}#endif ''' - # Replace '=rs' with 'equrs' in the output - output_str = output_str.replace('=RS', '_EQ_RS') - # Write the modified output to the file with open('encoding.out.h', 'w') as enc_file: enc_file.write(output_str)