MLIR  16.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
mlir::OpBuilder Class Reference

This class helps build Operations. More...

#include "mlir/IR/Builders.h"

+ Inheritance diagram for mlir::OpBuilder:
+ Collaboration diagram for mlir::OpBuilder:

Classes

class  InsertionGuard
 RAII guard to reset the insertion point of the builder when destroyed. More...
 
class  InsertPoint
 This class represents a saved insertion point. More...
 
struct  Listener
 This class represents a listener that may be used to hook into various actions within an OpBuilder. More...
 

Public Member Functions

 OpBuilder (MLIRContext *ctx, Listener *listener=nullptr)
 Create a builder with the given context. More...
 
 OpBuilder (Region *region, Listener *listener=nullptr)
 Create a builder and set the insertion point to the start of the region. More...
 
 OpBuilder (Region &region, Listener *listener=nullptr)
 
 OpBuilder (Operation *op, Listener *listener=nullptr)
 Create a builder and set insertion point to the given operation, which will cause subsequent insertions to go right before it. More...
 
 OpBuilder (Block *block, Block::iterator insertPoint, Listener *listener=nullptr)
 
void setListener (Listener *newListener)
 Sets the listener of this builder to the one provided. More...
 
ListenergetListener () const
 Returns the current listener of this builder, or nullptr if this builder doesn't have a listener. More...
 
void clearInsertionPoint ()
 Reset the insertion point to no location. More...
 
InsertPoint saveInsertionPoint () const
 Return a saved insertion point. More...
 
void restoreInsertionPoint (InsertPoint ip)
 Restore the insert point to a previously saved point. More...
 
void setInsertionPoint (Block *block, Block::iterator insertPoint)
 Set the insertion point to the specified location. More...
 
void setInsertionPoint (Operation *op)
 Sets the insertion point to the specified operation, which will cause subsequent insertions to go right before it. More...
 
void setInsertionPointAfter (Operation *op)
 Sets the insertion point to the node after the specified operation, which will cause subsequent insertions to go right after it. More...
 
void setInsertionPointAfterValue (Value val)
 Sets the insertion point to the node after the specified value. More...
 
void setInsertionPointToStart (Block *block)
 Sets the insertion point to the start of the specified block. More...
 
void setInsertionPointToEnd (Block *block)
 Sets the insertion point to the end of the specified block. More...
 
BlockgetInsertionBlock () const
 Return the block the current insertion point belongs to. More...
 
Block::iterator getInsertionPoint () const
 Returns the current insertion point of the builder. More...
 
BlockgetBlock () const
 Returns the current block of the builder. More...
 
BlockcreateBlock (Region *parent, Region::iterator insertPt={}, TypeRange argTypes=llvm::None, ArrayRef< Location > locs=llvm::None)
 Add new block with 'argTypes' arguments and set the insertion point to the end of it. More...
 
BlockcreateBlock (Block *insertBefore, TypeRange argTypes=llvm::None, ArrayRef< Location > locs=llvm::None)
 Add new block with 'argTypes' arguments and set the insertion point to the end of it. More...
 
Operationinsert (Operation *op)
 Insert the given operation at the current insertion point and return it. More...
 
Operationcreate (const OperationState &state)
 Creates an operation given the fields represented as an OperationState. More...
 
Operationcreate (Location loc, StringAttr opName, ValueRange operands, TypeRange types={}, ArrayRef< NamedAttribute > attributes={}, BlockRange successors={}, MutableArrayRef< std::unique_ptr< Region >> regions={})
 Creates an operation with the given fields. More...
 
template<typename OpTy , typename... Args>
OpTy create (Location location, Args &&...args)
 Create an operation of specific op type at the current insertion point. More...
 
template<typename OpTy , typename... Args>
void createOrFold (SmallVectorImpl< Value > &results, Location location, Args &&...args)
 Create an operation of specific op type at the current insertion point, and immediately try to fold it. More...
 
template<typename OpTy , typename... Args>
std::enable_if_t< OpTy::template hasTrait< OpTrait::OneResult >), ValuecreateOrFold (Location location, Args &&...args)
 Overload to create or fold a single result operation. More...
 
template<typename OpTy , typename... Args>
std::enable_if_t< OpTy::template hasTrait< OpTrait::ZeroResults >), OpTy > createOrFold (Location location, Args &&...args)
 Overload to create or fold a zero result operation. More...
 
LogicalResult tryFold (Operation *op, SmallVectorImpl< Value > &results)
 Attempts to fold the given operation and places new results within 'results'. More...
 
Operationclone (Operation &op, BlockAndValueMapping &mapper)
 Creates a deep copy of the specified operation, remapping any operands that use values outside of the operation using the map that is provided ( leaving them alone if no entry is present). More...
 
Operationclone (Operation &op)
 
OperationcloneWithoutRegions (Operation &op, BlockAndValueMapping &mapper)
 Creates a deep copy of this operation but keep the operation regions empty. More...
 
OperationcloneWithoutRegions (Operation &op)
 
template<typename OpT >
OpT cloneWithoutRegions (OpT op)
 
- Public Member Functions inherited from mlir::Builder
 Builder (MLIRContext *context)
 
 Builder (Operation *op)
 
MLIRContextgetContext () const
 
Location getUnknownLoc ()
 
Location getFusedLoc (ArrayRef< Location > locs, Attribute metadata=Attribute())
 
FloatType getFloat8E5M2Type ()
 
FloatType getBF16Type ()
 
FloatType getF16Type ()
 
FloatType getF32Type ()
 
FloatType getF64Type ()
 
FloatType getF80Type ()
 
FloatType getF128Type ()
 
IndexType getIndexType ()
 
IntegerType getI1Type ()
 
IntegerType getI2Type ()
 
