[clang] [llvm] [Clang][LoongArch] Add inline asm support for the `q` constraint (PR #141037)

Xi Ruoyao via cfe-commits cfe-commits at lists.llvm.org
Thu May 22 04:55:36 PDT 2025


xry111 wrote:

I have a C test case:

```c
unsigned long
test (unsigned long x, unsigned long y)
{
  register unsigned long ra asm ("ra");
  asm("" : "+r"(ra));

  unsigned long t = ra;
  asm ("csrxchg %0, %1, 0" : "+r" (x) : "r" (t));

  return x;
}
```

clang-20.1.4 errors out:

```
t.c:8:8: error: must not be $r0 or $r1
    8 |   asm ("csrxchg %0, %1, 0" : "+r" (x) : "r" (t));
      |        ^
<inline asm>:1:16: note: instantiated into assembly here
    1 |         csrxchg $a0, $ra, 0
      |                       ^
1 error generated.
```

And I suppose it should work after this PR and changing the second `"r"` to `"q"`.

https://github.com/llvm/llvm-project/pull/141037


More information about the cfe-commits mailing list