[cfe-dev] Where is the unknown token when using the Integrated Assembler (Intel syntax, neg instruction)?

Jeffrey Walton noloader at gmail.com
Wed Jul 22 23:42:34 PDT 2015


I'm part of an existing project, and I'm working on support for
Clang's Integrated Assembler. The project has copious amounts of
inline assembly (both stand alone one-liners for shift and rotates;
and blocks for things like AES and GCM mode). Even better (maybe
worse?), it mixes AT&T and Intel because it supports Microsoft and GNU
platforms.

I'm having trouble understanding an error message from the assembler.
The message is on the use of 'neg' under the Intel dialect:

<inline asm>:3:7: note: instantiated into assembly here
         neg %rcx;
             ^

The code looks like:

int SomeFunction(int* ptr, int val1, int val2)
{
    int ret;
    __asm__ __volatile (
        ".intel_syntax" "\n"
        neg %1;
        ...
    )

   return ret;
}

I'm testing on x86_64, so I tried changing to 'negq %1;' with no joy.
(Taking a hint from
http://clang.llvm.org/compatibility.html#inline-asm):

<inline asm>:3:8: note: instantiated into assembly here
         negq %rcx;
             ^

I'm experiencing it with both Apple's Clang 3.2, and LLVM's Clang
3.6.0 built from sources (http://llvm.org/releases/).

Naively (and I stress naively), “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 integrated assembler finds offensive.

Could anyone help me understand what the issue is?

Thanks in advance. Jeff.




More information about the cfe-dev mailing list