[llvm] 2eef875 - [TableGen] Avoid repeated lookups of Uses and Defs records. NFC.
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 23 10:46:39 PST 2023
Author: Jay Foad
Date: 2023-01-23T18:46:32Z
New Revision: 2eef8759152c7aba837addd8e90fda73c9c1f63e
URL: https://github.com/llvm/llvm-project/commit/2eef8759152c7aba837addd8e90fda73c9c1f63e
DIFF: https://github.com/llvm/llvm-project/commit/2eef8759152c7aba837addd8e90fda73c9c1f63e.diff
LOG: [TableGen] Avoid repeated lookups of Uses and Defs records. NFC.
Added:
Modified:
llvm/utils/TableGen/InstrInfoEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp
index a19ffb2ef2516..a378bd46ccf14 100644
--- a/llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -907,16 +907,19 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
// Emit all of the instruction's implicit uses and defs.
Records.startTimer("Emit uses/defs");
for (const CodeGenInstruction *II : Target.getInstructionsByEnumValue()) {
- Record *Inst = II->TheDef;
- std::vector<Record*> Uses = Inst->getValueAsListOfDefs("Uses");
- if (!Uses.empty()) {
- unsigned &IL = EmittedLists[Uses];
- if (!IL) PrintDefList(Uses, IL = ++ListNumber, OS);
+ if (!II->ImplicitUses.empty()) {
+ unsigned &IL = EmittedLists[II->ImplicitUses];
+ if (!IL) {
+ IL = ++ListNumber;
+ PrintDefList(II->ImplicitUses, IL, OS);
+ }
}
- std::vector<Record*> Defs = Inst->getValueAsListOfDefs("Defs");
- if (!Defs.empty()) {
- unsigned &IL = EmittedLists[Defs];
- if (!IL) PrintDefList(Defs, IL = ++ListNumber, OS);
+ if (!II->ImplicitDefs.empty()) {
+ unsigned &IL = EmittedLists[II->ImplicitDefs];
+ if (!IL) {
+ IL = ++ListNumber;
+ PrintDefList(II->ImplicitDefs, IL, OS);
+ }
}
}
@@ -1185,17 +1188,15 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
OS << "ULL, ";
// Emit the implicit uses and defs lists...
- std::vector<Record*> UseList = Inst.TheDef->getValueAsListOfDefs("Uses");
- if (UseList.empty())
+ if (Inst.ImplicitUses.empty())
OS << "nullptr, ";
else
- OS << "ImplicitList" << EmittedLists[UseList] << ", ";
+ OS << "ImplicitList" << EmittedLists[Inst.ImplicitUses] << ", ";
- std::vector<Record*> DefList = Inst.TheDef->getValueAsListOfDefs("Defs");
- if (DefList.empty())
+ if (Inst.ImplicitDefs.empty())
OS << "nullptr, ";
else
- OS << "ImplicitList" << EmittedLists[DefList] << ", ";
+ OS << "ImplicitList" << EmittedLists[Inst.ImplicitDefs] << ", ";
// Emit the operand info.
std::vector<std::string> OperandInfo = GetOperandInfo(Inst);
More information about the llvm-commits
mailing list