MLIR 22.0.0git
SCF.cpp File Reference
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Conversion/ConvertToEmitC/ToEmitCInterface.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.h"
#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/DeviceMappingInterface.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/OperationSupport.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Interfaces/ParallelCombiningOpInterface.h"
#include "mlir/Interfaces/ValueBoundsOpInterface.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DebugLog.h"
#include <optional>
#include "mlir/Dialect/SCF/IR/SCFOpsDialect.cpp.inc"
#include "mlir/Dialect/SCF/IR/SCFOps.cpp.inc"

Go to the source code of this file.

Classes

struct  SingleBlockExecuteInliner
struct  MultiBlockExecuteInliner
struct  ExecuteRegionForwardingEliminator
struct  FoldConstantCase

Macros

#define GET_OP_LIST
#define GET_OP_CLASSES

Functions

template<typename TerminatorTy>
static TerminatorTy verifyAndGetTerminator (Operation *op, Region &region, StringRef errorMessage)
 Verifies that the first block of the given region is terminated by a TerminatorTy.
static void replaceOpWithRegion (PatternRewriter &rewriter, Operation *op, Region &region, ValueRange blockArgs={})
 Replaces the given op with the contents of the given single-block region, using the operands of the block terminator to replace operation results.
static void printInitializationList (OpAsmPrinter &p, Block::BlockArgListType blocksArgs, ValueRange initializers, StringRef prefix="")
 Prints the initialization list in the form of <prefix>(inner = outer, inner2 = outer2, <...>) where 'inner' values are assumed to be region arguments and 'outer' values are regular SSA values.
template<typename OpTy>
static LogicalResult verifyTypeRangesMatch (OpTy op, TypeRange left, TypeRange right, StringRef message)
 Verifies that two ranges of types match, i.e.
static ParseResult parseSwitchCases (OpAsmParser &p, DenseI64ArrayAttr &cases, SmallVectorImpl< std::unique_ptr< Region > > &caseRegions)
 Parse the case regions and values.
static void printSwitchCases (OpAsmPrinter &p, Operation *op, DenseI64ArrayAttr cases, RegionRange caseRegions)
 Print the case regions and values.

Macro Definition Documentation

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 4586 of file SCF.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

Function Documentation

◆ parseSwitchCases()

ParseResult parseSwitchCases ( OpAsmParser & p,
DenseI64ArrayAttr & cases,
SmallVectorImpl< std::unique_ptr< Region > > & caseRegions )
static

◆ printInitializationList()

void printInitializationList ( OpAsmPrinter & p,
Block::BlockArgListType blocksArgs,
ValueRange initializers,
StringRef prefix = "" )
static

Prints the initialization list in the form of <prefix>(inner = outer, inner2 = outer2, <...>) where 'inner' values are assumed to be region arguments and 'outer' values are regular SSA values.

Definition at line 565 of file SCF.cpp.

◆ printSwitchCases()

void printSwitchCases ( OpAsmPrinter & p,
Operation * op,
DenseI64ArrayAttr cases,
RegionRange caseRegions )
static

Print the case regions and values.

Definition at line 4426 of file SCF.cpp.

References mlir::detail::DenseArrayAttrImpl< T >::asArrayRef(), mlir::OpAsmPrinter::printNewline(), and mlir::OpAsmPrinter::printRegion().

◆ replaceOpWithRegion()

void replaceOpWithRegion ( PatternRewriter & rewriter,
Operation * op,
Region & region,
ValueRange blockArgs = {} )
static

Replaces the given op with the contents of the given single-block region, using the operands of the block terminator to replace operation results.

Definition at line 136 of file SCF.cpp.

Referenced by SingleBlockExecuteInliner::matchAndRewrite().

◆ verifyAndGetTerminator()

template<typename TerminatorTy>
TerminatorTy verifyAndGetTerminator ( Operation * op,
Region & region,
StringRef errorMessage )
static

Verifies that the first block of the given region is terminated by a TerminatorTy.

Reports errors on the given operation if it is not the case.

Definition at line 100 of file SCF.cpp.

References mlir::Block::back(), diag(), mlir::Operation::emitOpError(), mlir::Block::empty(), mlir::Region::empty(), mlir::Region::front(), and mlir::Operation::getLoc().

◆ verifyTypeRangesMatch()

template<typename OpTy>
LogicalResult verifyTypeRangesMatch ( OpTy op,
TypeRange left,
TypeRange right,
StringRef message )
static

Verifies that two ranges of types match, i.e.

have the same number of entries and that types are pairwise equals. Reports errors on the given operation in case of mismatch.

Definition at line 3658 of file SCF.cpp.

References diag(), and success().