A64 inline assembly register width selection
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Linaro GCC |
New
|
Undecided
|
Unassigned |
Bug Description
The following code snippet fails to compile:
int main() {
int ret;
long a=0, b=1;
__asm__ volatile (
"stxr %0, %2, [%1] \n\t"
:"=&r" (ret)
:"r" (&a), "r" (b)
: "memory"
);
return ret;
}
Error: operand mismatch -- `stxr x0,x2,[x1]'
This can be worked around by manually using a 32-bit wide register such as the following.
int main() {
register int ret asm("w2");
long a=0, b=1;
__asm__ volatile (
"stxr w2, %2, [%1] \n\t"
:"=&r" (ret)
:"r" (&a), "r" (b)
: "memory"
);
return ret;
}
However it would be better if this didn't have to be worked around and instead the tools would select the proper form of the register for based on instruction limitations. If that is not possible/
"=&rw" (ret)
Hi Christopher,
you can explicitly constraint the register width like that :
"stxr %w0, %2, [%1] \n\t"
Yvan