MLIR 22.0.0git
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
using OperationDefIterator
using AttributeDefIterator
using TypeDefIterator

Public Member Functions

 AsmParserState ()
 ~AsmParserState ()
AsmParserStateoperator= (AsmParserState &&other)
iterator_range< BlockDefIteratorgetBlockDefs () const
 Return a range of the BlockDefinitions held by the current parser state.
const BlockDefinitiongetBlockDef (Block *block) const
 Return the definition for the given block, or nullptr if the given block does not have a definition.
iterator_range< OperationDefIteratorgetOpDefs () const
 Return a range of the OperationDefinitions held by the current parser state.
const OperationDefinitiongetOpDef (Operation *op) const
 Return the definition for the given operation, or nullptr if the given operation does not have a definition.
iterator_range< AttributeDefIteratorgetAttributeAliasDefs () const
 Return a range of the AttributeAliasDefinitions held by the current parser state.
const AttributeAliasDefinitiongetAttributeAliasDef (StringRef name) const
 Return the definition for the given attribute alias, or nullptr if the given alias does not have a definition.
iterator_range< TypeDefIteratorgetTypeAliasDefs () const
 Return a range of the TypeAliasDefinitions held by the current parser state.
const TypeAliasDefinitiongetTypeAliasDef (StringRef name) const
 Return the definition for the given type alias, or nullptr if the given alias does not have a definition.
void initialize (Operation *topLevelOp)
 Initialize the state in preparation for populating more parser state under the given top-level operation.
void finalize (Operation *topLevelOp)
 Finalize any in-progress parser state under the given top-level operation.
void startOperationDefinition (const OperationName &opName)
 Start a definition for an operation with the given name.
void finalizeOperationDefinition (Operation *op, SMRange nameLoc, SMLoc endLoc, ArrayRef< std::pair< unsigned, SMLoc > > resultGroups={})
 Finalize the most recently started operation definition.
void startRegionDefinition ()
 Start a definition for a region nested under the current operation.
void finalizeRegionDefinition ()
 Finalize the most recently started region definition.
void addDefinition (Block *block, SMLoc location)
 Add a definition of the given entity.
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.
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.
void refineDefinition (Value oldValue, Value newValue)
 Refine the oldValue to the newValue.

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.

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

Initial value:
llvm::pointee_iterator<

Definition at line 141 of file AsmParserState.h.

◆ BlockDefIterator

Initial value:
llvm::pointee_iterator<

Definition at line 137 of file AsmParserState.h.

◆ OperationDefIterator

Initial value:
llvm::pointee_iterator<

Definition at line 139 of file AsmParserState.h.

◆ TypeDefIterator

Initial value:
llvm::pointee_iterator<

Definition at line 143 of file AsmParserState.h.

Constructor & Destructor Documentation

◆ AsmParserState()

AsmParserState::AsmParserState ( )

Definition at line 113 of file AsmParserState.cpp.

Referenced by operator=(), and ~AsmParserState().

◆ ~AsmParserState()

AsmParserState::~AsmParserState ( )
default

References AsmParserState().

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

References convertIdLocToRange(), and inserted().

◆ addDefinition() [2/2]

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

◆ addTypeAliasDefinition()

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

Definition at line 334 of file AsmParserState.cpp.

References inserted().

◆ 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]

◆ 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(), addDefinition(), addUses(), addUses(), and finalizeOperationDefinition().

◆ finalize()

void AsmParserState::finalize ( Operation * topLevelOp)

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

Definition at line 231 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 = {} )

Finalize the most recently started operation definition.

Definition at line 248 of file AsmParserState.cpp.

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

◆ finalizeRegionDefinition()

void AsmParserState::finalizeRegionDefinition ( )

Finalize the most recently started region definition.

Definition at line 282 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.

References nullptr.

◆ 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.

References nullptr.

◆ 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.

References nullptr.

◆ 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.

References nullptr.

◆ 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 222 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 115 of file AsmParserState.cpp.

References AsmParserState().

◆ 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 244 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 271 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: