[llvm] fcc2e5a - [TableGen][NFC] Add postfix for validators of CompressPat

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 22:34:31 PST 2023


Author: wangpc
Date: 2023-01-18T14:34:06+08:00
New Revision: fcc2e5aa39428c25f9d164d4a25a2a4dab4f0071

URL: https://github.com/llvm/llvm-project/commit/fcc2e5aa39428c25f9d164d4a25a2a4dab4f0071
DIFF: https://github.com/llvm/llvm-project/commit/fcc2e5aa39428c25f9d164d4a25a2a4dab4f0071.diff

LOG: [TableGen][NFC] Add postfix for validators of CompressPat

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

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D141896

Added: 
    

Modified: 
    llvm/utils/TableGen/CompressInstEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/CompressInstEmitter.cpp b/llvm/utils/TableGen/CompressInstEmitter.cpp
index 88e3c64d7c39e..a18d6a6b8854f 100644
--- a/llvm/utils/TableGen/CompressInstEmitter.cpp
+++ b/llvm/utils/TableGen/CompressInstEmitter.cpp
@@ -638,6 +638,12 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &o,
       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)
@@ -774,7 +780,7 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &o,
                 getPredicates(MCOpPredicateMap, MCOpPredicates, DestOperand.Rec,
                               "MCOperandPredicate");
             CondStream.indent(6)
-                << TargetName << "ValidateMCOperand("
+                << ValidatorName << "("
                 << "MI.getOperand(" << OpIdx << "), STI, " << Entry << ") &&\n";
           } else {
             unsigned Entry =
@@ -797,7 +803,7 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &o,
           unsigned Entry = getPredicates(MCOpPredicateMap, MCOpPredicates,
                                          DestOperand.Rec, "MCOperandPredicate");
           CondStream.indent(6)
-              << TargetName << "ValidateMCOperand("
+              << ValidatorName << "("
               << "MCOperand::createImm(" << DestOperandMap[OpNo].Data.Imm
               << "), STI, " << Entry << ") &&\n";
         } else {
@@ -837,8 +843,7 @@ void CompressInstEmitter::emitCompressInstEmitter(raw_ostream &o,
   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"


        


More information about the llvm-commits mailing list