Clang集成汇编器和求反期间的“表达式中的未知令牌" [英] Clang integrated assembler and “unknown token in expression” during negate
问题描述
我们在默认配置中使用Clang.在默认配置中,使用的是Clang的集成汇编程序(而不是系统汇编程序,如GAS).我无法确定以下问题的确切问题(并解决):
We are using Clang in a default configuration. In the default configuration, Clang's Integrated Assembler is used (and not the system assembler, like GAS). I'm having trouble determining the exact problem (and fix) for:
make
...
clang++ -DNDEBUG -g2 -O3 -Wall -fPIC -arch i386 -arch x86_64 -pipe -Wno-tautological-compare -c integer.cpp
integer.cpp:542:2: error: unknown token in expression
AS1( neg %1)
^
./cpu.h:220:17: note: expanded from macro 'AS1'
#define AS1(x) GNU_AS1(x)
^
./cpu.h:215:24: note: expanded from macro 'GNU_AS1'
#define GNU_AS1(x) "\n\t" #x ";"
^
<inline asm>:3:6: note: instantiated into assembly here
neg %rcx;
^
有问题的代码在下面.
我 认为 ,以上错误可能与内联汇编和兼容性.一个简单的 negq%1
不能按预期工作:
I think the error above may be related to Inline Assembly and Compatibility. A simple negq %1
did not work as expected:
integer.cpp:543:2: error: unknown token in expression
AS1( negq %1)
^
./cpu.h:220:17: note: expanded from macro 'AS1'
#define AS1(x) GNU_AS1(x)
^
./cpu.h:215:24: note: expanded from macro 'GNU_AS1'
#define GNU_AS1(x) "\n\t" #x ";"
^
<inline asm>:3:7: note: instantiated into assembly here
negq %rcx;
^
自从其Intel大会以来,我还尝试了 negq [%1]
, neg DWORD PTR [%1]
和 negq DWORD PTR [%1]
不高兴.
Since its Intel assembly, I also tried negq [%1]
, neg DWORD PTR [%1]
and negq DWORD PTR [%1]
with no joy.
表达式中的未知标记"似乎是虚假消息,因为它抱怨的汇编指令似乎没有问题.因此,我怀疑Clang集成汇编程序还有其他令人反感的地方.
"unknown token in expression" appears to be a bogus message since the assembly instruction its complaining about does not seem to have a problem. So I suspect there is something else the Clang integrated assembler finds offensive.
代码有什么问题?
导致编译错误的代码:
int Baseline_Add(size_t N, word *C, const word *A, const word *B)
{
word result;
__asm__ __volatile__
(
".intel_syntax;" "\n"
AS1( neg %1)
ASJ( jz, 1, f)
AS2( mov %0,[%3+8*%1])
AS2( add %0,[%4+8*%1])
AS2( mov [%2+8*%1],%0)
ASL(0)
AS2( mov %0,[%3+8*%1+8])
AS2( adc %0,[%4+8*%1+8])
AS2( mov [%2+8*%1+8],%0)
AS2( lea %1,[%1+2])
ASJ( jrcxz, 1, f)
AS2( mov %0,[%3+8*%1])
AS2( adc %0,[%4+8*%1])
AS2( mov [%2+8*%1],%0)
ASJ( jmp, 0, b)
ASL(1)
AS2( mov %0, 0)
AS2( adc %0, %0)
".att_syntax;" "\n"
: "=&r" (result), "+c" (N)
: "r" (C+N), "r" (A+N), "r" (B+N)
: "memory", "cc"
);
return (int)result;
}
推荐答案
这似乎是集成汇编程序中的一个问题.在CFE-dev邮件列表中询问该问题后,一位LLVM开发人员打开了PR.另请参见 LLVM错误24232-[X86]内联汇编操作数不适用于.intel_syntax .
This appears to be an issue in the Integrated Assembler. One of the LLVM developers opened a PR after the question was asked on the CFE-dev mailing list. Also see LLVM Bug 24232 - [X86] Inline assembly operands don't work with .intel_syntax.
我认为,这意味着如果我们有时间和精力来重写1000行的块,迈克尔的评论可能是一个解决方案.
I think that means Michael's comment could be a solution if we had the time and energy to rewrite blocks with 1000's of lines.
这篇关于Clang集成汇编器和求反期间的“表达式中的未知令牌"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!