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

This class helps build Operations. More...

#include "mlir/IR/Builders.h"

+ Inheritance 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...
 
struct  ListenerBase
 Base class for listeners. 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=std::nullopt, ArrayRef< Location > locs=std::nullopt)
 Add new block with 'argTypes' arguments and set the insertion point to the end of it. More...
 
BlockcreateBlock (Block *insertBefore, TypeRange argTypes=std::nullopt, ArrayRef< Location > locs=std::nullopt)
 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, IRMapping &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, IRMapping &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)
 
void cloneRegionBefore (Region &region, Region &parent, Region::iterator before, IRMapping &mapping)
 Clone the blocks that belong to "region" before the given position in another region "parent". More...
 
void cloneRegionBefore (Region &region, Region &parent, Region::iterator before)
 
void cloneRegionBefore (Region &region, Block *before)
 
- 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 getFloat8E4M3FNType ()
 
FloatType getFloat8E5M2FNUZType ()
 
FloatType getFloat8E4M3FNUZType ()
 
FloatType getFloat8E4M3B11FNUZType ()
 
FloatType getBF16Type ()
 
FloatType getF16Type ()
 
FloatType getTF32Type ()
 
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)
 
TypedAttr getZeroAttr (Type type)
 
TypedAttr getOneAttr (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)
 
DenseFPElementsAttr getF32VectorAttr (ArrayRef< float > values)
 
