[PATCH] D18700: [Inline asm][GCC compatibility] Handle %v-prefixed code in inline assembly

Denis Zobnin via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 12 08:42:55 PDT 2016


d.zobnin.bugzilla updated this revision to Diff 53400.
d.zobnin.bugzilla added a comment.

Eric, thank you for the review!

I've renamed the test, but have also made it a .cpp file for the reasons described below.

You are right -- GCC looks at "target" attribute applied to the function in which inline asm exists. But GCC seems to take into account lambda's attributes as well, if asm statement is inside a lambda. To be correct, GCC seems to collect all target features from command line, function and lambda's attributes, so such code:

  void f8(void *x) __attribute__((__target__("no-avx")));
  void f8(void *x) {
    auto g1 = [](void *arg) __attribute__((__target__("avx2"))) {
      auto g2 = [&arg]() __attribute__((__target__("no-mmx"))) {
        int a = 10, b;
        __asm__ ("%vmovq (%%rbp), %%xmm0" : "=r"(b) : "r"(a) : "%eax");
      };
      g2();
    };
    g1(x);
  }

will produce "vmovq" instruction regardless of command line arguments because of g1's attribute.

I tried several approaches to implement this behavior and came up with this patch, please take a look!


http://reviews.llvm.org/D18700

Files:
  include/clang/AST/Stmt.h
  lib/AST/Stmt.cpp
  lib/Sema/SemaStmtAsm.cpp
  test/CodeGen/avx-v-modifier-inline-asm.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18700.53400.patch
Type: text/x-patch
Size: 11665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160412/a68c93b6/attachment-0001.bin>


More information about the cfe-commits mailing list