#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"
usingnamespacemlir;
usingnamespacemlir::cf;
namespace {
struct ControlFlowInlinerInterface : public DialectInlinerInterface { … };
}
void ControlFlowDialect::initialize() { … }
LogicalResult AssertOp::canonicalize(AssertOp op, PatternRewriter &rewriter) { … }
void AssertOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) { … }
static LogicalResult collapseBranch(Block *&successor,
ValueRange &successorOperands,
SmallVectorImpl<Value> &argStorage) { … }
static LogicalResult
simplifyBrToBlockWithSinglePred(BranchOp op, PatternRewriter &rewriter) { … }
static LogicalResult simplifyPassThroughBr(BranchOp op,
PatternRewriter &rewriter) { … }
LogicalResult BranchOp::canonicalize(BranchOp op, PatternRewriter &rewriter) { … }
void BranchOp::setDest(Block *block) { … }
void BranchOp::eraseOperand(unsigned index) { … }
SuccessorOperands BranchOp::getSuccessorOperands(unsigned index) { … }
Block *BranchOp::getSuccessorForOperands(ArrayRef<Attribute>) { … }
namespace {
struct SimplifyConstCondBranchPred : public OpRewritePattern<CondBranchOp> { … };
struct SimplifyPassThroughCondBranch : public OpRewritePattern<CondBranchOp> { … };
struct SimplifyCondBranchIdenticalSuccessors
: public OpRewritePattern<CondBranchOp> { … };
struct SimplifyCondBranchFromCondBranchOnSameCondition
: public OpRewritePattern<CondBranchOp> { … };
struct CondBranchTruthPropagation : public OpRewritePattern<CondBranchOp> { … };
}
void CondBranchOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
SuccessorOperands CondBranchOp::getSuccessorOperands(unsigned index) { … }
Block *CondBranchOp::getSuccessorForOperands(ArrayRef<Attribute> operands) { … }
void SwitchOp::build(OpBuilder &builder, OperationState &result, Value value,
Block *defaultDestination, ValueRange defaultOperands,
DenseIntElementsAttr caseValues,
BlockRange caseDestinations,
ArrayRef<ValueRange> caseOperands) { … }
void SwitchOp::build(OpBuilder &builder, OperationState &result, Value value,
Block *defaultDestination, ValueRange defaultOperands,
ArrayRef<APInt> caseValues, BlockRange caseDestinations,
ArrayRef<ValueRange> caseOperands) { … }
void SwitchOp::build(OpBuilder &builder, OperationState &result, Value value,
Block *defaultDestination, ValueRange defaultOperands,
ArrayRef<int32_t> caseValues, BlockRange caseDestinations,
ArrayRef<ValueRange> caseOperands) { … }
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 void printSwitchOpCases(
OpAsmPrinter &p, SwitchOp op, Type flagType, Block *defaultDestination,
OperandRange defaultOperands, TypeRange defaultOperandTypes,
DenseIntElementsAttr caseValues, SuccessorRange caseDestinations,
OperandRangeRange caseOperands, const TypeRangeRange &caseOperandTypes) { … }
LogicalResult SwitchOp::verify() { … }
SuccessorOperands SwitchOp::getSuccessorOperands(unsigned index) { … }
Block *SwitchOp::getSuccessorForOperands(ArrayRef<Attribute> operands) { … }
static LogicalResult simplifySwitchWithOnlyDefault(SwitchOp op,
PatternRewriter &rewriter) { … }
static LogicalResult
dropSwitchCasesThatMatchDefault(SwitchOp op, PatternRewriter &rewriter) { … }
static void foldSwitch(SwitchOp op, PatternRewriter &rewriter,
const APInt &caseValue) { … }
static LogicalResult simplifyConstSwitchValue(SwitchOp op,
PatternRewriter &rewriter) { … }
static LogicalResult simplifyPassThroughSwitch(SwitchOp op,
PatternRewriter &rewriter) { … }
static LogicalResult
simplifySwitchFromSwitchOnSameCondition(SwitchOp op,
PatternRewriter &rewriter) { … }
static LogicalResult
simplifySwitchFromDefaultSwitchOnSameCondition(SwitchOp op,
PatternRewriter &rewriter) { … }
void SwitchOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
#define GET_OP_CLASSES
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.cpp.inc"