Change TRUNCSTORE to use a VTSDNode operand instead of being an MVTSTDNode
authorChris Lattner <sabre@nondot.org>
Sun, 10 Jul 2005 00:29:18 +0000 (00:29 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 10 Jul 2005 00:29:18 +0000 (00:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22366 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/Target/Alpha/AlphaISelPattern.cpp
lib/Target/IA64/IA64ISelPattern.cpp
lib/Target/PowerPC/PPC64ISelPattern.cpp
lib/Target/PowerPC/PPCISelPattern.cpp
lib/Target/Sparc/SparcV8ISelPattern.cpp
lib/Target/SparcV8/SparcV8ISelPattern.cpp
lib/Target/X86/X86ISelPattern.cpp

index c6fc076ee2804d3fdb3a59fdf8c130d4c6245c2a..c42c0e031a73475b6188ad3e5ff575c6df1d4f66 100644 (file)
@@ -679,7 +679,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       Tmp3 = PromoteOp(Node->getOperand(1));
       Result = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, Tmp1, Tmp3, Tmp2,
                            Node->getOperand(3),
-                           Node->getOperand(1).getValueType()); 
+                          DAG.getValueType(Node->getOperand(1).getValueType()));
       break;
 
     case Expand:
@@ -718,8 +718,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1) ||
           Tmp3 != Node->getOperand(2))
         Result = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, Tmp1, Tmp2, Tmp3,
-                             Node->getOperand(3),
-                             cast<MVTSDNode>(Node)->getExtraValueType());
+                             Node->getOperand(3), Node->getOperand(4));
       break;
     case Promote:
     case Expand:
@@ -1482,7 +1481,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
         SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy());
         Result = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, DAG.getEntryNode(),
                              Node->getOperand(0), StackSlot,
-                             DAG.getSrcValue(NULL), ExtraVT);
+                             DAG.getSrcValue(NULL), DAG.getValueType(ExtraVT));
         Result = DAG.getNode(ISD::EXTLOAD, Node->getValueType(0),
                              Result, StackSlot, DAG.getSrcValue(NULL), ExtraVT);
       } else {
index 9cf6e0f3a6dde5020abc979c60f881a684870567..8ae96f8d4da7ea48dcf2b2e4ef5d442b3ed19049 100644 (file)
@@ -235,7 +235,6 @@ void SelectionDAG::DeleteNodeIfDead(SDNode *N, void *NodeSet) {
                                      cast<SetCCSDNode>(N)->getCondition(),
                                      N->getValueType(0))));
     break;
-  case ISD::TRUNCSTORE:
   case ISD::EXTLOAD:
   case ISD::SEXTLOAD:
   case ISD::ZEXTLOAD: {
@@ -1465,6 +1464,20 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
   return getNode(Opcode, VT, Ops);
 }
 
+SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
+                                SDOperand N1, SDOperand N2, SDOperand N3,
+                                SDOperand N4, SDOperand N5) {
+  std::vector<SDOperand> Ops;
+  Ops.reserve(5);
+  Ops.push_back(N1);
+  Ops.push_back(N2);
+  Ops.push_back(N3);
+  Ops.push_back(N4);
+  Ops.push_back(N5);
+  return getNode(Opcode, VT, Ops);
+}
+
+
 SDOperand SelectionDAG::getSrcValue(const Value *V, int Offset) {
   assert((!V || isa<PointerType>(V->getType())) &&
          "SrcValue is not a pointer?");
@@ -1496,6 +1509,27 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
       else                 // Unconditional branch to false dest.
         return getNode(ISD::BR, MVT::Other, Ops[0], Ops[3]);
     break;
+
+  case ISD::TRUNCSTORE: {
+    assert(Ops.size() == 5 && "TRUNCSTORE takes 5 operands!");
+    MVT::ValueType EVT = cast<VTSDNode>(Ops[4])->getVT();
+#if 0 // FIXME: If the target supports EVT natively, convert to a truncate/store
+    // If this is a truncating store of a constant, convert to the desired type
+    // and store it instead.
+    if (isa<Constant>(Ops[0])) {
+      SDOperand Op = getNode(ISD::TRUNCATE, EVT, N1);
+      if (isa<Constant>(Op))
+        N1 = Op;
+    }
+    // Also for ConstantFP?
+#endif
+    if (Ops[0].getValueType() == EVT)       // Normal store?
+      return getNode(ISD::STORE, VT, Ops[0], Ops[1], Ops[2], Ops[3]);
+    assert(Ops[1].getValueType() > EVT && "Not a truncation?");
+    assert(MVT::isInteger(Ops[1].getValueType()) == MVT::isInteger(EVT) &&
+           "Can't do FP-INT conversion!");
+    break;
+  }
   }
 
   // Memoize nodes.
@@ -1596,47 +1630,6 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1,
   return SDOperand(N, 0);
 }
 
-SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1,
-                                SDOperand N2, SDOperand N3, SDOperand N4,
-                                MVT::ValueType EVT) {
-  switch (Opcode) {
-  default:  assert(0 && "Bad opcode for this accessor!");
-  case ISD::TRUNCSTORE:
-#if 0 // FIXME: If the target supports EVT natively, convert to a truncate/store
-    // If this is a truncating store of a constant, convert to the desired type
-    // and store it instead.
-    if (isa<Constant>(N1)) {
-      SDOperand Op = getNode(ISD::TRUNCATE, EVT, N1);
-      if (isa<Constant>(Op))
-        N1 = Op;
-    }
-    // Also for ConstantFP?
-#endif
-    if (N1.getValueType() == EVT)       // Normal store?
-      return getNode(ISD::STORE, VT, N1, N2, N3, N4);
-    assert(N2.getValueType() > EVT && "Not a truncation?");
-    assert(MVT::isInteger(N2.getValueType()) == MVT::isInteger(EVT) &&
-           "Can't do FP-INT conversion!");
-    break;
-  }
-
-  EVTStruct NN;
-  NN.Opcode = Opcode;
-  NN.VT = VT;
-  NN.EVT = EVT;
-  NN.Ops.push_back(N1);
-  NN.Ops.push_back(N2);
-  NN.Ops.push_back(N3);
-  NN.Ops.push_back(N4);
-
-  SDNode *&N = MVTSDNodes[NN];
-  if (N) return SDOperand(N, 0);
-  N = new MVTSDNode(Opcode, VT, N1, N2, N3, N4, EVT);
-  AllNodes.push_back(N);
-  return SDOperand(N, 0);
-}
-
-
 /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
 /// indicated value.  This method ignores uses of other values defined by this
 /// operation.
index 32259631ce18859a99c14caa078e8028df7c0175..aeb15a02f50d9f5b629632b77cd674bdac9d30cb 100644 (file)
@@ -419,7 +419,7 @@ SDOperand AlphaTargetLowering::LowerVAStart(SDOperand Chain, SDOperand VAListP,
                               DAG.getConstant(8, MVT::i64));
   return DAG.getNode(ISD::TRUNCSTORE, MVT::Other, S1, 
                      DAG.getConstant(VarArgsOffset, MVT::i64), SA2, 
-                     DAG.getSrcValue(VAListV, 8), MVT::i32);
+                     DAG.getSrcValue(VAListV, 8), DAG.getValueType(MVT::i32));
 }
 
 std::pair<SDOperand,SDOperand> AlphaTargetLowering::
@@ -457,7 +457,8 @@ LowerVAArg(SDOperand Chain, SDOperand VAListP, Value *VAListV,
                                     DAG.getConstant(8, MVT::i64));
   SDOperand Update = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, 
                                  Result.getValue(1), NewOffset, 
-                                 Tmp, DAG.getSrcValue(VAListV, 8), MVT::i32);
+                                 Tmp, DAG.getSrcValue(VAListV, 8),
+                                 DAG.getValueType(MVT::i32));
   Result = DAG.getNode(ISD::TRUNCATE, getValueType(ArgTy), Result);
 
   return std::make_pair(Result, Update);
