MLIR  19.0.0git
Macros | Functions
ControlFlowOps.cpp File Reference
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.h"
#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/IR/Value.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include <numeric>
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOpsDialect.cpp.inc"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.cpp.inc"

Go to the source code of this file.

Macros

#define GET_OP_LIST
 
#define GET_OP_CLASSES
 

Functions

static LogicalResult collapseBranch (Block *&successor, ValueRange &successorOperands, SmallVectorImpl< Value > &argStorage)
 Given a successor, try to collapse it to a new destination if it only contains a passthrough unconditional branch. More...
 
static LogicalResult simplifyBrToBlockWithSinglePred (BranchOp op, PatternRewriter &rewriter)
 Simplify a branch to a block that has a single predecessor. More...
 
static LogicalResult simplifyPassThroughBr (BranchOp op, PatternRewriter &rewriter)
 br ^bb1 ^bb1 br ^bbN(...) More...
 
static ParseResult parseSwitchOpCases (OpAsmParser &parser, Type &flagType, Block *&defaultDestination, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &defaultOperands, SmallVectorImpl< Type > &defaultOperandTypes, DenseIntElementsAttr &caseValues, SmallVectorImpl< Block * > &caseDestinations, SmallVectorImpl< SmallVector< OpAsmParser::UnresolvedOperand >> &caseOperands, SmallVectorImpl< SmallVector< Type >> &caseOperandTypes)
 <cases> ::= default : bb-id (( ssa-use-and-type-list ))? ( , integer : bb-id (( ssa-use-and-type-list ))? )* More...
 
static void printSwitchOpCases (OpAsmPrinter &p, SwitchOp op, Type flagType, Block *defaultDestination, OperandRange defaultOperands, TypeRange defaultOperandTypes, DenseIntElementsAttr caseValues, SuccessorRange caseDestinations, OperandRangeRange caseOperands, const TypeRangeRange &caseOperandTypes)
 
static LogicalResult simplifySwitchWithOnlyDefault (SwitchOp op, PatternRewriter &rewriter)
 switch flag : i32, [ default: ^bb1 ] -> br ^bb1 More...
 
static LogicalResult dropSwitchCasesThatMatchDefault (SwitchOp op, PatternRewriter &rewriter)
 switch flag : i32, [ default: ^bb1, 42: ^bb1, 43: ^bb2 ] -> switch flag : i32, [ default: ^bb1, 43: ^bb2 ] More...
 
static void foldSwitch (SwitchOp op, PatternRewriter &rewriter, const APInt &caseValue)
 Helper for folding a switch with a constant value. More...
 
static LogicalResult simplifyConstSwitchValue (SwitchOp op, PatternRewriter &rewriter)
 switch c_42 : i32, [ default: ^bb1, 42: ^bb2, 43: ^bb3 ] -> br ^bb2 More...
 
static LogicalResult simplifyPassThroughSwitch (SwitchOp op, PatternRewriter &rewriter)
 switch c_42 : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb3 -> switch c_42 : i32, [ default: ^bb1, 42: ^bb3, ] More...
 
static LogicalResult simplifySwitchFromSwitchOnSameCondition (SwitchOp op, PatternRewriter &rewriter)
 switch flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: switch flag : i32, [ default: ^bb3, 42: ^bb4 ] -> switch flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb4 More...
 
static LogicalResult simplifySwitchFromDefaultSwitchOnSameCondition (SwitchOp op, PatternRewriter &rewriter)
 switch flag : i32, [ default: ^bb1, 42: ^bb2 ] ^bb1: switch flag : i32, [ default: ^bb3, 42: ^bb4, 43: ^bb5 ] -> switch flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb1: switch flag : i32, [ default: ^bb3, 43: ^bb5 ] More...
 

Macro Definition Documentation

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 911 of file ControlFlowOps.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

Function Documentation

◆ collapseBranch()

static LogicalResult collapseBranch ( Block *&  successor,
ValueRange successorOperands,
SmallVectorImpl< Value > &  argStorage 
)
static

Given a successor, try to collapse it to a new destination if it only contains a passthrough unconditional branch.

If the successor is collapsable, successor and successorOperands are updated to reference the new destination and values. argStorage is used as storage if operands to the collapsed successor need to be remapped. It must outlive uses of successorOperands.

Definition at line 102 of file ControlFlowOps.cpp.

References mlir::Block::args_empty(), mlir::Block::begin(), mlir::Block::end(), mlir::failure(), mlir::BlockArgument::getArgNumber(), mlir::Block::getArguments(), mlir::BlockArgument::getOwner(), mlir::Block::getTerminator(), mlir::Operation::getUsers(), and mlir::success().

