[Mlir-commits] [mlir] 97eedc7 - [MLIR][Affine] Expose getAffineScope as a utility function

William S. Moses llvmlistbot at llvm.org
Wed Mar 16 20:26:21 PDT 2022


Author: William S. Moses
Date: 2022-03-16T23:26:15-04:00
New Revision: 97eedc74439c5305dd72e5391e639087c2c4035f

URL: https://github.com/llvm/llvm-project/commit/97eedc74439c5305dd72e5391e639087c2c4035f
DIFF: https://github.com/llvm/llvm-project/commit/97eedc74439c5305dd72e5391e639087c2c4035f.diff

LOG: [MLIR][Affine] Expose getAffineScope as a utility function

The getAffineScope function is currently internal
to AffineOps.cpp. However, as the comment on the function
itself notes, this is useful in a variety of other places
externally. This PR allows other files to use the function.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D121827

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
    mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
index 96d134d802841..27f6857bf9fe7 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
@@ -32,6 +32,10 @@ class AffineValueMap;
 /// uses.
 bool isTopLevelValue(Value value);
 
+/// Returns the closest region enclosing `op` that is held by an operation with
+/// trait `AffineScope`; `nullptr` if there is no such region.
+Region *getAffineScope(Operation *op);
+
 /// AffineDmaStartOp starts a non-blocking DMA operation that transfers data
 /// from a source memref to a destination memref. The source and destination
 /// memref need not be of the same dimensionality, but need to have the same

diff  --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 3b288bed37bbf..6dbfebfe57e3c 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -244,8 +244,7 @@ bool mlir::isTopLevelValue(Value value) {
 
 /// Returns the closest region enclosing `op` that is held by an operation with
 /// trait `AffineScope`; `nullptr` if there is no such region.
-//  TODO: getAffineScope should be publicly exposed for affine passes/utilities.
-static Region *getAffineScope(Operation *op) {
+Region *mlir::getAffineScope(Operation *op) {
   auto *curOp = op;
   while (auto *parentOp = curOp->getParentOp()) {
     if (parentOp->hasTrait<OpTrait::AffineScope>())


        


More information about the Mlir-commits mailing list