MLIR 22.0.0git
mlir::AsmState Class Reference

This class provides management for the lifetime of the state used when printing the IR. More...

#include "mlir/IR/AsmState.h"

Public Types

using LocationMap = DenseMap<Operation *, std::pair<unsigned, unsigned>>
 This map represents the raw locations of operations within the output stream.

Public Member Functions

 AsmState (Operation *op, const OpPrintingFlags &printerFlags=OpPrintingFlags(), LocationMap *locationMap=nullptr, FallbackAsmResourceMap *map=nullptr)
 Initialize the asm state at the level of the given operation.
 AsmState (MLIRContext *ctx, const OpPrintingFlags &printerFlags=OpPrintingFlags(), LocationMap *locationMap=nullptr, FallbackAsmResourceMap *map=nullptr)
 ~AsmState ()
const OpPrintingFlagsgetPrinterFlags () const
 Get the printer flags.
detail::AsmStateImplgetImpl ()
 Return an instance of the internal implementation.
void attachResourcePrinter (std::unique_ptr< AsmResourcePrinter > printer)
 Attach the given resource printer to the AsmState.
template<typename CallableT>
std::enable_if_t< std::is_convertible< CallableT, function_ref< void(Operation *, AsmResourceBuilder &)> >::value > attachResourcePrinter (StringRef name, CallableT &&printFn)
 Attach an resource printer, in the form of a callable, to the AsmState.
void attachFallbackResourcePrinter (FallbackAsmResourceMap &map)
 Attach resource printers to the AsmState for the fallback resources in the given map.
DenseMap< Dialect *, SetVector< AsmDialectResourceHandle > > & getDialectResources () const
 Returns a map of dialect resources that were referenced when using this state to print IR.

Detailed Description

This class provides management for the lifetime of the state used when printing the IR.

It allows for alleviating the cost of recomputing the internal state of the asm printer.

The IR should not be mutated in-between invocations using this state, and the IR being printed must not be an parent of the IR originally used to initialize this state. This means that if a child operation is provided, a parent operation cannot reuse this state.

Definition at line 542 of file AsmState.h.

Member Typedef Documentation

◆ LocationMap

This map represents the raw locations of operations within the output stream.

This maps the original pointer to the operation, to a pair of line and column in the output stream.

Definition at line 547 of file AsmState.h.

Constructor & Destructor Documentation

◆ AsmState() [1/2]

AsmState::AsmState ( Operation * op,
const OpPrintingFlags & printerFlags = OpPrintingFlags(),
LocationMap * locationMap = nullptr,
FallbackAsmResourceMap * map = nullptr )

Initialize the asm state at the level of the given operation.

A location map may optionally be provided to be populated when printing. map is an optional fallback resource map, which when provided will attach resource printers for the fallback resources within the map.

Definition at line 2081 of file AsmPrinter.cpp.

References attachFallbackResourcePrinter(), and verifyOpAndAdjustFlags().

◆ AsmState() [2/2]

AsmState::AsmState ( MLIRContext * ctx,
const OpPrintingFlags & printerFlags = OpPrintingFlags(),
LocationMap * locationMap = nullptr,
FallbackAsmResourceMap * map = nullptr )

Definition at line 2088 of file AsmPrinter.cpp.

References attachFallbackResourcePrinter().

◆ ~AsmState()

AsmState::~AsmState ( )
default

Member Function Documentation

◆ attachFallbackResourcePrinter()

void mlir::AsmState::attachFallbackResourcePrinter ( FallbackAsmResourceMap & map)
inline

Attach resource printers to the AsmState for the fallback resources in the given map.

Definition at line 588 of file AsmState.h.

References attachResourcePrinter(), and mlir::FallbackAsmResourceMap::getPrinters().

Referenced by AsmState(), and AsmState().

◆ attachResourcePrinter() [1/2]

void AsmState::attachResourcePrinter ( std::unique_ptr< AsmResourcePrinter > printer)

Attach the given resource printer to the AsmState.

Definition at line 2100 of file AsmPrinter.cpp.

Referenced by appendReproducer(), attachFallbackResourcePrinter(), and attachResourcePrinter().

◆ attachResourcePrinter() [2/2]

template<typename CallableT>
std::enable_if_t< std::is_convertible< CallableT, function_ref< void(Operation *, AsmResourceBuilder &)> >::value > mlir::AsmState::attachResourcePrinter ( StringRef name,
CallableT && printFn )
inline

Attach an resource printer, in the form of a callable, to the AsmState.

Definition at line 581 of file AsmState.h.

References attachResourcePrinter(), and mlir::AsmResourcePrinter::fromCallable().

◆ getDialectResources()

DenseMap< Dialect *, SetVector< AsmDialectResourceHandle > > & AsmState::getDialectResources ( ) const

Returns a map of dialect resources that were referenced when using this state to print IR.

Definition at line 2106 of file AsmPrinter.cpp.

◆ getImpl()

detail::AsmStateImpl & mlir::AsmState::getImpl ( )
inline

◆ getPrinterFlags()

const OpPrintingFlags & AsmState::getPrinterFlags ( ) const

Get the printer flags.

Definition at line 2096 of file AsmPrinter.cpp.

Referenced by mlir::Operation::print().


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