forked from OSchip/llvm-project
[AArch64][AsmParser] Split index parsing from vector list.
Summary: Place parsing of a vector index into a separate function to reduce duplication, since the code is duplicated in both the parsing of a Neon vector register operand and a Neon vector list. This is patch [2/6] in a series to add assembler/disassembler support for SVE's contiguous ST1 (scalar+imm) instructions. Reviewers: fhahn, rengolin, javed.absar, huntergr, SjoerdMeijer, t.p.northover, echristo, evandro Reviewed By: rengolin Subscribers: kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D45428 llvm-svn: 329809
This commit is contained in:
parent
f26b723491
commit
c88f9a1a57
|
@ -88,7 +88,7 @@ private:
|
||||||
int tryParseRegister();
|
int tryParseRegister();
|
||||||
bool parseRegister(OperandVector &Operands);
|
bool parseRegister(OperandVector &Operands);
|
||||||
bool parseSymbolicImmVal(const MCExpr *&ImmVal);
|
bool parseSymbolicImmVal(const MCExpr *&ImmVal);
|
||||||
bool parseVectorList(OperandVector &Operands);
|
bool parseNeonVectorList(OperandVector &Operands);
|
||||||
bool parseOperand(OperandVector &Operands, bool isCondCode,
|
bool parseOperand(OperandVector &Operands, bool isCondCode,
|
||||||
bool invertCondCode);
|
bool invertCondCode);
|
||||||
|
|
||||||
|
@ -135,10 +135,12 @@ private:
|
||||||
OperandMatchResultTy tryParseAddSubImm(OperandVector &Operands);
|
OperandMatchResultTy tryParseAddSubImm(OperandVector &Operands);
|
||||||
OperandMatchResultTy tryParseGPR64sp0Operand(OperandVector &Operands);
|
OperandMatchResultTy tryParseGPR64sp0Operand(OperandVector &Operands);
|
||||||
bool tryParseNeonVectorRegister(OperandVector &Operands);
|
bool tryParseNeonVectorRegister(OperandVector &Operands);
|
||||||
|
OperandMatchResultTy tryParseVectorIndex(OperandVector &Operands);
|
||||||
OperandMatchResultTy tryParseGPRSeqPair(OperandVector &Operands);
|
OperandMatchResultTy tryParseGPRSeqPair(OperandVector &Operands);
|
||||||
template <bool ParseSuffix>
|
template <bool ParseSuffix>
|
||||||
OperandMatchResultTy tryParseSVEDataVector(OperandVector &Operands);
|
OperandMatchResultTy tryParseSVEDataVector(OperandVector &Operands);
|
||||||
OperandMatchResultTy tryParseSVEPredicateVector(OperandVector &Operands);
|
OperandMatchResultTy tryParseSVEPredicateVector(OperandVector &Operands);
|
||||||
|
bool tryParseVectorList(OperandVector &Operands);
|
||||||
OperandMatchResultTy tryParseSVEPattern(OperandVector &Operands);
|
OperandMatchResultTy tryParseSVEPattern(OperandVector &Operands);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -2676,28 +2678,33 @@ bool AArch64AsmParser::tryParseNeonVectorRegister(OperandVector &Operands) {
|
||||||
Operands.push_back(
|
Operands.push_back(
|
||||||
AArch64Operand::CreateToken(Kind, false, S, getContext()));
|
AArch64Operand::CreateToken(Kind, false, S, getContext()));
|
||||||
|
|
||||||
// If there is an index specifier following the register, parse that too.
|
return tryParseVectorIndex(Operands) == MatchOperand_ParseFail;
|
||||||
|
}
|
||||||
|
|
||||||
|
OperandMatchResultTy
|
||||||
|
AArch64AsmParser::tryParseVectorIndex(OperandVector &Operands) {
|
||||||
SMLoc SIdx = getLoc();
|
SMLoc SIdx = getLoc();
|
||||||
if (parseOptionalToken(AsmToken::LBrac)) {
|
if (parseOptionalToken(AsmToken::LBrac)) {
|
||||||
const MCExpr *ImmVal;
|
const MCExpr *ImmVal;
|
||||||
if (getParser().parseExpression(ImmVal))
|
if (getParser().parseExpression(ImmVal))
|
||||||
return false;
|
return MatchOperand_NoMatch;
|
||||||
const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(ImmVal);
|
const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(ImmVal);
|
||||||
if (!MCE) {
|
if (!MCE) {
|
||||||
TokError("immediate value expected for vector index");
|
TokError("immediate value expected for vector index");
|
||||||
return false;
|
return MatchOperand_ParseFail;;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMLoc E = getLoc();
|
SMLoc E = getLoc();
|
||||||
|
|
||||||
if (parseToken(AsmToken::RBrac, "']' expected"))
|
if (parseToken(AsmToken::RBrac, "']' expected"))
|
||||||
return false;
|
return MatchOperand_ParseFail;;
|
||||||
|
|
||||||
Operands.push_back(AArch64Operand::CreateVectorIndex(MCE->getValue(), SIdx,
|
Operands.push_back(AArch64Operand::CreateVectorIndex(MCE->getValue(), SIdx,
|
||||||
E, getContext()));
|
E, getContext()));
|
||||||
|
return MatchOperand_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return MatchOperand_NoMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tryParseVectorRegister - Try to parse a vector register name with
|
// tryParseVectorRegister - Try to parse a vector register name with
|
||||||
|
@ -2876,8 +2883,8 @@ bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// parseVectorList - Parse a vector list operand for AdvSIMD instructions.
|
/// parseVectorList - Parse a vector list operand for vector instructions.
|
||||||
bool AArch64AsmParser::parseVectorList(OperandVector &Operands) {
|
bool AArch64AsmParser::tryParseVectorList(OperandVector &Operands) {
|
||||||
MCAsmParser &Parser = getParser();
|
MCAsmParser &Parser = getParser();
|
||||||
assert(Parser.getTok().is(AsmToken::LCurly) && "Token is not a Left Bracket");
|
assert(Parser.getTok().is(AsmToken::LCurly) && "Token is not a Left Bracket");
|
||||||
|
|
||||||
|
@ -2961,28 +2968,17 @@ bool AArch64AsmParser::parseVectorList(OperandVector &Operands) {
|
||||||
Operands.push_back(AArch64Operand::CreateVectorList(
|
Operands.push_back(AArch64Operand::CreateVectorList(
|
||||||
FirstReg, Count, NumElements, ElementWidth, S, getLoc(), getContext()));
|
FirstReg, Count, NumElements, ElementWidth, S, getLoc(), getContext()));
|
||||||
|
|
||||||
// If there is an index specifier following the list, parse that too.
|
|
||||||
SMLoc SIdx = getLoc();
|
|
||||||
if (parseOptionalToken(AsmToken::LBrac)) { // Eat left bracket token.
|
|
||||||
const MCExpr *ImmVal;
|
|
||||||
if (getParser().parseExpression(ImmVal))
|
|
||||||
return false;
|
|
||||||
const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(ImmVal);
|
|
||||||
if (!MCE) {
|
|
||||||
TokError("immediate value expected for vector index");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SMLoc E = getLoc();
|
|
||||||
if (parseToken(AsmToken::RBrac, "']' expected"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Operands.push_back(AArch64Operand::CreateVectorIndex(MCE->getValue(), SIdx,
|
|
||||||
E, getContext()));
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// parseNeonVectorList - Parse a vector list operand for AdvSIMD instructions.
|
||||||
|
bool AArch64AsmParser::parseNeonVectorList(OperandVector &Operands) {
|
||||||
|
if (tryParseVectorList(Operands))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return tryParseVectorIndex(Operands) == MatchOperand_ParseFail;
|
||||||
|
}
|
||||||
|
|
||||||
OperandMatchResultTy
|
OperandMatchResultTy
|
||||||
AArch64AsmParser::tryParseGPR64sp0Operand(OperandVector &Operands) {
|
AArch64AsmParser::tryParseGPR64sp0Operand(OperandVector &Operands) {
|
||||||
MCAsmParser &Parser = getParser();
|
MCAsmParser &Parser = getParser();
|
||||||
|
@ -3068,7 +3064,7 @@ bool AArch64AsmParser::parseOperand(OperandVector &Operands, bool isCondCode,
|
||||||
return parseOperand(Operands, false, false);
|
return parseOperand(Operands, false, false);
|
||||||
}
|
}
|
||||||
case AsmToken::LCurly:
|
case AsmToken::LCurly:
|
||||||
return parseVectorList(Operands);
|
return parseNeonVectorList(Operands);
|
||||||
case AsmToken::Identifier: {
|
case AsmToken::Identifier: {
|
||||||
// If we're expecting a Condition Code operand, then just parse that.
|
// If we're expecting a Condition Code operand, then just parse that.
|
||||||
if (isCondCode)
|
if (isCondCode)
|
||||||
|
|
Loading…
Reference in New Issue