-
Notifications
You must be signed in to change notification settings - Fork 76
feat(backends): add GNU Assembler Test Generator for RISC-V #1139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: AFOliveira/addBinutils
Are you sure you want to change the base?
feat(backends): add GNU Assembler Test Generator for RISC-V #1139
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, @AnimeshAgarwal28.
Thanks for the PR, can you change it so that instead of merging into main, you merge it into my branch that has binutils generator? It's AFOliveira/addBinutils.
Also, if possible, can you post the artifacts this approach generates? Even if just an exapmle for the I extension.
Implement a test generator that creates GNU Assembler test files from the RISC-V unified database. The generator produces test files in the format expected by the binutils gas test suite. Signed-off-by: Animesh Agarwal <[email protected]>
563ce25
to
1823a4f
Compare
Hi @AFOliveira, I changed this PR to merge over your branch. I am attaching 2 sets of generated files, one for I extension and one for zicbom.: zicbom.s:
zicbom.d:
i.s:
i.d:
|
Are you only generating valid tests? I.e. not generating test that are supposed to fail? Per example, wrong number of operans, wrong operand type. |
No, the generator attempts to generate failing tests also (Currently the generator only generates invalid_operands errors), here is an example: i-fail.l:
i-fail.s
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## AFOliveira/addBinutils #1139 +/- ##
=======================================================
Coverage 46.05% 46.05%
=======================================================
Files 11 11
Lines 4942 4942
Branches 1345 1345
=======================================================
Hits 2276 2276
Misses 2666 2666
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I think there's some dead code like the one I pointed out, can you verify this is isn't the case or fix it if you find more?
Signed-off-by: Animesh Agarwal <[email protected]>
Trying something - @claude is all dead code removed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a GNU Assembler test generator that automatically creates test files for the RISC-V toolchain from the unified database. The generator aims to streamline testing of RISC-V extensions by producing assembly source files, dump files, and error test cases in the format expected by the binutils gas test suite.
Key changes:
- Adds comprehensive test generator with constraint-aware assembly generation and realistic operand combinations
- Creates documentation detailing usage, architecture, and integration instructions
- Implements modular design with separate components for instruction grouping, assembly generation, and test orchestration
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
File | Description |
---|---|
gas_test_generator_readme.md | Documentation covering usage, features, architecture, and extension guidelines |
gas_test_generator.py | Main implementation with instruction loading, constraint extraction, assembly generation, and test file creation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- normalize extension tokens, extract dependencies from definedBy, and carry them into each instruction group - replace ad-hoc fail lists with structured error cases, reason tags - emit annotated pass and no-alias dumps from a single primary example selection per instruction Signed-off-by: Animesh Agarwal <[email protected]>
@AnimeshAgarwal28 can you solve copilot's review? |
a75ecc4
to
8b72ae9
Compare
@AnimeshAgarwal28 Is this the version that you already tested on binutils and that compiled? |
Yes, a lot of the generated tests work as expected, there are still issues with some of the extensions. For eg. c-d.s does not pass because of a hyphen in the march string, this needs to be addressed. |
Ok, please let me know when you need help or a review! |
This PR introduces a test generator that creates GNU Assembler test files from the RISC-V unified database. The generator produces test files in the format expected by the binutils gas test suite.
Currently the generated test files although very close to upstream test files can be incorrect due to issues like:
Extension Dependencies: Instructions like ld and sd require the zilsd extension for RV32 but are incorrectly included in the base i extension tests.
Assembly Field Validation: Some instructions have malformed assembly patterns in the database, leading to invalid test cases (e.g., sspopchk.x1).
For usage instructions and more information about the generator check gas_test_generator_readme.md
This is a draft PR intended to gather community feedback/suggestions on approach and priorities before investing in accuracy improvements.