https://bugs.llvm.org/show_bug.cgi?id=36067
Bug ID: 36067
Summary: Unsupported ASM constraints for RISCV target
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangb...@nondot.org
Reporter: markwinterro...@gmail.com
CC: llvm-bugs@lists.llvm.org
When compiling the following reproducer with a RISCV-targeting build of
LLVM/Clang revision 322956:
static inline int a_cas(volatile int *p, int t, int s)
{
int old, tmp;
__asm__("li %1, 1\n"
"1:\n\t"
"lr.w %0, %2\n\t"
"bne %0, %3, 1f\n\t"
"sc.w %1, %4, %2\n\t"
"bnez %1, 1b\n"
"1:"
: "=rJ"(old), "+r"(tmp), "+A"(*p)
: "r"(t), "r"(s));
return old;
}
int x = 0;
int main() {
a_cas(&x, 0, 1);
}
as follows:
clang -target riscv64 test.c
I get the following error output:
test.c:11:19: error: invalid output constraint '=rJ' in asm
: "=rJ"(old), "+r"(tmp), "+A"(*p)
^
The above implementation of a_cas is taken directly from the atomic_a.h header
file in a RISCV-supporting implementation of the musl libc (which you can find
here: https://github.com/lluixhi/musl-riscv/blob/master/arch/riscv64/atomic_a.h
). Note that J is a valid constraint for the RISCV machine; you can find a
description of its behavior in this GCC doc:
https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Machine-Constraints.html
This lack of support for RISCV-provincial ASM constraints is not limited to J.
If you replace the "=rJ" with "=r", the following error results:
test.c:11:41: error: invalid output constraint '+A' in asm
: "=r"(old), "+r"(tmp), "+A"(*p)
^
indicating that the +A constraint is also not being recognized.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs