Skip to content

Commit

Permalink
Move INSN_FIELD sanitation to appropriate place
Browse files Browse the repository at this point in the history
The global search-and-replace is a bit worrisome.
  • Loading branch information
aswaterman committed Sep 30, 2024
1 parent c77c68c commit 191123c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 191123c

Please sign in to comment.