MLIR 22.0.0git
ControlFlowInterfaces.cpp File Reference
#include <utility>
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Operation.h"
#include "mlir/Interfaces/ControlFlowInterfaces.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 *, ArrayRef<bool> visited)>
 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 InFlightDiagnosticprintRegionEdgeName (InFlightDiagnostic &diag, RegionBranchPoint sourceNo, RegionSuccessor succRegionNo)
static LogicalResult verifyTypesAlongAllEdges (RegionBranchOpInterface branchOp, RegionBranchPoint sourcePoint, function_ref< FailureOr< TypeRange >(RegionSuccessor)> getInputsTypesForRegion)
 Verify that types match along all region control flow edges originating from sourcePoint.
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).

Typedef Documentation

◆ StopConditionFn

Stop condition for traverseRegionGraph.

The traversal is interrupted if this function returns "true" for a successor region. The first parameter is the successor region. The second parameter indicates all already visited regions.

Definition at line 271 of file ControlFlowInterfaces.cpp.

Function Documentation

◆ isRegionReachable()

bool isRegionReachable ( Region * begin,
Region * r )
static

Return true if region r is reachable from region begin according to the RegionBranchOpInterface (by taking a branch).

Definition at line 352 of file ControlFlowInterfaces.cpp.

References mlir::Region::getParentOp(), and traverseRegionGraph().

◆ printRegionEdgeName()

◆ traverseRegionGraph()

bool traverseRegionGraph ( Region * begin,
StopConditionFn stopConditionFn )
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 277 of file ControlFlowInterfaces.cpp.

References mlir::Region::getParentOp(), and mlir::Region::getRegionNumber().

Referenced by isRegionReachable().

◆ verifyTypesAlongAllEdges()

LogicalResult verifyTypesAlongAllEdges ( RegionBranchOpInterface branchOp,
RegionBranchPoint sourcePoint,
function_ref< FailureOr< TypeRange >(RegionSuccessor)> getInputsTypesForRegion )
static

Verify that types match along all region control flow edges originating from sourcePoint.

getInputsTypesForRegion is a function that returns the types of the inputs that flow to a successor region.

Definition at line 176 of file ControlFlowInterfaces.cpp.

References diag(), printRegionEdgeName(), and success().

Referenced by mlir::detail::verifyTypesAlongControlFlowEdges().

◆ verifyWeights()

LogicalResult verifyWeights ( Operation * op,
llvm::ArrayRef< int32_t > weights,
std::size_t expectedWeightsNum,
llvm::StringRef weightAnchorName,
llvm::StringRef weightRefName )
static