[flang-commits] [flang] [flang] Characterize allocation based on MemAlloc effect instead of pattern matching (PR #166806)
Susan Tan ス-ザン タン via flang-commits
flang-commits at lists.llvm.org
Thu Nov 6 13:50:16 PST 2025
https://github.com/SusanTan updated https://github.com/llvm/llvm-project/pull/166806
>From 05e4d390b46f5078c82a6f399c75cf1b034a7927 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Wed, 5 Nov 2025 19:13:01 -0800
Subject: [PATCH 1/9] first implementation
---
.../lib/Optimizer/Analysis/AliasAnalysis.cpp | 37 +++++++++++++++++++
.../AliasAnalysis/cuf-alloc-source-kind.mlir | 22 +++++++++++
2 files changed, 59 insertions(+)
create mode 100644 flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 73ddd1ff80126..2fabf8d7e95bf 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -22,6 +22,7 @@
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
+#include "mlir/Interfaces/ViewLikeInterface.h"
using namespace mlir;
@@ -535,6 +536,42 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
mlir::Operation *instantiationPoint{nullptr};
while (defOp && !breakFromLoop) {
ty = defOp->getResultTypes()[0];
+
+ // Effect-based detection using op-scoped Allocate with conservative
+ // heuristics (ignore value-scoped signals per request).
+ if (auto memIface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(defOp)) {
+ llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
+ memIface.getEffects(effects);
+ bool sawOpScopedAlloc = false;
+ for (auto &ei : effects) {
+ bool isAlloc = mlir::isa<mlir::MemoryEffects::Allocate>(ei.getEffect());
+ if (!ei.getValue() && isAlloc) {
+ sawOpScopedAlloc = true;
+ }
+ }
+ if (sawOpScopedAlloc) {
+ auto isMemoryRefLikeType = [](mlir::Type t) {
+ return fir::isa_ref_type(t) || mlir::isa<mlir::BaseMemRefType>(t) ||
+ mlir::isa<mlir::LLVM::LLVMPointerType>(t);
+ };
+ bool opIsViewLike = (bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(defOp);
+ bool hasMemOperands = llvm::any_of(defOp->getOperands(), [&](mlir::Value opnd) {
+ return isMemoryRefLikeType(opnd.getType());
+ });
+ if (!opIsViewLike && !hasMemOperands) {
+ for (mlir::Value res : defOp->getResults()) {
+ if (res == v && isMemoryRefLikeType(res.getType())) {
+ type = SourceKind::Allocate;
+ breakFromLoop = true;
+ break;
+ }
+ }
+ if (breakFromLoop)
+ break;
+ }
+ }
+ }
+
llvm::TypeSwitch<Operation *>(defOp)
.Case<hlfir::AsExprOp>([&](auto op) {
v = op.getVar();
diff --git a/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir b/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
new file mode 100644
index 0000000000000..6a911f8ff25e3
--- /dev/null
+++ b/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
@@ -0,0 +1,22 @@
+// REQUIRES: asserts
+// RUN: fir-opt %s -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' -debug-only=fir-alias-analysis --mlir-disable-threading 2>&1 | FileCheck %s
+
+// Verify that a CUF allocation is recognized as SourceKind::Allocate by
+// fir::AliasAnalysis::getSource.
+
+module {
+ func.func @_QQmain() attributes {fir.bindc_name = "TEST"} {
+ // Allocate two independent device arrays and tag the results; with
+ // op-scoped MemAlloc handling in AA, these should be classified as
+ // Allocate and not alias.
+ %a = cuf.alloc !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "a1", data_attr = #cuf.cuda<device>, uniq_name = "_QFEa1", test.ptr = "cuf_alloc_a"} -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+ %b = cuf.alloc !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "a2", data_attr = #cuf.cuda<device>, uniq_name = "_QFEa2", test.ptr = "cuf_alloc_b"} -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+ return
+ }
+}
+
+// CHECK-LABEL: Testing : "_QQmain"
+// Distinct allocations should not alias.
+// CHECK: cuf_alloc_a#0 <-> cuf_alloc_b#0: NoAlias
+
+
>From 0295bd12cfa1036e9569cbbe752668cfbb9265a3 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Wed, 5 Nov 2025 19:37:10 -0800
Subject: [PATCH 2/9] replace the main memalloc
---
.../lib/Optimizer/Analysis/AliasAnalysis.cpp | 91 ++++++++++++++-----
1 file changed, 68 insertions(+), 23 deletions(-)
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 2fabf8d7e95bf..f3496de360849 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -534,6 +534,16 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
mlir::SymbolRefAttr global;
Source::Attributes attributes;
mlir::Operation *instantiationPoint{nullptr};
+ // Helper to conservatively classify a candidate value as coming from a
+ // dummy argument or as indirect when no allocation or global can be proven.
+ auto classifyFallbackFrom = [&](mlir::Value candidate) {
+ if (isDummyArgument(candidate)) {
+ defOp = nullptr;
+ v = candidate;
+ } else {
+ type = SourceKind::Indirect;
+ }
+ };
while (defOp && !breakFromLoop) {
ty = defOp->getResultTypes()[0];
@@ -578,22 +588,14 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
defOp = v.getDefiningOp();
})
.Case<hlfir::AssociateOp>([&](auto op) {
+ // Do not pattern-match Allocate. Trace through the source.
mlir::Value source = op.getSource();
- if (fir::isa_trivial(source.getType())) {
- // Trivial values will always use distinct temp memory,
- // so we can classify this as Allocate and stop.
- type = SourceKind::Allocate;
- breakFromLoop = true;
- } else {
- // AssociateOp may reuse the expression storage,
- // so we have to trace further.
- v = source;
- defOp = v.getDefiningOp();
- }
+ v = source;
+ defOp = v.getDefiningOp();
})
.Case<fir::AllocaOp, fir::AllocMemOp>([&](auto op) {
- // Unique memory allocation.
- type = SourceKind::Allocate;
+ // Do not pattern-match allocations by op name; rely on memory
+ // effects classification above. Nothing to do here.
breakFromLoop = true;
})
.Case<fir::ConvertOp>([&](auto op) {
@@ -665,17 +667,60 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
type = SourceKind::Global;
} else {
auto def = llvm::cast<mlir::Value>(boxSrc.origin.u);
- // TODO: Add support to fir.allocmem
- if (auto allocOp = def.template getDefiningOp<fir::AllocaOp>()) {
- v = def;
- defOp = v.getDefiningOp();
- type = SourceKind::Allocate;
- } else if (isDummyArgument(def)) {
- defOp = nullptr;
- v = def;
- } else {
- type = SourceKind::Indirect;
+ bool classified = false;
+ if (auto defDefOp = def.getDefiningOp()) {
+ if (auto defIface =
+ llvm::dyn_cast<mlir::MemoryEffectOpInterface>(defDefOp)) {
+ llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> eff;
+ defIface.getEffects(eff);
+ // Prefer value-scoped Allocate on the underlying storage.
+ for (auto &e : eff) {
+ if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
+ e.getValue() && e.getValue() == def) {
+ v = def;
+ defOp = v.getDefiningOp();
+ type = SourceKind::Allocate;
+ classified = true;
+ break;
+ }
+ }
+ // Heuristic for op-scoped Allocate at the underlying defining op.
+ if (!classified) {
+ bool sawOpScopedAlloc = llvm::any_of(
+ eff, [](auto &e) {
+ return !e.getValue() &&
+ mlir::isa<mlir::MemoryEffects::Allocate>(
+ e.getEffect());
+ });
+ if (sawOpScopedAlloc) {
+ auto isMemoryRefLikeType = [](mlir::Type t) {
+ return fir::isa_ref_type(t) ||
+ mlir::isa<mlir::BaseMemRefType>(t) ||
+ mlir::isa<mlir::LLVM::LLVMPointerType>(t);
+ };
+ bool opIsViewLike = (bool)mlir::dyn_cast_or_null<
+ mlir::ViewLikeOpInterface>(defDefOp);
+ bool hasMemOperands = llvm::any_of(
+ defDefOp->getOperands(), [&](mlir::Value opnd) {
+ return isMemoryRefLikeType(opnd.getType());
+ });
+ if (!opIsViewLike && !hasMemOperands) {
+ for (mlir::Value res : defDefOp->getResults()) {
+ if (res == def && isMemoryRefLikeType(res.getType())) {
+ v = def;
+ defOp = v.getDefiningOp();
+ type = SourceKind::Allocate;
+ classified = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
}
+ if (!classified)
+ classifyFallbackFrom(def);
}
breakFromLoop = true;
return;
>From 4e64702e18ed3b0037a3b3f5a2aede4a7055b36d Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 08:53:46 -0800
Subject: [PATCH 3/9] refactor
---
.../lib/Optimizer/Analysis/AliasAnalysis.cpp | 169 +++++++++---------
1 file changed, 81 insertions(+), 88 deletions(-)
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index f3496de360849..94f9ec5892c58 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -28,6 +28,67 @@ using namespace mlir;
#define DEBUG_TYPE "fir-alias-analysis"
+//===----------------------------------------------------------------------===//
+// AliasAnalysis: alias helpers
+//===----------------------------------------------------------------------===//
+
+static bool tryClassifyAllocateFromEffects(mlir::Operation *op,
+ mlir::Value candidate, bool allowValueScoped, bool allowOpScoped,
+ mlir::Value &v, mlir::Operation *&defOp,
+ fir::AliasAnalysis::SourceKind &type) {
+ auto iface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
+ if (!iface)
+ return false;
+
+ llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
+ iface.getEffects(effects);
+
+ if (allowValueScoped) {
+ for (mlir::MemoryEffects::EffectInstance &e : effects) {
+ if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
+ e.getValue() && e.getValue() == candidate) {
+ v = candidate;
+ defOp = op;
+ type = fir::AliasAnalysis::SourceKind::Allocate;
+ return true;
+ }
+ }
+ }
+
+ if (!allowOpScoped)
+ return false;
+
+ bool hasOpScopedAlloc = llvm::any_of(
+ effects, [](const mlir::MemoryEffects::EffectInstance &e) {
+ return !e.getValue() &&
+ mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect());
+ });
+ if (!hasOpScopedAlloc)
+ return false;
+
+ bool opIsViewLike =
+ (bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(op);
+ auto isMemoryRefLikeType = [](mlir::Type type) {
+ return fir::isa_ref_type(type) || mlir::isa<mlir::BaseMemRefType>(type) ||
+ mlir::isa<mlir::LLVM::LLVMPointerType>(type);
+ };
+ bool hasMemOperands = llvm::any_of(op->getOperands(), [&](mlir::Value o) {
+ return isMemoryRefLikeType(o.getType());
+ });
+ if (opIsViewLike || hasMemOperands)
+ return false;
+
+ for (mlir::Value res : op->getResults()) {
+ if (res == candidate && isMemoryRefLikeType(res.getType())) {
+ v = candidate;
+ defOp = op;
+ type = fir::AliasAnalysis::SourceKind::Allocate;
+ return true;
+ }
+ }
+ return false;
+}
+
//===----------------------------------------------------------------------===//
// AliasAnalysis: alias
//===----------------------------------------------------------------------===//
@@ -544,43 +605,22 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
type = SourceKind::Indirect;
}
};
+
+ // Helper to detect memory-ref-like types.
+ auto isMemoryRefLikeType = [](mlir::Type t) {
+ return fir::isa_ref_type(t) || mlir::isa<mlir::BaseMemRefType>(t) ||
+ mlir::isa<mlir::LLVM::LLVMPointerType>(t);
+ };
+
while (defOp && !breakFromLoop) {
ty = defOp->getResultTypes()[0];
- // Effect-based detection using op-scoped Allocate with conservative
- // heuristics (ignore value-scoped signals per request).
- if (auto memIface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(defOp)) {
- llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
- memIface.getEffects(effects);
- bool sawOpScopedAlloc = false;
- for (auto &ei : effects) {
- bool isAlloc = mlir::isa<mlir::MemoryEffects::Allocate>(ei.getEffect());
- if (!ei.getValue() && isAlloc) {
- sawOpScopedAlloc = true;
- }
- }
- if (sawOpScopedAlloc) {
- auto isMemoryRefLikeType = [](mlir::Type t) {
- return fir::isa_ref_type(t) || mlir::isa<mlir::BaseMemRefType>(t) ||
- mlir::isa<mlir::LLVM::LLVMPointerType>(t);
- };
- bool opIsViewLike = (bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(defOp);
- bool hasMemOperands = llvm::any_of(defOp->getOperands(), [&](mlir::Value opnd) {
- return isMemoryRefLikeType(opnd.getType());
- });
- if (!opIsViewLike && !hasMemOperands) {
- for (mlir::Value res : defOp->getResults()) {
- if (res == v && isMemoryRefLikeType(res.getType())) {
- type = SourceKind::Allocate;
- breakFromLoop = true;
- break;
- }
- }
- if (breakFromLoop)
- break;
- }
- }
- }
+ // Effect-based detection (op-scoped heuristic only at this level).
+ if (tryClassifyAllocateFromEffects(defOp, v,
+ /*allowValueScoped=*/false,
+ /*allowOpScoped=*/true,
+ v, defOp, type))
+ break;
llvm::TypeSwitch<Operation *>(defOp)
.Case<hlfir::AsExprOp>([&](auto op) {
@@ -666,61 +706,14 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
if (global) {
type = SourceKind::Global;
} else {
- auto def = llvm::cast<mlir::Value>(boxSrc.origin.u);
+ mlir::Value def = llvm::cast<mlir::Value>(boxSrc.origin.u);
bool classified = false;
- if (auto defDefOp = def.getDefiningOp()) {
- if (auto defIface =
- llvm::dyn_cast<mlir::MemoryEffectOpInterface>(defDefOp)) {
- llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> eff;
- defIface.getEffects(eff);
- // Prefer value-scoped Allocate on the underlying storage.
- for (auto &e : eff) {
- if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
- e.getValue() && e.getValue() == def) {
- v = def;
- defOp = v.getDefiningOp();
- type = SourceKind::Allocate;
- classified = true;
- break;
- }
- }
- // Heuristic for op-scoped Allocate at the underlying defining op.
- if (!classified) {
- bool sawOpScopedAlloc = llvm::any_of(
- eff, [](auto &e) {
- return !e.getValue() &&
- mlir::isa<mlir::MemoryEffects::Allocate>(
- e.getEffect());
- });
- if (sawOpScopedAlloc) {
- auto isMemoryRefLikeType = [](mlir::Type t) {
- return fir::isa_ref_type(t) ||
- mlir::isa<mlir::BaseMemRefType>(t) ||
- mlir::isa<mlir::LLVM::LLVMPointerType>(t);
- };
- bool opIsViewLike = (bool)mlir::dyn_cast_or_null<
- mlir::ViewLikeOpInterface>(defDefOp);
- bool hasMemOperands = llvm::any_of(
- defDefOp->getOperands(), [&](mlir::Value opnd) {
- return isMemoryRefLikeType(opnd.getType());
- });
- if (!opIsViewLike && !hasMemOperands) {
- for (mlir::Value res : defDefOp->getResults()) {
- if (res == def && isMemoryRefLikeType(res.getType())) {
- v = def;
- defOp = v.getDefiningOp();
- type = SourceKind::Allocate;
- classified = true;
- break;
- }
- }
- }
- }
- }
- }
- }
- if (!classified)
- classifyFallbackFrom(def);
+ if (auto defDefOp = def.getDefiningOp())
+ classified = tryClassifyAllocateFromEffects(
+ defDefOp, def,
+ /*allowValueScoped=*/true, /*allowOpScoped=*/true,
+ v, defOp, type);
+ if (!classified) classifyFallbackFrom(def);
}
breakFromLoop = true;
return;
>From d4ffa26657ba26970045ff31c1dec7052c7a953e Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 09:19:58 -0800
Subject: [PATCH 4/9] cleanup
---
.../lib/Optimizer/Analysis/AliasAnalysis.cpp | 27 ++++++++++---------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 94f9ec5892c58..2c43db7f81218 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -19,23 +19,24 @@
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Value.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
+#include "mlir/Interfaces/ViewLikeInterface.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
-#include "mlir/Interfaces/ViewLikeInterface.h"
using namespace mlir;
#define DEBUG_TYPE "fir-alias-analysis"
//===----------------------------------------------------------------------===//
-// AliasAnalysis: alias helpers
+// AliasAnalysis: allocation detection based on MemAlloc effect
//===----------------------------------------------------------------------===//
-static bool tryClassifyAllocateFromEffects(mlir::Operation *op,
- mlir::Value candidate, bool allowValueScoped, bool allowOpScoped,
- mlir::Value &v, mlir::Operation *&defOp,
- fir::AliasAnalysis::SourceKind &type) {
+static bool
+tryClassifyAllocateFromEffects(mlir::Operation *op, mlir::Value candidate,
+ bool allowValueScoped, bool allowOpScoped,
+ mlir::Value &v, mlir::Operation *&defOp,
+ fir::AliasAnalysis::SourceKind &type) {
auto iface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
if (!iface)
return false;
@@ -58,8 +59,8 @@ static bool tryClassifyAllocateFromEffects(mlir::Operation *op,
if (!allowOpScoped)
return false;
- bool hasOpScopedAlloc = llvm::any_of(
- effects, [](const mlir::MemoryEffects::EffectInstance &e) {
+ bool hasOpScopedAlloc =
+ llvm::any_of(effects, [](const mlir::MemoryEffects::EffectInstance &e) {
return !e.getValue() &&
mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect());
});
@@ -618,8 +619,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
// Effect-based detection (op-scoped heuristic only at this level).
if (tryClassifyAllocateFromEffects(defOp, v,
/*allowValueScoped=*/false,
- /*allowOpScoped=*/true,
- v, defOp, type))
+ /*allowOpScoped=*/true, v, defOp, type))
break;
llvm::TypeSwitch<Operation *>(defOp)
@@ -711,9 +711,10 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
if (auto defDefOp = def.getDefiningOp())
classified = tryClassifyAllocateFromEffects(
defDefOp, def,
- /*allowValueScoped=*/true, /*allowOpScoped=*/true,
- v, defOp, type);
- if (!classified) classifyFallbackFrom(def);
+ /*allowValueScoped=*/true, /*allowOpScoped=*/true, v, defOp,
+ type);
+ if (!classified)
+ classifyFallbackFrom(def);
}
breakFromLoop = true;
return;
>From 163cda55aa4fc0fe574f73253b2b8d74b435c5b8 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 09:27:31 -0800
Subject: [PATCH 5/9] rm unused function
---
flang/lib/Optimizer/Analysis/AliasAnalysis.cpp | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 2c43db7f81218..b9cc5a4c8b261 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -69,18 +69,18 @@ tryClassifyAllocateFromEffects(mlir::Operation *op, mlir::Value candidate,
bool opIsViewLike =
(bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(op);
- auto isMemoryRefLikeType = [](mlir::Type type) {
+ auto isMemRefLikeType = [](mlir::Type type) {
return fir::isa_ref_type(type) || mlir::isa<mlir::BaseMemRefType>(type) ||
mlir::isa<mlir::LLVM::LLVMPointerType>(type);
};
bool hasMemOperands = llvm::any_of(op->getOperands(), [&](mlir::Value o) {
- return isMemoryRefLikeType(o.getType());
+ return isMemRefLikeType(o.getType());
});
if (opIsViewLike || hasMemOperands)
return false;
for (mlir::Value res : op->getResults()) {
- if (res == candidate && isMemoryRefLikeType(res.getType())) {
+ if (res == candidate && isMemRefLikeType(res.getType())) {
v = candidate;
defOp = op;
type = fir::AliasAnalysis::SourceKind::Allocate;
@@ -607,12 +607,6 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
}
};
- // Helper to detect memory-ref-like types.
- auto isMemoryRefLikeType = [](mlir::Type t) {
- return fir::isa_ref_type(t) || mlir::isa<mlir::BaseMemRefType>(t) ||
- mlir::isa<mlir::LLVM::LLVMPointerType>(t);
- };
-
while (defOp && !breakFromLoop) {
ty = defOp->getResultTypes()[0];
>From 538424c7820884414128ae61b56488ddf43f1f53 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 10:55:44 -0800
Subject: [PATCH 6/9] change cuf
---
flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td | 8 +++++++-
flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp | 9 +++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td b/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
index e38738230ffbc..6a19dc0370f84 100644
--- a/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
+++ b/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
@@ -21,13 +21,14 @@ include "flang/Optimizer/Dialect/FIRAttr.td"
include "mlir/Dialect/GPU/IR/GPUBase.td"
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
include "mlir/Interfaces/LoopLikeInterface.td"
+include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/IR/BuiltinAttributes.td"
class cuf_Op<string mnemonic, list<Trait> traits>
: Op<CUFDialect, mnemonic, traits>;
def cuf_AllocOp : cuf_Op<"alloc", [AttrSizedOperandSegments,
- MemoryEffects<[MemAlloc]>]> {
+ MemoryEffectsOpInterface]> {
let summary = "Allocate an object on device";
let description = [{
@@ -62,6 +63,11 @@ def cuf_AllocOp : cuf_Op<"alloc", [AttrSizedOperandSegments,
CArg<"mlir::ValueRange", "{}">:$shape,
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+ let extraClassDeclaration = [{
+ void getEffects(
+ llvm::SmallVectorImpl<mlir::MemoryEffects::EffectInstance> &effects);
+ }];
+
let hasVerifier = 1;
}
diff --git a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
index 687007d957225..65283872afa34 100644
--- a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
+++ b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
@@ -24,6 +24,7 @@
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/PatternMatch.h"
+#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "llvm/ADT/SmallVector.h"
//===----------------------------------------------------------------------===//
@@ -66,6 +67,14 @@ static llvm::LogicalResult checkCudaAttr(Op op) {
llvm::LogicalResult cuf::AllocOp::verify() { return checkCudaAttr(*this); }
+// Attach value-scoped MemAlloc to the result value.
+void cuf::AllocOp::getEffects(
+ llvm::SmallVectorImpl<mlir::MemoryEffects::EffectInstance> &effects) {
+ effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
+ mlir::cast<mlir::OpResult>(getPtr()),
+ mlir::SideEffects::DefaultResource::get());
+}
+
//===----------------------------------------------------------------------===//
// FreeOp
//===----------------------------------------------------------------------===//
>From 3e216425b1c5be55b2601435eaedaee03952bf91 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 13:46:50 -0800
Subject: [PATCH 7/9] change to value base
---
.../include/flang/Optimizer/Dialect/FIROps.td | 931 ++++++++----------
.../lib/Optimizer/Analysis/AliasAnalysis.cpp | 117 +--
flang/lib/Optimizer/Dialect/FIROps.cpp | 28 +
3 files changed, 482 insertions(+), 594 deletions(-)
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index bae52d63fda45..087eadf836e18 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -30,22 +30,22 @@ include "mlir/IR/BuiltinAttributes.td"
// Base class for FIR operations.
// All operations automatically get a prefix of "fir.".
class fir_Op<string mnemonic, list<Trait> traits>
- : Op<FIROpsDialect, mnemonic, traits>;
+ : Op<FIROpsDialect, mnemonic, traits>;
// Base class for FIR operations that take a single argument
class fir_SimpleOp<string mnemonic, list<Trait> traits>
- : fir_Op<mnemonic, traits> {
+ : fir_Op<mnemonic, traits> {
let assemblyFormat = [{
operands attr-dict `:` functional-type(operands, results)
}];
}
-def fir_OneResultOpBuilder : OpBuilder<(ins
- "mlir::Type":$resultType,
- "mlir::ValueRange":$operands,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
- [{
+def fir_OneResultOpBuilder
+ : OpBuilder<
+ (ins "mlir::Type":$resultType, "mlir::ValueRange":$operands,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+ [{
if (resultType)
$_state.addTypes(resultType);
$_state.addOperands(operands);
@@ -53,35 +53,36 @@ def fir_OneResultOpBuilder : OpBuilder<(ins
}]>;
// Base class of FIR operations that return 1 result
-class fir_OneResultOp<string mnemonic, list<Trait> traits = []> :
- fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
+class fir_OneResultOp<string mnemonic, list<Trait> traits = []>
+ : fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
let builders = [fir_OneResultOpBuilder];
}
// Base class of FIR operations that have 1 argument and return 1 result
-class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []> :
- fir_SimpleOp<mnemonic, traits> {
+class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []>
+ : fir_SimpleOp<mnemonic, traits> {
let builders = [fir_OneResultOpBuilder];
}
// Whether a type is a BaseBoxType or a reference to a BaseBoxType.
-def IsBoxAddressOrValueTypePred
- : CPred<"::fir::isBoxAddressOrValue($_self)">;
+def IsBoxAddressOrValueTypePred : CPred<"::fir::isBoxAddressOrValue($_self)">;
def fir_BoxAddressOrValueType : Type<IsBoxAddressOrValueTypePred,
- "fir.box or fir.class type or reference">;
+ "fir.box or fir.class type or reference">;
def RefOfConstantSizeAggregateTypePred
- : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
-def AnyRefOfConstantSizeAggregateType : TypeConstraint<
- RefOfConstantSizeAggregateTypePred,
- "a reference type to a constant size fir.array, fir.char, or fir.type">;
+ : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
+def AnyRefOfConstantSizeAggregateType
+ : TypeConstraint<RefOfConstantSizeAggregateTypePred,
+ "a reference type to a constant size fir.array, fir.char, "
+ "or fir.type">;
//===----------------------------------------------------------------------===//
// Memory SSA operations
//===----------------------------------------------------------------------===//
-def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
- MemoryEffects<[MemAlloc<AutomaticAllocationScopeResource>]>]> {
+def fir_AllocaOp
+ : fir_Op<"alloca", [AttrSizedOperandSegments,
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
let summary = "allocate storage for a temporary on the stack given a type";
let description = [{
This primitive operation is used to allocate an object on the stack. A
@@ -153,46 +154,42 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
region and avoid them being hoisted in an alloca hoisting pass.
}];
- let arguments = (ins
- TypeAttr:$in_type,
- OptionalAttr<StrAttr>:$uniq_name,
- OptionalAttr<StrAttr>:$bindc_name,
- UnitAttr:$pinned,
- Variadic<AnyIntegerType>:$typeparams,
- Variadic<AnyIntegerType>:$shape
- );
+ let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
+ OptionalAttr<StrAttr>:$bindc_name, UnitAttr:$pinned,
+ Variadic<AnyIntegerType>:$typeparams, Variadic<AnyIntegerType>:$shape);
let results = (outs fir_ReferenceType);
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
- let builders = [
- OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
- "llvm::StringRef":$bindcName, CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::ValueRange", "{}">:$shape,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
- OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
- "llvm::StringRef":$bindcName, "bool":$pinned,
- CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::ValueRange", "{}">:$shape,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
- OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
- CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::ValueRange", "{}">:$shape,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
- OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
- "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::ValueRange", "{}">:$shape,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
- OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
- CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::ValueRange", "{}">:$shape,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
- OpBuilder<(ins "mlir::Type":$inType,
- CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::ValueRange", "{}">:$shape,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+ let builders =
+ [OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+ "llvm::StringRef":$bindcName,
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::ValueRange", "{}">:$shape,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+ OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+ "llvm::StringRef":$bindcName, "bool":$pinned,
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::ValueRange", "{}">:$shape,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+ OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::ValueRange", "{}">:$shape,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+ OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+ "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::ValueRange", "{}">:$shape,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+ OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::ValueRange", "{}">:$shape,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+ OpBuilder<(ins "mlir::Type":$inType,
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::ValueRange", "{}">:$shape,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
let extraClassDeclaration = [{
mlir::Type getAllocatedType();
@@ -212,8 +209,9 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
}];
}
-def fir_AllocMemOp : fir_Op<"allocmem",
- [MemoryEffects<[MemAlloc<DefaultResource>]>, AttrSizedOperandSegments]> {
+def fir_AllocMemOp
+ : fir_Op<"allocmem", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
+ AttrSizedOperandSegments]> {
let summary = "allocate storage on the heap for an object of a given type";
let description = [{
@@ -228,31 +226,28 @@ def fir_AllocMemOp : fir_Op<"allocmem",
```
}];
- let arguments = (ins
- TypeAttr:$in_type,
- OptionalAttr<StrAttr>:$uniq_name,
- OptionalAttr<StrAttr>:$bindc_name,
- Variadic<AnyIntegerType>:$typeparams,
- Variadic<AnyIntegerType>:$shape
- );
+ let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
+ OptionalAttr<StrAttr>:$bindc_name, Variadic<AnyIntegerType>:$typeparams,
+ Variadic<AnyIntegerType>:$shape);
let results = (outs fir_HeapType);
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
- let builders = [
- OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
- "llvm::StringRef":$bindc_name, CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::ValueRange", "{}">:$shape,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
- OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
- CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::ValueRange", "{}">:$shape,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
- OpBuilder<(ins "mlir::Type":$in_type,
- CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::ValueRange", "{}">:$shape,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+ let builders =
+ [OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+ "llvm::StringRef":$bindc_name,
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::ValueRange", "{}">:$shape,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+ OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::ValueRange", "{}">:$shape,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+ OpBuilder<(ins "mlir::Type":$in_type,
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::ValueRange", "{}">:$shape,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
let extraClassDeclaration = [{
mlir::Type getAllocatedType();
@@ -288,8 +283,10 @@ def fir_FreeMemOp : fir_Op<"freemem", [MemoryEffects<[MemFree]>]> {
let assemblyFormat = "$heapref attr-dict `:` qualified(type($heapref))";
}
-def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface,
- DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_LoadOp
+ : fir_OneResultOp<
+ "load", [FirAliasTagOpInterface,
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
let summary = "load a value from a memory reference";
let description = [{
Load a value from a memory reference into an ssa-value (virtual register).
@@ -318,8 +315,9 @@ def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface,
}];
}
-def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
- DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_StoreOp
+ : fir_Op<"store", [FirAliasTagOpInterface,
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
let summary = "store an SSA-value to a memory location";
let description = [{
@@ -351,7 +349,8 @@ def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
}];
}
-def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_CopyOp
+ : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
let summary = "copy constant size memory";
let description = [{
@@ -373,12 +372,11 @@ def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterf
}];
let arguments = (ins AnyRefOfConstantSizeAggregateType:$source,
- AnyRefOfConstantSizeAggregateType:$destination,
- OptionalAttr<UnitAttr>:$no_overlap);
+ AnyRefOfConstantSizeAggregateType:$destination,
+ OptionalAttr<UnitAttr>:$no_overlap);
let builders = [OpBuilder<(ins "mlir::Value":$source,
- "mlir::Value":$destination,
- CArg<"bool", "false">:$no_overlap)>];
+ "mlir::Value":$destination, CArg<"bool", "false">:$no_overlap)>];
let assemblyFormat = [{
$source `to` $destination (`no_overlap` $no_overlap^)?
@@ -388,7 +386,6 @@ def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterf
let hasVerifier = 1;
}
-
def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
let summary = [{
save an array, box, or record function result SSA-value to a memory location
@@ -425,9 +422,8 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
}];
let arguments = (ins ArrayOrBoxOrRecord:$value,
- Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
- Optional<AnyShapeType>:$shape,
- Variadic<AnyIntegerType>:$typeparams);
+ Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
+ Optional<AnyShapeType>:$shape, Variadic<AnyIntegerType>:$typeparams);
let assemblyFormat = [{
$value `to` $memref (`(` $shape^ `)`)? (`typeparams` $typeparams^)?
@@ -464,11 +460,8 @@ def fir_CharConvertOp : fir_Op<"char_convert", []> {
`count` limit. These details are left as future to-dos.
}];
- let arguments = (ins
- Arg<AnyReferenceLike, "", [MemRead]>:$from,
- AnyIntegerType:$count,
- Arg<AnyReferenceLike, "", [MemWrite]>:$to
- );
+ let arguments = (ins Arg<AnyReferenceLike, "", [MemRead]>:$from,
+ AnyIntegerType:$count, Arg<AnyReferenceLike, "", [MemWrite]>:$to);
let assemblyFormat = [{
$from `for` $count `to` $to attr-dict `:` type(operands)
@@ -496,7 +489,8 @@ def fir_UndefOp : fir_OneResultOp<"undefined", [NoMemoryEffect]> {
let assemblyFormat = "type($intype) attr-dict";
- // Note: we allow `undef : ref<T>` since it is a possible from transformations.
+ // Note: we allow `undef : ref<T>` since it is a possible from
+ // transformations.
let hasVerifier = 0;
}
@@ -522,15 +516,14 @@ def fir_ZeroOp : fir_OneResultOp<"zero_bits", [NoMemoryEffect]> {
// Terminator operations
//===----------------------------------------------------------------------===//
-class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []> :
- fir_Op<mnemonic, !listconcat(traits, [AttrSizedOperandSegments,
- DeclareOpInterfaceMethods<BranchOpInterface>, Terminator])> {
+class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
+ : fir_Op<mnemonic,
+ !listconcat(traits, [AttrSizedOperandSegments,
+ DeclareOpInterfaceMethods<BranchOpInterface>,
+ Terminator])> {
- let arguments = (ins
- AnyType:$selector,
- Variadic<AnyType>:$compareArgs,
- Variadic<AnyType>:$targetArgs
- );
+ let arguments = (ins AnyType:$selector, Variadic<AnyType>:$compareArgs,
+ Variadic<AnyType>:$targetArgs);
let results = (outs);
@@ -583,16 +576,16 @@ class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []> :
}];
}
-class fir_IntegralSwitchTerminatorOp<string mnemonic,
- list<Trait> traits = []> : fir_SwitchTerminatorOp<mnemonic, traits> {
+class fir_IntegralSwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
+ : fir_SwitchTerminatorOp<mnemonic, traits> {
let skipDefaultBuilders = 1;
- let builders = [OpBuilder<(ins "mlir::Value":$selector,
- "llvm::ArrayRef<int64_t>":$compareOperands,
- "llvm::ArrayRef<mlir::Block *>":$destinations,
- CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
- [{
+ let builders = [OpBuilder<
+ (ins "mlir::Value":$selector, "llvm::ArrayRef<int64_t>":$compareOperands,
+ "llvm::ArrayRef<mlir::Block *>":$destinations,
+ CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+ [{
$_state.addOperands(selector);
llvm::SmallVector<mlir::Attribute> ivalues;
for (auto iv : compareOperands)
@@ -620,8 +613,7 @@ class fir_IntegralSwitchTerminatorOp<string mnemonic,
$_state.addAttribute(getTargetOffsetAttr(),
$_builder.getDenseI32ArrayAttr(argOffs));
$_state.addAttributes(attributes);
- }]
- >];
+ }]>];
let extraClassDeclaration = extraSwitchClassDeclaration;
}
@@ -647,7 +639,6 @@ def fir_SelectOp : fir_IntegralSwitchTerminatorOp<"select"> {
}];
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
-
}
def fir_SelectRankOp : fir_IntegralSwitchTerminatorOp<"select_rank"> {
@@ -693,19 +684,19 @@ def fir_SelectCaseOp : fir_SwitchTerminatorOp<"select_case"> {
}];
let skipDefaultBuilders = 1;
- let builders = [
- OpBuilder<(ins "mlir::Value":$selector,
- "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
- "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
- "llvm::ArrayRef<mlir::Block *>":$destinations,
- CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
- OpBuilder<(ins "mlir::Value":$selector,
- "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
- "llvm::ArrayRef<mlir::Value>":$cmpOpList,
- "llvm::ArrayRef<mlir::Block *>":$destinations,
- CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+ let builders =
+ [OpBuilder<(ins "mlir::Value":$selector,
+ "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+ "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
+ "llvm::ArrayRef<mlir::Block *>":$destinations,
+ CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+ OpBuilder<(ins "mlir::Value":$selector,
+ "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+ "llvm::ArrayRef<mlir::Value>":$cmpOpList,
+ "llvm::ArrayRef<mlir::Block *>":$destinations,
+ CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
@@ -737,10 +728,10 @@ def fir_SelectTypeOp : fir_SwitchTerminatorOp<"select_type"> {
let skipDefaultBuilders = 1;
let builders = [OpBuilder<(ins "mlir::Value":$selector,
- "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
- "llvm::ArrayRef<mlir::Block *>":$destinations,
- CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+ "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
+ "llvm::ArrayRef<mlir::Block *>":$destinations,
+ CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
@@ -764,7 +755,6 @@ def fir_UnreachableOp : fir_Op<"unreachable", [Terminator]> {
}];
let assemblyFormat = [{ attr-dict }];
-
}
def fir_FirEndOp : fir_Op<"end", [Terminator, NoMemoryEffect]> {
@@ -843,17 +833,15 @@ def fir_EmboxOp : fir_Op<"embox", [NoMemoryEffect, AttrSizedOperandSegments]> {
let results = (outs BoxOrClassType);
- let builders = [
- OpBuilder<(ins "llvm::ArrayRef<mlir::Type>":$resultTypes,
- "mlir::Value":$memref, CArg<"mlir::Value", "{}">:$shape,
- CArg<"mlir::Value", "{}">:$slice,
- CArg<"mlir::ValueRange", "{}">:$typeparams,
- CArg<"mlir::Value", "{}">:$sourceBox,
- CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
- [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
+ let builders = [OpBuilder<
+ (ins "llvm::ArrayRef<mlir::Type>":$resultTypes, "mlir::Value":$memref,
+ CArg<"mlir::Value", "{}">:$shape, CArg<"mlir::Value", "{}">:$slice,
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"mlir::Value", "{}">:$sourceBox,
+ CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
+ [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
typeparams, sourceBox, mlir::AffineMapAttr{},
- allocator_idx); }]>
- ];
+ allocator_idx); }]>];
let assemblyFormat = [{
$memref (`(` $shape^ `)`)? (`[` $slice^ `]`)? (`typeparams` $typeparams^)?
@@ -909,11 +897,8 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
```
}];
- let arguments = (ins
- BoxOrClassType:$box,
- Optional<AnyShapeOrShiftType>:$shape,
- Optional<fir_SliceType>:$slice
- );
+ let arguments = (ins BoxOrClassType:$box,
+ Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice);
let results = (outs BoxOrClassType);
@@ -925,8 +910,9 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
let hasVerifier = 1;
}
-def fir_ReboxAssumedRankOp : fir_Op<"rebox_assumed_rank",
- [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ReboxAssumedRankOp
+ : fir_Op<"rebox_assumed_rank", [DeclareOpInterfaceMethods<
+ MemoryEffectsOpInterface>]> {
let summary = "create an assumed-rank box given another assumed-rank box";
let description = [{
@@ -947,10 +933,8 @@ def fir_ReboxAssumedRankOp : fir_Op<"rebox_assumed_rank",
```
}];
- let arguments = (ins
- AnyRefOrBoxType:$box,
- fir_LowerBoundModifierAttribute:$lbs_modifier
- );
+ let arguments = (ins AnyRefOrBoxType:$box,
+ fir_LowerBoundModifierAttribute:$lbs_modifier);
let results = (outs BoxOrClassType);
@@ -1171,8 +1155,8 @@ def fir_BoxEleSizeOp : fir_SimpleOneResultOp<"box_elesize", [NoMemoryEffect]> {
let results = (outs AnyIntegerLike);
}
-def fir_BoxTypeCodeOp : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]>
-{
+def fir_BoxTypeCodeOp
+ : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]> {
let summary = "return the type code the boxed value";
let description = [{
@@ -1250,7 +1234,8 @@ def fir_IsAssumedSizeOp : fir_SimpleOp<"is_assumed_size", [NoMemoryEffect]> {
let results = (outs BoolLike);
}
-def fir_AssumedSizeExtentOp : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
+def fir_AssumedSizeExtentOp
+ : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
let summary = "get the assumed-size last extent sentinel";
let description = [{
@@ -1268,7 +1253,8 @@ def fir_AssumedSizeExtentOp : fir_SimpleOneResultOp<"assumed_size_extent", [NoMe
let assemblyFormat = "attr-dict `:` type(results)";
}
-def fir_IsAssumedSizeExtentOp : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
+def fir_IsAssumedSizeExtentOp
+ : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
let summary = "is value the assumed-size last extent sentinel";
let description = [{
@@ -1325,8 +1311,9 @@ def fir_BoxProcHostOp : fir_SimpleOp<"boxproc_host", [NoMemoryEffect]> {
let results = (outs fir_ReferenceType);
}
-def fir_BoxRankOp : fir_SimpleOneResultOp<"box_rank",
- [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_BoxRankOp
+ : fir_SimpleOneResultOp<
+ "box_rank", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
let summary = "return the number of dimensions for the boxed value";
let description = [{
@@ -1407,8 +1394,10 @@ def fir_BoxTypeDescOp : fir_SimpleOneResultOp<"box_tdesc", [NoMemoryEffect]> {
// !- Merge the new and old values into the memory for "A"
// array_merge_store <updated A> to <A's address>
-def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
- DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ArrayLoadOp
+ : fir_Op<
+ "array_load", [AttrSizedOperandSegments,
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
let summary = "Load an array as a value.";
@@ -1446,12 +1435,9 @@ def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
```
}];
- let arguments = (ins
- AnyRefOrBox:$memref,
- Optional<AnyShapeOrShiftType>:$shape,
- Optional<fir_SliceType>:$slice,
- Variadic<AnyIntegerType>:$typeparams
- );
+ let arguments = (ins AnyRefOrBox:$memref,
+ Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
+ Variadic<AnyIntegerType>:$typeparams);
let results = (outs fir_SequenceType);
@@ -1467,8 +1453,8 @@ def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
}];
}
-def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
- NoMemoryEffect]> {
+def fir_ArrayFetchOp
+ : fir_Op<"array_fetch", [AttrSizedOperandSegments, NoMemoryEffect]> {
let summary = "Fetch the value of an element of an array value";
@@ -1497,11 +1483,9 @@ def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
It is only possible to use `array_fetch` on an `array_load` result value.
}];
- let arguments = (ins
- fir_SequenceType:$sequence,
- Variadic<AnyCoordinateType>:$indices,
- Variadic<AnyIntegerType>:$typeparams
- );
+ let arguments = (ins fir_SequenceType:$sequence,
+ Variadic<AnyCoordinateType>:$indices,
+ Variadic<AnyIntegerType>:$typeparams);
let results = (outs AnyType:$element);
@@ -1513,8 +1497,8 @@ def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
let hasVerifier = 1;
}
-def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
- NoMemoryEffect]> {
+def fir_ArrayUpdateOp
+ : fir_Op<"array_update", [AttrSizedOperandSegments, NoMemoryEffect]> {
let summary = "Update the value of an element of an array value";
@@ -1548,12 +1532,9 @@ def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
memory until the `fir.array_merge_store` is performed.
}];
- let arguments = (ins
- fir_SequenceType:$sequence,
- AnyType:$merge,
- Variadic<AnyCoordinateType>:$indices,
- Variadic<AnyIntegerType>:$typeparams
- );
+ let arguments = (ins fir_SequenceType:$sequence, AnyType:$merge,
+ Variadic<AnyCoordinateType>:$indices,
+ Variadic<AnyIntegerType>:$typeparams);
let results = (outs fir_SequenceType);
@@ -1565,8 +1546,8 @@ def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
let hasVerifier = 1;
}
-def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
- NoMemoryEffect]> {
+def fir_ArrayModifyOp
+ : fir_Op<"array_modify", [AttrSizedOperandSegments, NoMemoryEffect]> {
let summary = "Get an address for an array value to modify it.";
let description = [{
@@ -1607,11 +1588,9 @@ def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
memory until the `fir.array_merge_store` is performed.
}];
- let arguments = (ins
- fir_SequenceType:$sequence,
- Variadic<AnyCoordinateType>:$indices,
- Variadic<AnyIntegerType>:$typeparams
- );
+ let arguments = (ins fir_SequenceType:$sequence,
+ Variadic<AnyCoordinateType>:$indices,
+ Variadic<AnyIntegerType>:$typeparams);
let results = (outs fir_ReferenceType, fir_SequenceType);
@@ -1623,8 +1602,8 @@ def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
let hasVerifier = 1;
}
-def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
- NoMemoryEffect]> {
+def fir_ArrayAccessOp
+ : fir_Op<"array_access", [AttrSizedOperandSegments, NoMemoryEffect]> {
let summary = "Fetch the reference of an element of an array value";
let description = [{
@@ -1669,11 +1648,9 @@ def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
found in flang/docs/FIRArrayOperations.md.
}];
- let arguments = (ins
- fir_SequenceType:$sequence,
- Variadic<AnyCoordinateType>:$indices,
- Variadic<AnyIntegerType>:$typeparams
- );
+ let arguments = (ins fir_SequenceType:$sequence,
+ Variadic<AnyCoordinateType>:$indices,
+ Variadic<AnyIntegerType>:$typeparams);
let results = (outs fir_ReferenceType:$element);
@@ -1707,10 +1684,7 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
found in flang/docs/FIRArrayOperations.md.
}];
- let arguments = (ins
- fir_SequenceType:$sequence,
- fir_ReferenceType:$memref
- );
+ let arguments = (ins fir_SequenceType:$sequence, fir_ReferenceType:$memref);
let results = (outs fir_SequenceType);
@@ -1719,8 +1693,10 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
}];
}
-def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
- [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ArrayMergeStoreOp
+ : fir_Op<"array_merge_store", [AttrSizedOperandSegments,
+ DeclareOpInterfaceMethods<
+ MemoryEffectsOpInterface>]> {
let summary = "Store merged array value to memory.";
@@ -1746,13 +1722,9 @@ def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
chained updates, `%r`, and stores the result to the array at address, `%a`.
}];
- let arguments = (ins
- fir_SequenceType:$original,
- fir_SequenceType:$sequence,
- AnyRefOrBox:$memref,
- Optional<fir_SliceType>:$slice,
- Variadic<AnyIntegerType>:$typeparams
- );
+ let arguments = (ins fir_SequenceType:$original, fir_SequenceType:$sequence,
+ AnyRefOrBox:$memref, Optional<fir_SliceType>:$slice,
+ Variadic<AnyIntegerType>:$typeparams);
let assemblyFormat = [{
$original `,` $sequence `to` $memref (`[` $slice^ `]`)? (`typeparams`
@@ -1766,8 +1738,8 @@ def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
// Record and array type operations
//===----------------------------------------------------------------------===//
-def fir_ArrayCoorOp : fir_Op<"array_coor",
- [NoMemoryEffect, AttrSizedOperandSegments]> {
+def fir_ArrayCoorOp
+ : fir_Op<"array_coor", [NoMemoryEffect, AttrSizedOperandSegments]> {
let summary = "Find the coordinate of an element of an array";
@@ -1793,13 +1765,10 @@ def fir_ArrayCoorOp : fir_Op<"array_coor",
```
}];
- let arguments = (ins
- AnyRefOrBox:$memref,
- Optional<AnyShapeOrShiftType>:$shape,
- Optional<fir_SliceType>:$slice,
- Variadic<AnyCoordinateType>:$indices,
- Variadic<AnyIntegerType>:$typeparams
- );
+ let arguments = (ins AnyRefOrBox:$memref,
+ Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
+ Variadic<AnyCoordinateType>:$indices,
+ Variadic<AnyIntegerType>:$typeparams);
let results = (outs fir_ReferenceType);
@@ -1843,24 +1812,18 @@ def fir_CoordinateOp : fir_Op<"coordinate_of", [NoMemoryEffect]> {
array `%h`.
}];
- let arguments = (ins
- AnyRefOrBox:$ref,
- Variadic<AnyCoordinateType>:$coor,
- TypeAttr:$baseType,
- OptionalAttr<DenseI32ArrayAttr>:$field_indices
- );
+ let arguments = (ins AnyRefOrBox:$ref, Variadic<AnyCoordinateType>:$coor,
+ TypeAttr:$baseType, OptionalAttr<DenseI32ArrayAttr>:$field_indices);
let results = (outs RefOrLLVMPtr);
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
- let builders = [
- OpBuilder<(ins "mlir::Type":$resultType,
- "mlir::Value":$ref, "mlir::ValueRange":$coor)>,
- OpBuilder<(ins "mlir::Type":$resultType,
- "mlir::Value":$ref, "llvm::ArrayRef<fir::IntOrValue>":$coor)>
- ];
+ let builders = [OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
+ "mlir::ValueRange":$coor)>,
+ OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
+ "llvm::ArrayRef<fir::IntOrValue>":$coor)>];
let extraClassDeclaration = [{
constexpr static int32_t kDynamicIndex = std::numeric_limits<int32_t>::min();
CoordinateIndicesAdaptor getIndices();
@@ -1887,10 +1850,7 @@ def fir_ExtractValueOp : fir_OneResultOp<"extract_value", [NoMemoryEffect]> {
```
}];
- let arguments = (ins
- AnyCompositeLike:$adt,
- ArrayAttr:$coor
- );
+ let arguments = (ins AnyCompositeLike:$adt, ArrayAttr:$coor);
let assemblyFormat = [{
$adt `,` $coor attr-dict `:` functional-type(operands, results)
@@ -1913,16 +1873,13 @@ def fir_FieldIndexOp : fir_OneResultOp<"field_index", [NoMemoryEffect]> {
```
}];
- let arguments = (ins
- StrAttr:$field_id,
- TypeAttr:$on_type,
- Variadic<AnyIntegerType>:$typeparams
- );
+ let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
+ Variadic<AnyIntegerType>:$typeparams);
let hasCustomAssemblyFormat = 1;
let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
- "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
+ "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
let extraClassDeclaration = [{
static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2074,11 +2031,8 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
```
}];
- let arguments = (ins
- Variadic<AnyIntegerType>:$triples,
- Variadic<AnyComponentType>:$fields,
- Variadic<AnyIntegerType>:$substr
- );
+ let arguments = (ins Variadic<AnyIntegerType>:$triples,
+ Variadic<AnyComponentType>:$fields, Variadic<AnyIntegerType>:$substr);
let results = (outs fir_SliceType);
@@ -2087,11 +2041,9 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
functional-type(operands, results)
}];
- let builders = [
- OpBuilder<(ins "mlir::ValueRange":$triples,
+ let builders = [OpBuilder<(ins "mlir::ValueRange":$triples,
CArg<"mlir::ValueRange", "{}">:$fields,
- CArg<"mlir::ValueRange", "{}">:$substr)>
- ];
+ CArg<"mlir::ValueRange", "{}">:$substr)>];
let hasVerifier = 1;
@@ -2154,7 +2106,8 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
the value 3.0.
}];
- let arguments = (ins fir_SequenceType:$seq, AnyType:$val, IndexElementsAttr:$coor);
+ let arguments = (ins fir_SequenceType:$seq, AnyType:$val,
+ IndexElementsAttr:$coor);
let results = (outs fir_SequenceType);
let assemblyFormat = [{
@@ -2171,7 +2124,7 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
let summary =
- "create a field index value from a LEN type parameter identifier";
+ "create a field index value from a LEN type parameter identifier";
let description = [{
Generate a LEN parameter (offset) value from a LEN parameter identifier.
@@ -2186,16 +2139,13 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
```
}];
- let arguments = (ins
- StrAttr:$field_id,
- TypeAttr:$on_type,
- Variadic<AnyIntegerType>:$typeparams
- );
+ let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
+ Variadic<AnyIntegerType>:$typeparams);
let hasCustomAssemblyFormat = 1;
let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
- "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
+ "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
let extraClassDeclaration = [{
static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2209,9 +2159,9 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
// Fortran loops
//===----------------------------------------------------------------------===//
-def fir_ResultOp : fir_Op<"result",
- [NoMemoryEffect, ReturnLike, Terminator,
- ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
+def fir_ResultOp
+ : fir_Op<"result", [NoMemoryEffect, ReturnLike, Terminator,
+ ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
let summary = "special terminator for use in fir region operations";
let description = [{
@@ -2231,17 +2181,19 @@ def fir_ResultOp : fir_Op<"result",
def FirRegionTerminator : SingleBlockImplicitTerminator<"ResultOp">;
-class region_Op<string mnemonic, list<Trait> traits = []> :
- fir_Op<mnemonic,
- !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
- RecursiveMemoryEffects])> {
+class region_Op<string mnemonic, list<Trait> traits = []>
+ : fir_Op<mnemonic,
+ !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
+ RecursiveMemoryEffects])> {
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
}
-def fir_DoLoopOp : region_Op<"do_loop", [AttrSizedOperandSegments,
- DeclareOpInterfaceMethods<LoopLikeOpInterface,
- ["getYieldedValuesMutable"]>]> {
+def fir_DoLoopOp
+ : region_Op<
+ "do_loop", [AttrSizedOperandSegments,
+ DeclareOpInterfaceMethods<
+ LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
let summary = "generalized loop operation";
let description = [{
Generalized high-level looping construct. This operation is similar to
@@ -2266,30 +2218,22 @@ def fir_DoLoopOp : region_Op<"do_loop", [AttrSizedOperandSegments,
let hasVerifier = 1;
let hasCustomAssemblyFormat = 1;
- let arguments = (ins
- Index:$lowerBound,
- Index:$upperBound,
- Index:$step,
- Variadic<AnyType>:$reduceOperands,
- Variadic<AnyType>:$initArgs,
- OptionalAttr<UnitAttr>:$unordered,
- OptionalAttr<UnitAttr>:$finalValue,
- OptionalAttr<ArrayAttr>:$reduceAttrs,
- OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
- );
+ let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
+ Variadic<AnyType>:$reduceOperands, Variadic<AnyType>:$initArgs,
+ OptionalAttr<UnitAttr>:$unordered, OptionalAttr<UnitAttr>:$finalValue,
+ OptionalAttr<ArrayAttr>:$reduceAttrs,
+ OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
let results = (outs Variadic<AnyType>:$results);
let regions = (region SizedRegion<1>:$region);
let skipDefaultBuilders = 1;
- let builders = [
- OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
- "mlir::Value":$step, CArg<"bool", "false">:$unordered,
- CArg<"bool", "false">:$finalCountValue,
+ let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
+ "mlir::Value":$upperBound, "mlir::Value":$step,
+ CArg<"bool", "false">:$unordered, CArg<"bool", "false">:$finalCountValue,
CArg<"mlir::ValueRange", "{}">:$iterArgs,
CArg<"mlir::ValueRange", "{}">:$reduceOperands,
CArg<"llvm::ArrayRef<mlir::Attribute>", "{}">:$reduceAttrs,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
- ];
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
let extraClassDeclaration = [{
mlir::Value getInductionVar() { return getBody()->getArgument(0); }
@@ -2382,17 +2326,13 @@ def fir_IfOp
OptionalAttr<DenseI32ArrayAttr>:$region_weights);
let results = (outs Variadic<AnyType>:$results);
- let regions = (region
- SizedRegion<1>:$thenRegion,
- MaxSizedRegion<1>:$elseRegion
- );
+ let regions = (region SizedRegion<1>:$thenRegion,
+ MaxSizedRegion<1>:$elseRegion);
let skipDefaultBuilders = 1;
- let builders = [
- OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
- OpBuilder<(ins "mlir::TypeRange":$resultTypes, "mlir::Value":$cond,
- "bool":$withElseRegion)>
- ];
+ let builders = [OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
+ OpBuilder<(ins "mlir::TypeRange":$resultTypes,
+ "mlir::Value":$cond, "bool":$withElseRegion)>];
let extraClassDeclaration = [{
mlir::OpBuilder getThenBodyBuilder() {
@@ -2426,9 +2366,10 @@ def fir_IfOp
}];
}
-def fir_IterWhileOp : region_Op<"iterate_while",
- [DeclareOpInterfaceMethods<LoopLikeOpInterface,
- ["getYieldedValuesMutable"]>]> {
+def fir_IterWhileOp
+ : region_Op<"iterate_while",
+ [DeclareOpInterfaceMethods<
+ LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
let summary = "DO loop with early exit condition";
let description = [{
This single-entry, single-exit looping construct is useful for lowering
@@ -2457,25 +2398,18 @@ def fir_IterWhileOp : region_Op<"iterate_while",
```
}];
- let arguments = (ins
- Index:$lowerBound,
- Index:$upperBound,
- Index:$step,
- I1:$iterateIn,
- Variadic<AnyType>:$initArgs,
- OptionalAttr<UnitAttr>:$finalValue
- );
+ let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
+ I1:$iterateIn, Variadic<AnyType>:$initArgs,
+ OptionalAttr<UnitAttr>:$finalValue);
let results = (outs Variadic<AnyType>:$results);
let regions = (region SizedRegion<1>:$region);
let skipDefaultBuilders = 1;
- let builders = [
- OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
- "mlir::Value":$step, "mlir::Value":$iterate,
+ let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
+ "mlir::Value":$upperBound, "mlir::Value":$step, "mlir::Value":$iterate,
CArg<"bool", "false">:$finalCountValue,
CArg<"mlir::ValueRange", "{}">:$iterArgs,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
- ];
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
let extraClassDeclaration = [{
static constexpr llvm::StringRef getFinalValueAttrNameStr() {
@@ -2528,8 +2462,9 @@ def fir_IterWhileOp : region_Op<"iterate_while",
// Procedure call operations
//===----------------------------------------------------------------------===//
-def fir_CallOp : fir_Op<"call",
- [CallOpInterface, DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CallOp
+ : fir_Op<"call", [CallOpInterface,
+ DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
let summary = "call a procedure";
let description = [{
@@ -2544,30 +2479,26 @@ def fir_CallOp : fir_Op<"call",
```
}];
- let arguments = (ins
- OptionalAttr<SymbolRefAttr>:$callee,
- Variadic<AnyType>:$args,
- OptionalAttr<DictArrayAttr>:$arg_attrs,
- OptionalAttr<DictArrayAttr>:$res_attrs,
- OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
- OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
- DefaultValuedAttr<Arith_FastMathAttr,
- "::mlir::arith::FastMathFlags::none">:$fastmath
- );
+ let arguments = (ins OptionalAttr<SymbolRefAttr>:$callee,
+ Variadic<AnyType>:$args, OptionalAttr<DictArrayAttr>:$arg_attrs,
+ OptionalAttr<DictArrayAttr>:$res_attrs,
+ OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
+ OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
+ DefaultValuedAttr<Arith_FastMathAttr,
+ "::mlir::arith::FastMathFlags::none">:$fastmath);
let results = (outs Variadic<AnyType>);
let hasCustomAssemblyFormat = 1;
- let builders = [
- OpBuilder<(ins "mlir::func::FuncOp":$callee,
- CArg<"mlir::ValueRange", "{}">:$operands)>,
- OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
- "llvm::ArrayRef<mlir::Type>":$results,
- CArg<"mlir::ValueRange", "{}">:$operands)>,
- OpBuilder<(ins "llvm::StringRef":$callee,
- "llvm::ArrayRef<mlir::Type>":$results,
- CArg<"mlir::ValueRange", "{}">:$operands),
- [{
+ let builders = [OpBuilder<(ins "mlir::func::FuncOp":$callee,
+ CArg<"mlir::ValueRange", "{}">:$operands)>,
+ OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
+ "llvm::ArrayRef<mlir::Type>":$results,
+ CArg<"mlir::ValueRange", "{}">:$operands)>,
+ OpBuilder<(ins "llvm::StringRef":$callee,
+ "llvm::ArrayRef<mlir::Type>":$results,
+ CArg<"mlir::ValueRange", "{}">:$operands),
+ [{
build($_builder, $_state,
mlir::SymbolRefAttr::get($_builder.getContext(), callee), results,
operands);
@@ -2631,15 +2562,11 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
```
}];
- let arguments = (ins
- StrAttr:$method,
- fir_ClassType:$object,
- Variadic<AnyType>:$args,
- OptionalAttr<I32Attr>:$pass_arg_pos,
- OptionalAttr<DictArrayAttr>:$arg_attrs,
- OptionalAttr<DictArrayAttr>:$res_attrs,
- OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs
- );
+ let arguments = (ins StrAttr:$method, fir_ClassType:$object,
+ Variadic<AnyType>:$args, OptionalAttr<I32Attr>:$pass_arg_pos,
+ OptionalAttr<DictArrayAttr>:$arg_attrs,
+ OptionalAttr<DictArrayAttr>:$res_attrs,
+ OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs);
let results = (outs Variadic<AnyType>:$results);
@@ -2683,19 +2610,18 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
- let builders = [
- OpBuilder<(ins "fir::CharacterType":$inType,
- "llvm::StringRef":$value,
- CArg<"std::optional<int64_t>", "{}">:$len)>,
- OpBuilder<(ins "fir::CharacterType":$inType,
- "llvm::ArrayRef<char>":$xlist,
- CArg<"std::optional<int64_t>", "{}">:$len)>,
- OpBuilder<(ins "fir::CharacterType":$inType,
- "llvm::ArrayRef<char16_t>":$xlist,
- CArg<"std::optional<int64_t>", "{}">:$len)>,
- OpBuilder<(ins "fir::CharacterType":$inType,
- "llvm::ArrayRef<char32_t>":$xlist,
- CArg<"std::optional<int64_t>", "{}">:$len)>];
+ let builders = [OpBuilder<(ins "fir::CharacterType":$inType,
+ "llvm::StringRef":$value,
+ CArg<"std::optional<int64_t>", "{}">:$len)>,
+ OpBuilder<(ins "fir::CharacterType":$inType,
+ "llvm::ArrayRef<char>":$xlist,
+ CArg<"std::optional<int64_t>", "{}">:$len)>,
+ OpBuilder<(ins "fir::CharacterType":$inType,
+ "llvm::ArrayRef<char16_t>":$xlist,
+ CArg<"std::optional<int64_t>", "{}">:$len)>,
+ OpBuilder<(ins "fir::CharacterType":$inType,
+ "llvm::ArrayRef<char32_t>":$xlist,
+ CArg<"std::optional<int64_t>", "{}">:$len)>];
let extraClassDeclaration = [{
static constexpr const char *size() { return "size"; }
@@ -2718,62 +2644,67 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
// Complex operations
-class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []> :
- fir_Op<mnemonic,
- !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
- Results<(outs AnyType:$result)> {
+class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []>
+ : fir_Op<mnemonic,
+ !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
+ Results<(outs AnyType:$result)> {
let assemblyFormat = "operands attr-dict `:` type($result)";
}
-class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
- fir_Op<mnemonic,
+class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
+ : fir_Op<mnemonic,
!listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
Results<(outs AnyType:$result)> {
let assemblyFormat = "operands attr-dict `:` type($result)";
}
-class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
- fir_UnaryArithmeticOp<mnemonic, traits>,
+class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
+ : fir_UnaryArithmeticOp<mnemonic, traits>,
Arguments<(ins AnyFirComplex:$operand)>;
def fir_NegcOp : ComplexUnaryArithmeticOp<"negc">;
-class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []> :
- fir_ArithmeticOp<mnemonic, traits>,
+class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []>
+ : fir_ArithmeticOp<mnemonic, traits>,
Arguments<(ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
DefaultValuedAttr<Arith_FastMathAttr,
"::mlir::arith::FastMathFlags::none">:$fastmath)>;
-def fir_AddcOp : ComplexArithmeticOp<"addc",
- [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_SubcOp : ComplexArithmeticOp<"subc",
- [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_MulcOp : ComplexArithmeticOp<"mulc",
- [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_DivcOp : ComplexArithmeticOp<"divc",
- [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_AddcOp
+ : ComplexArithmeticOp<"addc", [Commutative, DeclareOpInterfaceMethods<
+ ArithFastMathInterface>]>;
+def fir_SubcOp
+ : ComplexArithmeticOp<
+ "subc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_MulcOp
+ : ComplexArithmeticOp<"mulc", [Commutative, DeclareOpInterfaceMethods<
+ ArithFastMathInterface>]>;
+def fir_DivcOp
+ : ComplexArithmeticOp<
+ "divc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
// Pow is a builtin call and not a primitive
-def fir_CmpcOp : fir_Op<"cmpc",
- [NoMemoryEffect, SameTypeOperands, SameOperandsAndResultShape,
- DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CmpcOp
+ : fir_Op<"cmpc", [NoMemoryEffect, SameTypeOperands,
+ SameOperandsAndResultShape,
+ DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
let summary = "complex floating-point comparison operator";
let description = [{
A complex comparison to handle complex types found in FIR.
}];
- let arguments = (ins
- AnyFirComplex:$lhs,
- AnyFirComplex:$rhs,
- DefaultValuedAttr<Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath);
+ let arguments = (ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
+ DefaultValuedAttr<Arith_FastMathAttr,
+ "::mlir::arith::FastMathFlags::none">:$fastmath);
let results = (outs AnyLogicalLike);
let hasCustomAssemblyFormat = 1;
let builders = [OpBuilder<(ins "mlir::arith::CmpFPredicate":$predicate,
- "mlir::Value":$lhs, "mlir::Value":$rhs), [{
+ "mlir::Value":$lhs, "mlir::Value":$rhs),
+ [{
buildCmpCOp($_builder, $_state, predicate, lhs, rhs);
}]>];
@@ -2873,12 +2804,15 @@ def fir_ConvertOp
let hasCanonicalizer = 1;
}
-def FortranTypeAttr : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
- Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
- "fir::UnsignedType, fir::LogicalType, mlir::FloatType, "
- "mlir::ComplexType, "
- "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self).getValue())"
- >]>]>, "Fortran surface type"> {
+def FortranTypeAttr
+ : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
+ Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
+ "fir::UnsignedType, fir::LogicalType, "
+ "mlir::FloatType, "
+ "mlir::ComplexType, "
+ "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self)."
+ "getValue())">]>]>,
+ "Fortran surface type"> {
let storageType = [{ ::mlir::TypeAttr }];
let returnType = "mlir::Type";
let convertFromStorage = "mlir::cast<mlir::Type>($_self.getValue())";
@@ -2904,8 +2838,9 @@ def fir_TypeDescOp : fir_OneResultOp<"type_desc", [NoMemoryEffect]> {
let builders = [OpBuilder<(ins "mlir::TypeAttr":$inty)>];
}
-def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
- [NoMemoryEffect, SameOperandsAndResultType]> {
+def fir_NoReassocOp
+ : fir_OneResultOp<"no_reassoc", [NoMemoryEffect,
+ SameOperandsAndResultType]> {
let summary = "synthetic op to prevent reassociation";
let description = [{
Primitive operation meant to intrusively prevent operator reassociation.
@@ -2928,9 +2863,9 @@ def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
let assemblyFormat = "$val attr-dict `:` type($val)";
}
-class AtMostRegion<int numBlocks> : Region<
- CPred<"$_self.getBlocks().size() <= " # numBlocks>,
- "region with " # numBlocks # " blocks">;
+class AtMostRegion<int numBlocks>
+ : Region<CPred<"$_self.getBlocks().size() <= "#numBlocks>,
+ "region with "#numBlocks#" blocks">;
def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
let summary = "Global data";
@@ -2955,43 +2890,37 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
```
}];
- let arguments = (ins
- StrAttr:$sym_name,
- SymbolRefAttr:$symref,
- TypeAttr:$type,
- OptionalAttr<AnyAttr>:$initVal,
- OptionalAttr<UnitAttr>:$constant,
- OptionalAttr<UnitAttr>:$target,
- OptionalAttr<StrAttr>:$linkName,
- OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
- OptionalAttr<I64Attr>:$alignment
- );
+ let arguments = (ins StrAttr:$sym_name, SymbolRefAttr:$symref, TypeAttr:$type,
+ OptionalAttr<AnyAttr>:$initVal, OptionalAttr<UnitAttr>:$constant,
+ OptionalAttr<UnitAttr>:$target, OptionalAttr<StrAttr>:$linkName,
+ OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
+ OptionalAttr<I64Attr>:$alignment);
let regions = (region AtMostRegion<1>:$region);
let hasCustomAssemblyFormat = 1;
let skipDefaultBuilders = 1;
- let builders = [
- OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
- OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
- "bool":$isTarget, "mlir::Type":$type,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
- OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
- CArg<"mlir::StringAttr", "{}">:$linkage,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
- OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
- "bool":$isTarget,
- "mlir::Type":$type, CArg<"mlir::StringAttr", "{}">:$linkage,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
- OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
- "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
- OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
- "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
- CArg<"mlir::StringAttr", "{}">:$linkage,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+ let builders =
+ [OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+ OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+ "bool":$isTarget, "mlir::Type":$type,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+ OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+ CArg<"mlir::StringAttr", "{}">:$linkage,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+ OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+ "bool":$isTarget, "mlir::Type":$type,
+ CArg<"mlir::StringAttr", "{}">:$linkage,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+ OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+ "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+ OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+ "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
+ CArg<"mlir::StringAttr", "{}">:$linkage,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
];
let extraClassDeclaration = [{
@@ -3056,8 +2985,8 @@ def fir_GlobalLenOp : fir_Op<"global_len", []> {
def ImplicitFirTerminator : SingleBlockImplicitTerminator<"FirEndOp">;
-def fir_TypeInfoOp : fir_Op<"type_info",
- [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
+def fir_TypeInfoOp
+ : fir_Op<"type_info", [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
let summary = "Derived type information";
let description = [{
@@ -3087,26 +3016,18 @@ def fir_TypeInfoOp : fir_Op<"type_info",
```
}];
- let arguments = (ins
- SymbolNameAttr:$sym_name,
- TypeAttr:$type,
- OptionalAttr<TypeAttr>:$parent_type,
- UnitAttr:$no_init,
- UnitAttr:$no_destroy,
- UnitAttr:$no_final
- );
+ let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type,
+ OptionalAttr<TypeAttr>:$parent_type, UnitAttr:$no_init,
+ UnitAttr:$no_destroy, UnitAttr:$no_final);
let hasVerifier = 1;
- let regions = (region
- MaxSizedRegion<1>:$dispatch_table,
- MaxSizedRegion<1>:$component_info
- );
+ let regions = (region MaxSizedRegion<1>:$dispatch_table,
+ MaxSizedRegion<1>:$component_info);
- let builders = [
- OpBuilder<(ins "fir::RecordType":$type, "fir::RecordType":$parent_type,
- CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>
- ];
+ let builders = [OpBuilder<(ins "fir::RecordType":$type,
+ "fir::RecordType":$parent_type,
+ CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>];
let assemblyFormat = [{
$sym_name (`noinit` $no_init^)? (`nodestroy` $no_destroy^)?
@@ -3157,7 +3078,8 @@ def fir_DTEntryOp : fir_Op<"dt_entry", [HasParent<"TypeInfoOp">]> {
}
def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
- let summary = "define extra information about a component inside fir.type_info";
+ let summary =
+ "define extra information about a component inside fir.type_info";
let description = [{
```
@@ -3165,17 +3087,17 @@ def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
```
}];
- let arguments = (ins
- StrAttr:$name,
- OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
- OptionalAttr<FlatSymbolRefAttr>:$init_val
- );
+ let arguments = (ins StrAttr:$name,
+ OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
+ OptionalAttr<FlatSymbolRefAttr>:$init_val);
- let assemblyFormat = "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
+ let assemblyFormat =
+ "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
}
def fir_AbsentOp : fir_OneResultOp<"absent", [NoMemoryEffect]> {
- let summary = "create value to be passed for absent optional function argument";
+ let summary =
+ "create value to be passed for absent optional function argument";
let description = [{
Given the type of a function argument, create a value that will signal that
an optional argument is absent in the call. On the caller side, fir.is_present
@@ -3316,10 +3238,7 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
The derived_type field cannot be used when the input to this op is a reference to a fir.boxchar.
}];
- let arguments = (ins
- AnyReferenceLike:$box_ref,
- fir_BoxFieldAttr:$field
- );
+ let arguments = (ins AnyReferenceLike:$box_ref, fir_BoxFieldAttr:$field);
let results = (outs RefOrLLVMPtr);
let hasVerifier = 1;
@@ -3328,13 +3247,12 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
$box_ref $field attr-dict `:` functional-type(operands, results)
}];
- let builders = [
- OpBuilder<(ins "mlir::Value":$boxRef, "fir::BoxFieldAttr":$field)>
- ];
+ let builders = [OpBuilder<(ins "mlir::Value":$boxRef,
+ "fir::BoxFieldAttr":$field)>];
}
-def fir_DummyScopeOp : fir_Op<"dummy_scope",
- [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
+def fir_DummyScopeOp
+ : fir_Op<"dummy_scope", [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
let summary = "Define a scope for dummy arguments";
let description = [{
@@ -3559,9 +3477,9 @@ def fir_BoxTotalElementsOp
let hasCanonicalizer = 1;
}
-def YieldOp : fir_Op<"yield",
- [Pure, ReturnLike, Terminator,
- ParentOneOf<["LocalitySpecifierOp", "DeclareReductionOp"]>]> {
+def YieldOp : fir_Op<"yield", [Pure, ReturnLike, Terminator,
+ ParentOneOf<["LocalitySpecifierOp",
+ "DeclareReductionOp"]>]> {
let summary = "loop yield and termination operation";
let description = [{
"fir.yield" yields SSA values from a fir dialect op region and
@@ -3571,9 +3489,7 @@ def YieldOp : fir_Op<"yield",
let arguments = (ins Variadic<AnyType>:$results);
- let builders = [
- OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>
- ];
+ let builders = [OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>];
let assemblyFormat = "( `(` $results^ `:` type($results) `)` )? attr-dict";
}
@@ -3651,13 +3567,11 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
corresponds to a `local` or a `local_init` specifier.
}];
- let arguments = (ins SymbolNameAttr:$sym_name,
- TypeAttrOf<AnyType>:$type,
- LocalitySpecifierTypeAttr:$locality_specifier_type);
+ let arguments = (ins SymbolNameAttr:$sym_name, TypeAttrOf<AnyType>:$type,
+ LocalitySpecifierTypeAttr:$locality_specifier_type);
- let regions = (region AnyRegion:$init_region,
- AnyRegion:$copy_region,
- AnyRegion:$dealloc_region);
+ let regions = (region AnyRegion:$init_region, AnyRegion:$copy_region,
+ AnyRegion:$dealloc_region);
let assemblyFormat = [{
$locality_specifier_type $sym_name `:` $type
@@ -3699,8 +3613,8 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
let hasRegionVerifier = 1;
}
-def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
- Symbol]> {
+def fir_DeclareReductionOp
+ : fir_Op<"declare_reduction", [IsolatedFromAbove, Symbol]> {
let summary = "declares a reduction kind";
let description = [{
Note: this operation is adapted from omp::DeclareReductionOp. There is a lot
@@ -3745,14 +3659,11 @@ def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
match the parent operation's results.
}];
- let arguments = (ins SymbolNameAttr:$sym_name,
- TypeAttr:$type);
+ let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type);
let regions = (region MaxSizedRegion<1>:$allocRegion,
- AnyRegion:$initializerRegion,
- AnyRegion:$reductionRegion,
- AnyRegion:$atomicReductionRegion,
- AnyRegion:$cleanupRegion);
+ AnyRegion:$initializerRegion, AnyRegion:$reductionRegion,
+ AnyRegion:$atomicReductionRegion, AnyRegion:$cleanupRegion);
let assemblyFormat = "$sym_name `:` $type attr-dict-with-keyword "
"( `alloc` $allocRegion^ )? "
@@ -3796,8 +3707,8 @@ def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
let hasRegionVerifier = 1;
}
-def fir_DoConcurrentOp : fir_Op<"do_concurrent",
- [SingleBlock, AutomaticAllocationScope]> {
+def fir_DoConcurrentOp
+ : fir_Op<"do_concurrent", [SingleBlock, AutomaticAllocationScope]> {
let summary = "do concurrent loop wrapper";
let description = [{
@@ -3828,35 +3739,34 @@ def fir_DoConcurrentOp : fir_Op<"do_concurrent",
}
def fir_LocalSpecifier {
- dag arguments = (ins
- Variadic<AnyType>:$local_vars,
- OptionalAttr<SymbolRefArrayAttr>:$local_syms
- );
+ dag arguments = (ins Variadic<AnyType>:$local_vars,
+ OptionalAttr<SymbolRefArrayAttr>:$local_syms);
}
def fir_ReduceSpecifier {
- dag arguments = (ins
- Variadic<AnyType>:$reduce_vars,
- OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
-
- // This introduces redundency in how reductions are modelled. In particular,
- // a single reduction is represented by 2 attributes:
- //
- // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
- // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
- //
- // The first makes it easier to map `do concurrent` to parallization models
- // (e.g. OpenMP and OpenACC) while the second makes it easier to map it to
- // nests of `fir.do_loop ... unodered` ops.
- OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
- OptionalAttr<ArrayAttr>:$reduce_attrs
- );
-}
-
-def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
- [AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopLikeOpInterface,
- ["getLoopInductionVars"]>,
- Terminator, NoTerminator, SingleBlock, ParentOneOf<["DoConcurrentOp"]>]> {
+ dag arguments = (ins Variadic<AnyType>:$reduce_vars,
+ OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
+
+ // This introduces redundency in how reductions are modelled. In
+ // particular, a single reduction is represented by 2 attributes:
+ //
+ // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
+ // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
+ //
+ // The first makes it easier to map `do concurrent` to parallization
+ // models (e.g. OpenMP and OpenACC) while the second makes it easier to
+ // map it to nests of `fir.do_loop ... unodered` ops.
+ OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
+ OptionalAttr<ArrayAttr>:$reduce_attrs);
+}
+
+def fir_DoConcurrentLoopOp
+ : fir_Op<"do_concurrent.loop",
+ [AttrSizedOperandSegments,
+ DeclareOpInterfaceMethods<
+ LoopLikeOpInterface, ["getLoopInductionVars"]>,
+ Terminator, NoTerminator, SingleBlock,
+ ParentOneOf<["DoConcurrentOp"]>]> {
let summary = "do concurrent loop";
let description = [{
@@ -3904,16 +3814,11 @@ def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
LLVM.
}];
- defvar opArgs = (ins
- Variadic<Index>:$lowerBound,
- Variadic<Index>:$upperBound,
- Variadic<Index>:$step,
- OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
- );
+ defvar opArgs = (ins Variadic<Index>:$lowerBound, Variadic<Index>:$upperBound,
+ Variadic<Index>:$step, OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
- let arguments = !con(opArgs,
- fir_LocalSpecifier.arguments,
- fir_ReduceSpecifier.arguments);
+ let arguments =
+ !con(opArgs, fir_LocalSpecifier.arguments, fir_ReduceSpecifier.arguments);
let regions = (region SizedRegion<1>:$region);
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index b9cc5a4c8b261..c62bad5fc9c0a 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -19,7 +19,6 @@
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Value.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
-#include "mlir/Interfaces/ViewLikeInterface.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
@@ -28,59 +27,23 @@ using namespace mlir;
#define DEBUG_TYPE "fir-alias-analysis"
-//===----------------------------------------------------------------------===//
-// AliasAnalysis: allocation detection based on MemAlloc effect
-//===----------------------------------------------------------------------===//
-
-static bool
-tryClassifyAllocateFromEffects(mlir::Operation *op, mlir::Value candidate,
- bool allowValueScoped, bool allowOpScoped,
- mlir::Value &v, mlir::Operation *&defOp,
- fir::AliasAnalysis::SourceKind &type) {
+// Classify 'candidate' as an allocation based on value-scoped Allocate effects
+// attached by its defining operation 'op'. Returns true if classified and fills
+// out 'v', 'defOp' and 'type'.
+static bool classifyAllocateFromEffects(mlir::Operation *op,
+ mlir::Value candidate, mlir::Value &v,
+ mlir::Operation *&defOp,
+ fir::AliasAnalysis::SourceKind &type) {
+ if (!op)
+ return false;
auto iface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
if (!iface)
return false;
-
llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
iface.getEffects(effects);
-
- if (allowValueScoped) {
- for (mlir::MemoryEffects::EffectInstance &e : effects) {
- if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
- e.getValue() && e.getValue() == candidate) {
- v = candidate;
- defOp = op;
- type = fir::AliasAnalysis::SourceKind::Allocate;
- return true;
- }
- }
- }
-
- if (!allowOpScoped)
- return false;
-
- bool hasOpScopedAlloc =
- llvm::any_of(effects, [](const mlir::MemoryEffects::EffectInstance &e) {
- return !e.getValue() &&
- mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect());
- });
- if (!hasOpScopedAlloc)
- return false;
-
- bool opIsViewLike =
- (bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(op);
- auto isMemRefLikeType = [](mlir::Type type) {
- return fir::isa_ref_type(type) || mlir::isa<mlir::BaseMemRefType>(type) ||
- mlir::isa<mlir::LLVM::LLVMPointerType>(type);
- };
- bool hasMemOperands = llvm::any_of(op->getOperands(), [&](mlir::Value o) {
- return isMemRefLikeType(o.getType());
- });
- if (opIsViewLike || hasMemOperands)
- return false;
-
- for (mlir::Value res : op->getResults()) {
- if (res == candidate && isMemRefLikeType(res.getType())) {
+ for (mlir::MemoryEffects::EffectInstance &e : effects) {
+ if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
+ e.getValue() && e.getValue() == candidate) {
v = candidate;
defOp = op;
type = fir::AliasAnalysis::SourceKind::Allocate;
@@ -596,41 +559,29 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
mlir::SymbolRefAttr global;
Source::Attributes attributes;
mlir::Operation *instantiationPoint{nullptr};
- // Helper to conservatively classify a candidate value as coming from a
- // dummy argument or as indirect when no allocation or global can be proven.
- auto classifyFallbackFrom = [&](mlir::Value candidate) {
- if (isDummyArgument(candidate)) {
- defOp = nullptr;
- v = candidate;
- } else {
- type = SourceKind::Indirect;
- }
- };
-
while (defOp && !breakFromLoop) {
ty = defOp->getResultTypes()[0];
-
- // Effect-based detection (op-scoped heuristic only at this level).
- if (tryClassifyAllocateFromEffects(defOp, v,
- /*allowValueScoped=*/false,
- /*allowOpScoped=*/true, v, defOp, type))
+ // Value-scoped allocation detection via effects.
+ if (classifyAllocateFromEffects(defOp, v, v, defOp, type))
break;
-
llvm::TypeSwitch<Operation *>(defOp)
.Case<hlfir::AsExprOp>([&](auto op) {
v = op.getVar();
defOp = v.getDefiningOp();
})
.Case<hlfir::AssociateOp>([&](auto op) {
- // Do not pattern-match Allocate. Trace through the source.
mlir::Value source = op.getSource();
- v = source;
- defOp = v.getDefiningOp();
- })
- .Case<fir::AllocaOp, fir::AllocMemOp>([&](auto op) {
- // Do not pattern-match allocations by op name; rely on memory
- // effects classification above. Nothing to do here.
- breakFromLoop = true;
+ if (fir::isa_trivial(source.getType())) {
+ // Trivial values will always use distinct temp memory,
+ // so we can classify this as Allocate and stop.
+ type = SourceKind::Allocate;
+ breakFromLoop = true;
+ } else {
+ // AssociateOp may reuse the expression storage,
+ // so we have to trace further.
+ v = source;
+ defOp = v.getDefiningOp();
+ }
})
.Case<fir::ConvertOp>([&](auto op) {
// Skip ConvertOp's and track further through the operand.
@@ -700,15 +651,19 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
if (global) {
type = SourceKind::Global;
} else {
- mlir::Value def = llvm::cast<mlir::Value>(boxSrc.origin.u);
+ auto def = llvm::cast<mlir::Value>(boxSrc.origin.u);
bool classified = false;
if (auto defDefOp = def.getDefiningOp())
- classified = tryClassifyAllocateFromEffects(
- defDefOp, def,
- /*allowValueScoped=*/true, /*allowOpScoped=*/true, v, defOp,
- type);
- if (!classified)
- classifyFallbackFrom(def);
+ classified =
+ classifyAllocateFromEffects(defDefOp, def, v, defOp, type);
+ if (!classified) {
+ if (isDummyArgument(def)) {
+ defOp = nullptr;
+ v = def;
+ } else {
+ type = SourceKind::Indirect;
+ }
+ }
}
breakFromLoop = true;
return;
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 4f97acaa88b7a..9d182a699c634 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -285,6 +285,21 @@ llvm::LogicalResult fir::AllocaOp::verify() {
return mlir::success();
}
+void fir::AllocaOp::getEffects(
+ llvm::SmallVectorImpl<
+ mlir::SideEffects::EffectInstance<mlir::MemoryEffects::Effect>>
+ &effects) {
+ // Value-scoped Allocate for AA.
+ effects.emplace_back(
+ mlir::MemoryEffects::Allocate::get(),
+ mlir::cast<mlir::OpResult>(getOperation()->getResult(0)),
+ mlir::SideEffects::AutomaticAllocationScopeResource::get());
+ // Preserve previous behavior: op-scoped Allocate for passes relying on it.
+ effects.emplace_back(
+ mlir::MemoryEffects::Allocate::get(),
+ mlir::SideEffects::AutomaticAllocationScopeResource::get());
+}
+
bool fir::AllocaOp::ownsNestedAlloca(mlir::Operation *op) {
return op->hasTrait<mlir::OpTrait::IsIsolatedFromAbove>() ||
op->hasTrait<mlir::OpTrait::AutomaticAllocationScope>() ||
@@ -384,6 +399,19 @@ llvm::LogicalResult fir::AllocMemOp::verify() {
return mlir::success();
}
+void fir::AllocMemOp::getEffects(
+ llvm::SmallVectorImpl<
+ mlir::SideEffects::EffectInstance<mlir::MemoryEffects::Effect>>
+ &effects) {
+ // Value-scoped Allocate for AA.
+ effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
+ mlir::cast<mlir::OpResult>(getOperation()->getResult(0)),
+ mlir::SideEffects::DefaultResource::get());
+ // Preserve previous behavior: op-scoped Allocate for passes relying on it.
+ effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
+ mlir::SideEffects::DefaultResource::get());
+}
+
//===----------------------------------------------------------------------===//
// ArrayCoorOp
//===----------------------------------------------------------------------===//
>From fb74ffdee0191b77671d930fb07ff0d65116ff09 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 13:48:11 -0800
Subject: [PATCH 8/9] remove cuf
---
flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp | 8 -------
.../AliasAnalysis/cuf-alloc-source-kind.mlir | 22 -------------------
2 files changed, 30 deletions(-)
delete mode 100644 flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
diff --git a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
index 65283872afa34..a43c718a85562 100644
--- a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
+++ b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
@@ -67,14 +67,6 @@ static llvm::LogicalResult checkCudaAttr(Op op) {
llvm::LogicalResult cuf::AllocOp::verify() { return checkCudaAttr(*this); }
-// Attach value-scoped MemAlloc to the result value.
-void cuf::AllocOp::getEffects(
- llvm::SmallVectorImpl<mlir::MemoryEffects::EffectInstance> &effects) {
- effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
- mlir::cast<mlir::OpResult>(getPtr()),
- mlir::SideEffects::DefaultResource::get());
-}
-
//===----------------------------------------------------------------------===//
// FreeOp
//===----------------------------------------------------------------------===//
diff --git a/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir b/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
deleted file mode 100644
index 6a911f8ff25e3..0000000000000
--- a/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
+++ /dev/null
@@ -1,22 +0,0 @@
-// REQUIRES: asserts
-// RUN: fir-opt %s -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' -debug-only=fir-alias-analysis --mlir-disable-threading 2>&1 | FileCheck %s
-
-// Verify that a CUF allocation is recognized as SourceKind::Allocate by
-// fir::AliasAnalysis::getSource.
-
-module {
- func.func @_QQmain() attributes {fir.bindc_name = "TEST"} {
- // Allocate two independent device arrays and tag the results; with
- // op-scoped MemAlloc handling in AA, these should be classified as
- // Allocate and not alias.
- %a = cuf.alloc !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "a1", data_attr = #cuf.cuda<device>, uniq_name = "_QFEa1", test.ptr = "cuf_alloc_a"} -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
- %b = cuf.alloc !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "a2", data_attr = #cuf.cuda<device>, uniq_name = "_QFEa2", test.ptr = "cuf_alloc_b"} -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
- return
- }
-}
-
-// CHECK-LABEL: Testing : "_QQmain"
-// Distinct allocations should not alias.
-// CHECK: cuf_alloc_a#0 <-> cuf_alloc_b#0: NoAlias
-
-
>From 7c380e1610180d3ca41964125ada877f393864a6 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 13:49:57 -0800
Subject: [PATCH 9/9] remove headerfile
---
flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
index a43c718a85562..687007d957225 100644
--- a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
+++ b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
@@ -24,7 +24,6 @@
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/PatternMatch.h"
-#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "llvm/ADT/SmallVector.h"
//===----------------------------------------------------------------------===//
More information about the flang-commits
mailing list