IntegerType getI4Type ()
 
IntegerType getI8Type ()
 
IntegerType getI16Type ()
 
IntegerType getI32Type ()
 
IntegerType getI64Type ()
 
IntegerType getIntegerType (unsigned width)
 
IntegerType getIntegerType (unsigned width, bool isSigned)
 
FunctionType getFunctionType (TypeRange inputs, TypeRange results)
 
TupleType getTupleType (TypeRange elementTypes)
 
NoneType getNoneType ()
 
template<typename Ty , typename... Args>
Ty getType (Args &&...args)
 Get or construct an instance of the type Ty with provided arguments. More...
 
template<typename Attr , typename... Args>
Attr getAttr (Args &&...args)
 Get or construct an instance of the attribute Attr with provided arguments. More...
 
NamedAttribute getNamedAttr (StringRef name, Attribute val)
 
UnitAttr getUnitAttr ()
 
BoolAttr getBoolAttr (bool value)
 
DictionaryAttr getDictionaryAttr (ArrayRef< NamedAttribute > value)
 
IntegerAttr getIntegerAttr (Type type, int64_t value)
 
IntegerAttr getIntegerAttr (Type type, const APInt &value)
 
FloatAttr getFloatAttr (Type type, double value)
 
FloatAttr getFloatAttr (Type type, const APFloat &value)
 
StringAttr getStringAttr (const Twine &bytes)
 
ArrayAttr getArrayAttr (ArrayRef< Attribute > value)
 
Attribute getZeroAttr (Type type)
 
FloatAttr getF16FloatAttr (float value)
 
FloatAttr getF32FloatAttr (float value)
 
FloatAttr getF64FloatAttr (double value)
 
IntegerAttr getI8IntegerAttr (int8_t value)
 
IntegerAttr getI16IntegerAttr (int16_t value)
 
IntegerAttr getI32IntegerAttr (int32_t value)
 
IntegerAttr getI64IntegerAttr (int64_t value)
 
IntegerAttr getIndexAttr (int64_t value)
 
IntegerAttr getSI32IntegerAttr (int32_t value)
 Signed and unsigned integer attribute getters. More...
 
IntegerAttr getUI32IntegerAttr (uint32_t value)
 
DenseIntElementsAttr getBoolVectorAttr (ArrayRef< bool > values)
 Vector-typed DenseIntElementsAttr getters. values must not be empty. More...
 
DenseIntElementsAttr getI32VectorAttr (ArrayRef< int32_t > values)
 
DenseIntElementsAttr getI64VectorAttr (ArrayRef< int64_t > values)
 
DenseIntElementsAttr getIndexVectorAttr (ArrayRef< int64_t > values)
 
DenseIntElementsAttr getI32TensorAttr (ArrayRef< int32_t > values)
 Tensor-typed DenseIntElementsAttr getters. More...
 
DenseIntElementsAttr getI64TensorAttr (ArrayRef< int64_t > values)
 
DenseIntElementsAttr getIndexTensorAttr (ArrayRef< int64_t > values)
 
DenseBoolArrayAttr getDenseBoolArrayAttr (ArrayRef< bool > values)
 Tensor-typed DenseArrayAttr getters. More...
 
DenseI8ArrayAttr getDenseI8ArrayAttr (ArrayRef< int8_t > values)
 
DenseI16ArrayAttr getDenseI16ArrayAttr (ArrayRef< int16_t > values)
 
DenseI32ArrayAttr getDenseI32ArrayAttr (ArrayRef< int32_t > values)
 
DenseI64ArrayAttr getDenseI64ArrayAttr (ArrayRef< int64_t > values)
 
DenseF32ArrayAttr getDenseF32ArrayAttr (ArrayRef< float > values)
 
DenseF64ArrayAttr getDenseF64ArrayAttr (ArrayRef< double > values)
 
ArrayAttr getAffineMapArrayAttr (ArrayRef< AffineMap > values)
 
ArrayAttr getBoolArrayAttr (ArrayRef< bool > values)
 
ArrayAttr getI32ArrayAttr (ArrayRef< int32_t > values)
 
ArrayAttr getI64ArrayAttr (ArrayRef< int64_t > values)
 
ArrayAttr getIndexArrayAttr (ArrayRef< int64_t > values)
 
ArrayAttr getF32ArrayAttr (ArrayRef< float > values)
 
ArrayAttr getF64ArrayAttr (ArrayRef< double > values)
 
ArrayAttr getStrArrayAttr (ArrayRef< StringRef > values)
 
ArrayAttr getTypeArrayAttr (TypeRange values)
 
AffineExpr getAffineDimExpr (unsigned position)
 
AffineExpr getAffineSymbolExpr (unsigned position)
 
AffineExpr getAffineConstantExpr (int64_t constant)
 
AffineMap getEmptyAffineMap ()
 Returns a zero result affine map with no dimensions or symbols: () -> (). More...
 
AffineMap getConstantAffineMap (int64_t val)
 Returns a single constant result affine map with 0 dimensions and 0 symbols. More...
 
AffineMap getDimIdentityMap ()
 
AffineMap getMultiDimIdentityMap (unsigned rank)
 
AffineMap getSymbolIdentityMap ()
 
AffineMap getSingleDimShiftAffineMap (int64_t shift)
 Returns a map that shifts its (single) input dimension by 'shift'. More...
 
AffineMap getShiftedAffineMap (AffineMap map, int64_t shift)
 Returns an affine map that is a translation (shift) of all result expressions in 'map' by 'shift'. More...
 

Static Public Member Functions

static OpBuilder atBlockBegin (Block *block, Listener *listener=nullptr)
 Create a builder and set the insertion point to before the first operation in the block but still inside the block. More...
 
