Skip to content

Conversation

s-barannikov
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Sep 19, 2025

@llvm/pr-subscribers-tablegen

Author: Sergei Barannikov (s-barannikov)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/159833.diff

3 Files Affected:

  • (modified) llvm/utils/TableGen/Common/InstructionEncoding.cpp (+13-18)
  • (modified) llvm/utils/TableGen/Common/InstructionEncoding.h (+5-6)
  • (modified) llvm/utils/TableGen/DecoderEmitter.cpp (+5-7)
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);
   }

@s-barannikov
Copy link
Contributor Author

Probably became dead after rebasing.
Unless you had plans of using in the future.

@s-barannikov s-barannikov force-pushed the tablegen/decoder/unused-target-oeprand branch from d1599c0 to 41889d5 Compare September 19, 2025 19:23
@s-barannikov s-barannikov merged commit 386301c into llvm:main Sep 20, 2025
9 checks passed
@s-barannikov s-barannikov deleted the tablegen/decoder/unused-target-oeprand branch September 20, 2025 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants