MLIR  20.0.0git
Public Member Functions | List of all members
mlir::OpAsmPrinter Class Referenceabstract

This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom print() method. More...

#include "mlir/IR/OpImplementation.h"

+ Inheritance diagram for mlir::OpAsmPrinter:

Public Member Functions

 ~OpAsmPrinter () override
 
virtual void printOptionalLocationSpecifier (Location loc)=0
 Print a loc(...) specifier if printing debug info is enabled. More...
 
virtual void printNewline ()=0
 Print a newline and indent the printer to the start of the current operation. More...
 
virtual void increaseIndent ()=0
 Increase indentation. More...
 
virtual void decreaseIndent ()=0
 Decrease indentation. More...
 
virtual void printRegionArgument (BlockArgument arg, ArrayRef< NamedAttribute > argAttrs={}, bool omitType=false)=0
 Print a block argument in the usual format of: ssaName : type {attr1=42} loc("here") where location printing is controlled by the standard internal option. More...
 
virtual void printOperand (Value value)=0
 Print implementations for various things an operation contains. More...
 
virtual void printOperand (Value value, raw_ostream &os)=0
 
template<typename ContainerType >
void printOperands (const ContainerType &container)
 Print a comma separated list of operands. More...
 
template<typename IteratorType >
void printOperands (IteratorType it, IteratorType end)
 Print a comma separated list of operands. More...
 
virtual void printSuccessor (Block *successor)=0
 Print the given successor. More...
 
virtual void printSuccessorAndUseList (Block *successor, ValueRange succOperands)=0
 Print the successor and its operands. More...
 
virtual void printOptionalAttrDict (ArrayRef< NamedAttribute > attrs, ArrayRef< StringRef > elidedAttrs={})=0
 If the specified operation has attributes, print out an attribute dictionary with their values. More...
 
virtual void printOptionalAttrDictWithKeyword (ArrayRef< NamedAttribute > attrs, ArrayRef< StringRef > elidedAttrs={})=0
 If the specified operation has attributes, print out an attribute dictionary prefixed with 'attributes'. More...
 
virtual void printCustomOrGenericOp (Operation *op)=0
 Prints the entire operation with the custom assembly form, if available, or the generic assembly form, otherwise. More...
 
virtual void printGenericOp (Operation *op, bool printOpName=true)=0
 Print the entire operation with the default generic assembly form. More...
 
virtual void printRegion (Region &blocks, bool printEntryBlockArgs=true, bool printBlockTerminators=true, bool printEmptyBlock=false)=0
 Prints a region. More...
 
virtual void shadowRegionArgs (Region &region, ValueRange namesToUse)=0
 Renumber the arguments for the specified region to the same names as the SSA values in namesToUse. More...
 
virtual void printAffineMapOfSSAIds (AffineMapAttr mapAttr, ValueRange operands)=0
 Prints an affine map of SSA ids, where SSA id names are used in place of dims/symbols. More...
 
virtual void printAffineExprOfSSAIds (AffineExpr expr, ValueRange dimOperands, ValueRange symOperands)=0
 Prints an affine expression of SSA ids with SSA id names used instead of dims and symbols. More...
 
void printFunctionalType (Operation *op)
 Print the complete type of an operation in functional form. More...
 
 AsmPrinter (Impl &impl)
 Initialize the printer with the given internal implementation. More...
 
 AsmPrinter ()=default
 Initialize the printer with no internal implementation. More...
 
template<typename InputRangeT , typename ResultRangeT >
void printFunctionalType (InputRangeT &&inputs, ResultRangeT &&results)
 Print the two given type ranges in a functional form. More...
 
- Public Member Functions inherited from mlir::AsmPrinter
 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< CyclicPrintResettryStartCyclicPrint (AttrOrTypeT attrOrType)
 Attempts to start a cyclic printing region for attrOrType. More...
 

Additional Inherited Members

