MLIR 22.0.0git
mlir::AsmPrinter::Impl Class Reference

Public Types

enum class  AttrTypeElision { Never , May , Must }
 This enum describes the different kinds of elision for the type of an attribute when printing it. More...

Public Member Functions

 Impl (raw_ostream &os, AsmStateImpl &state)
 Impl (Impl &other)
raw_ostreamgetStream ()
 Returns the output stream of the printer.
void printNewline ()
 Print a newline and indent the printer to the start of the current operation/attribute/type.
void increaseIndent ()
 Increase indentation.
void decreaseIndent ()
 Decrease indentation.
template<typename Container, typename UnaryFunctor>
void interleaveComma (const Container &c, UnaryFunctor eachFn) const
void printAttribute (Attribute attr, AttrTypeElision typeElision=AttrTypeElision::Never)
 Print the given attribute or an alias.
void printAttributeImpl (Attribute attr, AttrTypeElision typeElision=AttrTypeElision::Never)
 Print the given attribute without considering an alias.
void printNamedAttribute (NamedAttribute attr)
LogicalResult printAlias (Attribute attr)
 Print the alias for the given attribute, return failure if no alias could be printed.
void printType (Type type)
 Print the given type or an alias.
void printTypeImpl (Type type)
 Print the given type.
LogicalResult printAlias (Type type)
 Print the alias for the given type, return failure if no alias could be printed.
void printLocation (LocationAttr loc, bool allowAlias=false)
 Print the given location to the stream.
void printResourceHandle (const AsmDialectResourceHandle &resource)
 Print a reference to the given resource that is owned by the given dialect.
void printAffineMap (AffineMap map)
void printAffineExpr (AffineExpr expr, function_ref< void(unsigned, bool)> printValueName=nullptr)
void printAffineConstraint (AffineExpr expr, bool isEq)
void printIntegerSet (IntegerSet set)
LogicalResult pushCyclicPrinting (const void *opaquePointer)
void popCyclicPrinting ()
void printDimensionList (ArrayRef< int64_t > shape)

Protected Types

enum class  BindingStrength { Weak , Strong }
 This enum is used to represent the binding strength of the enclosing context that an AffineExprStorage is being printed in, so we can intelligently produce parens. More...

Protected Member Functions

void printOptionalAttrDict (ArrayRef< NamedAttribute > attrs, ArrayRef< StringRef > elidedAttrs={}, bool withKeyword=false)
void printTrailingLocation (Location loc, bool allowAlias=true)
void printLocationInternal (LocationAttr loc, bool pretty=false, bool isTopLevel=false)
void printDenseElementsAttr (DenseElementsAttr attr, bool allowHex)
 Print a dense elements attribute.
void printDenseStringElementsAttr (DenseStringElementsAttr attr)
 Print a dense string elements attribute.
void printDenseIntOrFPElementsAttr (DenseIntOrFPElementsAttr attr, bool allowHex)
 Print a dense elements attribute.
void printDenseArrayAttr (DenseArrayAttr attr)
 Print a dense array attribute.
void printDialectAttribute (Attribute attr)
void printDialectType (Type type)
void printEscapedString (StringRef str)
 Print an escaped string, wrapped with "".
void printHexString (StringRef str)
 Print a hex string, wrapped with "".
void printHexString (ArrayRef< char > data)
void printAffineExprInternal (AffineExpr expr, BindingStrength enclosingTightness, function_ref< void(unsigned, bool)> printValueName=nullptr)

Protected Attributes

raw_ostreamos
 The output stream for the printer.
AsmStateImplstate
 An underlying assembly printer state.
OpPrintingFlags printerFlags
 A set of flags to control the printer's behavior.
NewLineCounter newLine
 A tracker for the number of new lines emitted during printing.
unsigned currentIndent = 0
 This is the current indentation level for nested structures.

Static Protected Attributes

static const unsigned indentWidth = 2
 The number of spaces used as an indent.

Detailed Description

Definition at line 413 of file AsmPrinter.cpp.

Member Enumeration Documentation

◆ AttrTypeElision

This enum describes the different kinds of elision for the type of an attribute when printing it.

Enumerator
Never 

The type must not be elided,.

May 

The type may be elided when it matches the default used in the parser (for example i64 is the default for integer attributes).

Must 

The type must be elided.

Definition at line 443 of file AsmPrinter.cpp.

◆ BindingStrength

enum class mlir::AsmPrinter::Impl::BindingStrength
strongprotected

This enum is used to represent the binding strength of the enclosing context that an AffineExprStorage is being printed in, so we can intelligently produce parens.

Enumerator
Weak 
Strong 

Definition at line 531 of file AsmPrinter.cpp.

Constructor & Destructor Documentation

◆ Impl() [1/2]

AsmPrinter::Impl::Impl ( raw_ostream & os,
AsmStateImpl & state )

Definition at line 2141 of file AsmPrinter.cpp.

References os, printerFlags, and state.

Referenced by Impl(), printDialectAttribute(), and printDialectType().

