-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Delete `getLogicalOperandType` function from InstrInfoEmitter as no backend seems to use it.
@llvm/pr-subscribers-tablegen Author: Rahul Joshi (jurahul) Changes
Full diff: https://github.com/llvm/llvm-project/pull/125951.diff 1 Files Affected:
diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp
index 97c00ad4924197..b042a1c0c5cda0 100644
--- a/llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -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,
@@ -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 =
@@ -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);
|
mshockwave
approved these changes
Feb 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for preemptive approval, was waiting for checks to complete before starting review. |
Icohedron
pushed a commit
to Icohedron/llvm-project
that referenced
this pull request
Feb 11, 2025
…lvm#125951) Delete `getLogicalOperandType` function from InstrInfoEmitter as no backend seems to use it.
sivan-shani
pushed a commit
to sivan-shani/llvm-project
that referenced
this pull request
Feb 24, 2025
…lvm#125951) Delete `getLogicalOperandType` function from InstrInfoEmitter as no backend seems to use it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Delete
getLogicalOperandType
function from InstrInfoEmitter as no backend seems to use it.