Index: llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -1157,6 +1157,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 Id, const AsmToken::TokenKind Kind); bool trySkipToken(const AsmToken::TokenKind Kind); bool skipToken(const AsmToken::TokenKind Kind, const StringRef ErrMsg); bool parseString(StringRef &Val, const StringRef ErrMsg = "expected a string"); @@ -4039,46 +4040,19 @@ //===----------------------------------------------------------------------===// OperandMatchResultTy -AMDGPUAsmParser::parseIntWithPrefix(const char *Prefix, int64_t &Int) { - switch(getLexer().getKind()) { - default: return MatchOperand_NoMatch; - case AsmToken::Identifier: { - StringRef Name = Parser.getTok().getString(); - if (!Name.equals(Prefix)) { - return MatchOperand_NoMatch; - } +AMDGPUAsmParser::parseIntWithPrefix(const char *Prefix, int64_t &IntVal) { - Parser.Lex(); - if (getLexer().isNot(AsmToken::Colon)) - return MatchOperand_ParseFail; - - Parser.Lex(); - - bool IsMinus = false; - if (getLexer().getKind() == AsmToken::Minus) { - Parser.Lex(); - IsMinus = true; - } - - if (getLexer().isNot(AsmToken::Integer)) - return MatchOperand_ParseFail; - - if (getParser().parseAbsoluteExpression(Int)) - return MatchOperand_ParseFail; + if (!trySkipId(Prefix, AsmToken::Colon)) + return MatchOperand_NoMatch; - if (IsMinus) - Int = -Int; - break; - } - } - return MatchOperand_Success; + return parseExpr(IntVal) ? MatchOperand_Success : MatchOperand_ParseFail; } OperandMatchResultTy AMDGPUAsmParser::parseIntWithPrefix(const char *Prefix, OperandVector &Operands, AMDGPUOperand::ImmTy ImmTy, bool (*ConvertResult)(int64_t&)) { - SMLoc S = Parser.getTok().getLoc(); + SMLoc S = getLoc(); int64_t Value = 0; OperandMatchResultTy Res = parseIntWithPrefix(Prefix, Value); @@ -4086,7 +4060,7 @@ return Res; if (ConvertResult && !ConvertResult(Value)) { - return MatchOperand_ParseFail; + Error(S, "invalid " + StringRef(Prefix) + " value."); } Operands.push_back(AMDGPUOperand::CreateImm(this, Value, S, ImmTy)); @@ -4969,6 +4943,16 @@ } bool +AMDGPUAsmParser::trySkipId(const StringRef Id, const AsmToken::TokenKind Kind) { + if (isId(Id) && peekToken().is(Kind)) { + lex(); + lex(); + return true; + } + return false; +} + +bool AMDGPUAsmParser::trySkipToken(const AsmToken::TokenKind Kind) { if (isToken(Kind)) { lex(); Index: llvm/trunk/test/MC/AMDGPU/expressions.s =================================================================== --- llvm/trunk/test/MC/AMDGPU/expressions.s +++ llvm/trunk/test/MC/AMDGPU/expressions.s @@ -163,6 +163,22 @@ // VI: v_add_u16_e32 v0, 0xca, v0 ; encoding: [0xff,0x00,0x00,0x4c,0xca,0x00,0x00,0x00] //===----------------------------------------------------------------------===// +// Constant expressions may be used with Name:Value modifiers. +//===----------------------------------------------------------------------===// + +buffer_load_dword v1, off, s[4:7], s1 offset:-1+1 +// VI: buffer_load_dword v1, off, s[4:7], s1 ; encoding: [0x00,0x00,0x50,0xe0,0x00,0x01,0x01,0x01] + +buffer_load_dword v1, off, s[4:7], s1 offset:i1+4 +// VI: buffer_load_dword v1, off, s[4:7], s1 offset:5 ; encoding: [0x05,0x00,0x50,0xe0,0x00,0x01,0x01,0x01] + +buffer_load_dword v1, off, s[4:7], s1 offset:4+i1 +// VI: buffer_load_dword v1, off, s[4:7], s1 offset:5 ; encoding: [0x05,0x00,0x50,0xe0,0x00,0x01,0x01,0x01] + +buffer_load_dword v1, off, s[4:7], s1 offset:-i1+4 +// VI: buffer_load_dword v1, off, s[4:7], s1 offset:3 ; encoding: [0x03,0x00,0x50,0xe0,0x00,0x01,0x01,0x01] + +//===----------------------------------------------------------------------===// // Relocatable expressions can be used with 32-bit instructions. //===----------------------------------------------------------------------===// Index: llvm/trunk/test/MC/AMDGPU/vop3-errs.s =================================================================== --- llvm/trunk/test/MC/AMDGPU/vop3-errs.s +++ llvm/trunk/test/MC/AMDGPU/vop3-errs.s @@ -47,6 +47,13 @@ // GCN: error: invalid operand for instruction // +// mul +// + +v_cvt_f64_i32 v[5:6], s1 mul:3 +// GCN: error: invalid mul value. + +// // v_interp* //