[Mlir-commits] [mlir] 8670656 - [MLIR][Affine] Expose region-based isTopLevelValue

William S. Moses llvmlistbot at llvm.org
Wed Mar 16 20:43:39 PDT 2022


Author: William S. Moses
Date: 2022-03-16T23:43:34-04:00
New Revision: 86706561705db270357ab6a4dfd7d8206faa4ae0

URL: https://github.com/llvm/llvm-project/commit/86706561705db270357ab6a4dfd7d8206faa4ae0
DIFF: https://github.com/llvm/llvm-project/commit/86706561705db270357ab6a4dfd7d8206faa4ae0.diff

LOG: [MLIR][Affine] Expose region-based isTopLevelValue

This PR exposes the region-based isTopLevelValue,
which is useful for other code that performs Affine transformations,
but is not within AffineOps.cpp

Reviewed By: bondhugula

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

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 27f6857bf9fe7..05e31c9ebe8c6 100644
--- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
+++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
@@ -32,6 +32,12 @@ class AffineValueMap;
 /// uses.
 bool isTopLevelValue(Value value);
 
+/// A utility function to check if a value is defined at the top level of
+/// `region` or is an argument of `region`. A value of index type defined at the
+/// top level of a `AffineScope` region is always a valid symbol for all
+/// uses in that region.
+bool isTopLevelValue(Value value, Region *region);
+
 /// 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);

diff  --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 6dbfebfe57e3c..6a2e2430549fd 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -33,7 +33,7 @@ using namespace mlir;
 /// `region` or is an argument of `region`. A value of index type defined at the
 /// top level of a `AffineScope` region is always a valid symbol for all
 /// uses in that region.
-static bool isTopLevelValue(Value value, Region *region) {
+bool mlir::isTopLevelValue(Value value, Region *region) {
   if (auto arg = value.dyn_cast<BlockArgument>())
     return arg.getParentRegion() == region;
   return value.getDefiningOp()->getParentRegion() == region;


        


More information about the Mlir-commits mailing list