0
下面的代码只是试图将数据从'in *'数组复制到'out *'数组,但在第一个vst1.32
指令中出现段错误,但是为什么?arm neon vst1.32 segfault
int* in0 = new int[4]{ 0x0, 0x1, 0x2, 0x3 };
int* in1 = new int[4]{ 0x4, 0x5, 0x6, 0x7 };
int* in2 = new int[4]{ 0x8, 0x9, 0xA, 0xB };
int* in3 = new int[4]{ 0xC, 0xD, 0xE, 0xF };
int* out0 = new int[4]{};
int* out1 = new int[4]{};
int* out2 = new int[4]{};
int* out3 = new int[4]{};
asm volatile("vld1.32 {d0, d1}, [%[in0]] \n"
"vld1.32 {d2, d3}, [%[in1]] \n"
"vld1.32 {d4, d5}, [%[in2]] \n"
"vld1.32 {d6, d7}, [%[in3]] \n"
"vst1.32 {d0, d1}, [%[out0]] \n"
"vst1.32 {d2, d3}, [%[out1]] \n"
"vst1.32 {d4, d5}, [%[out2]] \n"
"vst1.32 {d6, d7}, [%[out3]] \n"
: [out0]"=r"(out0), [out1]"=r"(out1), [out2]"=r"(out2), [out3]"=r"(out3)
: [in0]"r"(in0), [in1]"r"(in1), [in2]"r"(in2), [in3]"r"(in3)
: "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "memory", "cc"
);
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491f/BABDCGGF.html被标记为“替代”。也许你应该寻找取代这个命令的东西。 – BitTickler
使用搜索功能制作了此页面:http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491f/BABDCGGF.html - 所以我认为它可能实际上是_version_作为一个整体的文件已被取代,而不是单独的指令。 – bitwise
'[out0]“= r”(out0)'表示out0中的值将被asm覆盖。而且由于该值在被覆盖之前从未被使用过,因此赋予它什么意义? IOW,就像它看起来的反直觉一样,out0是一个输入。那么你如何告诉gcc你正在修改out0的*内容*?在这种情况下,内存clobber应该就足够了。 –