MLIR  16.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  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...
 

Public Types

using BlockDefIterator = llvm::pointee_iterator< ArrayRef< std::unique_ptr< BlockDefinition > >::iterator >
 
using OperationDefIterator = llvm::pointee_iterator< ArrayRef< std::unique_ptr< OperationDefinition > >::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...
 
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=llvm::None)
 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 addUses (Value value, ArrayRef< SMLoc > locations)
 Add a source uses of the given value. More...
 
void addUses (Block *block, ArrayRef< SMLoc > locations)
 
void refineDefinition (Value oldValue, Value newValue)
 Add source uses for all the references nested under refAttr. 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 30 of file AsmParserState.h.

Member Typedef Documentation

◆ BlockDefIterator

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

Definition at line 106 of file AsmParserState.h.

◆ OperationDefIterator

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

Definition at line 108 of file AsmParserState.h.

Constructor & Destructor Documentation

◆ AsmParserState()

AsmParserState::AsmParserState ( )

Definition at line 94 of file AsmParserState.cpp.

References ~AsmParserState().

◆ ~AsmParserState()

AsmParserState::~AsmParserState ( )
default

Referenced by AsmParserState().

Member Function Documentation

◆ addDefinition() [1/2]

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

Add a definition of the given entity.

Definition at line 248 of file AsmParserState.cpp.

References convertIdLocToRange().

◆ addDefinition() [2/2]

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

◆ addUses() [1/2]

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

◆ addUses() [2/2]

void AsmParserState::addUses ( Block block,
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 151 of file AsmParserState.cpp.

References lexLocStringTok().

Referenced by addDefinition(), addUses(), and finalizeOperationDefinition().

◆ finalize()

void AsmParserState::finalize ( Operation topLevelOp)

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

Definition at line 186 of file AsmParserState.cpp.

Referenced by mlir::detail::Parser::codeCompleteDialectSymbol().

◆ finalizeOperationDefinition()

void AsmParserState::finalizeOperationDefinition ( Operation op,
SMRange  nameLoc,
SMLoc  endLoc,
ArrayRef< std::pair< unsigned, SMLoc >>  resultGroups = llvm::None 
)

Finalize the most recently started operation definition.

Definition at line 203 of file AsmParserState.cpp.

References convertIdLocToRange().

Referenced by mlir::detail::Parser::codeCompleteDialectSymbol().

◆ finalizeRegionDefinition()

void AsmParserState::finalizeRegionDefinition ( )

Finalize the most recently started region definition.

Definition at line 237 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 108 of file AsmParserState.cpp.

◆ getBlockDefs()

auto AsmParserState::getBlockDefs ( ) const

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

Definition at line 104 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 118 of file AsmParserState.cpp.

◆ getOpDefs()

auto AsmParserState::getOpDefs ( ) const

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

Definition at line 114 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 177 of file AsmParserState.cpp.

References mlir::Operation::getName(), and startOperationDefinition().

Referenced by mlir::detail::Parser::codeCompleteDialectSymbol().

◆ operator=()

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

Definition at line 96 of file AsmParserState.cpp.

◆ refineDefinition()

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

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

References addUses().

Referenced by mlir::detail::Parser::codeCompleteDialectSymbol().

◆ startOperationDefinition()

void AsmParserState::startOperationDefinition ( const OperationName opName)

Start a definition for an operation with the given name.

Definition at line 199 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 226 of file AsmParserState.cpp.


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