[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
This commit is contained in:
William S. Moses 2022-03-16 12:58:28 -04:00
parent 6dd21d1db1
commit 97eedc7443
2 changed files with 5 additions and 2 deletions

View File

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

View File

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