[PATCH] D141896: [TableGen][NFC] Add postfix for validators of CompressPat

Wang Pengcheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 00:01:58 PST 2023


pcwang-thead created this revision.
pcwang-thead added reviewers: craig.topper, kito-cheng, zixuan-wu.
Herald added a project: All.
pcwang-thead requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

So that we won't get redefinition errors if we use compressInst
and uncompressInst in the same file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141896

Files:
  llvm/utils/TableGen/CompressInstEmitter.cpp


Index: llvm/utils/TableGen/CompressInstEmitter.cpp
===================================================================
--- llvm/utils/TableGen/CompressInstEmitter.cpp
+++ llvm/utils/TableGen/CompressInstEmitter.cpp
@@ -647,6 +647,12 @@
       EType == EmitterType::Compress || EType == EmitterType::CheckCompress;
   bool CompressOrUncompress =
       EType == EmitterType::Compress || EType == EmitterType::Uncompress;
+  std::string ValidatorName =
+      CompressOrUncompress
+          ? (TargetName + "ValidateMCOperandFor" +
+             (EType == EmitterType::Compress ? "Compress" : "Uncompress"))
+                .str()
+          : "";
 
   for (auto &CompressPat : CompressPatterns) {
     if (EType == EmitterType::Uncompress && CompressPat.IsCompressOnly)
@@ -784,7 +790,7 @@
                 getPredicates(MCOpPredicateMap, MCOpPredicates, DestOperand.Rec,
                               "MCOperandPredicate");
             CondStream.indent(6)
-                << TargetName << "ValidateMCOperand("
+                << ValidatorName << "("
                 << "MI.getOperand(" << OpIdx << "), STI, " << Entry << ") &&\n";
           } else {
             unsigned Entry =
@@ -807,7 +813,7 @@
           unsigned Entry = getPredicates(MCOpPredicateMap, MCOpPredicates,
                                          DestOperand.Rec, "MCOperandPredicate");
           CondStream.indent(6)
-              << TargetName << "ValidateMCOperand("
+              << ValidatorName << "("
               << "MCOperand::createImm(" << DestOperandMap[OpNo].Data.Imm
               << "), STI, " << Entry << ") &&\n";
         } else {
@@ -847,8 +853,7 @@
   Func.indent(2) << "return false;\n}\n";
 
   if (!MCOpPredicates.empty()) {
-    o << "static bool " << TargetName
-      << "ValidateMCOperand(const MCOperand &MCOp,\n"
+    o << "static bool " << ValidatorName << "(const MCOperand &MCOp,\n"
       << "                  const MCSubtargetInfo &STI,\n"
       << "                  unsigned PredicateIndex) {\n"
       << "  switch (PredicateIndex) {\n"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141896.489711.patch
Type: text/x-patch
Size: 2062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230117/7682693f/attachment.bin>


More information about the llvm-commits mailing list