[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2007-06-19 Thread Chris Lattner


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::vectorstd::string 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

2007-05-15 Thread Evan Cheng

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

2007-05-15 Thread Chris Lattner
   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


[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2007-05-14 Thread Evan Cheng


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::vectorstd::string AllOps;
+  unsigned NumEAInputs = 0; // # of synthesized 'execute always' inputs.
   for (unsigned ChildNo = 0, InstOpNo = NumResults;
InstOpNo != II.OperandList.size(); ++InstOpNo) {
 std::vectorstd::string 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

2007-05-14 Thread Chris Lattner


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::vectorSDOperand 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::vectorMVT::ValueType 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


Re: [llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2007-05-14 Thread Chris Lattner
 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

2007-05-08 Thread Evan Cheng


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::vectorstd::string 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

2007-04-26 Thread Lauro Ramos Venancio


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

2007-04-20 Thread Lauro Ramos Venancio


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(castGlobalAddressSDNode( + 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

2007-01-26 Thread Jim Laskey


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 = castConstantSDNode(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

2007-01-16 Thread Chris Lattner


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

2006-11-14 Thread Chris Lattner


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

2006-11-14 Thread Chris Lattner


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::vectorunsigned char
 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::vectorunsigned char 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_castDefInit*(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

2006-11-14 Thread Chris Lattner


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)
-OSreturn Select_  getLegalCName(OpName)  (N);\n;
-  else
-   OSbreak;\n;
+  OSbreak;\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

2006-11-14 Thread Chris Lattner


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) {
+OSif (NVT == TLI.getPointerTy())\n;
+OS  return Select_  getLegalCName(OpName) 
_iPTR(N);\n;
+  }
   OSbreak;\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

2006-11-14 Thread Chris Lattner


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::mapstd::string, std::vectorstd::string ::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 @@
 OSif (NVT == TLI.getPointerTy())\n;
 OS  return Select_  getLegalCName(OpName) 
_iPTR(N);\n;
   }
+  if (HasDefaultPattern) {
+OSreturn Select_  getLegalCName(OpName)  (N);\n;
+  }
   OSbreak;\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

2006-11-08 Thread Evan Cheng


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

2006-11-08 Thread Evan Cheng


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::mapRecord*, std::vectorPatternToMatch*,
-CompareByRecordName PatternsByOpcode;
+  std::mapstd::string, std::vectorPatternToMatch*  PatternsByOpcode;
   // All unique target node emission functions.
   std::mapstd::string, unsigned 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_castIntInit*(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::vectorRecord* 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::mapRecord*, std::vectorPatternToMatch*,
-   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::mapstd::string, std::vectorPatternToMatch* ::iterator
+ PBOI = PatternsByOpcode.begin(), E = PatternsByOpcode.end();
+   PBOI != E; ++PBOI) {
+const std::string OpName = PBOI-first;
 std::vectorPatternToMatch* 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::mapMVT::ValueType, std::vectorPatternToMatch* ::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 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp Record.cpp SubtargetEmitter.cpp

2006-11-02 Thread Reid Spencer


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_castIntInit*(Node-getLeafValue())) {
+  if (dynamic_castIntInit*(Node-getLeafValue())) {
 PatternsByOpcode[getSDNodeNamed(imm)].push_back(PatternsToMatch[i]);
-  } else if ((CP = NodeGetComplexPattern(Node, *this))) {
+  } else if (NodeGetComplexPattern(Node, *this)) {
 std::vectorRecord* 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_castRecordRecTy*(getType()))
+  if (dynamic_castRecordRecTy*(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::vectorInstrItinerary 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

2006-11-02 Thread Reid Spencer


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_castIntInit*(Node-getLeafValue())) {
+  if (IntInit *II = 
+  dynamic_castIntInit*(Node-getLeafValue())) {
 PatternsByOpcode[getSDNodeNamed(imm)].push_back(PatternsToMatch[i]);
-  } else if (NodeGetComplexPattern(Node, *this)) {
+  } else if ((CP = NodeGetComplexPattern(Node, *this))) {
 std::vectorRecord* 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

2006-11-02 Thread Chris Lattner


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_castIntInit*(Node-getLeafValue())) {
+  if (dynamic_castIntInit*(Node-getLeafValue())) {
 PatternsByOpcode[getSDNodeNamed(imm)].push_back(PatternsToMatch[i]);
   } else if ((CP = NodeGetComplexPattern(Node, *this))) {
 std::vectorRecord* 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

2006-10-31 Thread Evan Cheng


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::vectorSDOperand 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::vectorMVT::ValueType 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

2006-10-16 Thread Evan Cheng


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, castConstantSDNode( +
 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;
-  Emitter.EmitMatchCode(Pattern.getSrcPattern(), 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-10-14 Thread Evan Cheng


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, castConstantSDNode( +
 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

2006-10-12 Thread Evan Cheng


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 @@
   OSRemoveKilled();\n;
   OS  }\n\n;
 
-  OS  void DeleteNode(SDNode *N) {\n;
-  OSCurDAG-DeleteNode(N);\n;
-  OSfor (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;
-  OSDeleteNode(Operand);\n;
-  OS}\n;
-  OS  }\n;
-
   OS  // SelectRoot - Top level entry to DAG isel.\n;
   OS  SDOperand SelectRoot(SDOperand Root) {\n;
   OSSelectRootInit();\n;
@@ -3774,8 +3764,10 @@
   OSif (ResNode != Node) {\n;
   OS  if (ResNode)\n;
   OSReplaceUses(Node, ResNode);\n;
-  OS  if (Node-use_empty()) // Don't delete EntryToken, etc.\n;
-  OSDeleteNode(Node);\n;
+  OS  if (Node-use_empty()) { // Don't delete EntryToken, etc.\n;
+  OSCurDAG-RemoveDeadNode(Node, ISelKilled);\n;
+  OSRemoveKilled();\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

2006-10-12 Thread Evan Cheng


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 @@
   OSif (NumKilled) {\n;
   OS  for (unsigned i = 0; i != NumKilled; ++i) {\n;
   OSSDNode *Temp = ISelKilled[i];\n;
-  OSstd::remove(ISelQueue.begin(), ISelQueue.end(), Temp);\n;
+  OSISelQueue.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

2006-10-11 Thread Evan Cheng


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::mapstd::string, Record* OperatorMap;
   // Names of all the folded nodes which produce chains.
   std::vectorstd::pairstd::string, unsigned  FoldedChains;
+  // Original input chain(s).
+  std::vectorstd::pairstd::string, std::string  OrigChains;
   std::setstd::string 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(SmallVectorSDOperand, 8 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::vectorstd::string AllOps;
   for (unsigned i = 0, e = N-getNumChildren(); i != e; ++i) {
 std::vectorstd::string Ops = EmitResultCode(N-getChild(i),
@@ -3647,6 +3672,21 @@
   OS  /// Dummy parameter to ReplaceAllUsesOfValueWith().\n
   std::vectorSDNode* 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;
+  OSif (Chain-getOpcode() == ISD::EntryToken)\n;
+  OS  return true;\n;
+  OSelse if (Chain-getOpcode() == ISD::TokenFactor)\n;
+  OS  return false;\n;
+  OSelse if (Chain-getNumOperands()  0) {\n;
+  OS  SDOperand C0 = Chain-getOperand(0);\n;
+  OS  if (C0.getValueType() == MVT::Other)\n;
+  OSreturn C0.Val != Op  IsChainCompatible(C0.Val, Op);\n;
+  OS}\n;
+  OSreturn true;\n;
+  OS  }\n;
+
   OS  /// Sorting functions for the selection queue.\n
   struct isel_sort : public std::binary_function
   SDNode*, SDNode*, bool {\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

2006-10-10 Thread Chris Lattner


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 algorithm
 #include set
 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_castDefInit*(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 SRCVALUE nodes. Nothing to do here.
-  } else if 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-10-10 Thread Chris Lattner


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_castIntInit*(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(isaConstantSDNode( + RootName + 1));
+  const char *MaskPredicate = N-getOperator()-getName() == or
+? CheckOrMask( : CheckAndMask(;
+  emitCheck(MaskPredicate + RootName + 0, castConstantSDNode( +
+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

2006-10-09 Thread Evan Cheng


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

2006-09-21 Thread Chris Lattner


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_castIntInit*(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

2006-09-19 Thread Evan Cheng


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

2006-09-19 Thread Evan Cheng


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_castIntInit*(Child-getLeafValue())) {
   emitCheck(isaConstantSDNode( + 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 FileLexer.cpp.cvs FileLexer.l FileLexer.l.cvs

2006-09-18 Thread Chris Lattner


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_castIntInit*(Child-getLeafValue())) {
+  if (II-getValue() == 2147483647)
+std::cerr  HERE!\n;
   emitCheck(isaConstantSDNode( + RootName + utostr(OpNo) + ));
   unsigned CTmp = TmpNo++;
   emitCode(int64_t CN+utostr(CTmp)+ = castConstantSDNode(+


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

2006-09-18 Thread Chris Lattner


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_castIntInit*(Child-getLeafValue())) {
-  if (II-getValue() == 2147483647)
-std::cerr  HERE!\n;
   emitCheck(isaConstantSDNode( + RootName + utostr(OpNo) + ));
   unsigned CTmp = TmpNo++;
   emitCode(int64_t CN+utostr(CTmp)+ = castConstantSDNode(+



___
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

2006-09-18 Thread Chris Lattner


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

2006-09-14 Thread Chris Lattner


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

2006-09-10 Thread Evan Cheng


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 @@
   OSRemoveKilled();\n;
   OS  }\n\n;
 
+  OS  void DeleteNode(SDNode *N) {\n;
+  OSCurDAG-DeleteNode(N);\n;
+  OSfor (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;
+  OSDeleteNode(Operand);\n;
+  OS}\n;
+  OS  }\n;
+
   OS  // SelectRoot - Top level entry to DAG isel.\n;
   OS  SDOperand SelectRoot(SDOperand Root) {\n;
   OSSelectRootInit();\n;
@@ -3649,7 +3641,12 @@
   OS  ISelQueue.pop_back();\n;
   OS  if (!isSelected(Node-getNodeId())) {\n;
   OSSDNode *ResNode = Select(SDOperand(Node, 0));\n;
-  OSif (ResNode  ResNode != Node) ReplaceUses(Node, ResNode);\n;
+  OSif (ResNode != Node) {\n;
+  OS  if (ResNode)\n;
+  OSReplaceUses(Node, ResNode);\n;
+  OS  if (Node-use_empty()) // Don't delete EntryToken, etc.\n;
+  OSDeleteNode(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

2006-09-08 Thread Evan Cheng


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_castIntInit*(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_castIntInit*(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

2006-08-27 Thread Chris Lattner


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::vectorstd::string::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::vectorSDNode* ISelQueue;\n;
@@ -3603,7 +3598,7 @@
   OSreturn 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;
   OSint Id = N.Val-getNodeId();\n;
   OSif (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;
   OSCurDAG-ReplaceAllUsesOfValueWith(F, T, ISelKilled);\n;
   OSsetSelected(F.Val-getNodeId());\n;
   OSRemoveKilled();\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

2006-08-26 Thread Evan Cheng


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 DAGISelEmitter.h

2006-08-25 Thread Evan Cheng


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::vectorstd::pairstd::string, unsigned  FoldedChains;
   std::setstd::string 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::vectorstd::pairbool, std::string  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::vectorstd::pairunsigned, std::string  GeneratedCode;
   /// GeneratedDecl - This is the set of all SDOperand declarations needed for
   /// the set of patterns for each top-level opcode.
   std::setstd::pairunsigned, std::string  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::vectorstd::pairbool, std::string  gc,
+ std::vectorstd::pairunsigned, std::string  gc,
  std::setstd::pairunsigned, std::string  gd,
  std::vectorstd::string to,
  std::vectorstd::string 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) {
+ 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-08-16 Thread Evan Cheng


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

2006-08-15 Thread Chris Lattner


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;
   OSSDNode *ResNode = Select(Tmp, SDOperand(Node, 0));\n;
-  OSif (ResNode) ReplaceUses(Node, ResNode);\n;
+  OSif (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

2006-08-15 Thread Chris Lattner


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 @@
   OSmemset(ISelQueued,   0, NumBytes);\n;
   OSmemset(ISelSelected, 0, NumBytes);\n;
   OS  \n;
-  OSSDOperand ResNode;\n;
-  OSSelect(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;
   OSwhile (!ISelQueue.empty()) {\n;
   OS  SDOperand Tmp;\n;
   OS  SDNode *Node = ISelQueue.front();\n;
@@ -3663,7 +3666,7 @@
   OSISelQueued = NULL;\n;
   OSdelete[] ISelSelected;\n;
   OSISelSelected = NULL;\n;
-  OSreturn ResNode;\n;
+  OSreturn 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

2006-08-11 Thread Evan Cheng


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::pairunsigned, unsigned
-  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::pairunsigned, unsigned NumTemp =  EmitResultCode(Child);
+std::pairunsigned, unsigned 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.
-  emitCode(if (N.ResNo   + 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-08-11 Thread Evan Cheng


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::vectorSDOperand Ops;);
+emitCode(SmallVectorSDOperand, 8 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

2006-08-09 Thread Tanya Lattner


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_castDefInit*(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::vectorstd::pairstd::string, unsigned  FoldedChains;
   std::setstd::string Duplicates;
+  /// These nodes are being marked in-flight so they cannot be folded.
+  std::vectorstd::string 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::vectorstd::string TargetVTs;
 
   std::string ChainName;
+  bool DoReplace;
   unsigned TmpNo;
   unsigned OpcNo;
   unsigned VTNo;
@@ -2164,10 +2154,11 @@
  std::vectorstd::pairbool, std::string  gc,
  std::setstd::pairunsigned, std::string  gd,
  std::vectorstd::string to,
- std::vectorstd::string tv)
+ std::vectorstd::string 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 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-08-09 Thread Chris Lattner


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_castDefInit*(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::vectorstd::pairstd::string, unsigned  FoldedChains;
   std::setstd::string Duplicates;
-  /// These nodes are being marked in-flight so they cannot be folded.
-  std::vectorstd::string 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::vectorstd::string TargetVTs;
 
   std::string ChainName;
-  bool DoReplace;
   unsigned TmpNo;
   unsigned OpcNo;
   unsigned VTNo;
@@ -2154,11 +2164,10 @@
  std::vectorstd::pairbool, std::string  gc,
  std::setstd::pairunsigned, std::string  gd,
  std::vectorstd::string to,
- std::vectorstd::string tv,
- bool dorep)
+ std::vectorstd::string 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, 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-08-07 Thread Chris Lattner


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::vectorMVT::ValueType 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

2006-08-02 Thread Chris Lattner


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

2006-08-02 Thread Chris Lattner


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

2006-07-31 Thread Evan Cheng


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_castDefInit*(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

2006-07-31 Thread Evan Cheng


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) {
 OSif (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

2006-07-28 Thread Evan Cheng


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::mapstd::string, std::vectorstd::string  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::vectorPatternToMatch* Patterns = PBOI-second;
-assert(!Patterns.empty()  No patterns but map has entry?);
-
+std::vectorPatternToMatch* 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::vectorstd::pairbool, std::string  CodeList;
-typedef std::vectorstd::pairbool, std::string ::iterator CodeListI;
-
-std::vectorstd::pairPatternToMatch*, CodeList  CodeForPatterns;
-std::vectorstd::vectorstd::string  PatternOpcodes;
-std::vectorstd::vectorstd::string  PatternVTs;
-std::vectorstd::setstd::pairunsigned, std::string   PatternDecls;
-std::setstd::pairunsigned, std::string  AllGenDecls;
-for (unsigned i = 0, e = Patterns.size(); i != e; ++i) {
-  CodeList GeneratedCode;
-  std::setstd::pairunsigned, std::string  GeneratedDecl;
-  std::vectorstd::string TargetOpcodes;
-  std::vectorstd::string TargetVTs;
-  GenerateCodeForPattern(*Patterns[i], GeneratedCode, GeneratedDecl,
- TargetOpcodes, TargetVTs, OptSlctOrder);
-  for (std::setstd::pairunsigned, std::string ::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::mapMVT::ValueType, std::vectorPatternToMatch*  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::mapMVT::ValueType, std::vectorPatternToMatch* ::iterator TI = 
+PatternsByType.find(VT);
+  if (TI != PatternsByType.end())
+TI-second.push_back(Pat);
+  else {
+std::vectorPatternToMatch* PVec;
+PVec.push_back(Pat);
+PatternsByType.insert(std::make_pair(VT, PVec));
+  }
 }
+
+for (std::mapMVT::ValueType, std::vectorPatternToMatch* ::iterator
+   II = PatternsByType.begin(), EE = PatternsByType.end(); II != EE;
+ ++II) {
+  MVT::ValueType OpVT = II-first;
+  std::vectorPatternToMatch* Patterns = II-second;
+  typedef std::vectorstd::pairbool, std::string  CodeList;
+  typedef std::vectorstd::pairbool, std::string ::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) {
-  

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-07-27 Thread Evan Cheng


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

2006-07-27 Thread Evan Cheng


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::vectorstd::pairstd::string, unsigned  FoldedChains;
   std::setstd::string Duplicates;
-  /// These nodes are being marked in-flight so they cannot be folded.
-  std::vectorstd::string 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::vectorstd::string::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::vectorstd::pairunsigned, unsigned  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::vectorstd::string::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::mapSDOperand, SDOperand ReplaceMap;\n;
-  OS  // Keep track of nodes that are currently being selecte and 
therefore\n
-  // should not be folded.\n;
-  OS  std::setSDNode* 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

2006-07-27 Thread Evan Cheng


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

2006-07-26 Thread Evan Cheng


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::mapSDOperand, SDOperand 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

2006-07-21 Thread Evan Cheng


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::vectorstd::string 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;
-  OSOldTF = NULL;\n;
-  OSif (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::mapSDOperand, SDOperand::iterator CGMI = 
-  CodeGenMap.find(Ch);\n;
-  OS  if (CGMI != CodeGenMap.end())\n;
-  OSreturn SDOperand(0, 0);\n;
-  OS  OldTF = Chain;\n;
-  OS  std::vectorSDOperand Ops;\n;
-  OS  for (unsigned i = 0; i  Chain-getNumOperands(); ++i) {\n;
-  OSSDOperand Op = Chain-getOperand(i);\n;
-  OSif (Op.Val == N)\n;
-  OS  Ops.push_back(N-getOperand(0));\n;
-  OSelse\n;
-  OS  Ops.push_back(Op);\n;
-  OS  }\n;
-  OS  return DAG-getNode(ISD::TokenFactor, MVT::Other, Ops);\n;
-  OS}\n;
-  OSreturn SDOperand(0, 0);\n;
-  OS  }\n;
-
-  OS  \n;
   OS  // SelectRoot - Top level entry to DAG isel.\n;
   OS  SDOperand SelectRoot(SDOperand N) {\n;
   OSSDOperand 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

2006-07-20 Thread Evan Cheng


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

2006-07-18 Thread Evan Cheng


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

2006-07-11 Thread Jim Laskey


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_castDefInit*(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(castCondCodeSDNode( + 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

2006-07-11 Thread Jim Laskey


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_castDefInit*(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(castCondCodeSDNode( + 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

2006-06-19 Thread Chris Lattner


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

2006-06-19 Thread Chris Lattner


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

2006-06-16 Thread Chris Lattner


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

2006-06-14 Thread Evan Cheng


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

2006-06-09 Thread Chris Lattner


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;
   OSSDNode *Use = *UI;\n;
   OSstd::vectorSDOperand Ops;\n;
-  OSfor (unsigned i = 0, e = Use-getNumOperands(); i != e; ++i) 
{\n;
+  OSfor (unsigned i = 0, e = Use-getNumOperands(); i != e; 
++i){\n;
   OS  SDOperand O = Use-getOperand(i);\n;
   OS  if (O.Val == From.Val)\n;
   OSOps.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

2006-05-25 Thread Evan Cheng


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 @@
   OSif (found || !Visited.insert(Use).second) return;\n;
   OSfor (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;
-  OSif (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;
+  OSfindNonImmUse(N, Def, found, Visited);\n;
+  OS  } else {\n;
+  OSfound = true;\n;
+  OSbreak;\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

2006-05-24 Thread Evan Cheng


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::vectorstd::string::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::vectorstd::pairunsigned, unsigned  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::vectorstd::pairunsigned, unsigned  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

2006-05-19 Thread Evan Cheng


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

2006-05-12 Thread Evan Cheng


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

2006-04-28 Thread Evan Cheng


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

2006-04-27 Thread Evan Cheng


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::vectorstd::pairstd::string, unsigned  FoldedChains;
   std::setstd::string Duplicates;
+  /// These nodes are being marked in-flight so they cannot be folded.
+  std::vectorstd::string 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::vectorstd::pairunsigned, unsigned  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::pairunsigned, unsigned 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::vectorstd::string::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::mapSDOperand, SDOperand ReplaceMap;\n;
+  OS  // Keep track of nodes that are currently being selecte and 
therefore\n
+  // should not be folded.\n;
+  OS  std::setSDNode* 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

2006-04-22 Thread Nate Begeman


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

2006-04-19 Thread Evan Cheng


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



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h

2006-04-19 Thread Evan Cheng


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.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-04-06 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.192 - 1.193
---
Log message:

rename a method, to avoid confusion with llvm intrinsics.


---
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.192 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.193
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.192Thu Mar 30 23:25:56 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Thu Apr  6 15:19:52 2006
@@ -542,11 +542,11 @@
   return FragTree;
 }
 
-/// getIntrinsicType - Check to see if the specified record has an intrinsic
+/// getImplicitType - Check to see if the specified record has an implicit
 /// type which should be applied to it.  This infer the type of register
 /// references from the register file information, for example.
 ///
-static std::vectorunsigned char getIntrinsicType(Record *R, bool 
NotRegisters,
+static std::vectorunsigned char getImplicitType(Record *R, bool NotRegisters,
   TreePattern TP) {
   // Some common return values
   std::vectorunsigned char Unknown(1, MVT::isUnknown);
@@ -598,8 +598,7 @@
   if (isLeaf()) {
 if (DefInit *DI = dynamic_castDefInit*(getLeafValue())) {
   // If it's a regclass or something else known, include the type.
-  return UpdateNodeType(getIntrinsicType(DI-getDef(), NotRegisters, TP),
-TP);
+  return UpdateNodeType(getImplicitType(DI-getDef(), NotRegisters, 
TP),TP);
 } else if (IntInit *II = dynamic_castIntInit*(getLeafValue())) {
   // Int inits are always integers. :)
   bool MadeChange = UpdateNodeType(MVT::isInt, TP);



___
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

2006-04-06 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.193 - 1.194
---
Log message:

Infer element types for shuffle masks


---
Diffs of the changes:  (+20 -0)

 DAGISelEmitter.cpp |   20 
 1 files changed, 20 insertions(+)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.193 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.194
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.193Thu Apr  6 15:19:52 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Thu Apr  6 15:36:51 2006
@@ -672,6 +672,26 @@
 // must have void types.
 if (NI.getNumResults() == 0)
   MadeChange |= UpdateNodeType(MVT::isVoid, TP);
+
+// If this is a vector_shuffle operation, apply types to the build_vector
+// operation.  The types of the integers don't matter, but this ensures 
they
+// won't get checked.
+if (getOperator()-getName() == vector_shuffle 
+getChild(2)-getOperator()-getName() == build_vector) {
+  TreePatternNode *BV = getChild(2);
+  const std::vectorMVT::ValueType LegalVTs
+= ISE.getTargetInfo().getLegalValueTypes();
+  MVT::ValueType LegalIntVT = MVT::Other;
+  for (unsigned i = 0, e = LegalVTs.size(); i != e; ++i)
+if (MVT::isInteger(LegalVTs[i])  !MVT::isVector(LegalVTs[i])) {
+  LegalIntVT = LegalVTs[i];
+  break;
+}
+  assert(LegalIntVT != MVT::Other  No legal integer VT?);
+
+  for (unsigned i = 0, e = BV-getNumChildren(); i != e; ++i)
+MadeChange |= BV-getChild(i)-UpdateNodeType(LegalIntVT, TP);
+}
 return MadeChange;  
   } else if (getOperator()-isSubClassOf(Instruction)) {
 const DAGInstruction Inst = ISE.getInstruction(getOperator());



___
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 FileParser.y Record.h Record.cpp

2006-03-30 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.190 - 1.191
FileParser.y updated: 1.40 - 1.41
Record.h updated: 1.55 - 1.56
Record.cpp updated: 1.51 - 1.52
---
Log message:

Implement Regression/TableGen/DagDefSubst.ll


---
Diffs of the changes:  (+45 -41)

 DAGISelEmitter.cpp |   11 +++
 FileParser.y   |   49 -
 Record.cpp |8 +---
 Record.h   |   18 +-
 4 files changed, 45 insertions(+), 41 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.190 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.191
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.190Mon Mar 27 18:41:33 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Thu Mar 30 16:50:40 2006
@@ -804,7 +804,9 @@
 }
 
 TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
-  Record *Operator = Dag-getNodeType();
+  DefInit *OpDef = dynamic_castDefInit*(Dag-getOperator());
+  if (!OpDef) error(Pattern has unexpected operator type!);
+  Record *Operator = OpDef-getDef();
   
   if (Operator-isSubClassOf(ValueType)) {
 // If the operator is a ValueType, then this must be type cast of a leaf
@@ -817,7 +819,7 @@
 if (DefInit *DI = dynamic_castDefInit*(Arg)) {
   Record *R = DI-getDef();
   if (R-isSubClassOf(SDNode) || R-isSubClassOf(PatFrag)) {
-Dag-setArg(0, new DagInit(R,
+Dag-setArg(0, new DagInit(DI,
 std::vectorstd::pairInit*, std::string 
()));
 return ParseTreePattern(Dag);
   }
@@ -866,7 +868,7 @@
   // Direct reference to a leaf DagNode or PatFrag?  Turn it into a
   // TreePatternNode if its own.
   if (R-isSubClassOf(SDNode) || R-isSubClassOf(PatFrag)) {
-Dag-setArg(i, new DagInit(R,
+Dag-setArg(i, new DagInit(DefI,
   std::vectorstd::pairInit*, std::string ()));
 --i;  // Revisit this node...
   } else {
@@ -1043,7 +1045,8 @@
 
 // Parse the operands list.
 DagInit *OpsList = Fragments[i]-getValueAsDag(Operands);
-if (OpsList-getNodeType()-getName() != ops)
+DefInit *OpsOp = dynamic_castDefInit*(OpsList-getOperator());
+if (!OpsOp || OpsOp-getDef()-getName() != ops)
   P-error(Operands list should start with '(ops ... '!);
 
 // Copy over the arguments.   


Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.40 
llvm/utils/TableGen/FileParser.y:1.41
--- llvm/utils/TableGen/FileParser.y:1.40   Tue Jan 31 00:02:35 2006
+++ llvm/utils/TableGen/FileParser.yThu Mar 30 16:50:40 2006
@@ -210,7 +210,7 @@
 %type SubClassRef  SubClassRef
 %type SubClassList ClassList ClassListNE
 %type IntVal   OptPrefix
-%type Initializer  Value OptValue
+%type Initializer  Value OptValue IDValue
 %type DagValueList DagArgList DagArgListNE
 %type FieldListValueList ValueListNE
 %type BitList  BitList OptBitList RBitList
@@ -253,7 +253,26 @@
 
 OptValue : /*empty*/ { $$ = 0; } | '=' Value { $$ = $2; };
 
-Value : INTVAL {
+IDValue : ID {
+  if (const RecordVal *RV = (CurRec ? CurRec-getValue(*$1) : 0)) {
+$$ = new VarInit(*$1, RV-getType());
+  } else if (CurRec  CurRec-isTemplateArg(CurRec-getName()+:+*$1)) {
+const RecordVal *RV = CurRec-getValue(CurRec-getName()+:+*$1);
+assert(RV  Template arg doesn't exist??);
+$$ = new VarInit(CurRec-getName()+:+*$1, RV-getType());
+  } else if (Record *D = Records.getDef(*$1)) {
+$$ = new DefInit(D);
+  } else {
+err()  Variable not defined: '  *$1  '!\n;
+exit(1);
+  }
+  
+  delete $1;
+};
+
+Value : IDValue {
+$$ = $1;
+  } | INTVAL {
 $$ = new IntInit($1);
   } | STRVAL {
 $$ = new StringInit(*$1);
@@ -304,21 +323,6 @@
 
 // Restore the old CurRec
 CurRec = OldRec;
-  } | ID {
-if (const RecordVal *RV = (CurRec ? CurRec-getValue(*$1) : 0)) {
-  $$ = new VarInit(*$1, RV-getType());
-} else if (CurRec  CurRec-isTemplateArg(CurRec-getName()+:+*$1)) {
-  const RecordVal *RV = CurRec-getValue(CurRec-getName()+:+*$1);
-  assert(RV  Template arg doesn't exist??);
-  $$ = new VarInit(CurRec-getName()+:+*$1, RV-getType());
-} else if (Record *D = Records.getDef(*$1)) {
-  $$ = new DefInit(D);
-} else {
-  err()  Variable not defined: '  *$1  '!\n;
-  exit(1);
-}
-
-delete $1;
   } | Value '{' BitList '}' {
 $$ = $1-convertInitializerBitRange(*$3);
 if ($$ == 0) {
@@ -336,14 +340,9 @@
 }
 $$ = new FieldInit($1, *$3);
 delete $3;
-  } | '(' ID DagArgList ')' {
-Record *D = Records.getDef(*$2);
-if (D == 0) {
-  err()  Invalid def '  *$2  '!\n;
-  exit(1);
-}
-$$ = new DagInit(D, *$3);
-delete $2; delete $3;
+  } | '(' IDValue DagArgList ')' {
+$$ = new DagInit($2, *$3);
+delete $3;
   } | Value '[' BitList ']' {
 std::reverse($3-begin(), $3-end());
 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-03-30 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.191 - 1.192
---
Log message:

Allow bits init values to be used in patterns, turn them into ints.


---
Diffs of the changes:  (+19 -0)

 DAGISelEmitter.cpp |   19 +++
 1 files changed, 19 insertions(+)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.191 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.192
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.191Thu Mar 30 16:50:40 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Thu Mar 30 23:25:56 2006
@@ -830,6 +830,15 @@
   New = new TreePatternNode(II);
   if (!Dag-getArgName(0).empty())
 error(Constant int argument should not have a name!);
+} else if (BitsInit *BI = dynamic_castBitsInit*(Arg)) {
+  // Turn this into an IntInit.
+  Init *II = BI-convertInitializerTo(new IntRecTy());
+  if (II == 0 || !dynamic_castIntInit*(II))
+error(Bits value must be constants!);
+  
+  New = new TreePatternNode(dynamic_castIntInit*(II));
+  if (!Dag-getArgName(0).empty())
+error(Constant int argument should not have a name!);
 } else {
   Arg-dump();
   error(Unknown leaf value for tree pattern!);
@@ -888,6 +897,16 @@
   if (!Dag-getArgName(i).empty())
 error(Constant int argument should not have a name!);
   Children.push_back(Node);
+} else if (BitsInit *BI = dynamic_castBitsInit*(Arg)) {
+  // Turn this into an IntInit.
+  Init *II = BI-convertInitializerTo(new IntRecTy());
+  if (II == 0 || !dynamic_castIntInit*(II))
+error(Bits value must be constants!);
+  
+  TreePatternNode *Node = new TreePatternNode(dynamic_castIntInit*(II));
+  if (!Dag-getArgName(i).empty())
+error(Constant int argument should not have a name!);
+  Children.push_back(Node);
 } else {
   std::cerr  '';
   Arg-dump();



___
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

2006-03-27 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.189 - 1.190
---
Log message:

Tblgen doesn't like multiple SDNode definitions that map to the sameenum 
value.  Split them into separate enums.

Also, don't emit dynamic checks when we can compute them statically


---
Diffs of the changes:  (+17 -13)

 DAGISelEmitter.cpp |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.189 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.190
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.189Mon Mar 27 16:21:18 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Mon Mar 27 18:41:33 2006
@@ -3115,19 +3115,21 @@
 
 // If the last pattern has predicates (which could fail) emit code to catch
 // the case where nothing handles a pattern.
-if (mightNotMatch)
-  OSstd::cerr  \Cannot yet select: \;\n
-if (N.getOpcode() != ISD::INTRINSIC) {\n
-  N.Val-dump(CurDAG);\n
-} else {\n
-  unsigned iid = castConstantSDNode(N.getOperand(
- N.getOperand(0).getValueType() == 
MVT::Other))-getValue();\n
-  std::cerr  \intrinsic %\ 
-   Intrinsic::getName((Intrinsic::ID)iid);\n
-}\n
-std::cerr  '\\n';\n
+if (mightNotMatch) {
+  OSstd::cerr  \Cannot yet select: \;\n;
+  if (OpcodeInfo.getEnumName() != ISD::INTRINSIC_W_CHAIN 
+  OpcodeInfo.getEnumName() != ISD::INTRINSIC_WO_CHAIN 
+  OpcodeInfo.getEnumName() != ISD::INTRINSIC_VOID) {
+OSN.Val-dump(CurDAG);\n;
+  } else {
+OSunsigned iid = castConstantSDNode(N.getOperand(
+   N.getOperand(0).getValueType() == MVT::Other))-getValue();\n
+  std::cerr  \intrinsic %\ 
+ Intrinsic::getName((Intrinsic::ID)iid);\n;
+  }
+  OSstd::cerr  '\\n';\n
 abort();\n;
-
+}
 OS  }\n\n;
   }
   
@@ -3285,7 +3287,9 @@
 
   OS} // end of big switch.\n\n
 std::cerr  \Cannot yet select: \;\n
-if (N.getOpcode() != ISD::INTRINSIC) {\n
+if (N.getOpcode() != ISD::INTRINSIC_W_CHAIN \n
+N.getOpcode() != ISD::INTRINSIC_WO_CHAIN \n
+N.getOpcode() != ISD::INTRINSIC_VOID) {\n
   N.Val-dump(CurDAG);\n
 } else {\n
   unsigned iid = castConstantSDNode(N.getOperand(



___
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

2006-03-24 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.183 - 1.184
DAGISelEmitter.h updated: 1.59 - 1.60
---
Log message:

Parse intrinsics correctly and perform type propagation.  This doesn't currently
emit the code to select intrinsics, but that is next :)


---
Diffs of the changes:  (+49 -3)

 DAGISelEmitter.cpp |   43 ---
 DAGISelEmitter.h   |9 +
 2 files changed, 49 insertions(+), 3 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.183 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.184
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.183Wed Mar 22 20:35:32 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Fri Mar 24 15:48:51 2006
@@ -691,6 +691,25 @@
   MadeChange |= getChild(i)-ApplyTypeConstraints(TP, NotRegisters);
 }
 return MadeChange;
+  } else if (getOperator()-isSubClassOf(Intrinsic)) {
+const CodeGenIntrinsic Int = 
+  TP.getDAGISelEmitter().getIntrinsic(getOperator());
+// FIXME: get type information! 
+bool MadeChange = false;
+
+// Apply the result type to the node.
+MadeChange = UpdateNodeType(Int.ArgVTs[0], TP);
+
+if (getNumChildren() != Int.ArgVTs.size()-1)
+  TP.error(Intrinsic ' + getOperator()-getName() +  expects  +
+   utostr(Int.ArgVTs.size()-1) +  operands, not  +
+   utostr(getNumChildren()) +  operands!);
+for (unsigned i = 0, e = getNumChildren(); i != e; ++i) {
+  MVT::ValueType OpVT = Int.ArgVTs[i+1];
+  MadeChange |= getChild(i)-UpdateNodeType(OpVT, TP);
+  MadeChange |= getChild(i)-ApplyTypeConstraints(TP, NotRegisters);
+}
+return MadeChange;
   } else {
 assert(getOperator()-isSubClassOf(SDNodeXForm)  Unknown node type!);
 
@@ -723,6 +742,13 @@
 if (!getChild(i)-canPatternMatch(Reason, ISE))
   return false;
 
+  // If this is an intrinsic, handle cases that would make it not match.  For
+  // example, if an operand is required to be an immediate.
+  if (getOperator()-isSubClassOf(Intrinsic)) {
+// TODO:
+return true;
+  }
+  
   // If this node is a commutative operator, check that the LHS isn't an
   // immediate.
   const SDNodeInfo NodeInfo = ISE.getSDNodeInfo(getOperator());
@@ -811,6 +837,7 @@
   if (!Operator-isSubClassOf(PatFrag)  !Operator-isSubClassOf(SDNode) 

   !Operator-isSubClassOf(Instruction)  
   !Operator-isSubClassOf(SDNodeXForm) 
+  !Operator-isSubClassOf(Intrinsic) 
   Operator-getName() != set)
 error(Unrecognized node ' + Operator-getName() + '!);
   
@@ -1592,10 +1619,13 @@
   }
 
   // Look up interesting info about the node.
-  const SDNodeInfo NodeInfo = ISE.getSDNodeInfo(N-getOperator());
+  const SDNodeInfo *NodeInfo = 0;
+  
+  if (!N-getOperator()-isSubClassOf(Intrinsic))
+NodeInfo = ISE.getSDNodeInfo(N-getOperator());
 
   // If this node is associative, reassociate.
-  if (NodeInfo.hasProperty(SDNodeInfo::SDNPAssociative)) {
+  if (NodeInfo  NodeInfo-hasProperty(SDNodeInfo::SDNPAssociative)) {
 // Reassociate by pulling together all of the linked operators 
 std::vectorTreePatternNode* MaximalChildren;
 GatherChildrenOfAssociativeOpcode(N, MaximalChildren);
@@ -1656,7 +1686,7 @@
   CombineChildVariants(N, ChildVariants, OutVariants, ISE);
 
   // If this node is commutative, consider the commuted order.
-  if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) {
+  if (NodeInfo  NodeInfo-hasProperty(SDNodeInfo::SDNPCommutative)) {
 assert(N-getNumChildren()==2 Commutative but doesn't have 2 
children!);
 // Consider the commuted order.
 CombineChildVariants(N, ChildVariants[1], ChildVariants[0],
@@ -2955,6 +2985,9 @@
   for (std::mapRecord*, std::vectorPatternToMatch*,
CompareByRecordName::iterator PBOI = PatternsByOpcode.begin(),
E = PatternsByOpcode.end(); PBOI != E; ++PBOI) {
+if (PBOI-first-isSubClassOf(Intrinsic))
+  continue;   // Skip intrinsics here.
+
 const std::string OpName = PBOI-first-getName();
 OS  void Select_  OpName  (SDOperand Result, SDOperand N) {\n;
 
@@ -3201,6 +3234,9 @@
   for (std::mapRecord*, std::vectorPatternToMatch*,
 CompareByRecordName::iterator PBOI = PatternsByOpcode.begin(),
E = PatternsByOpcode.end(); PBOI != E; ++PBOI) {
+if (PBOI-first-isSubClassOf(Intrinsic))
+  continue;
+
 const SDNodeInfo OpcodeInfo = getSDNodeInfo(PBOI-first);
 OScase   OpcodeInfo.getEnumName()  : 
 std::string(std::max(0, int(24-OpcodeInfo.getEnumName().size())), ' 
')
@@ -3363,6 +3399,7 @@
   OSreturn ResNode;\n;
   OS  }\n;
   
+  Intrinsics = LoadIntrinsics(Records);
   ParseNodeInfo();
   ParseNodeTransforms(OS);
   ParseComplexPatterns();


Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.59 
llvm/utils/TableGen/DAGISelEmitter.h:1.60
--- llvm/utils/TableGen/DAGISelEmitter.h:1.59   

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-03-24 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.184 - 1.185
---
Log message:

fix 80 column violations


---
Diffs of the changes:  (+6 -5)

 DAGISelEmitter.cpp |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.184 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.185
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.184Fri Mar 24 15:48:51 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Fri Mar 24 15:52:20 2006
@@ -1138,7 +1138,7 @@
 void DAGISelEmitter::
 FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat,
 std::mapstd::string, TreePatternNode* 
InstInputs,
-std::mapstd::string, TreePatternNode* 
InstResults,
+std::mapstd::string, 
TreePatternNode*InstResults,
 std::vectorRecord* InstImpInputs,
 std::vectorRecord* InstImpResults) {
   if (Pat-isLeaf()) {
@@ -2220,7 +2220,8 @@
   /// EmitResultCode - Emit the action for a pattern.  Now that it has matched
   /// we actually have to build a DAG!
   std::pairunsigned, unsigned
-  EmitResultCode(TreePatternNode *N, bool LikeLeaf = false, bool isRoot = 
false) {
+  EmitResultCode(TreePatternNode *N, bool LikeLeaf = false,
+ bool isRoot = false) {
 // This is something selected from the pattern we matched.
 if (!N-getName().empty()) {
   std::string Val = VariableMap[N-getName()];
@@ -3056,8 +3057,8 @@
 }
 
 // Print all declarations.
-for (std::setstd::pairbool, std::string ::iterator I = 
GeneratedDecl.begin(),
-   E = GeneratedDecl.end(); I != E; ++I)
+for (std::setstd::pairbool, std::string ::iterator
+ I = GeneratedDecl.begin(), E = GeneratedDecl.end(); I != E; ++I)
   if (I-first)
 OSSDNode *  I-second  ;\n;
   else
@@ -3226,7 +3227,7 @@
   }\n
   return;\n
 }\n
-case ISD::INLINEASM:   Select_INLINEASM(Result, N); 
return;\n;
+case ISD::INLINEASM:  Select_INLINEASM(Result, N); return;\n;
 
 
   // Loop over all of the case statements, emiting a call to each method we



___
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

2006-03-24 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.185 - 1.186
DAGISelEmitter.h updated: 1.60 - 1.61
---
Log message:

Change approach so that we get codegen for free for intrinsics.  With this,
intrinsics that don't take pointer arguments now work.  For example, we can 
compile this:

int test3( __m128d *A) {
  return _mm_movemask_pd(*A);
}
int test4( __m128 *A) {
  return _mm_movemask_ps(*A);
}

to this:

_test3:
movl 4(%esp), %eax
movapd (%eax), %xmm0
movmskpd %xmm0, %eax
ret
_test4:
movl 4(%esp), %eax
movaps (%eax), %xmm0
movmskps %xmm0, %eax
ret



---
Diffs of the changes:  (+94 -38)

 DAGISelEmitter.cpp |  105 +
 DAGISelEmitter.h   |   27 +
 2 files changed, 94 insertions(+), 38 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.185 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.186
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.185Fri Mar 24 15:52:20 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Fri Mar 24 17:10:39 2006
@@ -594,6 +594,7 @@
 /// change, false otherwise.  If a type contradiction is found, throw an
 /// exception.
 bool TreePatternNode::ApplyTypeConstraints(TreePattern TP, bool NotRegisters) 
{
+  DAGISelEmitter ISE = TP.getDAGISelEmitter();
   if (isLeaf()) {
 if (DefInit *DI = dynamic_castDefInit*(getLeafValue())) {
   // If it's a regclass or something else known, include the type.
@@ -636,8 +637,34 @@
 MadeChange |= getChild(1)-UpdateNodeType(getChild(0)-getExtTypes(), TP);
 MadeChange |= UpdateNodeType(MVT::isVoid, TP);
 return MadeChange;
+  } else if (getOperator() == ISE.get_intrinsic_void_sdnode() ||
+ getOperator() == ISE.get_intrinsic_w_chain_sdnode() ||
+ getOperator() == ISE.get_intrinsic_wo_chain_sdnode()) {
+unsigned IID = 
+dynamic_castIntInit*(getChild(0)-getLeafValue())-getValue();
+const CodeGenIntrinsic Int = ISE.getIntrinsicInfo(IID);
+bool MadeChange = false;
+
+// Apply the result type to the node.
+MadeChange = UpdateNodeType(Int.ArgVTs[0], TP);
+
+if (getNumChildren() != Int.ArgVTs.size())
+  TP.error(Intrinsic ' + getOperator()-getName() +  expects  +
+   utostr(Int.ArgVTs.size()-1) +  operands, not  +
+   utostr(getNumChildren()-1) +  operands!);
+
+// Apply type info to the intrinsic ID.
+MVT::ValueType PtrTy = ISE.getTargetInfo().getPointerType();
+MadeChange |= getChild(0)-UpdateNodeType(PtrTy, TP);
+
+for (unsigned i = 1, e = getNumChildren(); i != e; ++i) {
+  MVT::ValueType OpVT = Int.ArgVTs[i];
+  MadeChange |= getChild(i)-UpdateNodeType(OpVT, TP);
+  MadeChange |= getChild(i)-ApplyTypeConstraints(TP, NotRegisters);
+}
+return MadeChange;
   } else if (getOperator()-isSubClassOf(SDNode)) {
-const SDNodeInfo NI = TP.getDAGISelEmitter().getSDNodeInfo(getOperator());
+const SDNodeInfo NI = ISE.getSDNodeInfo(getOperator());
 
 bool MadeChange = NI.ApplyTypeConstraints(this, TP);
 for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
@@ -648,8 +675,7 @@
   MadeChange |= UpdateNodeType(MVT::isVoid, TP);
 return MadeChange;  
   } else if (getOperator()-isSubClassOf(Instruction)) {
-const DAGInstruction Inst =
-  TP.getDAGISelEmitter().getInstruction(getOperator());
+const DAGInstruction Inst = ISE.getInstruction(getOperator());
 bool MadeChange = false;
 unsigned NumResults = Inst.getNumResults();
 
@@ -664,7 +690,7 @@
  Operands should be register classes!);
 
   const CodeGenRegisterClass RC = 
-TP.getDAGISelEmitter().getTargetInfo().getRegisterClass(ResultNode);
+ISE.getTargetInfo().getRegisterClass(ResultNode);
   MadeChange = UpdateNodeType(ConvertVTs(RC.getValueTypes()), TP);
 }
 
@@ -677,7 +703,7 @@
   MVT::ValueType VT;
   if (OperandNode-isSubClassOf(RegisterClass)) {
 const CodeGenRegisterClass RC = 
-  TP.getDAGISelEmitter().getTargetInfo().getRegisterClass(OperandNode);
+  ISE.getTargetInfo().getRegisterClass(OperandNode);
 //VT = RC.getValueTypeNum(0);
 MadeChange 
|=getChild(i)-UpdateNodeType(ConvertVTs(RC.getValueTypes()),
  TP);
@@ -691,25 +717,6 @@
   MadeChange |= getChild(i)-ApplyTypeConstraints(TP, NotRegisters);
 }
 return MadeChange;
-  } else if (getOperator()-isSubClassOf(Intrinsic)) {
-const CodeGenIntrinsic Int = 
-  TP.getDAGISelEmitter().getIntrinsic(getOperator());
-// FIXME: get type information! 
-bool MadeChange = false;
-
-// Apply the result type to the node.
-MadeChange = UpdateNodeType(Int.ArgVTs[0], TP);
-
-if (getNumChildren() != Int.ArgVTs.size()-1)
-  TP.error(Intrinsic ' + getOperator()-getName() +  expects  +
-

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-03-22 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.182 - 1.183
---
Log message:

Allow result node to be a simple leaf node. This enable bitconvert patterns
like this:
def : Pat(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src);


---
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.182 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.183
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.182Tue Mar 21 14:44:17 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Wed Mar 22 20:35:32 2006
@@ -1459,8 +1459,10 @@
   }
   ResultNodeOperands.push_back(OpNode);
 }
-DstPattern = new TreePatternNode(Result-getOnlyTree()-getOperator(),
- ResultNodeOperands);
+DstPattern = Result-getOnlyTree();
+if (!DstPattern-isLeaf())
+  DstPattern = new TreePatternNode(DstPattern-getOperator(),
+   ResultNodeOperands);
 DstPattern-setTypes(Result-getOnlyTree()-getExtTypes());
 TreePattern Temp(Result-getRecord(), DstPattern, false, *this);
 Temp.InferAllTypes();
@@ -2191,7 +2193,6 @@
   EmitResultCode(TreePatternNode *N, bool LikeLeaf = false, bool isRoot = 
false) {
 // This is something selected from the pattern we matched.
 if (!N-getName().empty()) {
-  assert(!isRoot  Root of pattern cannot be a leaf!);
   std::string Val = VariableMap[N-getName()];
   assert(!Val.empty() 
  Variable referenced but not defined and not caught earlier!);
@@ -2276,13 +2277,17 @@
   emitCode(Tmp + utostr(ResNo) +  =  + Val + ;);
 else
   emitCode(Select(Tmp + utostr(ResNo) + ,  + Val + ););
+
+if (isRoot  N-isLeaf()) {
+  emitCode(Result = Tmp + utostr(ResNo) + ;);
+  emitCode(return;);
+}
   }
   // Add TmpResNo to VariableMap, so that we don't multiply select this
   // value if used multiple times by this pattern result.
   Val = Tmp+utostr(ResNo);
   return std::make_pair(NumRes, ResNo);
 }
-  
 if (N-isLeaf()) {
   // If this is an explicit register reference, handle it.
   if (DefInit *DI = dynamic_castDefInit*(N-getLeafValue())) {



___
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

2006-03-20 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.178 - 1.179
---
Log message:

It should be ok for a xform output type to be different from input type.

---
Diffs of the changes:  (+17 -5)

 DAGISelEmitter.cpp |   22 +-
 1 files changed, 17 insertions(+), 5 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.178 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.179
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.178Mon Mar 20 00:04:09 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Mon Mar 20 02:09:17 2006
@@ -694,14 +694,26 @@
   } else {
 assert(getOperator()-isSubClassOf(SDNodeXForm)  Unknown node type!);
 
-// Node transforms always take one operand, and take and return the same
-// type.
+// Node transforms always take one operand.
 if (getNumChildren() != 1)
   TP.error(Node transform ' + getOperator()-getName() +
' requires one operand!);
-bool MadeChange = UpdateNodeType(getChild(0)-getExtTypes(), TP);
-MadeChange |= getChild(0)-UpdateNodeType(getExtTypes(), TP);
-return MadeChange;
+unsigned char ExtType0 = getExtTypeNum(0);
+unsigned char ChildExtType0 = getChild(0)-getExtTypeNum(0);
+if (ExtType0 == MVT::isInt ||
+ExtType0 == MVT::isFP ||
+ExtType0 == MVT::isUnknown ||
+ChildExtType0 == MVT::isInt ||
+ChildExtType0 == MVT::isFP ||
+ChildExtType0 == MVT::isUnknown) {
+  // If either the output or input of the xform does not have exact
+  // type info. We assume they must be the same. Otherwise, it is perfectly
+  // legal to transform from one type to a completely different type.
+  bool MadeChange = UpdateNodeType(getChild(0)-getExtTypes(), TP);
+  MadeChange |= getChild(0)-UpdateNodeType(getExtTypes(), TP);
+  return MadeChange;
+}
+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

2006-03-20 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.179 - 1.180
---
Log message:

The node wrapped in PatLeaf should be treated as a leaf even if it isn't
one, i.e. don't select it.


---
Diffs of the changes:  (+11 -4)

 DAGISelEmitter.cpp |   15 +++
 1 files changed, 11 insertions(+), 4 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.179 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.180
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.179Mon Mar 20 02:09:17 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Mon Mar 20 16:53:06 2006
@@ -2175,7 +2175,7 @@
   /// EmitResultCode - Emit the action for a pattern.  Now that it has matched
   /// we actually have to build a DAG!
   std::pairunsigned, unsigned
-  EmitResultCode(TreePatternNode *N, bool isRoot = false) {
+  EmitResultCode(TreePatternNode *N, bool LikeLeaf = false, bool isRoot = 
false) {
 // This is something selected from the pattern we matched.
 if (!N-getName().empty()) {
   assert(!isRoot  Root of pattern cannot be a leaf!);
@@ -2257,7 +2257,12 @@
 TmpNo = ResNo + NumRes;
   } else {
 emitDecl(Tmp + utostr(ResNo));
-emitCode(Select(Tmp + utostr(ResNo) + ,  + Val + ););
+// This node, probably wrapped in a SDNodeXForms, behaves like a leaf
+// node even if it isn't one. Don't select it.
+if (LikeLeaf)
+  emitCode(Tmp + utostr(ResNo) +  =  + Val + ;);
+else
+  emitCode(Select(Tmp + utostr(ResNo) + ,  + Val + ););
   }
   // Add TmpResNo to VariableMap, so that we don't multiply select this
   // value if used multiple times by this pattern result.
@@ -2552,7 +2557,9 @@
   return std::make_pair(1, ResNo);
 } else if (Op-isSubClassOf(SDNodeXForm)) {
   assert(N-getNumChildren() == 1  node xform should have one child!);
-  unsigned OpVal = EmitResultCode(N-getChild(0)).second;
+  // PatLeaf node - the operand may or may not be a leaf node. But it 
should
+  // behave like one.
+  unsigned OpVal = EmitResultCode(N-getChild(0), true).second;
   unsigned ResNo = TmpNo++;
   emitDecl(Tmp + utostr(ResNo));
   emitCode(Tmp + utostr(ResNo) +  = Transform_ + Op-getName()
@@ -2748,7 +2755,7 @@
 // otherwise we are done.
   } while (Emitter.InsertOneTypeCheck(Pat, Pattern.getSrcPattern(), N));
 
-  Emitter.EmitResultCode(Pattern.getDstPattern(), true /*the root*/);
+  Emitter.EmitResultCode(Pattern.getDstPattern(), false, true /*the root*/);
   delete Pat;
 }
 



___
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

2006-03-20 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.180 - 1.181
---
Log message:

minor code simplification


---
Diffs of the changes:  (+5 -11)

 DAGISelEmitter.cpp |   16 +---
 1 files changed, 5 insertions(+), 11 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.180 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.181
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.180Mon Mar 20 16:53:06 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Tue Mar 21 00:42:58 2006
@@ -698,17 +698,11 @@
 if (getNumChildren() != 1)
   TP.error(Node transform ' + getOperator()-getName() +
' requires one operand!);
-unsigned char ExtType0 = getExtTypeNum(0);
-unsigned char ChildExtType0 = getChild(0)-getExtTypeNum(0);
-if (ExtType0 == MVT::isInt ||
-ExtType0 == MVT::isFP ||
-ExtType0 == MVT::isUnknown ||
-ChildExtType0 == MVT::isInt ||
-ChildExtType0 == MVT::isFP ||
-ChildExtType0 == MVT::isUnknown) {
-  // If either the output or input of the xform does not have exact
-  // type info. We assume they must be the same. Otherwise, it is perfectly
-  // legal to transform from one type to a completely different type.
+
+// If either the output or input of the xform does not have exact
+// type info. We assume they must be the same. Otherwise, it is perfectly
+// legal to transform from one type to a completely different type.
+if (!hasTypeSet() || !getChild(0)-hasTypeSet()) {
   bool MadeChange = UpdateNodeType(getChild(0)-getExtTypes(), TP);
   MadeChange |= getChild(0)-UpdateNodeType(getExtTypes(), TP);
   return MadeChange;



___
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

2006-03-19 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.176 - 1.177
DAGISelEmitter.h updated: 1.57 - 1.58
---
Log message:

Add a new SDTCisIntVectorOfSameSize type constraint


---
Diffs of the changes:  (+23 -3)

 DAGISelEmitter.cpp |   21 +++--
 DAGISelEmitter.h   |5 -
 2 files changed, 23 insertions(+), 3 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.176 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.177
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.176Thu Mar  9 02:19:11 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Sun Mar 19 23:39:47 2006
@@ -63,14 +63,14 @@
 
 /// isExtIntegerVT - Return true if the specified extended value type vector
 /// contains isInt or an integer value type.
-static bool isExtIntegerInVTs(std::vectorunsigned char EVTs) {
+static bool isExtIntegerInVTs(const std::vectorunsigned char EVTs) {
   assert(!EVTs.empty()  Cannot check for integer in empty ExtVT list!);
   return EVTs[0] == MVT::isInt || !(FilterEVTs(EVTs, MVT::isInteger).empty());
 }
 
 /// isExtFloatingPointVT - Return true if the specified extended value type 
 /// vector contains isFP or a FP value type.
-static bool isExtFloatingPointInVTs(std::vectorunsigned char EVTs) {
+static bool isExtFloatingPointInVTs(const std::vectorunsigned char EVTs) {
   assert(!EVTs.empty()  Cannot check for integer in empty ExtVT list!);
   return EVTs[0] == MVT::isFP ||
  !(FilterEVTs(EVTs, MVT::isFloatingPoint).empty());
@@ -103,6 +103,10 @@
 ConstraintType = SDTCisOpSmallerThanOp;
 x.SDTCisOpSmallerThanOp_Info.BigOperandNum = 
   R-getValueAsInt(BigOperandNum);
+  } else if (R-isSubClassOf(SDTCisIntVectorOfSameSize)) {
+ConstraintType = SDTCisIntVectorOfSameSize;
+x.SDTCisIntVectorOfSameSize_Info.OtherOperandNum =
+  R-getValueAsInt(OtherOpNum);
   } else {
 std::cerr  Unrecognized SDTypeConstraint '  R-getName()  '!\n;
 exit(1);
@@ -259,6 +263,19 @@
 }
 return MadeChange;
   }
+  case SDTCisIntVectorOfSameSize: {
+TreePatternNode *OtherOperand =
+  getOperandNum(x.SDTCisIntVectorOfSameSize_Info.OtherOperandNum,
+N, NumResults);
+if (OtherOperand-hasTypeSet()) {
+  if (!MVT::isVector(OtherOperand-getTypeNum(0)))
+TP.error(N-getOperator()-getName() +  VT operand must be a 
vector!);
+  MVT::ValueType IVT = OtherOperand-getTypeNum(0);
+  IVT = MVT::getIntVectorWithNumElements(MVT::getVectorNumElements(IVT));
+  return NodeToApply-UpdateNodeType(IVT, TP);
+}
+return false;
+  }
   }  
   return false;
 }


Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.57 
llvm/utils/TableGen/DAGISelEmitter.h:1.58
--- llvm/utils/TableGen/DAGISelEmitter.h:1.57   Thu Feb  9 01:16:09 2006
+++ llvm/utils/TableGen/DAGISelEmitter.hSun Mar 19 23:39:48 2006
@@ -47,7 +47,7 @@
 unsigned OperandNo;   // The operand # this constraint applies to.
 enum { 
   SDTCisVT, SDTCisPtrTy, SDTCisInt, SDTCisFP, SDTCisSameAs, 
-  SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp
+  SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp, SDTCisIntVectorOfSameSize
 } ConstraintType;
 
 union {   // The discriminated union.
@@ -63,6 +63,9 @@
   struct {
 unsigned BigOperandNum;
   } SDTCisOpSmallerThanOp_Info;
+  struct {
+unsigned OtherOperandNum;
+  } SDTCisIntVectorOfSameSize_Info;
 } x;
 
 /// ApplyTypeConstraint - Given a node in a pattern, apply this type



___
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

2006-03-19 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.177 - 1.178
DAGISelEmitter.h updated: 1.58 - 1.59
---
Log message:

Copy matching pattern's output type info to instruction result pattern.
The instruction patterns do not contain enough information to resolve the
exact type of the destination if it of a generic vector type.


---
Diffs of the changes:  (+14 -6)

 DAGISelEmitter.cpp |   17 -
 DAGISelEmitter.h   |3 ++-
 2 files changed, 14 insertions(+), 6 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.177 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.178
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.177Sun Mar 19 23:39:47 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Mon Mar 20 00:04:09 2006
@@ -1105,7 +1105,7 @@
 void DAGISelEmitter::
 FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat,
 std::mapstd::string, TreePatternNode* 
InstInputs,
-std::mapstd::string, Record* InstResults,
+std::mapstd::string, TreePatternNode* 
InstResults,
 std::vectorRecord* InstImpInputs,
 std::vectorRecord* InstImpResults) {
   if (Pat-isLeaf()) {
@@ -1159,7 +1159,7 @@
 I-error(set destination must have a name!);
   if (InstResults.count(Dest-getName()))
 I-error(cannot set ' + Dest-getName() +' multiple times);
-  InstResults[Dest-getName()] = Val-getDef();
+  InstResults[Dest-getName()] = Dest;
 } else if (Val-getDef()-isSubClassOf(Register)) {
   InstImpResults.push_back(Val-getDef());
 } else {
@@ -1235,7 +1235,7 @@
 
 // InstResults - Keep track of all the virtual registers that are 'set'
 // in the instruction, including what reg class they are.
-std::mapstd::string, Record* InstResults;
+std::mapstd::string, TreePatternNode* InstResults;
 
 std::vectorRecord* InstImpInputs;
 std::vectorRecord* InstImpResults;
@@ -1265,6 +1265,7 @@
 
 // Check that all of the results occur first in the list.
 std::vectorRecord* Results;
+TreePatternNode *Res0Node = NULL;
 for (unsigned i = 0; i != NumResults; ++i) {
   if (i == CGI.OperandList.size())
 I-error(' + InstResults.begin()-first +
@@ -1272,7 +1273,10 @@
   const std::string OpName = CGI.OperandList[i].Name;
   
   // Check that it exists in InstResults.
-  Record *R = InstResults[OpName];
+  TreePatternNode *RNode = InstResults[OpName];
+  if (i == 0)
+Res0Node = RNode;
+  Record *R = dynamic_castDefInit*(RNode-getLeafValue())-getDef();
   if (R == 0)
 I-error(Operand $ + OpName +  should be a set destination: all 
  outputs must occur before inputs in operand list!);
@@ -1337,6 +1341,9 @@
 
 TreePatternNode *ResultPattern =
   new TreePatternNode(I-getRecord(), ResultNodeOperands);
+// Copy fully inferred output node type to instruction result pattern.
+if (NumResults  0)
+  ResultPattern-setTypes(Res0Node-getExtTypes());
 
 // Create and insert the instruction.
 DAGInstruction TheInst(I, Results, Operands, InstImpResults, 
InstImpInputs);
@@ -1407,7 +1414,7 @@
 // Validate that the input pattern is correct.
 {
   std::mapstd::string, TreePatternNode* InstInputs;
-  std::mapstd::string, Record* InstResults;
+  std::mapstd::string, TreePatternNode* InstResults;
   std::vectorRecord* InstImpInputs;
   std::vectorRecord* InstImpResults;
   FindPatternInputsAndOutputs(Pattern, Pattern-getOnlyTree(),


Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.58 
llvm/utils/TableGen/DAGISelEmitter.h:1.59
--- llvm/utils/TableGen/DAGISelEmitter.h:1.58   Sun Mar 19 23:39:48 2006
+++ llvm/utils/TableGen/DAGISelEmitter.hMon Mar 20 00:04:09 2006
@@ -469,7 +469,8 @@
   void FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat,
std::mapstd::string,
 TreePatternNode* InstInputs,
-   std::mapstd::string, Record* InstResults,
+   std::mapstd::string,
+TreePatternNode* InstResults,
std::vectorRecord* InstImpInputs,
std::vectorRecord* InstImpResults);
   void GenerateCodeForPattern(PatternToMatch Pattern,



___
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

2006-03-09 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.175 - 1.176
---
Log message:

Temporary hack to enable more (store (op (load ...))) folding. This makes
it possible when a TokenFactor is between the load and store. But is still
missing some cases due to ordering issue.


---
Diffs of the changes:  (+74 -30)

 DAGISelEmitter.cpp |  104 +
 1 files changed, 74 insertions(+), 30 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.175 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.176
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.175Tue Mar  7 02:31:27 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Thu Mar  9 02:19:11 2006
@@ -1866,6 +1866,7 @@
   std::setstd::pairbool, std::string  GeneratedDecl;
 
   std::string ChainName;
+  bool NewTF;
   bool DoReplace;
   unsigned TmpNo;
   
@@ -1888,7 +1889,8 @@
  std::setstd::pairbool, std::string  gd,
  bool dorep)
   : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr),
-GeneratedCode(gc), GeneratedDecl(gd), DoReplace(dorep), TmpNo(0) {}
+GeneratedCode(gc), GeneratedDecl(gd),
+NewTF(false), DoReplace(dorep), TmpNo(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
@@ -2018,14 +2020,19 @@
   }
 
   if (NodeHasChain) {
-if (FoundChain)
-  emitCheck(Chain.Val ==  + RootName + .Val);
-else
-  FoundChain = true;
 ChainName = Chain + ChainSuffix;
 emitDecl(ChainName);
-emitCode(ChainName +  =  + RootName +
- .getOperand(0););
+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, true);
+  emitCheck(( + ChainName +  = UpdateFoldedChain(CurDAG,  +
+RootName + .Val, Chain.Val, OldTF)).Val);
+} else {
+  FoundChain = true;
+  emitCode(ChainName +  =  + RootName + .getOperand(0););
+}
   }
 }
 
@@ -2272,11 +2279,11 @@
 emitCode(bool HasOptInFlag = false;);
 
   // How many results is this pattern expected to produce?
-  unsigned NumExpectedResults = 0;
+  unsigned PatResults = 0;
   for (unsigned i = 0, e = Pattern-getExtTypes().size(); i != e; i++) {
 MVT::ValueType VT = Pattern-getTypeNum(i);
 if (VT != MVT::isVoid  VT != MVT::Flag)
-  NumExpectedResults++;
+  PatResults++;
   }
 
   // Determine operand emission order. Complex pattern first.
@@ -2405,61 +2412,64 @@
   emitCode(Code + ););
 }
 
-unsigned ValNo = 0;
-for (unsigned i = 0; i  NumResults; i++) {
+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(ValNo) + , ResNode,  + utostr(ValNo) + ););
-  ValNo++;
-}
+   utostr(i) + , ResNode,  + utostr(i) + ););
 
 if (NodeHasOutFlag)
   emitCode(InFlag = SDOperand(ResNode,  + 
-   utostr(ValNo + (unsigned)HasChain) + ););
+   utostr(NumResults + (unsigned)HasChain) + ););
 
 if (HasImpResults  EmitCopyFromRegs(N, ChainEmitted)) {
-  emitCode(SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val,  +
-   utostr(ValNo) + , ResNode,  + utostr(ValNo) + ););
-  ValNo++;
+  emitCode(SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 
+   0, ResNode, 0););
+  NumResults = 1;
 }
 
-// User does not expect the instruction would produce a chain!
-bool AddedChain = HasChain  !NodeHasChain;
 if (NodeHasChain) {
   emitCode(SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val,  + 
-   utostr(ValNo) + , ResNode,  + utostr(ValNo) + ););
+   utostr(PatResults) + , ResNode,  +
+   utostr(NumResults) + ););
   if (DoReplace)
-emitCode(if (N.ResNo == 0) AddHandleReplacement(N.Val, 
- + utostr(ValNo) + ,  + ResNode,  + utostr(ValNo) + 
););
-  ValNo++;
+emitCode(if (N.ResNo == 0) AddHandleReplacement(N.Val,  +
+ utostr(PatResults) + ,  + ResNode,  +
+ utostr(NumResults) + ););
 }
 
-
 if (FoldedChains.size()  0) {
   std::string Code;
   for (unsigned j = 0, e = FoldedChains.size(); j  e; j++)
 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-02-17 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.172 - 1.173
---
Log message:

Bump up pattern cost if the resulting instruction is marked
usesCustomDAGSchedInserter.


---
Diffs of the changes:  (+14 -7)

 DAGISelEmitter.cpp |   21 ++---
 1 files changed, 14 insertions(+), 7 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.172 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.173
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.172Thu Feb  9 16:12:27 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Fri Feb 17 20:33:09 2006
@@ -1749,12 +1749,19 @@
 /// getResultPatternCost - Compute the number of instructions for this pattern.
 /// This is a temporary hack.  We should really include the instruction
 /// latencies in this calculation.
-static unsigned getResultPatternCost(TreePatternNode *P) {
+static unsigned getResultPatternCost(TreePatternNode *P, DAGISelEmitter ISE) {
   if (P-isLeaf()) return 0;
   
-  unsigned Cost = P-getOperator()-isSubClassOf(Instruction);
+  unsigned Cost = 0;
+  Record *Op = P-getOperator();
+  if (Op-isSubClassOf(Instruction)) {
+Cost++;
+CodeGenInstruction II = ISE.getTargetInfo().getInstruction(Op-getName());
+if (II.usesCustomDAGSchedInserter)
+  Cost += 10;
+  }
   for (unsigned i = 0, e = P-getNumChildren(); i != e; ++i)
-Cost += getResultPatternCost(P-getChild(i));
+Cost += getResultPatternCost(P-getChild(i), ISE);
   return Cost;
 }
 
@@ -1773,8 +1780,8 @@
 if (LHSSize  RHSSize) return false;
 
 // If the patterns have equal complexity, compare generated instruction 
cost
-return getResultPatternCost(LHS-getDstPattern()) 
-  getResultPatternCost(RHS-getDstPattern());
+return getResultPatternCost(LHS-getDstPattern(), ISE) 
+  getResultPatternCost(RHS-getDstPattern(), ISE);
   }
 };
 
@@ -2748,7 +2755,7 @@
   OS  \n;
   OS  std::string(Indent, ' ')  // Pattern complexity = 
   getPatternSize(Pattern.getSrcPattern(), *this)cost = 
-  getResultPatternCost(Pattern.getDstPattern())  \n;
+  getResultPatternCost(Pattern.getDstPattern(), *this)  \n;
 }
 if (!FirstCodeLine.first) {
   OS  std::string(Indent, ' ')  {\n;
@@ -2769,7 +2776,7 @@
   OS  \n;
   OS  std::string(Indent, ' ')  // Pattern complexity = 
   getPatternSize(Pattern.getSrcPattern(), *this)cost = 
-  getResultPatternCost(Pattern.getDstPattern())  \n;
+  getResultPatternCost(Pattern.getDstPattern(), *this)  \n;
 }
 EmitPatterns(Other, Indent, OS);
 return;



___
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

2006-02-09 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.171 - 1.172
---
Log message:

Call InsertISelMapEntry rather than map insertion operator to prevent overly
aggrssive inlining. This reduces Select_store frame size from 24k to 10k.


---
Diffs of the changes:  (+64 -45)

 DAGISelEmitter.cpp |  109 +++--
 1 files changed, 64 insertions(+), 45 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.171 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.172
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.171Thu Feb  9 01:16:09 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Thu Feb  9 16:12:27 2006
@@ -2395,32 +2395,29 @@
 
 unsigned ValNo = 0;
 for (unsigned i = 0; i  NumResults; i++) {
-  emitCode(CodeGenMap[N.getValue( + utostr(ValNo) +
-   )] = SDOperand(ResNode,  + utostr(ValNo) + ););
+  emitCode(SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val,  +
+   utostr(ValNo) + , ResNode,  + utostr(ValNo) + ););
   ValNo++;
 }
 
-if (HasChain)
-  emitCode(ChainName +  = SDOperand(ResNode,  + utostr(ValNo) + 
););
-
 if (NodeHasOutFlag)
   emitCode(InFlag = SDOperand(ResNode,  + 
utostr(ValNo + (unsigned)HasChain) + ););
 
 if (HasImpResults  EmitCopyFromRegs(N, ChainEmitted)) {
-  emitCode(CodeGenMap[N.getValue( + utostr(ValNo) + )] = 
-   SDOperand(ResNode,  + utostr(ValNo) + ););
+  emitCode(SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val,  +
+   utostr(ValNo) + , ResNode,  + utostr(ValNo) + ););
   ValNo++;
 }
 
 // User does not expect the instruction would produce a chain!
 bool AddedChain = HasChain  !NodeHasChain;
 if (NodeHasChain) {
-  emitCode(CodeGenMap[N.getValue( + utostr(ValNo) + )] =  +
-   ChainName + ;);
+  emitCode(SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val,  + 
+   utostr(ValNo) + , ResNode,  + utostr(ValNo) + ););
   if (DoReplace)
-emitCode(if (N.ResNo == 0) AddHandleReplacement(N.getValue(
- + utostr(ValNo) + ),  + ChainName + ););
+emitCode(if (N.ResNo == 0) AddHandleReplacement(N.Val, 
+ + utostr(ValNo) + ,  + ResNode,  + utostr(ValNo) + 
););
   ValNo++;
 }
 
@@ -2428,20 +2425,23 @@
 if (FoldedChains.size()  0) {
   std::string Code;
   for (unsigned j = 0, e = FoldedChains.size(); j  e; j++)
-Code += CodeGenMap[ + FoldedChains[j].first + .getValue( +
-  utostr(FoldedChains[j].second) + )] = ;
-  emitCode(Code + ChainName + ;);
+emitCode(SelectionDAG::InsertISelMapEntry(CodeGenMap,  +
+ FoldedChains[j].first + .Val,  + 
+ utostr(FoldedChains[j].second) + , ResNode,  +
+ utostr(ValNo) + ););
 
   for (unsigned j = 0, e = FoldedChains.size(); j  e; j++) {
 std::string Code =
-  FoldedChains[j].first + .getValue( +
-  utostr(FoldedChains[j].second) + );
-emitCode(AddHandleReplacement( + Code + ,  + ChainName + ););
+  FoldedChains[j].first + .Val,  +
+  utostr(FoldedChains[j].second) + , ;
+emitCode(AddHandleReplacement( + Code + ResNode,  +
+ utostr(ValNo) + ););
   }
 }
 
 if (NodeHasOutFlag)
-  emitCode(CodeGenMap[N.getValue( + utostr(ValNo) + )] = InFlag;);
+  emitCode(SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val,  +
+   utostr(ValNo) + , InFlag.Val, InFlag.ResNo););
 
 if (AddedChain  NodeHasOutFlag) {
   if (NumExpectedResults == 0) {
@@ -2483,7 +2483,9 @@
 if (HasInFlag || HasImpInputs)
   Code += , InFlag;
 emitCode(Code + ););
-emitCode(  Result = CodeGenMap[N] = SDOperand(ResNode, 0););
+emitCode(  SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 
N.ResNo, 
+ ResNode, 0););
+emitCode(  Result = SDOperand(ResNode, 0););
 emitCode(});
   }
 
@@ -2498,7 +2500,9 @@
   emitCode(Tmp + utostr(ResNo) +  = Transform_ + Op-getName()
+ (Tmp + utostr(OpVal) + .Val););
   if (isRoot) {
-emitCode(CodeGenMap[N] = Tmp +utostr(ResNo) + ;);
+emitCode(SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val,
+ N.ResNo, Tmp + utostr(ResNo) + .Val, Tmp +
+ utostr(ResNo) + .ResNo););
 emitCode(Result = Tmp + utostr(ResNo) + ;);
 emitCode(return;);
   }
@@ -2571,13 +2575,12 @@
   }
   emitCode(Select( + RootName + utostr(OpNo) + ,  +
RootName + utostr(OpNo) + ););
-  

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-02-08 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.169 - 1.170
---
Log message:

Change Select() from 
SDOperand Select(SDOperand N);
to
void Select(SDOperand Result, SDOperand N);


---
Diffs of the changes:  (+98 -69)

 DAGISelEmitter.cpp |  167 +++--
 1 files changed, 98 insertions(+), 69 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.169 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.170
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.169Mon Feb  6 18:37:41 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Wed Feb  8 18:37:58 2006
@@ -2196,13 +2196,13 @@
 emitCheck(Code + ));
 
 for (unsigned i = 0; i  NumRes; ++i)
-  emitCode(Tmp + utostr(i+ResNo) +  = Select(Tmp +
+  emitCode(Select(Tmp + utostr(i+ResNo) + , Tmp +
utostr(i+ResNo) + ););
 
 TmpNo = ResNo + NumRes;
   } else {
 emitDecl(Tmp + utostr(ResNo));
-emitCode(Tmp + utostr(ResNo) +  = Select( + Val + ););
+emitCode(Select(Tmp + utostr(ResNo) + ,  + Val + ););
   }
   // Add TmpResNo to VariableMap, so that we don't multiply select this
   // value if used multiple times by this pattern result.
@@ -2301,7 +2301,7 @@
   // Emit all the chain and CopyToReg stuff.
   bool ChainEmitted = HasChain;
   if (HasChain)
-emitCode(ChainName +  = Select( + ChainName + ););
+emitCode(Select( + ChainName + ,  + ChainName + ););
   if (HasInFlag || HasOptInFlag || HasImpInputs)
 EmitInFlagSelectCode(Pattern, N, ChainEmitted, true);
 
@@ -2329,9 +2329,7 @@
utostr(NumResults) + ););
 }
   } else if (HasChain || NodeHasOutFlag) {
-emitDecl(Result);
 if (HasOptInFlag) {
-  emitCode(Result = SDOperand(0, 0););
   unsigned FlagNo = (unsigned) NodeHasChain + 
Pattern-getNumChildren();
   emitCode(if (HasOptInFlag));
   std::string Code =   Result = CurDAG-getTargetNode( +
@@ -2445,21 +2443,21 @@
 
 if (AddedChain  NodeHasOutFlag) {
   if (NumExpectedResults == 0) {
-emitCode(return Result.getValue(N.ResNo+1););
+emitCode(Result = Result.getValue(N.ResNo+1););
   } else {
 emitCode(if (N.ResNo   + utostr(NumExpectedResults) + ));
-emitCode(  return Result.getValue(N.ResNo););
+emitCode(  Result = Result.getValue(N.ResNo););
 emitCode(else);
-emitCode(  return Result.getValue(N.ResNo+1););
+emitCode(  Result = Result.getValue(N.ResNo+1););
   }
 } else {
-  emitCode(return Result.getValue(N.ResNo););
+  emitCode(Result = Result.getValue(N.ResNo););
 }
   } else {
 // If this instruction is the root, and if there is only one use of it,
 // use SelectNodeTo instead of getTargetNode to avoid an allocation.
 emitCode(if (N.Val-hasOneUse()) {);
-std::string Code =   return CurDAG-SelectNodeTo(N.Val,  +
+std::string Code =   Result = CurDAG-SelectNodeTo(N.Val,  +
   II.Namespace + :: + II.TheDef-getName();
 if (N-getTypeNum(0) != MVT::isVoid)
   Code += , MVT:: + getEnumName(N-getTypeNum(0));
@@ -2471,7 +2469,7 @@
   Code += , InFlag;
 emitCode(Code + ););
 emitCode(} else {);
-Code =   return CodeGenMap[N] = CurDAG-getTargetNode( +
+Code =   Result = CodeGenMap[N] = CurDAG-getTargetNode( +
II.Namespace + :: + II.TheDef-getName();
 if (N-getTypeNum(0) != MVT::isVoid)
   Code += , MVT:: + getEnumName(N-getTypeNum(0));
@@ -2485,6 +2483,8 @@
 emitCode(});
   }
 
+  if (isRoot)
+emitCode(return;);
   return std::make_pair(1, ResNo);
 } else if (Op-isSubClassOf(SDNodeXForm)) {
   assert(N-getNumChildren() == 1  node xform should have one child!);
@@ -2495,7 +2495,8 @@
+ (Tmp + utostr(OpVal) + .Val););
   if (isRoot) {
 emitCode(CodeGenMap[N] = Tmp +utostr(ResNo) + ;);
-emitCode(return Tmp + utostr(ResNo) + ;);
+emitCode(Result = Tmp + utostr(ResNo) + ;);
+emitCode(return;);
   }
   return std::make_pair(1, ResNo);
 } else {
@@ -2556,7 +2557,7 @@
   if (RR-isSubClassOf(Register)) {
 MVT::ValueType RVT = getRegisterValueType(RR, T);
 if (RVT == MVT::Flag) {
-  emitCode(InFlag = Select( + RootName + utostr(OpNo) + ););
+  emitCode(Select(InFlag,  + RootName + utostr(OpNo) + ););
 } else {
   if (!ChainEmitted) {
 emitDecl(Chain);
@@ -2564,16 +2565,15 @@
 ChainName = Chain;
 ChainEmitted = true;
   }
-  emitDecl(RootName + CR + utostr(i));
-  emitCode(RootName + CR + utostr(i) +

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h

2006-02-08 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.170 - 1.171
DAGISelEmitter.h updated: 1.56 - 1.57
---
Log message:

Match getTargetNode() changes (now returns SDNode* instead of SDOperand).


---
Diffs of the changes:  (+47 -40)

 DAGISelEmitter.cpp |   85 -
 DAGISelEmitter.h   |2 -
 2 files changed, 47 insertions(+), 40 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.170 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.171
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.170Wed Feb  8 18:37:58 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Thu Feb  9 01:16:09 2006
@@ -1856,7 +1856,7 @@
   std::vectorstd::pairbool, std::string  GeneratedCode;
   /// GeneratedDecl - This is the set of all SDOperand declarations needed for
   /// the set of patterns for each top-level opcode.
-  std::setstd::string GeneratedDecl;
+  std::setstd::pairbool, std::string  GeneratedDecl;
 
   std::string ChainName;
   bool DoReplace;
@@ -1870,15 +1870,15 @@
 if (!S.empty())
   GeneratedCode.push_back(std::make_pair(false, S));
   }
-  void emitDecl(const std::string S) {
+  void emitDecl(const std::string S, bool isSDNode=false) {
 assert(!S.empty()  Invalid declaration);
-GeneratedDecl.insert(S);
+GeneratedDecl.insert(std::make_pair(isSDNode, S));
   }
 public:
   PatternCodeEmitter(DAGISelEmitter ise, ListInit *preds,
  TreePatternNode *pattern, TreePatternNode *instr,
  std::vectorstd::pairbool, std::string  gc,
- std::setstd::string gd,
+ std::setstd::pairbool, std::string  gd,
  bool dorep)
   : ISE(ise), Predicates(preds), Pattern(pattern), Instruction(instr),
 GeneratedCode(gc), GeneratedDecl(gd), DoReplace(dorep), TmpNo(0) {}
@@ -2310,7 +2310,7 @@
   if (!isRoot) {
 emitDecl(Tmp + utostr(ResNo));
 std::string Code =
-  Tmp + utostr(ResNo) +  = CurDAG-getTargetNode( +
+  Tmp + utostr(ResNo) +  = SDOperand(CurDAG-getTargetNode( +
   II.Namespace + :: + II.TheDef-getName();
 if (N-getTypeNum(0) != MVT::isVoid)
   Code += , MVT:: + getEnumName(N-getTypeNum(0));
@@ -2322,7 +2322,7 @@
   LastOp = Ops[i];
   Code += , Tmp + utostr(LastOp);
 }
-emitCode(Code + ););
+emitCode(Code + ), 0););
 if (HasChain) {
   // Must have at least one result
   emitCode(ChainName +  = Tmp + utostr(LastOp) + .getValue( +
@@ -2331,8 +2331,9 @@
   } else if (HasChain || NodeHasOutFlag) {
 if (HasOptInFlag) {
   unsigned FlagNo = (unsigned) NodeHasChain + 
Pattern-getNumChildren();
+  emitDecl(ResNode, true);
   emitCode(if (HasOptInFlag));
-  std::string Code =   Result = CurDAG-getTargetNode( +
+  std::string Code =   ResNode = CurDAG-getTargetNode( +
  II.Namespace + :: + II.TheDef-getName();
 
   // Output order: results, chain, flags
@@ -2353,7 +2354,7 @@
   emitCode(Code + , InFlag););
 
   emitCode(else);
-  Code =   Result = CurDAG-getTargetNode( + II.Namespace + :: +
+  Code =   ResNode = CurDAG-getTargetNode( + II.Namespace + :: +
  II.TheDef-getName();
 
   // Output order: results, chain, flags
@@ -2371,7 +2372,8 @@
   if (HasChain) Code += ,  + ChainName + );;
   emitCode(Code);
 } else {
-  std::string Code = Result = CurDAG-getTargetNode( +
+  emitDecl(ResNode, true);
+  std::string Code = ResNode = CurDAG-getTargetNode( +
 II.Namespace + :: + II.TheDef-getName();
 
   // Output order: results, chain, flags
@@ -2393,25 +2395,25 @@
 
 unsigned ValNo = 0;
 for (unsigned i = 0; i  NumResults; i++) {
-  emitCode(CodeGenMap[N.getValue( + utostr(ValNo) + )] = Result
-   .getValue( + utostr(ValNo) + ););
+  emitCode(CodeGenMap[N.getValue( + utostr(ValNo) +
+   )] = SDOperand(ResNode,  + utostr(ValNo) + ););
   ValNo++;
 }
 
 if (HasChain)
-  emitCode(ChainName +  = Result.getValue( + utostr(ValNo) + ););
+  emitCode(ChainName +  = SDOperand(ResNode,  + utostr(ValNo) + 
););
 
 if (NodeHasOutFlag)
-  emitCode(InFlag = Result.getValue( + 
+  emitCode(InFlag = SDOperand(ResNode,  + 
utostr(ValNo + (unsigned)HasChain) + ););
 
 if (HasImpResults  EmitCopyFromRegs(N, ChainEmitted)) {
   emitCode(CodeGenMap[N.getValue( + utostr(ValNo) + )] = 
-   Result.getValue( + utostr(ValNo) + ););
+   SDOperand(ResNode,  + utostr(ValNo) + ););
   ValNo++;
 }
 
-// User does not expect that the instruction produces a chain!
+// User does not expect the 

[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

2006-02-05 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.166 - 1.167
---
Log message:

Name change.


---
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.166 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.167
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.166Sun Feb  5 02:46:14 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Mon Feb  6 00:03:35 2006
@@ -2398,7 +2398,7 @@
   emitCode(CodeGenMap[N.getValue( + utostr(ValNo) + )] =  +
ChainName + ;);
   if (DoReplace)
-emitCode(if (N.ResNo == 0) AddReplacement(N.getValue(
+emitCode(if (N.ResNo == 0) AddHandleReplacement(N.getValue(
  + utostr(ValNo) + ),  + ChainName + ););
   ValNo++;
 }
@@ -2415,7 +2415,7 @@
 std::string Code =
   FoldedChains[j].first + .getValue( +
   utostr(FoldedChains[j].second) + );
-emitCode(AddReplacement( + Code + ,  + ChainName + ););
+emitCode(AddHandleReplacement( + Code + ,  + ChainName + ););
   }
 }
 
@@ -3099,9 +3099,9 @@
   OS  }\n;
 
   OS  \n;
-  OS  // AddReplacement - Note the pending replacement node for a\n
+  OS  // AddHandleReplacement - Note the pending replacement node for a\n
   // holder node in ReplaceMap.\n;
-  OS  void AddReplacement(SDOperand N, SDOperand R) {\n;
+  OS  void AddHandleReplacement(SDOperand N, SDOperand R) {\n;
   OSstd::mapSDOperand, SDOperand::iterator HMI = 
HolderMap.find(N);\n;
   OSif (HMI != HolderMap.end()) {\n;
   OS  ReplaceMap[HMI-second] = R;\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

2006-02-04 Thread Evan Cheng


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.161 - 1.162
---
Log message:

Complex pattern's custom matcher should not call Select() on any operands.
Select them afterwards if it returns true.


---
Diffs of the changes:  (+5 -0)

 DAGISelEmitter.cpp |5 +
 1 files changed, 5 insertions(+)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.161 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.162
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.161Fri Feb  3 12:06:02 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Sat Feb  4 02:50:49 2006
@@ -2136,6 +2136,11 @@
 for (unsigned i = 0; i  NumRes; i++)
   Code += , Tmp + utostr(i + ResNo);
 emitCheck(Code + ));
+
+for (unsigned i = 0; i  NumRes; ++i)
+  emitCode(Tmp + utostr(i+ResNo) +  = Select(Tmp +
+   utostr(i+ResNo) + ););
+
 TmpNo = ResNo + NumRes;
   } else {
 emitCode(SDOperand Tmp + utostr(ResNo) +  = Select( + 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

2006-02-04 Thread Chris Lattner


Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.162 - 1.163
---
Log message:

Temporarily revert the last change, which breaks PPC and other targets that
DO select things.


---
Diffs of the changes:  (+4 -3)

 DAGISelEmitter.cpp |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.162 
llvm/utils/TableGen/DAGISelEmitter.cpp:1.163
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.162Sat Feb  4 02:50:49 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp  Sat Feb  4 03:23:06 2006
@@ -2137,9 +2137,10 @@
   Code += , Tmp + utostr(i + ResNo);
 emitCheck(Code + ));
 
-for (unsigned i = 0; i  NumRes; ++i)
-  emitCode(Tmp + utostr(i+ResNo) +  = Select(Tmp +
-   utostr(i+ResNo) + ););
+// This breaks ppc
+//for (unsigned i = 0; i  NumRes; ++i)
+//  emitCode(Tmp + utostr(i+ResNo) +  = Select(Tmp +
+//   utostr(i+ResNo) + ););
 
 TmpNo = ResNo + NumRes;
   } else {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


  1   2   >