-
Notifications
You must be signed in to change notification settings - Fork 107
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
Fix declaration error when using clang #532
Conversation
When compile the rv32emu using clang, the error log shows the following: src/emulate.c:1127:5: error: expected expression rv_insn_t ir; According to [1], syntax of lebeled-statement stated in the following: labeled-statement: identifier : statement case constant-expression : statement default : statement Obviously, only the statement is valid after labeled-statement. When refering to [2], the following are the valid statements, excluding the declaration. statement: labeled-statement compound-statement expression-statement selection-statement iteration-statement jump-statement Thus, move the declaration of ir before the labeled-statement eliminates the clang compile error. [1] C99 6.8.1 Labeled statements [2] C99 6.8 Statement and blocks
During development, we might not consistently use multiple compilers (e.g., GCC and Clang) to build rv32emu for compatibility checks. The build checks can be automated in the CI pipeline. By default, GCC is used for behavioral verification, while Clang is reserved for build verification only. We can embrace Clang to our CI pipeline. What do you think? @jserv |
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.
Benchmarks
Benchmark suite | Current: f560955 | Previous: 8ee7304 | Ratio |
---|---|---|---|
Dhrystone |
1284 Average DMIPS over 10 runs |
1346 Average DMIPS over 10 runs |
1.05 |
Coremark |
976.216 Average iterations/sec over 10 runs |
961.255 Average iterations/sec over 10 runs |
0.98 |
This comment was automatically generated by workflow using github-action-benchmark.
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
Additionally, rv_clz() and rv_ctz() include MSVC implementations, but we don't have tests for them. Should we consider adding MSVC tests for these in CI? |
Seems applicable. BTW, did you try to build and run in Windows? |
I haven't tried it before, but I can give it a try! :) |
Thank @ChinYikMing for contributing! |
Fix declaration error when using clang
When compile the rv32emu using clang, the error log shows the following:
According to [1], syntax of labeled-statement stated in the following:
labeled-statement:
identifier : statement
case constant-expression : statement
default : statement
Obviously, only the statement is valid after labeled-statement. When refering to [2], the following are the valid statements, excluding the declaration.
statement:
labeled-statement
compound-statement
expression-statement
selection-statement
iteration-statement
jump-statement
Thus, move the declaration of ir before the labeled-statement eliminates the clang compile error.
[1] C99 6.8.1 Labeled statements
[2] C99 6.8 Statement and blocks