MLIR
20.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/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... | |
#define GET_OP_CLASSES |
Definition at line 918 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 109 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(), and mlir::Operation::getUsers().
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 652 of file ControlFlowOps.cpp.
References mlir::detail::enumerate(), and mlir::RewriterBase::replaceOpWithNewOp().
|
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 687 of file ControlFlowOps.cpp.
References mlir::detail::enumerate(), and 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 507 of file ControlFlowOps.cpp.
References mlir::DenseIntElementsAttr::get(), mlir::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(), and mlir::OpAsmParser::parseSuccessor().
|
static |
Definition at line 559 of file ControlFlowOps.cpp.
References mlir::detail::enumerate(), 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 155 of file ControlFlowOps.cpp.
References mlir::RewriterBase::eraseOp(), mlir::Block::getPredecessors(), and mlir::RewriterBase::mergeBlocks().
|
static |
switch c_42 : i32, [ default: ^bb1, 42: ^bb2, 43: ^bb3 ] -> br ^bb2
Definition at line 708 of file ControlFlowOps.cpp.
References foldSwitch(), mlir::m_ConstantInt(), and mlir::matchPattern().
|
static |
br ^bb1 ^bb1 br ^bbN(...)
-> br ^bbN(...)
Definition at line 175 of file ControlFlowOps.cpp.
References collapseBranch(), and mlir::RewriterBase::replaceOpWithNewOp().
|
static |
switch c_42 : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb3 -> switch c_42 : i32, [ default: ^bb1, 42: ^bb3, ]
Definition at line 729 of file ControlFlowOps.cpp.
References collapseBranch(), and mlir::RewriterBase::replaceOpWithNewOp().
|
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 854 of file ControlFlowOps.cpp.
References mlir::detail::enumerate(), mlir::Block::getSinglePredecessor(), mlir::Block::getTerminator(), and mlir::RewriterBase::replaceOpWithNewOp().
|
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 802 of file ControlFlowOps.cpp.
References foldSwitch(), mlir::Block::getSinglePredecessor(), mlir::Block::getTerminator(), and mlir::RewriterBase::replaceOpWithNewOp().
|
static |
switch flag : i32, [ default: ^bb1 ] -> br ^bb1
Definition at line 631 of file ControlFlowOps.cpp.
References mlir::RewriterBase::replaceOpWithNewOp().