◆ Impl() [2/2]

mlir::AsmPrinter::Impl::Impl ( Impl & other)
inlineexplicit

Definition at line 416 of file AsmPrinter.cpp.

References Impl(), os, and state.

Member Function Documentation

◆ decreaseIndent()

void mlir::AsmPrinter::Impl::decreaseIndent ( )
inline

Decrease indentation.

Definition at line 434 of file AsmPrinter.cpp.

References currentIndent, and indentWidth.

◆ getStream()

raw_ostream & mlir::AsmPrinter::Impl::getStream ( )
inline

Returns the output stream of the printer.

Definition at line 419 of file AsmPrinter.cpp.

References os.

Referenced by printDenseArrayAttr().

◆ increaseIndent()

void mlir::AsmPrinter::Impl::increaseIndent ( )
inline

Increase indentation.

Definition at line 431 of file AsmPrinter.cpp.

References currentIndent, and indentWidth.

◆ interleaveComma()

template<typename Container, typename UnaryFunctor>
void mlir::AsmPrinter::Impl::interleaveComma ( const Container & c,
UnaryFunctor eachFn ) const
inline

◆ popCyclicPrinting()

void AsmPrinter::Impl::popCyclicPrinting ( )

Definition at line 2985 of file AsmPrinter.cpp.

References state.

◆ printAffineConstraint()

void AsmPrinter::Impl::printAffineConstraint ( AffineExpr expr,
bool isEq )

Definition at line 3228 of file AsmPrinter.cpp.

References os, printAffineExprInternal(), and Weak.

Referenced by printIntegerSet().

◆ printAffineExpr()

void AsmPrinter::Impl::printAffineExpr ( AffineExpr expr,
function_ref< void(unsigned, bool)> printValueName = nullptr )

Definition at line 3090 of file AsmPrinter.cpp.

References printAffineExprInternal(), and Weak.

Referenced by mlir::AffineExpr::print().

◆ printAffineExprInternal()

void AsmPrinter::Impl::printAffineExprInternal ( AffineExpr expr,
BindingStrength enclosingTightness,
function_ref< void(unsigned, bool)> printValueName = nullptr )
protected

◆ printAffineMap()

void AsmPrinter::Impl::printAffineMap ( AffineMap map)

◆ printAlias() [1/2]

LogicalResult AsmPrinter::Impl::printAlias ( Attribute attr)

Print the alias for the given attribute, return failure if no alias could be printed.

Definition at line 2396 of file AsmPrinter.cpp.

References os, and state.

Referenced by mlir::Attribute::printStripped().

◆ printAlias() [2/2]

LogicalResult AsmPrinter::Impl::printAlias ( Type type)

Print the alias for the given type, return failure if no alias could be printed.

Definition at line 2400 of file AsmPrinter.cpp.

References os, and state.

◆ printAttribute()

void AsmPrinter::Impl::printAttribute ( Attribute attr,
AttrTypeElision typeElision = AttrTypeElision::Never )

Print the given attribute or an alias.

Definition at line 2404 of file AsmPrinter.cpp.

References os, mlir::AsmPrinter::printAlias(), and printAttributeImpl().

Referenced by mlir::Attribute::print().

◆ printAttributeImpl()

◆ printDenseArrayAttr()

void AsmPrinter::Impl::printDenseArrayAttr ( DenseArrayAttr attr)
protected

◆ printDenseElementsAttr()

void AsmPrinter::Impl::printDenseElementsAttr ( DenseElementsAttr attr,
bool allowHex )
protected

Print a dense elements attribute.

If 'allowHex' is true, a hex string is used instead of individual elements when the elements attr is large.

Definition at line 2629 of file AsmPrinter.cpp.

References printDenseIntOrFPElementsAttr(), and printDenseStringElementsAttr().

Referenced by printAttributeImpl().

◆ printDenseIntOrFPElementsAttr()

void AsmPrinter::Impl::printDenseIntOrFPElementsAttr ( DenseIntOrFPElementsAttr attr,
bool allowHex )
protected

Print a dense elements attribute.

If 'allowHex' is true, a hex string is used instead of individual elements when the elements attr is large.

Definition at line 2638 of file AsmPrinter.cpp.

References os, printDenseElementsAttrImpl(), printerFlags, and printHexString().

Referenced by printAttributeImpl(), and printDenseElementsAttr().

◆ printDenseStringElementsAttr()

void AsmPrinter::Impl::printDenseStringElementsAttr ( DenseStringElementsAttr attr)
protected

Print a dense string elements attribute.

Definition at line 2701 of file AsmPrinter.cpp.

References os, printDenseElementsAttrImpl(), and printEscapedString().

Referenced by printAttributeImpl(), and printDenseElementsAttr().

◆ printDialectAttribute()

void AsmPrinter::Impl::printDialectAttribute ( Attribute attr)
protected

◆ printDialectType()

void AsmPrinter::Impl::printDialectType ( Type type)
protected

Definition at line 2947 of file AsmPrinter.cpp.