DenseFPElementsAttr getF64VectorAttr (ArrayRef< double > 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...
 

Protected Attributes

Listenerlistener
 The optional listener for events of this builder. More...
 
- 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 209 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 215 of file Builders.h.

Referenced by atBlockBegin(), atBlockEnd(), and atBlockTerminator().

◆ 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 219 of file Builders.h.

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

◆ OpBuilder() [3/5]

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

Definition at line 224 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 229 of file Builders.h.

◆ OpBuilder() [5/5]

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

Definition at line 234 of file Builders.h.

References setInsertionPoint().

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 242 of file Builders.h.

References mlir::Block::begin(), listener, and OpBuilder().

Referenced by mlir::collapseParallelLoops(), createSingleEntryBlock(), createSingleExitingLatch(), getOrInsertPushConstantVariable(), normalizeLoop(), mlir::transformCFGToSCF(), and transformCyclesToSCFLoops().

◆ 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 248 of file Builders.h.

References mlir::Block::end(), listener, and OpBuilder().

Referenced by mlir::FunctionCallBuilder::create(), and transformToStructuredCFBranches().

◆ 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 254 of file Builders.h.

References mlir::Block::getTerminator(), listener, and OpBuilder().

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

◆ 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 381 of file Builders.h.

Referenced by mlir::bufferization::buildDeallocationLibraryFunction(), and restoreInsertionPoint().

◆ clone() [1/2]

Operation * OpBuilder::clone ( Operation op)

Definition at line 575 of file Builders.cpp.

◆ clone() [2/2]

Operation * OpBuilder::clone ( Operation op,
IRMapping 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).

Replaces references to cloned sub-operations to the corresponding operation that is copied, and adds those mappings to the map.

Definition at line 553 of file Builders.cpp.

Referenced by mlir::sparse_tensor::Merger::buildExp(), cloneAndFuseFirstUse(), createFullPartialVectorTransferRead(), createFullPartialVectorTransferWrite(), mlir::affine::fuseLoops(), generateCleanupLoopForUnroll(), hoistAffineIfOp(), mlir::affine::insertBackwardComputationSlice(), mlir::loopUnrollByFactor(), mlir::affine::loopUnrollJamByFactor(), mlir::makeRegionIsolatedFromAbove(), CanonicalizeContractAdd< AddOpType >::matchAndRewrite(), mlir::outlineSingleBlockRegion(), peelForLoop(), mlir::vector::splitFullAndPartialTransfer(), and tileAndFuseFirstExtractUseThroughContainingOpBlockArgument().

◆ cloneRegionBefore() [1/3]

void OpBuilder::cloneRegionBefore ( Region region,
Block before 
)

Definition at line 606 of file Builders.cpp.

References cloneRegionBefore(), and mlir::Block::getParent().

◆ cloneRegionBefore() [2/3]

void OpBuilder::cloneRegionBefore ( Region region,
Region parent,
Region::iterator  before 
)

Definition at line 600 of file Builders.cpp.

References cloneRegionBefore().

◆ cloneRegionBefore() [3/3]

void OpBuilder::cloneRegionBefore ( Region region,
Region parent,
Region::iterator  before,
IRMapping mapping 
)

Clone the blocks that belong to "region" before the given position in another region "parent".

The two regions must be different. The caller is responsible for creating or updating the operation transferring flow of control to the region and passing it the correct block arguments.

Definition at line 580 of file Builders.cpp.

References mlir::Region::cloneInto(), mlir::Region::front(), listener, mlir::IRMapping::lookup(), mlir::OpBuilder::Listener::notifyBlockInserted(), notifyBlockInsertions(), mlir::OpBuilder::Listener::notifyOperationInserted(), and mlir::PreOrder.

Referenced by cloneRegionBefore(), convertOmpParallel(), fuseWithReshapeByExpansion(), inlineIfCase(), and inlineWhileCase().

◆ cloneWithoutRegions() [1/3]

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

Definition at line 581 of file Builders.h.

◆ cloneWithoutRegions() [2/3]

Operation* mlir::OpBuilder::cloneWithoutRegions ( Operation op,
IRMapping 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 578 of file Builders.h.

◆ cloneWithoutRegions() [3/3]

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

Definition at line 585 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 464 of file Builders.cpp.

Referenced by mlir::ArithBuilder::_and(), mlir::ArithBuilder::add(), addAtomicRMW(), addBodyWithPayloadOp(), addInitOperandsToLoopNest(), addShardOp(), mlir::affine::affineParallelize(), mlir::UnrankedMemRefDescriptor::alignedPtr(), mlir::sparse_tensor::allocaBuffer(), mlir::UnrankedMemRefDescriptor::allocatedPtr(), allocateSubviewGPUMemoryInAddressSpace(), mlir::bufferization::allocateTensorForShapedValue(), mlir::sparse_tensor::allocDenseTensor(), allocSchemeForRank(), mlir::transform::gpu::alterGpuLaunch(), appendX1Dim(), applyPad(), bitAndAddrspaceCast(), broadcast(), broadcastDynamicDimension(), mlir::tensor::bubbleUpPadSlice(), mlir::bufferization::bufferizeBlockSignature(), mlir::linalg::bufferizeToAllocation(), mlir::bufferization::BufferizeTypeConverter::BufferizeTypeConverter(), mlir::MemRefDescriptor::bufferPtr(), mlir::NVVM::PtxBuilder::build(), buildAffineLoopFromConstants(), buildAffineLoopFromValues(), buildAffineLoopNestImpl(), HopperBuilder::buildAndInitBarrierInSharedMemory(), buildArithValue(), HopperBuilder::buildBarrierArriveTx(), buildBoolValue(), mlir::bufferization::buildDeallocationLibraryFunction(), buildDivOp(), mlir::sparse_tensor::Merger::buildExp(), HopperBuilder::buildGlobalMemRefDescriptor(), buildIdentityRegion(), mlir::tensor::buildIndependentOp(), buildLinearId(), mlir::scf::buildLoopNest(), buildMinMaxReductionSeq(), MmaSyncBuilder::buildMmaSync(), buildMultiDimReduce(), buildNumReadElements(), buildPackingLoopNestImpl(), HopperBuilder::buildPredicateLoadsOnThread0(), buildSubAndExpOp(), mlir::emitc::buildTerminatedBody(), mlir::scf::buildTerminatedBody(), mlir::vector::buildTerminatedBody(), HopperBuilder::buildTmaAsyncLoad(), HopperBuilder::buildTryWaitParity(), castAllocFuncResult(), mlir::vector::castAwayContractionLeadingOneDim(), castBoolToIntN(), castF32To(), castIntNToBool(), mlir::bufferization::castOrReallocMemRefValue(), castToCompatibleMemRefType(), castToF32(), castToSourceType(), ceilDivPositive(), checkAndNestUnderRewriteOp(), mlir::tosa::clampFloatHelper(), clampInput(), mlir::tosa::clampIntHelper(), cloneToCollapsedOp< GenericOp >(), mlir::affine::coalesceLoops(), mlir::coalesceLoops(), collapseInnerDims(), mlir::collapseParallelLoops(), collapseValue(), mlir::spirv::combine(), common3DIdBuilderFn(), mlir::UnrankedMemRefDescriptor::computeSizes(), computeTargetSize(), concatSizesFromInputs(), mlir::sparse_tensor::constantI1(), mlir::sparse_tensor::constantI16(), mlir::sparse_tensor::constantI32(), mlir::sparse_tensor::constantI64(), mlir::sparse_tensor::constantI8(), mlir::sparse_tensor::constantIndex(), mlir::sparse_tensor::constantOne(), mlir::sparse_tensor::constantZero(), constructTiledLoopNest(), mlir::convertFuncOpToLLVMFuncOp(), convertIntrinsicResult(), mlir::LLVM::ModuleImport::convertLinkerOptionsMetadata(), convertToLaunchFuncOp(), copy(), mlir::linalg::copyToGPUPrivateMemory(), mlir::linalg::copyToWorkgroupMemory(), mlir::ConvertToLLVMPattern::copyUnrankedDescriptors(), mlir::FunctionCallBuilder::create(), createAdd(), mlir::linalg::createAdd(), mlir::AllocationOpLLVMLowering::createAligned(), mlir::bufferization::BufferizationOptions::createAlloc(), createAllocation(), createAllocFields(), createAsyncDispatchFunction(), createBinarySearchFunc(), mlir::affine::createCanonicalizedAffineForOp(), mlir::ControlFlowToSCFTransformation::createCFGSwitchOp(), createChoosePivot(), createCompareThenSwap(), createConst(), createConstantAllBitsSet(), createCtlzFunc(), createDecl(), mlir::tensor::createDynamicDimValues(), createEqCompare(), mlir::linalg::GeneralizePadOpPattern::createFillOrGenerateOp(), createFloatConst(), createFor(), createForAllDimensions(), createFPConstant(), createFullPartialLinalgCopy(), createFullPartialVectorTransferRead(), createFullPartialVectorTransferWrite(), mlir::sparse_tensor::createFuncCall(), mlir::LLVM::createGlobalString(), createGlobalVarForEntryPointArgument(), mlir::transform::gpu::createGpuLaunch(), createGroupReduceOpImpl(), createHeapSortFunc(), createI1Constant(), createI32Constant(), createI32ConstantOf(), createInBoundsCond(), createIndex(), mlir::ConvertToLLVMPattern::createIndexAttrConstant(), createIndexAttrConstant(), createInlinedCompareImplementation(), createInserts(), createIntConst(), createLessThanCompare(), mlir::arm_sme::createLoopOverTileSlices(), mlir::bufferization::BufferizationOptions::createMemCpy(), createMemcpy(), createMul(), mlir::linalg::createMul(), createNewAliasScopesFromNoAliasParameter(), createNewDynamicSizes(), mlir::sparse_tensor::createOrFoldSliceOffsetOp(), mlir::sparse_tensor::createOrFoldSliceStrideOp(), mlir::tensor::createPadHighOp(), createPartitionFunc(), mlir::LLVM::createPrintStrCall(), createPrivateMemRef(), mlir::arith::createProduct(), createQuickSort(), createQuickSortFunc(), createReadOrMaskedRead(), mlir::createScalarOrSplatConstant(), createScanLoop(), createSeparationCondition(), createShiftDownFunc(), createSortStableFunc(), mlir::ControlFlowToSCFTransformation::createStructuredBranchRegionOp(), mlir::ControlFlowToSCFTransformation::createStructuredBranchRegionTerminatorOp(), mlir::ControlFlowToSCFTransformation::createStructuredDoWhileLoopOp(), createSubApply(), createSubTwoDividedByTwo(), createSubViewIntersection(), createSwap(), createSwitchOp(), mlir::ControlFlowToSCFTransformation::createUnreachableTerminator(), createWriteOrMaskedWrite(), mlir::sparse_tensor::deallocDenseTensor(), defaultDeallocBufferCallBack(), mlir::sparse_tensor::SparseIterator::deref(), doubleBuffer(), mlir::bufferization::dropEquivalentBufferResults(), dropTrailingX1Dim(), mlir::linalg::dropUnitDims(), dumpIndexMemRef(), emitElementwiseComputation(), mlir::tensor::ExtractSliceFromCollapseHelper::emitLoopNestBody(), emitScalarImplementation(), endIf(), ensureDistinctSuccessors(), mlir::tosa::EqualizeRanks(), expandRank(), expandValue(), extendMaskRank(), extendVectorRank(), extractConvFilterSlices(), extractConvInputSlices(), extractConvResultSlices(), mlir::extractFixedOuterLoops(), extractLastDimSlice(), extractOne(), mlir::StructBuilder::extractPtr(), finalizeWhileOp(), forEachIJPairInXs(), mlir::sparse_tensor::SparseIterator::forward(), mlir::sparse_tensor::SparseIterator::forwardIf(), mlir::linalg::fuseElementwiseOps(), fuseIfLegal(), mlir::fuseIndependentSiblingForallLoops(), mlir::linalg::fuseProducerOfTensor(), fuseWithReshapeByExpansion(), mlir::sparse_tensor::genAlloca(), mlir::sparse_tensor::genAllocaScalar(), mlir::sparse_tensor::FuncCallOrInlineGenerator< SubClass >::genCallOrInline(), mlir::sparse_tensor::genCast(), genCompressed(), genConstFloat32From(), genConstInt32From(), genDemap(), genEndInsert(), mlir::linalg::generalizeNamedOp(), generateCollapsedIndexingRegion(), generateCopy(), generateFusedElementwiseOpRegion(), generateLoopNestUsingForallOp(), generateLoopNestUsingForOp(), mlir::linalg::generateParallelLoopNest(), generatePointWiseCopy(), generateShiftedLoop(), genIf(), mlir::sparse_tensor::genIndexLoad(), mlir::sparse_tensor::SparseIterator::genInit(), mlir::sparse_tensor::genIsNonzero(), genLoad(), mlir::sparse_tensor::genMapBuffers(), mlir::sparse_tensor::SparseIterator::genNotEnd(), mlir::sparse_tensor::genReader(), genRemap(), mlir::sparse_tensor::genReshapeDstShape(), mlir::sparse_tensor::genScalarToTensor(), genSliceToSize(), genStore(), mlir::sparse_tensor::genToMemref(), mlir::sparse_tensor::genTuple(), genWhenInBound(), getAsLLVMValue(), mlir::vector::getAsValues(), mlir::bufferization::getBuffer(), mlir::ControlFlowToSCFTransformation::getCFGSwitchValue(), getCleanupLoopLowerBound(), getCompressedMaskOp(), getConvOutputDim(), mlir::sparse_tensor::SparseTensorDescriptor::getCrdMemRefOrView(), getExpandedOutputDimFromInputShape(), getFlatMemref(), getFlatOffsetAndStrides(), mlir::sparse_tensor::getFunc(), getIndexedPtrs(), getIndicesForAccess(), mlir::sparse_tensor::SparseTensorSpecifier::getInitValue(), getLaneId(), getLinearizedSrcIndices(), getLocationToWriteFullVec(), getMangledSortHelperFunc(), mlir::ConvertToLLVMPattern::getMemRefDescriptorSizes(), mlir::bufferization::DeallocationState::getMemrefsAndConditionsToDeallocate(), mlir::bufferization::DeallocationState::getMemrefWithUniqueOwnership(), mlir::ConvertToLLVMPattern::getNumElements(), getOffsetForBitwidth(), mlir::spirv::getOpenCLElementPtr(), mlir::tensor::getOrCreateDestination(), getOrCreateStep(), getOrDefineFunction(), getOrInsertBuiltinVariable(), getOrInsertPushConstantVariable(), getScalarOrVectorConstInt(), getScalarOrVectorI32Constant(), mlir::ConvertToLLVMPattern::getSizeInBytes(), getSlice(), getSubByteWriteMask(), getTensorDim(), mlir::ControlFlowToSCFTransformation::getUndefValue(), mlir::getValueOrCreateCastToIndexLike(), mlir::getValueOrCreateConstantIndexOp(), mlir::spirv::getVulkanElementPtr(), getZero(), handleByValArgumentInit(), handleInlinedAllocas(), mlir::mesh::handlePartialAxesDuringResharding(), hoistAffineIfOp(), mlir::linalg::hoistPaddingOnTensors(), inferDynamicDimsForConv(), mlir::sparse_tensor::LoopEmitter::initializeLoopEmit(), inlineIfCase(), inlineWhileCase(), insertConvResultSlices(), insertLastDimSlice(), insertOne(), mlir::NVVM::PtxBuilder::insertValue(), mlir::sparse_tensor::insertYieldOp(), invertCollapseShapeIndexing(), linalgBroadcastAndMaybeExtSI(), linalgIntBroadcastExtSIAdd(), mlir::spirv::linearizeIndex(), mlir::LLVMTypeConverter::LLVMTypeConverter(), mlir::sparse_tensor::loadAll(), mlir::sparse_tensor::SparseIterator::locate(), mlir::LLVM::lookupOrCreateFn(), mlir::loopUnrollByFactor(), mlir::affine::loopUnrollJamByFactor(), lowerAsEntryFunction(), lowerEntryPointABIAttr(), mlir::linalg::lowerPack(), mlir::linalg::lowerUnPack(), makeCanonicalAffineApplies(), mlir::affine::makeComposedAffineApply(), makeComposedMinMax(), mlir::linalg::makeMemRefCopyOp(), mlir::sparse_tensor::makeSparseTensorLevel(), mlir::linalg::makeTransposeOp(), mlir::transform::gpu::mapForallToBlocksImpl(), mlir::affine::mapLoopToProcessorIds(), mlir::transform::gpu::mapNestedForallToThreadsImpl(), mlir::transform::gpu::mapOneForallToThreadsImpl(), matchAndReplaceDepthwiseConv(), ConvertTypesInSCFForOp::matchAndRewrite(), mlir::LLVM::SplitGEP::matchAndRewrite(), mlir::GPUFuncOpLowering::matchAndRewrite(), mlir::GPUPrintfOpToHIPLowering::matchAndRewrite(), mlir::GPUPrintfOpToLLVMCallLowering::matchAndRewrite(), mlir::GPUPrintfOpToVPrintfLowering::matchAndRewrite(), ConvertAccessChain::matchAndRewrite(), ConvertLoad::matchAndRewrite(), ConvertStore::matchAndRewrite(), mlir::LLVM::BitcastStores::matchAndRewrite(), SwapExtractSliceOfFill::matchAndRewrite(), mlir::linalg::GeneralizeOuterUnitDimsPackOpPattern::matchAndRewrite(), mlir::linalg::GeneralizePadOpPattern::matchAndRewrite(), mlir::linalg::GeneralizeOuterUnitDimsUnPackOpPattern::matchAndRewrite(), ConcatSliceOptimization::matchAndRewrite(), ConsolidateTransposeOptimization::matchAndRewrite(), mlir::linalg::LinalgCopyVTRForwardingPattern::matchAndRewrite(), mlir::linalg::LinalgCopyVTWForwardingPattern::matchAndRewrite(), mlir::affine::materializeComputedBound(), mlir::linalg::materializeTiledShape(), materializeToTensor(), mfmaConcatIfNeeded(), modifyFuncOpToUseBarePtrCallingConv(), movePaddingToFillOrGenericOp(), moveRegionToNewWarpOpAndReplaceReturns(), mlir::ArithBuilder::mul(), mlir::memref::multiBuffer(), normalizeLoop(), mlir::affine::normalizeMemRef(), mlir::MemRefDescriptor::offset(), mlir::UnrankedMemRefDescriptor::offset(), mlir::UnrankedMemRefDescriptor::offsetBasePtr(), ofrToIndexValues(), optionallyTruncateOrExtend(), outlineKernelFuncImpl(), mlir::outlineSingleBlockRegion(), mlir::linalg::pack(), padOperandToSmallestStaticBoundingBox(), padThroughLoopIterArg(), permuteVectorOffset(), mlir::bufferization::populateDynamicDimSizes(), mlir::arith::populateEmulateUnsupportedFloatsConversions(), mlir::math::populateLegalizeToF32TypeConverter(), mlir::vector::populateVectorLinearizeTypeConversionsAndLegality(), mlir::LLVM::ModuleImport::processFunction(), processParallelLoop(), mlir::scf::promote(), mlir::bufferization::promoteBufferResultsToOutParams(), mlir::affine::promoteIfSingleIteration(), mlir::LLVMTypeConverter::promoteOneMemRefDescriptor(), mlir::linalg::promoteSubviewAsNewBuffer(), rankReducingSubviewDroppingUnitDims(), reduce(), reifyOrComputeDynamicSizes(), reifyValueBound(), remapValueRange(), replaceAndPropagateMemRefType(), replaceByPackingResult(), replaceConstantUsesOf(), replaceForAllWithNewSignature(), replaceForOpWithNewSignature(), replaceUsesAndPropagateType(), mlir::sparse_tensor::reshapeCvs(), reshapeLoad(), reshapeStore(), mlir::linalg::DownscaleConv2DOp::returningMatchAndRewrite(), mlir::linalg::DownscaleDepthwiseConv2DNhwcHwcOp::returningMatchAndRewrite(), mlir::linalg::rewriteAsPaddedOp(), rewriteI4ToI8SignedExt(), rewriteI8ToI4Trunc(), mlir::linalg::rewriteInDestinationPassingStyle(), mlir::linalg::rewriteInIm2Col(), rewriteOneForallCommonImpl(), PadOpVectorizationWithInsertSlicePattern::rewriteUser(), mlir::ArithBuilder::select(), mlir::UnrankedMemRefDescriptor::setAlignedPtr(), mlir::UnrankedMemRefDescriptor::setAllocatedPtr(), mlir::UnrankedMemRefDescriptor::setOffset(), mlir::MemRefDescriptor::setOffset(), mlir::StructBuilder::setPtr(), mlir::UnrankedMemRefDescriptor::setSize(), mlir::MemRefDescriptor::setSize(), mlir::UnrankedMemRefDescriptor::setStride(), mlir::MemRefDescriptor::setStride(), mlir::ArithBuilder::sgt(), shiftValue(), mlir::UnrankedMemRefDescriptor::size(), mlir::MemRefDescriptor::size(), mlir::UnrankedMemRefDescriptor::sizeBasePtr(), sizesForTensor(), sliceTransferIndices(), mlir::ArithBuilder::slt(), sourceMaterializationCallback(), mlir::SPIRVTypeConverter::SPIRVTypeConverter(), mlir::vector::splitFullAndPartialTransfer(), splitIntegerStore(), splitVectorStore(), mlir::sparse_tensor::storeAll(), mlir::UnrankedMemRefDescriptor::stride(), mlir::MemRefDescriptor::stride(), mlir::UnrankedMemRefDescriptor::strideBasePtr(), stripmineSink(), mlir::ArithBuilder::sub(), transposeOneLinalgOperandAndReplace(), transposeToShuffle1D(), GenericPadOpVectorizationPattern::tryVectorizeCopy(), mlir::MemRefDescriptor::undef(), mlir::UnrankedMemRefDescriptor::undef(), mlir::ComplexStructBuilder::undef(), mlir::linalg::unrollIndex(), updateExpandedGenericOpRegion(), vectorizeAsTensorPackOp(), vectorizeAsTensorUnpackOp(), mlir::linalg::vectorizeCopy(), wmmaPushInputOperand(), wmmaPushOutputOperand(), wrapExternalFunction(), wrapForExternalCallers(), and mlir::scf::yieldReplacementForFusedProducer().

◆ 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 469 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 508 of file Builders.h.

◆ createBlock() [1/2]

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

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 456 of file Builders.cpp.

References createBlock(), and mlir::Block::getParent().

◆ createBlock() [2/2]

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

◆ createOrFold() [1/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 543 of file Builders.h.

◆ createOrFold() [2/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 552 of file Builders.h.

◆ createOrFold() [3/3]

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

◆ getBlock()

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

Returns the current block of the builder.

Definition at line 450 of file Builders.h.

Referenced by mlir::sparse_tensor::Merger::buildExp(), mlir::FunctionCallBuilder::create(), and mlir::sparse_tensor::createFuncCall().

◆ 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 322 of file Builders.h.

References listener.

Referenced by createAsyncDispatchFunction(), mlir::LLVM::createGlobalString(), getOrInsertPushConstantVariable(), mlir::affine::makeComposedFoldedAffineApply(), and makeComposedFoldedMinMax().

◆ insert()

Operation * OpBuilder::insert ( Operation op)

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

Definition at line 428 of file Builders.cpp.

Referenced by mlir::impl::ensureRegionTerminator().

◆ restoreInsertionPoint()

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

◆ saveInsertionPoint()

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

Return a saved insertion point.

Definition at line 387 of file Builders.h.

References getInsertionBlock(), and getInsertionPoint().

Referenced by mlir::LLVM::createPrintStrCall().

◆ setInsertionPoint() [1/2]

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

Set the insertion point to the specified location.

Definition at line 400 of file Builders.h.

Referenced by addInitOperandsToLoopNest(), addShardOp(), allocateSubviewGPUMemoryInAddressSpace(), mlir::memref::allocToAlloca(), applyTilingToAll(), mlir::linalg::bufferizeToAllocation(), HopperBuilder::buildGlobalMemRefDescriptor(), mlir::tensor::buildIndependentOp(), buildPackingLoopNestImpl(), cloneAndFuseFirstUse(), createDecl(), createGlobalVarForEntryPointArgument(), declareReduction(), mlir::bufferization::dropEquivalentBufferResults(), mlir::sparse_tensor::LoopEmitter::exitCurrentLoop(), fuseIfLegal(), mlir::linalg::fuseProducerOfTensor(), fuseWithReshapeByExpansion(), mlir::sparse_tensor::FuncCallOrInlineGenerator< SubClass >::genCallOrInline(), generateLoopNestUsingForallOp(), getMangledSortHelperFunc(), mlir::OperationFolder::getOrCreateConstant(), mlir::tensor::getOrCreateDestination(), handleInlinedAllocas(), VectorizationState::initState(), inlineIfCase(), inlineWhileCase(), mlir::linalg::interchangeGenericOp(), mlir::loopUnrollByFactor(), mlir::linalg::lowerPack(), mlir::linalg::lowerUnPack(), mlir::affine::makeComposedFoldedAffineApply(), makeComposedFoldedMinMax(), InsertSliceOfInsertSliceFolder< OpTy >::matchAndRewrite(), moveRegionToNewWarpOpAndReplaceReturns(), mlir::memref::multiBuffer(), OpBuilder(), mlir::nvgpu::optimizeSharedMemoryReadsAndWrites(), mlir::amdgpu::optimizeSharedMemoryReadsAndWrites(), mlir::outlineSingleBlockRegion(), mlir::linalg::packTranspose(), peelForLoop(), mlir::LLVM::ModuleImport::processFunction(), processParallelLoop(), replaceByPackingResult(), replaceForAllWithNewSignature(), replaceForOpWithNewSignature(), replaceUnitDimIndexOps(), replaceUsesAndPropagateType(), restoreInsertionPoint(), CopyBuilder::rewrite(), rewriteOneForallCommonImpl(), PadOpVectorizationWithInsertSlicePattern::rewriteUser(), PadOpVectorizationWithTransferWritePattern::rewriteUser(), setInsertionPointToEnd(), setInsertionPointToStart(), mlir::vector::splitFullAndPartialTransfer(), tileAndFuseFirstExtractUse(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), mlir::scf::tileAndFuseProducerOfSlice(), vectorizeAsTensorPackOp(), vectorizeAsTensorPadOp(), vectorizeAsTensorUnpackOp(), and mlir::scf::yieldReplacementForFusedProducer().

◆ 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 408 of file Builders.h.

◆ 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 423 of file Builders.h.

Referenced by addShardOp(), mlir::transform::gpu::alterGpuLaunch(), createInlinedCompareImplementation(), mlir::mesh::handlePartialAxesDuringResharding(), mlir::mesh::moveLastSplitAxisInResharding(), and mlir::mesh::unsplitLastAxisInResharding().

◆ 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 433 of file Builders.h.

References mlir::Block::begin(), and setInsertionPoint().

Referenced by addBodyWithPayloadOp(), mlir::bufferization::bufferizeBlockSignature(), buildAffineLoopNestImpl(), mlir::bufferization::buildDeallocationLibraryFunction(), mlir::scf::buildLoopNest(), calculateTileOffsetsAndSizes(), mlir::async::cloneConstantsIntoTheRegion(), mlir::affine::coalesceLoops(), mlir::coalesceLoops(), mlir::spirv::combine(), createBinarySearchFunc(), createChoosePivot(), createCompareThenSwap(), createCtlzFunc(), createEqCompare(), createFor(), createHeapSortFunc(), createLessThanCompare(), mlir::arm_sme::createLoopOverTileSlices(), createPartitionFunc(), mlir::LLVM::createPrintStrCall(), createQuickSort(), createQuickSortFunc(), createShiftDownFunc(), createSortStableFunc(), destructureSlot(), endIf(), fillStructuredOpRegion(), mlir::sparse_tensor::SparseIterator::forwardIf(), mlir::fuseIndependentSiblingForallLoops(), mlir::sparse_tensor::FuncCallOrInlineGenerator< SubClass >::genCallOrInline(), genCompressed(), genEndInsert(), generateCollapsedIndexingRegion(), genIf(), genWhenInBound(), getOrDefineFunction(), getOrInsertBuiltinVariable(), handleByValArgumentInit(), injectGpuIndexOperations(), mlir::makeRegionIsolatedFromAbove(), mlir::transform::gpu::mapForallToBlocksImpl(), mlir::GPUFuncOpLowering::matchAndRewrite(), mlir::GPUPrintfOpToHIPLowering::matchAndRewrite(), mlir::GPUPrintfOpToLLVMCallLowering::matchAndRewrite(), mlir::GPUPrintfOpToVPrintfLowering::matchAndRewrite(), modifyFuncOpToUseBarePtrCallingConv(), mlir::LLVM::ModuleImport::ModuleImport(), movePaddingToFillOrGenericOp(), mlir::memref::multiBuffer(), mlir::outlineSingleBlockRegion(), processParallelLoop(), mlir::linalg::rewriteInDestinationPassingStyle(), setInsertionPointAfter(), setInsertionPointToStart(), mlir::vector::splitFullAndPartialTransfer(), wrapExternalFunction(), and wrapForExternalCallers().

◆ setListener()

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

Sets the listener of this builder to the one provided.

Definition at line 318 of file Builders.h.

References listener.

Referenced by mlir::transform::TransformRewriter::TransformRewriter().

◆ 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 482 of file Builders.cpp.

Member Data Documentation

◆ listener

Listener* mlir::OpBuilder::listener
protected

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