[llvm-commits] [llvm] r44728 - in /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeTypes.h LegalizeTypesExpand.cpp LegalizeTypesSplit.cpp

Chris Lattner sabre at nondot.org
Sat Dec 8 16:06:20 PST 2007


Author: lattner
Date: Sat Dec  8 18:06:19 2007
New Revision: 44728

URL: http://llvm.org/viewvc/llvm-project?rev=44728&view=rev
Log:
Add support for splitting the operand of a return instruction.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=44728&r1=44727&r2=44728&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Sat Dec  8 18:06:19 2007
@@ -291,7 +291,8 @@
   // Operand Vector Scalarization: <128 x ty> -> 2 x <64 x ty>.
   bool SplitOperand(SDNode *N, unsigned OpNo);
   
-  SDOperand SplitOperand_STORE(StoreSDNode *N, unsigned OpNo);
+  SDOperand SplitOp_STORE(StoreSDNode *N, unsigned OpNo);
+  SDOperand SplitOp_RET(SDNode *N, unsigned OpNo);
 };
 
 } // end namespace llvm.

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp?rev=44728&r1=44727&r2=44728&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesExpand.cpp Sat Dec  8 18:06:19 2007
@@ -1043,59 +1043,15 @@
 
   if (!N->isTruncatingStore()) {
     unsigned IncrementSize = 0;
+    GetExpandedOp(N->getValue(), Lo, Hi);
+    IncrementSize = MVT::getSizeInBits(Hi.getValueType())/8;
 
-    // If this is a vector type, then we have to calculate the increment as
-    // the product of the element size in bytes, and the number of elements
-    // in the high half of the vector.
-    if (MVT::isVector(N->getValue().getValueType())) {
-      assert(0 && "Vectors not supported yet");
-  #if 0
-      SDNode *InVal = ST->getValue().Val;
-      unsigned NumElems = MVT::getVectorNumElements(InVal->getValueType(0));
-      MVT::ValueType EVT = MVT::getVectorElementType(InVal->getValueType(0));
-
-      // Figure out if there is a simple type corresponding to this Vector
-      // type.  If so, convert to the vector type.
-      MVT::ValueType TVT = MVT::getVectorType(EVT, NumElems);
-      if (TLI.isTypeLegal(TVT)) {
-        // Turn this into a normal store of the vector type.
-        Tmp3 = LegalizeOp(Node->getOperand(1));
-        Result = DAG.getStore(Tmp1, Tmp3, Tmp2, ST->getSrcValue(),
-                              SVOffset, isVolatile, Alignment);
-        Result = LegalizeOp(Result);
-        break;
-      } else if (NumElems == 1) {
-        // Turn this into a normal store of the scalar type.
-        Tmp3 = ScalarizeVectorOp(Node->getOperand(1));
-        Result = DAG.getStore(Tmp1, Tmp3, Tmp2, ST->getSrcValue(),
-                              SVOffset, isVolatile, Alignment);
-        // The scalarized value type may not be legal, e.g. it might require
-        // promotion or expansion.  Relegalize the scalar store.
-        return LegalizeOp(Result);
-      } else {
-        SplitVectorOp(Node->getOperand(1), Lo, Hi);
-        IncrementSize = NumElems/2 * MVT::getSizeInBits(EVT)/8;
-      }
-  #endif
-    } else {
-      GetExpandedOp(N->getValue(), Lo, Hi);
-      IncrementSize = Hi.Val ? MVT::getSizeInBits(Hi.getValueType())/8 : 0;
-
-      if (!TLI.isLittleEndian())
-        std::swap(Lo, Hi);
-    }
+    if (!TLI.isLittleEndian())
+      std::swap(Lo, Hi);
 
     Lo = DAG.getStore(Ch, Lo, Ptr, N->getSrcValue(),
                       SVOffset, isVolatile, Alignment);
 
-    assert(Hi.Val && "FIXME: int <-> float should be handled with promote!");
-  #if 0
-    if (Hi.Val == NULL) {
-      // Must be int <-> float one-to-one expansion.
-      return Lo;
-    }
-  #endif
-
     Ptr = DAG.getNode(ISD::ADD, Ptr.getValueType(), Ptr,
                       getIntPtrConstant(IncrementSize));
     assert(isTypeLegal(Ptr.getValueType()) && "Pointers must be legal!");

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp?rev=44728&r1=44727&r2=44728&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesSplit.cpp Sat Dec  8 18:06:19 2007
@@ -337,9 +337,8 @@
 #endif
       assert(0 && "Do not know how to split this operator's operand!");
       abort();
-    case ISD::STORE:
-      Res = SplitOperand_STORE(cast<StoreSDNode>(N), OpNo);
-      break;
+    case ISD::STORE: Res = SplitOp_STORE(cast<StoreSDNode>(N), OpNo); break;
+    case ISD::RET:   Res = SplitOp_RET(N, OpNo); break;
     }
   }
   
@@ -364,7 +363,7 @@
   return false;
 }
 
-SDOperand DAGTypeLegalizer::SplitOperand_STORE(StoreSDNode *N, unsigned OpNo) {
+SDOperand DAGTypeLegalizer::SplitOp_STORE(StoreSDNode *N, unsigned OpNo) {
   assert(OpNo == 1 && "Can only split the stored value");
   
   SDOperand Ch  = N->getChain();
@@ -388,3 +387,15 @@
   return DAG.getNode(ISD::TokenFactor, MVT::Other, Lo, Hi);
 }
 
+SDOperand DAGTypeLegalizer::SplitOp_RET(SDNode *N, unsigned OpNo) {
+  assert(N->getNumOperands() == 3 &&"Can only handle ret of one vector so far");
+  // FIXME: Returns of gcc generic vectors larger than a legal vector
+  // type should be returned by reference!
+  SDOperand Lo, Hi;
+  GetSplitOp(N->getOperand(1), Lo, Hi);
+
+  SDOperand Chain = N->getOperand(0);  // The chain.
+  SDOperand Sign = N->getOperand(2);  // Signness
+  
+  return DAG.getNode(ISD::RET, MVT::Other, Chain, Lo, Sign, Hi, Sign);
+}





More information about the llvm-commits mailing list