Skip to content
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

Incorrect global/static float array initialization #315

Closed
fourcolor opened this issue Dec 31, 2023 · 2 comments · Fixed by #316
Closed

Incorrect global/static float array initialization #315

fourcolor opened this issue Dec 31, 2023 · 2 comments · Fixed by #316
Labels
bug Something isn't working

Comments

@fourcolor
Copy link
Collaborator

The following code run through rv32emu did not function as expected. I have also tested it with spike, confirming that the issue is specific to rv32emu. This error will lead to an error when running #28 embench-iot minver

  • global static float array initialization
#include <stdio.h>
static float test[3] = {-3.0, 0.0, 2.0};
int main()
{
    printf("%f\n", test[0]);
    return 0;
}

compile

riscv32-unknown-elf-gcc test.c -march=rv32imafc -mabi=ilp32 -o test.elf

expect output

-3.000000
inferior exit code 0

actual output

0.000000
inferior exit code 0

Furthermore, I have observed that the same issue exists in the following code.

  • global float array initialization
#include <stdio.h>
float test[3] = {-3.0, 0.0, 2.0};
int main()
{
    printf("%f\n", test[0]);
    return 0;
}
  • local static float array initialization
#include <stdio.h>
int main()
{
    static float test[3] = {-3.0, 0.0, 2.0};
    printf("%f\n", test[0]);
    return 0;
}

I notice that it only occurred with the global float array initialization and static float array initialization

@fourcolor fourcolor changed the title Incorrect global/static float variable initialization Incorrect global/static float array initialization Dec 31, 2023
@fourcolor
Copy link
Collaborator Author

I finally found the reason. Sometimes, 'flw' will be compiled to 'cflw.' However, currently, rv32emu hasn't implemented 'cflw.' I think it's better to have an error message when encountering an unimplemented feature.

@visitorckw
Copy link
Collaborator

After the formal support of the F extension, I believe we can now proceed to implement instructions related to RV32FC.

@jserv jserv added the bug Something isn't working label Jan 1, 2024
fourcolor added a commit to fourcolor/rv32emu that referenced this issue Jan 6, 2024
This patch is aimed at supporting RV32FC-only instructions.
* The following instructions are implemented: C.FSW, C.FLW, C.FSWSP, C.FLWSP.
* Update README.md for the corresponding extension description.
* Add corresponding RISC-V architectural tests suites

Close sysprog21#315
fourcolor added a commit to fourcolor/rv32emu that referenced this issue Jan 6, 2024
This patch is aimed at supporting RV32FC-only instructions.
* The following instructions are implemented: C.FSW, C.FLW, C.FSWSP, C.FLWSP.
* Update README.md for the corresponding extension description.
* Add corresponding RISC-V architectural tests suites

Close sysprog21#315
fourcolor added a commit to fourcolor/rv32emu that referenced this issue Jan 6, 2024
This patch is aimed at supporting RV32FC-only instructions.
* The following instructions are implemented: C.FSW, C.FLW, C.FSWSP, C.FLWSP.
* Update README.md for the corresponding extension description.
* Add corresponding RISC-V architectural tests suites

Close sysprog21#315
fourcolor added a commit to fourcolor/rv32emu that referenced this issue Jan 6, 2024
This patch is aimed at supporting RV32FC-only instructions.
* The following instructions are implemented: C.FSW, C.FLW, C.FSWSP, C.FLWSP.
* Update README.md for the corresponding extension description.
* Add corresponding RISC-V architectural tests suites

Close sysprog21#315
@jserv jserv closed this as completed in #316 Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants