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

Antonio Frighetto llvmlistbot at llvm.org
Tue Jan 27 03:18:11 PST 2026


================
@@ -240,6 +240,26 @@ 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 First = getModRef(IRMemLocation::FirstTarget);
+    for (unsigned ILoc = static_cast<unsigned>(IRMemLocation::FirstTarget) + 1;
+         ILoc <= static_cast<unsigned>(IRMemLocation::Last); ++ILoc) {
+      const auto Loc = static_cast<IRMemLocation>(ILoc);
+      ModRefInfo MR = getModRef(Loc);
+      if (First != MR)
+        return false;
+    }
+    return true;
+  }
----------------
antoniofrighetto wrote:

```suggestion
  bool isTargetMemLocSameForAll() const {
    auto First = static_cast<unsigned>(IRMemLocation::FirstTarget);
    auto Last = static_cast<unsigned>(IRMemLocation::Last);

    ModRefInfo Expected = getModRef(IRMemLocation::FirstTarget);
    for (unsigned ILoc = First + 1; ILoc <= Last; ++ILoc)
      if (getModRef(static_cast<IRMemLocation>(ILoc)) != Expected)
        return false;
    return true;
  }
```

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


More information about the Mlir-commits mailing list