[PATCH] D17766: [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces
Marina Yatsina via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 06:35:54 PST 2016
myatsina created this revision.
myatsina added reviewers: rnk, ehsan, mcrosier, delena.
myatsina added a subscriber: llvm-commits.
myatsina set the repository for this revision to rL LLVM.
Until now curly braces could only be used in MS inline assembly to mark block start/end.
All curly braces were removed completely at a very early stage.
This approach caused bugs like:
"m{o}v eax, ebx" turned into "mov eax, ebx" without any error.
In addition, AVX-512 added special operands (e.g., k registers), which are also surrounded by curly braces that mark them as such.
Now, we need to keep the curly braces and identify at a later stage if they are marking block start/end (if so, ignore them), or surrounding special AVX-512 operands (if so, parse them as such).
This patch fixes the bug described above and enables the use of AVX-512 special operands.
This review is for the clang part.
The llvm part of the review is: http://reviews.llvm.org/differential/diff/49485/
Repository:
rL LLVM
http://reviews.llvm.org/D17766
Files:
lib/Parse/ParseStmtAsm.cpp
test/CodeGen/ms-inline-asm-avx512.c
test/Parser/ms-inline-asm.c
Index: lib/Parse/ParseStmtAsm.cpp
===================================================================
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -390,6 +390,7 @@
if (!InAsmComment && Tok.is(tok::l_brace)) {
// Consume the opening brace.
SkippedStartOfLine = Tok.isAtStartOfLine();
+ AsmToks.push_back(Tok);
EndLoc = ConsumeBrace();
BraceNesting++;
LBraceLocs.push_back(EndLoc);
@@ -442,6 +443,11 @@
BraceCount == (savedBraceCount + BraceNesting)) {
// Consume the closing brace.
SkippedStartOfLine = Tok.isAtStartOfLine();
+ // Don't want to add the closing brac of the whole asm block
+ if (SingleLineMode || BraceNesting > 1) {
+ Tok.clearFlag(Token::LeadingSpace);
+ AsmToks.push_back(Tok);
+ }
EndLoc = ConsumeBrace();
BraceNesting--;
// Finish if all of the opened braces in the inline asm section were
Index: test/CodeGen/ms-inline-asm-avx512.c
===================================================================
--- test/CodeGen/ms-inline-asm-avx512.c
+++ test/CodeGen/ms-inline-asm-avx512.c
@@ -9,3 +9,13 @@
vaddpd zmm8, zmm27, zmm6
}
}
+
+
+void t2() {
+// CHECK: @t2
+// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: ret void
+ __asm {
+ vaddpd zmm8 {k1}, zmm27, zmm6
+ }
+}
Index: test/Parser/ms-inline-asm.c
===================================================================
--- test/Parser/ms-inline-asm.c
+++ test/Parser/ms-inline-asm.c
@@ -53,6 +53,10 @@
void t12() {
__asm jmp label // expected-error {{use of undeclared label 'label'}}
}
+void t13() {
+ __asm m{o}v eax, ebx // expected-error {{expected identifier}} expected-error {{use of undeclared label '{o}v eax, ebx'}}
+}
+
int t_fail() { // expected-note {{to match this}}
__asm
__asm { // expected-error 3 {{expected}} expected-note {{to match this}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17766.49482.patch
Type: text/x-patch
Size: 1977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160301/861f35e2/attachment.bin>
More information about the llvm-commits
mailing list