diff options
author | Daniel Sanders <daniel_l_sanders@apple.com> | 2017-07-05 14:50:18 +0000 |
---|---|---|
committer | Daniel Sanders <daniel_l_sanders@apple.com> | 2017-07-05 14:50:18 +0000 |
commit | a6cfce6863a5a3f89e6674db7d58b9eb75b90a58 (patch) | |
tree | b04dcf4c087ad88dd0d0343dda671cf2b17e2807 /llvm/utils/TableGen/GlobalISelEmitter.cpp | |
parent | b78adec6386d4e375177cb1ae100b8d439290cae (diff) | |
download | bcm5719-llvm-a6cfce6863a5a3f89e6674db7d58b9eb75b90a58.tar.gz bcm5719-llvm-a6cfce6863a5a3f89e6674db7d58b9eb75b90a58.zip |
[globalisel][tablegen] Finish fixing compile-time regressions by merging the matcher and emitter state machines.
Summary:
Also, made a few minor tweaks to shave off a little more cumulative memory consumption:
* All rules share a single NewMIs instead of constructing their own. Only one
will end up using it.
* Use MIs.resize(1) instead of MIs.clear();MIs.push_back(I) and prevent
GIM_RecordInsn from changing MIs[0].
Depends on D33764
Reviewers: rovka, vitalybuka, ab, t.p.northover, qcolombet, aditya_nandakumar
Reviewed By: ab
Subscribers: kristof.beyls, igorb, llvm-commits
Differential Revision: https://reviews.llvm.org/D33766
llvm-svn: 307159
Diffstat (limited to 'llvm/utils/TableGen/GlobalISelEmitter.cpp')
-rw-r--r-- | llvm/utils/TableGen/GlobalISelEmitter.cpp | 62 |
1 files changed, 26 insertions, 36 deletions
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp index d4e487cf7de..c7eb7d02c0d 100644 --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -928,7 +928,7 @@ public: void emitCxxRenderStmts(raw_ostream &OS, RuleMatcher &Rule) const override { const OperandMatcher &Operand = Matched.getOperand(SymbolicName); unsigned OldInsnVarID = Rule.getInsnVarID(Operand.getInstructionMatcher()); - OS << " GIR_Copy, /*NewInsnID*/" << NewInsnID << ", /*OldInsnID*/" + OS << " GIR_Copy, /*NewInsnID*/" << NewInsnID << ", /*OldInsnID*/" << OldInsnVarID << ", /*OpIdx*/" << Operand.getOperandIndex() << ", // " << SymbolicName << "\n"; } @@ -964,7 +964,7 @@ public: void emitCxxRenderStmts(raw_ostream &OS, RuleMatcher &Rule) const override { const OperandMatcher &Operand = Matched.getOperand(SymbolicName); unsigned OldInsnVarID = Rule.getInsnVarID(Operand.getInstructionMatcher()); - OS << " GIR_CopySubReg, /*NewInsnID*/" << NewInsnID + OS << " GIR_CopySubReg, /*NewInsnID*/" << NewInsnID << ", /*OldInsnID*/" << OldInsnVarID << ", /*OpIdx*/" << Operand.getOperandIndex() << ", /*SubRegIdx*/" << SubReg->EnumValue << ", // " << SymbolicName << "\n"; @@ -1043,8 +1043,8 @@ public: } void emitCxxRenderStmts(raw_ostream &OS, RuleMatcher &Rule) const override { - OS << " GIR_ComplexRenderer, /*InsnID*/" << InsnID - << ", /*RendererID*/" << RendererID << ",\n"; + OS << " GIR_ComplexRenderer, /*InsnID*/" << InsnID << ", /*RendererID*/" + << RendererID << ",\n"; } }; @@ -1076,7 +1076,7 @@ public: void emitCxxActionStmts(raw_ostream &OS, RuleMatcher &Rule, unsigned RecycleInsnID) const override { - OS << " // " << *P.getSrcPattern() << " => " << *P.getDstPattern() + OS << " // " << *P.getSrcPattern() << " => " << *P.getDstPattern() << "\n"; } }; @@ -1123,7 +1123,7 @@ public: void emitCxxActionStmts(raw_ostream &OS, RuleMatcher &Rule, unsigned RecycleInsnID) const override { if (canMutate()) { - OS << " GIR_MutateOpcode, /*InsnID*/" << InsnID + OS << " GIR_MutateOpcode, /*InsnID*/" << InsnID << ", /*RecycleInsnID*/ " << RecycleInsnID << ", /*Opcode*/" << I->Namespace << "::" << I->TheDef->getName() << ",\n"; @@ -1132,14 +1132,14 @@ public: auto Namespace = Def->getValue("Namespace") ? Def->getValueAsString("Namespace") : ""; - OS << " GIR_AddImplicitDef, " << InsnID << ", " << Namespace + OS << " GIR_AddImplicitDef, " << InsnID << ", " << Namespace << "::" << Def->getName() << ",\n"; } for (auto Use : I->ImplicitUses) { auto Namespace = Use->getValue("Namespace") ? Use->getValueAsString("Namespace") : ""; - OS << " GIR_AddImplicitUse, " << InsnID << ", " << Namespace + OS << " GIR_AddImplicitUse, " << InsnID << ", " << Namespace << "::" << Use->getName() << ",\n"; } } @@ -1149,13 +1149,13 @@ public: // TODO: Simple permutation looks like it could be almost as common as // mutation due to commutative operations. - OS << " GIR_BuildMI, /*InsnID*/" << InsnID << ", /*Opcode*/" + OS << " GIR_BuildMI, /*InsnID*/" << InsnID << ", /*Opcode*/" << I->Namespace << "::" << I->TheDef->getName() << ",\n"; for (const auto &Renderer : OperandRenderers) Renderer->emitCxxRenderStmts(OS, Rule); - OS << " GIR_MergeMemOperands, /*InsnID*/" << InsnID << ",\n" - << " GIR_EraseFromParent, /*InsnID*/" << RecycleInsnID << ",\n"; + OS << " GIR_MergeMemOperands, /*InsnID*/" << InsnID << ",\n" + << " GIR_EraseFromParent, /*InsnID*/" << RecycleInsnID << ",\n"; } }; @@ -1169,7 +1169,7 @@ public: void emitCxxActionStmts(raw_ostream &OS, RuleMatcher &Rule, unsigned RecycleInsnID) const override { - OS << " GIR_ConstrainSelectedInstOperands, /*InsnID*/" << InsnID << ",\n"; + OS << " GIR_ConstrainSelectedInstOperands, /*InsnID*/" << InsnID << ",\n"; } }; @@ -1187,7 +1187,7 @@ public: void emitCxxActionStmts(raw_ostream &OS, RuleMatcher &Rule, unsigned RecycleInsnID) const override { - OS << " GIR_ConstrainOperandRC, /*InsnID*/" << InsnID << ", /*Op*/" + OS << " GIR_ConstrainOperandRC, /*InsnID*/" << InsnID << ", /*Op*/" << OpIdx << ", /*RC " << RC.getName() << "*/ " << RC.EnumValue << ",\n"; } }; @@ -1264,21 +1264,11 @@ void RuleMatcher::emit(raw_ostream &OS) { << ",\n"; } - emitCxxCaptureStmts(OS); Matchers.front()->emitCxxPredicateExpr(OS, *this, getInsnVarID(*Matchers.front())); - OS << " GIM_Accept,\n" - << " };\n" - << " State.MIs.clear();\n" - << " State.MIs.push_back(&I);\n" - << " DEBUG(dbgs() << \"Processing MatchTable" << CurrentMatchTableID - << "\\n\");\n" - << " if (executeMatchTable(*this, State, MatcherInfo, MatchTable" - << CurrentMatchTableID << ", MRI, TRI, RBI, AvailableFeatures)) {\n"; - // We must also check if it's safe to fold the matched instructions. if (InsnVariableIDs.size() >= 2) { // Invert the map to create stable ordering (by var names) @@ -1295,8 +1285,7 @@ void RuleMatcher::emit(raw_ostream &OS) { for (const auto &InsnID : InsnIDs) { // Reject the difficult cases until we have a more accurate check. - OS << " if (!isObviouslySafeToFold(*State.MIs[" << InsnID << "]))\n" - << " return false;\n"; + OS << " GIM_CheckIsSafeToFold, /*InsnID*/" << InsnID << ",\n"; // FIXME: Emit checks to determine it's _actually_ safe to fold and/or // account for unsafe cases. @@ -1335,19 +1324,17 @@ void RuleMatcher::emit(raw_ostream &OS) { } } - OS << " const static int64_t EmitTable" << CurrentMatchTableID << "[] = {\n"; for (const auto &MA : Actions) MA->emitCxxActionStmts(OS, *this, 0); - OS << " GIR_Done,\n" - << " };\n" - << " NewMIVector OutMIs;\n" - << " DEBUG(dbgs() << \"Processing EmitTable" << CurrentMatchTableID + OS << " GIR_Done,\n" + << " };\n" + << " State.MIs.resize(1);\n" + << " DEBUG(dbgs() << \"Processing MatchTable" << CurrentMatchTableID << "\\n\");\n" - << " executeEmitTable(OutMIs, State, EmitTable" << CurrentMatchTableID - << ", TII, TRI, RBI);\n"; - - OS << " return true;\n"; - OS << " }\n\n"; + << " if (executeMatchTable(*this, OutMIs, State, MatcherInfo, MatchTable" + << CurrentMatchTableID << ", TII, MRI, TRI, RBI, AvailableFeatures)) {\n" + << " return true;\n" + << " }\n\n"; } bool RuleMatcher::isHigherPriorityThan(const RuleMatcher &B) const { @@ -2169,7 +2156,10 @@ void GlobalISelEmitter::run(raw_ostream &OS) { "than per-insn.\n" << " AvailableFunctionFeatures = computeAvailableFunctionFeatures(&STI, " "&MF);\n" - << " const PredicateBitset AvailableFeatures = getAvailableFeatures();\n"; + << " const PredicateBitset AvailableFeatures = getAvailableFeatures();\n" + << " NewMIVector OutMIs;\n" + << " State.MIs.clear();\n" + << " State.MIs.push_back(&I);\n\n"; for (auto &Rule : Rules) { Rule.emit(OS); |