Question about inline Assembler - Visual Studio Style

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about inline Assembler - Visual Studio Style

David Chisnall via cfe-dev
Hello friendly Clang-World,

this is my first time using a mailing list, so I hope I do everything right. For my company I try to compile some old x86 code with clang, which compiled with Visual Studio 6. There I found the following macro:

#define POINT_TO_LABEL(variable, address) {        void* dest; __asm push eax __asm mov eax, offset seq_lbl##address __asm mov dest,eax __asm {pop eax} variable = dest;}


Clang says:
error: unexpected token in

      argument list
        POINT_TO_LABEL(pTableOfEntryPoints[seq_BEGINROW(1)],seq_BeginRow1);
        ^
Include\vSeqCodeModule.h(183,155):  note: expanded from macro 'POINT_TO_LABEL'
  ...seq_lbl##address __asm mov dest,eax __asm {pop eax} variable = dest;}
                                                                                                                                       
^

When I remove the {} from the last __asm code, the error from the '=' disappears, but the first message keeps coming.

So... What is the problem? Is this kind of inline assembler not compatible with Clang?

I have a second question for a private project. Do I have to send another mail with this question?


Kind regards from Germany
Björn
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Hiroshi Kawamura, Dr Hiroshi Nakamura, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Question about inline Assembler - Visual Studio Style

David Chisnall via cfe-dev
This looks like we're lexing multiple __asm one line statements in macros incorrectly.

On top of that, MSVC supports using labels in inline asm in ways that LLVM cannot. I think this is the relevant open issue: https://bugs.llvm.org/show_bug.cgi?id=24529

Even if you overcome the lexing issue, I don't think this asm will work as intended with clang.

On Tue, Feb 21, 2017 at 7:26 AM, via cfe-dev <[hidden email]> wrote:
Hello friendly Clang-World,

this is my first time using a mailing list, so I hope I do everything right. For my company I try to compile some old x86 code with clang, which compiled with Visual Studio 6. There I found the following macro:

#define POINT_TO_LABEL(variable, address) {        void* dest; __asm push eax __asm mov eax, offset seq_lbl##address __asm mov dest,eax __asm {pop eax} variable = dest;}


Clang says:
error: unexpected token in

      argument list
        POINT_TO_LABEL(pTableOfEntryPoints[seq_BEGINROW(1)],seq_BeginRow1);
        ^
Include\vSeqCodeModule.h(183,155):  note: expanded from macro 'POINT_TO_LABEL'
  ...seq_lbl##address __asm mov dest,eax __asm {pop eax} variable = dest;}
                                                                                                                                       
^

When I remove the {} from the last __asm code, the error from the '=' disappears, but the first message keeps coming.

So... What is the problem? Is this kind of inline assembler not compatible with Clang?

I have a second question for a private project. Do I have to send another mail with this question?


Kind regards from Germany
Björn
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Hiroshi Kawamura, Dr Hiroshi Nakamura, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev