MLIR
20.0.0git
|
This base class exposes generic asm printer hooks, usable across the various derived printers. More...
#include "mlir/IR/OpImplementation.h"
Classes | |
class | CyclicPrintReset |
Class used to automatically end a cyclic region on destruction. More... | |
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 LogicalResult | printAlias (Attribute attr) |
Print the alias for the given attribute, return failure if no alias could be printed. More... | |
virtual LogicalResult | printAlias (Type type) |
Print the alias for the given type, return failure if no alias could be printed. 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 | printString (StringRef string) |
Print the given string as a quoted string, escaping 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... | |
void | printDimensionList (ArrayRef< int64_t > shape) |
template<class AttrOrTypeT > | |
FailureOr< CyclicPrintReset > | tryStartCyclicPrint (AttrOrTypeT attrOrType) |
Attempts to start a cyclic printing region for attrOrType . More... | |
Protected Member Functions | |
AsmPrinter ()=default | |
Initialize the printer with no internal implementation. More... | |
virtual LogicalResult | pushCyclicPrinting (const void *opaquePointer) |
Pushes a new attribute or type in the form of a type erased pointer into an internal set. More... | |
virtual void | popCyclicPrinting () |
Removes the element that was last inserted with a successful call to pushCyclicPrinting . More... | |
This base class exposes generic asm printer hooks, usable across the various derived printers.
Definition at line 106 of file OpImplementation.h.
using mlir::AsmPrinter::detect_has_print_method = llvm::is_detected<has_print_method, AttrOrType> |
Definition at line 132 of file OpImplementation.h.
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.
|
inline |
Initialize the printer with the given internal implementation.
Definition at line 113 of file OpImplementation.h.
|
virtualdefault |
|
protecteddefault |
Initialize the printer with no internal implementation.
In this case, all virtual methods of this class must be overriden.
|
virtual |
Return the raw output stream used by this printer.
Definition at line 2815 of file AsmPrinter.cpp.
Referenced by mlir::detail::DenseArrayAttrImpl< T >::print(), mlir::sparse_tensor::ir_detail::Var::print(), print(), printArrowTypeList(), printDimensionList(), printFunctionalType(), printFunctionResultList(), mlir::function_interface_impl::printFunctionSignature(), mlir::OpAsmPrinter::printOperands(), mlir::OpState::printOpName(), mlir::printSemiFunctionType(), printSequenceOpOperands(), printString(), printStrippedAttrOrType(), mlir::transform::printTransformMatchDims(), and typeOrAttrPrinter().
|
protectedvirtual |
Removes the element that was last inserted with a successful call to pushCyclicPrinting
.
There must be exactly one popCyclicPrinting
call in reverse order of all successful pushCyclicPrinting
.
Definition at line 2882 of file AsmPrinter.cpp.
Referenced by mlir::AsmPrinter::CyclicPrintReset::~CyclicPrintReset().
|
virtual |
Print the alias for the given attribute, return failure if no alias could be printed.
Definition at line 2836 of file AsmPrinter.cpp.
Referenced by mlir::AsmPrinter::Impl::printLocation(), and printStrippedAttrOrType().
|
virtual |
Print the alias for the given type, return failure if no alias could be printed.
Definition at line 2841 of file AsmPrinter.cpp.
|
inline |
Definition at line 215 of file OpImplementation.h.
References getStream().
Referenced by printFunctionalType(), and printOptionalArrowTypeList().
|
virtual |
Definition at line 2831 of file AsmPrinter.cpp.
Referenced by printTypedInitialValue(), and mlir::tosa::printTypeOrAttr().
|
virtual |
Print the given attribute without its type.
The corresponding parser must provide a valid type for the attribute.
Definition at line 2846 of file AsmPrinter.cpp.
References mlir::AsmPrinter::Impl::Must.
Referenced by printEmitCGlobalOpTypeAndInitialValue(), and printGlobalMemrefOpTypeAndInitialValue().
void AsmPrinter::printDimensionList | ( | ArrayRef< int64_t > | shape | ) |
Definition at line 2874 of file AsmPrinter.cpp.
References getStream(), and mlir::detail::printDimensionList().
Referenced by mlir::printDimensionList().
|
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 2821 of file AsmPrinter.cpp.
References printFloatValue().
|
inline |
Print the two given type ranges in a functional form.
Definition at line 229 of file OpImplementation.h.
References getStream(), and printArrowTypeList().
|
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 2852 of file AsmPrinter.cpp.
|
inline |
Print an optional arrow followed by a type list.
Definition at line 210 of file OpImplementation.h.
References printArrowTypeList().
Referenced by printNamedStructuredOpResults().
|
virtual |
Print a handle to the given dialect resource.
Definition at line 2869 of file AsmPrinter.cpp.
|
virtual |
Print the given string as a quoted string, escaping any special or non-printable characters in it.
Definition at line 2857 of file AsmPrinter.cpp.
References getStream().
Referenced by printOneOpBundle().
|
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 163 of file OpImplementation.h.
References getStream(), and printStrippedAttrOrType().
|
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 getStream(), and printAlias().
Referenced by printStrippedAttrOrType().
|
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 175 of file OpImplementation.h.
|
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 2864 of file AsmPrinter.cpp.
References printSymbolReference().
Referenced by mlir::function_interface_impl::printFunctionOp().
|
virtual |
Definition at line 2826 of file AsmPrinter.cpp.
Referenced by dispatchPrint(), mlir::function_interface_impl::printFunctionSignature(), printLaunchFuncOperands(), and printTokenOrdering().
|
protectedvirtual |
Pushes a new attribute or type in the form of a type erased pointer into an internal set.
Returns success if the type or attribute was inserted in the set or failure if it was already contained.
Definition at line 2878 of file AsmPrinter.cpp.
Referenced by tryStartCyclicPrint().
|
inline |
Attempts to start a cyclic printing region for attrOrType
.
A cyclic printing region starts with this call and ends with the destruction of the returned CyclicPrintReset
. During this time, calling tryStartCyclicPrint
with the same attribute in any printer will lead to returning failure.
This makes it possible to break infinite recursions when trying to print cyclic attributes or types by printing only immutable parameters if nested within itself.
Definition at line 275 of file OpImplementation.h.
References pushCyclicPrinting().
Referenced by print().