static OpBuilder atBlockEnd (Block *block, Listener *listener=nullptr)
 Create a builder and set the insertion point to after the last operation in the block but still inside the block. More...
 
static OpBuilder atBlockTerminator (Block *block, Listener *listener=nullptr)
 Create a builder and set the insertion point to before the block terminator. More...
 

Additional Inherited Members

- Protected Attributes inherited from mlir::Builder
MLIRContextcontext
 

Detailed Description

This class helps build Operations.

Operations that are created are automatically inserted at an insertion point. The builder is copyable.

Definition at line 197 of file Builders.h.

Constructor & Destructor Documentation

◆ OpBuilder() [1/5]

mlir::OpBuilder::OpBuilder ( MLIRContext ctx,
Listener listener = nullptr 
)
inlineexplicit

Create a builder with the given context.

Definition at line 202 of file Builders.h.

◆ OpBuilder() [2/5]

mlir::OpBuilder::OpBuilder ( Region region,
Listener listener = nullptr 
)
inlineexplicit

Create a builder and set the insertion point to the start of the region.

Definition at line 206 of file Builders.h.

References mlir::Block::begin(), mlir::Region::empty(), and mlir::Region::front().

◆ OpBuilder() [3/5]

mlir::OpBuilder::OpBuilder ( Region region,
Listener listener = nullptr 
)
inlineexplicit

Definition at line 211 of file Builders.h.

◆ OpBuilder() [4/5]

mlir::OpBuilder::OpBuilder ( Operation op,
Listener listener = nullptr 
)
inlineexplicit

Create a builder and set insertion point to the given operation, which will cause subsequent insertions to go right before it.

Definition at line 216 of file Builders.h.

◆ OpBuilder() [5/5]

mlir::OpBuilder::OpBuilder ( Block block,
Block::iterator  insertPoint,
Listener listener = nullptr 
)
inline

Definition at line 221 of file Builders.h.

Member Function Documentation

◆ atBlockBegin()

static OpBuilder mlir::OpBuilder::atBlockBegin ( Block block,
Listener listener = nullptr 
)
inlinestatic

Create a builder and set the insertion point to before the first operation in the block but still inside the block.

Definition at line 229 of file Builders.h.

References mlir::Block::begin().

Referenced by mlir::collapseParallelLoops(), getOrInsertPushConstantVariable(), mlir::normalizeAffineParallel(), normalizeLoop(), and walkReferenceCountedValues().

◆ atBlockEnd()

static OpBuilder mlir::OpBuilder::atBlockEnd ( Block block,
Listener listener = nullptr 
)
inlinestatic

Create a builder and set the insertion point to after the last operation in the block but still inside the block.

Definition at line 235 of file Builders.h.

References mlir::Block::end().

Referenced by hasOneBranchOpTo(), and walkReferenceCountedValues().

◆ atBlockTerminator()

static OpBuilder mlir::OpBuilder::atBlockTerminator ( Block block,
Listener listener = nullptr 
)
inlinestatic

Create a builder and set the insertion point to before the block terminator.

Definition at line 241 of file Builders.h.

References mlir::Block::getTerminator().

Referenced by createFullTiles(), generatePointWiseCopy(), generateShiftedLoop(), generateUnrolledLoop(), and stripmineSink().

◆ clearInsertionPoint()

void mlir::OpBuilder::clearInsertionPoint ( )
inline

Reset the insertion point to no location.

Creating an operation without a set insertion point is an error, but this can still be useful when the current insertion point a builder refers to is being removed.

Definition at line 330 of file Builders.h.

◆ clone() [1/2]

Operation * OpBuilder::clone ( Operation op,
BlockAndValueMapping mapper 
)

◆ clone() [2/2]

Operation * OpBuilder::clone ( Operation op)

Definition at line 521 of file Builders.cpp.

◆ cloneWithoutRegions() [1/3]

Operation* mlir::OpBuilder::cloneWithoutRegions ( Operation op,
BlockAndValueMapping mapper 
)
inline

Creates a deep copy of this operation but keep the operation regions empty.

Operands are remapped using mapper (if present), and mapper is updated to contain the results.

Definition at line 525 of file Builders.h.

References mlir::Operation::cloneWithoutRegions().

Referenced by addResumeFunction(), mlir::scf::insideMutuallyExclusiveBranches(), and wrapInExecuteRegion().

◆ cloneWithoutRegions() [2/3]

Operation* mlir::OpBuilder::cloneWithoutRegions ( Operation op)
inline

Definition at line 528 of file Builders.h.

References mlir::Operation::cloneWithoutRegions().

◆ cloneWithoutRegions() [3/3]

template<typename OpT >
OpT mlir::OpBuilder::cloneWithoutRegions ( OpT  op)
inline

Definition at line 532 of file Builders.h.

◆ create() [1/3]

Operation * OpBuilder::create ( const OperationState state)

Creates an operation given the fields represented as an OperationState.

Create an operation given the fields represented as an OperationState.

Definition at line 418 of file Builders.cpp.

References mlir::Operation::create().

Referenced by addAtomicRMW(), addResumeFunction(), adjustAccessChainForBitwidth(), mlir::affineParallelize(), mlir::UnrankedMemRefDescriptor::alignedPtr(), mlir::AllocationOpLLVMLowering::allocateBufferAutoAlign(), mlir::AllocationOpLLVMLowering::allocateBufferManuallyAlign(), mlir::UnrankedMemRefDescriptor::allocatedPtr(), mlir::bufferization::allocateTensorForShapedValue(), appendX1Dim(), applyPad(), broadcast(), mlir::tensor::bubbleUpPadSlice(), mlir::bufferization::func_ext::CallOpInterface::bufferize(), mlir::bufferization::func_ext::FuncOpInterface::bufferize(), mlir::bufferization::BufferizeTypeConverter::BufferizeTypeConverter(), buildAffineLoopFromConstants(), buildAffineLoopFromValues(), buildAffineLoopNestImpl(), mlir::scf::buildLoopNest(), buildMinMaxReductionSeq(), buildMultiDimReduce(), mlir::scf::buildTerminatedBody(), buildVectorComparison(), buildVectorWrite(), calculateExpandedAccessIndices(), calculateImplicitMap(), canonicalizeMinMaxOp(), castBoolToIntN(), castDataPtr(), castIntNToBool(), mlir::bufferization::castOrReallocMemRefValue(), ceilDivPositive(), checkAndNestUnderRewriteOp(), mlir::tosa::checkHasDynamicBatchDims(), mlir::tosa::clampFloatHelper(), mlir::tosa::clampIntHelper(), cloneOpWithOperandsAndTypes(), mlir::coalesceLoops(), collapseGenericOpIterationDims(), mlir::collapseParallelLoops(), mlir::spirv::Deserializer::collect(), mlir::spirv::combine(), computeMemRefRankReductionMask(), mlir::UnrankedMemRefDescriptor::computeSizes(), mlir::sparse_tensor::constantI1(), mlir::sparse_tensor::constantI16(), mlir::sparse_tensor::constantI32(), mlir::sparse_tensor::constantI8(), mlir::sparse_tensor::constantIndex(), mlir::sparse_tensor::constantOne(), mlir::sparse_tensor::constantZero(), mlir::detail::constructContainerOpForParserIfNecessary(), constructResultVector(), constructTiledLoopNest(), containsReturn(), convertBroadcastOp(), convertCmpPredicate(), convertConstantOp(), convertConstantOpMmaSync(), convertContractOp(), convertContractOpToMmaSync(), convertCtlzOp(), convertElementwiseOp(), convertIntrinsicResult(), convertStructType(), convertTanhOp(), convertToLaunchFuncOp(), convertTransferWriteOp(), convertTransferWriteToStores(), convertYieldOp(), copy(), mlir::ConvertToLLVMPattern::copyUnrankedDescriptors(), mlir::OperationFolder::create(), createAdd(), mlir::createAffineComputationSlice(), mlir::createAffineDataCopyGenerationPass(), mlir::AllocationOpLLVMLowering::createAligned(), mlir::bufferization::BufferizationOptions::createAlloc(), createAsyncDispatchFunction(), mlir::createCanonicalizedAffineForOp(), createConst(), createConstantAllBitsSet(), createConstFromIntAttribute(), mlir::bufferization::BufferizationOptions::createDealloc(), createDecl(), createDepthwiseConvCollapseMap(), mlir::tensor::createDynamicDimValues(), mlir::linalg::GeneralizePadOpPattern::createFillOrGenerateOp(), createFoldedSLE(), createForAllDimensions(), createFPConstant(), createFullPartialLinalgCopy(), createFullPartialVectorTransferRead(), createFullPartialVectorTransferWrite(), mlir::LLVM::createGlobalString(), createGlobalVarForEntryPointArgument(), createGpuLaunch(), createI32Constant(), createI32ConstantOf(), createInBoundsCond(), mlir::ConvertToLLVMPattern::createIndexAttrConstant(), createIndexAttrConstant(), createLessThanCompare(), createLessThanFunc(), createLinalgBodyCalculationForElementwiseOp(), createLinalgBodyCalculationForReduceOp(), createMaySwapFunc(), mlir::bufferization::BufferizationOptions::createMemCpy(), createMul(), createNewDynamicSizes(), createNonLdMatrixLoads(), createOrFold(), mlir::tensor::createPadScalarOp(), createPartitionFunc(), createReassociationMapsForCollapse(), createScalarOrSplatConstant(), createSeparationCondition(), createSortFunc(), createSplitPart(), createSubViewIntersection(), createSwitchOp(), creatLdMatrixCompatibleLoads(), declareReduction(), mlir::ValueDecomposer::decomposeValue(), defaultDeallocBufferCallBack(), deriveStaticUpperBound(), doSequentialDispatch(), doubleBuffer(), dropTrailingX1Dim(), eachHasOnlyOneOfTypes(), elementwiseMatchAndRewriteHelper(), mlir::tensor::ExtractSliceFromCollapseHelper::emitLoopNestBody(), emitScalarImplementation(), encodeKernelName(), endIf(), mlir::sparse_tensor::SparseTensorLoopEmitter::enterCoiterationOverTensorsAtDims(), mlir::sparse_tensor::SparseTensorLoopEmitter::enterLoopOverTensorAtDim(), mlir::extractFixedOuterLoops(), extractLastDimSlice(), extractOne(), extractOpcode(), mlir::StructBuilder::extractPtr(), findAncestorOpInRegion(), foldExtractStridedOpFromInsertChain(), foldInsertAfterExtractSlice(), foldMemRefCast(), foldTransferInBoundsAttribute(), mlir::linalg::fuseElementwiseOps(), mlir::linalg::TileLoopNest::fuseProducer(), mlir::linalg::fuseProducerOfTensor(), fuseWithReshapeByExpansion(), genAddress(), genAffine(), genBuffers(), mlir::linalg::generalizeNamedOp(), generateCollapsedIndexingRegion(), generateCopy(), generateFusedElementwiseOpRegion(), generateGpuBlockIds(), mlir::linalg::generateLibraryCallName(), mlir::linalg::generateParallelLoopNest(), generatePointWiseCopy(), generateShiftedLoop(), generateTileLoopNest(), genFor(), genForInduction(), genIf(), genIndexLoad(), genIndexValue(), genInit(), genInsertionLoad(), genInsertionLoadReduce(), mlir::sparse_tensor::genIsNonzero(), genLoad(), genLocals(), mlir::sparse_tensor::genReshapeDstShape(), genTensorLoad(), genVectorInvariantValue(), genVectorLoad(), genVectorMask(), genVectorReducInit(), genWhile(), genWhileInduction(), getAsValue(), getBlockIt(), mlir::bufferization::getBuffer(), getCleanupLoopLowerBound(), getCollapsedOpOperand(), getConvOutputDim(), getDefaultABIAttrs(), getDimPosition(), getExpandedOutputDimFromInputShape(), getFirstIntValue(), getGenericEffectsImpl(), mlir::arith::getIdentityValue(), getIndexedPtrs(), getIndicesForAccess(), getLibraryCallSymbolRef(), getLocalInvocationDimSize(), getLocationToWriteFullVec(), getMangledSortHelperFunc(), mlir::spirv::getMemorySpaceToStorageClassTarget(), mlir::ConvertToLLVMPattern::getMemRefDescriptorSizes(), mlir::tensor::getMixedSizes(), mlir::ConvertToLLVMPattern::getNumElements(), getOffsetForBitwidth(), mlir::spirv::getOpenCLElementPtr(), getOrCreateStep(), getOrDefineFunction(), getOrInsertBuiltinVariable(), getOrInsertPushConstantVariable(), mlir::scf::getParallelForInductionVarOwner(), getScalarOrVectorI32Constant(), getShapeDimSize(), mlir::ConvertToLLVMPattern::getSizeInBytes(), getSrcVectorElementType(), mlir::ConvertToLLVMPattern::getStridedElementPtr(), getUnorderedCOOFromType(), getUnrollOrder(), mlir::getValueOrCreateCastToIndexLike(), mlir::getValueOrCreateConstantIndexOp(), mlir::vector::getVectorReductionOp(), mlir::spirv::getVulkanElementPtr(), getZero(), mlir::LLVM::detail::handleMultidimensionalVectors(), hasOneBranchOpTo(), hoistAffineIfOp(), mlir::ComplexStructBuilder::imaginary(), inferDynamicDimsForConv(), mlir::sparse_tensor::SparseTensorLoopEmitter::initializeLoopEmit(), inlineIfCase(), inlinePayload(), inlineRegionAndEmitStore(), inlineWhileCase(), insertCasts(), insertLastDimSlice(), insertOne(), mlir::bufferization::insertSliceAnchoredAllocTensorEliminationStep(), insertSliceIntoTensor(), mlir::linalg::insertSlicesBack(), mlir::sparse_tensor::insertYieldOp(), mlir::scf::insideMutuallyExclusiveBranches(), mlir::linalg::interchangeGenericOp(), invertCollapseShapeIndexing(), isAsyncWithOneDependency(), isDefinedByCallTo(), isMemRefNormalizable(), isTrivialSubViewOp(), joinShapes(), mlir::spirv::linearizeIndex(), mlir::LLVMTypeConverter::LLVMTypeConverter(), mlir::LLVM::lookupOrCreateFn(), mlir::loopUnrollByFactor(), mlir::lowerAffineLowerBound(), lowerAsEntryFunction(), lowerEntryPointABIAttr(), mlir::scf::lowerToLoopsUsingSCFForOp(), mlir::makeComposedAffineApply(), mlir::linalg::makeMemRefCopyOp(), mlir::linalg::makeTransposeOp(), matchAndReplaceDepthwiseConv(), SwapExtractSliceOfFill::matchAndRewrite(), mlir::GPUFuncOpLowering::matchAndRewrite(), mlir::GPUIndexIntrinsicOpLowering< Op, XOp, YOp, ZOp >::matchAndRewrite(), mlir::OpToFuncCallLowering< SourceOp >::matchAndRewrite(), InnerOuterDimReductionConversion::matchAndRewrite(), mlir::OpWithOffsetSizesAndStridesConstantArgumentFolder< OpType, ResultTypeFunc, CastOpFunc >::matchAndRewrite(), mlir::GPUPrintfOpToHIPLowering::matchAndRewrite(), TransferReadPermutationLowering::matchAndRewrite(), DecomposeDifferentRankInsertStridedSlice::matchAndRewrite(), mlir::GPUPrintfOpToLLVMCallLowering::matchAndRewrite(), ReduceMultiDimReductionRank::matchAndRewrite(), TransferWritePermutationLowering::matchAndRewrite(), MultiBlockExecuteInliner::matchAndRewrite(), TransferOpReduceRank::matchAndRewrite(), TwoDimMultiReductionToElementWise::matchAndRewrite(), DecomposeNDExtractStridedSlice::matchAndRewrite(), MaterializePadValue::matchAndRewrite(), TwoDimMultiReductionToReduction::matchAndRewrite(), OneDimMultiReductionToTwoDim::matchAndRewrite(), ConvertAccessChain::matchAndRewrite(), ConvertLoad::matchAndRewrite(), AllocaScopeHoister::matchAndRewrite(), ConvertStore::matchAndRewrite(), YieldOpLowering::matchAndRewrite(), AssertOpLowering::matchAndRewrite(), FoldLaunchArguments::matchAndRewrite(), mlir::linalg::PadOpTransformationPattern::matchAndRewrite(), mlir::linalg::GeneralizePadOpPattern::matchAndRewrite(), mlir::linalg::LinalgCopyVTWForwardingPattern::matchAndRewrite(), SelectI1Simplify::matchAndRewrite(), SelectToExtUI::matchAndRewrite(), TransferReadToVectorLoadLowering::matchAndRewrite(), VectorLoadToMemrefLoadLowering::matchAndRewrite(), VectorStoreToMemrefStoreLowering::matchAndRewrite(), CollapseShapeOpMemRefCastFolder::matchAndRewrite(), BubbleDownVectorBitCastForExtract::matchAndRewrite(), BubbleDownBitCastForStridedSliceExtract::matchAndRewrite(), BubbleUpBitCastForStridedSliceInsert::matchAndRewrite(), MaterializeTransferMask< ConcreteOp >::matchAndRewrite(), mlir::linalg::materializeTiledShape(), materializeToTensor(), mfmaConcatIfNeeded(), mfmaOpToIntrinsic(), moveRegionToNewWarpOpAndReplaceReturns(), mlir::memref::multiBuffer(), mlir::normalizeAffineFor(), normalizeLoop(), mlir::normalizeMemRef(), mlir::MemRefDescriptor::offset(), mlir::UnrankedMemRefDescriptor::offset(), ofrToIndexValues(), mlir::LLVM::detail::oneToOneRewrite(), SliceCanonicalizer::operator()(), optionallyTruncateOrExtend(), outlineExecuteOp(), outlineKernelFuncImpl(), mlir::outlineSingleBlockRegion(), padOperandToSmallestStaticBoundingBox(), parseInferType(), permuteVectorOffset(), mlir::arith::populateArithToSPIRVPatterns(), mlir::bufferization::populateDynamicDimSizes(), print(), printLaunchFuncOperands(), processParallelLoop(), produceSliceErrorMsg(), mlir::promoteIfSingleIteration(), mlir::LLVMTypeConverter::promoteOneMemRefDescriptor(), mlir::linalg::promoteSubviewAsNewBuffer(), reduceMatchAndRewriteHelper(), remainsLegalAfterInline(), mlir::replaceAllMemRefUsesWith(), replaceForOpWithNewSignature(), mlir::replaceForOpWithNewYields(), mlir::replaceLoopWithNewYields(), mlir::bufferization::replaceOpWithBufferizedValues(), mlir::bufferization::replaceOpWithNewBufferizedOp(), replaceSCFOutputValue(), replaceUnitExtents(), replaceUsesAndPropagateType(), reshapeLoad(), reshapeLowerToHigher(), reshapeStore(), resolveSourceIndicesCollapseShape(), resolveSourceIndicesExpandShape(), resolveSourceIndicesSubView(), mlir::linalg::DownscaleSizeOneWindowed2DConvolution< Conv2DOp, Conv1DOp >::returningMatchAndRewrite(), mlir::linalg::DownscaleDepthwiseConv2DNhwcHwcOp::returningMatchAndRewrite(), mlir::linalg::rewriteAsPaddedOp(), rewriteOneForeachThreadToGpuThreads(), PadOpVectorizationWithInsertSlicePattern::rewriteUser(), mlir::linalg::LinalgTilingOptions::scalarizeDynamicDims(), mlir::UnrankedMemRefDescriptor::setAlignedPtr(), mlir::UnrankedMemRefDescriptor::setAllocatedPtr(), mlir::ImplicitLocOpBuilder::setLoc(), mlir::MemRefDescriptor::setOffset(), mlir::UnrankedMemRefDescriptor::setOffset(), mlir::StructBuilder::setPtr(), mlir::DataDescriptor::setSize(), mlir::MemRefDescriptor::setSize(), mlir::UnrankedMemRefDescriptor::setSize(), mlir::MemRefDescriptor::setStride(), mlir::UnrankedMemRefDescriptor::setStride(), mlir::scf::SCFTilingOptions::setTileSizes(), mlir::linalg::LinalgTilingOptions::setTileSizes(), shiftValue(), simplifyPassThroughBr(), mlir::MemRefDescriptor::size(), mlir::UnrankedMemRefDescriptor::size(), mlir::UnrankedMemRefDescriptor::sizeBasePtr(), sliceTransferIndices(), sourceMaterializationCallback(), specializeForLoopForUnrolling(), specializeParallelLoopForUnrolling(), mlir::SPIRVTypeConverter::SPIRVTypeConverter(), splatZero(), mlir::vector::splitFullAndPartialTransfer(), mlir::linalg::splitReduction(), mlir::linalg::splitReductionByScaling(), mlir::MemRefDescriptor::stride(), mlir::UnrankedMemRefDescriptor::stride(), mlir::UnrankedMemRefDescriptor::strideBasePtr(), stripmineSink(), mlir::scf::tileParallelLoop(), tileToForeachThreadOpImpl(), mlir::scf::tileUsingSCFForOp(), mlir::sparse_tensor::translateIndicesArray(), GenericPadOpVectorizationPattern::tryVectorizeCopy(), mlir::ComplexStructBuilder::undef(), mlir::MemRefDescriptor::undef(), mlir::DataDescriptor::undef(), mlir::UnrankedMemRefDescriptor::undef(), unpackOperandVector(), updateCalls(), updateExpandedGenericOpRegion(), updateReturnOps(), validateSupportedControlFlow(), vectorizeAsLinalgGeneric(), mlir::linalg::vectorizeCopy(), vectorizeLinalgIndex(), vectorizeOneOp(), mlir::LLVM::detail::vectorOneToOneRewrite(), verifyAllocLikeOp(), verifyConstantType(), verifyGatherOrScatterDims(), verifyJointMatrixMad(), verifyTensorReshapeOp(), verifyVectorMemoryOp(), walkReferenceCountedValues(), wrapExternalFunction(), wrapForExternalCallers(), wrapInExecuteRegion(), and yieldTiledValues().

◆ create() [2/3]

Operation * OpBuilder::create ( Location  loc,
StringAttr  opName,
ValueRange  operands,
TypeRange  types = {},
ArrayRef< NamedAttribute attributes = {},
BlockRange  successors = {},
MutableArrayRef< std::unique_ptr< Region >>  regions = {} 
)

Creates an operation with the given fields.

Definition at line 423 of file Builders.cpp.

◆ create() [3/3]

template<typename OpTy , typename... Args>
OpTy mlir::OpBuilder::create ( Location  location,
Args &&...  args 
)
inline

Create an operation of specific op type at the current insertion point.

Definition at line 457 of file Builders.h.

References mlir::Location::getContext().

◆ createBlock() [1/2]

Block * OpBuilder::createBlock ( Region parent,
Region::iterator  insertPt = {},
TypeRange  argTypes = llvm::None,
ArrayRef< Location locs = llvm::None 
)

◆ createBlock() [2/2]

Block * OpBuilder::createBlock ( Block insertBefore,
TypeRange  argTypes = llvm::None,
ArrayRef< Location locs = llvm::None 
)

Add new block with 'argTypes' arguments and set the insertion point to the end of it.

The block is placed before 'insertBefore'. locs contains the locations of the inserted arguments, and should match the size of argTypes.

