MLIR
20.0.0git
|
This class represents state from a parsed MLIR textual format string. More...
#include "mlir/AsmParser/AsmParserState.h"
Classes | |
struct | AttributeAliasDefinition |
This class represents the information for an attribute alias definition within the input file. More... | |
struct | BlockDefinition |
This class represents the information for a block definition within the input file. More... | |
struct | Impl |
struct | OperationDefinition |
This class represents the information for an operation definition within an input file. More... | |
struct | SMDefinition |
This class represents a definition within the source manager, containing it's defining location and locations of any uses. More... | |
struct | TypeAliasDefinition |
This class represents the information for type definition within the input file. More... | |
Public Types | |
using | BlockDefIterator = llvm::pointee_iterator< ArrayRef< std::unique_ptr< BlockDefinition > >::iterator > |
using | OperationDefIterator = llvm::pointee_iterator< ArrayRef< std::unique_ptr< OperationDefinition > >::iterator > |
using | AttributeDefIterator = llvm::pointee_iterator< ArrayRef< std::unique_ptr< AttributeAliasDefinition > >::iterator > |
using | TypeDefIterator = llvm::pointee_iterator< ArrayRef< std::unique_ptr< TypeAliasDefinition > >::iterator > |
Public Member Functions | |
AsmParserState () | |
~AsmParserState () | |
AsmParserState & | operator= (AsmParserState &&other) |
iterator_range< BlockDefIterator > | getBlockDefs () const |
Return a range of the BlockDefinitions held by the current parser state. More... | |
const BlockDefinition * | getBlockDef (Block *block) const |
Return the definition for the given block, or nullptr if the given block does not have a definition. More... | |
iterator_range< OperationDefIterator > | getOpDefs () const |
Return a range of the OperationDefinitions held by the current parser state. More... | |
const OperationDefinition * | getOpDef (Operation *op) const |
Return the definition for the given operation, or nullptr if the given operation does not have a definition. More... | |
iterator_range< AttributeDefIterator > | getAttributeAliasDefs () const |
Return a range of the AttributeAliasDefinitions held by the current parser state. More... | |
const AttributeAliasDefinition * | getAttributeAliasDef (StringRef name) const |
Return the definition for the given attribute alias, or nullptr if the given alias does not have a definition. More... | |
iterator_range< TypeDefIterator > | getTypeAliasDefs () const |
Return a range of the TypeAliasDefinitions held by the current parser state. More... | |
const TypeAliasDefinition * | getTypeAliasDef (StringRef name) const |
Return the definition for the given type alias, or nullptr if the given alias does not have a definition. More... | |
void | initialize (Operation *topLevelOp) |
Initialize the state in preparation for populating more parser state under the given top-level operation. More... | |
void | finalize (Operation *topLevelOp) |
Finalize any in-progress parser state under the given top-level operation. More... | |
void | startOperationDefinition (const OperationName &opName) |
Start a definition for an operation with the given name. More... | |
void | finalizeOperationDefinition (Operation *op, SMRange nameLoc, SMLoc endLoc, ArrayRef< std::pair< unsigned, SMLoc >> resultGroups=std::nullopt) |
Finalize the most recently started operation definition. More... | |
void | startRegionDefinition () |
Start a definition for a region nested under the current operation. More... | |
void | finalizeRegionDefinition () |
Finalize the most recently started region definition. More... | |
void | addDefinition (Block *block, SMLoc location) |
Add a definition of the given entity. More... | |
void | addDefinition (BlockArgument blockArg, SMLoc location) |
void | addAttrAliasDefinition (StringRef name, SMRange location, Attribute value) |
void | addTypeAliasDefinition (StringRef name, SMRange location, Type value) |
void | addUses (Value value, ArrayRef< SMLoc > locations) |
Add a source uses of the given value. More... | |
void | addUses (Block *block, ArrayRef< SMLoc > locations) |
void | addAttrAliasUses (StringRef name, SMRange locations) |
void | addTypeAliasUses (StringRef name, SMRange locations) |
void | addUses (SymbolRefAttr refAttr, ArrayRef< SMRange > refLocations) |
Add source uses for all the references nested under refAttr . More... | |
void | refineDefinition (Value oldValue, Value newValue) |
Refine the oldValue to the newValue . More... | |
Static Public Member Functions | |
static SMRange | convertIdLocToRange (SMLoc loc) |
Returns (heuristically) the range of an identifier given a SMLoc corresponding to the start of an identifier location. More... | |
This class represents state from a parsed MLIR textual format string.
It is useful for building additional analysis and language utilities on top of textual MLIR. This should generally not be used for traditional compilation.
Definition at line 29 of file AsmParserState.h.
using mlir::AsmParserState::AttributeDefIterator = llvm::pointee_iterator< ArrayRef<std::unique_ptr<AttributeAliasDefinition> >::iterator> |
Definition at line 141 of file AsmParserState.h.
using mlir::AsmParserState::BlockDefIterator = llvm::pointee_iterator< ArrayRef<std::unique_ptr<BlockDefinition> >::iterator> |
Definition at line 137 of file AsmParserState.h.
using mlir::AsmParserState::OperationDefIterator = llvm::pointee_iterator< ArrayRef<std::unique_ptr<OperationDefinition> >::iterator> |
Definition at line 139 of file AsmParserState.h.
using mlir::AsmParserState::TypeDefIterator = llvm::pointee_iterator< ArrayRef<std::unique_ptr<TypeAliasDefinition> >::iterator> |
Definition at line 143 of file AsmParserState.h.
AsmParserState::AsmParserState | ( | ) |
Definition at line 113 of file AsmParserState.cpp.
|
default |
void AsmParserState::addAttrAliasDefinition | ( | StringRef | name, |
SMRange | location, | ||
Attribute | value | ||
) |
Definition at line 317 of file AsmParserState.cpp.
References mlir::AsmParserState::AttributeAliasDefinition::definition, mlir::AsmParserState::SMDefinition::loc, and mlir::AsmParserState::AttributeAliasDefinition::value.
void AsmParserState::addAttrAliasUses | ( | StringRef | name, |
SMRange | locations | ||
) |
Definition at line 404 of file AsmParserState.cpp.
References mlir::AsmParserState::AttributeAliasDefinition::definition, and mlir::AsmParserState::SMDefinition::uses.
Referenced by parseExtendedSymbol().
void AsmParserState::addDefinition | ( | Block * | block, |
SMLoc | location | ||
) |
Add a definition of the given entity.
Definition at line 291 of file AsmParserState.cpp.
References convertIdLocToRange().
void AsmParserState::addDefinition | ( | BlockArgument | blockArg, |
SMLoc | location | ||
) |
Definition at line 305 of file AsmParserState.cpp.
References mlir::AsmParserState::BlockDefinition::arguments, convertIdLocToRange(), mlir::BlockArgument::getArgNumber(), and mlir::BlockArgument::getOwner().
void AsmParserState::addTypeAliasDefinition | ( | StringRef | name, |
SMRange | location, | ||
Type | value | ||
) |
Definition at line 332 of file AsmParserState.cpp.
void AsmParserState::addTypeAliasUses | ( | StringRef | name, |
SMRange | locations | ||
) |
Definition at line 416 of file AsmParserState.cpp.
References mlir::AsmParserState::TypeAliasDefinition::definition, and mlir::AsmParserState::SMDefinition::uses.
Referenced by parseExtendedSymbol().
Definition at line 381 of file AsmParserState.cpp.
References convertIdLocToRange(), mlir::AsmParserState::BlockDefinition::definition, and mlir::AsmParserState::SMDefinition::uses.
void AsmParserState::addUses | ( | SymbolRefAttr | refAttr, |
ArrayRef< SMRange > | refLocations | ||
) |
Add source uses for all the references nested under refAttr
.
The provided locations
should match 1-1 with the number of references in refAttr
, i.e.: nestedReferences.size() + /*leafReference=*/1 == refLocations.size()
Definition at line 392 of file AsmParserState.cpp.
Add a source uses of the given value.
Definition at line 341 of file AsmParserState.cpp.
References mlir::AsmParserState::BlockDefinition::arguments, convertIdLocToRange(), mlir::BlockArgument::getArgNumber(), mlir::BlockArgument::getOwner(), mlir::AsmParserState::OperationDefinition::resultGroups, and mlir::AsmParserState::SMDefinition::uses.
Referenced by mlir::detail::Parser::parseAttribute(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalSymbolName(), and refineDefinition().
|
static |
Returns (heuristically) the range of an identifier given a SMLoc corresponding to the start of an identifier location.
Definition at line 194 of file AsmParserState.cpp.
References lexLocStringTok().
Referenced by addDefinition(), addUses(), and finalizeOperationDefinition().
void AsmParserState::finalize | ( | Operation * | topLevelOp | ) |
Finalize any in-progress parser state under the given top-level operation.
Definition at line 229 of file AsmParserState.cpp.
References mlir::AsmParserState::Impl::PartialOpDef::isSymbolTable(), and mlir::AsmParserState::Impl::PartialOpDef::symbolTable.
void AsmParserState::finalizeOperationDefinition | ( | Operation * | op, |
SMRange | nameLoc, | ||
SMLoc | endLoc, | ||
ArrayRef< std::pair< unsigned, SMLoc >> | resultGroups = std::nullopt |
||
) |
Finalize the most recently started operation definition.
Definition at line 246 of file AsmParserState.cpp.
References convertIdLocToRange(), mlir::AsmParserState::Impl::PartialOpDef::isSymbolTable(), and mlir::AsmParserState::Impl::PartialOpDef::symbolTable.
void AsmParserState::finalizeRegionDefinition | ( | ) |
Finalize the most recently started region definition.
Definition at line 280 of file AsmParserState.cpp.
References mlir::AsmParserState::Impl::PartialOpDef::isSymbolTable().
auto AsmParserState::getAttributeAliasDef | ( | StringRef | name | ) | const |
Return the definition for the given attribute alias, or nullptr if the given alias does not have a definition.
Definition at line 149 of file AsmParserState.cpp.
auto AsmParserState::getAttributeAliasDefs | ( | ) | const |
Return a range of the AttributeAliasDefinitions held by the current parser state.
Definition at line 144 of file AsmParserState.cpp.
auto AsmParserState::getBlockDef | ( | Block * | block | ) | const |
Return the definition for the given block, or nullptr if the given block does not have a definition.
Definition at line 127 of file AsmParserState.cpp.
auto AsmParserState::getBlockDefs | ( | ) | const |
Return a range of the BlockDefinitions held by the current parser state.
Definition at line 123 of file AsmParserState.cpp.
auto AsmParserState::getOpDef | ( | Operation * | op | ) | const |
Return the definition for the given operation, or nullptr if the given operation does not have a definition.
Definition at line 137 of file AsmParserState.cpp.
auto AsmParserState::getOpDefs | ( | ) | const |
Return a range of the OperationDefinitions held by the current parser state.
Definition at line 133 of file AsmParserState.cpp.
auto AsmParserState::getTypeAliasDef | ( | StringRef | name | ) | const |
Return the definition for the given type alias, or nullptr if the given alias does not have a definition.
Definition at line 161 of file AsmParserState.cpp.
auto AsmParserState::getTypeAliasDefs | ( | ) | const |
Return a range of the TypeAliasDefinitions held by the current parser state.
Definition at line 156 of file AsmParserState.cpp.
void AsmParserState::initialize | ( | Operation * | topLevelOp | ) |
Initialize the state in preparation for populating more parser state under the given top-level operation.
Definition at line 220 of file AsmParserState.cpp.
References mlir::Operation::getName(), mlir::AsmParserState::Impl::PartialOpDef::isSymbolTable(), startOperationDefinition(), and mlir::AsmParserState::Impl::PartialOpDef::symbolTable.
AsmParserState & AsmParserState::operator= | ( | AsmParserState && | other | ) |
Definition at line 115 of file AsmParserState.cpp.
Refine the oldValue
to the newValue
.
This is used to indicate that oldValue
was a placeholder, and the uses of it should really refer to newValue
.
Definition at line 425 of file AsmParserState.cpp.
References addUses().
void AsmParserState::startOperationDefinition | ( | const OperationName & | opName | ) |
Start a definition for an operation with the given name.
Definition at line 242 of file AsmParserState.cpp.
Referenced by initialize().
void AsmParserState::startRegionDefinition | ( | ) |
Start a definition for a region nested under the current operation.
Definition at line 269 of file AsmParserState.cpp.
References mlir::AsmParserState::Impl::PartialOpDef::isSymbolTable(), and mlir::AsmParserState::Impl::PartialOpDef::symbolTable.