[llvm] r310467 - [AsmParser][AVX512]Enhance OpMask/Zero/Merge syntax check rubostness
Coby Tayree via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 9 05:32:05 PDT 2017
Author: coby
Date: Wed Aug 9 05:32:05 2017
New Revision: 310467
URL: http://llvm.org/viewvc/llvm-project?rev=310467&view=rev
Log:
[AsmParser][AVX512]Enhance OpMask/Zero/Merge syntax check rubostness
Adopt a more strict approach regarding what marks should/can appear after a destination register, when operating upon an AVX512 platform.
Differential Revision: https://reviews.llvm.org/D35785
Added:
llvm/trunk/test/MC/X86/intel-syntax-avx512-error.s
Modified:
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/trunk/test/MC/X86/avx512-err.s
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=310467&r1=310466&r2=310467&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Wed Aug 9 05:32:05 2017
@@ -2089,14 +2089,17 @@ bool X86AsmParser::HandleAVX512Operand(O
// 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 @@ bool X86AsmParser::HandleAVX512Operand(O
// 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.
Modified: llvm/trunk/test/MC/X86/avx512-err.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/avx512-err.s?rev=310467&r1=310466&r2=310467&view=diff
==============================================================================
--- llvm/trunk/test/MC/X86/avx512-err.s (original)
+++ llvm/trunk/test/MC/X86/avx512-err.s Wed Aug 9 05:32:05 2017
@@ -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}
Added: llvm/trunk/test/MC/X86/intel-syntax-avx512-error.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/intel-syntax-avx512-error.s?rev=310467&view=auto
==============================================================================
--- llvm/trunk/test/MC/X86/intel-syntax-avx512-error.s (added)
+++ llvm/trunk/test/MC/X86/intel-syntax-avx512-error.s Wed Aug 9 05:32:05 2017
@@ -0,0 +1,9 @@
+// RUN: not 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
More information about the llvm-commits
mailing list