The block is placed before 'insertBefore'.

Definition at line 410 of file Builders.cpp.

References mlir::Block::getParent().

◆ createOrFold() [1/3]

template<typename OpTy , typename... Args>
void mlir::OpBuilder::createOrFold ( SmallVectorImpl< Value > &  results,
Location  location,
Args &&...  args 
)
inline

◆ createOrFold() [2/3]

template<typename OpTy , typename... Args>
std::enable_if_t<OpTy::template hasTrait<OpTrait::OneResult>), Value> mlir::OpBuilder::createOrFold ( Location  location,
Args &&...  args 
)
inline

Overload to create or fold a single result operation.

Definition at line 490 of file Builders.h.

◆ createOrFold() [3/3]

template<typename OpTy , typename... Args>
std::enable_if_t<OpTy::template hasTrait<OpTrait::ZeroResults>), OpTy> mlir::OpBuilder::createOrFold ( Location  location,
Args &&...  args 
)
inline

Overload to create or fold a zero result operation.

Definition at line 499 of file Builders.h.

◆ getBlock()

Block* mlir::OpBuilder::getBlock ( ) const
inline

Returns the current block of the builder.

Definition at line 399 of file Builders.h.

References mlir::RegisteredOperationName::lookup().

Referenced by convertStructType(), and extractOpcode().

