[llvm] 0e79111 - [AVR][BPF][Lanai][Xtensa] Replace OperandMatchResultTy with ParseStatus (NFC)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 20 04:20:45 PDT 2023
Author: Sergei Barannikov
Date: 2023-08-20T14:20:28+03:00
New Revision: 0e79111e4d633f523fdc8b5ea91ea416320b37a5
URL: https://github.com/llvm/llvm-project/commit/0e79111e4d633f523fdc8b5ea91ea416320b37a5
DIFF: https://github.com/llvm/llvm-project/commit/0e79111e4d633f523fdc8b5ea91ea416320b37a5.diff
LOG: [AVR][BPF][Lanai][Xtensa] Replace OperandMatchResultTy with ParseStatus (NFC)
ParseStatus is slightly more convenient to use due to implicit
conversion from bool, which allows to do something like:
```
return Error(L, "msg");
```
when with MatchOperandResultTy it had to be:
```
Error(L, "msg");
return MatchOperand_ParseFail;
```
It also has more appropriate name since parse* methods are not only for
parsing operands.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D158275
Added:
Modified:
llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
index 6c328ffc58a466..d87a51203734f0 100644
--- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
+++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
@@ -66,7 +66,7 @@ class AVRAsmParser : public MCTargetAsmParser {
ParseStatus parseDirective(AsmToken DirectiveID) override;
- OperandMatchResultTy parseMemriOperand(OperandVector &Operands);
+ ParseStatus parseMemriOperand(OperandVector &Operands);
bool parseOperand(OperandVector &Operands, bool maybeReg);
int parseRegisterName(unsigned (*matchFn)(StringRef));
@@ -559,7 +559,7 @@ bool AVRAsmParser::parseOperand(OperandVector &Operands, bool maybeReg) {
return true;
}
-OperandMatchResultTy AVRAsmParser::parseMemriOperand(OperandVector &Operands) {
+ParseStatus AVRAsmParser::parseMemriOperand(OperandVector &Operands) {
LLVM_DEBUG(dbgs() << "parseMemriOperand()\n");
SMLoc E, S;
@@ -571,7 +571,7 @@ OperandMatchResultTy AVRAsmParser::parseMemriOperand(OperandVector &Operands) {
RegNo = parseRegister();
if (RegNo == AVR::NoRegister)
- return MatchOperand_ParseFail;
+ return ParseStatus::Failure;
S = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
Parser.Lex(); // Eat register token.
@@ -580,14 +580,14 @@ OperandMatchResultTy AVRAsmParser::parseMemriOperand(OperandVector &Operands) {
// Parse immediate;
{
if (getParser().parseExpression(Expression))
- return MatchOperand_ParseFail;
+ return ParseStatus::Failure;
E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
}
Operands.push_back(AVROperand::CreateMemri(RegNo, Expression, S, E));
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
bool AVRAsmParser::parseRegister(MCRegister &RegNo, SMLoc &StartLoc,
@@ -630,13 +630,12 @@ bool AVRAsmParser::ParseInstruction(ParseInstructionInfo &Info,
if (OperandNum > 0)
eatComma();
- auto MatchResult = MatchOperandParserImpl(Operands, Mnemonic);
+ ParseStatus ParseRes = MatchOperandParserImpl(Operands, Mnemonic);
- if (MatchResult == MatchOperand_Success) {
+ if (ParseRes.isSuccess())
continue;
- }
- if (MatchResult == MatchOperand_ParseFail) {
+ if (ParseRes.isFailure()) {
SMLoc Loc = getLexer().getLoc();
Parser.eatToEndOfStatement();
diff --git a/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp b/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
index a9bdccb229c629..f872df00ffee11 100644
--- a/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
+++ b/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
@@ -57,9 +57,9 @@ class BPFAsmParser : public MCTargetAsmParser {
#define GET_ASSEMBLER_HEADER
#include "BPFGenAsmMatcher.inc"
- OperandMatchResultTy parseImmediate(OperandVector &Operands);
- OperandMatchResultTy parseRegister(OperandVector &Operands);
- OperandMatchResultTy parseOperandAsOperator(OperandVector &Operands);
+ ParseStatus parseImmediate(OperandVector &Operands);
+ ParseStatus parseRegister(OperandVector &Operands);
+ ParseStatus parseOperandAsOperator(OperandVector &Operands);
public:
enum BPFMatchResultTy {
@@ -362,8 +362,7 @@ OperandMatchResultTy BPFAsmParser::tryParseRegister(MCRegister &RegNo,
return MatchOperand_NoMatch;
}
-OperandMatchResultTy
-BPFAsmParser::parseOperandAsOperator(OperandVector &Operands) {
+ParseStatus BPFAsmParser::parseOperandAsOperator(OperandVector &Operands) {
SMLoc S = getLoc();
if (getLexer().getKind() == AsmToken::Identifier) {
@@ -372,17 +371,17 @@ BPFAsmParser::parseOperandAsOperator(OperandVector &Operands) {
if (BPFOperand::isValidIdInMiddle(Name)) {
getLexer().Lex();
Operands.push_back(BPFOperand::createToken(Name, S));
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
}
switch (getLexer().getKind()) {
case AsmToken::Minus:
case AsmToken::Plus: {
if (getLexer().peekTok().is(AsmToken::Integer))
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
[[fallthrough]];
}
@@ -403,7 +402,7 @@ BPFAsmParser::parseOperandAsOperator(OperandVector &Operands) {
getLexer().Lex();
Operands.push_back(BPFOperand::createToken(Name, S));
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
case AsmToken::EqualEqual:
@@ -418,40 +417,40 @@ BPFAsmParser::parseOperandAsOperator(OperandVector &Operands) {
getLexer().getTok().getString().substr(1, 1), S));
getLexer().Lex();
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
default:
break;
}
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
}
-OperandMatchResultTy BPFAsmParser::parseRegister(OperandVector &Operands) {
+ParseStatus BPFAsmParser::parseRegister(OperandVector &Operands) {
SMLoc S = getLoc();
SMLoc E = SMLoc::getFromPointer(S.getPointer() - 1);
switch (getLexer().getKind()) {
default:
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
case AsmToken::Identifier:
StringRef Name = getLexer().getTok().getIdentifier();
unsigned RegNo = MatchRegisterName(Name);
if (RegNo == 0)
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
getLexer().Lex();
Operands.push_back(BPFOperand::createReg(RegNo, S, E));
}
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
-OperandMatchResultTy BPFAsmParser::parseImmediate(OperandVector &Operands) {
+ParseStatus BPFAsmParser::parseImmediate(OperandVector &Operands) {
switch (getLexer().getKind()) {
default:
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
case AsmToken::LParen:
case AsmToken::Minus:
case AsmToken::Plus:
@@ -465,12 +464,12 @@ OperandMatchResultTy BPFAsmParser::parseImmediate(OperandVector &Operands) {
SMLoc S = getLoc();
if (getParser().parseExpression(IdVal))
- return MatchOperand_ParseFail;
+ return ParseStatus::Failure;
SMLoc E = SMLoc::getFromPointer(S.getPointer() - 1);
Operands.push_back(BPFOperand::createImm(IdVal, S, E));
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
/// ParseInstruction - Parse an BPF instruction which is in BPF verifier
@@ -490,11 +489,11 @@ bool BPFAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
while (!getLexer().is(AsmToken::EndOfStatement)) {
// Attempt to parse token as operator
- if (parseOperandAsOperator(Operands) == MatchOperand_Success)
+ if (parseOperandAsOperator(Operands).isSuccess())
continue;
// Attempt to parse token as register
- if (parseRegister(Operands) == MatchOperand_Success)
+ if (parseRegister(Operands).isSuccess())
continue;
if (getLexer().is(AsmToken::Comma)) {
@@ -503,7 +502,7 @@ bool BPFAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
}
// Attempt to parse token as an immediate
- if (parseImmediate(Operands) != MatchOperand_Success) {
+ if (!parseImmediate(Operands).isSuccess()) {
SMLoc Loc = getLexer().getLoc();
return Error(Loc, "unexpected token");
}
diff --git a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
index 6b74423f9bc577..8be8f9c45809ff 100644
--- a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
+++ b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
@@ -79,10 +79,9 @@ class LanaiAsmParser : public MCTargetAsmParser {
#define GET_ASSEMBLER_HEADER
#include "LanaiGenAsmMatcher.inc"
- OperandMatchResultTy parseOperand(OperandVector *Operands,
- StringRef Mnemonic);
+ ParseStatus parseOperand(OperandVector *Operands, StringRef Mnemonic);
- OperandMatchResultTy parseMemoryOperand(OperandVector &Operands);
+ ParseStatus parseMemoryOperand(OperandVector &Operands);
public:
LanaiAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser,
@@ -885,8 +884,7 @@ bool shouldBeSls(const LanaiOperand &Op) {
}
// Matches memory operand. Returns true if error encountered.
-OperandMatchResultTy
-LanaiAsmParser::parseMemoryOperand(OperandVector &Operands) {
+ParseStatus LanaiAsmParser::parseMemoryOperand(OperandVector &Operands) {
// Try to match a memory operand.
// The memory operands are of the form:
// (1) Register|Immediate|'' '[' '*'? Register '*'? ']' or
@@ -916,13 +914,13 @@ LanaiAsmParser::parseMemoryOperand(OperandVector &Operands) {
// Only continue if next token is '['
if (Lexer.isNot(AsmToken::LBrac)) {
if (!Op)
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
// The start of this custom parsing overlaps with register/immediate so
// consider this as a successful match of an operand of that type as the
// token stream can't be rewound to allow them to match separately.
Operands.push_back(std::move(Op));
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
Parser.Lex(); // Eat the '['.
@@ -944,22 +942,19 @@ LanaiAsmParser::parseMemoryOperand(OperandVector &Operands) {
if (shouldBeSls(*Op)) {
Operands.push_back(LanaiOperand::MorphToMemImm(std::move(Op)));
} else {
- if (!Op->isLoImm16Signed()) {
- Error(Parser.getTok().getLoc(),
- "Memory address is not word "
- "aligned and larger than class RM can handle");
- return MatchOperand_ParseFail;
- }
+ if (!Op->isLoImm16Signed())
+ return Error(Parser.getTok().getLoc(),
+ "Memory address is not word aligned and larger than "
+ "class RM can handle");
Operands.push_back(LanaiOperand::MorphToMemRegImm(
Lanai::R0, std::move(Op), LPAC::ADD));
}
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
}
- Error(Parser.getTok().getLoc(),
- "Unknown operand, expected register or immediate");
- return MatchOperand_ParseFail;
+ return Error(Parser.getTok().getLoc(),
+ "Unknown operand, expected register or immediate");
}
BaseReg = Op->getReg();
@@ -979,20 +974,16 @@ LanaiAsmParser::parseMemoryOperand(OperandVector &Operands) {
Offset = LanaiOperand::createImm(OffsetConstExpr, Start, End);
}
} else {
- if (Offset || OffsetValue != 0) {
- Error(Parser.getTok().getLoc(), "Expected ']'");
- return MatchOperand_ParseFail;
- }
+ if (Offset || OffsetValue != 0)
+ return Error(Parser.getTok().getLoc(), "Expected ']'");
// Parse operator
AluOp = parseAluOperator(PreOp, PostOp);
// Second form requires offset register
Offset = parseRegister();
- if (!BaseReg || Lexer.isNot(AsmToken::RBrac)) {
- Error(Parser.getTok().getLoc(), "Expected ']'");
- return MatchOperand_ParseFail;
- }
+ if (!BaseReg || Lexer.isNot(AsmToken::RBrac))
+ return Error(Parser.getTok().getLoc(), "Expected ']'");
Parser.Lex(); // Eat the ']'.
}
@@ -1001,33 +992,31 @@ LanaiAsmParser::parseMemoryOperand(OperandVector &Operands) {
AluOp = AluWithPrePost(AluOp, PreOp, PostOp);
// Ensure immediate offset is not too large
- if (Offset->isImm() && !Offset->isLoImm16Signed()) {
- Error(Parser.getTok().getLoc(),
- "Memory address is not word "
- "aligned and larger than class RM can handle");
- return MatchOperand_ParseFail;
- }
+ if (Offset->isImm() && !Offset->isLoImm16Signed())
+ return Error(Parser.getTok().getLoc(),
+ "Memory address is not word aligned and larger than class RM "
+ "can handle");
Operands.push_back(
Offset->isImm()
? LanaiOperand::MorphToMemRegImm(BaseReg, std::move(Offset), AluOp)
: LanaiOperand::MorphToMemRegReg(BaseReg, std::move(Offset), AluOp));
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
// Looks at a token type and creates the relevant operand from this
// information, adding to operands.
// If operand was parsed, returns false, else true.
-OperandMatchResultTy
-LanaiAsmParser::parseOperand(OperandVector *Operands, StringRef Mnemonic) {
+ParseStatus LanaiAsmParser::parseOperand(OperandVector *Operands,
+ StringRef Mnemonic) {
// Check if the current operand has a custom associated parser, if so, try to
// custom parse the operand, or fallback to the general approach.
- OperandMatchResultTy Result = MatchOperandParserImpl(*Operands, Mnemonic);
+ ParseStatus Result = MatchOperandParserImpl(*Operands, Mnemonic);
- if (Result == MatchOperand_Success)
+ if (Result.isSuccess())
return Result;
- if (Result == MatchOperand_ParseFail) {
+ if (Result.isFailure()) {
Parser.eatToEndOfStatement();
return Result;
}
@@ -1043,13 +1032,13 @@ LanaiAsmParser::parseOperand(OperandVector *Operands, StringRef Mnemonic) {
if (!Op) {
Error(Parser.getTok().getLoc(), "Unknown operand");
Parser.eatToEndOfStatement();
- return MatchOperand_ParseFail;
+ return ParseStatus::Failure;
}
// Push back parsed operand into list of operands
Operands->push_back(std::move(Op));
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
// Split the mnemonic into ASM operand, conditional code and instruction
@@ -1189,7 +1178,7 @@ bool LanaiAsmParser::ParseInstruction(ParseInstructionInfo & /*Info*/,
return false;
// Parse first operand
- if (parseOperand(&Operands, Mnemonic) != MatchOperand_Success)
+ if (!parseOperand(&Operands, Mnemonic).isSuccess())
return true;
// If it is a st instruction with one 1 operand then it is a "store true".
@@ -1219,7 +1208,7 @@ bool LanaiAsmParser::ParseInstruction(ParseInstructionInfo & /*Info*/,
Lex();
// Parse next operand
- if (parseOperand(&Operands, Mnemonic) != MatchOperand_Success)
+ if (!parseOperand(&Operands, Mnemonic).isSuccess())
return true;
}
diff --git a/llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp b/llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp
index 8ffe1253aa018f..042efb7c42aa85 100644
--- a/llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp
+++ b/llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp
@@ -35,8 +35,8 @@ class XtensaAsmParser : public MCTargetAsmParser {
SMLoc getLoc() const { return getParser().getTok().getLoc(); }
- bool parseRegister(MCRegister &RegNo,
- SMLoc &StartLoc, SMLoc &EndLoc) override;
+ bool parseRegister(MCRegister &RegNo, SMLoc &StartLoc,
+ SMLoc &EndLoc) override;
bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
SMLoc NameLoc, OperandVector &Operands) override;
bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
@@ -50,10 +50,10 @@ class XtensaAsmParser : public MCTargetAsmParser {
#define GET_ASSEMBLER_HEADER
#include "XtensaGenAsmMatcher.inc"
- OperandMatchResultTy parseImmediate(OperandVector &Operands);
- OperandMatchResultTy parseRegister(OperandVector &Operands,
- bool AllowParens = false, bool SR = false);
- OperandMatchResultTy parseOperandWithModifier(OperandVector &Operands);
+ ParseStatus parseImmediate(OperandVector &Operands);
+ ParseStatus parseRegister(OperandVector &Operands, bool AllowParens = false,
+ bool SR = false);
+ ParseStatus parseOperandWithModifier(OperandVector &Operands);
bool parseOperand(OperandVector &Operands, StringRef Mnemonic,
bool SR = false);
bool ParseInstructionWithSR(ParseInstructionInfo &Info, StringRef Name,
@@ -62,7 +62,7 @@ class XtensaAsmParser : public MCTargetAsmParser {
SMLoc &EndLoc) override {
return MatchOperand_NoMatch;
}
- OperandMatchResultTy parsePCRelTarget(OperandVector &Operands);
+ ParseStatus parsePCRelTarget(OperandVector &Operands);
public:
enum XtensaMatchResultTy {
@@ -432,8 +432,7 @@ bool XtensaAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
report_fatal_error("Unknown match type detected!");
}
-OperandMatchResultTy
-XtensaAsmParser::parsePCRelTarget(OperandVector &Operands) {
+ParseStatus XtensaAsmParser::parsePCRelTarget(OperandVector &Operands) {
MCAsmParser &Parser = getParser();
LLVM_DEBUG(dbgs() << "parsePCRelTarget\n");
@@ -443,17 +442,15 @@ XtensaAsmParser::parsePCRelTarget(OperandVector &Operands) {
const MCExpr *Expr = nullptr;
if (Parser.parseExpression(Expr)) {
// We have no way of knowing if a symbol was consumed so we must ParseFail
- return MatchOperand_ParseFail;
+ return ParseStatus::Failure;
}
// Currently not support constants
- if (Expr->getKind() == MCExpr::ExprKind::Constant) {
- Error(getLoc(), "unknown operand");
- return MatchOperand_ParseFail;
- }
+ if (Expr->getKind() == MCExpr::ExprKind::Constant)
+ return Error(getLoc(), "unknown operand");
Operands.push_back(XtensaOperand::createImm(Expr, S, getLexer().getLoc()));
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
bool XtensaAsmParser::parseRegister(MCRegister &RegNo, SMLoc &StartLoc,
@@ -472,8 +469,8 @@ bool XtensaAsmParser::parseRegister(MCRegister &RegNo, SMLoc &StartLoc,
return Error(StartLoc, "invalid register name");
}
-OperandMatchResultTy XtensaAsmParser::parseRegister(OperandVector &Operands,
- bool AllowParens, bool SR) {
+ParseStatus XtensaAsmParser::parseRegister(OperandVector &Operands,
+ bool AllowParens, bool SR) {
SMLoc FirstS = getLoc();
bool HadParens = false;
AsmToken Buf[2];
@@ -484,7 +481,7 @@ OperandMatchResultTy XtensaAsmParser::parseRegister(OperandVector &Operands,
size_t ReadCount = getLexer().peekTokens(Buf);
if (ReadCount == 2 && Buf[1].getKind() == AsmToken::RParen) {
if ((Buf[0].getKind() == AsmToken::Integer) && (!SR))
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
HadParens = true;
getParser().Lex(); // Eat '('
}
@@ -494,10 +491,10 @@ OperandMatchResultTy XtensaAsmParser::parseRegister(OperandVector &Operands,
switch (getLexer().getKind()) {
default:
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
case AsmToken::Integer:
if (!SR)
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
RegName = StringRef(std::to_string(getLexer().getTok().getIntVal()));
RegNo = MatchRegisterName(RegName);
if (RegNo == 0)
@@ -514,7 +511,7 @@ OperandMatchResultTy XtensaAsmParser::parseRegister(OperandVector &Operands,
if (RegNo == 0) {
if (HadParens)
getLexer().UnLex(Buf[0]);
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
}
if (HadParens)
Operands.push_back(XtensaOperand::createToken("(", FirstS));
@@ -528,17 +525,17 @@ OperandMatchResultTy XtensaAsmParser::parseRegister(OperandVector &Operands,
Operands.push_back(XtensaOperand::createToken(")", getLoc()));
}
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
-OperandMatchResultTy XtensaAsmParser::parseImmediate(OperandVector &Operands) {
+ParseStatus XtensaAsmParser::parseImmediate(OperandVector &Operands) {
SMLoc S = getLoc();
SMLoc E;
const MCExpr *Res;
switch (getLexer().getKind()) {
default:
- return MatchOperand_NoMatch;
+ return ParseStatus::NoMatch;
case AsmToken::LParen:
case AsmToken::Minus:
case AsmToken::Plus:
@@ -546,12 +543,12 @@ OperandMatchResultTy XtensaAsmParser::parseImmediate(OperandVector &Operands) {
case AsmToken::Integer:
case AsmToken::String:
if (getParser().parseExpression(Res))
- return MatchOperand_ParseFail;
+ return ParseStatus::Failure;
break;
case AsmToken::Identifier: {
StringRef Identifier;
if (getParser().parseIdentifier(Identifier))
- return MatchOperand_ParseFail;
+ return ParseStatus::Failure;
MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier);
Res = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, getContext());
@@ -563,12 +560,11 @@ OperandMatchResultTy XtensaAsmParser::parseImmediate(OperandVector &Operands) {
E = SMLoc::getFromPointer(S.getPointer() - 1);
Operands.push_back(XtensaOperand::createImm(Res, S, E));
- return MatchOperand_Success;
+ return ParseStatus::Success;
}
-OperandMatchResultTy
-XtensaAsmParser::parseOperandWithModifier(OperandVector &Operands) {
- return MatchOperand_ParseFail;
+ParseStatus XtensaAsmParser::parseOperandWithModifier(OperandVector &Operands) {
+ return ParseStatus::Failure;
}
/// Looks at a token type and creates the relevant operand
@@ -578,28 +574,26 @@ bool XtensaAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic,
bool SR) {
// Check if the current operand has a custom associated parser, if so, try to
// custom parse the operand, or fallback to the general approach.
- OperandMatchResultTy ResTy = MatchOperandParserImpl(Operands, Mnemonic);
- if (ResTy == MatchOperand_Success)
+ ParseStatus Res = MatchOperandParserImpl(Operands, Mnemonic);
+ if (Res.isSuccess())
return false;
// If there wasn't a custom match, try the generic matcher below. Otherwise,
// there was a match, but an error occurred, in which case, just return that
// the operand parsing failed.
- if (ResTy == MatchOperand_ParseFail)
+ if (Res.isFailure())
return true;
// Attempt to parse token as register
- if (parseRegister(Operands, true, SR) == MatchOperand_Success)
+ if (parseRegister(Operands, true, SR).isSuccess())
return false;
// Attempt to parse token as an immediate
- if (parseImmediate(Operands) == MatchOperand_Success) {
+ if (parseImmediate(Operands).isSuccess())
return false;
- }
// Finally we have exhausted all options and must declare defeat.
- Error(getLoc(), "unknown operand");
- return true;
+ return Error(getLoc(), "unknown operand");
}
bool XtensaAsmParser::ParseInstructionWithSR(ParseInstructionInfo &Info,
@@ -620,10 +614,8 @@ bool XtensaAsmParser::ParseInstructionWithSR(ParseInstructionInfo &Info,
if (RegNo == 0)
RegNo = MatchRegisterAltName(RegName);
- if (RegNo == 0) {
- Error(NameLoc, "invalid register name");
- return true;
- }
+ if (RegNo == 0)
+ return Error(NameLoc, "invalid register name");
// Parse operand
if (parseOperand(Operands, Name))
More information about the llvm-commits
mailing list