I'm learning GCC inline assembler under under ARM on a 64-bit Aarch64 device. I'm seeing an error message I don't quite understand. The error message in from GCC's inline assembler:
$ gcc -DNDEBUG -g3 -O1 -march=armv8-a+crc+crypto test.cc -o test.exe
/tmp/ccCHOWrn.s: Assembler messages:
/tmp/ccCHOWrn.s:19: Error: invalid use of vector register at operand 1 -- `pmull v0,v0,v0'
The sample program simply tries to exercise the polynomial multiply:
$ cat test.cc
#include <arm_neon.h>
int main(int argc, char* argv[])
{
uint64x2_t r = {0,0}, a = {2,4};
__asm__ __volatile__
(
"pmull %0, %1, %1;"
: "=w" (r)
: "w" (a), "w" (a)
: "cc"
);
return (int)r[0];
}
The "w"
is an Aarch64 machine constraint. In this case, its described as "Floating point or SIMD vector register", which seems to be what I want.
The uint64x2_t
type is typically used with ARM intrinsics. But its a 128-bit type and aligned for SIMD coprocessor, so it seemed like a good choice for the sample.
The device is a LeMaker HiKey with a Linaro image and GCC 4.9.2 compiler. It looks like this bug was fixed a couple of years ago, but I'm not sure if its related: fbb ftbfs on arm64.
I have two questions:
- What does the error mean, and how can I fix it?
- Is there an intrinsic for
pmull
andpmull2
?
I tried adding the arrangement specifiers, but I'm not surprised it did not work since I don't know the syntax:
$ gcc -DNDEBUG -g3 -O1 -march=armv8-a+crc+crypto test.cc -o test.exe
test.cc: In function ‘int main(int, char**)’:
test.cc:8:15: error: expected ‘)’ before numeric constant
: "=w" (r.1q)
^
test.cc:8:15: error: expected ‘)’ before numeric constant
test.cc:9:6: error: expected ‘;’ before ‘:’ token
: "w" (a.1d), "w" (a.1d)
^
test.cc:9:6: error: expected primary-expression before ‘:’ token
I also tried adding double percent signs (i.e., %%0
and %%1
) since the assembler was having trouble with .att_stntax
and .intel_syntax
:
$ gcc -DNDEBUG -g3 -O1 -march=armv8-a+crc+crypto test.cc -o test.exe
/tmp/ccPpnvUP.s: Assembler messages:
/tmp/ccPpnvUP.s:19: Error: operand 1 should be a SIMD vector register -- `pmull %0,%1,%1'