Skip to content

Commit

Permalink
[TableGen][NFC] Add postfix for validators of CompressPat
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pcwang-thead committed Jan 18, 2023
1 parent 28b6f38 commit fcc2e5a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions llvm/utils/TableGen/CompressInstEmitter.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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 =
Expand All @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit fcc2e5a

Please sign in to comment.