diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp --- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -5854,10 +5854,8 @@ if (Str.getAsInteger(10, Val)) return MatchOperand_ParseFail; - if (Val > 7) { - Error(getLoc(), "invalid exp target"); + if (Val > 7) return MatchOperand_ParseFail; - } return MatchOperand_Success; } @@ -5867,10 +5865,8 @@ if (Str.getAsInteger(10, Val)) return MatchOperand_ParseFail; - if (Val > 4 || (Val == 4 && !isGFX10())) { - Error(getLoc(), "invalid exp target"); + if (Val > 4 || (Val == 4 && !isGFX10())) return MatchOperand_ParseFail; - } Val += 12; return MatchOperand_Success; @@ -5886,38 +5882,30 @@ if (Str.getAsInteger(10, Val)) return MatchOperand_ParseFail; - if (Val >= 32) { - Error(getLoc(), "invalid exp target"); + if (Val >= 32) return MatchOperand_ParseFail; - } Val += 32; return MatchOperand_Success; } - if (Str.startswith("invalid_target_")) { - Str = Str.drop_front(15); - if (Str.getAsInteger(10, Val)) - return MatchOperand_ParseFail; - - Error(getLoc(), "invalid exp target"); - return MatchOperand_ParseFail; - } - - return MatchOperand_NoMatch; + return MatchOperand_ParseFail; } OperandMatchResultTy AMDGPUAsmParser::parseExpTgt(OperandVector &Operands) { - uint8_t Val; - StringRef Str = Parser.getTok().getString(); + if (!isToken(AsmToken::Identifier)) + return MatchOperand_NoMatch; - auto Res = parseExpTgtImpl(Str, Val); - if (Res != MatchOperand_Success) + SMLoc S = getLoc(); + + uint8_t Val; + auto Res = parseExpTgtImpl(getTokenStr(), Val); + if (Res != MatchOperand_Success) { + Error(S, "invalid exp target"); return Res; + } - SMLoc S = Parser.getTok().getLoc(); Parser.Lex(); - Operands.push_back(AMDGPUOperand::CreateImm(this, Val, S, AMDGPUOperand::ImmTyExpTgt)); return MatchOperand_Success; diff --git a/llvm/test/MC/AMDGPU/exp-err.s b/llvm/test/MC/AMDGPU/exp-err.s --- a/llvm/test/MC/AMDGPU/exp-err.s +++ b/llvm/test/MC/AMDGPU/exp-err.s @@ -23,28 +23,37 @@ // GCN: :5: error: invalid exp target exp mrt-1 v3, v2, v1, v0 -// GCN: :5: error: failed parsing operand +// GCN: :5: error: invalid exp target exp mrtX v3, v2, v1, v0 -// GCN: :5: error: failed parsing operand +// GCN: :5: error: invalid exp target exp pos-1 v3, v2, v1, v0 -// GCN: :5: error: failed parsing operand +// GCN: :5: error: invalid exp target exp posX v3, v2, v1, v0 -// GCN: :5: error: failed parsing operand +// GCN: :5: error: invalid exp target exp param-1 v3, v2, v1, v0 -// GCN: :5: error: failed parsing operand +// GCN: :5: error: invalid exp target exp paramX v3, v2, v1, v0 -// GCN: :5: error: failed parsing operand +// GCN: :5: error: invalid exp target exp invalid_target_-1 v3, v2, v1, v0 -// GCN: :5: error: failed parsing operand +// GCN: :5: error: invalid exp target exp invalid_target_X v3, v2, v1, v0 -// GCN: :5: error: failed parsing operand +// GCN: :5: error: invalid exp target + +exp 0 v3, v2, v1, v0 +// GCN: :5: error: invalid operand for instruction + +exp , v3, v2, v1, v0 +// GCN: :5: error: unknown token in expression + +exp +// GCN: :1: error: too few operands for instruction exp mrt0 s0, v0, v0, v0 // GCN: 10: error: invalid operand for instruction diff --git a/llvm/test/MC/AMDGPU/exp-gfx10.s b/llvm/test/MC/AMDGPU/exp-gfx10.s --- a/llvm/test/MC/AMDGPU/exp-gfx10.s +++ b/llvm/test/MC/AMDGPU/exp-gfx10.s @@ -1,18 +1,15 @@ -// RUN: not llvm-mc -arch=amdgcn -mcpu=verde %s 2>&1 | FileCheck -check-prefix=SI --implicit-check-not=error: %s -// RUN: not llvm-mc -arch=amdgcn -mcpu=tonga %s 2>&1 | FileCheck -check-prefix=VI --implicit-check-not=error: %s +// RUN: not llvm-mc -arch=amdgcn -mcpu=verde %s 2>&1 | FileCheck -check-prefix=SIVI --implicit-check-not=error: %s +// RUN: not llvm-mc -arch=amdgcn -mcpu=tonga %s 2>&1 | FileCheck -check-prefix=SIVI --implicit-check-not=error: %s // RUN: llvm-mc -arch=amdgcn -mcpu=gfx1010 -show-encoding %s | FileCheck -check-prefix=GFX10 %s exp prim v1, off, off, off -// SI: :5: error: invalid operand for instruction -// VI: :5: error: invalid operand for instruction +// SIVI: :5: error: invalid exp target // GFX10: exp prim v1, off, off, off ; encoding: [0x41,0x01,0x00,0xf8,0x01,0x00,0x00,0x00] exp prim v2, v3, off, off -// SI: :5: error: invalid operand for instruction -// VI: :5: error: invalid operand for instruction +// SIVI: :5: error: invalid exp target // GFX10: exp prim v2, v3, off, off ; encoding: [0x43,0x01,0x00,0xf8,0x02,0x03,0x00,0x00] exp pos4 v4, v3, v2, v1 -// SI: error: invalid exp target -// VI: error: invalid exp target +// SIVI: error: invalid exp target // GFX10: exp pos4 v4, v3, v2, v1 ; encoding: [0x0f,0x01,0x00,0xf8,0x04,0x03,0x02,0x01]