Index: llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -1294,7 +1294,7 @@ bool (*ConvertResult)(int64_t&) = nullptr); OperandMatchResultTy - parseNamedBit(const char *Name, OperandVector &Operands, + parseNamedBit(StringRef Name, OperandVector &Operands, AMDGPUOperand::ImmTy ImmTy = AMDGPUOperand::ImmTyNone); OperandMatchResultTy parseStringWithPrefix(StringRef Prefix, StringRef &Value, @@ -1403,6 +1403,7 @@ bool isId(const AsmToken &Token, const StringRef Id) const; bool isToken(const AsmToken::TokenKind Kind) const; bool trySkipId(const StringRef Id); + bool trySkipId(const StringRef Pref, const StringRef Id); bool trySkipId(const StringRef Id, const AsmToken::TokenKind Kind); bool trySkipToken(const AsmToken::TokenKind Kind); bool skipToken(const AsmToken::TokenKind Kind, const StringRef ErrMsg); @@ -5043,39 +5044,31 @@ } OperandMatchResultTy -AMDGPUAsmParser::parseNamedBit(const char *Name, OperandVector &Operands, +AMDGPUAsmParser::parseNamedBit(StringRef Name, OperandVector &Operands, AMDGPUOperand::ImmTy ImmTy) { - int64_t Bit = 0; + int64_t Bit; SMLoc S = getLoc(); - // We are at the end of the statement, and this is a default argument, so - // use a default value. - if (!isToken(AsmToken::EndOfStatement)) { - switch(getTokenKind()) { - case AsmToken::Identifier: { - StringRef Tok = getTokenStr(); - if (Tok == Name) { - if (Tok == "r128" && !hasMIMG_R128()) - Error(S, "r128 modifier is not supported on this GPU"); - if (Tok == "a16" && !isGFX9() && !hasGFX10A16()) - Error(S, "a16 modifier is not supported on this GPU"); - Bit = 1; - Parser.Lex(); - } else if (Tok.startswith("no") && Tok.endswith(Name)) { - Bit = 0; - Parser.Lex(); - } else { - return MatchOperand_NoMatch; - } - break; - } - default: - return MatchOperand_NoMatch; - } + if (trySkipId(Name)) { + Bit = 1; + } else if (trySkipId("no", Name)) { + Bit = 0; + } else { + return MatchOperand_NoMatch; } - if (!isGFX10Plus() && ImmTy == AMDGPUOperand::ImmTyDLC) + if (Name == "r128" && !hasMIMG_R128()) { + Error(S, "r128 modifier is not supported on this GPU"); + return MatchOperand_ParseFail; + } + if (Name == "a16" && !isGFX9() && !hasGFX10A16()) { + Error(S, "a16 modifier is not supported on this GPU"); + return MatchOperand_ParseFail; + } + if (!isGFX10Plus() && ImmTy == AMDGPUOperand::ImmTyDLC) { + Error(S, "dlc modifier is not supported on this GPU"); return MatchOperand_ParseFail; + } if (isGFX9() && ImmTy == AMDGPUOperand::ImmTyA16) ImmTy = AMDGPUOperand::ImmTyR128A16; @@ -5933,6 +5926,18 @@ return false; } +bool +AMDGPUAsmParser::trySkipId(const StringRef Pref, const StringRef Id) { + if (isToken(AsmToken::Identifier)) { + StringRef Tok = getTokenStr(); + if (Tok.startswith(Pref) && Tok.substr(Pref.size()) == Id) { + lex(); + return true; + } + } + return false; +} + bool AMDGPUAsmParser::trySkipId(const StringRef Id, const AsmToken::TokenKind Kind) { if (isId(Id) && peekToken().is(Kind)) { Index: llvm/test/MC/AMDGPU/flat-global.s =================================================================== --- llvm/test/MC/AMDGPU/flat-global.s +++ llvm/test/MC/AMDGPU/flat-global.s @@ -12,7 +12,7 @@ global_load_ubyte v1, v[3:4], off dlc // GFX10: encoding: [0x00,0x90,0x20,0xdc,0x03,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_load_sbyte v1, v[3:4], off @@ -22,7 +22,7 @@ global_load_sbyte v1, v[3:4], off dlc // GFX10: encoding: [0x00,0x90,0x24,0xdc,0x03,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_load_ushort v1, v[3:4], off @@ -32,7 +32,7 @@ global_load_ushort v1, v[3:4], off dlc // GFX10: encoding: [0x00,0x90,0x28,0xdc,0x03,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_load_sshort v1, v[3:4], off @@ -42,7 +42,7 @@ global_load_sshort v1, v[3:4], off dlc // GFX10: encoding: [0x00,0x90,0x2c,0xdc,0x03,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_load_dword v1, v[3:4], off @@ -52,7 +52,7 @@ global_load_dword v1, v[3:4], off dlc // GFX10: encoding: [0x00,0x90,0x30,0xdc,0x03,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_load_dwordx2 v[1:2], v[3:4], off @@ -62,7 +62,7 @@ global_load_dwordx2 v[1:2], v[3:4], off dlc // GFX10: encoding: [0x00,0x90,0x34,0xdc,0x03,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_load_dwordx3 v[1:3], v[3:4], off @@ -72,7 +72,7 @@ global_load_dwordx3 v[1:3], v[3:4], off dlc // GFX10: encoding: [0x00,0x90,0x3c,0xdc,0x03,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_load_dwordx4 v[1:4], v[3:4], off @@ -82,7 +82,7 @@ global_load_dwordx4 v[1:4], v[3:4], off dlc // GFX10: encoding: [0x00,0x90,0x38,0xdc,0x03,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_load_dword v1, v[3:4], off offset:0 @@ -122,7 +122,7 @@ global_store_byte v[3:4], v1, off dlc // GFX10: encoding: [0x00,0x90,0x60,0xdc,0x03,0x01,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_store_short v[3:4], v1, off @@ -132,7 +132,7 @@ global_store_short v[3:4], v1, off dlc // GFX10: encoding: [0x00,0x90,0x68,0xdc,0x03,0x01,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_store_dword v[3:4], v1, off @@ -142,7 +142,7 @@ global_store_dword v[3:4], v1, off dlc // GFX10: encoding: [0x00,0x90,0x70,0xdc,0x03,0x01,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_store_dwordx2 v[3:4], v[1:2], off @@ -152,7 +152,7 @@ global_store_dwordx2 v[3:4], v[1:2], off dlc // GFX10: encoding: [0x00,0x90,0x74,0xdc,0x03,0x01,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_store_dwordx3 v[3:4], v[1:3], off @@ -162,7 +162,7 @@ global_store_dwordx3 v[3:4], v[1:3], off dlc // GFX10: encoding: [0x00,0x90,0x7c,0xdc,0x03,0x01,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_store_dwordx4 v[3:4], v[1:4], off @@ -172,7 +172,7 @@ global_store_dwordx4 v[3:4], v[1:4], off dlc // GFX10: encoding: [0x00,0x90,0x78,0xdc,0x03,0x01,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU global_store_dword v[3:4], v1, off offset:12 Index: llvm/test/MC/AMDGPU/flat-scratch-instructions.s =================================================================== --- llvm/test/MC/AMDGPU/flat-scratch-instructions.s +++ llvm/test/MC/AMDGPU/flat-scratch-instructions.s @@ -12,7 +12,7 @@ scratch_load_ubyte v1, v2, off dlc // GFX10: encoding: [0x00,0x50,0x20,0xdc,0x02,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_load_sbyte v1, v2, off @@ -22,7 +22,7 @@ scratch_load_sbyte v1, v2, off dlc // GFX10: encoding: [0x00,0x50,0x24,0xdc,0x02,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_load_ushort v1, v2, off @@ -32,7 +32,7 @@ scratch_load_ushort v1, v2, off dlc // GFX10: encoding: [0x00,0x50,0x28,0xdc,0x02,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_load_sshort v1, v2, off @@ -42,7 +42,7 @@ scratch_load_sshort v1, v2, off dlc // GFX10: encoding: [0x00,0x50,0x2c,0xdc,0x02,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_load_dword v1, v2, off @@ -52,7 +52,7 @@ scratch_load_dword v1, v2, off dlc // GFX10: encoding: [0x00,0x50,0x30,0xdc,0x02,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_load_dwordx2 v[1:2], v3, off @@ -62,7 +62,7 @@ scratch_load_dwordx2 v[1:2], v3, off dlc // GFX10: encoding: [0x00,0x50,0x34,0xdc,0x03,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_load_dwordx3 v[1:3], v4, off @@ -72,7 +72,7 @@ scratch_load_dwordx3 v[1:3], v4, off dlc // GFX10: encoding: [0x00,0x50,0x3c,0xdc,0x04,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_load_dwordx4 v[1:4], v5, off @@ -82,7 +82,7 @@ scratch_load_dwordx4 v[1:4], v5, off dlc // GFX10: encoding: [0x00,0x50,0x38,0xdc,0x05,0x00,0x7d,0x01] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_load_dword v1, v2, off offset:0 @@ -142,7 +142,7 @@ scratch_store_byte v1, v2, off dlc // GFX10: encoding: [0x00,0x50,0x60,0xdc,0x01,0x02,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_store_short v1, v2, off @@ -152,7 +152,7 @@ scratch_store_short v1, v2, off dlc // GFX10: encoding: [0x00,0x50,0x68,0xdc,0x01,0x02,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_store_dword v1, v2, off @@ -162,7 +162,7 @@ scratch_store_dword v1, v2, off dlc // GFX10: encoding: [0x00,0x50,0x70,0xdc,0x01,0x02,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_store_dwordx2 v1, v[2:3], off @@ -172,7 +172,7 @@ scratch_store_dwordx2 v1, v[2:3], off dlc // GFX10: encoding: [0x00,0x50,0x74,0xdc,0x01,0x02,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_store_dwordx3 v1, v[2:4], off @@ -182,7 +182,7 @@ scratch_store_dwordx3 v1, v[2:4], off dlc // GFX10: encoding: [0x00,0x50,0x7c,0xdc,0x01,0x02,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_store_dwordx4 v1, v[2:5], off @@ -192,7 +192,7 @@ scratch_store_dwordx4 v1, v[2:5], off dlc // GFX10: encoding: [0x00,0x50,0x78,0xdc,0x01,0x02,0x7d,0x00] -// GFX9-ERR: error: failed parsing operand +// GFX9-ERR: error: dlc modifier is not supported on this GPU // VI-ERR: error: instruction not supported on this GPU scratch_store_dword v1, v2, off offset:12 Index: llvm/test/MC/AMDGPU/gfx8_err_pos.s =================================================================== --- llvm/test/MC/AMDGPU/gfx8_err_pos.s +++ llvm/test/MC/AMDGPU/gfx8_err_pos.s @@ -8,6 +8,11 @@ // CHECK-NEXT:{{^}}image_gather4 v[5:8], v1, s[8:15], s[12:15] dmask:0x1 a16 // CHECK-NEXT:{{^}} ^ +image_gather4 v[5:8], v1, s[8:15], s[12:15] dmask:0x1 noa16 +// CHECK: error: a16 modifier is not supported on this GPU +// CHECK-NEXT:{{^}}image_gather4 v[5:8], v1, s[8:15], s[12:15] dmask:0x1 noa16 +// CHECK-NEXT:{{^}} ^ + //============================================================================== // expected a 20-bit unsigned offset Index: llvm/test/MC/AMDGPU/gfx9_err_pos.s =================================================================== --- llvm/test/MC/AMDGPU/gfx9_err_pos.s +++ llvm/test/MC/AMDGPU/gfx9_err_pos.s @@ -16,6 +16,19 @@ // CHECK-NEXT:{{^}}v_div_scale_f64 v[24:25], vcc, -|v[22:23]|, v[22:23], v[20:21] // CHECK-NEXT:{{^}}^ +//============================================================================== +// dlc modifier is not supported on this GPU + +scratch_load_ubyte v1, v2, off dlc +// CHECK: error: dlc modifier is not supported on this GPU +// CHECK-NEXT:{{^}}scratch_load_ubyte v1, v2, off dlc +// CHECK-NEXT:{{^}} ^ + +scratch_load_ubyte v1, v2, off nodlc +// CHECK: error: dlc modifier is not supported on this GPU +// CHECK-NEXT:{{^}}scratch_load_ubyte v1, v2, off nodlc +// CHECK-NEXT:{{^}} ^ + //============================================================================== // duplicate VGPR index mode @@ -173,6 +186,11 @@ // CHECK-NEXT:{{^}}image_atomic_add v10, v6, s[8:15] dmask:0x1 r128 // CHECK-NEXT:{{^}} ^ +image_atomic_add v10, v6, s[8:15] dmask:0x1 nor128 +// CHECK: error: r128 modifier is not supported on this GPU +// CHECK-NEXT:{{^}}image_atomic_add v10, v6, s[8:15] dmask:0x1 nor128 +// CHECK-NEXT:{{^}} ^ + //============================================================================== // unified format is not supported on this GPU Index: llvm/test/MC/AMDGPU/vop3-modifiers-err.s =================================================================== --- llvm/test/MC/AMDGPU/vop3-modifiers-err.s +++ llvm/test/MC/AMDGPU/vop3-modifiers-err.s @@ -13,3 +13,6 @@ v_ceil_f16 v0, abs(neg(1)) // CHECK: error: failed parsing operand + +v_cvt_f16_u16_e64 v5, s1 noXXXclamp +// CHECK: error: invalid operand for instruction Index: llvm/test/MC/AMDGPU/vop3-modifiers.s =================================================================== --- llvm/test/MC/AMDGPU/vop3-modifiers.s +++ llvm/test/MC/AMDGPU/vop3-modifiers.s @@ -386,3 +386,6 @@ // NB: output modifiers are not supported for f16 v_cvt_f16_u16_e64 v5, s1 clamp // CHECK: [0x05,0x80,0x79,0xd1,0x01,0x00,0x00,0x00] + +v_cvt_f16_u16_e64 v5, s1 noclamp +// CHECK: [0x05,0x00,0x79,0xd1,0x01,0x00,0x00,0x00]