-
Notifications
You must be signed in to change notification settings - Fork 188
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
Add first party C tests #764
Conversation
I definitely prefer this to the Zig implementation, even if the CMake file is a bit messier. Ideally it would work with both gcc and clang, especially because a lot of other riscv projects point users very strongly towards gcc (like the riscv-arch-test documentation). |
5195089
to
f127eb0
Compare
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.
Thanks for adding GCC. A few more comments.
DEPENDS ${common_deps} "src/${test_source}" | ||
COMMAND ${CROSS_COMPILER_COMMAND_RV${xlen}} | ||
# The ISA string to compile for. | ||
-march=rv${xlen}gc |
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.
As our tests evolve we'll need a more comprehensive march string. We use rv64gcv_zcb_zfa_zba_zbb_zbc_zbs_zfh_zicboz_zicbop_zicbom_zicond_zbkb_zbkx_zknd_zkne_zknh
for our tests. We really want to enable every extension so that any instruction can be used in a test file for the model.
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.
But some extensions are incompatible, such as Zcf and Zclsd, each test should be able to specify its own match string
One example is gcc's test framework, you can specify it in the comments (for reference)
gcc/testsuite/gcc.target/riscv/cmo-zicbom-1.c
/* { dg-do compile } */
/* { dg-options "-march=rv64gc_zicbom -mabi=lp64" } */
...
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.
That is a very good point. Not sure that we need that level of complexity yet in the first version of this PR (would rather get some testing in instead of waiting for it to be perfect and continue with almost no tests), but definitely something we will need to address eventually.
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.
completely agree, would be great to see this merged soon.
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.
Yeah my plan was to embed a list of march
and model configs inside the source files and then we would run each test for all of those. Probably worth waiting until after the new config system is done though.
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.
Seems reasonable. We should probably open an issue to track this after this PR is merged.
6986639
to
831e9aa
Compare
I like this, just a few minor comments (and haven't managed to review all the asm code) |
I figured out the It was because I forgot to set I'll fix the other issues mentioned in a bit. |
ca5efd5
to
43442e3
Compare
Add first party C tests that can be used for tests specific to this model. This uses Clang or RISCV GCC as the cross-compiler. This includes a copy of `nanoprinf` for printing to the UART.
d971e16
to
16a2f97
Compare
I removed the max_pmp test. I'll add it with my PR that fixes the PMP code. |
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.
LGTM at this point. There are still improvements to be made (especially with ISA strings), but those can be part of a follow up PR. This will be great to get in so new tests can easily be added for the model.
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.
LGTM, this is great and any improvements can be made in follow-up changes
Add first party C tests that can be used for tests specific to this model. This uses Clang as the cross-compiler.
This includes a copy of
nanoprinf
for printing to the UART.