[X86] When parsing rounding mode operands, provide a proper end location so we don't crash when trying to print an error message using it.

llvm-svn: 321930
This commit is contained in:
Craig Topper 2018-01-06 06:41:07 +00:00
parent 8c2ea74e74
commit 36d8da3358
2 changed files with 9 additions and 5 deletions

View File

@ -825,7 +825,7 @@ private:
bool ParseIntelDotOperator(IntelExprStateMachine &SM, SMLoc &End); bool ParseIntelDotOperator(IntelExprStateMachine &SM, SMLoc &End);
unsigned IdentifyIntelInlineAsmOperator(StringRef Name); unsigned IdentifyIntelInlineAsmOperator(StringRef Name);
unsigned ParseIntelInlineAsmOperator(unsigned OpKind); unsigned ParseIntelInlineAsmOperator(unsigned OpKind);
std::unique_ptr<X86Operand> ParseRoundingModeOp(SMLoc Start, SMLoc End); std::unique_ptr<X86Operand> ParseRoundingModeOp(SMLoc Start);
bool ParseIntelNamedOperator(StringRef Name, IntelExprStateMachine &SM); bool ParseIntelNamedOperator(StringRef Name, IntelExprStateMachine &SM);
void RewriteIntelExpression(IntelExprStateMachine &SM, SMLoc Start, void RewriteIntelExpression(IntelExprStateMachine &SM, SMLoc Start,
SMLoc End); SMLoc End);
@ -1595,7 +1595,7 @@ bool X86AsmParser::ParseIntelInlineAsmIdentifier(const MCExpr *&Val,
//ParseRoundingModeOp - Parse AVX-512 rounding mode operand //ParseRoundingModeOp - Parse AVX-512 rounding mode operand
std::unique_ptr<X86Operand> std::unique_ptr<X86Operand>
X86AsmParser::ParseRoundingModeOp(SMLoc Start, SMLoc End) { X86AsmParser::ParseRoundingModeOp(SMLoc Start) {
MCAsmParser &Parser = getParser(); MCAsmParser &Parser = getParser();
const AsmToken &Tok = Parser.getTok(); const AsmToken &Tok = Parser.getTok();
// Eat "{" and mark the current place. // Eat "{" and mark the current place.
@ -1616,6 +1616,7 @@ X86AsmParser::ParseRoundingModeOp(SMLoc Start, SMLoc End) {
Parser.Lex(); // Eat the sae Parser.Lex(); // Eat the sae
if (!getLexer().is(AsmToken::RCurly)) if (!getLexer().is(AsmToken::RCurly))
return ErrorOperand(Tok.getLoc(), "Expected } at this point"); return ErrorOperand(Tok.getLoc(), "Expected } at this point");
SMLoc End = Tok.getEndLoc();
Parser.Lex(); // Eat "}" Parser.Lex(); // Eat "}"
const MCExpr *RndModeOp = const MCExpr *RndModeOp =
MCConstantExpr::create(rndMode, Parser.getContext()); MCConstantExpr::create(rndMode, Parser.getContext());
@ -1794,7 +1795,7 @@ std::unique_ptr<X86Operand> X86AsmParser::ParseIntelOperand() {
// Rounding mode operand. // Rounding mode operand.
if (getSTI().getFeatureBits()[X86::FeatureAVX512] && if (getSTI().getFeatureBits()[X86::FeatureAVX512] &&
getLexer().is(AsmToken::LCurly)) getLexer().is(AsmToken::LCurly))
return ParseRoundingModeOp(Start, End); return ParseRoundingModeOp(Start);
// Register operand. // Register operand.
unsigned RegNo = 0; unsigned RegNo = 0;
@ -1895,9 +1896,9 @@ std::unique_ptr<X86Operand> X86AsmParser::ParseATTOperand() {
return X86Operand::CreateImm(Val, Start, End); return X86Operand::CreateImm(Val, Start, End);
} }
case AsmToken::LCurly:{ case AsmToken::LCurly:{
SMLoc Start = Parser.getTok().getLoc(), End; SMLoc Start = Parser.getTok().getLoc();
if (getSTI().getFeatureBits()[X86::FeatureAVX512]) if (getSTI().getFeatureBits()[X86::FeatureAVX512])
return ParseRoundingModeOp(Start, End); return ParseRoundingModeOp(Start);
return ErrorOperand(Start, "Unexpected '{' in expression"); return ErrorOperand(Start, "Unexpected '{' in expression");
} }
} }

View File

@ -8,3 +8,6 @@ vfmsub213ps %zmm8, %zmm8, %zmm8{%k2} {rn-sae}
// ERR: Expected an op-mask register at this point // ERR: Expected an op-mask register at this point
vfmsub213ps %zmm8, %zmm8, %zmm8 {rn-sae} vfmsub213ps %zmm8, %zmm8, %zmm8 {rn-sae}
// ERR: invalid operand for instruction
cvtsd2sil {rn-sae}, %xmm1, %eax