Introduce RISC-V support in goodasm #30
Open
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.
The language support files are duplicated -
galangriscv.{cpp|h} and galangriscv32.{cpp|h}.
This is with the intention of follow-up work
to add galangriscv64.{cpp|h}, which the RISCV
spec identifies as a distinct base ISA.
To suppport or streamline compressed instruction
extension encoding, a new feature was added
to goodasm.cpp for rejectWhenZero constraint
matching. This makes it easier to differentiate
between some compressed instructions against c.nop or each other. There may be ways to resolve and
improve the bitmask / match() without this,
but did not appear to impact performance.
(An alternative path is to generalize
rejectWhenZero so that you can support
arbitrary constraint matching - this
might help with other languages with
funky edge-cases in the future.)
A large number of test cases were added to
riscv/tests - including an instruction
generation python script that attempted to
bruteforce every possible valid instruction.
The general testing approach was reflexive -
encode .asm to binary, decode that binary
to .disasm. If .asm and .disasm match,
it increases confidence of the correct
encoding. Formatting need{s/ed} to be accounted
for and the possibility of incorrect
binary representations remain - more robust
testing would include QEMU virtualization.
All tests are currently passing.
Various AI coding assistants were used in
combination with manual effort in an attempt
to explore LLM capabilities; this contribution
is "spec-driven development" by definition.
There is a chance errors slipped through despite
best efforts to manually audit and refine.