-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Windows] Support MSVC __asm syntax #13712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Chad is working on this. |
Oops, wrong platform. |
What is the state of the asm support in trunk? Can this be closed as fixed? |
I think the support is not complete yet, e.g. this doesn't work IIRC:__asm {
|
Apparently this is also supported by MSVC: struct Foo { __asm { Clang gives what you might expect: |
Tracking the issue pointed out by Reid in rdar://13499009. Should should be relatively easy to fix. |
Reid, I'm unable to verify if your example is supported. With this example, struct Foo { I get the following errors: I'm compiling with the /Od /Fa options using Visual Studio 10. Am I doing something wrong? |
Should be a .cpp file, I suppose? |
Doh! That should have been obvious.. :o/ Thanks, Timur. The example works as expected. |
Discovered one more bug: LLVM doesn't recognize the setc opcode. It's an alias for setb; they both check the carry flag (CF). Test case attached. |
The setc issue is also being tracked in rdar://13674398. Hopefully, I can address this shortly. |
The setc issue should be resolved with r179804 and r179813. |
*** Bug llvm/llvm-bugzilla-archive#15779 has been marked as a duplicate of this bug. *** |
I've discovered another feature. :) Apparently you can do something like: The "Foo.a" expression here computes the offset of Foo::a and adds it to ebx before dereferencing. |
This is probably related, the 'context.Eip' expression fails to parse with an assertion (infinite loop in NDEBUG build): $ cat ms_inline_asm_call_pop_pic.cc $ ../../build_debug/bin/clang -c ms_inline_asm_call_pop_pic.cc
0x6166C94A (0x0000000A 0x00000000 0x0374B4E4 0x61747114), exit() + 0x13A bytes(s) |
Adding support for struct Foo { int a; }; is also being tracked in rdar://14070479. |
The assertion failure (infinite loop in NDEBUG build) is also being tracked by rdar://14070517 |
This basically works. The test cases in the last few comments work fine on trunk. There are bugs left (blockers of this bug, and others), but the feature basically exists. Marking this fixed. |
mentioned in issue llvm/llvm-bugzilla-archive#13707 |
mentioned in issue llvm/llvm-bugzilla-archive#15779 |
mentioned in issue llvm/llvm-bugzilla-archive#16830 |
mentioned in issue llvm/llvm-bugzilla-archive#17201 |
mentioned in issue llvm/llvm-bugzilla-archive#19861 |
Extended Description
$ cat assembly.cpp
int foo(int argument) {
int result;
__asm {
mov eax, argument
inc eax
mov result, eax
}
return result;
}
extern "C"
int printf(const char *fmt, ...);
int main() {
int val = 42;
int res = foo(val);
printf("res = %d\n", res);
return res != 43;
}
$ cl -nologo assembly.cpp && ./assembly.exe && echo "OK"
assembly.cpp
res = 43
OK
As of r159923,
$ clang++ -Xclang -cxx-abi -Xclang microsoft assembly.cpp && ./a.out && echo "OK"
assembly.cpp:3:3: warning: MS-style inline assembly is not supported [-Wmicrosoft]
__asm {
^
1 warning generated.
res = 11
The text was updated successfully, but these errors were encountered: