[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.297 -> 1.298 --- Log message: silence warning when assertions are disabled. --- Diffs of the changes: (+1 -2) DAGISelEmitter.cpp |3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.297 llvm/utils/TableGen/DAGISelEmitter.cpp:1.298 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.297Mon May 14 20:36:44 2007 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Jun 19 01:40:46 2007 @@ -1502,8 +1502,7 @@ unsigned NumResults = InstResults.size(); // Parse the operands list from the (ops) list, validating it. -std::vector &Args = I->getArgList(); -assert(Args.empty() && "Args list should still be empty here!"); +assert(I->getArgList().empty() && "Args list should still be empty here!"); CodeGenInstruction &CGI = Target.getInstruction(Instrs[i]->getName()); // Check that all of the results occur first in the list. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
>> If the bug was with ISD::Constant's, >> this is a serious bug and this is not the right fix. > > Huh? It has nothing to do with ISD::Constants. Remember > PredicateOperand with ExecuteAlways value is not part of the target > independent DAG. So something like this: > > def BL : I<(ops i32imm:$func, pred:$p, variable_ops), ...> > > The input node should have 2 operands (plus one if it has the > optional flag) plus the variable ops. The emit code has like this: > >for (unsigned i = 2, e = N.getNumOperands()-(HasInFlag?1:0); i != > e; ++i) { > AddToISelQueue(N.getOperand(i)); > Ops0.push_back(N.getOperand(i)); >} > > If we don't discount NumEAInputs (i.e. 1 in this case, to account for > the single ExecuteAlways value), i's starting value is 3 and that's > bad. Ahhh, so you're trying to avoid stepping on operands that don't exist... you're not trying to avoid selecting some operands that do exist? If so, that makes sense :) -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
On May 14, 2007, at 10:57 PM, Chris Lattner wrote: >> PredicateOperand related bug fix. >> @@ -2899,7 +2901,7 @@ >>else if (NodeHasOptInFlag) >> EndAdjust = "-(HasInFlag?1:0)"; // May have a flag. >> >> - emitCode("for (unsigned i = " + utostr(NumInputs) + >> + emitCode("for (unsigned i = " + utostr(NumInputs - >> NumEAInputs) + >> ", e = N.getNumOperands()" + EndAdjust + "; i ! >> = e; ++i) {"); >> > > Out of curiousity, why is this needed? Did you hit a bug with > something when it got selected? Yes. > If the bug was with ISD::Constant's, > this is a serious bug and this is not the right fix. Huh? It has nothing to do with ISD::Constants. Remember PredicateOperand with ExecuteAlways value is not part of the target independent DAG. So something like this: def BL : I<(ops i32imm:$func, pred:$p, variable_ops), ...> The input node should have 2 operands (plus one if it has the optional flag) plus the variable ops. The emit code has like this: for (unsigned i = 2, e = N.getNumOperands()-(HasInFlag?1:0); i != e; ++i) { AddToISelQueue(N.getOperand(i)); Ops0.push_back(N.getOperand(i)); } If we don't discount NumEAInputs (i.e. 1 in this case, to account for the single ExecuteAlways value), i's starting value is 3 and that's bad. Evan > > -Chris > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
> PredicateOperand related bug fix. > @@ -2899,7 +2901,7 @@ >else if (NodeHasOptInFlag) > EndAdjust = "-(HasInFlag?1:0)"; // May have a flag. > > - emitCode("for (unsigned i = " + utostr(NumInputs) + > + emitCode("for (unsigned i = " + utostr(NumInputs - > NumEAInputs) + > ", e = N.getNumOperands()" + EndAdjust + "; i ! > = e; ++i) {"); > Out of curiousity, why is this needed? Did you hit a bug with something when it got selected? If the bug was with ISD::Constant's, this is a serious bug and this is not the right fix. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.296 -> 1.297 --- Log message: Fix CodeGen/PowerPC/2007-05-14-InlineAsmSelectCrash.ll, the other recent patches are also needed. --- Diffs of the changes: (+7 -5) DAGISelEmitter.cpp | 12 +++- 1 files changed, 7 insertions(+), 5 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.296 llvm/utils/TableGen/DAGISelEmitter.cpp:1.297 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.296Mon May 14 20:19:51 2007 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon May 14 20:36:44 2007 @@ -3685,11 +3685,12 @@ // Emit boilerplate. OS << "SDNode *Select_INLINEASM(SDOperand N) {\n" << " std::vector Ops(N.Val->op_begin(), N.Val->op_end());\n" - << " AddToISelQueue(N.getOperand(0)); // Select the chain.\n\n" - << " // Select the flag operand.\n" - << " if (Ops.back().getValueType() == MVT::Flag)\n" - << "AddToISelQueue(Ops.back());\n" - << " SelectInlineAsmMemoryOperands(Ops, *CurDAG);\n" + << " SelectInlineAsmMemoryOperands(Ops, *CurDAG);\n\n" + + << " // Ensure that the asm operands are themselves selected.\n" + << " for (unsigned j = 0, e = Ops.size(); j != e; ++j)\n" + << "AddToISelQueue(Ops[j]);\n\n" + << " std::vector VTs;\n" << " VTs.push_back(MVT::Other);\n" << " VTs.push_back(MVT::Flag);\n" @@ -3725,6 +3726,7 @@ << " case ISD::TargetConstant:\n" << " case ISD::TargetConstantPool:\n" << " case ISD::TargetFrameIndex:\n" + << " case ISD::TargetExternalSymbol:\n" << " case ISD::TargetJumpTable:\n" << " case ISD::TargetGlobalTLSAddress:\n" << " case ISD::TargetGlobalAddress: {\n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.295 -> 1.296 --- Log message: PredicateOperand related bug fix. --- Diffs of the changes: (+3 -1) DAGISelEmitter.cpp |4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.295 llvm/utils/TableGen/DAGISelEmitter.cpp:1.296 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.295Tue May 8 16:04:07 2007 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon May 14 20:19:51 2007 @@ -2799,6 +2799,7 @@ // in the 'execute always' values. Match up the node operands to the // instruction operands to do this. std::vector AllOps; + unsigned NumEAInputs = 0; // # of synthesized 'execute always' inputs. for (unsigned ChildNo = 0, InstOpNo = NumResults; InstOpNo != II.OperandList.size(); ++InstOpNo) { std::vector Ops; @@ -2821,6 +2822,7 @@ Ops = EmitResultCode(Pred.AlwaysOps[i], RetSelected, InFlagDecled, ResNodeDecled); AllOps.insert(AllOps.end(), Ops.begin(), Ops.end()); +NumEAInputs += Ops.size(); } } } @@ -2899,7 +2901,7 @@ else if (NodeHasOptInFlag) EndAdjust = "-(HasInFlag?1:0)"; // May have a flag. - emitCode("for (unsigned i = " + utostr(NumInputs) + + emitCode("for (unsigned i = " + utostr(NumInputs - NumEAInputs) + ", e = N.getNumOperands()" + EndAdjust + "; i != e; ++i) {"); emitCode(" AddToISelQueue(N.getOperand(i));"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.294 -> 1.295 --- Log message: If a PredicateOperand has an empty ExecuteAlways field, treat it as if a normal operand for isel. --- Diffs of the changes: (+9 -4) DAGISelEmitter.cpp | 13 + 1 files changed, 9 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.294 llvm/utils/TableGen/DAGISelEmitter.cpp:1.295 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.294Thu Apr 26 12:03:22 2007 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue May 8 16:04:07 2007 @@ -775,8 +775,10 @@ Record *OperandNode = Inst.getOperand(i); // If the instruction expects a predicate operand, we codegen this by - // setting the predicate to it's "execute always" value. - if (OperandNode->isSubClassOf("PredicateOperand")) + // setting the predicate to it's "execute always" value if it has a + // non-empty ExecuteAlways field. + if (OperandNode->isSubClassOf("PredicateOperand") && + !ISE.getPredicateOperand(OperandNode).AlwaysOps.empty()) continue; // Verify that we didn't run out of provided operands. @@ -2801,8 +2803,11 @@ InstOpNo != II.OperandList.size(); ++InstOpNo) { std::vector Ops; -// If this is a normal operand, emit it. -if (!II.OperandList[InstOpNo].Rec->isSubClassOf("PredicateOperand")) { +// If this is a normal operand or a predicate operand without +// 'execute always', emit it. +Record *OperandNode = II.OperandList[InstOpNo].Rec; +if (!OperandNode->isSubClassOf("PredicateOperand") || +ISE.getPredicateOperand(OperandNode).AlwaysOps.empty()) { Ops = EmitResultCode(N->getChild(ChildNo), RetSelected, InFlagDecled, ResNodeDecled); AllOps.insert(AllOps.end(), Ops.begin(), Ops.end()); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.293 -> 1.294 --- Log message: bugfix: remember that ResNode was declared. --- Diffs of the changes: (+3 -2) DAGISelEmitter.cpp |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.293 llvm/utils/TableGen/DAGISelEmitter.cpp:1.294 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.293Fri Apr 20 16:38:10 2007 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Apr 26 12:03:22 2007 @@ -2851,9 +2851,10 @@ Code2 = "SDOperand " + NodeName + " = SDOperand("; } else { NodeName = "ResNode"; - if (!ResNodeDecled) + if (!ResNodeDecled) { Code2 = "SDNode *" + NodeName + " = "; - else +ResNodeDecled = true; + } else Code2 = NodeName + " = "; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.292 -> 1.293 --- Log message: Implement "general dynamic", "initial exec" and "local exec" TLS models for X86 32 bits. --- Diffs of the changes: (+5 -2) DAGISelEmitter.cpp |7 +-- 1 files changed, 5 insertions(+), 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.292 llvm/utils/TableGen/DAGISelEmitter.cpp:1.293 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.292Fri Jan 26 17:00:54 2007 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Apr 20 16:38:10 2007 @@ -2654,10 +2654,12 @@ } else { NodeOps.push_back(Val); } - } else if (!N->isLeaf() && N->getOperator()->getName() == "tglobaladdr") { + } else if (!N->isLeaf() && (N->getOperator()->getName() == "tglobaladdr" + || N->getOperator()->getName() == "tglobaltlsaddr")) { Record *Op = OperatorMap[N->getName()]; // Transform GlobalAddress to TargetGlobalAddress -if (Op && Op->getName() == "globaladdr") { +if (Op && (Op->getName() == "globaladdr" || + Op->getName() == "globaltlsaddr")) { emitCode("SDOperand Tmp" + utostr(ResNo) + " = CurDAG->getTarget" "GlobalAddress(cast(" + Val + ")->getGlobal(), " + getEnumName(N->getTypeNum(0)) + @@ -3716,6 +3718,7 @@ << " case ISD::TargetConstantPool:\n" << " case ISD::TargetFrameIndex:\n" << " case ISD::TargetJumpTable:\n" + << " case ISD::TargetGlobalTLSAddress:\n" << " case ISD::TargetGlobalAddress: {\n" << "return NULL;\n" << " }\n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.291 -> 1.292 --- Log message: Make the constant honest. --- Diffs of the changes: (+3 -1) DAGISelEmitter.cpp |4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.291 llvm/utils/TableGen/DAGISelEmitter.cpp:1.292 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.291Fri Jan 26 11:29:20 2007 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Jan 26 17:00:54 2007 @@ -3691,9 +3691,11 @@ OS << "SDNode *Select_LABEL(const SDOperand &N) {\n" << " SDOperand Chain = N.getOperand(0);\n" << " SDOperand N1 = N.getOperand(1);\n" + << " unsigned C = cast(N1)->getValue();\n" + << " SDOperand Tmp = CurDAG->getTargetConstant(C, MVT::i32);\n" << " AddToISelQueue(Chain);\n" << " return CurDAG->getTargetNode(TargetInstrInfo::LABEL,\n" - << " MVT::Other, N1, Chain);\n" + << " MVT::Other, Tmp, Chain);\n" << "}\n\n"; OS << "// The main instruction selector code.\n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.289 -> 1.290 --- Log message: Make tblgen error more useful. Patch by B. Scott Michel --- Diffs of the changes: (+4 -1) DAGISelEmitter.cpp |5 - 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.289 llvm/utils/TableGen/DAGISelEmitter.cpp:1.290 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.289Thu Dec 7 16:21:48 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Jan 17 01:45:12 2007 @@ -2621,7 +2621,10 @@ assert(N->getExtTypes().size() == 1 && "Multiple types not handled!"); std::string CastType; switch (N->getTypeNum(0)) { -default: assert(0 && "Unknown type for constant node!"); +default: + cerr << "Cannot handle " << getEnumName(N->getTypeNum(0)) + << " type as an immediate constant. Aborting\n"; + abort(); case MVT::i1: CastType = "bool"; break; case MVT::i8: CastType = "unsigned char"; break; case MVT::i16: CastType = "unsigned short"; break; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.286 -> 1.287 --- Log message: restore some 'magic' code that I removed: it is needed. Add comments explaining why. --- Diffs of the changes: (+22 -10) DAGISelEmitter.cpp | 32 ++-- 1 files changed, 22 insertions(+), 10 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.286 llvm/utils/TableGen/DAGISelEmitter.cpp:1.287 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.286Tue Nov 14 15:50:27 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 16:17:10 2006 @@ -3602,10 +3602,15 @@ // Print function. std::string OpVTStr; - if (OpVT == MVT::iPTR) -OpVTStr = "iPTR"; - else -OpVTStr = getEnumName(OpVT).substr(5); // Skip 'MVT::' + if (OpVT == MVT::iPTR) { +OpVTStr = "_iPTR"; + } else if (OpVT == MVT::isVoid) { +// Nodes with a void result actually have a first result type of either +// Other (a chain) or Flag. Since there is no one-to-one mapping from +// void to this case, we handle it specially here. + } else { +OpVTStr = "_" + getEnumName(OpVT).substr(5); // Skip 'MVT::' + } std::map >::iterator OpVTI = OpcodeVTMap.find(OpName); if (OpVTI == OpcodeVTMap.end()) { @@ -3616,7 +3621,7 @@ OpVTI->second.push_back(OpVTStr); OS << "SDNode *Select_" << getLegalCName(OpName) - << "_" << OpVTStr << "(const SDOperand &N) {\n"; + << OpVTStr << "(const SDOperand &N) {\n"; // Loop through and reverse all of the CodeList vectors, as we will be // accessing them from their logical front, but accessing the end of a @@ -3723,25 +3728,29 @@ if (OpVTs.size() == 1) { std::string &VTStr = OpVTs[0]; OS << "return Select_" << getLegalCName(OpName) - << (VTStr != "" ? "_" : "") << VTStr << "(N);\n"; + << VTStr << "(N);\n"; } else { // Keep track of whether we see a pattern that has an iPtr result. bool HasPtrPattern = false; + bool HasDefaultPattern = false; OS << "switch (NVT) {\n"; for (unsigned i = 0, e = OpVTs.size(); i < e; ++i) { std::string &VTStr = OpVTs[i]; -assert(!VTStr.empty() && "Unset vtstr?"); +if (VTStr.empty()) { + HasDefaultPattern = true; + continue; +} // If this is a match on iPTR: don't emit it directly, we need special // code. -if (VTStr == "iPTR") { +if (VTStr == "_iPTR") { HasPtrPattern = true; continue; } -OS << "case MVT::" << VTStr << ":\n" +OS << "case MVT::" << VTStr.substr(1) << ":\n" << " return Select_" << getLegalCName(OpName) - << "_" << VTStr << "(N);\n"; + << VTStr << "(N);\n"; } OS << "default:\n"; @@ -3750,6 +3759,9 @@ OS << " if (NVT == TLI.getPointerTy())\n"; OS << "return Select_" << getLegalCName(OpName) <<"_iPTR(N);\n"; } + if (HasDefaultPattern) { +OS << " return Select_" << getLegalCName(OpName) << "(N);\n"; + } OS << " break;\n"; OS << "}\n"; OS << "break;\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.285 -> 1.286 --- Log message: minimal hack to get patterns whose result type is iPTR to be selected. --- Diffs of the changes: (+16 -0) DAGISelEmitter.cpp | 16 1 files changed, 16 insertions(+) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.285 llvm/utils/TableGen/DAGISelEmitter.cpp:1.286 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.285Tue Nov 14 15:41:35 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 15:50:27 2006 @@ -3725,15 +3725,31 @@ OS << "return Select_" << getLegalCName(OpName) << (VTStr != "" ? "_" : "") << VTStr << "(N);\n"; } else { + // Keep track of whether we see a pattern that has an iPtr result. + bool HasPtrPattern = false; + OS << "switch (NVT) {\n"; for (unsigned i = 0, e = OpVTs.size(); i < e; ++i) { std::string &VTStr = OpVTs[i]; assert(!VTStr.empty() && "Unset vtstr?"); + +// If this is a match on iPTR: don't emit it directly, we need special +// code. +if (VTStr == "iPTR") { + HasPtrPattern = true; + continue; +} OS << "case MVT::" << VTStr << ":\n" << " return Select_" << getLegalCName(OpName) << "_" << VTStr << "(N);\n"; } OS << "default:\n"; + + // If there is an iPTR result version of this pattern, emit it here. + if (HasPtrPattern) { +OS << " if (NVT == TLI.getPointerTy())\n"; +OS << "return Select_" << getLegalCName(OpName) <<"_iPTR(N);\n"; + } OS << " break;\n"; OS << "}\n"; OS << "break;\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.284 -> 1.285 --- Log message: remove some dead code --- Diffs of the changes: (+2 -9) DAGISelEmitter.cpp | 11 ++- 1 files changed, 2 insertions(+), 9 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.284 llvm/utils/TableGen/DAGISelEmitter.cpp:1.285 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.284Tue Nov 14 15:32:01 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 15:41:35 2006 @@ -3725,23 +3725,16 @@ OS << "return Select_" << getLegalCName(OpName) << (VTStr != "" ? "_" : "") << VTStr << "(N);\n"; } else { - int Default = -1; OS << "switch (NVT) {\n"; for (unsigned i = 0, e = OpVTs.size(); i < e; ++i) { std::string &VTStr = OpVTs[i]; -if (VTStr == "") { - Default = i; - continue; -} +assert(!VTStr.empty() && "Unset vtstr?"); OS << "case MVT::" << VTStr << ":\n" << " return Select_" << getLegalCName(OpName) << "_" << VTStr << "(N);\n"; } OS << "default:\n"; - if (Default != -1) -OS << " return Select_" << getLegalCName(OpName) << "(N);\n"; - else - OS << " break;\n"; + OS << " break;\n"; OS << "}\n"; OS << "break;\n"; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.283 -> 1.284 --- Log message: Add support for nodes that return iPTR. --- Diffs of the changes: (+6 -4) DAGISelEmitter.cpp | 10 ++ 1 files changed, 6 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.283 llvm/utils/TableGen/DAGISelEmitter.cpp:1.284 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.283Tue Nov 14 15:18:40 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 15:32:01 2006 @@ -3601,8 +3601,11 @@ } // Print function. - std::string OpVTStr = (OpVT != MVT::isVoid && OpVT != MVT::iPTR) -? getEnumName(OpVT).substr(5) : "" ; + std::string OpVTStr; + if (OpVT == MVT::iPTR) +OpVTStr = "iPTR"; + else +OpVTStr = getEnumName(OpVT).substr(5); // Skip 'MVT::' std::map >::iterator OpVTI = OpcodeVTMap.find(OpName); if (OpVTI == OpcodeVTMap.end()) { @@ -3613,8 +3616,7 @@ OpVTI->second.push_back(OpVTStr); OS << "SDNode *Select_" << getLegalCName(OpName) - << (OpVTStr != "" ? "_" : "") - << OpVTStr << "(const SDOperand &N) {\n"; + << "_" << OpVTStr << "(const SDOperand &N) {\n"; // Loop through and reverse all of the CodeList vectors, as we will be // accessing them from their logical front, but accessing the end of a ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.282 -> 1.283 --- Log message: changes to get ptr_rc to be accepted in patterns. This is needed for ppc preinc stores. --- Diffs of the changes: (+22 -8) DAGISelEmitter.cpp | 30 ++ 1 files changed, 22 insertions(+), 8 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.282 llvm/utils/TableGen/DAGISelEmitter.cpp:1.283 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.282Tue Nov 14 12:41:38 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 15:18:40 2006 @@ -618,6 +618,9 @@ std::vector ComplexPat(1, TP.getDAGISelEmitter().getComplexPattern(R).getValueType()); return ComplexPat; + } else if (R->getName() == "ptr_rc") { +Other[0] = MVT::iPTR; +return Other; } else if (R->getName() == "node" || R->getName() == "srcvalue") { // Placeholder. return Unknown; @@ -747,16 +750,23 @@ CodeGenInstruction &InstInfo = ISE.getTargetInfo().getInstruction(getOperator()->getName()); // Apply the result type to the node -if (NumResults == 0 || InstInfo.noResults) { // FIXME: temporary hack... +if (NumResults == 0 || InstInfo.noResults) { // FIXME: temporary hack. MadeChange = UpdateNodeType(MVT::isVoid, TP); } else { Record *ResultNode = Inst.getResult(0); - assert(ResultNode->isSubClassOf("RegisterClass") && - "Operands should be register classes!"); + + if (ResultNode->getName() == "ptr_rc") { +std::vector VT; +VT.push_back(MVT::iPTR); +MadeChange = UpdateNodeType(VT, TP); + } else { +assert(ResultNode->isSubClassOf("RegisterClass") && + "Operands should be register classes!"); - const CodeGenRegisterClass &RC = -ISE.getTargetInfo().getRegisterClass(ResultNode); - MadeChange = UpdateNodeType(ConvertVTs(RC.getValueTypes()), TP); +const CodeGenRegisterClass &RC = + ISE.getTargetInfo().getRegisterClass(ResultNode); +MadeChange = UpdateNodeType(ConvertVTs(RC.getValueTypes()), TP); + } } unsigned ChildNo = 0; @@ -782,6 +792,8 @@ } else if (OperandNode->isSubClassOf("Operand")) { VT = getValueType(OperandNode->getValueAsDef("Type")); MadeChange |= Child->UpdateNodeType(VT, TP); + } else if (OperandNode->getName() == "ptr_rc") { +MadeChange |= Child->UpdateNodeType(MVT::iPTR, TP); } else { assert(0 && "Unknown operand type!"); abort(); @@ -1381,7 +1393,8 @@ if (!Val) I->error("set destination should be a register!"); -if (Val->getDef()->isSubClassOf("RegisterClass")) { +if (Val->getDef()->isSubClassOf("RegisterClass") || +Val->getDef()->getName() == "ptr_rc") { if (Dest->getName().empty()) I->error("set destination must have a name!"); if (InstResults.count(Dest->getName())) @@ -2507,7 +2520,8 @@ // Handle leaves of various types. if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { Record *LeafRec = DI->getDef(); -if (LeafRec->isSubClassOf("RegisterClass")) { +if (LeafRec->isSubClassOf("RegisterClass") || +LeafRec->getName() == "ptr_rc") { // Handle register references. Nothing to do here. } else if (LeafRec->isSubClassOf("Register")) { // Handle register references. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.281 -> 1.282 --- Log message: Fix a bug handling nodes with variable arguments. The code was fixed to assume that there were two input operands before the variable operand portion. This *happened* to be true for all call instructions, which took a chain and a destination, but was not true for the PPC BCTRL instruction, whose destination is implicit. Making this code more general allows elimination of the custom selection logic for BCTRL. --- Diffs of the changes: (+15 -8) DAGISelEmitter.cpp | 23 +++ 1 files changed, 15 insertions(+), 8 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.281 llvm/utils/TableGen/DAGISelEmitter.cpp:1.282 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.281Wed Nov 8 17:01:03 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Nov 14 12:41:38 2006 @@ -2852,6 +2852,11 @@ if (NodeHasOutFlag) Code += ", MVT::Flag"; +// Figure out how many fixed inputs the node has. This is important to +// know which inputs are the variable ones if present. +unsigned NumInputs = AllOps.size(); +NumInputs += NodeHasChain; + // Inputs. if (HasVarOps) { for (unsigned i = 0, e = AllOps.size(); i != e; ++i) @@ -2860,15 +2865,17 @@ } if (HasVarOps) { + // Figure out whether any operands at the end of the op list are not + // part of the variable section. + std::string EndAdjust; if (NodeHasInFlag || HasImpInputs) -emitCode("for (unsigned i = 2, e = N.getNumOperands()-1; " - "i != e; ++i) {"); - else if (NodeHasOptInFlag) -emitCode("for (unsigned i = 2, e = N.getNumOperands()-" - "(HasInFlag?1:0); i != e; ++i) {"); - else -emitCode("for (unsigned i = 2, e = N.getNumOperands(); " - "i != e; ++i) {"); +EndAdjust = "-1"; // Always has one flag. + else if (NodeHasOptInFlag) +EndAdjust = "-(HasInFlag?1:0)"; // May have a flag. + + emitCode("for (unsigned i = " + utostr(NumInputs) + + ", e = N.getNumOperands()" + EndAdjust + "; i != e; ++i) {"); + emitCode(" AddToISelQueue(N.getOperand(i));"); emitCode(" Ops" + utostr(OpsNo) + ".push_back(N.getOperand(i));"); emitCode("}"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.280 -> 1.281 --- Log message: Divide select methods into groups by SelectionDAG node opcodes (ISD::ADD, X86ISD::CMP, etc.) instead of SDNode names (add, x86cmp, etc). We now allow multiple SDNodes to map to the same SelectionDAG node (e.g. store, indexed store). --- Diffs of the changes: (+35 -46) DAGISelEmitter.cpp | 81 ++--- 1 files changed, 35 insertions(+), 46 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.280 llvm/utils/TableGen/DAGISelEmitter.cpp:1.281 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.280Wed Nov 8 14:31:10 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Nov 8 17:01:03 2006 @@ -3374,19 +3374,16 @@ OS << std::string(Indent-2, ' ') << "}\n"; } +static std::string getOpcodeName(Record *Op, DAGISelEmitter &ISE) { + const SDNodeInfo &OpcodeInfo = ISE.getSDNodeInfo(Op); + return OpcodeInfo.getEnumName(); +} - -namespace { - /// CompareByRecordName - An ordering predicate that implements less-than by - /// comparing the names records. - struct CompareByRecordName { -bool operator()(const Record *LHS, const Record *RHS) const { - // Sort by name first. - if (LHS->getName() < RHS->getName()) return true; - // If both names are equal, sort by pointer. - return LHS->getName() == RHS->getName() && LHS < RHS; -} - }; +static std::string getLegalCName(std::string OpName) { + std::string::size_type pos = OpName.find("::"); + if (pos != std::string::npos) +OpName.replace(pos, 2, "_"); + return OpName; } void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) { @@ -3394,23 +3391,25 @@ if (!InstNS.empty()) InstNS += "::"; // Group the patterns by their top-level opcodes. - std::map, -CompareByRecordName> PatternsByOpcode; + std::map > PatternsByOpcode; // All unique target node emission functions. std::map EmitFunctions; for (unsigned i = 0, e = PatternsToMatch.size(); i != e; ++i) { TreePatternNode *Node = PatternsToMatch[i].getSrcPattern(); if (!Node->isLeaf()) { - PatternsByOpcode[Node->getOperator()].push_back(&PatternsToMatch[i]); + PatternsByOpcode[getOpcodeName(Node->getOperator(), *this)]. +push_back(&PatternsToMatch[i]); } else { const ComplexPattern *CP; if (dynamic_cast(Node->getLeafValue())) { -PatternsByOpcode[getSDNodeNamed("imm")].push_back(&PatternsToMatch[i]); +PatternsByOpcode[getOpcodeName(getSDNodeNamed("imm"), *this)]. + push_back(&PatternsToMatch[i]); } else if ((CP = NodeGetComplexPattern(Node, *this))) { std::vector OpNodes = CP->getRootNodes(); for (unsigned j = 0, e = OpNodes.size(); j != e; j++) { - PatternsByOpcode[OpNodes[j]] -.insert(PatternsByOpcode[OpNodes[j]].begin(), &PatternsToMatch[i]); + PatternsByOpcode[getOpcodeName(OpNodes[j], *this)] +.insert(PatternsByOpcode[getOpcodeName(OpNodes[j], *this)].begin(), +&PatternsToMatch[i]); } } else { std::cerr << "Unrecognized opcode '"; @@ -3432,11 +3431,10 @@ // Emit one Select_* method for each top-level opcode. We do this instead of // emitting one giant switch statement to support compilers where this will // result in the recursive functions taking less stack space. - for (std::map, - CompareByRecordName>::iterator PBOI = PatternsByOpcode.begin(), - E = PatternsByOpcode.end(); PBOI != E; ++PBOI) { -const std::string &OpName = PBOI->first->getName(); -const SDNodeInfo &OpcodeInfo = getSDNodeInfo(PBOI->first); + for (std::map >::iterator + PBOI = PatternsByOpcode.begin(), E = PatternsByOpcode.end(); + PBOI != E; ++PBOI) { +const std::string &OpName = PBOI->first; std::vector &PatternsOfOp = PBOI->second; assert(!PatternsOfOp.empty() && "No patterns but map has entry?"); @@ -3451,8 +3449,6 @@ for (unsigned i = 0, e = PatternsOfOp.size(); i != e; ++i) { PatternToMatch *Pat = PatternsOfOp[i]; TreePatternNode *SrcPat = Pat->getSrcPattern(); - if (OpcodeInfo.getNumResults() == 0 && SrcPat->getNumChildren() > 0) -SrcPat = SrcPat->getChild(0); MVT::ValueType VT = SrcPat->getTypeNum(0); std::map >::iterator TI = PatternsByType.find(VT); @@ -3595,7 +3591,8 @@ } else OpVTI->second.push_back(OpVTStr); - OS << "SDNode *Select_" << OpName << (OpVTStr != "" ? "_" : "") + OS << "SDNode *Select_" << getLegalCName(OpName) + << (OpVTStr != "" ? "_" : "") << OpVTStr << "(const SDOperand &N) {\n"; // Loop through and reverse all of the CodeList vectors, as we will be @@ -3616,9 +3613,9 @@ // catch the case where nothing handles a pattern. if (mightNotMatch) { OS << " std::ce
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.279 -> 1.280 --- Log message: Always pass the root node to ComplexPattern isel matching function. --- Diffs of the changes: (+3 -4) DAGISelEmitter.cpp |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.279 llvm/utils/TableGen/DAGISelEmitter.cpp:1.280 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.279Fri Nov 3 23:12:02 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Nov 8 14:31:10 2006 @@ -2464,7 +2464,7 @@ emitCode("SDOperand Chain" + ChainSuffix + ";"); } - std::string Code = Fn + "(" + RootName; + std::string Code = Fn + "(" + RootName + ", " + RootName; for (unsigned i = 0; i < NumOps; i++) Code += ", CPTmp" + utostr(i); if (CP->hasProperty(SDNPHasChain)) { @@ -2531,10 +2531,10 @@ emitCode("SDOperand " + ChainName + ";"); } - std::string Code = Fn + "("; + std::string Code = Fn + "(N, "; if (CP->hasProperty(SDNPHasChain)) { std::string ParentName(RootName.begin(), RootName.end()-1); -Code += "N, " + ParentName + ", "; +Code += ParentName + ", "; } Code += RootName; for (unsigned i = 0; i < NumOps; i++) @@ -2662,7 +2662,6 @@ // value if used multiple times by this pattern result. Val = "Tmp"+utostr(ResNo); } else if (N->isLeaf() && (CP = NodeGetComplexPattern(N, ISE))) { -std::string Fn = CP->getSelectFunc(); for (unsigned i = 0; i < CP->getNumOperands(); ++i) { emitCode("AddToISelQueue(CPTmp" + utostr(i) + ");"); NodeOps.push_back("CPTmp" + utostr(i)); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.278 -> 1.279 DAGISelEmitter.h updated: 1.70 -> 1.71 --- Log message: Parse PredicateOperand's. When an instruction takes one, have the generated isel fill in the instruction operands with the 'execute always' value automatically. --- Diffs of the changes: (+86 -6) DAGISelEmitter.cpp | 80 + DAGISelEmitter.h | 12 +++ 2 files changed, 86 insertions(+), 6 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.278 llvm/utils/TableGen/DAGISelEmitter.cpp:1.279 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.278Fri Nov 3 19:35:50 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Nov 3 23:12:02 2006 @@ -1230,6 +1230,50 @@ } } +void DAGISelEmitter::ParsePredicateOperands() { + std::vector PredOps = +Records.getAllDerivedDefinitions("PredicateOperand"); + + // Find some SDNode. + assert(!SDNodes.empty() && "No SDNodes parsed?"); + Init *SomeSDNode = new DefInit(SDNodes.begin()->first); + + for (unsigned i = 0, e = PredOps.size(); i != e; ++i) { +DagInit *AlwaysInfo = PredOps[i]->getValueAsDag("ExecuteAlways"); + +// Clone the AlwaysInfo dag node, changing the operator from 'ops' to +// SomeSDnode so that we can parse this. +std::vector > Ops; +for (unsigned op = 0, e = AlwaysInfo->getNumArgs(); op != e; ++op) + Ops.push_back(std::make_pair(AlwaysInfo->getArg(op), + AlwaysInfo->getArgName(op))); +DagInit *DI = new DagInit(SomeSDNode, Ops); + +// Create a TreePattern to parse this. +TreePattern P(PredOps[i], DI, false, *this); +assert(P.getNumTrees() == 1 && "This ctor can only produce one tree!"); + +// Copy the operands over into a DAGPredicateOperand. +DAGPredicateOperand PredOpInfo; + +TreePatternNode *T = P.getTree(0); +for (unsigned op = 0, e = T->getNumChildren(); op != e; ++op) { + TreePatternNode *TPN = T->getChild(op); + while (TPN->ApplyTypeConstraints(P, false)) +/* Resolve all types */; + + if (TPN->ContainsUnresolvedType()) +throw "Value #" + utostr(i) + " of PredicateOperand '" + + PredOps[i]->getName() + "' doesn't have a concrete type!"; + + PredOpInfo.AlwaysOps.push_back(TPN); +} + +// Insert it into the PredicateOperands map so we can find it later. +PredicateOperands[PredOps[i]] = PredOpInfo; + } +} + /// HandleUse - Given "Pat" a leaf in the pattern, check to see if it is an /// instruction input. Return true if this is a real use. static bool HandleUse(TreePattern *I, TreePatternNode *Pat, @@ -1496,7 +1540,7 @@ if (Op.Rec->isSubClassOf("PredicateOperand")) { // Does it have a non-empty ExecuteAlways field? If so, ignore this // operand. - if (Op.Rec->getValueAsDag("ExecuteAlways")->getNumArgs()) + if (!getPredicateOperand(Op.Rec).AlwaysOps.empty()) continue; } I->error("Operand $" + OpName + @@ -2690,6 +2734,7 @@ PatternHasProperty(InstPatNode, SDNPHasChain, ISE); bool InputHasChain = isRoot && NodeHasProperty(Pattern, SDNPHasChain, ISE); + unsigned NumResults = Inst.getNumResults(); if (NodeHasOptInFlag) { emitCode("bool HasInFlag = " @@ -2726,11 +2771,34 @@ "&InChains[0], InChains.size());"); } + // Loop over all of the operands of the instruction pattern, emitting code + // to fill them all in. The node 'N' usually has number children equal to + // the number of input operands of the instruction. However, in cases + // where there are predicate operands for an instruction, we need to fill + // in the 'execute always' values. Match up the node operands to the + // instruction operands to do this. std::vector AllOps; - for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { -std::vector Ops = EmitResultCode(N->getChild(i), - RetSelected, InFlagDecled, ResNodeDecled); -AllOps.insert(AllOps.end(), Ops.begin(), Ops.end()); + for (unsigned ChildNo = 0, InstOpNo = NumResults; + InstOpNo != II.OperandList.size(); ++InstOpNo) { +std::vector Ops; + +// If this is a normal operand, emit it. +if (!II.OperandList[InstOpNo].Rec->isSubClassOf("PredicateOperand")) { + Ops = EmitResultCode(N->getChild(ChildNo), RetSelected, + InFlagDecled, ResNodeDecled); + AllOps.insert(AllOps.end(), Ops.begin(), Ops.end()); + ++ChildNo; +} else { + // Otherwise, this is a predicate operand, emit the 'execute always' + // operands. + const DAGPredicateOperand &Pred = +ISE.getPredicateOperand(II.OperandList[Ins
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.277 -> 1.278 --- Log message: First steps to getting PredicateOperand's to work. This handles instruction and pat pattern definitions. Codegen is not right for them yet. --- Diffs of the changes: (+37 -14) DAGISelEmitter.cpp | 51 +-- 1 files changed, 37 insertions(+), 14 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.277 llvm/utils/TableGen/DAGISelEmitter.cpp:1.278 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.277Thu Nov 2 19:11:05 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Nov 3 19:35:50 2006 @@ -759,27 +759,40 @@ MadeChange = UpdateNodeType(ConvertVTs(RC.getValueTypes()), TP); } -if (getNumChildren() != Inst.getNumOperands()) - TP.error("Instruction '" + getOperator()->getName() + " expects " + - utostr(Inst.getNumOperands()) + " operands, not " + - utostr(getNumChildren()) + " operands!"); -for (unsigned i = 0, e = getNumChildren(); i != e; ++i) { +unsigned ChildNo = 0; +for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i) { Record *OperandNode = Inst.getOperand(i); + + // If the instruction expects a predicate operand, we codegen this by + // setting the predicate to it's "execute always" value. + if (OperandNode->isSubClassOf("PredicateOperand")) +continue; + + // Verify that we didn't run out of provided operands. + if (ChildNo >= getNumChildren()) +TP.error("Instruction '" + getOperator()->getName() + + "' expects more operands than were provided."); + MVT::ValueType VT; + TreePatternNode *Child = getChild(ChildNo++); if (OperandNode->isSubClassOf("RegisterClass")) { const CodeGenRegisterClass &RC = ISE.getTargetInfo().getRegisterClass(OperandNode); -MadeChange |=getChild(i)->UpdateNodeType(ConvertVTs(RC.getValueTypes()), - TP); +MadeChange |= Child->UpdateNodeType(ConvertVTs(RC.getValueTypes()), TP); } else if (OperandNode->isSubClassOf("Operand")) { VT = getValueType(OperandNode->getValueAsDef("Type")); -MadeChange |= getChild(i)->UpdateNodeType(VT, TP); +MadeChange |= Child->UpdateNodeType(VT, TP); } else { assert(0 && "Unknown operand type!"); abort(); } - MadeChange |= getChild(i)->ApplyTypeConstraints(TP, NotRegisters); + MadeChange |= Child->ApplyTypeConstraints(TP, NotRegisters); } + +if (ChildNo != getNumChildren()) + TP.error("Instruction '" + getOperator()->getName() + + "' was provided too many operands!"); + return MadeChange; } else { assert(getOperator()->isSubClassOf("SDNodeXForm") && "Unknown node type!"); @@ -1471,25 +1484,35 @@ std::vector ResultNodeOperands; std::vector Operands; for (unsigned i = NumResults, e = CGI.OperandList.size(); i != e; ++i) { - const std::string &OpName = CGI.OperandList[i].Name; + CodeGenInstruction::OperandInfo &Op = CGI.OperandList[i]; + const std::string &OpName = Op.Name; if (OpName.empty()) I->error("Operand #" + utostr(i) + " in operands list has no name!"); - if (!InstInputsCheck.count(OpName)) + if (!InstInputsCheck.count(OpName)) { +// If this is an predicate operand with an ExecuteAlways set filled in, +// we can ignore this. When we codegen it, we will do so as always +// executed. +if (Op.Rec->isSubClassOf("PredicateOperand")) { + // Does it have a non-empty ExecuteAlways field? If so, ignore this + // operand. + if (Op.Rec->getValueAsDag("ExecuteAlways")->getNumArgs()) +continue; +} I->error("Operand $" + OpName + " does not appear in the instruction pattern"); + } TreePatternNode *InVal = InstInputsCheck[OpName]; InstInputsCheck.erase(OpName); // It occurred, remove from map. if (InVal->isLeaf() && dynamic_cast(InVal->getLeafValue())) { Record *InRec = static_cast(InVal->getLeafValue())->getDef(); -if (CGI.OperandList[i].Rec != InRec && -!InRec->isSubClassOf("ComplexPattern")) +if (Op.Rec != InRec && !InRec->isSubClassOf("ComplexPattern")) I->error("Operand $" + OpName + "'s register class disagrees" " between the operand and pattern"); } - Operands.push_back(CGI.OperandList[i].Rec); + Operands.push_back(Op.Rec); // Construct the result for the dest-pattern operand list. TreePatternNode *OpNode = InVal->clone(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.276 -> 1.277 --- Log message: silence warnings --- Diffs of the changes: (+1 -5) DAGISelEmitter.cpp |6 +- 1 files changed, 1 insertion(+), 5 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.276 llvm/utils/TableGen/DAGISelEmitter.cpp:1.277 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.276Thu Nov 2 15:07:40 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Nov 2 19:11:05 2006 @@ -2259,13 +2259,11 @@ unsigned OpNo = 0; bool NodeHasChain = NodeHasProperty (N, SDNPHasChain, ISE); bool HasChain = PatternHasProperty(N, SDNPHasChain, ISE); -bool HasOutFlag = PatternHasProperty(N, SDNPOutFlag, ISE); bool EmittedUseCheck = false; if (HasChain) { if (NodeHasChain) OpNo = 1; if (!isRoot) { -const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; @@ -2329,7 +2327,6 @@ (PatternHasProperty(N, SDNPInFlag, ISE) || PatternHasProperty(N, SDNPOptInFlag, ISE) || PatternHasProperty(N, SDNPOutFlag, ISE))) { - const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); if (!EmittedUseCheck) { // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); @@ -3318,8 +3315,7 @@ PatternsByOpcode[Node->getOperator()].push_back(&PatternsToMatch[i]); } else { const ComplexPattern *CP; - if (IntInit *II = - dynamic_cast(Node->getLeafValue())) { + if (dynamic_cast(Node->getLeafValue())) { PatternsByOpcode[getSDNodeNamed("imm")].push_back(&PatternsToMatch[i]); } else if ((CP = NodeGetComplexPattern(Node, *this))) { std::vector OpNodes = CP->getRootNodes(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.275 -> 1.276 --- Log message: Revert last patch which causes tblgen to segfault (why, I'm not sure). --- Diffs of the changes: (+6 -2) DAGISelEmitter.cpp |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.275 llvm/utils/TableGen/DAGISelEmitter.cpp:1.276 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.275Thu Nov 2 14:46:16 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Nov 2 15:07:40 2006 @@ -2259,11 +2259,13 @@ unsigned OpNo = 0; bool NodeHasChain = NodeHasProperty (N, SDNPHasChain, ISE); bool HasChain = PatternHasProperty(N, SDNPHasChain, ISE); +bool HasOutFlag = PatternHasProperty(N, SDNPOutFlag, ISE); bool EmittedUseCheck = false; if (HasChain) { if (NodeHasChain) OpNo = 1; if (!isRoot) { +const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; @@ -2327,6 +2329,7 @@ (PatternHasProperty(N, SDNPInFlag, ISE) || PatternHasProperty(N, SDNPOptInFlag, ISE) || PatternHasProperty(N, SDNPOutFlag, ISE))) { + const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); if (!EmittedUseCheck) { // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); @@ -3315,9 +3318,10 @@ PatternsByOpcode[Node->getOperator()].push_back(&PatternsToMatch[i]); } else { const ComplexPattern *CP; - if (dynamic_cast(Node->getLeafValue())) { + if (IntInit *II = + dynamic_cast(Node->getLeafValue())) { PatternsByOpcode[getSDNodeNamed("imm")].push_back(&PatternsToMatch[i]); - } else if (NodeGetComplexPattern(Node, *this)) { + } else if ((CP = NodeGetComplexPattern(Node, *this))) { std::vector OpNodes = CP->getRootNodes(); for (unsigned j = 0, e = OpNodes.size(); j != e; j++) { PatternsByOpcode[OpNodes[j]] ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp Record.cpp SubtargetEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.274 -> 1.275 Record.cpp updated: 1.53 -> 1.54 SubtargetEmitter.cpp updated: 1.19 -> 1.20 --- Log message: For PR786: http://llvm.org/PR786 : Remove unused variables. --- Diffs of the changes: (+3 -8) DAGISelEmitter.cpp |8 ++-- Record.cpp |2 +- SubtargetEmitter.cpp |1 - 3 files changed, 3 insertions(+), 8 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.274 llvm/utils/TableGen/DAGISelEmitter.cpp:1.275 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.274Tue Oct 31 18:27:59 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Nov 2 14:46:16 2006 @@ -2259,13 +2259,11 @@ unsigned OpNo = 0; bool NodeHasChain = NodeHasProperty (N, SDNPHasChain, ISE); bool HasChain = PatternHasProperty(N, SDNPHasChain, ISE); -bool HasOutFlag = PatternHasProperty(N, SDNPOutFlag, ISE); bool EmittedUseCheck = false; if (HasChain) { if (NodeHasChain) OpNo = 1; if (!isRoot) { -const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; @@ -2329,7 +2327,6 @@ (PatternHasProperty(N, SDNPInFlag, ISE) || PatternHasProperty(N, SDNPOptInFlag, ISE) || PatternHasProperty(N, SDNPOutFlag, ISE))) { - const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); if (!EmittedUseCheck) { // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); @@ -3318,10 +3315,9 @@ PatternsByOpcode[Node->getOperator()].push_back(&PatternsToMatch[i]); } else { const ComplexPattern *CP; - if (IntInit *II = - dynamic_cast(Node->getLeafValue())) { + if (dynamic_cast(Node->getLeafValue())) { PatternsByOpcode[getSDNodeNamed("imm")].push_back(&PatternsToMatch[i]); - } else if ((CP = NodeGetComplexPattern(Node, *this))) { + } else if (NodeGetComplexPattern(Node, *this)) { std::vector OpNodes = CP->getRootNodes(); for (unsigned j = 0, e = OpNodes.size(); j != e; j++) { PatternsByOpcode[OpNodes[j]] Index: llvm/utils/TableGen/Record.cpp diff -u llvm/utils/TableGen/Record.cpp:1.53 llvm/utils/TableGen/Record.cpp:1.54 --- llvm/utils/TableGen/Record.cpp:1.53 Fri Mar 31 15:53:49 2006 +++ llvm/utils/TableGen/Record.cpp Thu Nov 2 14:46:16 2006 @@ -498,7 +498,7 @@ } Init *VarInit::getFieldInit(Record &R, const std::string &FieldName) const { - if (RecordRecTy *RTy = dynamic_cast(getType())) + if (dynamic_cast(getType())) if (const RecordVal *RV = R.getValue(VarName)) { Init *TheInit = RV->getValue(); assert(TheInit != this && "Infinite loop detected!"); Index: llvm/utils/TableGen/SubtargetEmitter.cpp diff -u llvm/utils/TableGen/SubtargetEmitter.cpp:1.19 llvm/utils/TableGen/SubtargetEmitter.cpp:1.20 --- llvm/utils/TableGen/SubtargetEmitter.cpp:1.19 Wed May 24 12:31:02 2006 +++ llvm/utils/TableGen/SubtargetEmitter.cppThu Nov 2 14:46:16 2006 @@ -355,7 +355,6 @@ // For each itinerary class std::vector &ItinList = *ProcListIter++; -unsigned ItinIndex = 0; for (unsigned j = 0, M = ItinList.size(); j < M;) { InstrItinerary &Intinerary = ItinList[j]; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.273 -> 1.274 --- Log message: Not meant to be checked in. --- Diffs of the changes: (+1 -5) DAGISelEmitter.cpp |6 +- 1 files changed, 1 insertion(+), 5 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.273 llvm/utils/TableGen/DAGISelEmitter.cpp:1.274 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.273Tue Oct 31 18:27:05 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Oct 31 18:27:59 2006 @@ -3552,14 +3552,11 @@ // Emit boilerplate. OS << "SDNode *Select_INLINEASM(SDOperand N) {\n" << " std::vector Ops(N.Val->op_begin(), N.Val->op_end());\n" - << " AddToISelQueue(N.getOperand(0)); // Select the chain.\n" + << " AddToISelQueue(N.getOperand(0)); // Select the chain.\n\n" << " // Select the flag operand.\n" << " if (Ops.back().getValueType() == MVT::Flag)\n" << "AddToISelQueue(Ops.back());\n" << " SelectInlineAsmMemoryOperands(Ops, *CurDAG);\n" - << " for (unsigned i = 2, e = Ops.size(); i < e; ++i)\n" - << "if (Ops[i].getOpcode() != ISD::Constant)\n" - << " AddToISelQueue(Ops[i]);\n" << " std::vector VTs;\n" << " VTs.push_back(MVT::Other);\n" << " VTs.push_back(MVT::Flag);\n" @@ -3585,7 +3582,6 @@ << " case ISD::TargetConstantPool:\n" << " case ISD::TargetFrameIndex:\n" << " case ISD::TargetJumpTable:\n" - << " case ISD::TargetExternalSymbol:\n" << " case ISD::TargetGlobalAddress: {\n" << "return NULL;\n" << " }\n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.271 -> 1.272 --- Log message: Passing isel root and use operands to ComplexPattern functions, these should do the usual load folding checks as well. --- Diffs of the changes: (+28 -14) DAGISelEmitter.cpp | 42 -- 1 files changed, 28 insertions(+), 14 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.271 llvm/utils/TableGen/DAGISelEmitter.cpp:1.272 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.271Sat Oct 14 03:30:15 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Oct 16 01:33:44 2006 @@ -2199,9 +2199,9 @@ /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo /// if the match fails. At this point, we already know that the opcode for N /// matches, and the SDNode for the result has the RootName specified name. - void EmitMatchCode(TreePatternNode *Root, TreePatternNode *N, - TreePatternNode *P, const std::string &RootName, - const std::string &ChainSuffix, bool &FoundChain) { + void EmitMatchCode(TreePatternNode *N, TreePatternNode *P, + const std::string &RootName, const std::string &ChainSuffix, + bool &FoundChain) { bool isRoot = (P == NULL); // Emit instruction predicates. Each predicate is just a string for now. if (isRoot) { @@ -2283,12 +2283,22 @@ // /[YY] // | ^ // [XX]---| - const SDNodeInfo &PInfo = ISE.getSDNodeInfo(P->getOperator()); - if (P != Root || + bool NeedCheck = false; + if (P != Pattern) +NeedCheck = true; + else { +const SDNodeInfo &PInfo = ISE.getSDNodeInfo(P->getOperator()); +NeedCheck = + P->getOperator() == ISE.get_intrinsic_void_sdnode() || + P->getOperator() == ISE.get_intrinsic_w_chain_sdnode() || + P->getOperator() == ISE.get_intrinsic_wo_chain_sdnode() || PInfo.getNumOperands() > 1 || PInfo.hasProperty(SDNPHasChain) || PInfo.hasProperty(SDNPInFlag) || - PInfo.hasProperty(SDNPOptInFlag)) { + PInfo.hasProperty(SDNPOptInFlag); + } + + if (NeedCheck) { std::string ParentName(RootName.begin(), RootName.end()-1); emitCheck("CanBeFoldedBy(" + RootName + ".Val, " + ParentName + ".Val, N.Val)"); @@ -2359,7 +2369,7 @@ emitCheck(MaskPredicate + RootName + "0, cast(" + RootName + "1), " + itostr(II->getValue()) + ")"); - EmitChildMatchCode(Root, N->getChild(0), N, RootName + utostr(0), + EmitChildMatchCode(N->getChild(0), N, RootName + utostr(0), ChainSuffix + utostr(0), FoundChain); return; } @@ -2370,7 +2380,7 @@ emitInit("SDOperand " + RootName + utostr(OpNo) + " = " + RootName + ".getOperand(" +utostr(OpNo) + ");"); - EmitChildMatchCode(Root, N->getChild(i), N, RootName + utostr(OpNo), + EmitChildMatchCode(N->getChild(i), N, RootName + utostr(OpNo), ChainSuffix + utostr(OpNo), FoundChain); } @@ -2401,15 +2411,15 @@ } } - void EmitChildMatchCode(TreePatternNode *Root, TreePatternNode *Child, - TreePatternNode *Parent, const std::string &RootName, + void EmitChildMatchCode(TreePatternNode *Child, TreePatternNode *Parent, + const std::string &RootName, const std::string &ChainSuffix, bool &FoundChain) { if (!Child->isLeaf()) { // If it's not a leaf, recursively match. const SDNodeInfo &CInfo = ISE.getSDNodeInfo(Child->getOperator()); emitCheck(RootName + ".getOpcode() == " + CInfo.getEnumName()); - EmitMatchCode(Root, Child, Parent, RootName, ChainSuffix, FoundChain); + EmitMatchCode(Child, Parent, RootName, ChainSuffix, FoundChain); if (NodeHasProperty(Child, SDNPHasChain, ISE)) FoldedChains.push_back(std::make_pair(RootName, CInfo.getNumResults())); } else { @@ -2457,7 +2467,12 @@ emitCode("SDOperand " + ChainName + ";"); } - std::string Code = Fn + "(" + RootName; + std::string Code = Fn + "("; + if (CP->hasProperty(SDNPHasChain)) { +std::string ParentName(RootName.begin(), RootName.end()-1); +Code += "N, " + ParentName + ", "; + } + Code += RootName; for (unsigned i = 0; i < NumOps; i++) Code += ", CPTmp" + utostr(i); if (CP->hasProperty(SDNPHasChain)) @@ -3099,8 +3114,7 @@ // Emit the matcher, capturing named arguments in VariableMap. bool FoundChain = false; -
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.270 -> 1.271 --- Log message: When checking if a load can be folded, we check if there is any non-direct way to reach the load via any nodes that would be folded. Start from the root of the matched sub-tree. --- Diffs of the changes: (+12 -10) DAGISelEmitter.cpp | 22 -- 1 files changed, 12 insertions(+), 10 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.270 llvm/utils/TableGen/DAGISelEmitter.cpp:1.271 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.270Thu Oct 12 18:18:52 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sat Oct 14 03:30:15 2006 @@ -2199,8 +2199,8 @@ /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo /// if the match fails. At this point, we already know that the opcode for N /// matches, and the SDNode for the result has the RootName specified name. - void EmitMatchCode(TreePatternNode *N, TreePatternNode *P, - const std::string &RootName, + void EmitMatchCode(TreePatternNode *Root, TreePatternNode *N, + TreePatternNode *P, const std::string &RootName, const std::string &ChainSuffix, bool &FoundChain) { bool isRoot = (P == NULL); // Emit instruction predicates. Each predicate is just a string for now. @@ -2284,13 +2284,14 @@ // | ^ // [XX]---| const SDNodeInfo &PInfo = ISE.getSDNodeInfo(P->getOperator()); - if (PInfo.getNumOperands() > 1 || + if (P != Root || + PInfo.getNumOperands() > 1 || PInfo.hasProperty(SDNPHasChain) || PInfo.hasProperty(SDNPInFlag) || PInfo.hasProperty(SDNPOptInFlag)) { std::string ParentName(RootName.begin(), RootName.end()-1); emitCheck("CanBeFoldedBy(" + RootName + ".Val, " + ParentName + - ".Val)"); + ".Val, N.Val)"); } } } @@ -2358,7 +2359,7 @@ emitCheck(MaskPredicate + RootName + "0, cast(" + RootName + "1), " + itostr(II->getValue()) + ")"); - EmitChildMatchCode(N->getChild(0), N, RootName + utostr(0), + EmitChildMatchCode(Root, N->getChild(0), N, RootName + utostr(0), ChainSuffix + utostr(0), FoundChain); return; } @@ -2369,7 +2370,7 @@ emitInit("SDOperand " + RootName + utostr(OpNo) + " = " + RootName + ".getOperand(" +utostr(OpNo) + ");"); - EmitChildMatchCode(N->getChild(i), N, RootName + utostr(OpNo), + EmitChildMatchCode(Root, N->getChild(i), N, RootName + utostr(OpNo), ChainSuffix + utostr(OpNo), FoundChain); } @@ -2400,15 +2401,15 @@ } } - void EmitChildMatchCode(TreePatternNode *Child, TreePatternNode *Parent, - const std::string &RootName, + void EmitChildMatchCode(TreePatternNode *Root, TreePatternNode *Child, + TreePatternNode *Parent, const std::string &RootName, const std::string &ChainSuffix, bool &FoundChain) { if (!Child->isLeaf()) { // If it's not a leaf, recursively match. const SDNodeInfo &CInfo = ISE.getSDNodeInfo(Child->getOperator()); emitCheck(RootName + ".getOpcode() == " + CInfo.getEnumName()); - EmitMatchCode(Child, Parent, RootName, ChainSuffix, FoundChain); + EmitMatchCode(Root, Child, Parent, RootName, ChainSuffix, FoundChain); if (NodeHasProperty(Child, SDNPHasChain, ISE)) FoldedChains.push_back(std::make_pair(RootName, CInfo.getNumResults())); } else { @@ -3098,7 +3099,8 @@ // Emit the matcher, capturing named arguments in VariableMap. bool FoundChain = false; - Emitter.EmitMatchCode(Pattern.getSrcPattern(), NULL, "N", "", FoundChain); + Emitter.EmitMatchCode(Pattern.getSrcPattern(), Pattern.getSrcPattern(), NULL, +"N", "", FoundChain); // TP - Get *SOME* tree pattern, we don't care which. TreePattern &TP = *PatternFragments.begin()->second; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.269 -> 1.270 --- Log message: Really remove dead nodes from isel queue. --- Diffs of the changes: (+2 -1) DAGISelEmitter.cpp |3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.269 llvm/utils/TableGen/DAGISelEmitter.cpp:1.270 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.269Thu Oct 12 15:35:19 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Oct 12 18:18:52 2006 @@ -3723,7 +3723,8 @@ OS << " if (NumKilled) {\n"; OS << "for (unsigned i = 0; i != NumKilled; ++i) {\n"; OS << " SDNode *Temp = ISelKilled[i];\n"; - OS << " std::remove(ISelQueue.begin(), ISelQueue.end(), Temp);\n"; + OS << " ISelQueue.erase(std::remove(ISelQueue.begin(), ISelQueue.end(), " + << "Temp), ISelQueue.end());\n"; OS << "};\n"; OS << "std::make_heap(ISelQueue.begin(), ISelQueue.end(), isel_sort());\n"; OS << "ISelKilled.clear();\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.268 -> 1.269 --- Log message: Use RemoveDeadNode to kill dead node. --- Diffs of the changes: (+4 -12) DAGISelEmitter.cpp | 16 1 files changed, 4 insertions(+), 12 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.268 llvm/utils/TableGen/DAGISelEmitter.cpp:1.269 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.268Wed Oct 11 21:08:53 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Oct 12 15:35:19 2006 @@ -3741,16 +3741,6 @@ OS << " RemoveKilled();\n"; OS << "}\n\n"; - OS << "void DeleteNode(SDNode *N) {\n"; - OS << " CurDAG->DeleteNode(N);\n"; - OS << " for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); " - << "I != E; ++I) {\n"; - OS << "SDNode *Operand = I->Val;\n"; - OS << "if (Operand->use_empty())\n"; - OS << " DeleteNode(Operand);\n"; - OS << " }\n"; - OS << "}\n"; - OS << "// SelectRoot - Top level entry to DAG isel.\n"; OS << "SDOperand SelectRoot(SDOperand Root) {\n"; OS << " SelectRootInit();\n"; @@ -3774,8 +3764,10 @@ OS << " if (ResNode != Node) {\n"; OS << "if (ResNode)\n"; OS << " ReplaceUses(Node, ResNode);\n"; - OS << "if (Node->use_empty()) // Don't delete EntryToken, etc.\n"; - OS << " DeleteNode(Node);\n"; + OS << "if (Node->use_empty()) { // Don't delete EntryToken, etc.\n"; + OS << " CurDAG->RemoveDeadNode(Node, ISelKilled);\n"; + OS << " RemoveKilled();\n"; + OS << "}\n"; OS << " }\n"; OS << "}\n"; OS << " }\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.267 -> 1.268 --- Log message: Prior load folding check on chain operand was too strict. It requires the chain operand to point to the load being folded. Now we relax this, traversing up the chain, if it doesn't reach the load, then it's ok. We will create a TokenFactor (of all the chain operands and the load's chain) to capture all the control flow dependencies. --- Diffs of the changes: (+43 -3) DAGISelEmitter.cpp | 46 +++--- 1 files changed, 43 insertions(+), 3 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.267 llvm/utils/TableGen/DAGISelEmitter.cpp:1.268 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.267Wed Oct 11 16:02:01 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Oct 11 21:08:53 2006 @@ -2138,6 +2138,8 @@ std::map OperatorMap; // Names of all the folded nodes which produce chains. std::vector > FoldedChains; + // Original input chain(s). + std::vector > OrigChains; std::set Duplicates; /// GeneratedCode - This is the buffer that we emit code to. The first int @@ -2294,9 +2296,12 @@ } if (NodeHasChain) { -if (FoundChain) - emitCheck("Chain.Val == " + RootName + ".Val"); -else +if (FoundChain) { + emitCheck("(" + ChainName + ".Val == " + RootName + ".Val || " +"IsChainCompatible(" + ChainName + ".Val, " + +RootName + ".Val))"); + OrigChains.push_back(std::make_pair(ChainName, RootName)); +} else FoundChain = true; ChainName = "Chain" + ChainSuffix; emitInit("SDOperand " + ChainName + " = " + RootName + @@ -2665,6 +2670,26 @@ PatResults++; } + if (OrigChains.size() > 0) { +// The original input chain is being ignored. If it is not just +// pointing to the op that's being folded, we should create a +// TokenFactor with it and the chain of the folded op as the new chain. +// We could potentially be doing multiple levels of folding, in that +// case, the TokenFactor can have more operands. +emitCode("SmallVector InChains;"); +for (unsigned i = 0, e = OrigChains.size(); i < e; ++i) { + emitCode("if (" + OrigChains[i].first + ".Val != " + + OrigChains[i].second + ".Val) {"); + emitCode(" AddToISelQueue(" + OrigChains[i].first + ");"); + emitCode(" InChains.push_back(" + OrigChains[i].first + ");"); + emitCode("}"); +} +emitCode("AddToISelQueue(" + ChainName + ");"); +emitCode("InChains.push_back(" + ChainName + ");"); +emitCode(ChainName + " = CurDAG->getNode(ISD::TokenFactor, MVT::Other, " + "&InChains[0], InChains.size());"); + } + std::vector AllOps; for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { std::vector Ops = EmitResultCode(N->getChild(i), @@ -3647,6 +3672,21 @@ OS << "/// Dummy parameter to ReplaceAllUsesOfValueWith().\n" << "std::vector ISelKilled;\n\n"; + OS << "/// IsChainCompatible - Returns true if Chain is Op or Chain does\n"; + OS << "/// not reach Op.\n"; + OS << "static bool IsChainCompatible(SDNode *Chain, SDNode *Op) {\n"; + OS << " if (Chain->getOpcode() == ISD::EntryToken)\n"; + OS << "return true;\n"; + OS << " else if (Chain->getOpcode() == ISD::TokenFactor)\n"; + OS << "return false;\n"; + OS << " else if (Chain->getNumOperands() > 0) {\n"; + OS << "SDOperand C0 = Chain->getOperand(0);\n"; + OS << "if (C0.getValueType() == MVT::Other)\n"; + OS << " return C0.Val != Op && IsChainCompatible(C0.Val, Op);\n"; + OS << " }\n"; + OS << " return true;\n"; + OS << "}\n"; + OS << "/// Sorting functions for the selection queue.\n" << "struct isel_sort : public std::binary_function" << " {\n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.265 -> 1.266 --- Log message: Special case tblgen generated code for patterns like (and X, 255) or (or X, 42). The dag/inst combiners often 'simplify' the masked value based on whether or not the bits are live or known zero/one. This is good and dandy, but often causes special case patterns to fail, such as alpha's CMPBGE pattern, which looks like "(set GPRC:$RC, (setuge (and GPRC:$RA, 255), (and GPRC:$RB, 255)))". Here the pattern for (and X, 255) should match actual dags like (and X, 254) if the dag combiner proved that the missing bits are already zero (one for 'or'). For CodeGen/Alpha/cmpbge.ll:test2 for example, this results in: sll $16,1,$0 cmpbge $0,$17,$0 ret $31,($26),1 instead of: sll $16,1,$0 and $0,254,$0 and $17,255,$1 cmpule $1,$0,$0 ret $31,($26),1 ... and requires no target-specific code. --- Diffs of the changes: (+36 -1) DAGISelEmitter.cpp | 37 - 1 files changed, 36 insertions(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.265 llvm/utils/TableGen/DAGISelEmitter.cpp:1.266 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.265Tue Oct 10 22:35:34 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Oct 10 23:05:55 2006 @@ -2320,6 +2320,41 @@ emitCheck(N->getPredicateFn() + "(" + RootName + ".Val)"); +// If this is an 'and R, 1234' where the operation is AND/OR and the RHS is +// a constant without a predicate fn that has more that one bit set, handle +// this as a special case. This is usually for targets that have special +// handling of certain large constants (e.g. alpha with it's 8/16/32-bit +// handling stuff). Using these instructions is often far more efficient +// than materializing the constant. Unfortunately, both the instcombiner +// and the dag combiner can often infer that bits are dead, and thus drop +// them from the mask in the dag. For example, it might turn 'AND X, 255' +// into 'AND X, 254' if it knows the low bit is set. Emit code that checks +// to handle this. +if (!N->isLeaf() && +(N->getOperator()->getName() == "and" || + N->getOperator()->getName() == "or") && +N->getChild(1)->isLeaf() && +N->getChild(1)->getPredicateFn().empty()) { + if (IntInit *II = dynamic_cast(N->getChild(1)->getLeafValue())) { +if (!isPowerOf2_32(II->getValue())) { // Don't bother with single bits. + emitInit("SDOperand " + RootName + "0" + " = " + + RootName + ".getOperand(" + utostr(0) + ");"); + emitInit("SDOperand " + RootName + "1" + " = " + + RootName + ".getOperand(" + utostr(1) + ");"); + + emitCheck("isa(" + RootName + "1)"); + const char *MaskPredicate = N->getOperator()->getName() == "or" +? "CheckOrMask(" : "CheckAndMask("; + emitCheck(MaskPredicate + RootName + "0, cast(" + +RootName + "1), " + itostr(II->getValue()) + ")"); + + EmitChildMatchCode(N->getChild(0), N, RootName + utostr(0), + ChainSuffix + utostr(0), FoundChain); + return; +} + } +} + for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { emitInit("SDOperand " + RootName + utostr(OpNo) + " = " + RootName + ".getOperand(" +utostr(OpNo) + ");"); @@ -2344,7 +2379,7 @@ emitCheck(Code + ")"); } } - + void EmitChildMatchCode(TreePatternNode *Child, TreePatternNode *Parent, const std::string &RootName, const std::string &ChainSuffix, bool &FoundChain) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.264 -> 1.265 --- Log message: Split some code out into a new method. The generated code is exactly identical, this is just a refactoring. --- Diffs of the changes: (+99 -92) DAGISelEmitter.cpp | 191 +++-- 1 files changed, 99 insertions(+), 92 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.264 llvm/utils/TableGen/DAGISelEmitter.cpp:1.265 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.264Mon Oct 9 16:02:17 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Oct 10 22:35:34 2006 @@ -15,6 +15,7 @@ #include "Record.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/MathExtras.h" #include #include using namespace llvm; @@ -2192,7 +2193,7 @@ /// if the match fails. At this point, we already know that the opcode for N /// matches, and the SDNode for the result has the RootName specified name. void EmitMatchCode(TreePatternNode *N, TreePatternNode *P, - const std::string &RootName, const std::string &ParentName, + const std::string &RootName, const std::string &ChainSuffix, bool &FoundChain) { bool isRoot = (P == NULL); // Emit instruction predicates. Each predicate is just a string for now. @@ -2279,9 +2280,11 @@ if (PInfo.getNumOperands() > 1 || PInfo.hasProperty(SDNodeInfo::SDNPHasChain) || PInfo.hasProperty(SDNodeInfo::SDNPInFlag) || - PInfo.hasProperty(SDNodeInfo::SDNPOptInFlag)) + PInfo.hasProperty(SDNodeInfo::SDNPOptInFlag)) { +std::string ParentName(RootName.begin(), RootName.end()-1); emitCheck("CanBeFoldedBy(" + RootName + ".Val, " + ParentName + ".Val)"); + } } } @@ -2316,101 +2319,17 @@ if (!N->getPredicateFn().empty()) emitCheck(N->getPredicateFn() + "(" + RootName + ".Val)"); -const ComplexPattern *CP; + for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { emitInit("SDOperand " + RootName + utostr(OpNo) + " = " + RootName + ".getOperand(" +utostr(OpNo) + ");"); - TreePatternNode *Child = N->getChild(i); - if (!Child->isLeaf()) { -// If it's not a leaf, recursively match. -const SDNodeInfo &CInfo = ISE.getSDNodeInfo(Child->getOperator()); -emitCheck(RootName + utostr(OpNo) + ".getOpcode() == " + - CInfo.getEnumName()); -EmitMatchCode(Child, N, RootName + utostr(OpNo), RootName, - ChainSuffix + utostr(OpNo), FoundChain); -if (NodeHasProperty(Child, SDNodeInfo::SDNPHasChain, ISE)) - FoldedChains.push_back(std::make_pair(RootName + utostr(OpNo), -CInfo.getNumResults())); - } else { -// If this child has a name associated with it, capture it in VarMap. If -// we already saw this in the pattern, emit code to verify dagness. -if (!Child->getName().empty()) { - std::string &VarMapEntry = VariableMap[Child->getName()]; - if (VarMapEntry.empty()) { -VarMapEntry = RootName + utostr(OpNo); - } else { -// If we get here, this is a second reference to a specific name. -// Since we already have checked that the first reference is valid, -// we don't have to recursively match it, just check that it's the -// same as the previously named thing. -emitCheck(VarMapEntry + " == " + RootName + utostr(OpNo)); -Duplicates.insert(RootName + utostr(OpNo)); -continue; - } -} - -// Handle leaves of various types. -if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { - Record *LeafRec = DI->getDef(); - if (LeafRec->isSubClassOf("RegisterClass")) { -// Handle register references. Nothing to do here. - } else if (LeafRec->isSubClassOf("Register")) { -// Handle register references. - } else if (LeafRec->isSubClassOf("ComplexPattern")) { -// Handle complex pattern. -CP = NodeGetComplexPattern(Child, ISE); -std::string Fn = CP->getSelectFunc(); -unsigned NumOps = CP->getNumOperands(); -for (unsigned i = 0; i < NumOps; ++i) { - emitDecl("CPTmp" + utostr(i)); - emitCode("SDOperand CPTmp" + utostr(i) + ";"); -} - -std::string Code = Fn + "(" + RootName + utostr(OpNo); -for (unsigned i = 0; i < NumOps; i++) - Code += ", CPTmp" + utostr(i); -emitCheck(Code + ")"); - } else if (LeafRec->getName() == "srcvalue") { -// Place holder for SRC
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.263 -> 1.264 --- Log message: Predicate function on the node should be matched before its childrean' matching code. This is especially important now matching ISD::LOAD also requires a Predicate_Load call. --- Diffs of the changes: (+4 -4) DAGISelEmitter.cpp |8 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.263 llvm/utils/TableGen/DAGISelEmitter.cpp:1.264 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.263Thu Sep 21 15:46:13 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Oct 9 16:02:17 2006 @@ -2312,6 +2312,10 @@ } } +// If there is a node predicate for this, emit the call. +if (!N->getPredicateFn().empty()) + emitCheck(N->getPredicateFn() + "(" + RootName + ".Val)"); + const ComplexPattern *CP; for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { emitInit("SDOperand " + RootName + utostr(OpNo) + " = " + @@ -2420,10 +2424,6 @@ Code += ", CPTmp" + utostr(i); emitCheck(Code + ")"); } - -// If there is a node predicate for this, emit the call. -if (!N->getPredicateFn().empty()) - emitCheck(N->getPredicateFn() + "(" + RootName + ".Val)"); } /// EmitResultCode - Emit the action for a pattern. Now that it has matched ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.262 -> 1.263 --- Log message: don't allow 'imm' or specific imms, like '1' on the LHS of a binop. This shrinks X86GenDAGISel by ~330 lines. --- Diffs of the changes: (+13 -4) DAGISelEmitter.cpp | 17 + 1 files changed, 13 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.262 llvm/utils/TableGen/DAGISelEmitter.cpp:1.263 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.262Thu Sep 21 13:28:27 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Sep 21 15:46:13 2006 @@ -800,6 +800,17 @@ } } +/// OnlyOnRHSOfCommutative - Return true if this value is only allowed on the +/// RHS of a commutative operation, not the on LHS. +static bool OnlyOnRHSOfCommutative(TreePatternNode *N) { + if (!N->isLeaf() && N->getOperator()->getName() == "imm") +return true; + if (N->isLeaf() && dynamic_cast(N->getLeafValue())) +return true; + return false; +} + + /// canPatternMatch - If it is impossible for this pattern to match on this /// target, fill in Reason and return false. Otherwise, return true. This is /// used as a santity check for .td files (to prevent people from writing stuff @@ -825,11 +836,9 @@ if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) { // Scan all of the operands of the node and make sure that only the last one // is a constant node, unless the RHS also is. -if (getChild(getNumChildren()-1)->isLeaf() || -getChild(getNumChildren()-1)->getOperator()->getName() != "imm") { +if (!OnlyOnRHSOfCommutative(getChild(getNumChildren()-1))) { for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i) -if (!getChild(i)->isLeaf() && -getChild(i)->getOperator()->getName() == "imm") { +if (OnlyOnRHSOfCommutative(getChild(i))) { Reason="Immediate value must be on the RHS of commutative operators!"; return false; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.261 -> 1.262 --- Log message: Fit to 80 columns. --- Diffs of the changes: (+13 -13) DAGISelEmitter.cpp | 26 +- 1 files changed, 13 insertions(+), 13 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.261 llvm/utils/TableGen/DAGISelEmitter.cpp:1.262 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.261Tue Sep 19 14:08:04 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Sep 21 13:28:27 2006 @@ -830,7 +830,7 @@ for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i) if (!getChild(i)->isLeaf() && getChild(i)->getOperator()->getName() == "imm") { - Reason = "Immediate value must be on the RHS of commutative operators!"; + Reason="Immediate value must be on the RHS of commutative operators!"; return false; } } @@ -1590,8 +1590,8 @@ // can never do anything with this pattern: report it to the user. InferredAllPatternTypes = Pattern->InferAllTypes(); - // Infer as many types as possible. If we cannot infer all of them, we can - // never do anything with this pattern: report it to the user. + // Infer as many types as possible. If we cannot infer all of them, we + // can never do anything with this pattern: report it to the user. InferredAllResultTypes = Result->InferAllTypes(); // Apply the type of the result to the source pattern. This helps us @@ -2466,8 +2466,8 @@ Val + ")->getSymbol(), " + getEnumName(N->getTypeNum(0)) + ");"); NodeOps.push_back("Tmp" + utostr(ResNo)); - // Add Tmp to VariableMap, so that we don't multiply select this - // value if used multiple times by this pattern result. + // Add Tmp to VariableMap, so that we don't multiply select + // this value if used multiple times by this pattern result. Val = "Tmp"+utostr(ResNo); } else { NodeOps.push_back(Val); @@ -2481,8 +2481,8 @@ ")->getGlobal(), " + getEnumName(N->getTypeNum(0)) + ");"); NodeOps.push_back("Tmp" + utostr(ResNo)); - // Add Tmp to VariableMap, so that we don't multiply select this - // value if used multiple times by this pattern result. + // Add Tmp to VariableMap, so that we don't multiply select + // this value if used multiple times by this pattern result. Val = "Tmp"+utostr(ResNo); } else { NodeOps.push_back(Val); @@ -2765,8 +2765,8 @@ utostr(i) + "), SDOperand(ResNode, " + utostr(i) + "));"); if (InputHasChain) emitCode("ReplaceUses(SDOperand(N.Val, " + - utostr(PatResults) + "), SDOperand(" + ChainName + ".Val, " + - ChainName + ".ResNo" + "));"); + utostr(PatResults) + "), SDOperand(" + ChainName + ".Val, " + + ChainName + ".ResNo" + "));"); } else RetSelected = true; @@ -3266,8 +3266,8 @@ ++II) { MVT::ValueType OpVT = II->first; std::vector &Patterns = II->second; - typedef std::vector > CodeList; - typedef std::vector >::iterator CodeListI; + typedef std::vector > CodeList; + typedef std::vector >::iterator CodeListI; std::vector > CodeForPatterns; std::vector > PatternOpcodes; @@ -3408,8 +3408,8 @@ // Emit all of the patterns now, grouped together to share code. EmitPatterns(CodeForPatterns, 2, OS); - // If the last pattern has predicates (which could fail) emit code to catch - // the case where nothing handles a pattern. + // If the last pattern has predicates (which could fail) emit code to + // catch the case where nothing handles a pattern. if (mightNotMatch) { OS << " std::cerr << \"Cannot yet select: \";\n"; if (OpcodeInfo.getEnumName() != "ISD::INTRINSIC_W_CHAIN" && ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.260 -> 1.261 --- Log message: Allow PatFrag to be a leaf node. --- Diffs of the changes: (+18 -10) DAGISelEmitter.cpp | 28 ++-- 1 files changed, 18 insertions(+), 10 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.260 llvm/utils/TableGen/DAGISelEmitter.cpp:1.261 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.260Tue Sep 19 13:40:15 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Sep 19 14:08:04 2006 @@ -1158,15 +1158,19 @@ // keep track of the fact that this fragment uses it. std::string Code = Fragments[i]->getValueAsCode("Predicate"); if (!Code.empty()) { - assert(!P->getOnlyTree()->isLeaf() && "Can't be a leaf!"); - std::string ClassName = -getSDNodeInfo(P->getOnlyTree()->getOperator()).getSDClassName(); - const char *C2 = ClassName == "SDNode" ? "N" : "inN"; - - OS << "inline bool Predicate_" << Fragments[i]->getName() - << "(SDNode *" << C2 << ") {\n"; - if (ClassName != "SDNode") -OS << " " << ClassName << " *N = cast<" << ClassName << ">(inN);\n"; + if (P->getOnlyTree()->isLeaf()) +OS << "inline bool Predicate_" << Fragments[i]->getName() + << "(SDNode *N) {\n"; + else { +std::string ClassName = + getSDNodeInfo(P->getOnlyTree()->getOperator()).getSDClassName(); +const char *C2 = ClassName == "SDNode" ? "N" : "inN"; + +OS << "inline bool Predicate_" << Fragments[i]->getName() + << "(SDNode *" << C2 << ") {\n"; +if (ClassName != "SDNode") + OS << " " << ClassName << " *N = cast<" << ClassName << ">(inN);\n"; + } OS << Code << "\n}\n"; P->getOnlyTree()->setPredicateFn("Predicate_"+Fragments[i]->getName()); } @@ -2371,6 +2375,11 @@ #endif assert(0 && "Unknown leaf type!"); } + + // If there is a node predicate for this, emit the call. + if (!Child->getPredicateFn().empty()) +emitCheck(Child->getPredicateFn() + "(" + RootName + utostr(OpNo) + + ".Val)"); } else if (IntInit *II = dynamic_cast(Child->getLeafValue())) { emitCheck("isa(" + RootName + utostr(OpNo) + ")"); @@ -2827,7 +2836,6 @@ emitCode("SDOperand Tmp" + utostr(ResNo) + " = Transform_" + Op->getName() + "(" + Ops.back() + ".Val);"); NodeOps.push_back("Tmp" + utostr(ResNo)); - emitCode("AddToISelQueue(Tmp" + utostr(ResNo) + ");"); if (isRoot) emitCode("return Tmp" + utostr(ResNo) + ".Val;"); return NodeOps; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.259 -> 1.260 --- Log message: Add result of a Xform to isel queue. --- Diffs of the changes: (+1 -0) DAGISelEmitter.cpp |1 + 1 files changed, 1 insertion(+) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.259 llvm/utils/TableGen/DAGISelEmitter.cpp:1.260 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.259Mon Sep 18 19:41:36 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Sep 19 13:40:15 2006 @@ -2827,6 +2827,7 @@ emitCode("SDOperand Tmp" + utostr(ResNo) + " = Transform_" + Op->getName() + "(" + Ops.back() + ".Val);"); NodeOps.push_back("Tmp" + utostr(ResNo)); + emitCode("AddToISelQueue(Tmp" + utostr(ResNo) + ");"); if (isRoot) emitCode("return Tmp" + utostr(ResNo) + ".Val;"); return NodeOps; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.258 -> 1.259 --- Log message: If multiple predicates are listed, they must all pass --- Diffs of the changes: (+1 -1) DAGISelEmitter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.258 llvm/utils/TableGen/DAGISelEmitter.cpp:1.259 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.258Mon Sep 18 17:41:07 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Sep 18 19:41:36 2006 @@ -2195,7 +2195,7 @@ assert(0 && "Unknown predicate type!"); } if (!PredicateCheck.empty()) -PredicateCheck += " || "; +PredicateCheck += " && "; PredicateCheck += "(" + Def->getValueAsString("CondString") + ")"; } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.257 -> 1.258 --- Log message: There! --- Diffs of the changes: (+0 -2) DAGISelEmitter.cpp |2 -- 1 files changed, 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.257 llvm/utils/TableGen/DAGISelEmitter.cpp:1.258 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.257Mon Sep 18 17:28:27 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Sep 18 17:41:07 2006 @@ -2373,8 +2373,6 @@ } } else if (IntInit *II = dynamic_cast(Child->getLeafValue())) { - if (II->getValue() == 2147483647) -std::cerr << "HERE!\n"; emitCheck("isa(" + RootName + utostr(OpNo) + ")"); unsigned CTmp = TmpNo++; emitCode("int64_t CN"+utostr(CTmp)+" = cast("+ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp FileLexer.cpp.cvs FileLexer.l FileLexer.l.cvs
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.256 -> 1.257 FileLexer.cpp.cvs updated: 1.6 -> 1.7 FileLexer.l updated: 1.30 -> 1.31 FileLexer.l.cvs updated: 1.5 -> 1.6 --- Log message: Fix Regression/TableGen/2006-09-18-LargeInt.td --- Diffs of the changes: (+9 -7) DAGISelEmitter.cpp |2 ++ FileLexer.cpp.cvs |6 +++--- FileLexer.l|4 ++-- FileLexer.l.cvs|4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.256 llvm/utils/TableGen/DAGISelEmitter.cpp:1.257 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.256Thu Sep 14 18:54:24 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Sep 18 17:28:27 2006 @@ -2373,6 +2373,8 @@ } } else if (IntInit *II = dynamic_cast(Child->getLeafValue())) { + if (II->getValue() == 2147483647) +std::cerr << "HERE!\n"; emitCheck("isa(" + RootName + utostr(OpNo) + ")"); unsigned CTmp = TmpNo++; emitCode("int64_t CN"+utostr(CTmp)+" = cast("+ Index: llvm/utils/TableGen/FileLexer.cpp.cvs diff -u llvm/utils/TableGen/FileLexer.cpp.cvs:1.6 llvm/utils/TableGen/FileLexer.cpp.cvs:1.7 --- llvm/utils/TableGen/FileLexer.cpp.cvs:1.6 Fri Sep 1 16:14:42 2006 +++ llvm/utils/TableGen/FileLexer.cpp.cvs Mon Sep 18 17:28:27 2006 @@ -21,7 +21,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /var/cvs/llvm/llvm/utils/TableGen/FileLexer.cpp.cvs,v 1.6 2006/09/01 21:14:42 lattner Exp $ + * $Header: /var/cvs/llvm/llvm/utils/TableGen/FileLexer.cpp.cvs,v 1.7 2006/09/18 22:28:27 lattner Exp $ */ #define FLEX_SCANNER @@ -535,8 +535,8 @@ /// static int ParseInt(const char *Str) { if (Str[0] == '0' && Str[1] == 'b') -return strtol(Str+2, 0, 2); - return strtol(Str, 0, 0); +return strtoll(Str+2, 0, 2); + return strtoll(Str, 0, 0); } static int CommentDepth = 0; Index: llvm/utils/TableGen/FileLexer.l diff -u llvm/utils/TableGen/FileLexer.l:1.30 llvm/utils/TableGen/FileLexer.l:1.31 --- llvm/utils/TableGen/FileLexer.l:1.30Fri Sep 1 16:13:49 2006 +++ llvm/utils/TableGen/FileLexer.l Mon Sep 18 17:28:27 2006 @@ -42,8 +42,8 @@ /// static int ParseInt(const char *Str) { if (Str[0] == '0' && Str[1] == 'b') -return strtol(Str+2, 0, 2); - return strtol(Str, 0, 0); +return strtoll(Str+2, 0, 2); + return strtoll(Str, 0, 0); } static int CommentDepth = 0; Index: llvm/utils/TableGen/FileLexer.l.cvs diff -u llvm/utils/TableGen/FileLexer.l.cvs:1.5 llvm/utils/TableGen/FileLexer.l.cvs:1.6 --- llvm/utils/TableGen/FileLexer.l.cvs:1.5 Fri Sep 1 16:14:42 2006 +++ llvm/utils/TableGen/FileLexer.l.cvs Mon Sep 18 17:28:27 2006 @@ -42,8 +42,8 @@ /// static int ParseInt(const char *Str) { if (Str[0] == '0' && Str[1] == 'b') -return strtol(Str+2, 0, 2); - return strtol(Str, 0, 0); +return strtoll(Str+2, 0, 2); + return strtoll(Str, 0, 0); } static int CommentDepth = 0; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.255 -> 1.256 --- Log message: Relax this check. --- Diffs of the changes: (+10 -7) DAGISelEmitter.cpp | 17 ++--- 1 files changed, 10 insertions(+), 7 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.255 llvm/utils/TableGen/DAGISelEmitter.cpp:1.256 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.255Sun Sep 10 21:24:43 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Sep 14 18:54:24 2006 @@ -824,13 +824,16 @@ const SDNodeInfo &NodeInfo = ISE.getSDNodeInfo(getOperator()); if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) { // Scan all of the operands of the node and make sure that only the last one -// is a constant node. -for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i) - if (!getChild(i)->isLeaf() && - getChild(i)->getOperator()->getName() == "imm") { -Reason = "Immediate value must be on the RHS of commutative operators!"; -return false; - } +// is a constant node, unless the RHS also is. +if (getChild(getNumChildren()-1)->isLeaf() || +getChild(getNumChildren()-1)->getOperator()->getName() != "imm") { + for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i) +if (!getChild(i)->isLeaf() && +getChild(i)->getOperator()->getName() == "imm") { + Reason = "Immediate value must be on the RHS of commutative operators!"; + return false; +} +} } return true; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.254 -> 1.255 --- Log message: 1) With X86 lowering change, the following can no longer happen since the branch's chain is also produced by cmp. [ch, r : ld] ^ ^ | | [XX]--/ \- [flag : cmp] ^ ^ | | \---[br flag]- Remove an isel check which prevents loads from being folded into cmp / test instructions. 2) Whenever possible, delete a selected node to allow more load folding opportunities. Note not all nodes can be deleted after it has been selected. Some may have simply morphed; some have not changed at all (e.g. EntryToken). --- Diffs of the changes: (+16 -19) DAGISelEmitter.cpp | 35 --- 1 files changed, 16 insertions(+), 19 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.254 llvm/utils/TableGen/DAGISelEmitter.cpp:1.255 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.254Fri Sep 8 02:26:39 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sun Sep 10 21:24:43 2006 @@ -2246,24 +2246,6 @@ emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; if (NodeHasChain) { - // FIXME: Don't fold if 1) the parent node writes a flag, 2) the node - // has a chain use. - // This a workaround for this problem: - // - // [ch, r : ld] - // ^ ^ - // | | - // [XX]--/ \- [flag : cmp] - // ^ ^ - // | | - // \---[br flag]- - // - // cmp + br should be considered as a single node as they are flagged - // together. So, if the ld is folded into the cmp, the XX node in the - // graph is now both an operand and a use of the ld/cmp/br node. - if (NodeHasProperty(P, SDNodeInfo::SDNPOutFlag, ISE)) -emitCheck(ParentName + ".Val->isOnlyUse(" + RootName + ".Val)"); - // If the immediate use can somehow reach this node through another // path, then can't fold it either or it will create a cycle. // e.g. In the following diagram, XX can reach ld through YY. If @@ -3629,6 +3611,16 @@ OS << " RemoveKilled();\n"; OS << "}\n\n"; + OS << "void DeleteNode(SDNode *N) {\n"; + OS << " CurDAG->DeleteNode(N);\n"; + OS << " for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); " + << "I != E; ++I) {\n"; + OS << "SDNode *Operand = I->Val;\n"; + OS << "if (Operand->use_empty())\n"; + OS << " DeleteNode(Operand);\n"; + OS << " }\n"; + OS << "}\n"; + OS << "// SelectRoot - Top level entry to DAG isel.\n"; OS << "SDOperand SelectRoot(SDOperand Root) {\n"; OS << " SelectRootInit();\n"; @@ -3649,7 +3641,12 @@ OS << "ISelQueue.pop_back();\n"; OS << "if (!isSelected(Node->getNodeId())) {\n"; OS << " SDNode *ResNode = Select(SDOperand(Node, 0));\n"; - OS << " if (ResNode && ResNode != Node) ReplaceUses(Node, ResNode);\n"; + OS << " if (ResNode != Node) {\n"; + OS << "if (ResNode)\n"; + OS << " ReplaceUses(Node, ResNode);\n"; + OS << "if (Node->use_empty()) // Don't delete EntryToken, etc.\n"; + OS << " DeleteNode(Node);\n"; + OS << " }\n"; OS << "}\n"; OS << " }\n"; OS << "\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.253 -> 1.254 --- Log message: Generated isel should favors explicit constant operand (+2) over an operand with a predicate (+1). --- Diffs of the changes: (+4 -5) DAGISelEmitter.cpp |9 - 1 files changed, 4 insertions(+), 5 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.253 llvm/utils/TableGen/DAGISelEmitter.cpp:1.254 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.253Sun Aug 27 08:16:24 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Sep 8 02:26:39 2006 @@ -768,7 +768,6 @@ if (OperandNode->isSubClassOf("RegisterClass")) { const CodeGenRegisterClass &RC = ISE.getTargetInfo().getRegisterClass(OperandNode); -//VT = RC.getValueTypeNum(0); MadeChange |=getChild(i)->UpdateNodeType(ConvertVTs(RC.getValueTypes()), TP); } else if (OperandNode->isSubClassOf("Operand")) { @@ -1944,11 +1943,11 @@ P->getExtTypeNum(0) == MVT::Flag || P->getExtTypeNum(0) == MVT::iPTR) && "Not a valid pattern node to size!"); - unsigned Size = 2; // The node itself. + unsigned Size = 3; // The node itself. // If the root node is a ConstantSDNode, increases its size. // e.g. (set R32:$dst, 0). if (P->isLeaf() && dynamic_cast(P->getLeafValue())) -Size++; +Size += 2; // FIXME: This is a hack to statically increase the priority of patterns // which maps a sub-dag to a complex pattern. e.g. favors LEA over ADD. @@ -1957,7 +1956,7 @@ // calculate the complexity of all patterns a dag can potentially map to. const ComplexPattern *AM = NodeGetComplexPattern(P, ISE); if (AM) -Size += AM->getNumOperands() * 2; +Size += AM->getNumOperands() * 3; // If this node has some predicate function that must match, it adds to the // complexity of this node. @@ -1971,7 +1970,7 @@ Size += getPatternSize(Child, ISE); else if (Child->isLeaf()) { if (dynamic_cast(Child->getLeafValue())) -Size += 3; // Matches a ConstantSDNode (+2) and a specific value (+1). +Size += 5; // Matches a ConstantSDNode (+3) and a specific value (+2). else if (NodeIsComplexPattern(Child)) Size += getPatternSize(Child, ISE); else if (!Child->getPredicateFn().empty()) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.252 -> 1.253 --- Log message: Use compiler.h instead of hand rolling our own macro --- Diffs of the changes: (+4 -9) DAGISelEmitter.cpp | 13 - 1 files changed, 4 insertions(+), 9 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.252 llvm/utils/TableGen/DAGISelEmitter.cpp:1.253 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.252Sun Aug 27 03:11:28 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sun Aug 27 08:16:24 2006 @@ -3355,7 +3355,7 @@ CalleeCode += ") "; // Prevent emission routines from being inlined to reduce selection // routines stack frame sizes. -CalleeCode += "NOINLINE "; +CalleeCode += "DISABLE_INLINE "; CalleeCode += "{\n"; for (std::vector::const_reverse_iterator @@ -3565,12 +3565,7 @@ << "// *** instruction selector class. These functions are really " << "methods.\n\n"; - OS << "#if defined(__GNUC__) && \\\n"; - OS << "((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)))\n"; - OS << "#define NOINLINE __attribute__((noinline))\n"; - OS << "#else\n"; - OS << "#define NOINLINE\n"; - OS << "#endif\n\n"; + OS << "#include \"llvm/Support/Compiler.h\"\n"; OS << "// Instruction selector priority queue:\n" << "std::vector ISelQueue;\n"; @@ -3603,7 +3598,7 @@ OS << " return ISelSelected[Id / 8] & (1 << (Id % 8));\n"; OS << "}\n\n"; - OS << "void AddToISelQueue(SDOperand N) NOINLINE {\n"; + OS << "void AddToISelQueue(SDOperand N) DISABLE_INLINE {\n"; OS << " int Id = N.Val->getNodeId();\n"; OS << " if (Id != -1 && !isQueued(Id)) {\n"; OS << "ISelQueue.push_back(N.Val);\n"; @@ -3624,7 +3619,7 @@ OS << " }\n"; OS << "}\n\n"; - OS << "void ReplaceUses(SDOperand F, SDOperand T) NOINLINE {\n"; + OS << "void ReplaceUses(SDOperand F, SDOperand T) DISABLE_INLINE {\n"; OS << " CurDAG->ReplaceAllUsesOfValueWith(F, T, ISelKilled);\n"; OS << " setSelected(F.Val->getNodeId());\n"; OS << " RemoveKilled();\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.251 -> 1.252 --- Log message: Do not emit getTargetNode() and SelectNodeTo() which takes more than 3 SDOperand arguments. Use the variants which take an array and number instead. --- Diffs of the changes: (+71 -42) DAGISelEmitter.cpp | 113 + 1 files changed, 71 insertions(+), 42 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.251 llvm/utils/TableGen/DAGISelEmitter.cpp:1.252 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.251Sat Aug 26 02:56:39 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sun Aug 27 03:11:28 2006 @@ -2583,7 +2583,7 @@ "(N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag);"); } if (HasVarOps) -emitCode("SmallVector Ops;"); +emitCode("SmallVector Ops" + utostr(OpcNo) + ";"); // How many results is this pattern expected to produce? unsigned PatResults = 0; @@ -2607,15 +2607,17 @@ if (NodeHasInFlag || HasImpInputs) EmitInFlagSelectCode(Pattern, "N", ChainEmitted, InFlagDecled, ResNodeDecled, true); - if (NodeHasOptInFlag) { + if (NodeHasOptInFlag || NodeHasInFlag || HasImpInputs) { if (!InFlagDecled) { emitCode("SDOperand InFlag(0, 0);"); InFlagDecled = true; } -emitCode("if (HasInFlag) {"); -emitCode(" InFlag = N.getOperand(N.getNumOperands()-1);"); -emitCode(" AddToISelQueue(InFlag);"); -emitCode("}"); +if (NodeHasOptInFlag) { + emitCode("if (HasInFlag) {"); + emitCode(" InFlag = N.getOperand(N.getNumOperands()-1);"); + emitCode(" AddToISelQueue(InFlag);"); + emitCode("}"); +} } unsigned NumResults = Inst.getNumResults(); @@ -2635,7 +2637,9 @@ else Code2 = NodeName + " = "; } + Code = "CurDAG->getTargetNode(Opc" + utostr(OpcNo); +unsigned OpsNo = OpcNo; emitOpcode(II.Namespace + "::" + II.TheDef->getName()); // Output order: results, chain, flags @@ -2650,12 +2654,10 @@ Code += ", MVT::Flag"; // Inputs. -for (unsigned i = 0, e = AllOps.size(); i != e; ++i) { - std::string OpName = AllOps[i]; - if (HasVarOps) -emitCode("Ops.push_back(" + OpName + ");"); - else -Code += ", " + OpName; +if (HasVarOps) { + for (unsigned i = 0, e = AllOps.size(); i != e; ++i) +emitCode("Ops" + utostr(OpsNo) + ".push_back(" + AllOps[i] + ");"); + AllOps.clear(); } if (HasVarOps) { @@ -2669,40 +2671,51 @@ emitCode("for (unsigned i = 2, e = N.getNumOperands(); " "i != e; ++i) {"); emitCode(" AddToISelQueue(N.getOperand(i));"); - emitCode(" Ops.push_back(N.getOperand(i));"); + emitCode(" Ops" + utostr(OpsNo) + ".push_back(N.getOperand(i));"); emitCode("}"); } if (NodeHasChain) { if (HasVarOps) -emitCode("Ops.push_back(" + ChainName + ");"); +emitCode("Ops" + utostr(OpsNo) + ".push_back(" + ChainName + ");"); else -Code += ", " + ChainName; +AllOps.push_back(ChainName); } -if (NodeHasInFlag || HasImpInputs) { - if (!InFlagDecled) { -emitCode("SDOperand InFlag(0, 0);"); -InFlagDecled = true; + +if (HasVarOps) { + if (NodeHasInFlag || HasImpInputs) +emitCode("Ops" + utostr(OpsNo) + ".push_back(InFlag);"); + else if (NodeHasOptInFlag) { +emitCode("if (HasInFlag)"); +emitCode(" Ops" + utostr(OpsNo) + ".push_back(InFlag);"); } - if (HasVarOps) { -emitCode("Ops.push_back(InFlag);"); - } else -Code += ", InFlag"; -} else if (NodeHasOptInFlag && HasVarOps) { - if (!InFlagDecled) { -emitCode("SDOperand InFlag(0, 0);"); -InFlagDecled = true; + Code += ", &Ops" + utostr(OpsNo) + "[0], Ops" + utostr(OpsNo) + +".size()"; +} else if (NodeHasInFlag || NodeHasOptInFlag || HasImpInputs) +AllOps.push_back("InFlag"); + +unsigned NumOps = AllOps.size(); +if (NumOps) { + if (!NodeHasOptInFlag && NumOps < 4) { +for (unsigned i = 0; i != NumOps; ++i) + Code += ", " + AllOps[i]; + } else { +std::string OpsCode = "SDOperand Ops" + utostr(OpsNo) + "[] = { "; +for (unsigned i = 0; i != NumOps; ++i) { + OpsCode += AllOps[i]; + if (i != NumOps-1) +OpsCode += ", "; +} +emitCode(OpsCode + " };"); +Code
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.250 -> 1.251 --- Log message: SelectNodeTo now returns a SDNode*. --- Diffs of the changes: (+1 -1) DAGISelEmitter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.250 llvm/utils/TableGen/DAGISelEmitter.cpp:1.251 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.250Sat Aug 26 02:39:28 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sat Aug 26 02:56:39 2006 @@ -2796,7 +2796,7 @@ Code += ", " + AllOps[i]; if (NodeHasInFlag || HasImpInputs) Code += ", InFlag"; -emitCode(Code + ").Val;"); +emitCode(Code + ");"); emitOpcode(II.Namespace + "::" + II.TheDef->getName()); if (N->getTypeNum(0) != MVT::isVoid) emitVT(getEnumName(N->getTypeNum(0))); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.249 -> 1.250 --- Log message: Minor getCopyToReg() call change. --- Diffs of the changes: (+2 -3) DAGISelEmitter.cpp |5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.249 llvm/utils/TableGen/DAGISelEmitter.cpp:1.250 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.249Sat Aug 26 00:29:57 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sat Aug 26 02:39:28 2006 @@ -2897,9 +2897,8 @@ } std::string Decl = (!ResNodeDecled) ? "SDNode *" : ""; emitCode(Decl + "ResNode = CurDAG->getCopyToReg(" + ChainName + - ", CurDAG->getRegister(" + ISE.getQualifiedName(RR) + - ", " + getEnumName(RVT) + "), " + - RootName + utostr(OpNo) + ", InFlag).Val;"); + ", " + ISE.getQualifiedName(RR) + + ", " + RootName + utostr(OpNo) + ", InFlag).Val;"); ResNodeDecled = true; emitCode(ChainName + " = SDOperand(ResNode, 0);"); emitCode("InFlag = SDOperand(ResNode, 1);"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Evan, Something in this patch or the subsequent ones has broken all builds. Can you fix before the nightly testers all die? Reid. On Sat, 2006-08-26 at 00:30 -0500, Evan Cheng wrote: > > Changes in directory llvm/utils/TableGen: > > DAGISelEmitter.cpp updated: 1.248 -> 1.249 > --- > Log message: > > Select() no longer require Result operand by reference. > > --- > Diffs of the changes: (+18 -44) > > DAGISelEmitter.cpp | 62 > +++-- > 1 files changed, 18 insertions(+), 44 deletions(-) > > > Index: llvm/utils/TableGen/DAGISelEmitter.cpp > diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.248 > llvm/utils/TableGen/DAGISelEmitter.cpp:1.249 > --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.248 Fri Aug 25 20:34:15 2006 > +++ llvm/utils/TableGen/DAGISelEmitter.cppSat Aug 26 00:29:57 2006 > @@ -2517,7 +2517,6 @@ >emitCode("AddToISelQueue(" + Val + ");"); >if (isRoot && N->isLeaf()) { > emitCode("ReplaceUses(N, " + Val + ");"); > -emitCode("Result = " + Val + ";"); > emitCode("return NULL;"); >} > } > @@ -2768,43 +2767,26 @@ > > // User does not expect the instruction would produce a chain! > if ((!InputHasChain && NodeHasChain) && NodeHasOutFlag) { > - if (PatResults == 0) { > -emitCode("Result = SDOperand(ResNode, N.ResNo+1);"); > - } else { > - assert(PatResults == 1); > -emitCode("Result = (N.ResNo == 0) ? SDOperand(ResNode, 0) :" > - " SDOperand(ResNode, 1);"); > - } > + ; > } else if (InputHasChain && !NodeHasChain) { >// One of the inner node produces a chain. > - if (NodeHasOutFlag) { > -emitCode("Result = (N.ResNo < " + utostr(PatResults) + > - ") ? SDOperand(ResNode, N.ResNo) : " + > - "(N.ResNo > " + utostr(PatResults) + ") ? " + > - "SDOperand(ResNode, N.ResNo-1) : " + ChainName + "));"); > + if (NodeHasOutFlag) > emitCode("ReplaceUses(SDOperand(N.Val, " + utostr(PatResults+1) + >"), SDOperand(ResNode, N.ResNo-1));"); > - } else { > -emitCode("Result = (N.ResNo < " + utostr(PatResults) + > - ") ? SDOperand(ResNode, N.ResNo) : " + > - ChainName + ";"); > - } > for (unsigned i = 0; i < PatResults; ++i) > emitCode("ReplaceUses(SDOperand(N.Val, " + utostr(i) + >"), SDOperand(ResNode, " + utostr(i) + "));"); > emitCode("ReplaceUses(SDOperand(N.Val, " + utostr(PatResults) + > "), " + ChainName + ");"); > RetSelected = false; > - } else { > - emitCode("Result = SDOperand(ResNode, N.ResNo);"); > } > > if (RetSelected) > - emitCode("return Result.Val;"); > + emitCode("return ResNode;"); > else > emitCode("return NULL;"); >} else { > -std::string Code = "Result = CurDAG->SelectNodeTo(N.Val, Opc" + > +std::string Code = "return CurDAG->SelectNodeTo(N.Val, Opc" + >utostr(OpcNo); > if (N->getTypeNum(0) != MVT::isVoid) >Code += ", VT" + utostr(VTNo); > @@ -2814,8 +2796,7 @@ >Code += ", " + AllOps[i]; > if (NodeHasInFlag || HasImpInputs) >Code += ", InFlag"; > -emitCode(Code + ");"); > -emitCode("return Result.Val;"); > +emitCode(Code + ").Val;"); > emitOpcode(II.Namespace + "::" + II.TheDef->getName()); > if (N->getTypeNum(0) != MVT::isVoid) >emitVT(getEnumName(N->getTypeNum(0))); > @@ -2833,10 +2814,8 @@ >emitCode("SDOperand Tmp" + utostr(ResNo) + " = Transform_" + > Op->getName() > + "(" + Ops.back() + ".Val);"); >NodeOps.push_back("Tmp" + utostr(ResNo)); > - if (isRoot) { > -emitCode("Result = Tmp" + utostr(ResNo) + ";"); > -emitCode("return Result.Val;"); > - } > + if (isRoot) > +emitCode("return Tmp" + utostr(ResNo) + ".Val;"); >return NodeOps; > } else { >N->dump(); > @@ -3328,8 +3307,8 @@ > AddedInits.push_back(GeneratedCode[j].second); > } > > -std::string CalleeCode = "(SDOperand &Result, const SDOperand &N"; > -std::string CallerCode = "(Result, N"; > +std::string CalleeCode = "(const SDOperand &N"; > +std::string CallerCode = "(N"; > for (unsigned j = 0, e = TargetOpcodes.size(); j != e; ++j) { >CalleeCode += ", unsigned Opc" + utostr(j); >CallerCode += ", " + TargetOpcodes[j]; > @@ -3392,7 +3371,7 @@ > OpVTI->second.push_back(OpVTStr); > >OS << "SDNode *Select_" << OpName << (OpVTStr != "" ? "_" : "") > - << OpVTStr << "(SDOperand &Result, const SDOperand &N) {\n"; > + << OpVTStr << "
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.248 -> 1.249 --- Log message: Select() no longer require Result operand by reference. --- Diffs of the changes: (+18 -44) DAGISelEmitter.cpp | 62 +++-- 1 files changed, 18 insertions(+), 44 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.248 llvm/utils/TableGen/DAGISelEmitter.cpp:1.249 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.248Fri Aug 25 20:34:15 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sat Aug 26 00:29:57 2006 @@ -2517,7 +2517,6 @@ emitCode("AddToISelQueue(" + Val + ");"); if (isRoot && N->isLeaf()) { emitCode("ReplaceUses(N, " + Val + ");"); -emitCode("Result = " + Val + ";"); emitCode("return NULL;"); } } @@ -2768,43 +2767,26 @@ // User does not expect the instruction would produce a chain! if ((!InputHasChain && NodeHasChain) && NodeHasOutFlag) { - if (PatResults == 0) { -emitCode("Result = SDOperand(ResNode, N.ResNo+1);"); - } else { - assert(PatResults == 1); -emitCode("Result = (N.ResNo == 0) ? SDOperand(ResNode, 0) :" -" SDOperand(ResNode, 1);"); - } + ; } else if (InputHasChain && !NodeHasChain) { // One of the inner node produces a chain. - if (NodeHasOutFlag) { -emitCode("Result = (N.ResNo < " + utostr(PatResults) + -") ? SDOperand(ResNode, N.ResNo) : " + -"(N.ResNo > " + utostr(PatResults) + ") ? " + -"SDOperand(ResNode, N.ResNo-1) : " + ChainName + "));"); + if (NodeHasOutFlag) emitCode("ReplaceUses(SDOperand(N.Val, " + utostr(PatResults+1) + "), SDOperand(ResNode, N.ResNo-1));"); - } else { -emitCode("Result = (N.ResNo < " + utostr(PatResults) + -") ? SDOperand(ResNode, N.ResNo) : " + -ChainName + ";"); - } for (unsigned i = 0; i < PatResults; ++i) emitCode("ReplaceUses(SDOperand(N.Val, " + utostr(i) + "), SDOperand(ResNode, " + utostr(i) + "));"); emitCode("ReplaceUses(SDOperand(N.Val, " + utostr(PatResults) + "), " + ChainName + ");"); RetSelected = false; - } else { - emitCode("Result = SDOperand(ResNode, N.ResNo);"); } if (RetSelected) - emitCode("return Result.Val;"); + emitCode("return ResNode;"); else emitCode("return NULL;"); } else { -std::string Code = "Result = CurDAG->SelectNodeTo(N.Val, Opc" + +std::string Code = "return CurDAG->SelectNodeTo(N.Val, Opc" + utostr(OpcNo); if (N->getTypeNum(0) != MVT::isVoid) Code += ", VT" + utostr(VTNo); @@ -2814,8 +2796,7 @@ Code += ", " + AllOps[i]; if (NodeHasInFlag || HasImpInputs) Code += ", InFlag"; -emitCode(Code + ");"); -emitCode("return Result.Val;"); +emitCode(Code + ").Val;"); emitOpcode(II.Namespace + "::" + II.TheDef->getName()); if (N->getTypeNum(0) != MVT::isVoid) emitVT(getEnumName(N->getTypeNum(0))); @@ -2833,10 +2814,8 @@ emitCode("SDOperand Tmp" + utostr(ResNo) + " = Transform_" + Op->getName() + "(" + Ops.back() + ".Val);"); NodeOps.push_back("Tmp" + utostr(ResNo)); - if (isRoot) { -emitCode("Result = Tmp" + utostr(ResNo) + ";"); -emitCode("return Result.Val;"); - } + if (isRoot) +emitCode("return Tmp" + utostr(ResNo) + ".Val;"); return NodeOps; } else { N->dump(); @@ -3328,8 +3307,8 @@ AddedInits.push_back(GeneratedCode[j].second); } -std::string CalleeCode = "(SDOperand &Result, const SDOperand &N"; -std::string CallerCode = "(Result, N"; +std::string CalleeCode = "(const SDOperand &N"; +std::string CallerCode = "(N"; for (unsigned j = 0, e = TargetOpcodes.size(); j != e; ++j) { CalleeCode += ", unsigned Opc" + utostr(j); CallerCode += ", " + TargetOpcodes[j]; @@ -3392,7 +3371,7 @@ OpVTI->second.push_back(OpVTStr); OS << "SDNode *Select_" << OpName << (OpVTStr != "" ? "_" : "") - << OpVTStr << "(SDOperand &Result, const SDOperand &N) {\n"; + << OpVTStr << "(const SDOperand &N) {\n"; // Loop through and reverse all of the CodeList vectors, as we will be // accessing them from their logical front, but accessing the end of a @@ -3431,7 +3410,7 @@ } // Emit boilerplate. - OS << "SDNode *Select_INLINEASM(SDOperand& Result, SDOperand N) {\n" + OS << "SDNode *Select_INLINEASM(SDOperand N) {\n"
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.247 -> 1.248 --- Log message: Remove dead code. --- Diffs of the changes: (+0 -2) DAGISelEmitter.cpp |2 -- 1 files changed, 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.247 llvm/utils/TableGen/DAGISelEmitter.cpp:1.248 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.247Fri Aug 25 20:02:19 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Aug 25 20:34:15 2006 @@ -2658,7 +2658,6 @@ else Code += ", " + OpName; } -//AllOps.clear(); if (HasVarOps) { if (NodeHasInFlag || HasImpInputs) @@ -2813,7 +2812,6 @@ Code += ", MVT::Flag"; for (unsigned i = 0, e = AllOps.size(); i != e; ++i) Code += ", " + AllOps[i]; -//AllOps.clear(); if (NodeHasInFlag || HasImpInputs) Code += ", InFlag"; emitCode(Code + ");"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.246 -> 1.247 DAGISelEmitter.h updated: 1.68 -> 1.69 --- Log message: A bit more clean up. --- Diffs of the changes: (+14 -17) DAGISelEmitter.cpp | 29 + DAGISelEmitter.h |2 +- 2 files changed, 14 insertions(+), 17 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.246 llvm/utils/TableGen/DAGISelEmitter.cpp:1.247 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.246Fri Aug 25 19:59:04 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Aug 25 20:02:19 2006 @@ -2126,7 +2126,7 @@ std::vector > &GeneratedCode; /// GeneratedDecl - This is the set of all SDOperand declarations needed for /// the set of patterns for each top-level opcode. - std::set > &GeneratedDecl; + std::set &GeneratedDecl; /// TargetOpcodes - The target specific opcodes used by the resulting /// instructions. std::vector &TargetOpcodes; @@ -2149,9 +2149,9 @@ if (!S.empty()) GeneratedCode.push_back(std::make_pair(2, S)); } - void emitDecl(const std::string &S, unsigned T=0) { + void emitDecl(const std::string &S) { assert(!S.empty() && "Invalid declaration"); -GeneratedDecl.insert(std::make_pair(T, S)); +GeneratedDecl.insert(S); } void emitOpcode(const std::string &Opc) { TargetOpcodes.push_back(Opc); @@ -2165,7 +2165,7 @@ PatternCodeEmitter(DAGISelEmitter &ise, ListInit *preds, TreePatternNode *pattern, TreePatternNode *instr, std::vector > &gc, - std::set > &gd, + std::set &gd, std::vector &to, std::vector &tv) : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr), @@ -2986,9 +2986,9 @@ /// succeeds. Returns true if the pattern is not guaranteed to match. void DAGISelEmitter::GenerateCodeForPattern(PatternToMatch &Pattern, std::vector > &GeneratedCode, - std::set > &GeneratedDecl, + std::set &GeneratedDecl, std::vector &TargetOpcodes, -std::vector &TargetVTs) { + std::vector &TargetVTs) { PatternCodeEmitter Emitter(*this, Pattern.getPredicates(), Pattern.getSrcPattern(), Pattern.getDstPattern(), GeneratedCode, GeneratedDecl, @@ -3274,10 +3274,10 @@ std::vector > CodeForPatterns; std::vector > PatternOpcodes; std::vector > PatternVTs; - std::vector > > PatternDecls; + std::vector > PatternDecls; for (unsigned i = 0, e = Patterns.size(); i != e; ++i) { CodeList GeneratedCode; -std::set > GeneratedDecl; +std::set GeneratedDecl; std::vector TargetOpcodes; std::vector TargetVTs; GenerateCodeForPattern(*Patterns[i], GeneratedCode, GeneratedDecl, @@ -3319,7 +3319,7 @@ CodeList &GeneratedCode = CodeForPatterns[i].second; std::vector &TargetOpcodes = PatternOpcodes[i]; std::vector &TargetVTs = PatternVTs[i]; -std::set > Decls = PatternDecls[i]; +std::set Decls = PatternDecls[i]; std::vector AddedInits; int CodeSize = (int)GeneratedCode.size(); int LastPred = -1; @@ -3340,9 +3340,9 @@ CalleeCode += ", MVT::ValueType VT" + utostr(j); CallerCode += ", " + TargetVTs[j]; } -for (std::set >::iterator +for (std::set::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) { - std::string Name = I->second; + std::string Name = *I; CalleeCode += ", SDOperand &" + Name; CallerCode += ", " + Name; } @@ -3357,11 +3357,8 @@ I = AddedInits.rbegin(), E = AddedInits.rend(); I != E; ++I) CalleeCode += " " + *I + "\n"; -for (int j = LastPred+1; j < CodeSize; ++j) { - std::string code = GeneratedCode[j].second; - // if (!AddedDecls.count(code)) -CalleeCode += " " + code + "\n"; -} +for (int j = LastPred+1; j < CodeSize; ++j) + CalleeCode += " " + GeneratedCode[j].second + "\n"; for (int j = LastPred+1; j < CodeSize; ++j) GeneratedCode.pop_back(); CalleeCode += "}\n"; Index: llvm/utils/TableGen/DAGISelEmitter.h diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.68 llvm/utils/TableGen/DAGISelEmitter.h:1.69 --- llvm/utils/TableGen/DAGISelEmitter.h:1.68 Fri Aug 25 19:59:04 2006 +++ llvm/utils/TableGen/DAGISelEmitter.hFri Aug 25 20:02:19 2006 @@ -521,7 +521,7 @@ std::vector &InstImpResults); void GenerateCodeForPattern(PatternToMatch &Pattern, std::
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.245 -> 1.246 DAGISelEmitter.h updated: 1.67 -> 1.68 --- Log message: - Clean up tablegen dag isel generator code. - Clean up the code generated by tablegen: * AddToISelQueue now takes one argument. * ComplexPattern matching condition can now be shared. * Eliminate passing unnecessary arguments to emit routines. * Eliminate some unneeded SDOperand declarations in select routines. * Other minor clean ups. - This reduces foot print slightly: X86ISelDAGToDAG.o is reduced from 971k to 823k. --- Diffs of the changes: (+240 -237) DAGISelEmitter.cpp | 473 ++--- DAGISelEmitter.h |4 2 files changed, 240 insertions(+), 237 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.245 llvm/utils/TableGen/DAGISelEmitter.cpp:1.246 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.245Wed Aug 16 02:25:15 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Aug 25 19:59:04 2006 @@ -1909,7 +1909,6 @@ } } - // NodeIsComplexPattern - return true if N is a leaf node and a subclass of // ComplexPattern. static bool NodeIsComplexPattern(TreePatternNode *N) @@ -2120,11 +2119,11 @@ std::vector > FoldedChains; std::set Duplicates; - /// GeneratedCode - This is the buffer that we emit code to. The first bool + /// GeneratedCode - This is the buffer that we emit code to. The first int /// indicates whether this is an exit predicate (something that should be - /// tested, and if true, the match fails) [when true] or normal code to emit - /// [when false]. - std::vector > &GeneratedCode; + /// tested, and if true, the match fails) [when 1], or normal code to emit + /// [when 0], or initialization code to emit [when 2]. + std::vector > &GeneratedCode; /// GeneratedDecl - This is the set of all SDOperand declarations needed for /// the set of patterns for each top-level opcode. std::set > &GeneratedDecl; @@ -2140,11 +2139,15 @@ void emitCheck(const std::string &S) { if (!S.empty()) - GeneratedCode.push_back(std::make_pair(true, S)); + GeneratedCode.push_back(std::make_pair(1, S)); } void emitCode(const std::string &S) { if (!S.empty()) - GeneratedCode.push_back(std::make_pair(false, S)); + GeneratedCode.push_back(std::make_pair(0, S)); + } + void emitInit(const std::string &S) { +if (!S.empty()) + GeneratedCode.push_back(std::make_pair(2, S)); } void emitDecl(const std::string &S, unsigned T=0) { assert(!S.empty() && "Invalid declaration"); @@ -2161,12 +2164,13 @@ public: PatternCodeEmitter(DAGISelEmitter &ise, ListInit *preds, TreePatternNode *pattern, TreePatternNode *instr, - std::vector > &gc, + std::vector > &gc, std::set > &gd, std::vector &to, std::vector &tv) : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr), -GeneratedCode(gc), GeneratedDecl(gd), TargetOpcodes(to), TargetVTs(tv), +GeneratedCode(gc), GeneratedDecl(gd), +TargetOpcodes(to), TargetVTs(tv), TmpNo(0), OpcNo(0), VTNo(0) {} /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo @@ -2290,8 +2294,7 @@ else FoundChain = true; ChainName = "Chain" + ChainSuffix; -emitDecl(ChainName); -emitCode(ChainName + " = " + RootName + +emitInit("SDOperand " + ChainName + " = " + RootName + ".getOperand(0);"); } } @@ -2312,12 +2315,12 @@ } } +const ComplexPattern *CP; for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { - emitDecl(RootName + utostr(OpNo)); - emitCode(RootName + utostr(OpNo) + " = " + + emitInit("SDOperand " + RootName + utostr(OpNo) + " = " + RootName + ".getOperand(" +utostr(OpNo) + ");"); - TreePatternNode *Child = N->getChild(i); - + + TreePatternNode *Child = N->getChild(i); if (!Child->isLeaf()) { // If it's not a leaf, recursively match. const SDNodeInfo &CInfo = ISE.getSDNodeInfo(Child->getOperator()); @@ -2354,7 +2357,19 @@ } else if (LeafRec->isSubClassOf("Register")) { // Handle register references. } else if (LeafRec->isSubClassOf("ComplexPattern")) { -// Handle complex pattern. Nothing to do here. +// Handle complex pattern. +CP = NodeGetComplexPattern(Child, ISE); +std::string Fn = CP->getSelectFunc(); +unsigned NumOps = CP->getNumOperands(); +for (unsigned i = 0; i < NumOps; ++i) { + emitDecl("CPTmp" + utostr(i)); + emitCode("SDOperand CPTmp" + utostr(i) + ";"); +} + +std::string Code = Fn + "(" + RootName + u
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.244 -> 1.245 --- Log message: SelectNodeTo() may return a SDOperand that is different from the input. --- Diffs of the changes: (+1 -4) DAGISelEmitter.cpp |5 + 1 files changed, 1 insertion(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.244 llvm/utils/TableGen/DAGISelEmitter.cpp:1.245 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.244Tue Aug 15 18:42:26 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Aug 16 02:25:15 2006 @@ -2794,8 +2794,6 @@ if (NodeHasInFlag || HasImpInputs) Code += ", InFlag"; emitCode(Code + ");"); -if (isRoot) - emitCode(" return NULL;"); emitCode("} else {"); emitDecl("ResNode", 1); Code = " ResNode = CurDAG->getTargetNode(Opc" + utostr(OpcNo); @@ -2812,9 +2810,8 @@ Code += ", InFlag"; emitCode(Code + ");"); emitCode(" Result = SDOperand(ResNode, 0);"); -if (isRoot) - emitCode(" return Result.Val;"); emitCode("}"); +emitCode("return Result.Val;"); } return std::make_pair(1, ResNo); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.243 -> 1.244 --- Log message: The generated runloop shouldn't require Select to update 'Result'. In fact we'd like to remove result entirely. --- Diffs of the changes: (+6 -3) DAGISelEmitter.cpp |9 ++--- 1 files changed, 6 insertions(+), 3 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.243 llvm/utils/TableGen/DAGISelEmitter.cpp:1.244 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.243Tue Aug 15 18:27:50 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Aug 15 18:42:26 2006 @@ -3646,8 +3646,11 @@ OS << " memset(ISelQueued, 0, NumBytes);\n"; OS << " memset(ISelSelected, 0, NumBytes);\n"; OS << "\n"; - OS << " SDOperand ResNode;\n"; - OS << " Select(ResNode, Root);\n"; + OS << " // Create a dummy node (which is not added to allnodes), that adds\n" + << " // a reference to the root node, preventing it from being deleted,\n" + << " // and tracking any changes of the root.\n" + << " HandleSDNode Dummy(CurDAG->getRoot());\n" + << " ISelQueue.push_back(CurDAG->getRoot().Val);\n"; OS << " while (!ISelQueue.empty()) {\n"; OS << "SDOperand Tmp;\n"; OS << "SDNode *Node = ISelQueue.front();\n"; @@ -3663,7 +3666,7 @@ OS << " ISelQueued = NULL;\n"; OS << " delete[] ISelSelected;\n"; OS << " ISelSelected = NULL;\n"; - OS << " return ResNode;\n"; + OS << " return Dummy.getValue();\n"; OS << "}\n"; Intrinsics = LoadIntrinsics(Records); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.242 -> 1.243 --- Log message: allow Select to return the node being selected if RAU isn't needed. --- Diffs of the changes: (+1 -1) DAGISelEmitter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.242 llvm/utils/TableGen/DAGISelEmitter.cpp:1.243 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.242Fri Aug 11 13:33:41 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Aug 15 18:27:50 2006 @@ -3655,7 +3655,7 @@ OS << "ISelQueue.pop_back();\n"; OS << "if (!isSelected(Node->getNodeId())) {\n"; OS << " SDNode *ResNode = Select(Tmp, SDOperand(Node, 0));\n"; - OS << " if (ResNode) ReplaceUses(Node, ResNode);\n"; + OS << " if (ResNode && ResNode != Node) ReplaceUses(Node, ResNode);\n"; OS << "}\n"; OS << " }\n"; OS << "\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.241 -> 1.242 --- Log message: Use SmallVector instead. --- Diffs of the changes: (+1 -1) DAGISelEmitter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.241 llvm/utils/TableGen/DAGISelEmitter.cpp:1.242 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.241Fri Aug 11 03:59:35 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Aug 11 13:33:41 2006 @@ -2560,7 +2560,7 @@ "(N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag);"); } if (HasVarOps) -emitCode("std::vector Ops;"); +emitCode("SmallVector Ops;"); // How many results is this pattern expected to produce? unsigned PatResults = 0; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.240 -> 1.241 --- Log message: - Prevent some functions from being inlined to eliminate the code size bloat introduced by previous commit. - SelectCode now returns a SDNode*. If it is not null, the selected node produces the same number of results as the input node. The seletion loop is responsible for calling ReplaceAllUsesWith() to replace the input node with the output target node. For other cases, e.g. when load is folded, the selection code is responsible for calling ReplaceAllUsesOfValueWith() and SelectCode returns NULL. - Other clean ups. --- Diffs of the changes: (+96 -67) DAGISelEmitter.cpp | 163 +++-- 1 files changed, 96 insertions(+), 67 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.240 llvm/utils/TableGen/DAGISelEmitter.cpp:1.241 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.240Wed Aug 9 11:44:44 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Aug 11 03:59:35 2006 @@ -2397,7 +2397,7 @@ /// EmitResultCode - Emit the action for a pattern. Now that it has matched /// we actually have to build a DAG! std::pair - EmitResultCode(TreePatternNode *N, bool LikeLeaf = false, + EmitResultCode(TreePatternNode *N, bool &RetSelected, bool LikeLeaf = false, bool isRoot = false) { // This is something selected from the pattern we matched. if (!N->getName().empty()) { @@ -2489,7 +2489,7 @@ if (isRoot && N->isLeaf()) { emitCode("ReplaceUses(N, Tmp" + utostr(ResNo) + ");"); emitCode("Result = Tmp" + utostr(ResNo) + ";"); -emitCode("return;"); +emitCode("return NULL;"); } } } @@ -2590,7 +2590,8 @@ for (unsigned i = 0, e = EmitOrder.size(); i != e; ++i) { unsigned OpOrder = EmitOrder[i].first; TreePatternNode *Child = EmitOrder[i].second; -std::pair NumTemp = EmitResultCode(Child); +std::pair NumTemp = + EmitResultCode(Child, RetSelected); NumTemps[OpOrder] = NumTemp; } @@ -2703,10 +2704,7 @@ if (!isRoot) return std::make_pair(1, ResNo); -for (unsigned i = 0; i < NumResults; i++) - emitCode("ReplaceUses(SDOperand(N.Val, " + - utostr(i) + "), SDOperand(ResNode, " + utostr(i) + "));"); - +bool NeedReplace = false; if (NodeHasOutFlag) emitCode("InFlag = SDOperand(ResNode, " + utostr(NumResults + (unsigned)NodeHasChain) + ");"); @@ -2716,11 +2714,6 @@ NumResults = 1; } -if (InputHasChain) - emitCode("ReplaceUses(SDOperand(N.Val, " + - utostr(PatResults) + "), SDOperand(" + ChainName + ".Val, " + - ChainName + ".ResNo" + "));"); - if (FoldedChains.size() > 0) { std::string Code; for (unsigned j = 0, e = FoldedChains.size(); j < e; j++) @@ -2728,37 +2721,64 @@ FoldedChains[j].first + ".Val, " + utostr(FoldedChains[j].second) + "), SDOperand(ResNode, " + utostr(NumResults) + "));"); + NeedReplace = true; } -if (NodeHasOutFlag) +if (NodeHasOutFlag) { emitCode("ReplaceUses(SDOperand(N.Val, " + utostr(PatResults + (unsigned)InputHasChain) +"), InFlag);"); + NeedReplace = true; +} + +if (NeedReplace) { + for (unsigned i = 0; i < NumResults; i++) +emitCode("ReplaceUses(SDOperand(N.Val, " + + utostr(i) + "), SDOperand(ResNode, " + utostr(i) + "));"); + if (InputHasChain) +emitCode("ReplaceUses(SDOperand(N.Val, " + + utostr(PatResults) + "), SDOperand(" + ChainName + ".Val, " + + ChainName + ".ResNo" + "));"); +} else { + RetSelected = true; +} // User does not expect the instruction would produce a chain! -bool AddedChain = NodeHasChain && !InputHasChain; -if (AddedChain && NodeHasOutFlag) { +if ((!InputHasChain && NodeHasChain) && NodeHasOutFlag) { if (PatResults == 0) { emitCode("Result = SDOperand(ResNode, N.ResNo+1);"); } else { -emitCode("if (N.ResNo < " + utostr(PatResults) + ")"); -emitCode(" Result = SDOperand(ResNode, N.ResNo);"); -emitCode("else"); -emitCode(" Result = SDOperand(ResNode, N.ResNo+1);"); + assert(PatResults == 1); +emitCode("Result = (N.ResNo == 0) ? SDOperand(ResNode, 0) :" +" SDOperand(ResNode, 1);"); } } else if (InputHasChain && !NodeHasChain) { // One of the inner node produces a chain. -
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.239 -> 1.240 --- Log message: Revert previous patch --- Diffs of the changes: (+398 -503) DAGISelEmitter.cpp | 901 +++-- 1 files changed, 398 insertions(+), 503 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.239 llvm/utils/TableGen/DAGISelEmitter.cpp:1.240 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.239Wed Aug 9 11:41:21 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Aug 9 11:44:44 2006 @@ -1829,9 +1829,22 @@ // If this node is commutative, consider the commuted order. if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) { assert(N->getNumChildren()==2 &&"Commutative but doesn't have 2 children!"); +// Don't count children which are actually register references. +unsigned NC = 0; +for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { + TreePatternNode *Child = N->getChild(i); + if (Child->isLeaf()) +if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { + Record *RR = DI->getDef(); + if (RR->isSubClassOf("Register")) +continue; +} + NC++; +} // Consider the commuted order. -CombineChildVariants(N, ChildVariants[1], ChildVariants[0], - OutVariants, ISE); +if (NC == 2) + CombineChildVariants(N, ChildVariants[1], ChildVariants[0], + OutVariants, ISE); } } @@ -2106,8 +2119,6 @@ // Names of all the folded nodes which produce chains. std::vector > FoldedChains; std::set Duplicates; - /// These nodes are being marked "in-flight" so they cannot be folded. - std::vector InflightNodes; /// GeneratedCode - This is the buffer that we emit code to. The first bool /// indicates whether this is an exit predicate (something that should be @@ -2123,7 +2134,6 @@ std::vector &TargetVTs; std::string ChainName; - bool DoReplace; unsigned TmpNo; unsigned OpcNo; unsigned VTNo; @@ -2154,11 +2164,10 @@ std::vector > &gc, std::set > &gd, std::vector &to, - std::vector &tv, - bool dorep) + std::vector &tv) : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr), GeneratedCode(gc), GeneratedDecl(gd), TargetOpcodes(to), TargetVTs(tv), -DoReplace(dorep), TmpNo(0), OpcNo(0), VTNo(0) {} +TmpNo(0), OpcNo(0), VTNo(0) {} /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo /// if the match fails. At this point, we already know that the opcode for N @@ -2225,24 +2234,14 @@ bool HasChain = PatternHasProperty(N, SDNodeInfo::SDNPHasChain, ISE); bool HasOutFlag = PatternHasProperty(N, SDNodeInfo::SDNPOutFlag, ISE); bool EmittedUseCheck = false; -bool EmittedSlctedCheck = false; if (HasChain) { if (NodeHasChain) OpNo = 1; if (!isRoot) { const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); -// Not in flight? -emitCheck("InFlightSet.count(" + RootName + ".Val) == 0"); // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; -// hasOneUse() check is not strong enough. If the original node has -// already been selected, it may have been replaced with another. -for (unsigned j = 0; j != CInfo.getNumResults(); j++) - emitCheck("!CodeGenMap.count(" + RootName + ".getValue(" + utostr(j) + -"))"); - -EmittedSlctedCheck = true; if (NodeHasChain) { // FIXME: Don't fold if 1) the parent node writes a flag, 2) the node // has a chain use. @@ -2280,14 +2279,8 @@ PInfo.hasProperty(SDNodeInfo::SDNPHasChain) || PInfo.hasProperty(SDNodeInfo::SDNPInFlag) || PInfo.hasProperty(SDNodeInfo::SDNPOptInFlag)) -if (PInfo.getNumOperands() > 1) { - emitCheck("!isNonImmUse(" + ParentName + ".Val, " + RootName + -".Val)"); -} else { - emitCheck("(" + ParentName + ".getNumOperands() == 1 || !" + -"isNonImmUse(" + ParentName + ".Val, " + RootName + -".Val))"); -} +emitCheck("CanBeFoldedBy(" + RootName + ".Val, " + ParentName + + ".Val)"); } } @@ -2317,12 +2310,6 @@ // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); } - if (!EmittedSlctedCheck) -// hasOneUse() check is not strong enough. If the original node has -// already been selected, it may have been replaced with another. -for (unsigned j = 0; j < CInfo.getNumResults();
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.238 -> 1.239 --- Log message: Reverting back to original 1.8 version so I can manually merge in patch. --- Diffs of the changes: (+503 -398) DAGISelEmitter.cpp | 901 + 1 files changed, 503 insertions(+), 398 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.238 llvm/utils/TableGen/DAGISelEmitter.cpp:1.239 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.238Mon Aug 7 21:23:42 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Aug 9 11:41:21 2006 @@ -1829,22 +1829,9 @@ // If this node is commutative, consider the commuted order. if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) { assert(N->getNumChildren()==2 &&"Commutative but doesn't have 2 children!"); -// Don't count children which are actually register references. -unsigned NC = 0; -for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { - TreePatternNode *Child = N->getChild(i); - if (Child->isLeaf()) -if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { - Record *RR = DI->getDef(); - if (RR->isSubClassOf("Register")) -continue; -} - NC++; -} // Consider the commuted order. -if (NC == 2) - CombineChildVariants(N, ChildVariants[1], ChildVariants[0], - OutVariants, ISE); +CombineChildVariants(N, ChildVariants[1], ChildVariants[0], + OutVariants, ISE); } } @@ -2119,6 +2106,8 @@ // Names of all the folded nodes which produce chains. std::vector > FoldedChains; std::set Duplicates; + /// These nodes are being marked "in-flight" so they cannot be folded. + std::vector InflightNodes; /// GeneratedCode - This is the buffer that we emit code to. The first bool /// indicates whether this is an exit predicate (something that should be @@ -2134,6 +2123,7 @@ std::vector &TargetVTs; std::string ChainName; + bool DoReplace; unsigned TmpNo; unsigned OpcNo; unsigned VTNo; @@ -2164,10 +2154,11 @@ std::vector > &gc, std::set > &gd, std::vector &to, - std::vector &tv) + std::vector &tv, + bool dorep) : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr), GeneratedCode(gc), GeneratedDecl(gd), TargetOpcodes(to), TargetVTs(tv), -TmpNo(0), OpcNo(0), VTNo(0) {} +DoReplace(dorep), TmpNo(0), OpcNo(0), VTNo(0) {} /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo /// if the match fails. At this point, we already know that the opcode for N @@ -2234,14 +2225,24 @@ bool HasChain = PatternHasProperty(N, SDNodeInfo::SDNPHasChain, ISE); bool HasOutFlag = PatternHasProperty(N, SDNodeInfo::SDNPOutFlag, ISE); bool EmittedUseCheck = false; +bool EmittedSlctedCheck = false; if (HasChain) { if (NodeHasChain) OpNo = 1; if (!isRoot) { const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); +// Not in flight? +emitCheck("InFlightSet.count(" + RootName + ".Val) == 0"); // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; +// hasOneUse() check is not strong enough. If the original node has +// already been selected, it may have been replaced with another. +for (unsigned j = 0; j != CInfo.getNumResults(); j++) + emitCheck("!CodeGenMap.count(" + RootName + ".getValue(" + utostr(j) + +"))"); + +EmittedSlctedCheck = true; if (NodeHasChain) { // FIXME: Don't fold if 1) the parent node writes a flag, 2) the node // has a chain use. @@ -2279,8 +2280,14 @@ PInfo.hasProperty(SDNodeInfo::SDNPHasChain) || PInfo.hasProperty(SDNodeInfo::SDNPInFlag) || PInfo.hasProperty(SDNodeInfo::SDNPOptInFlag)) -emitCheck("CanBeFoldedBy(" + RootName + ".Val, " + ParentName + - ".Val)"); +if (PInfo.getNumOperands() > 1) { + emitCheck("!isNonImmUse(" + ParentName + ".Val, " + RootName + +".Val)"); +} else { + emitCheck("(" + ParentName + ".getNumOperands() == 1 || !" + +"isNonImmUse(" + ParentName + ".Val, " + RootName + +".Val))"); +} } } @@ -2310,6 +2317,12 @@ // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); } + if (!EmittedSlctedCheck) +// hasOneUse() check is not strong enough. If the original node has +// already been selected, it may have been replaced with another. +
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.237 -> 1.238 --- Log message: Start eliminating temporary vectors used to create DAG nodes. Instead, pass in the start of an array and a count of operands where applicable. In many cases, the number of operands is known, so this static array can be allocated on the stack, avoiding the heap. In many other cases, a SmallVector can be used, which has the same benefit in the common cases. I updated a lot of code calling getNode that takes a vector, but ran out of time. The rest of the code should be updated, and these methods should be removed. We should also do the same thing to eliminate the methods that take a vector of MVT::ValueTypes. It would be extra nice to convert the dagiselemitter to avoid creating vectors for operands when calling getTargetNode. --- Diffs of the changes: (+3 -2) DAGISelEmitter.cpp |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.237 llvm/utils/TableGen/DAGISelEmitter.cpp:1.238 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.237Mon Aug 7 17:17:58 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Aug 7 21:23:42 2006 @@ -2683,7 +2683,7 @@ } if (HasVarOps) - Code += ", Ops"; + Code += ", &Ops[0], Ops.size()"; else if (NodeHasOptInFlag) Code = "HasInFlag ? " + Code + ", InFlag) : " + Code; @@ -3420,7 +3420,8 @@ << " std::vector VTs;\n" << " VTs.push_back(MVT::Other);\n" << " VTs.push_back(MVT::Flag);\n" - << " SDOperand New = CurDAG->getNode(ISD::INLINEASM, VTs, Ops);\n" + << " SDOperand New = CurDAG->getNode(ISD::INLINEASM, VTs, &Ops[0], " + "Ops.size());\n" << " ReplaceUses(SDOperand(N.Val, 0), New);\n" << " ReplaceUses(SDOperand(N.Val, 1), SDOperand(New.Val, 1));\n" << " Result = New.getValue(N.ResNo);\n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.236 -> 1.237 DAGISelEmitter.h updated: 1.66 -> 1.67 --- Log message: Making TableGen'd instruction selection code non-recursive. This fixes PR805: http://llvm.org/PR805 . --- Diffs of the changes: (+123 -246) DAGISelEmitter.cpp | 366 + DAGISelEmitter.h |3 2 files changed, 123 insertions(+), 246 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.236 llvm/utils/TableGen/DAGISelEmitter.cpp:1.237 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.236Wed Aug 2 19:42:26 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Aug 7 17:17:58 2006 @@ -2134,7 +2134,6 @@ std::vector &TargetVTs; std::string ChainName; - bool DoReplace; unsigned TmpNo; unsigned OpcNo; unsigned VTNo; @@ -2165,11 +2164,10 @@ std::vector > &gc, std::set > &gd, std::vector &to, - std::vector &tv, - bool dorep) + std::vector &tv) : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr), GeneratedCode(gc), GeneratedDecl(gd), TargetOpcodes(to), TargetVTs(tv), -DoReplace(dorep), TmpNo(0), OpcNo(0), VTNo(0) {} +TmpNo(0), OpcNo(0), VTNo(0) {} /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo /// if the match fails. At this point, we already know that the opcode for N @@ -2236,7 +2234,6 @@ bool HasChain = PatternHasProperty(N, SDNodeInfo::SDNPHasChain, ISE); bool HasOutFlag = PatternHasProperty(N, SDNodeInfo::SDNPOutFlag, ISE); bool EmittedUseCheck = false; -bool EmittedSlctedCheck = false; if (HasChain) { if (NodeHasChain) OpNo = 1; @@ -2245,13 +2242,6 @@ // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; -// hasOneUse() check is not strong enough. If the original node has -// already been selected, it may have been replaced with another. -for (unsigned j = 0; j != CInfo.getNumResults(); j++) - emitCheck("!CodeGenMap.count(" + RootName + ".getValue(" + utostr(j) + -"))"); - -EmittedSlctedCheck = true; if (NodeHasChain) { // FIXME: Don't fold if 1) the parent node writes a flag, 2) the node // has a chain use. @@ -2320,12 +2310,6 @@ // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); } - if (!EmittedSlctedCheck) -// hasOneUse() check is not strong enough. If the original node has -// already been selected, it may have been replaced with another. -for (unsigned j = 0; j < CInfo.getNumResults(); j++) - emitCheck("!CodeGenMap.count(" + RootName + ".getValue(" + utostr(j) + -"))"); } for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { @@ -2489,7 +2473,7 @@ for (unsigned i = 0; i < NumRes; ++i) { emitDecl("Tmp" + utostr(i+ResNo)); - emitCode("Select(Tmp" + utostr(i+ResNo) + ", CPTmp" + + emitCode("AddToQueue(Tmp" + utostr(i+ResNo) + ", CPTmp" + utostr(i+ResNo) + ");"); } @@ -2501,12 +2485,12 @@ if (LikeLeaf) emitCode("Tmp" + utostr(ResNo) + " = " + Val + ";"); else { - emitCode("Select(Tmp" + utostr(ResNo) + ", " + Val + ");"); -} - -if (isRoot && N->isLeaf()) { - emitCode("Result = Tmp" + utostr(ResNo) + ";"); - emitCode("return;"); + emitCode("AddToQueue(Tmp" + utostr(ResNo) + ", " + Val + ");"); + if (isRoot && N->isLeaf()) { +emitCode("ReplaceUses(N, Tmp" + utostr(ResNo) + ");"); +emitCode("Result = Tmp" + utostr(ResNo) + ";"); +emitCode("return;"); + } } } // Add Tmp to VariableMap, so that we don't multiply select this @@ -2620,12 +2604,12 @@ // Emit all the chain and CopyToReg stuff. bool ChainEmitted = NodeHasChain; if (NodeHasChain) -emitCode("Select(" + ChainName + ", " + ChainName + ");"); +emitCode("AddToQueue(" + ChainName + ", " + ChainName + ");"); if (NodeHasInFlag || HasImpInputs) EmitInFlagSelectCode(Pattern, "N", ChainEmitted, true); if (NodeHasOptInFlag) { emitCode("if (HasInFlag)"); -emitCode(" Select(InFlag, N.getOperand(N.getNumOperands()-1));"); +emitCode(" AddToQueue(InFlag, N.getOperand(N.getNumOperands()-1));"); } unsigned NumResults = Inst.getNumResults(); @@ -2677,7 +2661,7 @@ emitCode("for (unsigned i = 2, e = N.getNumOperands(); " "i != e; ++i) {"); emitCode(" SDOperand VarOp(0, 0);"); -
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.235 -> 1.236 --- Log message: Remove some extraneous newlines. --- Diffs of the changes: (+2 -2) DAGISelEmitter.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.235 llvm/utils/TableGen/DAGISelEmitter.cpp:1.236 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.235Wed Aug 2 19:26:13 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Aug 2 19:42:26 2006 @@ -3679,8 +3679,8 @@ OS << "#if defined(__GNUC__) && \\\n"; OS << "((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)))\n"; OS << "#define NOINLINE __attribute__((noinline))\n"; - OS << "#else\n\n"; - OS << "#define NOINLINE\n\n"; + OS << "#else\n"; + OS << "#define NOINLINE\n"; OS << "#endif\n\n"; OS << "// Instance var to keep track of multiply used nodes that have \n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.234 -> 1.235 --- Log message: Really add support for compilers without noinline --- Diffs of the changes: (+2 -0) DAGISelEmitter.cpp |2 ++ 1 files changed, 2 insertions(+) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.234 llvm/utils/TableGen/DAGISelEmitter.cpp:1.235 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.234Mon Jul 31 20:07:48 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Aug 2 19:26:13 2006 @@ -3679,6 +3679,8 @@ OS << "#if defined(__GNUC__) && \\\n"; OS << "((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)))\n"; OS << "#define NOINLINE __attribute__((noinline))\n"; + OS << "#else\n\n"; + OS << "#define NOINLINE\n\n"; OS << "#endif\n\n"; OS << "// Instance var to keep track of multiply used nodes that have \n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.233 -> 1.234 --- Log message: Pass N by reference to select functions to prevent gcc from allocating more stack. --- Diffs of the changes: (+3 -3) DAGISelEmitter.cpp |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.233 llvm/utils/TableGen/DAGISelEmitter.cpp:1.234 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.233Mon Jul 31 14:01:58 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Jul 31 20:07:48 2006 @@ -1829,7 +1829,7 @@ // If this node is commutative, consider the commuted order. if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) { assert(N->getNumChildren()==2 &&"Commutative but doesn't have 2 children!"); -// Don't count childrean which are actually +// Don't count children which are actually register references. unsigned NC = 0; for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { TreePatternNode *Child = N->getChild(i); @@ -3321,7 +3321,7 @@ } std::string CalleeDecls; -std::string CalleeCode = "(SDOperand &Result, SDOperand &N"; +std::string CalleeCode = "(SDOperand &Result, const SDOperand &N"; std::string CallerCode = "(Result, N"; for (unsigned j = 0, e = TargetOpcodes.size(); j != e; ++j) { CalleeCode += ", unsigned Opc" + utostr(j); @@ -3399,7 +3399,7 @@ OpVTI->second.push_back(OpVTStr); OS << "void Select_" << OpName << (OpVTStr != "" ? "_" : "") - << OpVTStr << "(SDOperand &Result, SDOperand N) {\n"; + << OpVTStr << "(SDOperand &Result, const SDOperand &N) {\n"; if (OptSlctOrder) { OS << " if (N.ResNo == " << OpcodeInfo.getNumResults() << " && N.getValue(0).hasOneUse()) {\n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.232 -> 1.233 --- Log message: Remove an unneeded match condition: the type check for root node has been moved to outside the actual select routine. --- Diffs of the changes: (+22 -7) DAGISelEmitter.cpp | 29 ++--- 1 files changed, 22 insertions(+), 7 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.232 llvm/utils/TableGen/DAGISelEmitter.cpp:1.233 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.232Fri Jul 28 17:51:01 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Jul 31 14:01:58 2006 @@ -1829,9 +1829,22 @@ // If this node is commutative, consider the commuted order. if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) { assert(N->getNumChildren()==2 &&"Commutative but doesn't have 2 children!"); +// Don't count childrean which are actually +unsigned NC = 0; +for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { + TreePatternNode *Child = N->getChild(i); + if (Child->isLeaf()) +if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { + Record *RR = DI->getDef(); + if (RR->isSubClassOf("Register")) +continue; +} + NC++; +} // Consider the commuted order. -CombineChildVariants(N, ChildVariants[1], ChildVariants[0], - OutVariants, ISE); +if (NC == 2) + CombineChildVariants(N, ChildVariants[1], ChildVariants[0], + OutVariants, ISE); } } @@ -2845,13 +2858,15 @@ /// 'Pat' may be missing types. If we find an unresolved type to add a check /// for, this returns true otherwise false if Pat has all types. bool InsertOneTypeCheck(TreePatternNode *Pat, TreePatternNode *Other, - const std::string &Prefix) { + const std::string &Prefix, bool isRoot = false) { // Did we find one? if (Pat->getExtTypes() != Other->getExtTypes()) { // Move a type over from 'other' to 'pat'. Pat->setTypes(Other->getExtTypes()); - emitCheck(Prefix + ".Val->getValueType(0) == " + -getName(Pat->getTypeNum(0))); + // The top level node type is checked outside of the select function. + if (!isRoot) +emitCheck(Prefix + ".Val->getValueType(0) == " + + getName(Pat->getTypeNum(0))); return true; } @@ -3005,7 +3020,7 @@ // Insert a check for an unresolved type and add it to the tree. If we find // an unresolved type to add a check for, this returns true and we iterate, // otherwise we are done. - } while (Emitter.InsertOneTypeCheck(Pat, Pattern.getSrcPattern(), "N")); + } while (Emitter.InsertOneTypeCheck(Pat, Pattern.getSrcPattern(), "N", true)); Emitter.EmitResultCode(Pattern.getDstPattern(), false, true /*the root*/); delete Pat; @@ -3282,7 +3297,7 @@ // patterns after it CANNOT ever match. Error out. if (mightNotMatch == false && i != CodeForPatterns.size()-1) { std::cerr << "Pattern '"; - CodeForPatterns[i+1].first->getSrcPattern()->print(OS); + CodeForPatterns[i+1].first->getSrcPattern()->print(std::cerr); std::cerr << "' is impossible to select!\n"; exit(1); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.231 -> 1.232 --- Log message: Split each select function for a particular opcode into multiple ones. One per possible ValueType of the node. e.g. Select_add is split into Select_add_i8, Select_add_i16, etc. For opcodes which do not produce a non-chain result, it is split on the ValueType of its first non-chain operand. e.g. Select_store. On X86 / Mac OS X, Select_store used to be the largest function. It had a stack frame size of 8.5k. Now the largest one is Store_i32 with a frame size of 3.1k. --- Diffs of the changes: (+259 -178) DAGISelEmitter.cpp | 437 +++-- 1 files changed, 259 insertions(+), 178 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.231 llvm/utils/TableGen/DAGISelEmitter.cpp:1.232 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.231Thu Jul 27 20:19:22 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Jul 28 17:51:01 2006 @@ -3190,7 +3190,12 @@ } } } - + + // For each opcode, there might be multiple select functions, one per + // ValueType of the node (or its first operand if it doesn't produce a + // non-chain result. + std::map > OpcodeVTMap; + // Emit one Select_* method for each top-level opcode. We do this instead of // emitting one giant switch statement to support compilers where this will // result in the recursive functions taking less stack space. @@ -3202,204 +3207,241 @@ bool OptSlctOrder = (OpcodeInfo.hasProperty(SDNodeInfo::SDNPHasChain) && OpcodeInfo.getNumResults() > 0); -std::vector &Patterns = PBOI->second; -assert(!Patterns.empty() && "No patterns but map has entry?"); - +std::vector &PatternsOfOp = PBOI->second; +assert(!PatternsOfOp.empty() && "No patterns but map has entry?"); + // We want to emit all of the matching code now. However, we want to emit // the matches in order of minimal cost. Sort the patterns so the least // cost one is at the start. -std::stable_sort(Patterns.begin(), Patterns.end(), +std::stable_sort(PatternsOfOp.begin(), PatternsOfOp.end(), PatternSortingPredicate(*this)); -typedef std::vector > CodeList; -typedef std::vector >::iterator CodeListI; - -std::vector > CodeForPatterns; -std::vector > PatternOpcodes; -std::vector > PatternVTs; -std::vector > > PatternDecls; -std::set > AllGenDecls; -for (unsigned i = 0, e = Patterns.size(); i != e; ++i) { - CodeList GeneratedCode; - std::set > GeneratedDecl; - std::vector TargetOpcodes; - std::vector TargetVTs; - GenerateCodeForPattern(*Patterns[i], GeneratedCode, GeneratedDecl, - TargetOpcodes, TargetVTs, OptSlctOrder); - for (std::set >::iterator - si = GeneratedDecl.begin(), se = GeneratedDecl.end(); si!=se; ++si) -AllGenDecls.insert(*si); - CodeForPatterns.push_back(std::make_pair(Patterns[i], GeneratedCode)); - PatternDecls.push_back(GeneratedDecl); - PatternOpcodes.push_back(TargetOpcodes); - PatternVTs.push_back(TargetVTs); +// Split them into groups by type. +std::map > PatternsByType; +for (unsigned i = 0, e = PatternsOfOp.size(); i != e; ++i) { + PatternToMatch *Pat = PatternsOfOp[i]; + TreePatternNode *SrcPat = Pat->getSrcPattern(); + if (OpcodeInfo.getNumResults() == 0 && SrcPat->getNumChildren() > 0) +SrcPat = SrcPat->getChild(0); + MVT::ValueType VT = SrcPat->getTypeNum(0); + std::map >::iterator TI = +PatternsByType.find(VT); + if (TI != PatternsByType.end()) +TI->second.push_back(Pat); + else { +std::vector PVec; +PVec.push_back(Pat); +PatternsByType.insert(std::make_pair(VT, PVec)); + } } + +for (std::map >::iterator + II = PatternsByType.begin(), EE = PatternsByType.end(); II != EE; + ++II) { + MVT::ValueType OpVT = II->first; + std::vector &Patterns = II->second; + typedef std::vector > CodeList; + typedef std::vector >::iterator CodeListI; -// Scan the code to see if all of the patterns are reachable and if it is -// possible that the last one might not match. -bool mightNotMatch = true; -for (unsigned i = 0, e = CodeForPatterns.size(); i != e; ++i) { - CodeList &GeneratedCode = CodeForPatterns[i].second; - mightNotMatch = false; - - for (unsigned j = 0, e = GeneratedCode.size(); j != e; ++j) { -if (GeneratedCode[j].first) { // predicate. - mightNotMatch = true; - break; -} + std::vector > CodeForPatterns; + std::vector > PatternOpcodes; + std::vector > PatternVTs; + std::vector > > PatternDecls; + std::set > AllGenDecls; + for (unsigned i = 0, e = Patterns.size(); i != e; ++i) { +
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.230 -> 1.231 --- Log message: Clean up. --- Diffs of the changes: (+2 -3) DAGISelEmitter.cpp |5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.230 llvm/utils/TableGen/DAGISelEmitter.cpp:1.231 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.230Thu Jul 27 20:03:48 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Jul 27 20:19:22 2006 @@ -2469,11 +2469,10 @@ for (unsigned i = 0; i < NumRes; ++i) emitDecl("CPTmp" + utostr(i+ResNo)); -std::string Code = "bool Match = " + Fn + "(" + Val; +std::string Code = Fn + "(" + Val; for (unsigned i = 0; i < NumRes; i++) Code += ", CPTmp" + utostr(i + ResNo); -emitCode(Code + ");"); -emitCheck("Match"); +emitCheck(Code + ")"); for (unsigned i = 0; i < NumRes; ++i) { emitDecl("Tmp" + utostr(i+ResNo)); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.229 -> 1.230 --- Log message: Rename IsFoldableBy to CanBeFoldedleBy --- Diffs of the changes: (+1 -1) DAGISelEmitter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.229 llvm/utils/TableGen/DAGISelEmitter.cpp:1.230 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.229Thu Jul 27 19:43:52 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Jul 27 20:03:48 2006 @@ -2276,7 +2276,7 @@ PInfo.hasProperty(SDNodeInfo::SDNPHasChain) || PInfo.hasProperty(SDNodeInfo::SDNPInFlag) || PInfo.hasProperty(SDNodeInfo::SDNPOptInFlag)) -emitCheck("IsFoldableBy(" + RootName + ".Val, " + ParentName + +emitCheck("CanBeFoldedBy(" + RootName + ".Val, " + ParentName + ".Val)"); } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.228 -> 1.229 --- Log message: Remove InFlightSet hack. No longer needed. --- Diffs of the changes: (+0 -46) DAGISelEmitter.cpp | 46 -- 1 files changed, 46 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.228 llvm/utils/TableGen/DAGISelEmitter.cpp:1.229 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.228Thu Jul 27 14:59:34 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Jul 27 19:43:52 2006 @@ -2106,8 +2106,6 @@ // Names of all the folded nodes which produce chains. std::vector > FoldedChains; std::set Duplicates; - /// These nodes are being marked "in-flight" so they cannot be folded. - std::vector InflightNodes; /// GeneratedCode - This is the buffer that we emit code to. The first bool /// indicates whether this is an exit predicate (something that should be @@ -2231,8 +2229,6 @@ OpNo = 1; if (!isRoot) { const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); -// Not in flight? -emitCheck("InFlightSet.count(" + RootName + ".Val) == 0"); // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; @@ -2477,24 +2473,9 @@ for (unsigned i = 0; i < NumRes; i++) Code += ", CPTmp" + utostr(i + ResNo); emitCode(Code + ");"); -if (InflightNodes.size()) { - // Remove the in-flight nodes if the ComplexPattern does not match! - emitCode("if (!Match) {"); - for (std::vector::iterator AI = InflightNodes.begin(), - AE = InflightNodes.end(); AI != AE; ++AI) -emitCode(" SelectionDAG::RemoveInFlightSetEntry(InFlightSet, " + - *AI + ".Val);"); - emitCode("}"); -} - emitCheck("Match"); for (unsigned i = 0; i < NumRes; ++i) { - emitCode("SelectionDAG::InsertInFlightSetEntry(InFlightSet, CPTmp" + - utostr(i+ResNo) + ".Val);"); - InflightNodes.push_back("CPTmp" + utostr(i+ResNo)); -} -for (unsigned i = 0; i < NumRes; ++i) { emitDecl("Tmp" + utostr(i+ResNo)); emitCode("Select(Tmp" + utostr(i+ResNo) + ", CPTmp" + utostr(i+ResNo) + ");"); @@ -2608,22 +2589,6 @@ } } - // Make sure these operands which would be selected won't be folded while - // the isel traverses the DAG upward. - for (unsigned i = 0, e = EmitOrder.size(); i != e; ++i) { -TreePatternNode *Child = EmitOrder[i].second; -if (!Child->getName().empty()) { - std::string &Val = VariableMap[Child->getName()]; - assert(!Val.empty() && - "Variable referenced but not defined and not caught earlier!"); - if (Child->isLeaf() && !NodeGetComplexPattern(Child, ISE)) { -emitCode("SelectionDAG::InsertInFlightSetEntry(InFlightSet, " + - Val + ".Val);"); -InflightNodes.push_back(Val); - } -} - } - // Emit all of the operands. std::vector > NumTemps(EmitOrder.size()); for (unsigned i = 0, e = EmitOrder.size(); i != e; ++i) { @@ -2651,14 +2616,6 @@ emitCode(" Select(InFlag, N.getOperand(N.getNumOperands()-1));"); } - if (isRoot) { -// The operands have been selected. Remove them from InFlightSet. -for (std::vector::iterator AI = InflightNodes.begin(), - AE = InflightNodes.end(); AI != AE; ++AI) - emitCode("SelectionDAG::RemoveInFlightSetEntry(InFlightSet, " + - *AI + ".Val);"); - } - unsigned NumResults = Inst.getNumResults(); unsigned ResNo = TmpNo++; if (!isRoot || InputHasChain || NodeHasChain || NodeHasOutFlag || @@ -3639,9 +3596,6 @@ OS << "// Instance var to keep track of mapping of place handle nodes\n" << "// and their replacement nodes.\n"; OS << "std::map ReplaceMap;\n"; - OS << "// Keep track of nodes that are currently being selecte and therefore\n" - << "// should not be folded.\n"; - OS << "std::set InFlightSet;\n"; OS << "\n"; OS << "// AddHandleReplacement - Note the pending replacement node for a\n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.227 -> 1.228 --- Log message: Remove dead code. --- Diffs of the changes: (+0 -29) DAGISelEmitter.cpp | 29 - 1 files changed, 29 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.227 llvm/utils/TableGen/DAGISelEmitter.cpp:1.228 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.227Thu Jul 27 01:36:11 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Jul 27 14:59:34 2006 @@ -3644,35 +3644,6 @@ OS << "std::set InFlightSet;\n"; OS << "\n"; - OS << "static void findNonImmUse(SDNode* Use, SDNode* Def, bool &found, " - << "std::set &Visited) {\n"; - OS << " if (found || !Visited.insert(Use).second) return;\n"; - OS << " for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {\n"; - OS << "SDNode *N = Use->getOperand(i).Val;\n"; - OS << "if (N != Def) {\n"; - OS << " findNonImmUse(N, Def, found, Visited);\n"; - OS << "} else {\n"; - OS << " found = true;\n"; - OS << " break;\n"; - OS << "}\n"; - OS << " }\n"; - OS << "}\n"; - - OS << "\n"; - OS << "static bool isNonImmUse(SDNode* Use, SDNode* Def) {\n"; - OS << " std::set Visited;\n"; - OS << " bool found = false;\n"; - OS << " for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {\n"; - OS << "SDNode *N = Use->getOperand(i).Val;\n"; - OS << "if (N != Def) {\n"; - OS << " findNonImmUse(N, Def, found, Visited);\n"; - OS << " if (found) break;\n"; - OS << "}\n"; - OS << " }\n"; - OS << " return found;\n"; - OS << "}\n"; - - OS << "\n"; OS << "// AddHandleReplacement - Note the pending replacement node for a\n" << "// handle node in ReplaceMap.\n"; OS << "void AddHandleReplacement(SDNode *H, unsigned HNum, SDNode *R, " ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.226 -> 1.227 --- Log message: Let each target specific isel provide routine to check if a chain producing node is foldable by another. --- Diffs of the changes: (+2 -8) DAGISelEmitter.cpp | 10 ++ 1 files changed, 2 insertions(+), 8 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.226 llvm/utils/TableGen/DAGISelEmitter.cpp:1.227 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.226Wed Jul 26 18:06:27 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Jul 27 01:36:11 2006 @@ -2280,14 +2280,8 @@ PInfo.hasProperty(SDNodeInfo::SDNPHasChain) || PInfo.hasProperty(SDNodeInfo::SDNPInFlag) || PInfo.hasProperty(SDNodeInfo::SDNPOptInFlag)) -if (PInfo.getNumOperands() > 1) { - emitCheck("!isNonImmUse(" + ParentName + ".Val, " + RootName + -".Val)"); -} else { - emitCheck("(" + ParentName + ".getNumOperands() == 1 || !" + -"isNonImmUse(" + ParentName + ".Val, " + RootName + -".Val))"); -} +emitCheck("IsFoldableBy(" + RootName + ".Val, " + ParentName + + ".Val)"); } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.225 -> 1.226 --- Log message: Fix for bug 840: http://llvm.org/PR840 . Only use noinline attribute if gcc version >= 3.4 --- Diffs of the changes: (+6 -3) DAGISelEmitter.cpp |9 ++--- 1 files changed, 6 insertions(+), 3 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.225 llvm/utils/TableGen/DAGISelEmitter.cpp:1.226 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.225Fri Jul 21 17:19:51 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Jul 26 18:06:27 2006 @@ -3363,11 +3363,9 @@ } CallerCode += ");"; CalleeCode += ") "; -#ifdef __GNUC__ // Prevent emission routines from being inlined to reduce selection // routines stack frame sizes. - CalleeCode += "__attribute__((noinline)) "; -#endif + CalleeCode += "NOINLINE "; CalleeCode += "{\n" + CalleeDecls; for (int j = LastPred+1; j < CodeSize; ++j) CalleeCode += " " + GeneratedCode[j].second + '\n'; @@ -3632,6 +3630,11 @@ << "// *** instruction selector class. These functions are really " << "methods.\n\n"; + OS << "#if defined(__GNUC__) && \\\n"; + OS << "((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)))\n"; + OS << "#define NOINLINE __attribute__((noinline))\n"; + OS << "#endif\n\n"; + OS << "// Instance var to keep track of multiply used nodes that have \n" << "// already been selected.\n" << "std::map CodeGenMap;\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.224 -> 1.225 --- Log message: Removed a hack intended to allow (store (op (load))) folding. Will handle this with preprocessing. --- Diffs of the changes: (+7 -52) DAGISelEmitter.cpp | 59 ++--- 1 files changed, 7 insertions(+), 52 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.224 llvm/utils/TableGen/DAGISelEmitter.cpp:1.225 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.224Thu Jul 20 18:36:20 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Jul 21 17:19:51 2006 @@ -2123,7 +2123,6 @@ std::vector &TargetVTs; std::string ChainName; - bool NewTF; bool DoReplace; unsigned TmpNo; unsigned OpcNo; @@ -2159,7 +2158,7 @@ bool dorep) : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr), GeneratedCode(gc), GeneratedDecl(gd), TargetOpcodes(to), TargetVTs(tv), -NewTF(false), DoReplace(dorep), TmpNo(0), OpcNo(0), VTNo(0) {} +DoReplace(dorep), TmpNo(0), OpcNo(0), VTNo(0) {} /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo /// if the match fails. At this point, we already know that the opcode for N @@ -2293,19 +2292,14 @@ } if (NodeHasChain) { +if (FoundChain) + emitCheck("Chain.Val == " + RootName + ".Val"); +else + FoundChain = true; ChainName = "Chain" + ChainSuffix; emitDecl(ChainName); -if (FoundChain) { - // FIXME: temporary workaround for a common case where chain - // is a TokenFactor and the previous "inner" chain is an operand. - NewTF = true; - emitDecl("OldTF", 1); - emitCheck("(" + ChainName + " = UpdateFoldedChain(CurDAG, " + -RootName + ".Val, Chain.Val, OldTF)).Val"); -} else { - FoundChain = true; - emitCode(ChainName + " = " + RootName + ".getOperand(0);"); -} +emitCode(ChainName + " = " + RootName + + ".getOperand(0);"); } } @@ -2762,11 +2756,6 @@ if (!isRoot) return std::make_pair(1, ResNo); -if (NewTF) - emitCode("if (OldTF) " - "SelectionDAG::InsertISelMapEntry(CodeGenMap, OldTF, 0, " + - ChainName + ".Val, 0);"); - for (unsigned i = 0; i < NumResults; i++) emitCode("SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, " + utostr(i) + ", ResNode, " + utostr(i) + ");"); @@ -3740,40 +3729,6 @@ OS << "}\n"; OS << "\n"; - OS << "// UpdateFoldedChain - return a SDOperand of the new chain created\n"; - OS << "// if the folding were to happen. This is called when, for example,\n"; - OS << "// a load is folded into a store. If the store's chain is the load,\n"; - OS << "// then the resulting node's input chain would be the load's input\n"; - OS << "// chain. If the store's chain is a TokenFactor and the load's\n"; - OS << "// output chain feeds into in, then the new chain is a TokenFactor\n"; - OS << "// with the other operands along with the input chain of the load.\n"; - OS << "SDOperand UpdateFoldedChain(SelectionDAG *DAG, SDNode *N, " - << "SDNode *Chain, SDNode* &OldTF) {\n"; - OS << " OldTF = NULL;\n"; - OS << " if (N == Chain) {\n"; - OS << "return N->getOperand(0);\n"; - OS << " } else if (Chain->getOpcode() == ISD::TokenFactor &&\n"; - OS << " N->isOperand(Chain)) {\n"; - OS << "SDOperand Ch = SDOperand(Chain, 0);\n"; - OS << "std::map::iterator CGMI = " - << "CodeGenMap.find(Ch);\n"; - OS << "if (CGMI != CodeGenMap.end())\n"; - OS << " return SDOperand(0, 0);\n"; - OS << "OldTF = Chain;\n"; - OS << "std::vector Ops;\n"; - OS << "for (unsigned i = 0; i < Chain->getNumOperands(); ++i) {\n"; - OS << " SDOperand Op = Chain->getOperand(i);\n"; - OS << " if (Op.Val == N)\n"; - OS << "Ops.push_back(N->getOperand(0));\n"; - OS << " else\n"; - OS << "Ops.push_back(Op);\n"; - OS << "}\n"; - OS << "return DAG->getNode(ISD::TokenFactor, MVT::Other, Ops);\n"; - OS << " }\n"; - OS << " return SDOperand(0, 0);\n"; - OS << "}\n"; - - OS << "\n"; OS << "// SelectRoot - Top level entry to DAG isel.\n"; OS << "SDOperand SelectRoot(SDOperand N) {\n"; OS << " SDOperand ResNode;\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.223 -> 1.224 --- Log message: Also checks for noResults field. --- Diffs of the changes: (+4 -1) DAGISelEmitter.cpp |5 - 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.223 llvm/utils/TableGen/DAGISelEmitter.cpp:1.224 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.223Tue Jul 18 19:24:41 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Jul 20 18:36:20 2006 @@ -742,8 +742,11 @@ assert(NumResults <= 1 && "Only supports zero or one result instrs!"); + +CodeGenInstruction &InstInfo = + ISE.getTargetInfo().getInstruction(getOperator()->getName()); // Apply the result type to the node -if (NumResults == 0) { +if (NumResults == 0 || InstInfo.noResults) { // FIXME: temporary hack... MadeChange = UpdateNodeType(MVT::isVoid, TP); } else { Record *ResultNode = Inst.getResult(0); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.222 -> 1.223 --- Log message: Add code size to target instruction use it as the 3rd isel sorting tie-breaker. --- Diffs of the changes: (+25 -3) DAGISelEmitter.cpp | 28 +--- 1 files changed, 25 insertions(+), 3 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.222 llvm/utils/TableGen/DAGISelEmitter.cpp:1.223 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.222Sun Jul 16 01:14:37 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Jul 18 19:24:41 2006 @@ -1986,6 +1986,21 @@ return Cost; } +/// getResultPatternCodeSize - Compute the code size of instructions for this +/// pattern. +static unsigned getResultPatternSize(TreePatternNode *P, DAGISelEmitter &ISE) { + if (P->isLeaf()) return 0; + + unsigned Cost = 0; + Record *Op = P->getOperator(); + if (Op->isSubClassOf("Instruction")) { +Cost += Op->getValueAsInt("CodeSize"); + } + for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i) +Cost += getResultPatternSize(P->getChild(i), ISE); + return Cost; +} + // PatternSortingPredicate - return true if we prefer to match LHS before RHS. // In particular, we want to match maximal patterns first and lowest cost within // a particular complexity first. @@ -2003,8 +2018,13 @@ if (LHSSize < RHSSize) return false; // If the patterns have equal complexity, compare generated instruction cost -return getResultPatternCost(LHS->getDstPattern(), ISE) < - getResultPatternCost(RHS->getDstPattern(), ISE); +unsigned LHSCost = getResultPatternCost(LHS->getDstPattern(), ISE); +unsigned RHSCost = getResultPatternCost(RHS->getDstPattern(), ISE); +if (LHSCost < RHSCost) return true; +if (LHSCost > RHSCost) return false; + +return getResultPatternSize(LHS->getDstPattern(), ISE) < + getResultPatternSize(RHS->getDstPattern(), ISE); } }; @@ -3105,7 +3125,9 @@ OS << std::string(Indent, ' ') << "// Pattern complexity = " << getPatternSize(Pattern.getSrcPattern(), *this) + AddedComplexity << " cost = " - << getResultPatternCost(Pattern.getDstPattern(), *this) << "\n"; + << getResultPatternCost(Pattern.getDstPattern(), *this) + << " size = " + << getResultPatternSize(Pattern.getDstPattern(), *this) << "\n"; } if (!FirstCodeLine.first) { OS << std::string(Indent, ' ') << "{\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.221 -> 1.222 --- Log message: Use __attribute__((noinline)) only if compiled by gcc. --- Diffs of the changes: (+1 -1) DAGISelEmitter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.221 llvm/utils/TableGen/DAGISelEmitter.cpp:1.222 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.221Sun Jul 16 01:12:52 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sun Jul 16 01:14:37 2006 @@ -3349,7 +3349,7 @@ } CallerCode += ");"; CalleeCode += ") "; -#ifndef _MSC_VER +#ifdef __GNUC__ // Prevent emission routines from being inlined to reduce selection // routines stack frame sizes. CalleeCode += "__attribute__((noinline)) "; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.220 -> 1.221 DAGISelEmitter.h updated: 1.65 -> 1.66 --- Log message: Parameterize target node ValueType to allow more sharing of emit functions. Also reduce the number of arguments passed to emit functions and removed a hack. --- Diffs of the changes: (+67 -32) DAGISelEmitter.cpp | 96 +++-- DAGISelEmitter.h |3 + 2 files changed, 67 insertions(+), 32 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.220 llvm/utils/TableGen/DAGISelEmitter.cpp:1.221 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.220Sat Jul 15 03:45:20 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sun Jul 16 01:12:52 2006 @@ -2093,16 +2093,18 @@ std::vector > &GeneratedCode; /// GeneratedDecl - This is the set of all SDOperand declarations needed for /// the set of patterns for each top-level opcode. - std::set > &GeneratedDecl; + std::set > &GeneratedDecl; /// TargetOpcodes - The target specific opcodes used by the resulting /// instructions. std::vector &TargetOpcodes; + std::vector &TargetVTs; std::string ChainName; bool NewTF; bool DoReplace; unsigned TmpNo; unsigned OpcNo; + unsigned VTNo; void emitCheck(const std::string &S) { if (!S.empty()) @@ -2112,24 +2114,29 @@ if (!S.empty()) GeneratedCode.push_back(std::make_pair(false, S)); } - void emitDecl(const std::string &S, bool isSDNode=false) { + void emitDecl(const std::string &S, unsigned T=0) { assert(!S.empty() && "Invalid declaration"); -GeneratedDecl.insert(std::make_pair(isSDNode, S)); +GeneratedDecl.insert(std::make_pair(T, S)); } void emitOpcode(const std::string &Opc) { TargetOpcodes.push_back(Opc); OpcNo++; } + void emitVT(const std::string &VT) { +TargetVTs.push_back(VT); +VTNo++; + } public: PatternCodeEmitter(DAGISelEmitter &ise, ListInit *preds, TreePatternNode *pattern, TreePatternNode *instr, std::vector > &gc, - std::set > &gd, + std::set > &gd, std::vector &to, + std::vector &tv, bool dorep) : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr), -GeneratedCode(gc), GeneratedDecl(gd), TargetOpcodes(to), -NewTF(false), DoReplace(dorep), TmpNo(0), OpcNo(0) {} +GeneratedCode(gc), GeneratedDecl(gd), TargetOpcodes(to), TargetVTs(tv), +NewTF(false), DoReplace(dorep), TmpNo(0), OpcNo(0), VTNo(0) {} /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo /// if the match fails. At this point, we already know that the opcode for N @@ -2269,7 +2276,7 @@ // FIXME: temporary workaround for a common case where chain // is a TokenFactor and the previous "inner" chain is an operand. NewTF = true; - emitDecl("OldTF", true); + emitDecl("OldTF", 1); emitCheck("(" + ChainName + " = UpdateFoldedChain(CurDAG, " + RootName + ".Val, Chain.Val, OldTF)).Val"); } else { @@ -2560,11 +2567,9 @@ if (NodeHasInFlag || NodeHasOutFlag || NodeHasOptInFlag || HasImpInputs) emitDecl("InFlag"); if (NodeHasOptInFlag) { -// FIXME: This is ugly. We are using a SDNode* in place of a bool. -emitDecl("HasInFlag", true); +emitDecl("HasInFlag", 2); emitCode("HasInFlag = " - "(N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag) " - "? (SDNode*)1 : (SDNode*)0;"); + "(N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag);"); } if (HasVarOps) emitCode("std::vector Ops;"); @@ -2664,8 +2669,10 @@ // Output order: results, chain, flags // Result types. -if (NumResults > 0 && N->getTypeNum(0) != MVT::isVoid) - Code += ", " + getEnumName(N->getTypeNum(0)); +if (NumResults > 0 && N->getTypeNum(0) != MVT::isVoid) { + Code += ", VT" + utostr(VTNo); + emitVT(getEnumName(N->getTypeNum(0))); +} if (NodeHasChain) Code += ", MVT::Other"; if (NodeHasOutFlag) @@ -2815,7 +2822,7 @@ std::string Code = " Result = CurDAG->SelectNodeTo(N.Val, Opc" + utostr(OpcNo); if (N->getTypeNum(0) != MVT::isVoid) - Code += ", " + getEnumName(N->getTypeNum(0)); + Code += ", VT" + utostr(VTNo); if (NodeHasOutFlag) Code += ", MVT::Flag"; for (unsigned i = 0, e = Ops.size(); i != e; ++i) @@ -2824,11 +2831,13 @@ Code += ", InFlag"; emitCode(Code + ");"); emitCode("} else {"); -emitDecl("ResNode", true); +emitDecl("ResNode", 1); Code = " ResNode = CurDAG->getTargetNode(Opc"
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.219 -> 1.220 DAGISelEmitter.h updated: 1.64 -> 1.65 --- Log message: Reduce instruction selection code size and stack frame size by factoring code that emit target specific nodes into emit functions that are uniquified and shared among selection routines. e.g. This reduces X86ISelDAGToDAG.o (release) from ~2M to ~1.5M. Stack frame size of Select_store from ~13k down to ~8k. This is the first step. Further work to enable more sharing will follow. --- Diffs of the changes: (+135 -43) DAGISelEmitter.cpp | 175 - DAGISelEmitter.h |3 2 files changed, 135 insertions(+), 43 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.219 llvm/utils/TableGen/DAGISelEmitter.cpp:1.220 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.219Tue Jul 11 13:25:13 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sat Jul 15 03:45:20 2006 @@ -2094,11 +2094,15 @@ /// GeneratedDecl - This is the set of all SDOperand declarations needed for /// the set of patterns for each top-level opcode. std::set > &GeneratedDecl; + /// TargetOpcodes - The target specific opcodes used by the resulting + /// instructions. + std::vector &TargetOpcodes; std::string ChainName; bool NewTF; bool DoReplace; unsigned TmpNo; + unsigned OpcNo; void emitCheck(const std::string &S) { if (!S.empty()) @@ -2112,15 +2116,20 @@ assert(!S.empty() && "Invalid declaration"); GeneratedDecl.insert(std::make_pair(isSDNode, S)); } + void emitOpcode(const std::string &Opc) { +TargetOpcodes.push_back(Opc); +OpcNo++; + } public: PatternCodeEmitter(DAGISelEmitter &ise, ListInit *preds, TreePatternNode *pattern, TreePatternNode *instr, std::vector > &gc, std::set > &gd, + std::vector &to, bool dorep) : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr), -GeneratedCode(gc), GeneratedDecl(gd), -NewTF(false), DoReplace(dorep), TmpNo(0) {} +GeneratedCode(gc), GeneratedDecl(gd), TargetOpcodes(to), +NewTF(false), DoReplace(dorep), TmpNo(0), OpcNo(0) {} /// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo /// if the match fails. At this point, we already know that the opcode for N @@ -2403,12 +2412,11 @@ case MVT::i32: CastType = "unsigned"; break; case MVT::i64: CastType = "uint64_t"; break; } -emitCode(CastType + " Tmp" + utostr(ResNo) + "C = (" + CastType + - ")cast(" + Val + ")->getValue();"); emitDecl("Tmp" + utostr(ResNo)); emitCode("Tmp" + utostr(ResNo) + - " = CurDAG->getTargetConstant(Tmp" + utostr(ResNo) + - "C, " + getEnumName(N->getTypeNum(0)) + ");"); + " = CurDAG->getTargetConstant(((" + CastType + + ") cast(" + Val + ")->getValue()), " + + getEnumName(N->getTypeNum(0)) + ");"); } else if (!N->isLeaf() && N->getOperator()->getName() == "texternalsym"){ Record *Op = OperatorMap[N->getName()]; // Transform ExternalSymbol to TargetExternalSymbol @@ -2551,9 +2559,13 @@ if (NodeHasInFlag || NodeHasOutFlag || NodeHasOptInFlag || HasImpInputs) emitDecl("InFlag"); - if (NodeHasOptInFlag) -emitCode("bool HasInFlag = " - "N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag;"); + if (NodeHasOptInFlag) { +// FIXME: This is ugly. We are using a SDNode* in place of a bool. +emitDecl("HasInFlag", true); +emitCode("HasInFlag = " + "(N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag) " + "? (SDNode*)1 : (SDNode*)0;"); + } if (HasVarOps) emitCode("std::vector Ops;"); @@ -2647,8 +2659,8 @@ emitDecl(NodeName, true); Code2 = NodeName + " = "; } -Code = "CurDAG->getTargetNode(" + - II.Namespace + "::" + II.TheDef->getName(); +Code = "CurDAG->getTargetNode(Opc" + utostr(OpcNo); +emitOpcode(II.Namespace + "::" + II.TheDef->getName()); // Output order: results, chain, flags // Result types. @@ -2672,8 +2684,8 @@ emitCode("for (unsigned i = 2, e = N.getNumOperands()-1; " "i != e; ++i) {"); else if (NodeHasOptInFlag) -emitCode("for (unsigned i = 2, e = N.getNumOperands()-HasInFlag; " - "i != e; ++i) {"); +emitCode("for (unsigned i = 2, e = N.getNumOperands()-" + "(HasInFlag?1:0); i != e; ++i) {"); else emitCode("for (unsigned i = 2, e = N.getNumOperands(); " "i != e; ++i) {"); @@ -2800,8 +2812,8 @@
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.218 -> 1.219 --- Log message: It was pointed out that DEBUG() is only available with -debug. --- Diffs of the changes: (+12 -4) DAGISelEmitter.cpp | 16 1 files changed, 12 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.218 llvm/utils/TableGen/DAGISelEmitter.cpp:1.219 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.218Tue Jul 11 12:58:07 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Jul 11 13:25:13 2006 @@ -2136,7 +2136,9 @@ if (DefInit *Pred = dynamic_cast(Predicates->getElement(i))) { Record *Def = Pred->getDef(); if (!Def->isSubClassOf("Predicate")) { -DEBUG(Def->dump()); +#ifndef NDEBUG +Def->dump(); +#endif assert(0 && "Unknown predicate type!"); } if (!PredicateCheck.empty()) @@ -2344,8 +2346,10 @@ emitCheck("cast(" + RootName + utostr(OpNo) + ")->get() == ISD::" + LeafRec->getName()); } else { -DEBUG(Child->dump()); +#ifndef NDEBUG +Child->dump(); std::cerr << " "; +#endif assert(0 && "Unknown leaf type!"); } } else if (IntInit *II = @@ -2357,7 +2361,9 @@ emitCheck("CN" + utostr(CTmp) + " == " +itostr(II->getValue())); } else { - DEBUG(Child->dump()); +#ifndef NDEBUG + Child->dump(); +#endif assert(0 && "Unknown leaf type!"); } } @@ -2510,7 +2516,9 @@ return std::make_pair(1, ResNo); } - DEBUG(N->dump()); +#ifndef NDEBUG + N->dump(); +#endif assert(0 && "Unknown leaf type!"); return std::make_pair(1, ~0U); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.217 -> 1.218 --- Log message: Ensure that dump calls that are associated with asserts are removed from non-debug build. --- Diffs of the changes: (+4 -4) DAGISelEmitter.cpp |8 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.217 llvm/utils/TableGen/DAGISelEmitter.cpp:1.218 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.217Thu Jun 29 18:57:05 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Jul 11 12:58:07 2006 @@ -2136,7 +2136,7 @@ if (DefInit *Pred = dynamic_cast(Predicates->getElement(i))) { Record *Def = Pred->getDef(); if (!Def->isSubClassOf("Predicate")) { -Def->dump(); +DEBUG(Def->dump()); assert(0 && "Unknown predicate type!"); } if (!PredicateCheck.empty()) @@ -2344,7 +2344,7 @@ emitCheck("cast(" + RootName + utostr(OpNo) + ")->get() == ISD::" + LeafRec->getName()); } else { -Child->dump(); +DEBUG(Child->dump()); std::cerr << " "; assert(0 && "Unknown leaf type!"); } @@ -2357,7 +2357,7 @@ emitCheck("CN" + utostr(CTmp) + " == " +itostr(II->getValue())); } else { - Child->dump(); + DEBUG(Child->dump()); assert(0 && "Unknown leaf type!"); } } @@ -2510,7 +2510,7 @@ return std::make_pair(1, ResNo); } - N->dump(); + DEBUG(N->dump()); assert(0 && "Unknown leaf type!"); return std::make_pair(1, ~0U); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.216 -> 1.217 --- Log message: Ugly hack! Add helper functions InsertInFlightSetEntry and RemoveInFlightSetEntry. They are used in place of direct set operators to reduce instruction selection function stack size. --- Diffs of the changes: (+8 -4) DAGISelEmitter.cpp | 12 1 files changed, 8 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.216 llvm/utils/TableGen/DAGISelEmitter.cpp:1.217 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.216Mon Jun 19 19:56:37 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Jun 29 18:57:05 2006 @@ -2450,14 +2450,16 @@ emitCode("if (!Match) {"); for (std::vector::iterator AI = InflightNodes.begin(), AE = InflightNodes.end(); AI != AE; ++AI) -emitCode(" InFlightSet.erase(" + *AI + ".Val);"); +emitCode(" SelectionDAG::RemoveInFlightSetEntry(InFlightSet, " + + *AI + ".Val);"); emitCode("}"); } emitCheck("Match"); for (unsigned i = 0; i < NumRes; ++i) { - emitCode("InFlightSet.insert(CPTmp" + utostr(i+ResNo) + ".Val);"); + emitCode("SelectionDAG::InsertInFlightSetEntry(InFlightSet, CPTmp" + + utostr(i+ResNo) + ".Val);"); InflightNodes.push_back("CPTmp" + utostr(i+ResNo)); } for (unsigned i = 0; i < NumRes; ++i) { @@ -2579,7 +2581,8 @@ assert(!Val.empty() && "Variable referenced but not defined and not caught earlier!"); if (Child->isLeaf() && !NodeGetComplexPattern(Child, ISE)) { -emitCode("InFlightSet.insert(" + Val + ".Val);"); +emitCode("SelectionDAG::InsertInFlightSetEntry(InFlightSet, " + + Val + ".Val);"); InflightNodes.push_back(Val); } } @@ -2616,7 +2619,8 @@ // The operands have been selected. Remove them from InFlightSet. for (std::vector::iterator AI = InflightNodes.begin(), AE = InflightNodes.end(); AI != AE; ++AI) - emitCode("InFlightSet.erase(" + *AI + ".Val);"); + emitCode("SelectionDAG::RemoveInFlightSetEntry(InFlightSet, " + + *AI + ".Val);"); } unsigned NumResults = Inst.getNumResults(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.215 -> 1.216 --- Log message: Fix an error message regression. Print: LI8:(LI8:i64 (imm:i64):$imm) instead of: LI8:(LI8:MVT::i64 (imm:MVT::i64):$imm) --- Diffs of the changes: (+8 -1) DAGISelEmitter.cpp |9 - 1 files changed, 8 insertions(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.215 llvm/utils/TableGen/DAGISelEmitter.cpp:1.216 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.215Mon Jun 19 19:31:27 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Jun 19 19:56:37 2006 @@ -436,7 +436,14 @@ case MVT::isFP : OS << ":isFP"; break; case MVT::isUnknown: ; /*OS << ":?";*/ break; case MVT::iPTR: OS << ":iPTR"; break; - default: OS << ":" << getTypeNum(0); break; + default: { +std::string VTName = llvm::getName(getTypeNum(0)); +// Strip off MVT:: prefix if present. +if (VTName.substr(0,5) == "MVT::") + VTName = VTName.substr(5); +OS << ":" << VTName; +break; + } } if (!isLeaf()) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.214 -> 1.215 --- Log message: Don't require src/dst patterns to be able to fully resolve their types, because information about one can help refine the other. This allows us to write: def : Pat<(i32 (extload xaddr:$src, i8)), (LBZX xaddr:$src)>; as: def : Pat<(extload xaddr:$src, i8), (LBZX xaddr:$src)>; because tblgen knows LBZX returns i32. --- Diffs of the changes: (+11 -5) DAGISelEmitter.cpp | 16 +++- 1 files changed, 11 insertions(+), 5 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.214 llvm/utils/TableGen/DAGISelEmitter.cpp:1.215 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.214Mon Jun 19 19:18:02 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Jun 19 19:31:27 2006 @@ -1568,17 +1568,16 @@ "with temporaries yet!"); bool IterateInference; +bool InferredAllPatternTypes, InferredAllResultTypes; do { // Infer as many types as possible. If we cannot infer all of them, we // can never do anything with this pattern: report it to the user. - if (!Pattern->InferAllTypes()) -Pattern->error("Could not infer all types in pattern!"); + InferredAllPatternTypes = Pattern->InferAllTypes(); // Infer as many types as possible. If we cannot infer all of them, we can // never do anything with this pattern: report it to the user. - if (!Result->InferAllTypes()) -Result->error("Could not infer all types in pattern result!"); - + InferredAllResultTypes = Result->InferAllTypes(); + // Apply the type of the result to the source pattern. This helps us // resolve cases where the input type is known to be a pointer type (which // is considered resolved), but the result knows it needs to be 32- or @@ -1588,6 +1587,13 @@ IterateInference |= Result->getOnlyTree()-> UpdateNodeType(Pattern->getOnlyTree()->getExtTypes(), *Result); } while (IterateInference); + +// Verify that we inferred enough types that we can do something with the +// pattern and result. If these fire the user has to add type casts. +if (!InferredAllPatternTypes) + Pattern->error("Could not infer all types in pattern!"); +if (!InferredAllResultTypes) + Result->error("Could not infer all types in pattern result!"); // Validate that the input pattern is correct. { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.213 -> 1.214 --- Log message: Make sure to use the result of the pattern to infer the result type of the instruction, and the result type of the instruction to refine the pattern. This allows us to write things like this: def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>; as: def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (VR128:$src)> and fixes a ppc64 issue. --- Diffs of the changes: (+34 -22) DAGISelEmitter.cpp | 56 - 1 files changed, 34 insertions(+), 22 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.213 llvm/utils/TableGen/DAGISelEmitter.cpp:1.214 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.213Fri Jun 16 13:25:06 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Mon Jun 19 19:18:02 2006 @@ -1554,22 +1554,6 @@ // Inline pattern fragments into it. Pattern->InlinePatternFragments(); -// Infer as many types as possible. If we cannot infer all of them, we can -// never do anything with this pattern: report it to the user. -if (!Pattern->InferAllTypes()) - Pattern->error("Could not infer all types in pattern!"); - -// Validate that the input pattern is correct. -{ - std::map InstInputs; - std::map InstResults; - std::vector InstImpInputs; - std::vector InstImpResults; - FindPatternInputsAndOutputs(Pattern, Pattern->getOnlyTree(), - InstInputs, InstResults, - InstImpInputs, InstImpResults); -} - ListInit *LI = Patterns[i]->getValueAsListInit("ResultInstrs"); if (LI->getSize() == 0) continue; // no pattern. @@ -1578,15 +1562,43 @@ // Inline pattern fragments into it. Result->InlinePatternFragments(); - -// Infer as many types as possible. If we cannot infer all of them, we can -// never do anything with this pattern: report it to the user. -if (!Result->InferAllTypes()) - Result->error("Could not infer all types in pattern result!"); - + if (Result->getNumTrees() != 1) Result->error("Cannot handle instructions producing instructions " "with temporaries yet!"); + +bool IterateInference; +do { + // Infer as many types as possible. If we cannot infer all of them, we + // can never do anything with this pattern: report it to the user. + if (!Pattern->InferAllTypes()) +Pattern->error("Could not infer all types in pattern!"); + + // Infer as many types as possible. If we cannot infer all of them, we can + // never do anything with this pattern: report it to the user. + if (!Result->InferAllTypes()) +Result->error("Could not infer all types in pattern result!"); + + // Apply the type of the result to the source pattern. This helps us + // resolve cases where the input type is known to be a pointer type (which + // is considered resolved), but the result knows it needs to be 32- or + // 64-bits. Infer the other way for good measure. + IterateInference = Pattern->getOnlyTree()-> +UpdateNodeType(Result->getOnlyTree()->getExtTypes(), *Result); + IterateInference |= Result->getOnlyTree()-> +UpdateNodeType(Pattern->getOnlyTree()->getExtTypes(), *Result); +} while (IterateInference); + +// Validate that the input pattern is correct. +{ + std::map InstInputs; + std::map InstResults; + std::vector InstImpInputs; + std::vector InstImpResults; + FindPatternInputsAndOutputs(Pattern, Pattern->getOnlyTree(), + InstInputs, InstResults, + InstImpInputs, InstImpResults); +} // Promote the xform function to be an explicit node if set. std::vector ResultNodeOperands; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.212 -> 1.213 --- Log message: Improve a comment. --- Diffs of the changes: (+1 -1) DAGISelEmitter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.212 llvm/utils/TableGen/DAGISelEmitter.cpp:1.213 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.212Wed Jun 14 19:16:37 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Jun 16 13:25:06 2006 @@ -145,7 +145,7 @@ assert(NumResults <= 1 && "We only work with nodes with zero or one result so far!"); - // Check that the number of operands is sane. + // Check that the number of operands is sane. Negative operands -> varargs. if (NodeInfo.getNumOperands() >= 0) { if (N->getNumChildren() != (unsigned)NodeInfo.getNumOperands()) TP.error(N->getOperator()->getName() + " node requires exactly " + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.210 -> 1.211 --- Log message: Added support for variable_ops. --- Diffs of the changes: (+78 -85) DAGISelEmitter.cpp | 163 + 1 files changed, 78 insertions(+), 85 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.210 llvm/utils/TableGen/DAGISelEmitter.cpp:1.211 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.210Wed Jun 14 14:27:50 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Jun 14 17:22:20 2006 @@ -2500,6 +2500,7 @@ if (InstPatNode && InstPatNode->getOperator()->getName() == "set") { InstPatNode = InstPatNode->getChild(1); } + bool HasVarOps = isRoot && II.hasVariableNumberOfOperands; bool HasImpInputs = isRoot && Inst.getNumImpOperands() > 0; bool HasImpResults = isRoot && Inst.getNumImpResults() > 0; bool NodeHasOptInFlag = isRoot && @@ -2515,10 +2516,11 @@ if (NodeHasInFlag || NodeHasOutFlag || NodeHasOptInFlag || HasImpInputs) emitDecl("InFlag"); - if (NodeHasOptInFlag) { -emitCode("bool HasOptInFlag = " + if (NodeHasOptInFlag) +emitCode("bool HasInFlag = " "N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag;"); - } + if (HasVarOps) +emitCode("std::vector Ops;"); // How many results is this pattern expected to produce? unsigned PatResults = 0; @@ -2581,7 +2583,7 @@ if (NodeHasInFlag || HasImpInputs) EmitInFlagSelectCode(Pattern, "N", ChainEmitted, true); if (NodeHasOptInFlag) { -emitCode("if (HasOptInFlag)"); +emitCode("if (HasInFlag)"); emitCode(" Select(InFlag, N.getOperand(N.getNumOperands()-1));"); } @@ -2596,96 +2598,87 @@ unsigned ResNo = TmpNo++; if (!isRoot || InputHasChain || NodeHasChain || NodeHasOutFlag || NodeHasOptInFlag) { -if (NodeHasOptInFlag) { - unsigned FlagNo = (unsigned) NodeHasChain + Pattern->getNumChildren(); - emitDecl("ResNode", true); - emitCode("if (HasOptInFlag)"); - std::string Code = " ResNode = CurDAG->getTargetNode(" + - II.Namespace + "::" + II.TheDef->getName(); - - // Output order: results, chain, flags - // Result types. - if (PatResults > 0) { -if (N->getTypeNum(0) != MVT::isVoid) - Code += ", " + getEnumName(N->getTypeNum(0)); - } - if (NodeHasChain) -Code += ", MVT::Other"; - if (NodeHasOutFlag) -Code += ", MVT::Flag"; +std::string Code; +std::string Code2; +std::string NodeName; +if (!isRoot) { + NodeName = "Tmp" + utostr(ResNo); + emitDecl(NodeName); + Code2 = NodeName + " = SDOperand("; +} else { + NodeName = "ResNode"; + emitDecl(NodeName, true); + Code2 = NodeName + " = "; +} +Code = "CurDAG->getTargetNode(" + + II.Namespace + "::" + II.TheDef->getName(); - // Inputs. - for (unsigned i = 0, e = Ops.size(); i != e; ++i) -Code += ", Tmp" + utostr(Ops[i]); - if (NodeHasChain) Code += ", " + ChainName; - emitCode(Code + ", InFlag);"); +// Output order: results, chain, flags +// Result types. +if (NumResults > 0 && N->getTypeNum(0) != MVT::isVoid) + Code += ", " + getEnumName(N->getTypeNum(0)); +if (NodeHasChain) + Code += ", MVT::Other"; +if (NodeHasOutFlag) + Code += ", MVT::Flag"; - emitCode("else"); - Code = " ResNode = CurDAG->getTargetNode(" + II.Namespace + "::" + - II.TheDef->getName(); +// Inputs. +for (unsigned i = 0, e = Ops.size(); i != e; ++i) { + if (HasVarOps) +emitCode("Ops.push_back(Tmp" + utostr(Ops[i]) + ");"); + else +Code += ", Tmp" + utostr(Ops[i]); +} - // Output order: results, chain, flags - // Result types. - if (PatResults > 0 && N->getTypeNum(0) != MVT::isVoid) -Code += ", " + getEnumName(N->getTypeNum(0)); - if (NodeHasChain) -Code += ", MVT::Other"; - if (NodeHasOutFlag) -Code += ", MVT::Flag"; +if (HasVarOps) { + if (NodeHasInFlag || HasImpInputs) +emitCode("for (unsigned i = 2, e = N.getNumOperands()-1; " + "i != e; ++i) {"); + else if (NodeHasOptInFlag) +emitCode("for (unsigned i = 2, e = N.getNumOperands()-HasInFlag; " + "i != e; ++i) {"); + else +emitCode("for (unsigned i = 2, e = N.getNumOperands(); " + "i != e; ++i) {"); + emitCode(" SDOperand VarOp(0, 0);"); +
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.209 -> 1.210 --- Log message: Fix support for optional input flag. --- Diffs of the changes: (+11 -17) DAGISelEmitter.cpp | 28 +++- 1 files changed, 11 insertions(+), 17 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.209 llvm/utils/TableGen/DAGISelEmitter.cpp:1.210 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.209Tue Jun 13 16:47:27 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Jun 14 14:27:50 2006 @@ -2515,8 +2515,10 @@ if (NodeHasInFlag || NodeHasOutFlag || NodeHasOptInFlag || HasImpInputs) emitDecl("InFlag"); - if (NodeHasOptInFlag) -emitCode("bool HasOptInFlag = false;"); + if (NodeHasOptInFlag) { +emitCode("bool HasOptInFlag = " + "N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag;"); + } // How many results is this pattern expected to produce? unsigned PatResults = 0; @@ -2576,8 +2578,12 @@ bool ChainEmitted = NodeHasChain; if (NodeHasChain) emitCode("Select(" + ChainName + ", " + ChainName + ");"); - if (NodeHasInFlag || NodeHasOptInFlag || HasImpInputs) + if (NodeHasInFlag || HasImpInputs) EmitInFlagSelectCode(Pattern, "N", ChainEmitted, true); + if (NodeHasOptInFlag) { +emitCode("if (HasOptInFlag)"); +emitCode(" Select(InFlag, N.getOperand(N.getNumOperands()-1));"); + } if (isRoot) { // The operands have been selected. Remove them from InFlightSet. @@ -2854,7 +2860,6 @@ unsigned OpNo = (unsigned) NodeHasProperty(N, SDNodeInfo::SDNPHasChain, ISE); bool HasInFlag = NodeHasProperty(N, SDNodeInfo::SDNPInFlag, ISE); -bool HasOptInFlag = NodeHasProperty(N, SDNodeInfo::SDNPOptInFlag, ISE); for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { TreePatternNode *Child = N->getChild(i); if (!Child->isLeaf()) { @@ -2894,20 +2899,9 @@ } } -if (HasInFlag || HasOptInFlag) { - std::string Code; - if (HasOptInFlag) { -emitCode("if (" + RootName + ".getNumOperands() == " + utostr(OpNo+1) + - ") {"); -Code = " "; - } - emitCode(Code + "Select(InFlag, " + RootName + +if (HasInFlag) + emitCode("Select(InFlag, " + RootName + ".getOperand(" + utostr(OpNo) + "));"); - if (HasOptInFlag) { -emitCode(" HasOptInFlag = true;"); -emitCode("}"); - } -} } /// EmitCopyFromRegs - Emit code to copy result to physical registers ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.208 -> 1.209 --- Log message: getOperandNum(): error if specified operand number is out of range. --- Diffs of the changes: (+7 -0) DAGISelEmitter.cpp |7 +++ 1 files changed, 7 insertions(+) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.208 llvm/utils/TableGen/DAGISelEmitter.cpp:1.209 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.208Fri Jun 9 18:59:44 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Jun 13 16:47:27 2006 @@ -121,6 +121,13 @@ assert(NumResults <= 1 && "We only work with nodes with zero or one result so far!"); + if (OpNo >= (NumResults + N->getNumChildren())) { +std::cerr << "Invalid operand number " << OpNo << " "; +N->dump(); +std::cerr << '\n'; +exit(1); + } + if (OpNo < NumResults) return N; // FIXME: need value # else ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.207 -> 1.208 --- Log message: Wrap to 80 cols --- Diffs of the changes: (+5 -4) DAGISelEmitter.cpp |9 + 1 files changed, 5 insertions(+), 4 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.207 llvm/utils/TableGen/DAGISelEmitter.cpp:1.208 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.207Thu May 25 15:16:55 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Jun 9 18:59:44 2006 @@ -2748,7 +2748,8 @@ emitCode(" Result = SDOperand(ResNode, N.ResNo-1);"); } emitCode("else"); - emitCode(" Result = SDOperand(" + ChainName + ".Val, " + ChainName + ".ResNo);"); + emitCode(" Result = SDOperand(" + ChainName + ".Val, " + + ChainName + ".ResNo);"); } else { emitCode("Result = SDOperand(ResNode, N.ResNo);"); } @@ -2780,8 +2781,8 @@ if (NodeHasInFlag || HasImpInputs) Code += ", InFlag"; emitCode(Code + ");"); -emitCode(" SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, " - "ResNode, 0);"); +emitCode(" SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo" + ", ResNode, 0);"); emitCode(" Result = SDOperand(ResNode, 0);"); emitCode("}"); } @@ -3544,7 +3545,7 @@ << "E = From.Val->use_end(); UI != E; ++UI) {\n"; OS << " SDNode *Use = *UI;\n"; OS << " std::vector Ops;\n"; - OS << " for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {\n"; + OS << " for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i){\n"; OS << "SDOperand O = Use->getOperand(i);\n"; OS << "if (O.Val == From.Val)\n"; OS << " Ops.push_back(To);\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.206 -> 1.207 --- Log message: Can't trust NodeDepth when checking for possibility of load folding creating a cycle. This increase the search space and will increase compile time (in practice it appears to be small, e.g. 176.gcc goes from 62 sec to 65 sec) that will be addressed later. --- Diffs of the changes: (+5 -7) DAGISelEmitter.cpp | 12 +--- 1 files changed, 5 insertions(+), 7 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.206 llvm/utils/TableGen/DAGISelEmitter.cpp:1.207 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.206Wed May 24 19:21:44 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu May 25 15:16:55 2006 @@ -3481,13 +3481,11 @@ OS << " if (found || !Visited.insert(Use).second) return;\n"; OS << " for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {\n"; OS << "SDNode *N = Use->getOperand(i).Val;\n"; - OS << "if (N->getNodeDepth() >= Def->getNodeDepth()) {\n"; - OS << " if (N != Def) {\n"; - OS << "findNonImmUse(N, Def, found, Visited);\n"; - OS << " } else {\n"; - OS << "found = true;\n"; - OS << "break;\n"; - OS << " }\n"; + OS << "if (N != Def) {\n"; + OS << " findNonImmUse(N, Def, found, Visited);\n"; + OS << "} else {\n"; + OS << " found = true;\n"; + OS << " break;\n"; OS << "}\n"; OS << " }\n"; OS << "}\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.205 -> 1.206 --- Log message: Fixed a really ugly bug. The TableGen'd isel is not freeing the "inflight set" correctly. That is causing non-deterministic behavior (and possibly preventing some load folding from happening). --- Diffs of the changes: (+21 -9) DAGISelEmitter.cpp | 30 +- 1 files changed, 21 insertions(+), 9 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.205 llvm/utils/TableGen/DAGISelEmitter.cpp:1.206 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.205Fri May 19 02:24:32 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed May 24 19:21:44 2006 @@ -2407,20 +2407,32 @@ std::string Fn = CP->getSelectFunc(); NumRes = CP->getNumOperands(); for (unsigned i = 0; i < NumRes; ++i) - emitDecl("Tmp" + utostr(i+ResNo)); + emitDecl("CPTmp" + utostr(i+ResNo)); -std::string Code = Fn + "(" + Val; +std::string Code = "bool Match = " + Fn + "(" + Val; for (unsigned i = 0; i < NumRes; i++) - Code += ", Tmp" + utostr(i + ResNo); -emitCheck(Code + ")"); + Code += ", CPTmp" + utostr(i + ResNo); +emitCode(Code + ");"); +if (InflightNodes.size()) { + // Remove the in-flight nodes if the ComplexPattern does not match! + emitCode("if (!Match) {"); + for (std::vector::iterator AI = InflightNodes.begin(), + AE = InflightNodes.end(); AI != AE; ++AI) +emitCode(" InFlightSet.erase(" + *AI + ".Val);"); + emitCode("}"); +} + +emitCheck("Match"); for (unsigned i = 0; i < NumRes; ++i) { - emitCode("InFlightSet.insert(Tmp" + utostr(i+ResNo) + ".Val);"); - InflightNodes.push_back("Tmp" + utostr(i+ResNo)); + emitCode("InFlightSet.insert(CPTmp" + utostr(i+ResNo) + ".Val);"); + InflightNodes.push_back("CPTmp" + utostr(i+ResNo)); } -for (unsigned i = 0; i < NumRes; ++i) - emitCode("Select(Tmp" + utostr(i+ResNo) + ", Tmp" + +for (unsigned i = 0; i < NumRes; ++i) { + emitDecl("Tmp" + utostr(i+ResNo)); + emitCode("Select(Tmp" + utostr(i+ResNo) + ", CPTmp" + utostr(i+ResNo) + ");"); +} TmpNo = ResNo + NumRes; } else { @@ -2524,7 +2536,6 @@ // Make sure these operands which would be selected won't be folded while // the isel traverses the DAG upward. - std::vector > NumTemps(EmitOrder.size()); for (unsigned i = 0, e = EmitOrder.size(); i != e; ++i) { TreePatternNode *Child = EmitOrder[i].second; if (!Child->getName().empty()) { @@ -2539,6 +2550,7 @@ } // Emit all of the operands. + std::vector > NumTemps(EmitOrder.size()); for (unsigned i = 0, e = EmitOrder.size(); i != e; ++i) { unsigned OpOrder = EmitOrder[i].first; TreePatternNode *Child = EmitOrder[i].second; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.204 -> 1.205 --- Log message: Now that iPTR is a fully resolved type. We end up losing the type check for patterns that look like this: def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>; InsertOneTypeCheck should copy the type from the resolved pattern to the unresolved one as long as there types are different. --- Diffs of the changes: (+1 -1) DAGISelEmitter.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.204 llvm/utils/TableGen/DAGISelEmitter.cpp:1.205 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.204Wed May 17 15:37:59 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri May 19 02:24:32 2006 @@ -2808,7 +2808,7 @@ bool InsertOneTypeCheck(TreePatternNode *Pat, TreePatternNode *Other, const std::string &Prefix) { // Did we find one? -if (!Pat->hasTypeSet()) { +if (Pat->getExtTypes() != Other->getExtTypes()) { // Move a type over from 'other' to 'pat'. Pat->setTypes(Other->getExtTypes()); emitCheck(Prefix + ".Val->getValueType(0) == MVT::" + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.201 -> 1.202 --- Log message: Unused instruction --- Diffs of the changes: (+0 -1) DAGISelEmitter.cpp |1 - 1 files changed, 1 deletion(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.201 llvm/utils/TableGen/DAGISelEmitter.cpp:1.202 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.201Tue May 9 21:47:57 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri May 12 02:42:01 2006 @@ -2870,7 +2870,6 @@ if (Op->isSubClassOf("Instruction")) { const DAGInstruction &Inst = ISE.getInstruction(Op); const CodeGenTarget &CGT = ISE.getTargetInfo(); - CodeGenInstruction &II = CGT.getInstruction(Op->getName()); unsigned NumImpResults = Inst.getNumImpResults(); for (unsigned i = 0; i < NumImpResults; i++) { Record *RR = Inst.getImpResult(i); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.200 -> 1.201 --- Log message: Watch out for the following case: 1. Use expects a chain output. 2. Node is expanded into multiple target ops. 3. One of the inner node produces a chain, the outer most one doesn't. --- Diffs of the changes: (+37 -11) DAGISelEmitter.cpp | 48 +--- 1 files changed, 37 insertions(+), 11 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.200 llvm/utils/TableGen/DAGISelEmitter.cpp:1.201 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.200Tue May 9 19:05:46 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue May 9 21:47:57 2006 @@ -2462,6 +2462,8 @@ PatternHasProperty(Pattern, SDNodeInfo::SDNPOutFlag, ISE)); bool NodeHasChain = InstPatNode && PatternHasProperty(InstPatNode, SDNodeInfo::SDNPHasChain, ISE); + bool InputHasChain = isRoot && +NodeHasProperty(Pattern, SDNodeInfo::SDNPHasChain, ISE); if (NodeHasInFlag || NodeHasOutFlag || NodeHasOptInFlag || HasImpInputs) emitDecl("InFlag"); @@ -2538,7 +2540,8 @@ unsigned NumResults = Inst.getNumResults(); unsigned ResNo = TmpNo++; - if (!isRoot || NodeHasChain || NodeHasOutFlag || NodeHasOptInFlag) { + if (!isRoot || InputHasChain || NodeHasChain || NodeHasOutFlag || + NodeHasOptInFlag) { if (NodeHasOptInFlag) { unsigned FlagNo = (unsigned) NodeHasChain + Pattern->getNumChildren(); emitDecl("ResNode", true); @@ -2548,7 +2551,7 @@ // Output order: results, chain, flags // Result types. - if (NumResults > 0) { + if (PatResults > 0) { if (N->getTypeNum(0) != MVT::isVoid) Code += ", MVT::" + getEnumName(N->getTypeNum(0)); } @@ -2569,7 +2572,7 @@ // Output order: results, chain, flags // Result types. - if (NumResults > 0 && N->getTypeNum(0) != MVT::isVoid) + if (PatResults > 0 && N->getTypeNum(0) != MVT::isVoid) Code += ", MVT::" + getEnumName(N->getTypeNum(0)); if (NodeHasChain) Code += ", MVT::Other"; @@ -2581,14 +2584,20 @@ Code += ", Tmp" + utostr(Ops[i]); if (NodeHasChain) Code += ", " + ChainName + ");"; emitCode(Code); + + if (NodeHasChain) +// Remember which op produces the chain. +emitCode(ChainName + " = SDOperand(ResNode" + + ", " + utostr(PatResults) + ");"); } else { std::string Code; + std::string NodeName; if (!isRoot) { -std::string NodeName = "Tmp" + utostr(ResNo); +NodeName = "Tmp" + utostr(ResNo); emitDecl(NodeName); Code = NodeName + " = SDOperand("; } else { -std::string NodeName = "ResNode"; +NodeName = "ResNode"; emitDecl(NodeName, true); Code = NodeName + " = "; } @@ -2613,6 +2622,15 @@ emitCode(Code + "), 0);"); else emitCode(Code + ");"); + + if (NodeHasChain) +// Remember which op produces the chain. +if (!isRoot) + emitCode(ChainName + " = SDOperand(" + NodeName + + ".Val, " + utostr(PatResults) + ");"); +else + emitCode(ChainName + " = SDOperand(" + NodeName + + ", " + utostr(PatResults) + ");"); } if (!isRoot) @@ -2637,16 +2655,14 @@ NumResults = 1; } -bool InputHasChain = - NodeHasProperty(Pattern, SDNodeInfo::SDNPHasChain, ISE); if (InputHasChain) { emitCode("SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, " + - utostr(PatResults) + ", ResNode, " + - utostr(NumResults) + ");"); + utostr(PatResults) + ", " + ChainName + ".Val, " + + ChainName + ".ResNo" + ");"); if (DoReplace) emitCode("if (N.ResNo == 0) AddHandleReplacement(N.Val, " + - utostr(PatResults) + ", " + "ResNode, " + - utostr(NumResults) + ");"); + utostr(PatResults) + ", " + ChainName + ".Val, " + + ChainName + ".ResNo" + ");"); } if (FoldedChains.size() > 0) { @@ -2682,6 +2698,16 @@ emitCode("else"); emitCode(" Result = SDOperand(ResNode, N.ResNo+1);"); } +} else if (InputHasChain && !NodeHasChain) { + // One of the inner node produces a chain. + emitCode("if (N.ResNo < " + utostr(PatResults) + ")"); + emitCode(" Result = SDOperand(ResNode, N.ResNo);"); + if (NodeHasOutFlag) { +emitCode("else if (N.ResNo >
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.199 -> 1.200 --- Log message: Fix a load folding bug. It is exposed by a multi- resulting instructions def : Pat<> pattern. --- Diffs of the changes: (+62 -58) DAGISelEmitter.cpp | 120 +++-- 1 files changed, 62 insertions(+), 58 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.199 llvm/utils/TableGen/DAGISelEmitter.cpp:1.200 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.199Fri Apr 28 13:54:11 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue May 9 19:05:46 2006 @@ -2445,22 +2445,27 @@ const CodeGenTarget &CGT = ISE.getTargetInfo(); CodeGenInstruction &II = CGT.getInstruction(Op->getName()); const DAGInstruction &Inst = ISE.getInstruction(Op); - bool HasImpInputs = Inst.getNumImpOperands() > 0; - bool HasImpResults = Inst.getNumImpResults() > 0; - bool HasOptInFlag = isRoot && + TreePattern *InstPat = Inst.getPattern(); + TreePatternNode *InstPatNode = +isRoot ? (InstPat ? InstPat->getOnlyTree() : Pattern) + : (InstPat ? InstPat->getOnlyTree() : NULL); + if (InstPatNode && InstPatNode->getOperator()->getName() == "set") { +InstPatNode = InstPatNode->getChild(1); + } + bool HasImpInputs = isRoot && Inst.getNumImpOperands() > 0; + bool HasImpResults = isRoot && Inst.getNumImpResults() > 0; + bool NodeHasOptInFlag = isRoot && PatternHasProperty(Pattern, SDNodeInfo::SDNPOptInFlag, ISE); - bool HasInFlag = isRoot && + bool NodeHasInFlag = isRoot && PatternHasProperty(Pattern, SDNodeInfo::SDNPInFlag, ISE); - bool NodeHasOutFlag = HasImpResults || -(isRoot && PatternHasProperty(Pattern, SDNodeInfo::SDNPOutFlag, ISE)); - bool NodeHasChain = -NodeHasProperty(Pattern, SDNodeInfo::SDNPHasChain, ISE); - bool HasChain = II.hasCtrlDep || -(isRoot && PatternHasProperty(Pattern, SDNodeInfo::SDNPHasChain, ISE)); + bool NodeHasOutFlag = HasImpResults || (isRoot && +PatternHasProperty(Pattern, SDNodeInfo::SDNPOutFlag, ISE)); + bool NodeHasChain = InstPatNode && +PatternHasProperty(InstPatNode, SDNodeInfo::SDNPHasChain, ISE); - if (HasInFlag || NodeHasOutFlag || HasOptInFlag || HasImpInputs) + if (NodeHasInFlag || NodeHasOutFlag || NodeHasOptInFlag || HasImpInputs) emitDecl("InFlag"); - if (HasOptInFlag) + if (NodeHasOptInFlag) emitCode("bool HasOptInFlag = false;"); // How many results is this pattern expected to produce? @@ -2518,41 +2523,23 @@ } // Emit all the chain and CopyToReg stuff. - bool ChainEmitted = HasChain; - if (HasChain) + bool ChainEmitted = NodeHasChain; + if (NodeHasChain) emitCode("Select(" + ChainName + ", " + ChainName + ");"); - if (HasInFlag || HasOptInFlag || HasImpInputs) + if (NodeHasInFlag || NodeHasOptInFlag || HasImpInputs) EmitInFlagSelectCode(Pattern, "N", ChainEmitted, true); - // The operands have been selected. Remove them from InFlightSet. - for (std::vector::iterator AI = InflightNodes.begin(), - AE = InflightNodes.end(); AI != AE; ++AI) -emitCode("InFlightSet.erase(" + *AI + ".Val);"); + if (isRoot) { +// The operands have been selected. Remove them from InFlightSet. +for (std::vector::iterator AI = InflightNodes.begin(), + AE = InflightNodes.end(); AI != AE; ++AI) + emitCode("InFlightSet.erase(" + *AI + ".Val);"); + } + unsigned NumResults = Inst.getNumResults(); unsigned ResNo = TmpNo++; - if (!isRoot) { -emitDecl("Tmp" + utostr(ResNo)); -std::string Code = - "Tmp" + utostr(ResNo) + " = SDOperand(CurDAG->getTargetNode(" + - II.Namespace + "::" + II.TheDef->getName(); -if (N->getTypeNum(0) != MVT::isVoid) - Code += ", MVT::" + getEnumName(N->getTypeNum(0)); -if (NodeHasOutFlag) - Code += ", MVT::Flag"; - -unsigned LastOp = 0; -for (unsigned i = 0, e = Ops.size(); i != e; ++i) { - LastOp = Ops[i]; - Code += ", Tmp" + utostr(LastOp); -} -emitCode(Code + "), 0);"); -if (HasChain) { - // Must have at least one result - emitCode(ChainName + " = Tmp" + utostr(LastOp) + ".getValue(" + - utostr(NumResults) + ");"); -} - } else if (HasChain || NodeHasOutFlag) { -if (HasOptInFlag) { + if (!isRoot || NodeHasChain || NodeHasOutFlag || NodeHasOptInFlag) { +if (NodeHasOptInFlag) { unsigned FlagNo = (unsigned) NodeHasChain + Pattern->getNumChildren(); emitDecl("ResNode", true); emitCode("if (HasOptInFlag)"); @@ -2565,7 +2552,7 @@ if (N->getTypeNum(0)
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.198 -> 1.199 --- Log message: Remove the temporary option: -no-isel-fold-inflight --- Diffs of the changes: (+1 -2) DAGISelEmitter.cpp |3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.198 llvm/utils/TableGen/DAGISelEmitter.cpp:1.199 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.198Thu Apr 27 21:08:10 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Fri Apr 28 13:54:11 2006 @@ -2131,8 +2131,7 @@ if (!isRoot) { const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); // Not in flight? -emitCheck("(FoldNodeInFlight || InFlightSet.count(" - + RootName + ".Val) == 0)"); +emitCheck("InFlightSet.count(" + RootName + ".Val) == 0"); // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.197 -> 1.198 --- Log message: When isel'ing a node, mark its operands "InFlight" before selecting them. These nodes should not be folded into other nodes. This fixes the miscompilation of PR 749: http://llvm.cs.uiuc.edu/PR749 . Temporarily under flag control. --- Diffs of the changes: (+34 -2) DAGISelEmitter.cpp | 36 ++-- 1 files changed, 34 insertions(+), 2 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.197 llvm/utils/TableGen/DAGISelEmitter.cpp:1.198 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.197Sat Apr 22 13:53:45 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Apr 27 21:08:10 2006 @@ -2022,6 +2022,8 @@ // Names of all the folded nodes which produce chains. std::vector > FoldedChains; std::set Duplicates; + /// These nodes are being marked "in-flight" so they cannot be folded. + std::vector InflightNodes; /// GeneratedCode - This is the buffer that we emit code to. The first bool /// indicates whether this is an exit predicate (something that should be @@ -2128,6 +2130,9 @@ OpNo = 1; if (!isRoot) { const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator()); +// Not in flight? +emitCheck("(FoldNodeInFlight || InFlightSet.count(" + + RootName + ".Val) == 0)"); // Multiple uses of actual result? emitCheck(RootName + ".hasOneUse()"); EmittedUseCheck = true; @@ -2381,6 +2386,10 @@ Code += ", Tmp" + utostr(i + ResNo); emitCheck(Code + ")"); +for (unsigned i = 0; i < NumRes; ++i) { + emitCode("InFlightSet.insert(Tmp" + utostr(i+ResNo) + ".Val);"); + InflightNodes.push_back("Tmp" + utostr(i+ResNo)); +} for (unsigned i = 0; i < NumRes; ++i) emitCode("Select(Tmp" + utostr(i+ResNo) + ", Tmp" + utostr(i+ResNo) + ");"); @@ -2392,8 +2401,9 @@ // node even if it isn't one. Don't select it. if (LikeLeaf) emitCode("Tmp" + utostr(ResNo) + " = " + Val + ";"); -else +else { emitCode("Select(Tmp" + utostr(ResNo) + ", " + Val + ");"); +} if (isRoot && N->isLeaf()) { emitCode("Result = Tmp" + utostr(ResNo) + ";"); @@ -2477,9 +2487,24 @@ } } - // Emit all of the operands. + // Make sure these operands which would be selected won't be folded while + // the isel traverses the DAG upward. std::vector > NumTemps(EmitOrder.size()); for (unsigned i = 0, e = EmitOrder.size(); i != e; ++i) { +TreePatternNode *Child = EmitOrder[i].second; +if (!Child->getName().empty()) { + std::string &Val = VariableMap[Child->getName()]; + assert(!Val.empty() && + "Variable referenced but not defined and not caught earlier!"); + if (Child->isLeaf() && !NodeGetComplexPattern(Child, ISE)) { +emitCode("InFlightSet.insert(" + Val + ".Val);"); +InflightNodes.push_back(Val); + } +} + } + + // Emit all of the operands. + for (unsigned i = 0, e = EmitOrder.size(); i != e; ++i) { unsigned OpOrder = EmitOrder[i].first; TreePatternNode *Child = EmitOrder[i].second; std::pair NumTemp = EmitResultCode(Child); @@ -2500,6 +2525,10 @@ if (HasInFlag || HasOptInFlag || HasImpInputs) EmitInFlagSelectCode(Pattern, "N", ChainEmitted, true); + // The operands have been selected. Remove them from InFlightSet. + for (std::vector::iterator AI = InflightNodes.begin(), + AE = InflightNodes.end(); AI != AE; ++AI) +emitCode("InFlightSet.erase(" + *AI + ".Val);"); unsigned NumResults = Inst.getNumResults(); unsigned ResNo = TmpNo++; if (!isRoot) { @@ -3373,6 +3402,9 @@ OS << "// Instance var to keep track of mapping of place handle nodes\n" << "// and their replacement nodes.\n"; OS << "std::map ReplaceMap;\n"; + OS << "// Keep track of nodes that are currently being selecte and therefore\n" + << "// should not be folded.\n"; + OS << "std::set InFlightSet;\n"; OS << "\n"; OS << "static void findNonImmUse(SDNode* Use, SDNode* Def, bool &found, " ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.196 -> 1.197 --- Log message: JumpTable support! What this represents is working asm and jit support for x86 and ppc for 100% dense switch statements when relocations are non-PIC. This support will be extended and enhanced in the coming days to support PIC, and less dense forms of jump tables. --- Diffs of the changes: (+1 -0) DAGISelEmitter.cpp |1 + 1 files changed, 1 insertion(+) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.196 llvm/utils/TableGen/DAGISelEmitter.cpp:1.197 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.196Wed Apr 19 15:36:09 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Sat Apr 22 13:53:45 2006 @@ -3225,6 +3225,7 @@ << " case ISD::TargetConstant:\n" << " case ISD::TargetConstantPool:\n" << " case ISD::TargetFrameIndex:\n" + << " case ISD::TargetJumpTable:\n" << " case ISD::TargetGlobalAddress: {\n" << "Result = N;\n" << "return;\n" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.195 -> 1.196 DAGISelEmitter.h updated: 1.62 -> 1.63 --- Log message: Rename AddedCost to AddedComplexity. --- Diffs of the changes: (+15 -13) DAGISelEmitter.cpp | 18 +- DAGISelEmitter.h | 10 ++ 2 files changed, 15 insertions(+), 13 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.195 llvm/utils/TableGen/DAGISelEmitter.cpp:1.196 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.195Wed Apr 19 13:07:24 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Apr 19 15:36:09 2006 @@ -1505,7 +1505,7 @@ PatternsToMatch. push_back(PatternToMatch(Instr->getValueAsListInit("Predicates"), SrcPattern, DstPattern, - Instr->getValueAsInt("AddedCost"))); + Instr->getValueAsInt("AddedComplexity"))); } } @@ -1582,7 +1582,7 @@ push_back(PatternToMatch(Patterns[i]->getValueAsListInit("Predicates"), Pattern->getOnlyTree(), Temp.getOnlyTree(), - Patterns[i]->getValueAsInt("AddedCost"))); + Patterns[i]->getValueAsInt("AddedComplexity"))); } } @@ -1826,7 +1826,7 @@ PatternsToMatch. push_back(PatternToMatch(PatternsToMatch[i].getPredicates(), Variant, PatternsToMatch[i].getDstPattern(), - PatternsToMatch[i].getAddedCost())); + PatternsToMatch[i].getAddedComplexity())); } DEBUG(std::cerr << "\n"); @@ -1936,8 +1936,8 @@ PatternToMatch *RHS) { unsigned LHSSize = getPatternSize(LHS->getSrcPattern(), ISE); unsigned RHSSize = getPatternSize(RHS->getSrcPattern(), ISE); -LHSSize += LHS->getAddedCost(); -RHSSize += RHS->getAddedCost(); +LHSSize += LHS->getAddedComplexity(); +RHSSize += RHS->getAddedComplexity(); if (LHSSize > RHSSize) return true; // LHS -> bigger -> less cost if (LHSSize < RHSSize) return false; @@ -2946,9 +2946,9 @@ OS << "\n" << std::string(Indent, ' ') << "// Emits: "; Pattern.getDstPattern()->print(OS); OS << "\n"; - unsigned AddedCost = Pattern.getAddedCost(); + unsigned AddedComplexity = Pattern.getAddedComplexity(); OS << std::string(Indent, ' ') << "// Pattern complexity = " - << getPatternSize(Pattern.getSrcPattern(), *this) + AddedCost + << getPatternSize(Pattern.getSrcPattern(), *this) + AddedComplexity << " cost = " << getResultPatternCost(Pattern.getDstPattern(), *this) << "\n"; } @@ -2969,9 +2969,9 @@ OS << "\n" << std::string(Indent, ' ') << "// Emits: "; Pattern.getDstPattern()->print(OS); OS << "\n"; - unsigned AddedCost = Pattern.getAddedCost(); + unsigned AddedComplexity = Pattern.getAddedComplexity(); OS << std::string(Indent, ' ') << "// Pattern complexity = " - << getPatternSize(Pattern.getSrcPattern(), *this) + AddedCost + << getPatternSize(Pattern.getSrcPattern(), *this) + AddedComplexity << " cost = " << getResultPatternCost(Pattern.getDstPattern(), *this) << "\n"; } Index: llvm/utils/TableGen/DAGISelEmitter.h diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.62 llvm/utils/TableGen/DAGISelEmitter.h:1.63 --- llvm/utils/TableGen/DAGISelEmitter.h:1.62 Wed Apr 19 13:07:24 2006 +++ llvm/utils/TableGen/DAGISelEmitter.hWed Apr 19 15:36:09 2006 @@ -395,18 +395,20 @@ /// to produce isel. struct PatternToMatch { PatternToMatch(ListInit *preds, - TreePatternNode *src, TreePatternNode *dst, unsigned cost): -Predicates(preds), SrcPattern(src), DstPattern(dst), AddedCost(cost) {}; + TreePatternNode *src, TreePatternNode *dst, + unsigned complexity): +Predicates(preds), SrcPattern(src), DstPattern(dst), +AddedComplexity(complexity) {}; ListInit*Predicates; // Top level predicate conditions to match. TreePatternNode *SrcPattern; // Source pattern to match. TreePatternNode *DstPattern; // Resulting pattern. - unsigned AddedCost; // Add to matching pattern complexity. + unsigned AddedComplexity; // Add to matching pattern complexity. ListInit*getPredicates() const { return Predicates; } TreePatternNode *getSrcPattern() const { return SrcPattern; } TreePatternNode *getDstPattern() const { return DstPattern; } - unsigned getAddedCost() const { return AddedCost; } + unsigned getAddedComplexity() const { return AddedComplexity; } }; /// DAGISelEmitter - The top-level class which coordinates construction ___ llvm-commits mailing list llvm-commits@cs.uiuc.e
[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Changes in directory llvm/utils/TableGen: DAGISelEmitter.cpp updated: 1.194 -> 1.195 DAGISelEmitter.h updated: 1.61 -> 1.62 --- Log message: Allow "let AddedCost = n in" to increase pattern complexity. --- Diffs of the changes: (+21 -7) DAGISelEmitter.cpp | 21 - DAGISelEmitter.h |7 +-- 2 files changed, 21 insertions(+), 7 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.194 llvm/utils/TableGen/DAGISelEmitter.cpp:1.195 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.194Thu Apr 6 15:36:51 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Apr 19 13:07:24 2006 @@ -1504,7 +1504,8 @@ TreePatternNode *DstPattern = TheInst.getResultPattern(); PatternsToMatch. push_back(PatternToMatch(Instr->getValueAsListInit("Predicates"), - SrcPattern, DstPattern)); + SrcPattern, DstPattern, + Instr->getValueAsInt("AddedCost"))); } } @@ -1580,7 +1581,8 @@ PatternsToMatch. push_back(PatternToMatch(Patterns[i]->getValueAsListInit("Predicates"), Pattern->getOnlyTree(), - Temp.getOnlyTree())); + Temp.getOnlyTree(), + Patterns[i]->getValueAsInt("AddedCost"))); } } @@ -1823,7 +1825,8 @@ // Otherwise, add it to the list of patterns we have. PatternsToMatch. push_back(PatternToMatch(PatternsToMatch[i].getPredicates(), - Variant, PatternsToMatch[i].getDstPattern())); + Variant, PatternsToMatch[i].getDstPattern(), + PatternsToMatch[i].getAddedCost())); } DEBUG(std::cerr << "\n"); @@ -1933,6 +1936,8 @@ PatternToMatch *RHS) { unsigned LHSSize = getPatternSize(LHS->getSrcPattern(), ISE); unsigned RHSSize = getPatternSize(RHS->getSrcPattern(), ISE); +LHSSize += LHS->getAddedCost(); +RHSSize += RHS->getAddedCost(); if (LHSSize > RHSSize) return true; // LHS -> bigger -> less cost if (LHSSize < RHSSize) return false; @@ -2003,6 +2008,8 @@ // Predicates. ListInit *Predicates; + // Pattern cost. + unsigned Cost; // Instruction selector pattern. TreePatternNode *Pattern; // Matched instruction. @@ -2939,8 +2946,10 @@ OS << "\n" << std::string(Indent, ' ') << "// Emits: "; Pattern.getDstPattern()->print(OS); OS << "\n"; + unsigned AddedCost = Pattern.getAddedCost(); OS << std::string(Indent, ' ') << "// Pattern complexity = " - << getPatternSize(Pattern.getSrcPattern(), *this) << " cost = " + << getPatternSize(Pattern.getSrcPattern(), *this) + AddedCost + << " cost = " << getResultPatternCost(Pattern.getDstPattern(), *this) << "\n"; } if (!FirstCodeLine.first) { @@ -2960,8 +2969,10 @@ OS << "\n" << std::string(Indent, ' ') << "// Emits: "; Pattern.getDstPattern()->print(OS); OS << "\n"; + unsigned AddedCost = Pattern.getAddedCost(); OS << std::string(Indent, ' ') << "// Pattern complexity = " - << getPatternSize(Pattern.getSrcPattern(), *this) << " cost = " + << getPatternSize(Pattern.getSrcPattern(), *this) + AddedCost + << " cost = " << getResultPatternCost(Pattern.getDstPattern(), *this) << "\n"; } EmitPatterns(Other, Indent, OS); Index: llvm/utils/TableGen/DAGISelEmitter.h diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.61 llvm/utils/TableGen/DAGISelEmitter.h:1.62 --- llvm/utils/TableGen/DAGISelEmitter.h:1.61 Fri Mar 24 17:10:39 2006 +++ llvm/utils/TableGen/DAGISelEmitter.hWed Apr 19 13:07:24 2006 @@ -394,16 +394,19 @@ /// PatternToMatch - Used by DAGISelEmitter to keep tab of patterns processed /// to produce isel. struct PatternToMatch { - PatternToMatch(ListInit *preds, TreePatternNode *src, TreePatternNode *dst): -Predicates(preds), SrcPattern(src), DstPattern(dst) {}; + PatternToMatch(ListInit *preds, + TreePatternNode *src, TreePatternNode *dst, unsigned cost): +Predicates(preds), SrcPattern(src), DstPattern(dst), AddedCost(cost) {}; ListInit*Predicates; // Top level predicate conditions to match. TreePatternNode *SrcPattern; // Source pattern to match. TreePatternNode *DstPattern; // Resulting pattern. + unsigned AddedCost; // Add to matching pattern complexity. ListInit*getPredicates() const { return Predicates; } TreePatternNode *getSrcPattern() const { return SrcPattern; } TreePatternNode *getDstPattern() const { return DstPattern; } + unsigned getAddedCost() const { return AddedCost; } }; /// DAGISelEmitter - The top-level class which coordinates construction __