[AMDGPU] Assembler: prevent parseDPPCtrlOps from eating invalid tokens

Reviewers: nhaustov, tstellarAMD

Subscribers: arsenm

Differential Revision: http://reviews.llvm.org/D19317

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266984 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sam Kolton 2016-04-21 13:14:24 +00:00
parent b18e50cc39
commit 02026c0953

View File

@ -2027,7 +2027,6 @@ bool AMDGPUOperand::isDPPCtrl() const {
AMDGPUAsmParser::OperandMatchResultTy
AMDGPUAsmParser::parseDPPCtrlOps(OperandVector &Operands) {
// ToDo: use same syntax as sp3 for dpp_ctrl
SMLoc S = Parser.getTok().getLoc();
StringRef Prefix;
int64_t Int;
@ -2043,6 +2042,19 @@ AMDGPUAsmParser::parseDPPCtrlOps(OperandVector &Operands) {
} else if (Prefix == "row_half_mirror") {
Int = 0x141;
} else {
// Check to prevent parseDPPCtrlOps from eating invalid tokens
if (Prefix != "quad_perm"
&& Prefix != "row_shl"
&& Prefix != "row_shr"
&& Prefix != "row_ror"
&& Prefix != "wave_shl"
&& Prefix != "wave_rol"
&& Prefix != "wave_shr"
&& Prefix != "wave_ror"
&& Prefix != "row_bcast") {
return MatchOperand_NoMatch;
}
Parser.Lex();
if (getLexer().isNot(AsmToken::Colon))
return MatchOperand_ParseFail;
@ -2114,7 +2126,7 @@ AMDGPUAsmParser::parseDPPCtrlOps(OperandVector &Operands) {
Int = 0x143;
}
} else {
return MatchOperand_NoMatch;
return MatchOperand_ParseFail;
}
}
}