Open apetenchea opened 3 weeks ago
@llvm/issue-subscribers-backend-risc-v
Author: Alex Petenchea (apetenchea)
The compiler doesn't read the text of the inline assembly so it doesn't know what instruction is being used. It only looks at the register constraints.
New constraints for inline assembly need to be defined to express this.
The compiler doesn't read the text of the inline assembly so it doesn't know what instruction is being used. It only looks at the register constraints.
New constraints for inline assembly need to be defined to express this.
Actually I don't think it's possible to add a constraint for this. The __int128 type is broken down into 2 64-bit values too early.
The compiler doesn't read the text of the inline assembly so it doesn't know what instruction is being used. It only looks at the register constraints. New constraints for inline assembly need to be defined to express this.
Actually I don't think it's possible to add a constraint for this. The __int128 type is broken down into 2 64-bit values too early.
I have an interest in supporting even-odd register pair constraints. They've come up here, and they'll come up more as things like Zilsd reach maturity and ratification. While the public Zilsd llvm implementation (by NXP -- https://github.com/llvm/llvm-project/compare/release/18.x...nxp-auto-tools:llvm-project:Zilsd/release/18.1.6 ) doesn't contain this support, evidently even-odd register pairs are becoming something repeated throughout the ISA.
It is high up my list to look at implementing support for these constraints and mapping __(u)int128_t
/(u)int64_t
onto them (on RV64/RV32 respectively), I don't think I require your help immediately, but I'll certainly be tagging you on reviews, and am happy to be given advice.
I think this will be fixed by https://github.com/llvm/llvm-project/pull/112983 - but it will also require the use of the Pr
constraint for the i128 values, rather than the r
constraint.
Thank you for the reasonably complex example, as it did help me to find crashes in my implementation.
Problem
Atomic Compare-and-Swap instructions (amocas) are part of the experimental zacas1p0 extension. For more information on
amocas
instructions, see Chapter 16. "Zacas" Extension for Atomic Compare-and-Swap (CAS) Instructions, Version 1.0.0, from the The RISC-V Instruction Set Manual Volume I.During code generation from inline assembly, the compiler "self-sabotages" itself by using the wrong regsiters.
Steps to reproduce
Suppose I have a file
bug.c
. I am trying to use the 128 bit version ofamocas
from inline assembly, like this:I am compiling it like this:
I am getting the following error:
My setup is the following:
main
, last commit is https://github.com/llvm/llvm-project/commit/2190ffa0f7e874d04fd0f750142135faa5df5d6bNote that other variants of
amocas
work fine, for example:The above compiles. Currently I have had this problem only with
amocas.q
, but it might be the case thatamocas.d
causes similar issues on riscv32.Current workaround
I can get this to compile by tricking the compiler into not using register "a3":
I'm leaving this here in case somebody experiences a similar issue. I would've gladly looked more into it, but I've got no idea where to start.