-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[TableGen] Remove unused Target from InstructionEncoding methods (NFC) #159833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
s-barannikov
merged 3 commits into
llvm:main
from
s-barannikov:tablegen/decoder/unused-target-oeprand
Sep 20, 2025
Merged
[TableGen] Remove unused Target from InstructionEncoding methods (NFC) #159833
s-barannikov
merged 3 commits into
llvm:main
from
s-barannikov:tablegen/decoder/unused-target-oeprand
Sep 20, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-tablegen Author: Sergei Barannikov (s-barannikov) ChangesFull diff: https://github.com/llvm/llvm-project/pull/159833.diff 3 Files Affected:
diff --git a/llvm/utils/TableGen/Common/InstructionEncoding.cpp b/llvm/utils/TableGen/Common/InstructionEncoding.cpp
index c6c006b527b05..7260ee3d9b534 100644
--- a/llvm/utils/TableGen/Common/InstructionEncoding.cpp
+++ b/llvm/utils/TableGen/Common/InstructionEncoding.cpp
@@ -15,8 +15,7 @@
using namespace llvm;
std::pair<std::string, bool>
-InstructionEncoding::findOperandDecoderMethod(const CodeGenTarget &Target,
- const Record *Record) {
+InstructionEncoding::findOperandDecoderMethod(const Record *Record) {
std::string Decoder;
const RecordVal *DecoderString = Record->getValue("DecoderMethod");
@@ -30,7 +29,7 @@ InstructionEncoding::findOperandDecoderMethod(const CodeGenTarget &Target,
if (Record->isSubClassOf("RegisterOperand"))
// Allows use of a DecoderMethod in referenced RegisterClass if set.
- return findOperandDecoderMethod(Target, Record->getValueAsDef("RegClass"));
+ return findOperandDecoderMethod(Record->getValueAsDef("RegClass"));
if (Record->isSubClassOf("RegisterClass")) {
Decoder = "Decode" + Record->getName().str() + "RegisterClass";
@@ -44,8 +43,7 @@ InstructionEncoding::findOperandDecoderMethod(const CodeGenTarget &Target,
return {Decoder, true};
}
-OperandInfo InstructionEncoding::getOpInfo(const CodeGenTarget &Target,
- const Record *TypeRecord) {
+OperandInfo InstructionEncoding::getOpInfo(const Record *TypeRecord) {
const RecordVal *HasCompleteDecoderVal =
TypeRecord->getValue("hasCompleteDecoder");
const BitInit *HasCompleteDecoderBit =
@@ -55,7 +53,7 @@ OperandInfo InstructionEncoding::getOpInfo(const CodeGenTarget &Target,
bool HasCompleteDecoder =
HasCompleteDecoderBit ? HasCompleteDecoderBit->getValue() : true;
- return OperandInfo(findOperandDecoderMethod(Target, TypeRecord).first,
+ return OperandInfo(findOperandDecoderMethod(TypeRecord).first,
HasCompleteDecoder);
}
@@ -177,16 +175,15 @@ void InstructionEncoding::parseFixedLenEncoding(
}
}
-void InstructionEncoding::parseVarLenOperands(const CodeGenTarget &Target,
- const VarLenInst &VLI) {
+void InstructionEncoding::parseVarLenOperands(const VarLenInst &VLI) {
SmallVector<int> TiedTo;
for (const auto &[Idx, Op] : enumerate(Inst->Operands)) {
if (Op.MIOperandInfo && Op.MIOperandInfo->getNumArgs() > 0)
for (auto *Arg : Op.MIOperandInfo->getArgs())
- Operands.push_back(getOpInfo(Target, cast<DefInit>(Arg)->getDef()));
+ Operands.push_back(getOpInfo(cast<DefInit>(Arg)->getDef()));
else
- Operands.push_back(getOpInfo(Target, Op.Rec));
+ Operands.push_back(getOpInfo(Op.Rec));
int TiedReg = Op.getTiedRegister();
TiedTo.push_back(-1);
@@ -321,8 +318,7 @@ static void addOneOperandFields(const Record *EncodingDef,
}
}
-void InstructionEncoding::parseFixedLenOperands(const CodeGenTarget &Target,
- const BitsInit &Bits) {
+void InstructionEncoding::parseFixedLenOperands(const BitsInit &Bits) {
// Search for tied operands, so that we can correctly instantiate
// operands that are not explicitly represented in the encoding.
std::map<StringRef, StringRef> TiedNames;
@@ -348,7 +344,7 @@ void InstructionEncoding::parseFixedLenOperands(const CodeGenTarget &Target,
for (const CGIOperandList::OperandInfo &Op : Inst->Operands) {
// Lookup the decoder method and construct a new OperandInfo to hold our
// result.
- OperandInfo OpInfo = getOpInfo(Target, Op.Rec);
+ OperandInfo OpInfo = getOpInfo(Op.Rec);
// If we have named sub-operands...
if (Op.MIOperandInfo && !Op.SubOpNames[0].empty()) {
@@ -367,7 +363,7 @@ void InstructionEncoding::parseFixedLenOperands(const CodeGenTarget &Target,
for (auto [SubOpName, SubOp] :
zip_equal(Op.SubOpNames, Op.MIOperandInfo->getArgs())) {
const Record *SubOpRec = cast<DefInit>(SubOp)->getDef();
- OperandInfo SubOpInfo = getOpInfo(Target, SubOpRec);
+ OperandInfo SubOpInfo = getOpInfo(SubOpRec);
addOneOperandFields(EncodingDef, Bits, TiedNames, SubOpRec, SubOpName,
SubOpInfo);
Operands.push_back(std::move(SubOpInfo));
@@ -395,8 +391,7 @@ void InstructionEncoding::parseFixedLenOperands(const CodeGenTarget &Target,
}
}
-InstructionEncoding::InstructionEncoding(const CodeGenTarget &Target,
- const Record *EncodingDef,
+InstructionEncoding::InstructionEncoding(const Record *EncodingDef,
const CodeGenInstruction *Inst)
: EncodingDef(EncodingDef), Inst(Inst) {
const Record *InstDef = Inst->TheDef;
@@ -417,13 +412,13 @@ InstructionEncoding::InstructionEncoding(const CodeGenTarget &Target,
parseVarLenEncoding(VLI);
// If the encoding has a custom decoder, don't bother parsing the operands.
if (DecoderMethod.empty())
- parseVarLenOperands(Target, VLI);
+ parseVarLenOperands(VLI);
} else {
const auto *BI = cast<BitsInit>(InstField->getValue());
parseFixedLenEncoding(*BI);
// If the encoding has a custom decoder, don't bother parsing the operands.
if (DecoderMethod.empty())
- parseFixedLenOperands(Target, *BI);
+ parseFixedLenOperands(*BI);
}
if (DecoderMethod.empty()) {
diff --git a/llvm/utils/TableGen/Common/InstructionEncoding.h b/llvm/utils/TableGen/Common/InstructionEncoding.h
index 412f93402170c..d9e70edb0b04e 100644
--- a/llvm/utils/TableGen/Common/InstructionEncoding.h
+++ b/llvm/utils/TableGen/Common/InstructionEncoding.h
@@ -92,7 +92,7 @@ class InstructionEncoding {
SmallVector<OperandInfo, 16> Operands;
public:
- InstructionEncoding(const CodeGenTarget &Target, const Record *EncodingDef,
+ InstructionEncoding(const Record *EncodingDef,
const CodeGenInstruction *Inst);
/// Returns the Record this encoding originates from.
@@ -141,17 +141,16 @@ class InstructionEncoding {
/// \returns the effective value of the DecoderMethod field. If DecoderMethod
/// is an explictly set value, return false for second.
static std::pair<std::string, bool>
- findOperandDecoderMethod(const CodeGenTarget &Target, const Record *Record);
+ findOperandDecoderMethod(const Record *Record);
- static OperandInfo getOpInfo(const CodeGenTarget &Target,
- const Record *TypeRecord);
+ static OperandInfo getOpInfo(const Record *TypeRecord);
private:
void parseVarLenEncoding(const VarLenInst &VLI);
void parseFixedLenEncoding(const BitsInit &RecordInstBits);
- void parseVarLenOperands(const CodeGenTarget &Target, const VarLenInst &VLI);
- void parseFixedLenOperands(const CodeGenTarget &Target, const BitsInit &Bits);
+ void parseVarLenOperands(const VarLenInst &VLI);
+ void parseFixedLenOperands(const BitsInit &Bits);
};
} // namespace llvm
diff --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index 10863343d4625..ff8d8a804125b 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -860,8 +860,7 @@ void DecoderEmitter::emitRegClassByHwModeDecoders(
for (const Record *ClassByHwMode : RegClassByHwMode) {
// Ignore cases that had an explicit DecoderMethod set.
- if (!InstructionEncoding::findOperandDecoderMethod(Target, ClassByHwMode)
- .second)
+ if (!InstructionEncoding::findOperandDecoderMethod(ClassByHwMode).second)
continue;
const HwModeSelect &ModeSelect = CGH.getHwModeSelect(ClassByHwMode);
@@ -880,8 +879,7 @@ void DecoderEmitter::emitRegClassByHwModeDecoders(
OS << indent(2) << "case " << ModeID << ": // "
<< CGH.getModeName(ModeID, /*IncludeDefault=*/true) << '\n'
<< indent(4) << "return "
- << InstructionEncoding::findOperandDecoderMethod(Target, RegClassRec)
- .first
+ << InstructionEncoding::findOperandDecoderMethod(RegClassRec).first
<< "(Inst, Imm, Addr, Decoder);\n";
}
OS << indent(2) << R"(default:
@@ -1853,7 +1851,7 @@ void DecoderEmitter::parseInstructionEncodings() {
continue;
}
unsigned EncodingID = Encodings.size();
- Encodings.emplace_back(Target, EncodingDef, Inst);
+ Encodings.emplace_back(EncodingDef, Inst);
EncodingIDsByHwMode[HwModeID].push_back(EncodingID);
}
continue; // Ignore encoding specified by Instruction itself.
@@ -1865,7 +1863,7 @@ void DecoderEmitter::parseInstructionEncodings() {
}
unsigned EncodingID = Encodings.size();
- Encodings.emplace_back(Target, InstDef, Inst);
+ Encodings.emplace_back(InstDef, Inst);
// This instruction is encoded the same on all HwModes.
// According to user needs, add it to all, some, or only the default HwMode.
@@ -1888,7 +1886,7 @@ void DecoderEmitter::parseInstructionEncodings() {
continue;
}
unsigned EncodingID = Encodings.size();
- Encodings.emplace_back(Target, EncodingDef,
+ Encodings.emplace_back(EncodingDef,
&Target.getInstruction(InstDef));
EncodingIDsByHwMode[DefaultMode].push_back(EncodingID);
}
|
Probably became dead after rebasing. |
d1599c0
to
41889d5
Compare
arsenm
approved these changes
Sep 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.