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

ImplicitLocOpBuilder maintains a 'current location', allowing use of the create<> method without specifying the location. More...

#include "mlir/IR/ImplicitLocOpBuilder.h"

+ Inheritance diagram for mlir::ImplicitLocOpBuilder:
+ Collaboration diagram for mlir::ImplicitLocOpBuilder:

Public Member Functions

template<typename... T>
 ImplicitLocOpBuilder (Location loc, T &&...operands)
 OpBuilder has a bunch of convenience constructors - we support them all with the additional Location. More...
 
Location getLoc () const
 Accessors for the implied location. More...
 
void setLoc (Location loc)
 
template<typename OpTy , typename... Args>
OpTy create (Args &&...args)
 Create an operation of specific op type at the current insertion point and location. More...
 
template<typename OpTy , typename... Args>
void createOrFold (llvm::SmallVectorImpl< Value > &results, 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< mlir::OpTrait::OneResult >), ValuecreateOrFold (Args &&...args)
 Overload to create or fold a single result operation. More...
 
template<typename OpTy , typename... Args>
std::enable_if_t< OpTy::template hasTrait< mlir::OpTrait::ZeroResults >), OpTy > createOrFold (Args &&...args)
 Overload to create or fold a zero result operation. More...
 
mlir::InFlightDiagnostic emitError (const llvm::Twine &message=llvm::Twine())
 This builder can also be used to emit diagnostics to the current location. More...
 
mlir::InFlightDiagnostic emitWarning (const llvm::Twine &message=llvm::Twine())
 
mlir::InFlightDiagnostic emitRemark (const llvm::Twine &message=llvm::Twine())
 
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...
 
- Public Member Functions inherited from mlir::OpBuilder
 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, 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 getFloat8E4M3FNType ()
 
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 ImplicitLocOpBuilder atBlockBegin (Location loc, 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 ImplicitLocOpBuilder atBlockEnd (Location loc, 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 ImplicitLocOpBuilder atBlockTerminator (Location loc, Block *block, Listener *listener=nullptr)
 Create a builder and set the insertion point to before the block terminator. More...
 
- Static Public Member Functions inherited from mlir::OpBuilder
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

ImplicitLocOpBuilder maintains a 'current location', allowing use of the create<> method without specifying the location.

It is otherwise the same as OpBuilder.

Definition at line 23 of file ImplicitLocOpBuilder.h.

Constructor & Destructor Documentation

◆ ImplicitLocOpBuilder()

template<typename... T>
mlir::ImplicitLocOpBuilder::ImplicitLocOpBuilder ( Location  loc,
T &&...  operands 
)
inline

OpBuilder has a bunch of convenience constructors - we support them all with the additional Location.

Definition at line 28 of file ImplicitLocOpBuilder.h.

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

Member Function Documentation

◆ atBlockBegin()

static ImplicitLocOpBuilder mlir::ImplicitLocOpBuilder::atBlockBegin ( Location  loc,
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 33 of file ImplicitLocOpBuilder.h.

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

Referenced by insertCopies(), outlineExecuteOp(), setupCoroMachinery(), and setupSetErrorBlock().

◆ atBlockEnd()

static ImplicitLocOpBuilder mlir::ImplicitLocOpBuilder::atBlockEnd ( Location  loc,
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 40 of file ImplicitLocOpBuilder.h.

References mlir::Block::end(), and ImplicitLocOpBuilder().

Referenced by addAsyncRuntimeApiDeclarations(), addResumeFunction(), and createElementIPowIFunc().

◆ atBlockTerminator()

static ImplicitLocOpBuilder mlir::ImplicitLocOpBuilder::atBlockTerminator ( Location  loc,
Block block,
Listener listener = nullptr 
)
inlinestatic

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

Definition at line 47 of file ImplicitLocOpBuilder.h.

References mlir::Block::getTerminator(), and ImplicitLocOpBuilder().

◆ create() [1/4]

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

◆ create() [2/4]

Operation * OpBuilder::create

Creates an operation given the fields represented as an OperationState.

Create an operation given the fields represented as an OperationState.

Definition at line 429 of file Builders.cpp.

◆ create() [3/4]

Operation * OpBuilder::create

Creates an operation with the given fields.

Definition at line 432 of file Builders.cpp.

◆ create() [4/4]

template<typename OpTy , typename... Args>
OpTy mlir::OpBuilder::create ( typename OpTy  ,
typename...  Args 
)
inline

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

Definition at line 458 of file Builders.h.

◆ createOrFold() [1/6]

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

Overload to create or fold a single result operation.

Definition at line 81 of file ImplicitLocOpBuilder.h.

◆ createOrFold() [2/6]

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

Overload to create or fold a zero result operation.

Definition at line 88 of file ImplicitLocOpBuilder.h.

◆ createOrFold() [3/6]

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

Create an operation of specific op type at the current insertion point, and immediately try to fold it.

This functions populates 'results' with the results after folding the operation.

Definition at line 74 of file ImplicitLocOpBuilder.h.

Referenced by allocBuffer(), defaultAllocBufferCallBack(), HoistingAnalysis::getPackedTensorSizes(), insertCopyLoops(), and reifyConstantDim().

◆ createOrFold() [4/6]

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

Overload to create or fold a single result operation.

Definition at line 491 of file Builders.h.

◆ createOrFold() [5/6]

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

Overload to create or fold a zero result operation.

Definition at line 500 of file Builders.h.

◆ createOrFold() [6/6]

template<typename OpTy , typename... Args>
void mlir::OpBuilder::createOrFold ( typename OpTy  ,
typename...  Args 
)
inline

Create an operation of specific op type at the current insertion point, and immediately try to fold it.

This functions populates 'results' with the results after folding the operation.

Definition at line 472 of file Builders.h.

◆ emitError()

mlir::InFlightDiagnostic mlir::ImplicitLocOpBuilder::emitError ( const llvm::Twine &  message = llvm::Twine())
inline

This builder can also be used to emit diagnostics to the current location.

Definition at line 94 of file ImplicitLocOpBuilder.h.

References mlir::emitError().

◆ emitRemark()

mlir::InFlightDiagnostic mlir::ImplicitLocOpBuilder::emitRemark ( const llvm::Twine &  message = llvm::Twine())
inline

Definition at line 102 of file ImplicitLocOpBuilder.h.

References mlir::emitRemark().

◆ emitWarning()

mlir::InFlightDiagnostic mlir::ImplicitLocOpBuilder::emitWarning ( const llvm::Twine &  message = llvm::Twine())
inline

Definition at line 98 of file ImplicitLocOpBuilder.h.

References mlir::emitWarning().

◆ getLoc()

Location mlir::ImplicitLocOpBuilder::getLoc ( ) const
inline

Accessors for the implied location.

Definition at line 56 of file ImplicitLocOpBuilder.h.

Referenced by mlir::linalg::computeMultiTileSizes(), createElementIPowIFunc(), insertCopyLoops(), and promoteSubViews().

◆ setLoc()

void mlir::ImplicitLocOpBuilder::setLoc ( Location  loc)
inline

Definition at line 57 of file ImplicitLocOpBuilder.h.


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