[PATCH] D25012: [x86][inline-asm] Add support for curly brackets escape using "%" in extended inline asm.
Matan via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 28 02:52:00 PDT 2016
mharoush created this revision.
mharoush added reviewers: rnk, myatsina.
mharoush added a subscriber: cfe-commits.
mharoush set the repository for this revision to rL LLVM.
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.
Note: This related test is dependent on the review on https://reviews.llvm.org/D25011
Repository:
rL LLVM
https://reviews.llvm.org/D25012
Files:
lib/AST/Stmt.cpp
test/CodeGen/x86_inlineasm_curly_bracket_escape.c
Index: lib/AST/Stmt.cpp
===================================================================
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -533,15 +533,17 @@
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;
}
Index: test/CodeGen/x86_inlineasm_curly_bracket_escape.c
===================================================================
--- test/CodeGen/x86_inlineasm_curly_bracket_escape.c
+++ test/CodeGen/x86_inlineasm_curly_bracket_escape.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -target-cpu skylake-avx512 -O0 -S -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: #APP
+//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1} {z}
+//CHECK: #NO_APP
+ asm ("vpaddb\t %%xmm1,%%xmm0,%%xmm1 %{%%k1%}%{z%}\t":::);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25012.72783.patch
Type: text/x-patch
Size: 1484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160928/3767311b/attachment-0001.bin>
More information about the cfe-commits
mailing list