MLIR  19.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
mlir::AsmParserState Class Reference

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 ()
 
AsmParserStateoperator= (AsmParserState &&other)
 
iterator_range< BlockDefIteratorgetBlockDefs () const
 Return a range of the BlockDefinitions held by the current parser state. More...
 
const BlockDefinitiongetBlockDef (Block *block) const
 Return the definition for the given block, or nullptr if the given block does not have a definition. More...
 
iterator_range< OperationDefIteratorgetOpDefs () const
 Return a range of the OperationDefinitions held by the current parser state. More...
 
const OperationDefinitiongetOpDef (Operation *op) const
 Return the definition for the given operation, or nullptr if the given operation does not have a definition. More...
 
iterator_range< AttributeDefIteratorgetAttributeAliasDefs () const
 Return a range of the AttributeAliasDefinitions held by the current parser state. More...
 
const AttributeAliasDefinitiongetAttributeAliasDef (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< TypeDefIteratorgetTypeAliasDefs () const
 Return a range of the TypeAliasDefinitions held by the current parser state. More...
 
const TypeAliasDefinitiongetTypeAliasDef (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...
 

Detailed Description

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.

Member Typedef Documentation

◆ AttributeDefIterator

using mlir::AsmParserState::AttributeDefIterator = llvm::pointee_iterator< ArrayRef<std::unique_ptr<AttributeAliasDefinition> >::iterator>

Definition at line 141 of file AsmParserState.h.

◆ BlockDefIterator

using mlir::AsmParserState::BlockDefIterator = llvm::pointee_iterator< ArrayRef<std::unique_ptr<BlockDefinition> >::iterator>

Definition at line 137 of file AsmParserState.h.

◆ OperationDefIterator

using mlir::AsmParserState::OperationDefIterator = llvm::pointee_iterator< ArrayRef<std::unique_ptr<OperationDefinition> >::iterator>

Definition at line 139 of file AsmParserState.h.

◆ TypeDefIterator

using mlir::AsmParserState::TypeDefIterator = llvm::pointee_iterator< ArrayRef<std::unique_ptr<TypeAliasDefinition> >::iterator>

Definition at line 143 of file AsmParserState.h.

Constructor & Destructor Documentation

◆ AsmParserState()

AsmParserState::AsmParserState ( )

Definition at line 114 of file AsmParserState.cpp.

◆ ~AsmParserState()

AsmParserState::~AsmParserState ( )
default

Member Function Documentation

◆ addAttrAliasDefinition()

void AsmParserState::addAttrAliasDefinition ( StringRef  name,
SMRange  location,
Attribute  value 
)

◆ addAttrAliasUses()

void AsmParserState::addAttrAliasUses ( StringRef  name,
SMRange  locations 
)

◆ addDefinition() [1/2]

void AsmParserState::addDefinition ( Block block,
SMLoc  location 
)

Add a definition of the given entity.

Definition at line 292 of file AsmParserState.cpp.

References convertIdLocToRange().

◆ addDefinition() [2/2]

void AsmParserState::addDefinition ( BlockArgument  blockArg,
SMLoc  location 
)

◆ addTypeAliasDefinition()

void AsmParserState::addTypeAliasDefinition ( StringRef  name,
SMRange  location,
Type  value 
)

Definition at line 333 of file AsmParserState.cpp.

◆ addTypeAliasUses()

void AsmParserState::addTypeAliasUses ( StringRef  name,
SMRange  locations 
)

◆ addUses() [1/3]

void AsmParserState::addUses ( Block block,
ArrayRef< SMLoc >  locations 
)

◆ addUses() [2/3]

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 394 of file AsmParserState.cpp.

◆ addUses() [3/3]

void AsmParserState::addUses ( Value  value,
ArrayRef< SMLoc >  locations 
)

◆ convertIdLocToRange()

SMRange AsmParserState::convertIdLocToRange ( SMLoc  loc)
static

Returns (heuristically) the range of an identifier given a SMLoc corresponding to the start of an identifier location.

Definition at line 195 of file AsmParserState.cpp.

References lexLocStringTok().

Referenced by addDefinition(), and addUses().

◆ finalize()

void AsmParserState::finalize ( Operation topLevelOp)

Finalize any in-progress parser state under the given top-level operation.

Definition at line 230 of file AsmParserState.cpp.

References mlir::AsmParserState::Impl::PartialOpDef::isSymbolTable(), and mlir::AsmParserState::Impl::PartialOpDef::symbolTable.

◆ finalizeOperationDefinition()

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 247 of file AsmParserState.cpp.

◆ finalizeRegionDefinition()

void AsmParserState::finalizeRegionDefinition ( )

Finalize the most recently started region definition.

Definition at line 281 of file AsmParserState.cpp.

References mlir::AsmParserState::Impl::PartialOpDef::isSymbolTable().

◆ getAttributeAliasDef()

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 150 of file AsmParserState.cpp.

◆ getAttributeAliasDefs()

auto AsmParserState::getAttributeAliasDefs ( ) const

Return a range of the AttributeAliasDefinitions held by the current parser state.

Definition at line 145 of file AsmParserState.cpp.

◆ getBlockDef()

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 128 of file AsmParserState.cpp.

◆ getBlockDefs()

auto AsmParserState::getBlockDefs ( ) const

Return a range of the BlockDefinitions held by the current parser state.

Definition at line 124 of file AsmParserState.cpp.

◆ getOpDef()

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 138 of file AsmParserState.cpp.

◆ getOpDefs()

auto AsmParserState::getOpDefs ( ) const

Return a range of the OperationDefinitions held by the current parser state.

Definition at line 134 of file AsmParserState.cpp.

◆ getTypeAliasDef()

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 162 of file AsmParserState.cpp.

◆ getTypeAliasDefs()

auto AsmParserState::getTypeAliasDefs ( ) const

Return a range of the TypeAliasDefinitions held by the current parser state.

Definition at line 157 of file AsmParserState.cpp.

◆ initialize()

void AsmParserState::initialize ( Operation topLevelOp)

Initialize the state in preparation for populating more parser state under the given top-level operation.

Definition at line 221 of file AsmParserState.cpp.

References mlir::Operation::getName(), mlir::AsmParserState::Impl::PartialOpDef::isSymbolTable(), startOperationDefinition(), and mlir::AsmParserState::Impl::PartialOpDef::symbolTable.

◆ operator=()

AsmParserState & AsmParserState::operator= ( AsmParserState &&  other)

Definition at line 116 of file AsmParserState.cpp.

◆ refineDefinition()

void AsmParserState::refineDefinition ( Value  oldValue,
Value  newValue 
)

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 427 of file AsmParserState.cpp.

References addUses().

◆ startOperationDefinition()

void AsmParserState::startOperationDefinition ( const OperationName opName)

Start a definition for an operation with the given name.

Definition at line 243 of file AsmParserState.cpp.

Referenced by initialize().

◆ startRegionDefinition()

void AsmParserState::startRegionDefinition ( )

Start a definition for a region nested under the current operation.

Definition at line 270 of file AsmParserState.cpp.

References mlir::AsmParserState::Impl::PartialOpDef::isSymbolTable(), and mlir::AsmParserState::Impl::PartialOpDef::symbolTable.


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