diff options
author | Pavel I. Kryukov <pavel.igorevich.kryukov@gmail.com> | 2022-05-11 02:59:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-10 16:59:54 -0700 |
commit | 9b9f61e34431f9924a0ce57b6cb8c61c63c9d97d (patch) | |
tree | 612ed04fa83e3fa79b40c0e442aecc2e10b293f9 /parse.py | |
parent | 833ba82b5df000ad6bc2a2cbca367d889272f88a (diff) | |
download | riscv-opcodes-9b9f61e34431f9924a0ce57b6cb8c61c63c9d97d.zip riscv-opcodes-9b9f61e34431f9924a0ce57b6cb8c61c63c9d97d.tar.gz riscv-opcodes-9b9f61e34431f9924a0ce57b6cb8c61c63c9d97d.tar.bz2 |
Dump masks to C output (#113)
* Dump masks to C output
* Use `INSN_FIELD_` for masks
Diffstat (limited to 'parse.py')
-rwxr-xr-x | parse.py | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -813,6 +813,13 @@ def make_c(instr_dict): causes_str += f"#define CAUSE_{name.upper().replace(' ', '_')} {hex(num)}\n" declare_cause_str += f"DECLARE_CAUSE(\"{name}\", CAUSE_{name.upper().replace(' ','_')})\n" + arg_str = '' + for name, rng in arg_lut.items(): + 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" + with open('encoding.h', 'r') as file: enc_header = file.read() @@ -829,7 +836,8 @@ def make_c(instr_dict): #define RISCV_ENCODING_H {mask_match_str} {csr_names_str} -{causes_str}#endif +{causes_str} +{arg_str}#endif #ifdef DECLARE_INSN {declare_insn_str}#endif #ifdef DECLARE_CSR |