diff options
author | Chris Lattner <sabre@nondot.org> | 2005-09-26 21:53:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-09-26 21:53:26 +0000 |
commit | 6bc7e513d567002d0df10ca5cde8054d906f5d5c (patch) | |
tree | dee74da1d348f507a75ca052c8f8f8f82f3a2c97 | |
parent | ff0c1ef9eb9266acaf4bb956de17d6f6ceab87e0 (diff) |
implement a fixme: only select values once, even if used multiple times.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23454 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | utils/TableGen/DAGISelEmitter.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index ae38830a9d..77067806f2 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -1074,23 +1074,26 @@ void DAGISelEmitter::EmitMatchForPattern(TreePatternNode *N, << ".Val)) goto P" << PatternNo << "Fail;\n"; } - +/// CodeGenPatternResult - Emit the action for a pattern. Now that it has +/// matched, we actually have to build a DAG! unsigned DAGISelEmitter:: CodeGenPatternResult(TreePatternNode *N, unsigned &Ctr, std::map<std::string,std::string> &VariableMap, - std::ostream &OS){ + std::ostream &OS) { // This is something selected from the pattern we matched. if (!N->getName().empty()) { - const std::string &Val = VariableMap[N->getName()]; + std::string &Val = VariableMap[N->getName()]; assert(!Val.empty() && "Variable referenced but not defined and not caught earlier!"); if (Val[0] == 'T' && Val[1] == 'm' && Val[2] == 'p') { // Already selected this operand, just return the tmpval. - // FIXME: DO THIS. + return atoi(Val.c_str()+3); } else { unsigned ResNo = Ctr++; OS << " SDOperand Tmp" << ResNo << " = Select(" << Val << ");\n"; - // FIXME: Add Tmp<ResNo> to VariableMap. + // Add Tmp<ResNo> to VariableMap, so that we don't multiply select this + // value if used multiple times by this pattern result. + Val = "Tmp"+utostr(ResNo); return ResNo; } } |