Index: llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -1297,7 +1297,8 @@ parseNamedBit(const char *Name, OperandVector &Operands, AMDGPUOperand::ImmTy ImmTy = AMDGPUOperand::ImmTyNone); OperandMatchResultTy parseStringWithPrefix(StringRef Prefix, - StringRef &Value); + StringRef &Value, + SMLoc &StringLoc); bool isModifier(); bool isOperandModifier(const AsmToken &Token, const AsmToken &NextToken) const; @@ -5099,11 +5100,15 @@ } OperandMatchResultTy -AMDGPUAsmParser::parseStringWithPrefix(StringRef Prefix, StringRef &Value) { +AMDGPUAsmParser::parseStringWithPrefix(StringRef Prefix, + StringRef &Value, + SMLoc &StringLoc) { if (!trySkipId(Prefix, AsmToken::Colon)) return MatchOperand_NoMatch; - return parseId(Value) ? MatchOperand_Success : MatchOperand_ParseFail; + StringLoc = getLoc(); + return parseId(Value, "expected an identifier") ? MatchOperand_Success + : MatchOperand_ParseFail; } //===----------------------------------------------------------------------===// @@ -7523,7 +7528,8 @@ StringRef Value; OperandMatchResultTy res; - res = parseStringWithPrefix(Prefix, Value); + SMLoc StringLoc; + res = parseStringWithPrefix(Prefix, Value, StringLoc); if (res != MatchOperand_Success) { return res; } @@ -7540,6 +7546,7 @@ .Default(0xffffffff); if (Int == 0xffffffff) { + Error(StringLoc, "invalid " + Twine(Prefix) + " value"); return MatchOperand_ParseFail; } @@ -7555,7 +7562,8 @@ StringRef Value; OperandMatchResultTy res; - res = parseStringWithPrefix("dst_unused", Value); + SMLoc StringLoc; + res = parseStringWithPrefix("dst_unused", Value, StringLoc); if (res != MatchOperand_Success) { return res; } @@ -7568,6 +7576,7 @@ .Default(0xffffffff); if (Int == 0xffffffff) { + Error(StringLoc, "invalid dst_unused value"); return MatchOperand_ParseFail; } Index: llvm/test/MC/AMDGPU/gfx10_err_pos.s =================================================================== --- llvm/test/MC/AMDGPU/gfx10_err_pos.s +++ llvm/test/MC/AMDGPU/gfx10_err_pos.s @@ -483,6 +483,24 @@ // CHECK-NEXT:{{^}}v_mov_b32_sdwa v1, sext(u) // CHECK-NEXT:{{^}} ^ +//============================================================================== +// expected an identifier + +v_mov_b32_sdwa v5, v1 dst_sel: +// CHECK: error: expected an identifier +// CHECK-NEXT:{{^}}v_mov_b32_sdwa v5, v1 dst_sel: +// CHECK-NEXT:{{^}} ^ + +v_mov_b32_sdwa v5, v1 dst_sel:0 +// CHECK: error: expected an identifier +// CHECK-NEXT:{{^}}v_mov_b32_sdwa v5, v1 dst_sel:0 +// CHECK-NEXT:{{^}} ^ + +v_mov_b32_sdwa v5, v1 dst_sel:DWORD dst_unused:[UNUSED_PAD] +// CHECK: error: expected an identifier +// CHECK-NEXT:{{^}}v_mov_b32_sdwa v5, v1 dst_sel:DWORD dst_unused:[UNUSED_PAD] +// CHECK-NEXT:{{^}} ^ + //============================================================================== // expected an opening square bracket @@ -623,6 +641,22 @@ // CHECK-NEXT:{{^}}s_waitcnt vmcnt(0) & expcnt(0) x(0) // CHECK-NEXT:{{^}} ^ +//============================================================================== +// invalid dst_sel value + +v_mov_b32_sdwa v5, v1 dst_sel:WORD +// CHECK: error: invalid dst_sel value +// CHECK-NEXT:{{^}}v_mov_b32_sdwa v5, v1 dst_sel:WORD +// CHECK-NEXT:{{^}} ^ + +//============================================================================== +// invalid dst_unused value + +v_mov_b32_sdwa v5, v1 dst_unused:UNUSED +// CHECK: error: invalid dst_unused value +// CHECK-NEXT:{{^}}v_mov_b32_sdwa v5, v1 dst_unused:UNUSED +// CHECK-NEXT:{{^}} ^ + //============================================================================== // invalid exp target