Closed rod-chapman closed 2 years ago
It may also be possible to directly insert an assembler directive in the generated code for the packages that require the CSRR and CSRW instructions. I think you need to add .option arch,+zicsr
near the top of the generated .s file. Can this be done with package Machine_Code?
Details in the RISC-V specific section of the most recent GNU as manual.
For reference, my local changes to SPARKNaCl to get GNAT 12.1.1 working are here: https://github.com/rod-chapman/SPARKNaCl/pull/28
.option arch,+zicsr
in inlined machine code would be the best option in my opinion. Did you try it?
Yes... but I couldn't work out the exact syntax required...
See https://sourceware.org/binutils/docs/as/RISC_002dV_002dDirectives.html#RISC_002dV_002dDirectives
Might be because we don't have the latest binutils: https://github.com/enjoy-digital/litex/commit/91d79ae1daec8ca46a2d359bed37cfe5176f29d9
I will build a toolchain with the latest and try again.
Confirmed, I started build for a new release of the toolchains with binutils 2.38.
OK... let me know when it's ready (and how to get it) and I will give it a try...
Reading the ISA spec more carefully, I think you actually should generate
.option push .option arch,+zicsr # do stuff with CSRs or whatever... .option pop
so that the existing state of the "arch" setting is saved and restored properly.
The SPARKNaCl performance test program now seems to build OK with the new GNAT 12.1.2 with no modification to the assembly language component(s), so looking good.
Without the .option arch,+zicsr
?
Thanks for the update,
Yes... my sources (see SPARKNaCl/perf/csrs.s) are unmodified and it builds OK...
A recent change in GNU binutils (see https://groups.google.com/a/groups.riscv.org/g/sw-dev/c/aE1ZeHHCYf4) means that the RISC-V "performance counter" registers are now in a specific ISA extension called "zicsr". This change is shipping with the FSF GNAT 12.1.1 in Alire, so the build of Ada_Drivers_Library for the HiFive_revb (for example) fails. The project files needs to be updated to select "-march=rv32imac_zicsr" for all units, or (more generally) to add "_zicsr" to the end of the "-march" option for units that require the CSRR instructions.