<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Unsupported ASM constraints for RISCV target"
href="https://bugs.llvm.org/show_bug.cgi?id=36067">36067</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unsupported ASM constraints for RISCV target
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>markwinterrowd4@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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: <a href="https://github.com/lluixhi/musl-riscv/blob/master/arch/riscv64/atomic_a.h">https://github.com/lluixhi/musl-riscv/blob/master/arch/riscv64/atomic_a.h</a>
). Note that J is a valid constraint for the RISCV machine; you can find a
description of its behavior in this GCC doc:
<a href="https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Machine-Constraints.html">https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Machine-Constraints.html</a>
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>