Author: mzuckerm
Date: Mon Oct 31 10:27:54 2016
New Revision: 285585

URL: http://llvm.org/viewvc/llvm-project?rev=285585&view=rev
Log:
[x86][inline-asm] Add support for curly brackets escape using "%" in extended 
inline asm.

Commit on behalf of mharoush

After LGTM and check all:

This patch is a compatibility fix for clang, matching GCC support for charter 
escape when using extended in-line assembly (i.e, "%{" ,"%}" --> "{" ,"}" ).
 It is meant to enable support for advanced features such as AVX512 
conditional\masked vector instructions/broadcast assembly syntax.

Reviewer: 1. rnk

Differential Revision: https://reviews.llvm.org/D25012


Added:
    cfe/trunk/test/CodeGen/x86_inlineasm_curly_bracket_escape.c
Modified:
    cfe/trunk/lib/AST/Stmt.cpp

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=285585&r1=285584&r2=285585&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Mon Oct 31 10:27:54 2016
@@ -533,15 +533,17 @@ unsigned GCCAsmStmt::AnalyzeAsmString(Sm
       DiagOffs = CurPtr-StrStart-1;
       return diag::err_asm_invalid_escape;
     }
-
+    // Handle escaped char and continue looping over the asm string.
     char EscapedChar = *CurPtr++;
-    if (EscapedChar == '%') {  // %% -> %
-      // Escaped percentage sign.
-      CurStringPiece += '%';
+    switch (EscapedChar) {
+    default:
+      break;
+    case '%': // %% -> %
+    case '{': // %{ -> {
+    case '}': // %} -> }
+      CurStringPiece += EscapedChar;
       continue;
-    }
-
-    if (EscapedChar == '=') {  // %= -> Generate an unique ID.
+    case '=': // %= -> Generate a unique ID.
       CurStringPiece += "${:uid}";
       continue;
     }

Added: cfe/trunk/test/CodeGen/x86_inlineasm_curly_bracket_escape.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_inlineasm_curly_bracket_escape.c?rev=285585&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/x86_inlineasm_curly_bracket_escape.c (added)
+++ cfe/trunk/test/CodeGen/x86_inlineasm_curly_bracket_escape.c Mon Oct 31 
10:27:54 2016
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-cpu skylake-avx512 
-O0  -S -emit-llvm -o - -Wall -Werror | FileCheck %s
+// This test checks validity of inline assembly using curly brackets syntax
+// for extended inline asm.
+
+void test_curly_brackets() {
+    //CHECK:  %xmm1,%xmm0,%xmm1 {%k1}{z}
+    asm("vpaddb\t %%xmm1,%%xmm0,%%xmm1 %{%%k1%}%{z%}\t":::);
+}
\ No newline at end of file


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to