[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Sep 23 17:51:03 PDT 2005
Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.39 -> 1.40
---
Log message:
memoize translations
---
Diffs of the changes: (+11 -0)
DAGISelEmitter.cpp | 11 +++++++++++
1 files changed, 11 insertions(+)
Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.39 llvm/utils/TableGen/DAGISelEmitter.cpp:1.40
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.39 Fri Sep 23 19:40:24 2005
+++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Sep 23 19:50:51 2005
@@ -1153,6 +1153,9 @@
unsigned TmpNo = 0;
unsigned Res = CodeGenPatternResult(Pattern.second, TmpNo, VariableMap, OS);
+
+ // Add the result to the map if it has multiple uses.
+ OS << " if (!N.Val->hasOneUse()) CodeGenMap[N] = Tmp" << Res << ";\n";
OS << " return Tmp" << Res << ";\n";
OS << " }\n P" << PatternNo << "Fail:\n";
}
@@ -1199,6 +1202,10 @@
<< " if (N.getOpcode() >= ISD::BUILTIN_OP_END &&\n"
<< " N.getOpcode() < PPCISD::FIRST_NUMBER)\n"
<< " return N; // Already selected.\n\n"
+ << " if (!N.Val->hasOneUse()) {\n"
+ << " std::map<SDOperand, SDOperand>::iterator CGMI = CodeGenMap.find(N);\n"
+ << " if (CGMI != CodeGenMap.end()) return CGMI->second;\n"
+ << " }\n"
<< " switch (N.getOpcode()) {\n"
<< " default: break;\n"
<< " case ISD::EntryToken: // These leaves remain the same.\n"
@@ -1250,6 +1257,10 @@
<< "// *** instruction selector class. These functions are really "
<< "methods.\n\n";
+ OS << "// Instance var to keep track of multiply used nodes that have \n"
+ << "// already been selected.\n"
+ << "std::map<SDOperand, SDOperand> CodeGenMap;\n";
+
ParseNodeInfo();
ParseNodeTransforms(OS);
ParsePatternFragments(OS);
More information about the llvm-commits
mailing list