MLIR  17.0.0git
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
mlir::AsmPrinter Class Reference

This base class exposes generic asm printer hooks, usable across the various derived printers. More...

#include "mlir/IR/OpImplementation.h"

+ Inheritance diagram for mlir::AsmPrinter:

Classes

class  Impl
 

Public Types

template<typename AttrOrType >
using has_print_method = decltype(std::declval< AttrOrType >().print(std::declval< AsmPrinter & >()))
 Trait to check if AttrType provides a print method. More...
 
template<typename AttrOrType >
using detect_has_print_method = llvm::is_detected< has_print_method, AttrOrType >
 

Public Member Functions

 AsmPrinter (Impl &impl)
 Initialize the printer with the given internal implementation. More...
 
virtual ~AsmPrinter ()
 
virtual raw_ostream & getStream () const
 Return the raw output stream used by this printer. More...
 
virtual void printFloat (const APFloat &value)
 Print the given floating point value in a stabilized form that can be roundtripped through the IR. More...
 
virtual void printType (Type type)
 
virtual void printAttribute (Attribute attr)
 
template<typename AttrOrType , std::enable_if_t< detect_has_print_method< AttrOrType >::value > * sfinae = nullptr>
void printStrippedAttrOrType (AttrOrType attrOrType)
 Print the provided attribute in the context of an operation custom printer/parser: this will invoke directly the print method on the attribute class and skip the #dialect.mnemonic prefix in most cases. More...
 
template<typename AttrOrType , std::enable_if_t< detect_has_print_method< AttrOrType >::value > * sfinae = nullptr>
void printStrippedAttrOrType (ArrayRef< AttrOrType > attrOrTypes)
 Print the provided array of attributes or types in the context of an operation custom printer/parser: this will invoke directly the print method on the attribute class and skip the #dialect.mnemonic prefix in most cases. More...
 
template<typename AttrOrType , std::enable_if_t<!detect_has_print_method< AttrOrType >::value > * sfinae = nullptr>
void printStrippedAttrOrType (AttrOrType attrOrType)
 SFINAE for printing the provided attribute in the context of an operation custom printer in the case where the attribute does not define a print method. More...
 
virtual void printAttributeWithoutType (Attribute attr)
 Print the given attribute without its type. More...
 
virtual void printKeywordOrString (StringRef keyword)
 Print the given string as a keyword, or a quoted and escaped string if it has any special or non-printable characters in it. More...
 
virtual void printSymbolName (StringRef symbolRef)
 Print the given string as a symbol reference, i.e. More...
 
virtual void printResourceHandle (const AsmDialectResourceHandle &resource)
 Print a handle to the given dialect resource. More...
 
template<typename TypeRange >
void printOptionalArrowTypeList (TypeRange &&types)
 Print an optional arrow followed by a type list. More...
 
template<typename TypeRange >
void printArrowTypeList (TypeRange &&types)
 
template<typename InputRangeT , typename ResultRangeT >
void printFunctionalType (InputRangeT &&inputs, ResultRangeT &&results)
 Print the two given type ranges in a functional form. More...
 

Protected Member Functions

 AsmPrinter ()=default
 Initialize the printer with no internal implementation. More...
 

Detailed Description

This base class exposes generic asm printer hooks, usable across the various derived printers.

Definition at line 106 of file OpImplementation.h.

Member Typedef Documentation

◆ detect_has_print_method

template<typename AttrOrType >
using mlir::AsmPrinter::detect_has_print_method = llvm::is_detected<has_print_method, AttrOrType>

Definition at line 132 of file OpImplementation.h.

◆ has_print_method

template<typename AttrOrType >
using mlir::AsmPrinter::has_print_method = decltype(std::declval<AttrOrType>().print(std::declval<AsmPrinter &>()))

Trait to check if AttrType provides a print method.

Definition at line 129 of file OpImplementation.h.

Constructor & Destructor Documentation

◆ AsmPrinter() [1/2]

mlir::AsmPrinter::AsmPrinter ( Impl impl)
inline

Initialize the printer with the given internal implementation.

Definition at line 113 of file OpImplementation.h.

◆ ~AsmPrinter()

AsmPrinter::~AsmPrinter ( )
virtualdefault

◆ AsmPrinter() [2/2]

mlir::AsmPrinter::AsmPrinter ( )
protecteddefault

Initialize the printer with no internal implementation.

In this case, all virtual methods of this class must be overriden.

Member Function Documentation

◆ getStream()

