[clang] [llvm] [mlir] [LLVM] Improve IR parsing and printing for target memory locations (PR #176968)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 3 08:02:46 PST 2026


================
@@ -240,6 +240,25 @@ template <typename LocationEnum> class MemoryEffectsBase {
     return getWithoutLoc(Location::InaccessibleMem).doesNotAccessMemory();
   }
 
+  bool isTargetMemLoc(IRMemLocation Loc) const {
+    return static_cast<unsigned>(Loc) >=
+           static_cast<unsigned>(Location::FirstTarget);
+  }
+
+  // Whether the target memory locations are all the same.
+  // So it behaves as the default read/write, but for Target
+  // locations only.
+  bool isTargetMemLocSameForAll() const {
+    ModRefInfo Expected = getModRef(IRMemLocation::FirstTarget);
+    auto First = static_cast<unsigned>(IRMemLocation::FirstTarget);
+    auto Last = static_cast<unsigned>(IRMemLocation::Last);
----------------
nikic wrote:

Would probably make sense to add a helper `target_locations()` defined similarly to `locations()`.

https://github.com/llvm/llvm-project/pull/176968


More information about the cfe-commits mailing list