Skip to content

Commit 6462223

Browse files
committed
[TableGen] Make ParseOperandName method const (NFC)
Also change its name to start with a lowercase letter and update the doxygen comment to conform to the coding standard.
1 parent ef68d15 commit 6462223

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

llvm/utils/TableGen/Common/CodeGenInstruction.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ CGIOperandList::findSubOperandAlias(StringRef Name) const {
227227
}
228228

229229
std::pair<unsigned, unsigned>
230-
CGIOperandList::ParseOperandName(StringRef Op, bool AllowWholeOp) {
230+
CGIOperandList::parseOperandName(StringRef Op, bool AllowWholeOp) const {
231231
if (!Op.starts_with("$"))
232232
PrintFatalError(TheDef->getLoc(),
233233
TheDef->getName() + ": Illegal operand name: '" + Op + "'");
@@ -307,7 +307,7 @@ static void ParseConstraint(StringRef CStr, CGIOperandList &Ops,
307307
"Illegal format for @earlyclobber constraint in '" +
308308
Rec->getName() + "': '" + CStr + "'");
309309
Name = Name.substr(wpos);
310-
std::pair<unsigned, unsigned> Op = Ops.ParseOperandName(Name, false);
310+
std::pair<unsigned, unsigned> Op = Ops.parseOperandName(Name, false);
311311

312312
// Build the string for the operand
313313
if (!Ops[Op.first].Constraints[Op.second].isNone())
@@ -335,15 +335,15 @@ static void ParseConstraint(StringRef CStr, CGIOperandList &Ops,
335335
"Illegal format for tied-to constraint in '" +
336336
Rec->getName() + "': '" + CStr + "'");
337337
StringRef LHSOpName = CStr.substr(start, wpos - start);
338-
std::pair<unsigned, unsigned> LHSOp = Ops.ParseOperandName(LHSOpName, false);
338+
std::pair<unsigned, unsigned> LHSOp = Ops.parseOperandName(LHSOpName, false);
339339

340340
wpos = CStr.find_first_not_of(" \t", pos + 1);
341341
if (wpos == StringRef::npos)
342342
PrintFatalError(Rec->getLoc(),
343343
"Illegal format for tied-to constraint: '" + CStr + "'");
344344

345345
StringRef RHSOpName = CStr.substr(wpos);
346-
std::pair<unsigned, unsigned> RHSOp = Ops.ParseOperandName(RHSOpName, false);
346+
std::pair<unsigned, unsigned> RHSOp = Ops.parseOperandName(RHSOpName, false);
347347

348348
// Sort the operands into order, which should put the output one
349349
// first. But keep the original order, for use in diagnostics.
@@ -414,7 +414,7 @@ void CGIOperandList::ProcessDisableEncoding(StringRef DisableEncoding) {
414414
break;
415415

416416
// Figure out which operand this is.
417-
std::pair<unsigned, unsigned> Op = ParseOperandName(OpName, false);
417+
std::pair<unsigned, unsigned> Op = parseOperandName(OpName, false);
418418

419419
// Mark the operand as not-to-be encoded.
420420
OperandList[Op.first].DoNotEncode[Op.second] = true;

llvm/utils/TableGen/Common/CodeGenInstruction.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ class CGIOperandList {
183183
std::optional<std::pair<unsigned, unsigned>>
184184
findSubOperandAlias(StringRef Name) const;
185185

186-
/// ParseOperandName - Parse an operand name like "$foo" or "$foo.bar",
186+
/// Parses an operand name like "$foo" or "$foo.bar",
187187
/// where $foo is a whole operand and $foo.bar refers to a suboperand.
188188
/// This aborts if the name is invalid. If AllowWholeOp is true, references
189189
/// to operands with suboperands are allowed, otherwise not.
190-
std::pair<unsigned, unsigned> ParseOperandName(StringRef Op,
191-
bool AllowWholeOp = true);
190+
std::pair<unsigned, unsigned>
191+
parseOperandName(StringRef Op, bool AllowWholeOp = true) const;
192192

193193
/// getFlattenedOperandNumber - Flatten a operand/suboperand pair into a
194194
/// flat machineinstr operand #.

llvm/utils/TableGen/Common/VarLenCodeEmitterGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ VarLenCodeEmitterGen::getInstructionCases(const Record *R,
447447
std::string VarLenCodeEmitterGen::getInstructionCaseForEncoding(
448448
const Record *R, AltEncodingTy Mode, const VarLenInst &VLI,
449449
const CodeGenTarget &Target, int Indent) {
450-
CodeGenInstruction &CGI = Target.getInstruction(R);
450+
const CodeGenInstruction &CGI = Target.getInstruction(R);
451451

452452
std::string Case;
453453
raw_string_ostream SS(Case);
@@ -474,7 +474,7 @@ std::string VarLenCodeEmitterGen::getInstructionCaseForEncoding(
474474
LoBit = static_cast<unsigned>(cast<IntInit>(DV->getArg(2))->getValue());
475475
}
476476

477-
auto OpIdx = CGI.Operands.ParseOperandName(OperandName);
477+
auto OpIdx = CGI.Operands.parseOperandName(OperandName);
478478
unsigned FlatOpIdx = CGI.Operands.getFlattenedOperandNumber(OpIdx);
479479
StringRef CustomEncoder =
480480
CGI.Operands[OpIdx.first].EncoderMethodNames[OpIdx.second];

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,9 +1885,7 @@ static void parseVarLenInstOperand(const Record &Def,
18851885
}
18861886

18871887
if (!OpName.empty()) {
1888-
auto OpSubOpPair =
1889-
const_cast<CodeGenInstruction &>(CGI).Operands.ParseOperandName(
1890-
OpName);
1888+
auto OpSubOpPair = CGI.Operands.parseOperandName(OpName);
18911889
unsigned OpIdx = CGI.Operands.getFlattenedOperandNumber(OpSubOpPair);
18921890
Operands[OpIdx].addField(CurrBitPos, EncodingSegment.BitWidth, Offset);
18931891
if (!EncodingSegment.CustomDecoder.empty())

0 commit comments

Comments
 (0)