- Public Types inherited from mlir::AsmPrinter
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 >
 
- Protected Member Functions inherited from mlir::AsmPrinter
 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...
 

Detailed Description

This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom print() method.

Definition at line 412 of file OpImplementation.h.

Constructor & Destructor Documentation

◆ ~OpAsmPrinter()

OpAsmPrinter::~OpAsmPrinter ( )
overridedefault

Member Function Documentation

◆ AsmPrinter() [1/2]

mlir::AsmPrinter::AsmPrinter
default

Initialize the printer with no internal implementation.

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

◆ AsmPrinter() [2/2]

mlir::AsmPrinter::AsmPrinter
inline

Initialize the printer with the given internal implementation.

Definition at line 113 of file OpImplementation.h.

◆ decreaseIndent()

virtual void mlir::OpAsmPrinter::decreaseIndent ( )
pure virtual

Decrease indentation.

Referenced by printForeachMatchSymbols().

◆ increaseIndent()

virtual void mlir::OpAsmPrinter::increaseIndent ( )
pure virtual

Increase indentation.

Referenced by printForeachMatchSymbols().

◆ printAffineExprOfSSAIds()

virtual void mlir::OpAsmPrinter::printAffineExprOfSSAIds ( AffineExpr  expr,
ValueRange  dimOperands,
ValueRange  symOperands 
)
pure virtual

Prints an affine expression of SSA ids with SSA id names used instead of dims and symbols.

Operand values must come from single-result sources, and be valid dimensions/symbol identifiers according to mlir::isValidDim/Symbol.

Referenced by printMinMaxBound().

◆ printAffineMapOfSSAIds()

virtual void mlir::OpAsmPrinter::printAffineMapOfSSAIds ( AffineMapAttr  mapAttr,
ValueRange  operands 
)
pure virtual

Prints an affine map of SSA ids, where SSA id names are used in place of dims/symbols.

Operand values must come from single-result sources, and be valid dimensions/symbol identifiers according to mlir::isValidDim/Symbol.

Referenced by mlir::affine::AffineDmaStartOp::print(), mlir::affine::AffineDmaWaitOp::print(), and printMinMaxBound().

◆ printCustomOrGenericOp()

virtual void mlir::OpAsmPrinter::printCustomOrGenericOp ( Operation op)
pure virtual

Prints the entire operation with the custom assembly form, if available, or the generic assembly form, otherwise.

◆ printFunctionalType() [1/2]

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

Print the two given type ranges in a functional form.

Definition at line 229 of file OpImplementation.h.

◆ printFunctionalType() [2/2]

void OpAsmPrinter::printFunctionalType ( Operation op)

◆ printGenericOp()

virtual void mlir::OpAsmPrinter::printGenericOp ( Operation op,
bool  printOpName = true 
)
pure virtual

Print the entire operation with the default generic assembly form.

If printOpName is true, then the operation name is printed (the default) otherwise it is omitted and the print will start with the operand list.

Referenced by mlir::OpState::print(), mlir::OperationName::UnregisteredOpModel::printAssembly(), and printOneResultOp().

◆ printNewline()

virtual void mlir::OpAsmPrinter::printNewline ( )
pure virtual

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

Referenced by printForeachMatchSymbols(), printSwitchCases(), and printSwitchOpCases().

◆ printOperand() [1/2]

virtual void mlir::OpAsmPrinter::printOperand ( Value  value)
pure virtual

Print implementations for various things an operation contains.

Referenced by mlir::operator<<(), mlir::affine::AffineDmaWaitOp::print(), printBound(), printGEPIndices(), printLaunchFuncOperands(), and printOperands().

◆ printOperand() [2/2]

virtual void mlir::OpAsmPrinter::printOperand ( Value  value,
raw_ostream &  os 
)
pure virtual

◆ printOperands() [1/2]

template<typename ContainerType >
void mlir::OpAsmPrinter::printOperands ( const ContainerType &  container)
inline

