[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
This commit is contained in:
William S. Moses 2022-03-16 23:29:42 -04:00
parent 97eedc7443
commit 8670656170
2 changed files with 7 additions and 1 deletions

View File

@ -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);

View File

@ -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;