MLIR
20.0.0git
|
Interface that should be implemented by any caller of transformCFGToSCF
.
More...
#include "mlir/Transforms/CFGToSCF.h"
Public Member Functions | |
virtual | ~CFGToSCFInterface ()=default |
virtual FailureOr< Operation * > | createStructuredBranchRegionOp (OpBuilder &builder, Operation *controlFlowCondOp, TypeRange resultTypes, MutableArrayRef< Region > regions)=0 |
Creates a structured control flow operation branching to one of regions . More... | |
virtual LogicalResult | createStructuredBranchRegionTerminatorOp (Location loc, OpBuilder &builder, Operation *branchRegionOp, Operation *replacedControlFlowOp, ValueRange results)=0 |
Creates a return-like terminator for a branch region of the op returned by createStructuredBranchRegionOp . More... | |
virtual FailureOr< Operation * > | createStructuredDoWhileLoopOp (OpBuilder &builder, Operation *replacedOp, ValueRange loopValuesInit, Value condition, ValueRange loopValuesNextIter, Region &&loopBody)=0 |
Creates a structured control flow operation representing a do-while loop. More... | |
virtual Value | getCFGSwitchValue (Location loc, OpBuilder &builder, unsigned value)=0 |
Creates a constant operation with a result representing value that is suitable as flag for createCFGSwitchOp . More... | |
virtual void | createCFGSwitchOp (Location loc, OpBuilder &builder, Value flag, ArrayRef< unsigned > caseValues, BlockRange caseDestinations, ArrayRef< ValueRange > caseArguments, Block *defaultDest, ValueRange defaultArgs)=0 |
Creates a switch CFG branch operation branching to one of caseDestinations or defaultDest . More... | |
virtual Value | getUndefValue (Location loc, OpBuilder &builder, Type type)=0 |
Creates a constant operation returning an undefined instance of type . More... | |
virtual FailureOr< Operation * > | createUnreachableTerminator (Location loc, OpBuilder &builder, Region ®ion)=0 |
Creates a return-like terminator indicating unreachable. More... | |
void | createSingleDestinationBranch (Location loc, OpBuilder &builder, Value dummyFlag, Block *destination, ValueRange arguments) |
Helper function to create an unconditional branch using createCFGSwitchOp . More... | |
void | createConditionalBranch (Location loc, OpBuilder &builder, Value condition, Block *trueDest, ValueRange trueArgs, Block *falseDest, ValueRange falseArgs) |
Helper function to create a conditional branch using createCFGSwitchOp . More... | |
Interface that should be implemented by any caller of transformCFGToSCF
.
The transformation requires the caller to 1) create switch-like control flow operations for intermediate transformations and 2) to create the desired structured control flow ops.
Definition at line 28 of file CFGToSCF.h.
|
virtualdefault |
|
pure virtual |
Creates a switch CFG branch operation branching to one of caseDestinations
or defaultDest
.
This is used by the transformation for intermediate transformations before lifting to structured control flow. The switch op branches based on flag
which is guaranteed to be of the same type as values returned by getCFGSwitchValue
. The insertion block of the builder is guaranteed to have its predecessors already set to create an equivalent CFG after this operation. Note: caseValues
and other related ranges may be empty to represent an unconditional branch.
Implemented in mlir::ControlFlowToSCFTransformation.
Referenced by createConditionalBranch(), and createSingleDestinationBranch().
|
inline |
Helper function to create a conditional branch using createCFGSwitchOp
.
Definition at line 126 of file CFGToSCF.h.
References createCFGSwitchOp().
Referenced by createSingleExitingLatch().
|
inline |
Helper function to create an unconditional branch using createCFGSwitchOp
.
Definition at line 117 of file CFGToSCF.h.
References createCFGSwitchOp().
|
pure virtual |
Creates a structured control flow operation branching to one of regions
.
It replaces controlFlowCondOp
and must have resultTypes
as results. regions
contains the list of branch regions corresponding to each successor of controlFlowCondOp
. Their bodies must simply be taken and left as is. Returns failure if incapable of converting the control flow graph operation.
Implemented in mlir::ControlFlowToSCFTransformation.
Referenced by transformToStructuredCFBranches().
|
pure virtual |
Creates a return-like terminator for a branch region of the op returned by createStructuredBranchRegionOp
.
branchRegionOp
is the operation returned by createStructuredBranchRegionOp
. replacedControlFlowOp
is the control flow op being replaced by the terminator or nullptr if the terminator is not replacing any existing control flow op. results
are the values that should be returned by the branch region.
Implemented in mlir::ControlFlowToSCFTransformation.
Referenced by transformToStructuredCFBranches().
|
pure virtual |
Creates a structured control flow operation representing a do-while loop.
The do-while loop is expected to have the exact same result types as the types of the iteration values. loopBody
is the body of the loop. The implementation of this function must create a suitable terminator op at the end of the last block in loopBody
which continues the loop if condition
is 1 and exits the loop if 0. loopValuesNextIter
are the values that have to be passed as the iteration values for the next iteration if continuing, or the result of the loop if exiting. condition
is guaranteed to be of the same type as values returned by getCFGSwitchValue
with either 0 or 1 as value.
loopValuesInit
are the values used to initialize the iteration values of the loop. Returns failure if incapable of creating a loop op.
Implemented in mlir::ControlFlowToSCFTransformation.
Referenced by transformCyclesToSCFLoops().
|
pure virtual |
Creates a return-like terminator indicating unreachable.
This is required when the transformation encounters a statically known infinite loop. Since structured control flow ops are not terminators, after lifting an infinite loop, a terminator has to be placed after to possibly satisfy the terminator requirement of the region originally passed to transformCFGToSCF
.
region
is guaranteed to be the region originally passed to transformCFGToSCF
and the op is guaranteed to always be an op in a block directly nested under region
after the transformation.
Returns failure if incapable of creating an unreachable terminator.
Implemented in mlir::ControlFlowToSCFTransformation.
Referenced by createSingleExitingLatch().
|
pure virtual |
Creates a constant operation with a result representing value
that is suitable as flag for createCFGSwitchOp
.
Implemented in mlir::ControlFlowToSCFTransformation.
Referenced by mlir::transformCFGToSCF().
|
pure virtual |
Creates a constant operation returning an undefined instance of type
.
This is required by the transformation as the lifting process might create control-flow paths where an SSA-value is undefined.
Implemented in mlir::ControlFlowToSCFTransformation.
Referenced by mlir::transformCFGToSCF().