]> granicus.if.org Git - clang/commitdiff
[x86][inline-asm] Add support for curly brackets escape using "%" in extended inline...
authorMichael Zuckerman <Michael.zuckerman@intel.com>
Mon, 31 Oct 2016 15:27:54 +0000 (15:27 +0000)
committerMichael Zuckerman <Michael.zuckerman@intel.com>
Mon, 31 Oct 2016 15:27:54 +0000 (15:27 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285585 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Stmt.cpp
test/CodeGen/x86_inlineasm_curly_bracket_escape.c [new file with mode: 0644]

index 89fbdf9d5894a4d31bfa9df331338ce75be7da68..697cdc3fb36081eecd2ebd527fe7fe47e03718f3 100644 (file)
@@ -533,15 +533,17 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces,
       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;
     }
diff --git a/test/CodeGen/x86_inlineasm_curly_bracket_escape.c b/test/CodeGen/x86_inlineasm_curly_bracket_escape.c
new file mode 100644 (file)
index 0000000..503c13e
--- /dev/null
@@ -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