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.
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.

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 428 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 516 of file AsmPrinter.cpp.

Constructor & Destructor Documentation

◆ Impl() [1/2]

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

Definition at line 2114 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

◆ 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().

◆ 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 2944 of file AsmPrinter.cpp.

References state.

◆ printAffineConstraint()

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

Definition at line 3172 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 3034 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 2369 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 2373 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 2377 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 2602 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 2611 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 2674 of file AsmPrinter.cpp.

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

Referenced by printAttributeImpl(), and printDenseElementsAttr().

◆ printDialectAttribute()

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

Definition at line 2899 of file AsmPrinter.cpp.

References mlir::Attribute::getDialect(), Impl(), os, printDialectSymbol(), and state.

Referenced by printAttributeImpl().

◆ printDialectType()

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

Definition at line 2913 of file AsmPrinter.cpp.

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

Referenced by printTypeImpl().

◆ printDimensionList()

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

Definition at line 2946 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 2927 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 2936 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 2933 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 2268 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()

◆ 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 2362 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 2117 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 2706 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 2940 of file AsmPrinter.cpp.

References state.

Member Data Documentation

◆ newLine

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

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

Definition at line 534 of file AsmPrinter.cpp.

Referenced by printLocationInternal().

◆ os

◆ printerFlags

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

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

Definition at line 531 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: