Added indexed store node and patfrag's.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 8 Nov 2006 23:02:11 +0000 (23:02 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 8 Nov 2006 23:02:11 +0000 (23:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31576 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/TargetSelectionDAG.td

index 0d4da01f57bd2248691c3a8b9ca736526d8ebefd..554991564bcf06524f0c6771e82bf2e3bee62db0 100644 (file)
@@ -164,6 +164,10 @@ def SDTStore : SDTypeProfile<0, 2, [ // store
   SDTCisPtrTy<1>  
 ]>;
 
+def SDTIStore : SDTypeProfile<1, 3, [ // indexed store
+  SDTCisSameAs<0, 2>, SDTCisPtrTy<0>, SDTCisPtrTy<3>
+]>;
+
 def SDTVecShuffle : SDTypeProfile<1, 3, [
   SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisIntVectorOfSameSize<3, 0>
 ]>;
@@ -299,6 +303,7 @@ def ret        : SDNode<"ISD::RET"        , SDTRet,    [SDNPHasChain]>;
 // and truncst (see below).
 def ld         : SDNode<"ISD::LOAD"       , SDTLoad,  [SDNPHasChain]>;
 def st         : SDNode<"ISD::STORE"      , SDTStore, [SDNPHasChain]>;
+def ist        : SDNode<"ISD::STORE"      , SDTIStore, [SDNPHasChain]>;
 
 def vector_shuffle : SDNode<"ISD::VECTOR_SHUFFLE", SDTVecShuffle, []>;
 def build_vector : SDNode<"ISD::BUILD_VECTOR", SDTypeProfile<1, 0, []>, []>;
@@ -505,38 +510,153 @@ def zextloadi32 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{
 // store fragments.
 def store : PatFrag<(ops node:$val, node:$ptr),
                     (st node:$val, node:$ptr), [{
-  return ISD::isNON_TRUNCStore(N);
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
+    return !ST->isTruncatingStore();
+  return false;
 }]>;
 
 // truncstore fragments.
 def truncstorei1 : PatFrag<(ops node:$val, node:$ptr),
                            (st node:$val, node:$ptr), [{
-  if (ISD::isTRUNCStore(N))
-    return cast<StoreSDNode>(N)->getStoredVT() == MVT::i1;
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
+    return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i1;
   return false;
 }]>;
 def truncstorei8 : PatFrag<(ops node:$val, node:$ptr),
                            (st node:$val, node:$ptr), [{
-  if (ISD::isTRUNCStore(N))
-    return cast<StoreSDNode>(N)->getStoredVT() == MVT::i8;
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
+    return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i8;
   return false;
 }]>;
 def truncstorei16 : PatFrag<(ops node:$val, node:$ptr),
                             (st node:$val, node:$ptr), [{
-  if (ISD::isTRUNCStore(N))
-    return cast<StoreSDNode>(N)->getStoredVT() == MVT::i16;
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
+    return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i16;
   return false;
 }]>;
 def truncstorei32 : PatFrag<(ops node:$val, node:$ptr),
                             (st node:$val, node:$ptr), [{
-  if (ISD::isTRUNCStore(N))
-    return cast<StoreSDNode>(N)->getStoredVT() == MVT::i32;
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
+    return ST->isTruncatingStore() && ST->getStoredVT() == MVT::i32;
   return false;
 }]>;
 def truncstoref32 : PatFrag<(ops node:$val, node:$ptr),
                             (st node:$val, node:$ptr), [{
-  if (ISD::isTRUNCStore(N))
-    return cast<StoreSDNode>(N)->getStoredVT() == MVT::f32;
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N))
+    return ST->isTruncatingStore() && ST->getStoredVT() == MVT::f32;
+  return false;
+}]>;
+
+// indexed store fragments.
+def pre_store : PatFrag<(ops node:$val, node:$base, node:$offset),
+                        (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
+           !ST->isTruncatingStore();
+  }
+  return false;
+}]>;
+
+def pre_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                            (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::i1;
+  }
+  return false;
+}]>;
+def pre_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                            (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::i8;
+  }
+  return false;
+}]>;
+def pre_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                             (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::i16;
+  }
+  return false;
+}]>;
+def pre_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                             (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::i32;
+  }
+  return false;
+}]>;
+def pre_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                             (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::PRE_INC || AM == ISD::PRE_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::f32;
+  }
+  return false;
+}]>;
+
+def post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
+                         (ist node:$val, node:$ptr, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return !ST->isTruncatingStore() &&
+            (AM == ISD::POST_INC || AM == ISD::POST_DEC);
+  }
+  return false;
+}]>;
+
+def post_truncsti1 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                             (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::i1;
+  }
+  return false;
+}]>;
+def post_truncsti8 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                             (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::i8;
+  }
+  return false;
+}]>;
+def post_truncsti16 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                              (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::i16;
+  }
+  return false;
+}]>;
+def post_truncsti32 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                              (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::i32;
+  }
+  return false;
+}]>;
+def post_truncstf32 : PatFrag<(ops node:$val, node:$base, node:$offset),
+                              (ist node:$val, node:$base, node:$offset), [{
+  if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
+    ISD::MemOpAddrMode AM = ST->getAddressingMode();
+    return (AM == ISD::POST_INC || AM == ISD::POST_DEC) &&
+           ST->isTruncatingStore() && ST->getStoredVT() == MVT::f32;
+  }
   return false;
 }]>;