MLIR 22.0.0git
mlir::impl Namespace Reference

Attribute collections provide a dictionary-like interface. More...

Functions

LogicalResult verifyHasDefaultDLTIDataLayoutTrait (Operation *op)
DataLayoutSpecInterface getDataLayoutSpec (Operation *op)
TargetSystemSpecInterface getTargetSystemSpec (Operation *op)
LogicalResult foldCastInterfaceOp (Operation *op, ArrayRef< Attribute > attrOperands, SmallVectorImpl< OpFoldResult > &foldResults)
 Attempt to fold the given cast operation.
LogicalResult verifyCastInterfaceOp (Operation *op)
 Attempt to verify the given cast operation.
void ensureRegionTerminator (Region &region, OpBuilder &builder, Location loc, function_ref< Operation *(OpBuilder &, Location)> buildTerminatorOp)
 Insert an operation, generated by buildTerminatorOp, at the end of the region's only block if it does not have a terminator already.
void ensureRegionTerminator (Region &region, Builder &builder, Location loc, function_ref< Operation *(OpBuilder &, Location)> buildTerminatorOp)
 Create a simple OpBuilder and forward to the OpBuilder version of this function.
template<typename IteratorT, typename NameT>
std::pair< IteratorT, boolfindAttrUnsorted (IteratorT first, IteratorT last, NameT name)
 Unsorted string search or identifier lookups are linear scans.
template<typename IteratorT>
std::pair< IteratorT, boolfindAttrSorted (IteratorT first, IteratorT last, StringRef name)
 Using llvm::lower_bound requires an extra string comparison to check whether the returned iterator points to the found element or whether it indicates the lower bound.
template<typename IteratorT>
std::pair< IteratorT, boolfindAttrSorted (IteratorT first, IteratorT last, StringAttr name)
 StringAttr lookups on large attribute lists will switch to string binary search.
template<typename IteratorT, typename NameT>
Attribute getAttrFromSortedRange (IteratorT first, IteratorT last, NameT name)
 Get an attribute from a sorted range of named attributes.
template<typename IteratorT, typename NameT>
std::optional< NamedAttributegetNamedAttrFromSortedRange (IteratorT first, IteratorT last, NameT name)
 Get an attribute from a sorted range of named attributes.
ParseResult parseOptionalVisibilityKeyword (OpAsmParser &parser, NamedAttrList &attrs)
 Parse an optional visibility attribute keyword (i.e., public, private, or nested) without quotes in a string attribute named 'attrName'.
LogicalResult scalarizeVectorOp (Operation *op, ValueRange operands, ConversionPatternRewriter &rewriter, const LLVMTypeConverter &converter)
 Unrolls op to array/vector elements.

Detailed Description

Attribute collections provide a dictionary-like interface.

Define common lookup functions.

Function Documentation

◆ ensureRegionTerminator() [1/2]

void mlir::impl::ensureRegionTerminator ( Region & region,
Builder & builder,
Location loc,
function_ref< Operation *(OpBuilder &, Location)> buildTerminatorOp )

Create a simple OpBuilder and forward to the OpBuilder version of this function.

Definition at line 1420 of file Operation.cpp.

References ensureRegionTerminator(), and mlir::Builder::getContext().

◆ ensureRegionTerminator() [2/2]

void mlir::impl::ensureRegionTerminator ( Region & region,
OpBuilder & builder,
Location loc,
function_ref< Operation *(OpBuilder &, Location)> buildTerminatorOp )

Insert an operation, generated by buildTerminatorOp, at the end of the region's only block if it does not have a terminator already.

If the region is empty, insert a new block first. buildTerminatorOp should return the terminator operation to insert.

Definition at line 1403 of file Operation.cpp.

References mlir::Block::back(), mlir::Region::back(), mlir::OpBuilder::createBlock(), mlir::Block::empty(), mlir::Region::empty(), mlir::Operation::hasTrait(), mlir::OpBuilder::insert(), and mlir::OpBuilder::setInsertionPointToEnd().

Referenced by ensureRegionTerminator(), mlir::OpTrait::SingleBlockImplicitTerminator< TerminatorOpType >::Impl< ConcreteType >::ensureTerminator(), and mlir::OpTrait::SingleBlockImplicitTerminator< TerminatorOpType >::Impl< ConcreteType >::ensureTerminator().

