MLIR
20.0.0git
|
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, FallbackAsmResourceMap *map=nullptr) | |
Initialize the asm state at the level of the given operation. More... | |
AsmState (MLIRContext *ctx, const OpPrintingFlags &printerFlags=OpPrintingFlags(), LocationMap *locationMap=nullptr, FallbackAsmResourceMap *map=nullptr) | |
~AsmState () | |
const OpPrintingFlags & | getPrinterFlags () const |
Get the printer flags. More... | |
detail::AsmStateImpl & | getImpl () |
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 &)> >::value > | attachResourcePrinter (StringRef name, CallableT &&printFn) |
Attach an resource printer, in the form of a callable, to the AsmState. More... | |
void | attachFallbackResourcePrinter (FallbackAsmResourceMap &map) |
Attach resource printers to the AsmState for the fallback resources in the given map. More... | |
DenseMap< Dialect *, SetVector< AsmDialectResourceHandle > > & | getDialectResources () const |
Returns a map of dialect resources that were referenced when using this state to print IR. More... | |
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 540 of file AsmState.h.
using mlir::AsmState::LocationMap = DenseMap<Operation *, std::pair<unsigned, unsigned> > |
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 545 of file AsmState.h.
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 1951 of file AsmPrinter.cpp.
AsmState::AsmState | ( | MLIRContext * | ctx, |
const OpPrintingFlags & | printerFlags = OpPrintingFlags() , |
||
LocationMap * | locationMap = nullptr , |
||
FallbackAsmResourceMap * | map = nullptr |
||
) |
Definition at line 1958 of file AsmPrinter.cpp.
References attachFallbackResourcePrinter().
|
default |
|
inline |
Attach resource printers to the AsmState for the fallback resources in the given map.
Definition at line 586 of file AsmState.h.
References attachResourcePrinter(), and mlir::FallbackAsmResourceMap::getPrinters().
Referenced by AsmState().
void AsmState::attachResourcePrinter | ( | std::unique_ptr< AsmResourcePrinter > | printer | ) |
Attach the given resource printer to the AsmState.
Definition at line 1970 of file AsmPrinter.cpp.
Referenced by attachFallbackResourcePrinter(), and attachResourcePrinter().
|
inline |
Attach an resource printer, in the form of a callable, to the AsmState.
Definition at line 579 of file AsmState.h.
References attachResourcePrinter(), and mlir::AsmResourcePrinter::fromCallable().
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 1976 of file AsmPrinter.cpp.
|
inline |
Return an instance of the internal implementation.
Returns nullptr if the state has not been initialized.
Definition at line 566 of file AsmState.h.
const OpPrintingFlags & AsmState::getPrinterFlags | ( | ) | const |
Get the printer flags.
Definition at line 1966 of file AsmPrinter.cpp.