MLIR  16.0.0git
Public Types | Public Member Functions | List of all members
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. More...
 

Public Member Functions

 AsmState (Operation *op, const OpPrintingFlags &printerFlags=OpPrintingFlags(), LocationMap *locationMap=nullptr)
 Initialize the asm state at the level of the given operation. More...
 
 ~AsmState ()
 
const OpPrintingFlagsgetPrinterFlags () const
 Get the printer flags. More...
 
detail::AsmStateImplgetImpl ()
 Return an instance of the internal implementation. More...
 
void attachResourcePrinter (std::unique_ptr< AsmResourcePrinter > printer)
 Attach the given resource printer to the AsmState. More...
 
template<typename CallableT >
std::enable_if_t< std::is_convertible< CallableT, function_ref< void(Operation *, AsmResourceBuilder &)> >::valueattachResourcePrinter (StringRef name, CallableT &&printFn)
 Attach an resource printer, in the form of a callable, to the AsmState. More...
 

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 446 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 451 of file AsmState.h.

Constructor & Destructor Documentation

◆ AsmState()

AsmState::AsmState ( Operation op,
const OpPrintingFlags printerFlags = OpPrintingFlags(),
LocationMap locationMap = nullptr 
)

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

A location map may optionally be provided to be populated when printing.

Definition at line 1378 of file AsmPrinter.cpp.

References ~AsmState().

◆ ~AsmState()

AsmState::~AsmState ( )
default

Referenced by AsmState().

Member Function Documentation

◆ attachResourcePrinter() [1/2]

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

Attach the given resource printer to the AsmState.

Definition at line 1388 of file AsmPrinter.cpp.

Referenced by mlir::detail::RecoveryReproducerContext::generate().

◆ 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 478 of file AsmState.h.

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

◆ getImpl()

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

Return an instance of the internal implementation.

Returns nullptr if the state has not been initialized.

Definition at line 465 of file AsmState.h.

References value.

Referenced by mlir::Operation::print(), mlir::Block::print(), mlir::Value::printAsOperand(), and mlir::Block::printAsOperand().

◆ getPrinterFlags()

const OpPrintingFlags & AsmState::getPrinterFlags ( ) const

Get the printer flags.

Definition at line 1384 of file AsmPrinter.cpp.

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


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