Print a comma separated list of operands.

Definition at line 445 of file OpImplementation.h.

Referenced by mlir::operator<<(), printArithmeticExtendedBinaryOp(), printOneOpBundle(), printOneResultOp(), printSequenceOpOperands(), and printTokenOrdering().

◆ printOperands() [2/2]

template<typename IteratorType >
void mlir::OpAsmPrinter::printOperands ( IteratorType  it,
IteratorType  end 
)
inline

Print a comma separated list of operands.

Definition at line 451 of file OpImplementation.h.

References mlir::AsmPrinter::getStream(), and printOperand().

◆ printOptionalAttrDict()

virtual void mlir::OpAsmPrinter::printOptionalAttrDict ( ArrayRef< NamedAttribute attrs,
ArrayRef< StringRef >  elidedAttrs = {} 
)
pure virtual

If the specified operation has attributes, print out an attribute dictionary with their values.

elidedAttrs allows the client to ignore specific well known attributes, commonly used if the attribute value is printed some other way (like as a fixed operand).

Referenced by mlir::OpState::genericPrintProperties(), printAffineMinMaxOp(), printArithmeticExtendedBinaryOp(), printAttributions(), mlir::function_interface_impl::printFunctionSignature(), printOneResultOp(), printShortForm(), printTransferAttrs(), and mlir::spirv::printVariableDecorations().

◆ printOptionalAttrDictWithKeyword()

virtual void mlir::OpAsmPrinter::printOptionalAttrDictWithKeyword ( ArrayRef< NamedAttribute attrs,
ArrayRef< StringRef >  elidedAttrs = {} 
)
pure virtual

If the specified operation has attributes, print out an attribute dictionary prefixed with 'attributes'.

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

◆ printOptionalLocationSpecifier()

virtual void mlir::OpAsmPrinter::printOptionalLocationSpecifier ( Location  loc)
pure virtual

Print a loc(...) specifier if printing debug info is enabled.

◆ printRegion()

virtual void mlir::OpAsmPrinter::printRegion ( Region blocks,
bool  printEntryBlockArgs = true,
bool  printBlockTerminators = true,
bool  printEmptyBlock = false 
)
pure virtual

Prints a region.

If 'printEntryBlockArgs' is false, the arguments of the block are not printed. If 'printBlockTerminator' is false, the terminator operation of the block is not printed. If printEmptyBlock is true, then the block header is printed even if the block is empty.

Referenced by printBlockArgRegion(), mlir::function_interface_impl::printFunctionOp(), printLoopControl(), printSingleBlockRegion(), and printSwitchCases().

◆ printRegionArgument()

virtual void mlir::OpAsmPrinter::printRegionArgument ( BlockArgument  arg,
ArrayRef< NamedAttribute argAttrs = {},
bool  omitType = false 
)
pure virtual

Print a block argument in the usual format of: ssaName : type {attr1=42} loc("here") where location printing is controlled by the standard internal option.

You may pass omitType=true to not print a type, and pass an empty attribute list if you don't care for attributes.

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

◆ printSuccessor()

virtual void mlir::OpAsmPrinter::printSuccessor ( Block successor)
pure virtual

Print the given successor.

Referenced by mlir::operator<<().

◆ printSuccessorAndUseList()

virtual void mlir::OpAsmPrinter::printSuccessorAndUseList ( Block successor,
ValueRange  succOperands 
)
pure virtual

Print the successor and its operands.

Referenced by printSwitchOpCases().

◆ shadowRegionArgs()

virtual void mlir::OpAsmPrinter::shadowRegionArgs ( Region region,
ValueRange  namesToUse 
)
pure virtual

Renumber the arguments for the specified region to the same names as the SSA values in namesToUse.

This may only be used for IsolatedFromAbove operations. If any entry in namesToUse is null, the corresponding argument name is left alone.


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