Skip to content

Commit

Permalink
[AMDGPU][MC] Corrected error message for s_waitcnt helpers
Browse files Browse the repository at this point in the history
See Bug 32711: https://bugs.llvm.org//show_bug.cgi?id=32711

Reviewers: artem.tamazov

Differential Revision: https://reviews.llvm.org/D33781

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304922 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dpreobra committed Jun 7, 2017
1 parent 619317e commit 8848866
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
28 changes: 16 additions & 12 deletions lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2849,6 +2849,7 @@ bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) {
if (getLexer().isNot(AsmToken::Integer))
return true;

SMLoc ValLoc = Parser.getTok().getLoc();
if (getParser().parseAbsoluteExpression(CntVal))
return true;

Expand All @@ -2866,21 +2867,24 @@ bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) {
Failed = encodeCnt(ISA, IntVal, CntVal, Sat, encodeLgkmcnt, decodeLgkmcnt);
}

// To improve diagnostics, do not skip delimiters on errors
if (!Failed) {
if (getLexer().isNot(AsmToken::RParen)) {
return true;
}
Parser.Lex();
if (getLexer().is(AsmToken::Amp) || getLexer().is(AsmToken::Comma)) {
const AsmToken NextToken = getLexer().peekTok();
if (NextToken.is(AsmToken::Identifier)) {
Parser.Lex();
}
if (Failed) {
Error(ValLoc, "too large value for " + CntName);
return true;
}

if (getLexer().isNot(AsmToken::RParen)) {
return true;
}

Parser.Lex();
if (getLexer().is(AsmToken::Amp) || getLexer().is(AsmToken::Comma)) {
const AsmToken NextToken = getLexer().peekTok();
if (NextToken.is(AsmToken::Identifier)) {
Parser.Lex();
}
}

return Failed;
return false;
}

OperandMatchResultTy
Expand Down
8 changes: 4 additions & 4 deletions test/MC/AMDGPU/sopp-err.s
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ s_sendmsg sendmsg(MSG_SYSMSG, 5)
// GCN: error: invalid/unsupported code of SYSMSG_OP

s_waitcnt lgkmcnt(16)
// GCN: error: failed parsing operand
// GCN: error: too large value for lgkmcnt

s_waitcnt expcnt(8)
// GCN: error: failed parsing operand
// GCN: error: too large value for expcnt

s_waitcnt vmcnt(16)
// GCN: error: failed parsing operand
// GCN: error: too large value for vmcnt

s_waitcnt vmcnt(0xFFFFFFFFFFFF0000)
// GCN: error: failed parsing operand
// GCN: error: too large value for vmcnt

s_waitcnt vmcnt(0), expcnt(0), lgkmcnt(0),
// GCN: error: failed parsing operand
Expand Down

0 comments on commit 8848866

Please sign in to comment.