[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Jan 9 11:43:38 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.17 -> 1.18
---
Log message:

Fix a bug legalizing call instructions (make sure to remember all result
values), and eliminate some switch statements.


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

Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.17 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.18
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.17	Sun Jan  9 13:07:54 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Sun Jan  9 13:43:23 2005
@@ -332,9 +332,15 @@
       RetTyVTs.reserve(Node->getNumValues());
       for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i)
         RetTyVTs.push_back(Node->getValueType(i));
-      Result = SDOperand(DAG.getCall(RetTyVTs, Tmp1, Tmp2), Op.ResNo);
-    }
-    break;
+      Result = SDOperand(DAG.getCall(RetTyVTs, Tmp1, Tmp2), 0);
+    } else {
+      Result = Result.getValue(0);
+    }
+    // Since calls produce multiple values, make sure to remember that we
+    // legalized all of them.
+    for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i)
+      AddLegalizedOperand(SDOperand(Node, i), Result.getValue(i));
+    return Result.getValue(Op.ResNo);
 
   case ISD::BR:
     Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
@@ -499,13 +505,7 @@
       // FIXME: These two stores are independent of each other!
       Result = DAG.getNode(ISD::STORE, MVT::Other, Tmp1, Lo, Tmp2);
 
-      unsigned IncrementSize;
-      switch (Lo.getValueType()) {
-      default: assert(0 && "Unknown ValueType to expand to!");
-      case MVT::i32: IncrementSize = 4; break;
-      case MVT::i16: IncrementSize = 2; break;
-      case MVT::i8:  IncrementSize = 1; break;
-      }
+      unsigned IncrementSize = MVT::getSizeInBits(Lo.getValueType())/8;
       Tmp2 = DAG.getNode(ISD::ADD, Tmp2.getValueType(), Tmp2,
                          getIntPtrConstant(IncrementSize));
       assert(isTypeLegal(Tmp2.getValueType()) &&
@@ -701,13 +701,7 @@
     Lo = DAG.getLoad(NVT, Ch, Ptr);
 
     // Increment the pointer to the other half.
-    unsigned IncrementSize;
-    switch (Lo.getValueType()) {
-    default: assert(0 && "Unknown ValueType to expand to!");
-    case MVT::i32: IncrementSize = 4; break;
-    case MVT::i16: IncrementSize = 2; break;
-    case MVT::i8:  IncrementSize = 1; break;
-    }
+    unsigned IncrementSize = MVT::getSizeInBits(Lo.getValueType())/8;
     Ptr = DAG.getNode(ISD::ADD, Ptr.getValueType(), Ptr,
                       getIntPtrConstant(IncrementSize));
     // FIXME: This load is independent of the first one.






More information about the llvm-commits mailing list