References currentIndent, mlir::Type::getDialect(), Impl(), newLine, os, printDialectSymbol(), and state.

Referenced by printTypeImpl().

◆ printDimensionList()

void AsmPrinter::Impl::printDimensionList ( ArrayRef< int64_t > shape)

Definition at line 2987 of file AsmPrinter.cpp.

References os, and mlir::detail::printDimensionList().

◆ printEscapedString()

void AsmPrinter::Impl::printEscapedString ( StringRef str)
protected

Print an escaped string, wrapped with "".

Definition at line 2968 of file AsmPrinter.cpp.

References os.

Referenced by printAttributeImpl(), printDenseStringElementsAttr(), and printLocationInternal().

◆ printHexString() [1/2]

void AsmPrinter::Impl::printHexString ( ArrayRef< char > data)
protected

Definition at line 2977 of file AsmPrinter.cpp.

References printHexString().

◆ printHexString() [2/2]

void AsmPrinter::Impl::printHexString ( StringRef str)
protected

Print a hex string, wrapped with "".

Definition at line 2974 of file AsmPrinter.cpp.

References os.

Referenced by printDenseIntOrFPElementsAttr(), and printHexString().

◆ printIntegerSet()

◆ printLocation()

void AsmPrinter::Impl::printLocation ( LocationAttr loc,
bool allowAlias = false )

Print the given location to the stream.

If allowAlias is true, this allows for the internal location to use an attribute alias.

Definition at line 2295 of file AsmPrinter.cpp.

References os, mlir::AsmPrinter::printAlias(), printerFlags, and printLocationInternal().

Referenced by printAttributeImpl(), and printTrailingLocation().

◆ printLocationInternal()

void AsmPrinter::Impl::printLocationInternal ( LocationAttr loc,
bool pretty = false,
bool isTopLevel = false )
protected

◆ printNamedAttribute()

◆ printNewline()

void mlir::AsmPrinter::Impl::printNewline ( )
inline

Print a newline and indent the printer to the start of the current operation/attribute/type.

Note: For attributes and types this method should only be used in custom dialects. Usage in MLIR dialects is disallowed.

Definition at line 425 of file AsmPrinter.cpp.

References currentIndent, newLine, and os.

◆ printOptionalAttrDict()

void AsmPrinter::Impl::printOptionalAttrDict ( ArrayRef< NamedAttribute > attrs,
ArrayRef< StringRef > elidedAttrs = {},
bool withKeyword = false )
protected

◆ printResourceHandle()

void AsmPrinter::Impl::printResourceHandle ( const AsmDialectResourceHandle & resource)

Print a reference to the given resource that is owned by the given dialect.

Definition at line 2389 of file AsmPrinter.cpp.

References mlir::AsmDialectResourceHandle::getDialect(), os, mlir::AsmPrinter::printKeywordOrString(), and state.

◆ printTrailingLocation()

void AsmPrinter::Impl::printTrailingLocation ( Location loc,
bool allowAlias = true )
protected

Definition at line 2144 of file AsmPrinter.cpp.

References os, printerFlags, and printLocation().

◆ printType()

void AsmPrinter::Impl::printType ( Type type)

Print the given type or an alias.

Definition at line 2733 of file AsmPrinter.cpp.

References os, mlir::AsmPrinter::printAlias(), and printTypeImpl().

Referenced by mlir::Type::print().

◆ printTypeImpl()

void AsmPrinter::Impl::printTypeImpl ( Type type)

◆ pushCyclicPrinting()

LogicalResult AsmPrinter::Impl::pushCyclicPrinting ( const void * opaquePointer)

Definition at line 2981 of file AsmPrinter.cpp.

References state.

Member Data Documentation

◆ currentIndent

unsigned mlir::AsmPrinter::Impl::currentIndent = 0
protected

This is the current indentation level for nested structures.

Definition at line 555 of file AsmPrinter.cpp.

Referenced by decreaseIndent(), increaseIndent(), printDialectAttribute(), printDialectType(), and printNewline().

◆ indentWidth

const unsigned mlir::AsmPrinter::Impl::indentWidth = 2
staticprotected

The number of spaces used as an indent.

Definition at line 552 of file AsmPrinter.cpp.

Referenced by decreaseIndent(), and increaseIndent().

◆ newLine

NewLineCounter mlir::AsmPrinter::Impl::newLine
protected

A tracker for the number of new lines emitted during printing.

Definition at line 549 of file AsmPrinter.cpp.

Referenced by printDialectAttribute(), printDialectType(), printLocationInternal(), and printNewline().

◆ os

◆ printerFlags

OpPrintingFlags mlir::AsmPrinter::Impl::printerFlags
protected

A set of flags to control the printer's behavior.

Definition at line 546 of file AsmPrinter.cpp.

Referenced by Impl(), printAttributeImpl(), printDenseIntOrFPElementsAttr(), printLocation(), and printTrailingLocation().

◆ state

AsmStateImpl& mlir::AsmPrinter::Impl::state
protected

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