◆ getInsertionBlock()

Block* mlir::OpBuilder::getInsertionBlock ( ) const
inline

◆ getInsertionPoint()

Block::iterator mlir::OpBuilder::getInsertionPoint ( ) const
inline

◆ getListener()

Listener* mlir::OpBuilder::getListener ( ) const
inline

Returns the current listener of this builder, or nullptr if this builder doesn't have a listener.

Definition at line 271 of file Builders.h.

Referenced by createAsyncDispatchFunction(), mlir::LLVM::createGlobalString(), createOrFold(), createParallelComputeFunction(), getOrInsertPushConstantVariable(), materializeConstants(), and outlineExecuteOp().

◆ insert()

Operation * OpBuilder::insert ( Operation op)

Insert the given operation at the current insertion point and return it.

Definition at line 382 of file Builders.cpp.

Referenced by mlir::spirv::combine(), mlir::OperationFolder::create(), mlir::impl::ensureRegionTerminator(), and mlir::ConversionPattern::matchAndRewrite().

◆ restoreInsertionPoint()

void mlir::OpBuilder::restoreInsertionPoint ( InsertPoint  ip)
inline

Restore the insert point to a previously saved point.

Definition at line 341 of file Builders.h.

References mlir::OpBuilder::InsertPoint::getBlock(), mlir::OpBuilder::InsertPoint::getPoint(), and mlir::OpBuilder::InsertPoint::isSet().

Referenced by isDefinedByCallTo().

◆ saveInsertionPoint()

InsertPoint mlir::OpBuilder::saveInsertionPoint ( ) const
inline

Return a saved insertion point.

Definition at line 336 of file Builders.h.

Referenced by isDefinedByCallTo(), and tileToForeachThreadOpImpl().

◆ setInsertionPoint() [1/2]

void mlir::OpBuilder::setInsertionPoint ( Block block,
Block::iterator  insertPoint 
)
inline

Set the insertion point to the specified location.

Definition at line 349 of file Builders.h.

Referenced by mlir::bufferization::allocateTensorForShapedValue(), mlir::bufferization::func_ext::FuncOpInterface::bufferize(), mlir::scf::buildLoopNest(), canonicalizeMinMaxOp(), cloneAndFuseFirstUse(), collapseGenericOpIterationDims(), convertStructType(), createDecl(), createGlobalVarForEntryPointArgument(), declareReduction(), eachHasOnlyOneOfTypes(), mlir::bufferization::eliminateAllocTensors(), encodeKernelName(), foldInsertAfterExtractSlice(), mlir::linalg::fuseProducerOfBuffer(), mlir::linalg::fuseProducerOfTensor(), fuseWithReshapeByExpansion(), generateGpuBlockIds(), mlir::linalg::generateLibraryCallName(), generateTileLoopNest(), getBlockIt(), getGenericEffectsImpl(), getGenericOpLoopRange(), getLibraryCallSymbolRef(), getMangledSortHelperFunc(), mlir::OperationFolder::getOrCreateConstant(), mlir::scf::getParallelForInductionVarOwner(), inlineIfCase(), inlinePayload(), inlineWhileCase(), mlir::scf::insideMutuallyExclusiveBranches(), mlir::linalg::interchangeGenericOp(), legalizeUnresolvedMaterialization(), mlir::loopUnrollByFactor(), mlir::lowerAffineLowerBound(), mlir::scf::lowerToLoopsUsingSCFForOp(), mlir::transform::gpu::mapNestedForeachToThreadsImpl(), mlir::PatternApplicator::matchAndRewrite(), MultiBlockExecuteInliner::matchAndRewrite(), mlir::ConversionPattern::matchAndRewrite(), AllocaScopeHoister::matchAndRewrite(), moveRegionToNewWarpOpAndReplaceReturns(), mlir::memref::multiBuffer(), mlir::outlineSingleBlockRegion(), peelForLoop(), mlir::bufferization::populateDynamicDimSizes(), processParallelLoop(), replaceForOpWithNewSignature(), mlir::replaceForOpWithNewYields(), mlir::replaceLoopWithNewYields(), replaceSCFOutputValue(), replaceUnitDimIndexOps(), replaceUsesAndPropagateType(), rewrite(), PadOpVectorizationWithTransferWritePattern::rewriteUser(), PadOpVectorizationWithInsertSlicePattern::rewriteUser(), mlir::vector::splitFullAndPartialTransfer(), mlir::linalg::splitReduction(), mlir::linalg::splitReductionByScaling(), tileAndFuseFirstExtractUse(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), mlir::scf::tileConsumerAndFuseProducerGreedilyUsingSCFForOp(), tileLinalgOpImpl(), tilePadOp(), mlir::transform::tileToForeachThreadOpImpl(), tileToForeachThreadOpImpl(), mlir::scf::tileUsingSCFForOp(), and wrapInExecuteRegion().