◆ dropSwitchCasesThatMatchDefault()

static LogicalResult dropSwitchCasesThatMatchDefault ( SwitchOp  op,
PatternRewriter rewriter 
)
static

switch flag : i32, [ default: ^bb1, 42: ^bb1, 43: ^bb2 ] -> switch flag : i32, [ default: ^bb1, 43: ^bb2 ]

Definition at line 645 of file ControlFlowOps.cpp.

◆ foldSwitch()

static void foldSwitch ( SwitchOp  op,
PatternRewriter rewriter,
const APInt &  caseValue 
)
static

Helper for folding a switch with a constant value.

switch c_42 : i32, [ default: ^bb1 , 42: ^bb2, 43: ^bb3 ] -> br ^bb2

Definition at line 680 of file ControlFlowOps.cpp.

◆ parseSwitchOpCases()

static ParseResult parseSwitchOpCases ( OpAsmParser parser,
Type flagType,
Block *&  defaultDestination,
SmallVectorImpl< OpAsmParser::UnresolvedOperand > &  defaultOperands,
SmallVectorImpl< Type > &  defaultOperandTypes,
DenseIntElementsAttr caseValues,
SmallVectorImpl< Block * > &  caseDestinations,
SmallVectorImpl< SmallVector< OpAsmParser::UnresolvedOperand >> &  caseOperands,
SmallVectorImpl< SmallVector< Type >> &  caseOperandTypes 
)
static

◆ printSwitchOpCases()

static void printSwitchOpCases ( OpAsmPrinter p,
SwitchOp  op,
Type  flagType,
Block defaultDestination,
OperandRange  defaultOperands,
TypeRange  defaultOperandTypes,
DenseIntElementsAttr  caseValues,
SuccessorRange  caseDestinations,
OperandRangeRange  caseOperands,
const TypeRangeRange caseOperandTypes 
)
static

Definition at line 552 of file ControlFlowOps.cpp.

◆ simplifyBrToBlockWithSinglePred()

static LogicalResult simplifyBrToBlockWithSinglePred ( BranchOp  op,
PatternRewriter rewriter 
)
static

Simplify a branch to a block that has a single predecessor.

This effectively merges the two blocks.

Definition at line 148 of file ControlFlowOps.cpp.

◆ simplifyConstSwitchValue()

static LogicalResult simplifyConstSwitchValue ( SwitchOp  op,
PatternRewriter rewriter 
)
static

switch c_42 : i32, [ default: ^bb1, 42: ^bb2, 43: ^bb3 ] -> br ^bb2

Definition at line 701 of file ControlFlowOps.cpp.

◆ simplifyPassThroughBr()

static LogicalResult simplifyPassThroughBr ( BranchOp  op,
PatternRewriter rewriter 
)
static

br ^bb1 ^bb1 br ^bbN(...)

-> br ^bbN(...)

Definition at line 168 of file ControlFlowOps.cpp.

◆ simplifyPassThroughSwitch()

static LogicalResult simplifyPassThroughSwitch ( SwitchOp  op,
PatternRewriter rewriter 
)
static

switch c_42 : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb3 -> switch c_42 : i32, [ default: ^bb1, 42: ^bb3, ]

Definition at line 722 of file ControlFlowOps.cpp.

◆ simplifySwitchFromDefaultSwitchOnSameCondition()

static LogicalResult simplifySwitchFromDefaultSwitchOnSameCondition ( SwitchOp  op,
PatternRewriter rewriter 
)
static

switch flag : i32, [ default: ^bb1, 42: ^bb2 ] ^bb1: switch flag : i32, [ default: ^bb3, 42: ^bb4, 43: ^bb5 ] -> switch flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb1: switch flag : i32, [ default: ^bb3, 43: ^bb5 ]

Definition at line 847 of file ControlFlowOps.cpp.

◆ simplifySwitchFromSwitchOnSameCondition()

static LogicalResult simplifySwitchFromSwitchOnSameCondition ( SwitchOp  op,
PatternRewriter rewriter 
)
static

switch flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: switch flag : i32, [ default: ^bb3, 42: ^bb4 ] -> switch flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb4

and

switch flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: switch flag : i32, [ default: ^bb3, 43: ^bb4 ] -> switch flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb3

Definition at line 795 of file ControlFlowOps.cpp.

◆ simplifySwitchWithOnlyDefault()

static LogicalResult simplifySwitchWithOnlyDefault ( SwitchOp  op,
PatternRewriter rewriter 
)
static

switch flag : i32, [ default: ^bb1 ] -> br ^bb1

Definition at line 624 of file ControlFlowOps.cpp.