[clang] [Clang][LoongArch] Match GCC behaviour when parsing FPRs in asm clobbers (PR #138391)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 19 01:16:48 PDT 2025
wangleiat wrote:
> There're four possible formats to refer a register in inline assembly,
>
> 1. Numeric name without dollar sign ("f0")
> 2. Numeric name with dollar sign ("$f0")
> 3. ABI name without dollar sign ("fa0")
> 4. ABI name with dollar sign ("$fa0")
>
> LoongArch GCC accepts 1 and 2 for FPRs before r15-8284[1] and all these formats after the chagne. But Clang supports only 2 and 4 for FPRs. The inconsistency has caused compatibility issues, such as QEMU's case[2].
>
> This patch follows [0bbf3dd](https://github.com/llvm/llvm-project/commit/0bbf3ddf5fea86e0eb0726142827e175aadaf53b) ("[Clang][LoongArch] Add GPR alias handling without `$` prefix") and accepts FPRs without dollar sign prefixes as well to keep aligned with GCC, avoiding future compatibility problems.
>
> Link: https://gcc.gnu.org/cgit/gcc/commit/?id=d0110185eb78f14a8e485f410bee237c9c71548d [1] Link: https://lore.kernel.org/qemu-devel/20250314033150.53268-3-ziyao@disroot.org/ [2]
GCC handles `vr` and `xr` in the same way, but the generated registers are incorrect. For now, it's sufficient to handle only fr.
https://github.com/llvm/llvm-project/pull/138391
More information about the cfe-commits
mailing list