◆ setInsertionPoint() [2/2]

void mlir::OpBuilder::setInsertionPoint ( Operation op)
inline

Sets the insertion point to the specified operation, which will cause subsequent insertions to go right before it.

Definition at line 357 of file Builders.h.

References mlir::Operation::getBlock().

◆ setInsertionPointAfter()

void mlir::OpBuilder::setInsertionPointAfter ( Operation op)
inline

◆ setInsertionPointAfterValue()

void mlir::OpBuilder::setInsertionPointAfterValue ( Value  val)
inline

Sets the insertion point to the node after the specified value.

If value has a defining operation, sets the insertion point to the node after such defining operation. This will cause subsequent insertions to go right after it. Otherwise, value is a BlockArgument. Sets the insertion point to the start of its block.

Definition at line 372 of file Builders.h.

References mlir::Value::cast(), mlir::Value::getDefiningOp(), and setInsertionPointAfter().

Referenced by legalizeUnresolvedMaterialization().

◆ setInsertionPointToEnd()

void mlir::OpBuilder::setInsertionPointToEnd ( Block block)
inline

◆ setInsertionPointToStart()

void mlir::OpBuilder::setInsertionPointToStart ( Block block)
inline

Sets the insertion point to the start of the specified block.

Definition at line 382 of file Builders.h.

References mlir::Block::begin().

Referenced by mlir::bufferization::func_ext::FuncOpInterface::bufferize(), buildAffineLoopNestImpl(), mlir::scf::buildLoopNest(), castBoolToIntN(), mlir::async::cloneConstantsIntoTheRegion(), mlir::coalesceLoops(), mlir::spirv::combine(), convertCtlzOp(), convertStructType(), createLessThanCompare(), createLessThanFunc(), createMaySwapFunc(), createPartitionFunc(), createReassociationMapsForCollapse(), createSortFunc(), declareReduction(), eachHasOnlyOneOfTypes(), encodeKernelName(), endIf(), mlir::sparse_tensor::SparseTensorLoopEmitter::enterLoopOverTensorAtDim(), fillStructuredOpRegion(), mlir::AffineDmaWaitOp::fold(), fuseIfLegal(), generateCollapsedIndexingRegion(), generateFusedElementwiseOpRegion(), genFor(), genIf(), genWhile(), getOrDefineFunction(), getOrInsertBuiltinVariable(), getUnorderedCOOFromType(), mlir::scf::insideMutuallyExclusiveBranches(), lowerEntryPointABIAttr(), mlir::GPUFuncOpLowering::matchAndRewrite(), mlir::GPUPrintfOpToHIPLowering::matchAndRewrite(), mlir::GPUPrintfOpToLLVMCallLowering::matchAndRewrite(), FoldLaunchArguments::matchAndRewrite(), mlir::normalizeAffineFor(), outlineExecuteOp(), mlir::outlineSingleBlockRegion(), processParallelLoop(), setInsertionPointAfter(), mlir::scf::SCFTilingOptions::setTileSizes(), mlir::linalg::LinalgTilingOptions::setTileSizes(), mlir::vector::splitFullAndPartialTransfer(), mlir::scf::tileParallelLoop(), tileToForeachThreadOpImpl(), wrapExternalFunction(), wrapForExternalCallers(), and wrapInExecuteRegion().

◆ setListener()

void mlir::OpBuilder::setListener ( Listener newListener)
inline

Sets the listener of this builder to the one provided.

Definition at line 267 of file Builders.h.

Referenced by createOrFold(), and materializeConstants().

◆ tryFold()

LogicalResult OpBuilder::tryFold ( Operation op,
SmallVectorImpl< Value > &  results 
)

Attempts to fold the given operation and places new results within 'results'.

Returns success if the operation was folded, failure otherwise. Note: This function does not erase the operation on a successful fold.

Definition at line 436 of file Builders.cpp.

References mlir::Builder::context, mlir::Operation::erase(), mlir::failed(), mlir::failure(), mlir::Operation::fold(), mlir::Operation::getDialect(), mlir::Operation::getLoc(), mlir::Operation::getNumOperands(), mlir::Operation::getOperand(), mlir::Operation::getResults(), mlir::ResultRange::getTypes(), mlir::m_Constant(), mlir::matchPattern(), mlir::Dialect::materializeConstant(), mlir::success(), and value.

Referenced by mlir::ConversionPattern::matchAndRewrite().


The documentation for this class was generated from the following files: