]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rtl-ssa: Add drop_memory_access helper
authorAlex Coplan <alex.coplan@arm.com>
Tue, 22 Aug 2023 12:37:53 +0000 (13:37 +0100)
committerAlex Coplan <alex.coplan@arm.com>
Thu, 19 Oct 2023 10:12:22 +0000 (11:12 +0100)
Add a helper routine to access-utils.h which removes the memory access
from an access_array, if it has one.

gcc/ChangeLog:

* rtl-ssa/access-utils.h (drop_memory_access): New.

gcc/rtl-ssa/access-utils.h

index fbaaaa2c2d3a964bba7146863beace1fef1d4bea..84d386b7d8bd11a608c825f02d5be0b6e8140dab 100644 (file)
@@ -51,6 +51,19 @@ memory_access (T accesses) -> decltype (accesses[0])
   return nullptr;
 }
 
+// If ACCESSES has a memory access, drop it.  Otherwise, return ACCESSES
+// unchanged.
+template<typename T>
+inline T
+drop_memory_access (T accesses)
+{
+  if (!memory_access (accesses))
+    return accesses;
+
+  access_array arr (accesses);
+  return T (arr.begin (), accesses.size () - 1);
+}
+
 // If sorted array ACCESSES includes a reference to REGNO, return the
 // access, otherwise return null.
 template<typename T>