Skip to content

[NFC][TableGen] Delete getLogicalOperandType from InstrInfoEmitter #125951

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
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 0 additions & 93 deletions llvm/utils/TableGen/InstrInfoEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ class InstrInfoEmitter {
void emitLogicalOperandSizeMappings(
raw_ostream &OS, StringRef Namespace,
ArrayRef<const CodeGenInstruction *> NumberedInstructions);
void emitLogicalOperandTypeMappings(
raw_ostream &OS, StringRef Namespace,
ArrayRef<const CodeGenInstruction *> NumberedInstructions);

// Operand information.
unsigned CollectOperandInfo(OperandInfoListTy &OperandInfoList,
Expand Down Expand Up @@ -556,93 +553,6 @@ void InstrInfoEmitter::emitLogicalOperandSizeMappings(
OS << "#endif // GET_INSTRINFO_LOGICAL_OPERAND_SIZE_MAP\n\n";
}

void InstrInfoEmitter::emitLogicalOperandTypeMappings(
raw_ostream &OS, StringRef Namespace,
ArrayRef<const CodeGenInstruction *> NumberedInstructions) {
std::map<std::vector<std::string>, unsigned> LogicalOpTypeMap;

std::map<unsigned, std::vector<std::string>> InstMap;

size_t OpTypeListSize = 0U;
std::vector<std::string> LogicalOpTypeList;
for (const auto *Inst : NumberedInstructions) {
if (!Inst->TheDef->getValueAsBit("UseLogicalOperandMappings"))
continue;

LogicalOpTypeList.clear();
for (const auto &Op : Inst->Operands) {
auto *OpR = Op.Rec;
if ((OpR->isSubClassOf("Operand") ||
OpR->isSubClassOf("RegisterOperand") ||
OpR->isSubClassOf("RegisterClass")) &&
!OpR->isAnonymous()) {
LogicalOpTypeList.push_back(
(Namespace + "::OpTypes::" + Op.Rec->getName()).str());
} else {
LogicalOpTypeList.push_back("-1");
}
}
OpTypeListSize = std::max(LogicalOpTypeList.size(), OpTypeListSize);

auto I =
LogicalOpTypeMap.insert({LogicalOpTypeList, LogicalOpTypeMap.size()})
.first;
InstMap[I->second].push_back(
(Namespace + "::" + Inst->TheDef->getName()).str());
}

OS << "#ifdef GET_INSTRINFO_LOGICAL_OPERAND_TYPE_MAP\n";
OS << "#undef GET_INSTRINFO_LOGICAL_OPERAND_TYPE_MAP\n";
OS << "namespace llvm::" << Namespace << " {\n";
OS << "LLVM_READONLY static int\n";
OS << "getLogicalOperandType(uint16_t Opcode, uint16_t LogicalOpIdx) {\n";
if (!InstMap.empty()) {
std::vector<const std::vector<std::string> *> LogicalOpTypeList(
LogicalOpTypeMap.size());
for (auto &P : LogicalOpTypeMap) {
LogicalOpTypeList[P.second] = &P.first;
}
OS << " static const int TypeMap[][" << OpTypeListSize << "] = {\n";
for (int r = 0, rs = LogicalOpTypeList.size(); r < rs; ++r) {
const auto &Row = *LogicalOpTypeList[r];
OS << " {";
int i, s = Row.size();
for (i = 0; i < s; ++i) {
if (i > 0)
OS << ", ";
OS << Row[i];
}
for (; i < static_cast<int>(OpTypeListSize); ++i) {
if (i > 0)
OS << ", ";
OS << "-1";
}
OS << "}";
if (r != rs - 1)
OS << ",";
OS << "\n";
}
OS << " };\n";

OS << " switch (Opcode) {\n";
OS << " default: return -1;\n";
for (auto &P : InstMap) {
auto OpMapIdx = P.first;
const auto &Insts = P.second;
for (const auto &Inst : Insts) {
OS << " case " << Inst << ":\n";
}
OS << " return TypeMap[" << OpMapIdx << "][LogicalOpIdx];\n";
}
OS << " }\n";
} else {
OS << " return -1;\n";
}
OS << "}\n";
OS << "} // end namespace llvm::" << Namespace << "\n";
OS << "#endif // GET_INSTRINFO_LOGICAL_OPERAND_TYPE_MAP\n\n";
}

void InstrInfoEmitter::emitMCIIHelperMethods(raw_ostream &OS,
StringRef TargetName) {
ArrayRef<const Record *> TIIPredicates =
Expand Down Expand Up @@ -1130,9 +1040,6 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
Timer.startTimer("Emit logical operand size mappings");
emitLogicalOperandSizeMappings(OS, TargetName, NumberedInstructions);

Timer.startTimer("Emit logical operand type mappings");
emitLogicalOperandTypeMappings(OS, TargetName, NumberedInstructions);

Timer.startTimer("Emit helper methods");
emitMCIIHelperMethods(OS, TargetName);

Expand Down