MLIR  16.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...
 
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 ()
 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 105 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 112 of file OpImplementation.h.

References mlir::LLVM::detail::printType(), and value.

◆ ~AsmPrinter()

AsmPrinter::~AsmPrinter ( )
virtualdefault

◆ AsmPrinter() [2/2]

mlir::AsmPrinter::AsmPrinter ( )
inlineprotected

Initialize the printer with no internal implementation.

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

Definition at line 218 of file OpImplementation.h.

References value.

Member Function Documentation

◆ getStream()

raw_ostream & AsmPrinter::getStream ( ) const
virtual

◆ printArrowTypeList()

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

Definition at line 193 of file OpImplementation.h.

Referenced by isIntegerPtxType().

◆ printAttribute()

void AsmPrinter::printAttribute ( Attribute  attr)
virtual

Definition at line 2399 of file AsmPrinter.cpp.

Referenced by parentLLVMModule(), and printTypedInitialValue().

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

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 2389 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 207 of file OpImplementation.h.

Referenced by mlir::OpAsmPrinter::printOperands().

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

References printKeywordOrString().

◆ printOptionalArrowTypeList()

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

Print an optional arrow followed by a type list.

Definition at line 188 of file OpImplementation.h.

Referenced by mlir::scf::insideMutuallyExclusiveBranches(), printNamedStructuredOpResults(), mlir::replaceForOpWithNewYields(), and replaceOpWithRegion().

◆ printResourceHandle()

void AsmPrinter::printResourceHandle ( const AsmDialectResourceHandle resource)

Print a handle to the given dialect resource.

Definition at line 2430 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 ( 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 140 of file OpImplementation.h.

References mlir::succeeded(), and value.

Referenced by mlir::bufferization::populateDynamicDimSizes().

◆ printStrippedAttrOrType() [2/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 153 of file OpImplementation.h.

References value.

◆ 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 165 of file OpImplementation.h.

References printKeywordOrString().

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

References printSymbolReference().

Referenced by buildLLVMFunctionType(), getLoadStoreElementType(), hasOneBranchOpTo(), parentLLVMModule(), printAttributions(), mlir::function_interface_impl::printFunctionOp(), verifyAttributions(), verifyConstantType(), and verifyJointMatrixMad().

◆ printType()

void AsmPrinter::printType ( Type  type)
virtual

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