forked from OSchip/llvm-project
[AMDGPU][MC] Corrected parsing of NAME:VALUE modifiers
See bug 41298: https://bugs.llvm.org/show_bug.cgi?id=41298 Reviewers: artem.tamazov, arsenm Differential Revision: https://reviews.llvm.org/D61009 llvm-svn: 361045
This commit is contained in:
parent
64c756b991
commit
198611b0ff
|
@ -1157,6 +1157,7 @@ private:
|
|||
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 @@ bool AMDGPUAsmParser::ParseInstruction(ParseInstructionInfo &Info,
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
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;
|
||||
if (!trySkipId(Prefix, AsmToken::Colon))
|
||||
return MatchOperand_NoMatch;
|
||||
|
||||
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 (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 @@ AMDGPUAsmParser::parseIntWithPrefix(const char *Prefix, OperandVector &Operands,
|
|||
return Res;
|
||||
|
||||
if (ConvertResult && !ConvertResult(Value)) {
|
||||
return MatchOperand_ParseFail;
|
||||
Error(S, "invalid " + StringRef(Prefix) + " value.");
|
||||
}
|
||||
|
||||
Operands.push_back(AMDGPUOperand::CreateImm(this, Value, S, ImmTy));
|
||||
|
@ -4968,6 +4942,16 @@ AMDGPUAsmParser::trySkipId(const StringRef Id) {
|
|||
return false;
|
||||
}
|
||||
|
||||
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)) {
|
||||
|
|
|
@ -162,6 +162,22 @@ v_and_b32 v0, -i1+102, v0
|
|||
v_add_u16 v0, (i1+100)*2, v0
|
||||
// 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.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -46,6 +46,13 @@ v_cmp_le_f64_e64 vcc, v0, v1 mul:4
|
|||
v_cvt_u32_f32_e64 v0, v1 div:2
|
||||
// GCN: error: invalid operand for instruction
|
||||
|
||||
//
|
||||
// mul
|
||||
//
|
||||
|
||||
v_cvt_f64_i32 v[5:6], s1 mul:3
|
||||
// GCN: error: invalid mul value.
|
||||
|
||||
//
|
||||
// v_interp*
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue