|
MLIR 24.0.0git
|
#include <map>#include <utility>#include "mlir/IR/BuiltinTypes.h"#include "mlir/IR/Matchers.h"#include "mlir/IR/Operation.h"#include "mlir/IR/PatternMatch.h"#include "mlir/Interfaces/ControlFlowInterfaces.h"#include "llvm/ADT/EquivalenceClasses.h"#include "llvm/ADT/PointerIntPair.h"#include "llvm/Support/DebugLog.h"#include "mlir/Interfaces/ControlFlowInterfaces.cpp.inc"Go to the source code of this file.
Typedefs | |
| using | StopConditionFn = function_ref<bool(Region *)> |
| Stop condition for traverseRegionGraph. | |
Functions | |
| static LogicalResult | verifyWeights (Operation *op, llvm::ArrayRef< int32_t > weights, std::size_t expectedWeightsNum, llvm::StringRef weightAnchorName, llvm::StringRef weightRefName) |
| static SmallVector< Region * > | filterRegionSuccessors (ArrayRef< RegionSuccessor > successors) |
| Return the regions in successors. | |
| static SmallVector< Region * > | getSuccessorRegionsOf (Region *region) |
| Return the regions that the terminators of region may branch to. | |
| static bool | traverseRegionGraph (Region *begin, StopConditionFn stopConditionFn) |
| Traverse the region graph starting at begin. | |
| static bool | isRegionReachable (Region *begin, Region *r) |
| Return true if region r is reachable from region begin according to the RegionBranchOpInterface (by taking a branch). | |
| static bool | canReachCycle (ArrayRef< Region * > entryRegions) |
| Return "true" if a cycle in the region graph is reachable from one of entryRegions, which must belong to the same op. | |
| static MutableArrayRef< OpOperand > | operandsToOpOperands (OperandRange &operands) |
| static void | getSuccessorOperandInputMapping (RegionBranchOpInterface branchOp, RegionBranchSuccessorMapping &mapping, RegionBranchPoint src) |
| static RegionBranchInverseSuccessorMapping | invertRegionBranchSuccessorMapping (const RegionBranchSuccessorMapping &operandToInputs) |
| static bool | isDefinedBefore (Operation *regionBranchOp, Value a, Value b) |
| Return "true" if a can be used in lieu of b, where b is a region successor input and a is a "reachable value" of b. | |
| static LogicalResult | computeReachableValuesFromSuccessorInput (llvm::SmallDenseSet< Value > &result, Value value, const RegionBranchInverseSuccessorMapping &inputToOperands, std::optional< unsigned > maxReachableValues=std::nullopt) |
| Compute all non-successor-input values that a successor input could have based on the given successor input to successor operand mapping. | |
| using StopConditionFn = function_ref<bool(Region *)> |
Stop condition for traverseRegionGraph.
The traversal is interrupted if this function returns "true" for a successor region.
Definition at line 252 of file ControlFlowInterfaces.cpp.
Return "true" if a cycle in the region graph is reachable from one of entryRegions, which must belong to the same op.
This is an iterative depth-first search. A region is on the DFS path from the time the search enters it until every region reachable from it is finished. Reaching a region on the path closes a cycle. Reaching a finished region does not. That happens, for example, when two terminators branch to the same successor region.
Definition at line 408 of file ControlFlowInterfaces.cpp.
References mlir::Region::getRegionNumber(), and getSuccessorRegionsOf().
|
static |
Compute all non-successor-input values that a successor input could have based on the given successor input to successor operand mapping.
Starting with the given value, trace back all predecessor values (i.e., preceding successor operands) and add them to the set of reachable values. If the successor operand is again a successor input, do not add it to the result set, but instead continue the traversal.
If maxReachableValues is set, the traversal is aborted early and failure is returned as soon as the number of reachable values exceeds the limit. Otherwise, success is returned and the result set contains all reachable values.
Example 1: r = scf.if ... { scf.yield a : ... } else { scf.yield b : ... } reachableValues(r) = {a, b}
Example 2: r = scf.for ... iter_args(arg0 = %0) -> ... { scf.yield arg0 : ... } reachableValues(arg0) = {%0} reachableValues(r) = {%0}
Example 3: r = scf.for ... iter_args(arg0 = %0) -> ... { ... scf.yield %1 : ... } reachableValues(arg0) = {%0, %1} reachableValues(r) = {%0, %1}
Definition at line 690 of file ControlFlowInterfaces.cpp.
References mlir::IROperand< DerivedT, IRValueT >::get(), result, and success().
|
static |
Return the regions in successors.
Branches back to the parent op are left out.
Definition at line 228 of file ControlFlowInterfaces.cpp.
Referenced by getSuccessorRegionsOf().
|
static |
Definition at line 494 of file ControlFlowInterfaces.cpp.
References operandsToOpOperands().
|
static |
Return the regions that the terminators of region may branch to.
This asks the parent op, not each terminator. A terminator's own getSuccessorRegions can only narrow the parent's answer using constant operands, and we know no operand values here.
Definition at line 241 of file ControlFlowInterfaces.cpp.
References filterRegionSuccessors(), mlir::Region::getParentOp(), and mlir::Region::getRegionNumber().
Referenced by canReachCycle(), and traverseRegionGraph().
|
static |
Definition at line 521 of file ControlFlowInterfaces.cpp.
Return "true" if a can be used in lieu of b, where b is a region successor input and a is a "reachable value" of b.
Reachable values are successor operand values that are (maybe transitively) forwarded to b.
Definition at line 609 of file ControlFlowInterfaces.cpp.
References b, mlir::Region::getParentOp(), and mlir::Value::getParentRegion().
Return true if region r is reachable from region begin according to the RegionBranchOpInterface (by taking a branch).
Definition at line 306 of file ControlFlowInterfaces.cpp.
References mlir::Region::getParentOp(), and traverseRegionGraph().
|
static |
Definition at line 489 of file ControlFlowInterfaces.cpp.
|
static |
Traverse the region graph starting at begin.
The traversal is interrupted if stopCondition evaluates to "true" for a successor region. In that case, this function returns "true". Otherwise, if the traversal was not interrupted, this function returns "false".
Definition at line 258 of file ControlFlowInterfaces.cpp.
References mlir::Region::getParentOp(), mlir::Region::getRegionNumber(), and getSuccessorRegionsOf().
Referenced by isRegionReachable().
|
static |
Definition at line 119 of file ControlFlowInterfaces.cpp.
References mlir::Operation::emitError(), and success().
Referenced by mlir::detail::verifyBranchWeights(), and mlir::detail::verifyRegionBranchWeights().