Skip to content

Commit 5f2e88a

Browse files
authored
[NFC][TableGen] Rename CodeGenTarget instruction accessors (#146767)
Rename `getXYZInstructionsByEnumValue()` to just `getXYZInstructions` and drop the `ByEnumValue` in the name.
1 parent 17d6aa0 commit 5f2e88a

17 files changed

+38
-44
lines changed

llvm/utils/TableGen/AsmMatcherEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ void AsmMatcherInfo::buildInfo() {
15411541
Variant.Name = AsmVariant->getValueAsString("Name");
15421542
Variant.AsmVariantNo = AsmVariant->getValueAsInt("Variant");
15431543

1544-
for (const CodeGenInstruction *CGI : Target.getInstructionsByEnumValue()) {
1544+
for (const CodeGenInstruction *CGI : Target.getInstructions()) {
15451545

15461546
// If the tblgen -match-prefix option is specified (for tblgen hackers),
15471547
// filter the set of instructions we consider.

llvm/utils/TableGen/AsmWriterEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ AsmWriterEmitter::AsmWriterEmitter(const RecordKeeper &R)
13141314
unsigned Variant = AsmWriter->getValueAsInt("Variant");
13151315

13161316
// Get the instruction numbering.
1317-
NumberedInstructions = Target.getInstructionsByEnumValue();
1317+
NumberedInstructions = Target.getInstructions();
13181318

13191319
for (const auto &[Idx, I] : enumerate(NumberedInstructions)) {
13201320
if (!I->AsmString.empty() && I->TheDef->getName() != "PHI")

llvm/utils/TableGen/CodeEmitterGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ void CodeEmitterGen::run(raw_ostream &O) {
475475
Target.reverseBitsForLittleEndianEncoding();
476476

477477
ArrayRef<const CodeGenInstruction *> NumberedInstructions =
478-
Target.getInstructionsByEnumValue();
478+
Target.getInstructions();
479479

480480
if (Target.hasVariableLengthEncodings()) {
481481
emitVarLenCodeEmitter(Records, O);

llvm/utils/TableGen/CodeGenMapTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ const Record *MapTableEmitter::getInstrForColumn(const Record *KeyInstr,
358358

359359
unsigned MapTableEmitter::emitBinSearchTable(raw_ostream &OS) {
360360
ArrayRef<const CodeGenInstruction *> NumberedInstructions =
361-
Target.getInstructionsByEnumValue();
361+
Target.getInstructions();
362362
StringRef Namespace = Target.getInstNamespace();
363363
ArrayRef<const ListInit *> ValueCols = InstrMapDesc.getValueCols();
364364
unsigned NumCol = ValueCols.size();

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4122,8 +4122,7 @@ void CodeGenDAGPatterns::AddPatternToMatch(TreePattern *Pattern,
41224122
}
41234123

41244124
void CodeGenDAGPatterns::InferInstructionFlags() {
4125-
ArrayRef<const CodeGenInstruction *> Instructions =
4126-
Target.getInstructionsByEnumValue();
4125+
ArrayRef<const CodeGenInstruction *> Instructions = Target.getInstructions();
41274126

41284127
unsigned Errors = 0;
41294128

llvm/utils/TableGen/Common/CodeGenSchedule.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ struct InstRegexOp : public SetTheory::Operator {
7878
void apply(SetTheory &ST, const DagInit *Expr, SetTheory::RecSet &Elts,
7979
ArrayRef<SMLoc> Loc) override {
8080
ArrayRef<const CodeGenInstruction *> Generics =
81-
Target.getGenericInstructionsByEnumValue();
81+
Target.getGenericInstructions();
8282
ArrayRef<const CodeGenInstruction *> Pseudos =
83-
Target.getTargetPseudoInstructionsByEnumValue();
83+
Target.getTargetPseudoInstructions();
8484
ArrayRef<const CodeGenInstruction *> NonPseudos =
85-
Target.getTargetNonPseudoInstructionsByEnumValue();
85+
Target.getTargetNonPseudoInstructions();
8686

8787
for (const Init *Arg : Expr->getArgs()) {
8888
const StringInit *SI = dyn_cast<StringInit>(Arg);
@@ -587,7 +587,7 @@ void CodeGenSchedModels::collectSchedRW() {
587587

588588
// Find all SchedReadWrites referenced by instruction defs.
589589
ConstRecVec SWDefs, SRDefs;
590-
for (const CodeGenInstruction *Inst : Target.getInstructionsByEnumValue()) {
590+
for (const CodeGenInstruction *Inst : Target.getInstructions()) {
591591
const Record *SchedDef = Inst->TheDef;
592592
if (SchedDef->isValueUnset("SchedRW"))
593593
continue;
@@ -836,7 +836,7 @@ void CodeGenSchedModels::collectSchedClasses() {
836836

837837
// Create a SchedClass for each unique combination of itinerary class and
838838
// SchedRW list.
839-
for (const CodeGenInstruction *Inst : Target.getInstructionsByEnumValue()) {
839+
for (const CodeGenInstruction *Inst : Target.getInstructions()) {
840840
const Record *ItinDef = Inst->TheDef->getValueAsDef("Itinerary");
841841
IdxVec Writes, Reads;
842842
if (!Inst->TheDef->isValueUnset("SchedRW"))
@@ -861,7 +861,7 @@ void CodeGenSchedModels::collectSchedClasses() {
861861
LLVM_DEBUG(
862862
dbgs()
863863
<< "\n+++ ITINERARIES and/or MACHINE MODELS (collectSchedClasses) +++\n");
864-
for (const CodeGenInstruction *Inst : Target.getInstructionsByEnumValue()) {
864+
for (const CodeGenInstruction *Inst : Target.getInstructions()) {
865865
StringRef InstName = Inst->TheDef->getName();
866866
unsigned SCIdx = getSchedClassIdx(*Inst);
867867
if (!SCIdx) {
@@ -1922,7 +1922,7 @@ void CodeGenSchedModels::checkCompleteness() {
19221922
const bool HasItineraries = ProcModel.hasItineraries();
19231923
if (!ProcModel.ModelDef->getValueAsBit("CompleteModel"))
19241924
continue;
1925-
for (const CodeGenInstruction *Inst : Target.getInstructionsByEnumValue()) {
1925+
for (const CodeGenInstruction *Inst : Target.getInstructions()) {
19261926
if (Inst->hasNoSchedulingInfo)
19271927
continue;
19281928
if (ProcModel.isUnsupported(*Inst))

llvm/utils/TableGen/Common/CodeGenTarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ StringRef CodeGenTarget::getName() const { return TargetRec->getName(); }
8888
/// namespace. The namespace is cached because it is requested multiple times.
8989
StringRef CodeGenTarget::getInstNamespace() const {
9090
if (InstNamespace.empty()) {
91-
for (const CodeGenInstruction *Inst : getInstructionsByEnumValue()) {
91+
for (const CodeGenInstruction *Inst : getInstructions()) {
9292
// We are not interested in the "TargetOpcode" namespace.
9393
if (Inst->Namespace != "TargetOpcode") {
9494
InstNamespace = Inst->Namespace;

llvm/utils/TableGen/Common/CodeGenTarget.h

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,31 +176,28 @@ class CodeGenTarget {
176176
/// - fixed / generic instructions as declared in TargetOpcodes.def, in order;
177177
/// - pseudo instructions in lexicographical order sorted by name;
178178
/// - other instructions in lexicographical order sorted by name.
179-
ArrayRef<const CodeGenInstruction *> getInstructionsByEnumValue() const {
179+
ArrayRef<const CodeGenInstruction *> getInstructions() const {
180180
if (InstrsByEnum.empty())
181181
ComputeInstrsByEnum();
182182
return InstrsByEnum;
183183
}
184184

185-
// Functions that return various slices of `getInstructionsByEnumValue`.
186-
ArrayRef<const CodeGenInstruction *>
187-
getGenericInstructionsByEnumValue() const {
188-
return getInstructionsByEnumValue().take_front(getNumFixedInstructions());
185+
// Functions that return various slices of `getInstructions`, ordered by
186+
// their enum values.
187+
ArrayRef<const CodeGenInstruction *> getGenericInstructions() const {
188+
return getInstructions().take_front(getNumFixedInstructions());
189189
}
190190

191-
ArrayRef<const CodeGenInstruction *>
192-
getTargetInstructionsByEnumValue() const {
193-
return getInstructionsByEnumValue().drop_front(getNumFixedInstructions());
191+
ArrayRef<const CodeGenInstruction *> getTargetInstructions() const {
192+
return getInstructions().drop_front(getNumFixedInstructions());
194193
}
195194

196-
ArrayRef<const CodeGenInstruction *>
197-
getTargetPseudoInstructionsByEnumValue() const {
198-
return getTargetInstructionsByEnumValue().take_front(NumPseudoInstructions);
195+
ArrayRef<const CodeGenInstruction *> getTargetPseudoInstructions() const {
196+
return getTargetInstructions().take_front(NumPseudoInstructions);
199197
}
200198

201-
ArrayRef<const CodeGenInstruction *>
202-
getTargetNonPseudoInstructionsByEnumValue() const {
203-
return getTargetInstructionsByEnumValue().drop_front(NumPseudoInstructions);
199+
ArrayRef<const CodeGenInstruction *> getTargetNonPseudoInstructions() const {
200+
return getTargetInstructions().drop_front(NumPseudoInstructions);
204201
}
205202

206203
/// Return the integer enum value corresponding to this instruction record.

llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ void InstructionOpcodeMatcher::initOpcodeValuesMap(
14481448
const CodeGenTarget &Target) {
14491449
OpcodeValues.clear();
14501450

1451-
for (const CodeGenInstruction *I : Target.getInstructionsByEnumValue())
1451+
for (const CodeGenInstruction *I : Target.getInstructions())
14521452
OpcodeValues[I] = Target.getInstrIntValue(I->TheDef);
14531453
}
14541454

llvm/utils/TableGen/Common/VarLenCodeEmitterGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void VarLenInst::buildRec(const DagInit *DI) {
226226
void VarLenCodeEmitterGen::run(raw_ostream &OS) {
227227
CodeGenTarget Target(Records);
228228

229-
auto NumberedInstructions = Target.getInstructionsByEnumValue();
229+
auto NumberedInstructions = Target.getInstructions();
230230

231231
for (const CodeGenInstruction *CGI : NumberedInstructions) {
232232
const Record *R = CGI->TheDef;

0 commit comments

Comments
 (0)