raw_ostream & AsmPrinter::getStream ( ) const
virtual

◆ printArrowTypeList()

template<typename TypeRange >
void mlir::AsmPrinter::printArrowTypeList ( TypeRange &&  types)
inline

Definition at line 194 of file OpImplementation.h.

References getStream().

Referenced by printFunctionalType(), and printOptionalArrowTypeList().

◆ printAttribute()

void AsmPrinter::printAttribute ( Attribute  attr)
virtual

◆ printAttributeWithoutType()

void AsmPrinter::printAttributeWithoutType ( Attribute  attr)
virtual

Print the given attribute without its type.

The corresponding parser must provide a valid type for the attribute.

Definition at line 2650 of file AsmPrinter.cpp.

References mlir::AsmPrinter::Impl::Must.

Referenced by printGlobalMemrefOpTypeAndInitialValue().

◆ printFloat()

void AsmPrinter::printFloat ( const APFloat &  value)
virtual

Print the given floating point value in a stabilized form that can be roundtripped through the IR.

Print the given floating point value in a stablized form.

This is the companion to the 'parseFloat' hook on the AsmParser.

Definition at line 2625 of file AsmPrinter.cpp.

References printFloatValue().

◆ printFunctionalType()

template<typename InputRangeT , typename ResultRangeT >
void mlir::AsmPrinter::printFunctionalType ( InputRangeT &&  inputs,
ResultRangeT &&  results 
)
inline

Print the two given type ranges in a functional form.

Definition at line 208 of file OpImplementation.h.

References getStream(), and printArrowTypeList().

◆ printKeywordOrString()

void AsmPrinter::printKeywordOrString ( StringRef  keyword)
virtual

Print the given string as a keyword, or a quoted and escaped string if it has any special or non-printable characters in it.

Definition at line 2656 of file AsmPrinter.cpp.

◆ printOptionalArrowTypeList()

template<typename TypeRange >
void mlir::AsmPrinter::printOptionalArrowTypeList ( TypeRange &&  types)
inline

Print an optional arrow followed by a type list.

Definition at line 189 of file OpImplementation.h.

References printArrowTypeList().

Referenced by printNamedStructuredOpResults().

◆ printResourceHandle()

void AsmPrinter::printResourceHandle ( const AsmDialectResourceHandle resource)
virtual

Print a handle to the given dialect resource.

Definition at line 2666 of file AsmPrinter.cpp.

◆ printStrippedAttrOrType() [1/3]

template<typename AttrOrType , std::enable_if_t< detect_has_print_method< AttrOrType >::value > * sfinae = nullptr>
void mlir::AsmPrinter::printStrippedAttrOrType ( ArrayRef< AttrOrType >  attrOrTypes)
inline

Print the provided array of attributes or types in the context of an operation custom printer/parser: this will invoke directly the print method on the attribute class and skip the #dialect.mnemonic prefix in most cases.

Definition at line 154 of file OpImplementation.h.

References getStream(), and printStrippedAttrOrType().

◆ printStrippedAttrOrType() [2/3]

template<typename AttrOrType , std::enable_if_t< detect_has_print_method< AttrOrType >::value > * sfinae = nullptr>
void mlir::AsmPrinter::printStrippedAttrOrType ( AttrOrType  attrOrType)
inline

Print the provided attribute in the context of an operation custom printer/parser: this will invoke directly the print method on the attribute class and skip the #dialect.mnemonic prefix in most cases.

Definition at line 141 of file OpImplementation.h.

References mlir::succeeded().

Referenced by printStrippedAttrOrType().

◆ printStrippedAttrOrType() [3/3]

template<typename AttrOrType , std::enable_if_t<!detect_has_print_method< AttrOrType >::value > * sfinae = nullptr>
void mlir::AsmPrinter::printStrippedAttrOrType ( AttrOrType  attrOrType)
inline

SFINAE for printing the provided attribute in the context of an operation custom printer in the case where the attribute does not define a print method.

Definition at line 166 of file OpImplementation.h.

◆ printSymbolName()

void AsmPrinter::printSymbolName ( StringRef  symbolRef)
virtual

Print the given string as a symbol reference, i.e.

a form representable by a SymbolRefAttr. A symbol reference is represented as a string prefixed with '@'. The reference is surrounded with ""'s and escaped if it has any special or non-printable characters in it.

Definition at line 2661 of file AsmPrinter.cpp.

References printSymbolReference().

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

◆ printType()

void AsmPrinter::printType ( Type  type)
virtual

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