Skip to content

Commit 386301c

Browse files
authored
[TableGen] Remove unused Target from InstructionEncoding methods (NFC) (#159833)
1 parent 0a47e8c commit 386301c

File tree

3 files changed

+23
-32
lines changed

3 files changed

+23
-32
lines changed

llvm/utils/TableGen/Common/InstructionEncoding.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
using namespace llvm;
1616

1717
std::pair<std::string, bool>
18-
InstructionEncoding::findOperandDecoderMethod(const CodeGenTarget &Target,
19-
const Record *Record) {
18+
InstructionEncoding::findOperandDecoderMethod(const Record *Record) {
2019
std::string Decoder;
2120

2221
const RecordVal *DecoderString = Record->getValue("DecoderMethod");
@@ -30,7 +29,7 @@ InstructionEncoding::findOperandDecoderMethod(const CodeGenTarget &Target,
3029

3130
if (Record->isSubClassOf("RegisterOperand"))
3231
// Allows use of a DecoderMethod in referenced RegisterClass if set.
33-
return findOperandDecoderMethod(Target, Record->getValueAsDef("RegClass"));
32+
return findOperandDecoderMethod(Record->getValueAsDef("RegClass"));
3433

3534
if (Record->isSubClassOf("RegisterClass")) {
3635
Decoder = "Decode" + Record->getName().str() + "RegisterClass";
@@ -44,8 +43,7 @@ InstructionEncoding::findOperandDecoderMethod(const CodeGenTarget &Target,
4443
return {Decoder, true};
4544
}
4645

47-
OperandInfo InstructionEncoding::getOpInfo(const CodeGenTarget &Target,
48-
const Record *TypeRecord) {
46+
OperandInfo InstructionEncoding::getOpInfo(const Record *TypeRecord) {
4947
const RecordVal *HasCompleteDecoderVal =
5048
TypeRecord->getValue("hasCompleteDecoder");
5149
const BitInit *HasCompleteDecoderBit =
@@ -55,7 +53,7 @@ OperandInfo InstructionEncoding::getOpInfo(const CodeGenTarget &Target,
5553
bool HasCompleteDecoder =
5654
HasCompleteDecoderBit ? HasCompleteDecoderBit->getValue() : true;
5755

58-
return OperandInfo(findOperandDecoderMethod(Target, TypeRecord).first,
56+
return OperandInfo(findOperandDecoderMethod(TypeRecord).first,
5957
HasCompleteDecoder);
6058
}
6159

@@ -177,16 +175,15 @@ void InstructionEncoding::parseFixedLenEncoding(
177175
}
178176
}
179177

180-
void InstructionEncoding::parseVarLenOperands(const CodeGenTarget &Target,
181-
const VarLenInst &VLI) {
178+
void InstructionEncoding::parseVarLenOperands(const VarLenInst &VLI) {
182179
SmallVector<int> TiedTo;
183180

184181
for (const auto &[Idx, Op] : enumerate(Inst->Operands)) {
185182
if (Op.MIOperandInfo && Op.MIOperandInfo->getNumArgs() > 0)
186183
for (auto *Arg : Op.MIOperandInfo->getArgs())
187-
Operands.push_back(getOpInfo(Target, cast<DefInit>(Arg)->getDef()));
184+
Operands.push_back(getOpInfo(cast<DefInit>(Arg)->getDef()));
188185
else
189-
Operands.push_back(getOpInfo(Target, Op.Rec));
186+
Operands.push_back(getOpInfo(Op.Rec));
190187

191188
int TiedReg = Op.getTiedRegister();
192189
TiedTo.push_back(-1);
@@ -321,8 +318,7 @@ static void addOneOperandFields(const Record *EncodingDef,
321318
}
322319
}
323320

324-
void InstructionEncoding::parseFixedLenOperands(const CodeGenTarget &Target,
325-
const BitsInit &Bits) {
321+
void InstructionEncoding::parseFixedLenOperands(const BitsInit &Bits) {
326322
// Search for tied operands, so that we can correctly instantiate
327323
// operands that are not explicitly represented in the encoding.
328324
std::map<StringRef, StringRef> TiedNames;
@@ -348,7 +344,7 @@ void InstructionEncoding::parseFixedLenOperands(const CodeGenTarget &Target,
348344
for (const CGIOperandList::OperandInfo &Op : Inst->Operands) {
349345
// Lookup the decoder method and construct a new OperandInfo to hold our
350346
// result.
351-
OperandInfo OpInfo = getOpInfo(Target, Op.Rec);
347+
OperandInfo OpInfo = getOpInfo(Op.Rec);
352348

353349
// If we have named sub-operands...
354350
if (Op.MIOperandInfo && !Op.SubOpNames[0].empty()) {
@@ -367,7 +363,7 @@ void InstructionEncoding::parseFixedLenOperands(const CodeGenTarget &Target,
367363
for (auto [SubOpName, SubOp] :
368364
zip_equal(Op.SubOpNames, Op.MIOperandInfo->getArgs())) {
369365
const Record *SubOpRec = cast<DefInit>(SubOp)->getDef();
370-
OperandInfo SubOpInfo = getOpInfo(Target, SubOpRec);
366+
OperandInfo SubOpInfo = getOpInfo(SubOpRec);
371367
addOneOperandFields(EncodingDef, Bits, TiedNames, SubOpRec, SubOpName,
372368
SubOpInfo);
373369
Operands.push_back(std::move(SubOpInfo));
@@ -395,8 +391,7 @@ void InstructionEncoding::parseFixedLenOperands(const CodeGenTarget &Target,
395391
}
396392
}
397393

398-
InstructionEncoding::InstructionEncoding(const CodeGenTarget &Target,
399-
const Record *EncodingDef,
394+
InstructionEncoding::InstructionEncoding(const Record *EncodingDef,
400395
const CodeGenInstruction *Inst)
401396
: EncodingDef(EncodingDef), Inst(Inst) {
402397
const Record *InstDef = Inst->TheDef;
@@ -417,13 +412,13 @@ InstructionEncoding::InstructionEncoding(const CodeGenTarget &Target,
417412
parseVarLenEncoding(VLI);
418413
// If the encoding has a custom decoder, don't bother parsing the operands.
419414
if (DecoderMethod.empty())
420-
parseVarLenOperands(Target, VLI);
415+
parseVarLenOperands(VLI);
421416
} else {
422417
const auto *BI = cast<BitsInit>(InstField->getValue());
423418
parseFixedLenEncoding(*BI);
424419
// If the encoding has a custom decoder, don't bother parsing the operands.
425420
if (DecoderMethod.empty())
426-
parseFixedLenOperands(Target, *BI);
421+
parseFixedLenOperands(*BI);
427422
}
428423

429424
if (DecoderMethod.empty()) {

llvm/utils/TableGen/Common/InstructionEncoding.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class InstructionEncoding {
9292
SmallVector<OperandInfo, 16> Operands;
9393

9494
public:
95-
InstructionEncoding(const CodeGenTarget &Target, const Record *EncodingDef,
95+
InstructionEncoding(const Record *EncodingDef,
9696
const CodeGenInstruction *Inst);
9797

9898
/// Returns the Record this encoding originates from.
@@ -141,17 +141,16 @@ class InstructionEncoding {
141141
/// \returns the effective value of the DecoderMethod field. If DecoderMethod
142142
/// is an explictly set value, return false for second.
143143
static std::pair<std::string, bool>
144-
findOperandDecoderMethod(const CodeGenTarget &Target, const Record *Record);
144+
findOperandDecoderMethod(const Record *Record);
145145

146-
static OperandInfo getOpInfo(const CodeGenTarget &Target,
147-
const Record *TypeRecord);
146+
static OperandInfo getOpInfo(const Record *TypeRecord);
148147

149148
private:
150149
void parseVarLenEncoding(const VarLenInst &VLI);
151150
void parseFixedLenEncoding(const BitsInit &RecordInstBits);
152151

153-
void parseVarLenOperands(const CodeGenTarget &Target, const VarLenInst &VLI);
154-
void parseFixedLenOperands(const CodeGenTarget &Target, const BitsInit &Bits);
152+
void parseVarLenOperands(const VarLenInst &VLI);
153+
void parseFixedLenOperands(const BitsInit &Bits);
155154
};
156155

157156
} // namespace llvm

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,7 @@ void DecoderEmitter::emitRegClassByHwModeDecoders(
860860

861861
for (const Record *ClassByHwMode : RegClassByHwMode) {
862862
// Ignore cases that had an explicit DecoderMethod set.
863-
if (!InstructionEncoding::findOperandDecoderMethod(Target, ClassByHwMode)
864-
.second)
863+
if (!InstructionEncoding::findOperandDecoderMethod(ClassByHwMode).second)
865864
continue;
866865

867866
const HwModeSelect &ModeSelect = CGH.getHwModeSelect(ClassByHwMode);
@@ -880,8 +879,7 @@ void DecoderEmitter::emitRegClassByHwModeDecoders(
880879
OS << indent(2) << "case " << ModeID << ": // "
881880
<< CGH.getModeName(ModeID, /*IncludeDefault=*/true) << '\n'
882881
<< indent(4) << "return "
883-
<< InstructionEncoding::findOperandDecoderMethod(Target, RegClassRec)
884-
.first
882+
<< InstructionEncoding::findOperandDecoderMethod(RegClassRec).first
885883
<< "(Inst, Imm, Addr, Decoder);\n";
886884
}
887885
OS << indent(2) << R"(default:
@@ -1853,7 +1851,7 @@ void DecoderEmitter::parseInstructionEncodings() {
18531851
continue;
18541852
}
18551853
unsigned EncodingID = Encodings.size();
1856-
Encodings.emplace_back(Target, EncodingDef, Inst);
1854+
Encodings.emplace_back(EncodingDef, Inst);
18571855
EncodingIDsByHwMode[HwModeID].push_back(EncodingID);
18581856
}
18591857
continue; // Ignore encoding specified by Instruction itself.
@@ -1865,7 +1863,7 @@ void DecoderEmitter::parseInstructionEncodings() {
18651863
}
18661864

18671865
unsigned EncodingID = Encodings.size();
1868-
Encodings.emplace_back(Target, InstDef, Inst);
1866+
Encodings.emplace_back(InstDef, Inst);
18691867

18701868
// This instruction is encoded the same on all HwModes.
18711869
// According to user needs, add it to all, some, or only the default HwMode.
@@ -1888,8 +1886,7 @@ void DecoderEmitter::parseInstructionEncodings() {
18881886
continue;
18891887
}
18901888
unsigned EncodingID = Encodings.size();
1891-
Encodings.emplace_back(Target, EncodingDef,
1892-
&Target.getInstruction(InstDef));
1889+
Encodings.emplace_back(EncodingDef, &Target.getInstruction(InstDef));
18931890
EncodingIDsByHwMode[DefaultMode].push_back(EncodingID);
18941891
}
18951892

0 commit comments

Comments
 (0)