[Draft] Script to generate instr_dict.json from riscv-opcodes using UDB data #328
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a draft PR for #300
I included a
instr_dict.json
which I generated from riscv-opcodes which has data as of Nov 28, 2024There's 2 main scripts involved here.
generate_instr_dict.py
: This script generates a file calleddata.json
which is equivalent of theinstr_dict.json
from riscv-opcodes but using the data from UDB.sorter.py
: This script generates 2 files which sortsdata.json
andinstr_dict.json
to make it easier to diff the 2 files.Known issues:
I use this site to diff the 2 files and here are some immediate issues
add.uw
. Iirc, this is because 1 extension encapsulates the other extension.variable_fields
. I'm unsure on how to handle some cases likeimm
where it can range from eitherimmxx
wherexx
is just the size of the range but also deal with cases whereimm
turns intobimm12hi
andbimm12lo
for instructions likebeq
. There are more cases of these.rori
contains incorrect encoding. I'll open a separate pull request for this.These are currently the roadblocks that I am facing and I can't seem to resolve them. Feel free to give feedback or modify the script if necessary.
There's also some redundant functions such as
find_first_match
which I previously used but no longer require, but I kept it for now in case anyone finds it useful. I also tried adding types to most of these functions to make it easier to follow through.