内联 aarch64 程序集 UMOV 源语法
Inline aarch64 assembly UMOV source syntax
下面是我使用 NEON 为 AArch64 实现快速弹出计数的尝试:
#include <stdio.h>
int count_bits(unsigned long long val) {
unsigned long long p = 0;
int c = 0;
__asm__("DUP %0.2d, %2 \n\t"
"CNT %0.8b, %0.8b \n\t"
"ADDP d0, %0.2d \n\t"
"UMOV %1, d0 \n\t"
: "+w"(p), "+r"(c)
: "r"(val) : "d0");
return c;
}
int main(int argc, const char *argv[]) {
printf("Test: %i\n", count_bits(-1ull));
return 0;
}
错误:
$ gcc test.c -o test
Error: operand 2 should be a SIMD vector element -- `umov x0,d0'
我也不太确定 ADDP
指令,说明符建议它添加 2 个双字,但 CNT
指令的结果存储为 8 个字节(%0.8b
在 ADDP
中不起作用)。我不应该使用 UADALP
来求和组件吗?
Error: operand 2 should be a SIMD vector element -- `umov x0,d0'
("SIMD vector element" 定义在 ARM ARM for ARMv8-A 中的 C1.2.4。)
UMOV <Wd>, <Vn>.<Ts>[<index>]
或 64 位
UMOV <Xd>, <Vn>.<Ts>[<index>]
我猜你的情况可能是
UMOV %1, v0.D[0]
但是我不确定代码现在是否正确。我没有环境。测试。
下面是我使用 NEON 为 AArch64 实现快速弹出计数的尝试:
#include <stdio.h>
int count_bits(unsigned long long val) {
unsigned long long p = 0;
int c = 0;
__asm__("DUP %0.2d, %2 \n\t"
"CNT %0.8b, %0.8b \n\t"
"ADDP d0, %0.2d \n\t"
"UMOV %1, d0 \n\t"
: "+w"(p), "+r"(c)
: "r"(val) : "d0");
return c;
}
int main(int argc, const char *argv[]) {
printf("Test: %i\n", count_bits(-1ull));
return 0;
}
错误:
$ gcc test.c -o test
Error: operand 2 should be a SIMD vector element -- `umov x0,d0'
我也不太确定 ADDP
指令,说明符建议它添加 2 个双字,但 CNT
指令的结果存储为 8 个字节(%0.8b
在 ADDP
中不起作用)。我不应该使用 UADALP
来求和组件吗?
Error: operand 2 should be a SIMD vector element -- `umov x0,d0'
("SIMD vector element" 定义在 ARM ARM for ARMv8-A 中的 C1.2.4。)
UMOV <Wd>, <Vn>.<Ts>[<index>]
或 64 位
UMOV <Xd>, <Vn>.<Ts>[<index>]
我猜你的情况可能是
UMOV %1, v0.D[0]
但是我不确定代码现在是否正确。我没有环境。测试。