◆ findAttrSorted() [1/2]

template<typename IteratorT>
std::pair< IteratorT, bool > mlir::impl::findAttrSorted ( IteratorT first,
IteratorT last,
StringAttr name )

StringAttr lookups on large attribute lists will switch to string binary search.

String binary searches become significantly faster than linear scans with the identifier when the attribute list becomes very large.

Definition at line 763 of file OperationSupport.h.

References findAttrSorted(), and findAttrUnsorted().

◆ findAttrSorted() [2/2]

template<typename IteratorT>
std::pair< IteratorT, bool > mlir::impl::findAttrSorted ( IteratorT first,
IteratorT last,
StringRef name )

Using llvm::lower_bound requires an extra string comparison to check whether the returned iterator points to the found element or whether it indicates the lower bound.

Skip this redundant comparison by checking if compare == / 0 during the binary search.

Definition at line 739 of file OperationSupport.h.

Referenced by findAttrSorted(), getAttrFromSortedRange(), and getNamedAttrFromSortedRange().

◆ findAttrUnsorted()

template<typename IteratorT, typename NameT>
std::pair< IteratorT, bool > mlir::impl::findAttrUnsorted ( IteratorT first,
IteratorT last,
NameT name )

Unsorted string search or identifier lookups are linear scans.

Definition at line 726 of file OperationSupport.h.

Referenced by findAttrSorted().

◆ foldCastInterfaceOp()

LogicalResult mlir::impl::foldCastInterfaceOp ( Operation * op,
ArrayRef< Attribute > attrOperands,
SmallVectorImpl< OpFoldResult > & foldResults )

◆ getAttrFromSortedRange()

template<typename IteratorT, typename NameT>
Attribute mlir::impl::getAttrFromSortedRange ( IteratorT first,
IteratorT last,
NameT name )

Get an attribute from a sorted range of named attributes.

Returns null if the attribute was not found.

Definition at line 774 of file OperationSupport.h.

References findAttrSorted(), and result.

◆ getDataLayoutSpec()

DataLayoutSpecInterface mlir::impl::getDataLayoutSpec ( Operation * op)

◆ getNamedAttrFromSortedRange()

template<typename IteratorT, typename NameT>
std::optional< NamedAttribute > mlir::impl::getNamedAttrFromSortedRange ( IteratorT first,
IteratorT last,
NameT name )

Get an attribute from a sorted range of named attributes.

Returns std::nullopt if the attribute was not found.

Definition at line 783 of file OperationSupport.h.

References findAttrSorted(), and result.

◆ getTargetSystemSpec()

TargetSystemSpecInterface mlir::impl::getTargetSystemSpec ( Operation * op)

◆ parseOptionalVisibilityKeyword()

ParseResult mlir::impl::parseOptionalVisibilityKeyword ( OpAsmParser & parser,
NamedAttrList & attrs )

Parse an optional visibility attribute keyword (i.e., public, private, or nested) without quotes in a string attribute named 'attrName'.

Definition at line 1124 of file SymbolTable.cpp.

References mlir::AsmParser::getBuilder(), mlir::Builder::getNamedAttr(), mlir::Builder::getStringAttr(), mlir::SymbolTable::getVisibilityAttrName(), mlir::AsmParser::parseOptionalKeyword(), mlir::NamedAttrList::push_back(), and success().

Referenced by mlir::function_interface_impl::parseFunctionOp().

◆ scalarizeVectorOp()

LogicalResult mlir::impl::scalarizeVectorOp ( Operation * op,
ValueRange operands,
ConversionPatternRewriter & rewriter,
const LLVMTypeConverter & converter )

◆ verifyCastInterfaceOp()

LogicalResult mlir::impl::verifyCastInterfaceOp ( Operation * op)

◆ verifyHasDefaultDLTIDataLayoutTrait()

LogicalResult mlir::impl::verifyHasDefaultDLTIDataLayoutTrait ( Operation * op)

Definition at line 15 of file Traits.cpp.

References success().

Referenced by mlir::HasDefaultDLTIDataLayout< ConcreteOp >::verifyTrait().