MLIR  19.0.0git
Public Member Functions | List of all members
mlir::ControlFlowToSCFTransformation Class Reference

Implementation of CFGToSCFInterface used to lift Control Flow Dialect operations to SCF Dialect operations. More...

#include "mlir/Conversion/ControlFlowToSCF/ControlFlowToSCF.h"

+ Inheritance diagram for mlir::ControlFlowToSCFTransformation:

Public Member Functions

FailureOr< Operation * > createStructuredBranchRegionOp (OpBuilder &builder, Operation *controlFlowCondOp, TypeRange resultTypes, MutableArrayRef< Region > regions) override
 Creates an scf.if op if controlFlowCondOp is a cf.cond_br op or an scf.index_switch if controlFlowCondOp is a cf.switch. More...
 
LogicalResult createStructuredBranchRegionTerminatorOp (Location loc, OpBuilder &builder, Operation *branchRegionOp, Operation *replacedControlFlowOp, ValueRange results) override
 Creates an scf.yield op returning the given results. More...
 
FailureOr< Operation * > createStructuredDoWhileLoopOp (OpBuilder &builder, Operation *replacedOp, ValueRange loopVariablesInit, Value condition, ValueRange loopVariablesNextIter, Region &&loopBody) override
 Creates an scf.while op. More...
 
Value getCFGSwitchValue (Location loc, OpBuilder &builder, unsigned value) override
 Creates an arith.constant with an i32 attribute of the given value. More...
 
void createCFGSwitchOp (Location loc, OpBuilder &builder, Value flag, ArrayRef< unsigned > caseValues, BlockRange caseDestinations, ArrayRef< ValueRange > caseArguments, Block *defaultDest, ValueRange defaultArgs) override
 Creates a cf.switch op with the given cases and flag. More...
 
Value getUndefValue (Location loc, OpBuilder &builder, Type type) override
 Creates a ub.poison op of the given type. More...
 
FailureOr< Operation * > createUnreachableTerminator (Location loc, OpBuilder &builder, Region &region) override
 Creates a func.return op with poison for each of the return values of the function. More...
 
- Public Member Functions inherited from mlir::CFGToSCFInterface
virtual ~CFGToSCFInterface ()=default
 
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...
 

Detailed Description

Implementation of CFGToSCFInterface used to lift Control Flow Dialect operations to SCF Dialect operations.

Definition at line 25 of file ControlFlowToSCF.h.

Member Function Documentation

◆ createCFGSwitchOp()

void ControlFlowToSCFTransformation::createCFGSwitchOp ( Location  loc,
OpBuilder builder,
Value  flag,
ArrayRef< unsigned >  caseValues,
BlockRange  caseDestinations,
ArrayRef< ValueRange caseArguments,
Block defaultDest,
ValueRange  defaultArgs 
)
overridevirtual

Creates a cf.switch op with the given cases and flag.

Implements mlir::CFGToSCFInterface.

Definition at line 117 of file ControlFlowToSCF.cpp.

References mlir::OpBuilder::create().

◆ createStructuredBranchRegionOp()

FailureOr< Operation * > ControlFlowToSCFTransformation::createStructuredBranchRegionOp ( OpBuilder builder,
Operation controlFlowCondOp,
TypeRange  resultTypes,
MutableArrayRef< Region regions 
)
overridevirtual

Creates an scf.if op if controlFlowCondOp is a cf.cond_br op or an scf.index_switch if controlFlowCondOp is a cf.switch.

Returns failure otherwise.

Implements mlir::CFGToSCFInterface.

Definition at line 33 of file ControlFlowToSCF.cpp.

References mlir::OpBuilder::create(), mlir::Operation::emitOpError(), mlir::failure(), mlir::Builder::getIndexType(), and mlir::Operation::getLoc().

◆ createStructuredBranchRegionTerminatorOp()

LogicalResult ControlFlowToSCFTransformation::createStructuredBranchRegionTerminatorOp ( Location  loc,
OpBuilder builder,
Operation branchRegionOp,
Operation replacedControlFlowOp,
ValueRange  results 
)
overridevirtual

Creates an scf.yield op returning the given results.

Implements mlir::CFGToSCFInterface.

Definition at line 77 of file ControlFlowToSCF.cpp.

References mlir::OpBuilder::create(), and mlir::success().

◆ createStructuredDoWhileLoopOp()

FailureOr< Operation * > ControlFlowToSCFTransformation::createStructuredDoWhileLoopOp ( OpBuilder builder,
Operation replacedOp,
ValueRange  loopVariablesInit,
Value  condition,
ValueRange  loopVariablesNextIter,
Region &&  loopBody 
)
overridevirtual

Creates an scf.while op.

The loop body is made the before-region of the while op and terminated with an scf.condition op. The after-region does nothing but forward the iteration variables.

Implements mlir::CFGToSCFInterface.

Definition at line 85 of file ControlFlowToSCF.cpp.

References mlir::Block::addArguments(), mlir::OpBuilder::create(), mlir::OpBuilder::createBlock(), mlir::Block::getArguments(), mlir::Builder::getI1Type(), mlir::Operation::getLoc(), mlir::ValueRange::getTypes(), and mlir::OpBuilder::setInsertionPointToEnd().

◆ createUnreachableTerminator()

FailureOr< Operation * > ControlFlowToSCFTransformation::createUnreachableTerminator ( Location  loc,
OpBuilder builder,
Region region 
)
overridevirtual

Creates a func.return op with poison for each of the return values of the function.

It is guaranteed to be directly within the function body. TODO: This can be made independent of the func dialect once the UB dialect has a ub.unreachable op.

Implements mlir::CFGToSCFInterface.

Definition at line 134 of file ControlFlowToSCF.cpp.

References mlir::OpBuilder::create(), mlir::emitError(), mlir::Operation::getName(), and mlir::Region::getParentOp().

◆ getCFGSwitchValue()

Value ControlFlowToSCFTransformation::getCFGSwitchValue ( Location  loc,
OpBuilder builder,
unsigned  value 
)
overridevirtual

Creates an arith.constant with an i32 attribute of the given value.

Implements mlir::CFGToSCFInterface.

Definition at line 110 of file ControlFlowToSCF.cpp.

References mlir::OpBuilder::create(), and mlir::Builder::getI32IntegerAttr().

◆ getUndefValue()

Value ControlFlowToSCFTransformation::getUndefValue ( Location  loc,
OpBuilder builder,
Type  type 
)
overridevirtual

Creates a ub.poison op of the given type.

Implements mlir::CFGToSCFInterface.

Definition at line 127 of file ControlFlowToSCF.cpp.

References mlir::OpBuilder::create().


The documentation for this class was generated from the following files: