|
MLIR 22.0.0git
|
#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/Dialect/UB/IR/UBOps.h"#include "mlir/IR/AffineExpr.h"#include "mlir/IR/AffineMap.h"#include "mlir/IR/Builders.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/STLExtras.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. | |
| static LogicalResult | simplifyBrToBlockWithSinglePred (BranchOp op, PatternRewriter &rewriter) |
| Simplify a branch to a block that has a single predecessor. | |
| static LogicalResult | simplifyPassThroughBr (BranchOp op, PatternRewriter &rewriter) |
| br ^bb1 ^bb1 br ^bbN(...) | |
| 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 ))? | |
| 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 | |
| static LogicalResult | dropSwitchCasesThatMatchDefault (SwitchOp op, PatternRewriter &rewriter) |
| switch flag : i32, [ default: ^bb1, 42: ^bb1, 43: ^bb2 ] -> switch flag : i32, [ default: ^bb1, 43: ^bb2 ] | |
| static void | foldSwitch (SwitchOp op, PatternRewriter &rewriter, const APInt &caseValue) |
| Helper for folding a switch with a constant value. | |
| static LogicalResult | simplifyConstSwitchValue (SwitchOp op, PatternRewriter &rewriter) |
| switch c_42 : i32, [ default: ^bb1, 42: ^bb2, 43: ^bb3 ] -> br ^bb2 | |
| 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, ] | |
| 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 | |
| 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 ] | |
| #define GET_OP_CLASSES |
Definition at line 957 of file ControlFlowOps.cpp.
| #define GET_OP_LIST |
|
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 106 of file ControlFlowOps.cpp.
References mlir::Block::args_empty(), mlir::Block::begin(), mlir::Block::end(), mlir::BlockArgument::getArgNumber(), mlir::Block::getArguments(), mlir::BlockArgument::getOwner(), mlir::Block::getTerminator(), mlir::Operation::getUsers(), and success().
Referenced by simplifyPassThroughBr(), and simplifyPassThroughSwitch().
|
static |
switch flag : i32, [ default: ^bb1, 42: ^bb1, 43: ^bb2 ] -> switch flag : i32, [ default: ^bb1, 43: ^bb2 ]
Definition at line 691 of file ControlFlowOps.cpp.
References mlir::RewriterBase::replaceOpWithNewOp(), and success().
|
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 726 of file ControlFlowOps.cpp.
References mlir::RewriterBase::replaceOpWithNewOp().
Referenced by simplifyConstSwitchValue(), and simplifySwitchFromSwitchOnSameCondition().
|
static |
<cases> ::= default : bb-id (( ssa-use-and-type-list ))?
( , integer : bb-id (( ssa-use-and-type-list ))? )*
Definition at line 546 of file ControlFlowOps.cpp.
References mlir::DenseIntElementsAttr::get(), mlir::Type::getIntOrFloatBitWidth(), mlir::AsmParser::None, mlir::AsmParser::parseColon(), mlir::AsmParser::parseColonTypeList(), mlir::AsmParser::parseInteger(), mlir::AsmParser::parseKeyword(), mlir::OpAsmParser::parseOperandList(), mlir::AsmParser::parseOptionalComma(), mlir::AsmParser::parseOptionalLParen(), mlir::AsmParser::parseRParen(), mlir::OpAsmParser::parseSuccessor(), and success().
|
static |
Definition at line 598 of file ControlFlowOps.cpp.
References mlir::OpAsmPrinter::printNewline(), and mlir::OpAsmPrinter::printSuccessorAndUseList().
|
static |
Simplify a branch to a block that has a single predecessor.
This effectively merges the two blocks.
Definition at line 162 of file ControlFlowOps.cpp.
References mlir::RewriterBase::eraseOp(), mlir::Block::getPredecessors(), mlir::RewriterBase::mergeBlocks(), and success().
|
static |
switch c_42 : i32, [ default: ^bb1, 42: ^bb2, 43: ^bb3 ] -> br ^bb2
Definition at line 747 of file ControlFlowOps.cpp.
References foldSwitch(), mlir::m_ConstantInt(), mlir::matchPattern(), and success().
|
static |
br ^bb1 ^bb1 br ^bbN(...)
-> br ^bbN(...)
Definition at line 182 of file ControlFlowOps.cpp.
References collapseBranch(), mlir::RewriterBase::replaceOpWithNewOp(), and success().
|
static |
switch c_42 : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb3 -> switch c_42 : i32, [ default: ^bb1, 42: ^bb3, ]
Definition at line 768 of file ControlFlowOps.cpp.
References collapseBranch(), mlir::RewriterBase::replaceOpWithNewOp(), and success().
|
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 893 of file ControlFlowOps.cpp.
References mlir::Block::getSinglePredecessor(), mlir::Block::getTerminator(), mlir::RewriterBase::replaceOpWithNewOp(), and success().
|
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 841 of file ControlFlowOps.cpp.
References foldSwitch(), mlir::Block::getSinglePredecessor(), mlir::Block::getTerminator(), mlir::RewriterBase::replaceOpWithNewOp(), and success().
|
static |
switch flag : i32, [ default: ^bb1 ] -> br ^bb1
Definition at line 670 of file ControlFlowOps.cpp.
References mlir::RewriterBase::replaceOpWithNewOp(), and success().