[PATCH] D35785: [AsmParser][AVX512]Enhance OpMask/Zero/Merge syntax check rubostness
coby via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 8 03:49:27 PDT 2017
coby updated this revision to Diff 110169.
coby added a comment.
Added intel-dialect test as well
Repository:
rL LLVM
https://reviews.llvm.org/D35785
Files:
lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/X86/avx512-err.s
test/MC/X86/intel-syntax-avx512-error.s
Index: lib/Target/X86/AsmParser/X86AsmParser.cpp
===================================================================
--- lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -2089,14 +2089,17 @@
// no errors.
// Query for the need of further parsing for a {%k<NUM>} mark
if (!Z || getLexer().is(AsmToken::LCurly)) {
- const SMLoc StartLoc = Z ? consumeToken() : consumedToken;
+ SMLoc StartLoc = Z ? consumeToken() : consumedToken;
// Parse an op-mask register mark ({%k<NUM>}), which is now to be
// expected
- if (std::unique_ptr<X86Operand> Op = ParseOperand()) {
+ unsigned RegNo;
+ if (!ParseRegister(RegNo, StartLoc, StartLoc) &&
+ X86MCRegisterClasses[X86::VK1RegClassID].contains(RegNo)) {
if (!getLexer().is(AsmToken::RCurly))
return Error(getLexer().getLoc(), "Expected } at this point");
Operands.push_back(X86Operand::CreateToken("{", StartLoc));
- Operands.push_back(std::move(Op));
+ Operands.push_back(std::move(X86Operand::CreateReg(RegNo, StartLoc,
+ StartLoc)));
Operands.push_back(X86Operand::CreateToken("}", consumeToken()));
} else
return Error(getLexer().getLoc(),
@@ -2106,7 +2109,8 @@
// Have we've found a parsing error, or found no (expected) {z} mark
// - report an error
if (ParseZ(Z, consumeToken()) || !Z)
- return true;
+ return Error(getLexer().getLoc(),
+ "Expected a {z} mark at this point");
}
// '{z}' on its own is meaningless, hence should be ignored.
Index: test/MC/X86/avx512-err.s
===================================================================
--- test/MC/X86/avx512-err.s
+++ test/MC/X86/avx512-err.s
@@ -1,6 +1,11 @@
-// RUN: not llvm-mc -triple x86_64-unknown-unknown -mcpu=knl -mattr=+avx512dq --show-encoding %s 2> %t.err
+// RUN: not llvm-mc -triple x86_64-unknown-unknown -mcpu=knl -mattr=+avx512dq -mattr=+avx512f --show-encoding %s 2> %t.err
// RUN: FileCheck --check-prefix=ERR < %t.err %s
// ERR: invalid operand for instruction
vpcmpd $1, %zmm24, %zmm7, %k5{%k0}
+// ERR: Expected a {z} mark at this point
+vfmsub213ps %zmm8, %zmm8, %zmm8{%k2} {rn-sae}
+
+// ERR: Expected an op-mask register at this point
+vfmsub213ps %zmm8, %zmm8, %zmm8 {rn-sae}
Index: test/MC/X86/intel-syntax-avx512-error.s
===================================================================
--- test/MC/X86/intel-syntax-avx512-error.s
+++ test/MC/X86/intel-syntax-avx512-error.s
@@ -0,0 +1,9 @@
+// RUN: llvm-mc %s -triple x86_64-unknown-unknown -mcpu=knl -mattr=+avx512f -x86-asm-syntax=intel -output-asm-variant=1 -o /dev/null 2>&1 | FileCheck %s
+
+// Validate that only OpMask/Zero mark may immediately follow destination
+ vfmsub213ps zmm8{rn-sae} {k2}, zmm8, zmm8
+// CHECK: error: Expected an op-mask register at this point
+ vfmsub213ps zmm8{k2} {rn-sae}, zmm8, zmm8
+// CHECK: error: Expected a {z} mark at this point
+ vfmsub213ps zmm8{rn-sae}, zmm8, zmm8
+// CHECK: error: Expected an op-mask register at this point
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35785.110169.patch
Type: text/x-patch
Size: 3291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170808/a297fca8/attachment.bin>
More information about the llvm-commits
mailing list