@@ -478,7 +479,8 @@ LowerVACopy(SDOperand Chain, SDOperand SrcP, Value *SrcV, SDOperand DestP,
   SDOperand NPD = DAG.getNode(ISD::ADD, MVT::i64, DestP, 
                              DAG.getConstant(8, MVT::i64));
   return DAG.getNode(ISD::TRUNCSTORE, MVT::Other, Val.getValue(1),
-                     Val, NPD, DAG.getSrcValue(DestV, 8), MVT::i32);
+                     Val, NPD, DAG.getSrcValue(DestV, 8),
+                     DAG.getValueType(MVT::i32));
 }
 
 namespace {
@@ -2283,7 +2285,7 @@ void AlphaISel::Select(SDOperand N) {
         case MVT::f32: Opc = Alpha::STS; break;
         }
       } else { //ISD::TRUNCSTORE
-        switch(cast<MVTSDNode>(Node)->getExtraValueType()) {
+        switch(cast<VTSDNode>(Node->getOperand(4))->getVT()) {
         default: assert(0 && "unknown Type in store");
         case MVT::i1: //FIXME: DAG does not promote this load
         case MVT::i8: Opc = Alpha::STB; break;
index a93e2ead27404634d083f406546adcf67626c11d..3b3f90a489c2c5ea76608ef48b17a057d3642d3c 100644 (file)
@@ -2361,7 +2361,7 @@ void ISel::Select(SDOperand N) {
           case MVT::f64: Opc = IA64::STF8; break;
         }
       } else { // truncstore
-        switch(cast<MVTSDNode>(Node)->getExtraValueType()) {
+        switch(cast<VTSDNode>(Node->getOperand(4))->getVT()) {
           default: assert(0 && "unknown type in truncstore");
           case MVT::i1: Opc = IA64::ST1; isBool=true; break;
                         //FIXME: DAG does not promote this load?
index 6761ab1115cba9593eb0d52e582502a80af561f7..1fca3391707e09f709f75c6d3d17abe69afe6b3f 100644 (file)
@@ -1593,7 +1593,7 @@ void ISel::Select(SDOperand N) {
         case MVT::f32: Opc = PPC::STFS; break;
         }
       } else { //ISD::TRUNCSTORE
-        switch(cast<MVTSDNode>(Node)->getExtraValueType()) {
+        switch(cast<VTSDNode>(Node->getOperand(4))->getVT()) {
         default: assert(0 && "unknown Type in store");
         case MVT::i1: //FIXME: DAG does not promote this load
         case MVT::i8:  Opc= PPC::STB; break;
index b29b11f182b49d1a77e66fcc898d5c0c32d50b11..f5a09a7f60f82e29661812358c3822cad0660d4d 100644 (file)
@@ -2530,7 +2530,7 @@ void ISel::Select(SDOperand N) {
         case MVT::f32: Opc = PPC::STFS; break;
         }
       } else { //ISD::TRUNCSTORE
-        switch(cast<MVTSDNode>(Node)->getExtraValueType()) {
+        switch(cast<VTSDNode>(Node->getOperand(4))->getVT()) {
         default: assert(0 && "unknown Type in store");
         case MVT::i1:
         case MVT::i8: Opc  = PPC::STB; break;
index e19e14c12b340976e0e3725789545326c72c6f6c..c2740e339bec2d0f0720ad62e5c42ff1f3fc8b12 100644 (file)
@@ -489,7 +489,7 @@ void ISel::Select(SDOperand N) {
       Tmp2 = SelectExpr(Address);
 
       unsigned VT = opcode == ISD::STORE ? 
-        Value.getValueType() : cast<MVTSDNode>(Node)->getExtraValueType();
+        Value.getValueType() : cast<VTSDNode>(Node->getOperand(4))->getVT();
       switch(VT) {
       default: assert(0 && "unknown Type in store");
       case MVT::f64: Opc = V8::STDFrr; break;
index e19e14c12b340976e0e3725789545326c72c6f6c..c2740e339bec2d0f0720ad62e5c42ff1f3fc8b12 100644 (file)
@@ -489,7 +489,7 @@ void ISel::Select(SDOperand N) {
       Tmp2 = SelectExpr(Address);
 
       unsigned VT = opcode == ISD::STORE ? 
-        Value.getValueType() : cast<MVTSDNode>(Node)->getExtraValueType();
+        Value.getValueType() : cast<VTSDNode>(Node->getOperand(4))->getVT();
       switch(VT) {
       default: assert(0 && "unknown Type in store");
       case MVT::f64: Opc = V8::STDFrr; break;
index d7a1c4d01d883152332812f722d8d3b68dbc4095..af75bdc7796ca07ae0179cc55025e55f192f0fd1 100644 (file)
@@ -4009,7 +4009,7 @@ static SDOperand GetAdjustedArgumentStores(SDOperand Chain, int Offset,
     StoreVT = Chain.getOperand(1).getValueType();
     break;
   case ISD::TRUNCSTORE:  // FLOAT store
-    StoreVT = cast<MVTSDNode>(Chain)->getExtraValueType();
+    StoreVT = cast<VTSDNode>(Chain.getOperand(4))->getVT();
     break;
   }
 
@@ -4043,7 +4043,7 @@ static SDOperand GetAdjustedArgumentStores(SDOperand Chain, int Offset,
                        FIN);
   assert(Chain.getOpcode() == ISD::TRUNCSTORE);
   return DAG.getNode(ISD::TRUNCSTORE, MVT::Other, InChain, Chain.getOperand(1),
-                     FIN, DAG.getSrcValue(NULL), StoreVT);
+                     FIN, DAG.getSrcValue(NULL), DAG.getValueType(StoreVT));
 }
 
 
@@ -4366,10 +4366,9 @@ void ISel::Select(SDOperand N) {
     SelectExpr(N.getValue(0));
     return;
 
-  case ISD::TRUNCSTORE: {  // truncstore chain, val, ptr :storety
-    // On X86, we can represent all types except for Bool and Float natively.
+  case ISD::TRUNCSTORE: {  // truncstore chain, val, ptr, SRCVALUE, storety
     X86AddressMode AM;
-    MVT::ValueType StoredTy = cast<MVTSDNode>(Node)->getExtraValueType();
+    MVT::ValueType StoredTy = cast<VTSDNode>(N.getOperand(4))->getVT();
     assert((StoredTy == MVT::i1 || StoredTy == MVT::f32 ||
             StoredTy == MVT::i16 /*FIXME: THIS IS JUST FOR TESTING!*/)
            && "Unsupported TRUNCSTORE for this target!");