diff options
| author | Dmitry Preobrazhensky <dmitry.preobrazhensky@amd.com> | 2019-05-27 14:08:43 +0000 |
|---|---|---|
| committer | Dmitry Preobrazhensky <dmitry.preobrazhensky@amd.com> | 2019-05-27 14:08:43 +0000 |
| commit | b79af7930cac33ce23aa27a06a5cc2d3e2740028 (patch) | |
| tree | 980cd0b6536ffa18c8bfa981aff5aaeee8a6d8a9 /llvm/lib/Target | |
| parent | 3860aad6e7f0c261512ece251a6796dd71450e90 (diff) | |
| download | bcm5719-llvm-b79af7930cac33ce23aa27a06a5cc2d3e2740028.tar.gz bcm5719-llvm-b79af7930cac33ce23aa27a06a5cc2d3e2740028.zip | |
[AMDGPU][MC] Enabled constant expressions as operands of s_waitcnt
See bug 40820: https://bugs.llvm.org/show_bug.cgi?id=40820
Reviewers: artem.tamazov, arsenm
Differential Revision: https://reviews.llvm.org/D61017
llvm-svn: 361763
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp index b55facadf49..bc7068ef756 100644 --- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -4391,20 +4391,18 @@ encodeCnt( } bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) { - StringRef CntName = Parser.getTok().getString(); - int64_t CntVal; - Parser.Lex(); - if (getLexer().isNot(AsmToken::LParen)) - return true; + SMLoc CntLoc = getLoc(); + StringRef CntName = getTokenStr(); - Parser.Lex(); - if (getLexer().isNot(AsmToken::Integer)) - return true; + if (!skipToken(AsmToken::Identifier, "expected a counter name") || + !skipToken(AsmToken::LParen, "expected a left parenthesis")) + return false; - SMLoc ValLoc = Parser.getTok().getLoc(); - if (getParser().parseAbsoluteExpression(CntVal)) - return true; + int64_t CntVal; + SMLoc ValLoc = getLoc(); + if (!parseExpr(CntVal)) + return false; AMDGPU::IsaVersion ISA = AMDGPU::getIsaVersion(getSTI().getCPU()); @@ -4417,49 +4415,43 @@ bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) { Failed = encodeCnt(ISA, IntVal, CntVal, Sat, encodeExpcnt, decodeExpcnt); } else if (CntName == "lgkmcnt" || CntName == "lgkmcnt_sat") { Failed = encodeCnt(ISA, IntVal, CntVal, Sat, encodeLgkmcnt, decodeLgkmcnt); + } else { + Error(CntLoc, "invalid counter name " + CntName); + return false; } if (Failed) { Error(ValLoc, "too large value for " + CntName); - return true; + return false; } - if (getLexer().isNot(AsmToken::RParen)) { - return true; - } + if (!skipToken(AsmToken::RParen, "expected a closing parenthesis")) + return false; - Parser.Lex(); - if (getLexer().is(AsmToken::Amp) || getLexer().is(AsmToken::Comma)) { - const AsmToken NextToken = getLexer().peekTok(); - if (NextToken.is(AsmToken::Identifier)) { - Parser.Lex(); + if (trySkipToken(AsmToken::Amp) || trySkipToken(AsmToken::Comma)) { + if (isToken(AsmToken::EndOfStatement)) { + Error(getLoc(), "expected a counter name"); + return false; } } - return false; + return true; } OperandMatchResultTy AMDGPUAsmParser::parseSWaitCntOps(OperandVector &Operands) { AMDGPU::IsaVersion ISA = AMDGPU::getIsaVersion(getSTI().getCPU()); int64_t Waitcnt = getWaitcntBitMask(ISA); - SMLoc S = Parser.getTok().getLoc(); - - switch(getLexer().getKind()) { - default: return MatchOperand_ParseFail; - case AsmToken::Integer: - // The operand can be an integer value. - if (getParser().parseAbsoluteExpression(Waitcnt)) - return MatchOperand_ParseFail; - break; + SMLoc S = getLoc(); - case AsmToken::Identifier: - do { - if (parseCnt(Waitcnt)) - return MatchOperand_ParseFail; - } while(getLexer().isNot(AsmToken::EndOfStatement)); - break; + // If parse failed, do not return error code + // to avoid excessive error messages. + if (isToken(AsmToken::Identifier) && peekToken().is(AsmToken::LParen)) { + while (parseCnt(Waitcnt) && !isToken(AsmToken::EndOfStatement)); + } else { + parseExpr(Waitcnt); } + Operands.push_back(AMDGPUOperand::CreateImm(this, Waitcnt, S)); return MatchOperand_Success; } |

