MLIR  19.0.0git
Public Member Functions | List of all members
mlir::sparse_tensor::ir_detail::VarEnv Class Referencefinal

#include "Dialect/SparseTensor/IR/Detail/Var.h"

Public Member Functions

 VarEnv ()
 
VarInfo const & access (VarInfo::ID id) const
 Gets the underlying storage for the VarInfo identified by the VarInfo::ID. More...
 
VarInfo const * access (std::optional< VarInfo::ID > oid) const
 
std::optional< VarInfo::IDlookup (StringRef name) const
 Looks up the variable with the given name. More...
 
std::optional< std::pair< VarInfo::ID, bool > > create (StringRef name, llvm::SMLoc loc, VarKind vk, bool verifyUsage=false)
 Creates a new currently-unbound variable. More...
 
std::optional< std::pair< VarInfo::ID, bool > > lookupOrCreate (Policy creationPolicy, StringRef name, llvm::SMLoc loc, VarKind vk)
 Looks up or creates a variable according to the given Policy. More...
 
Var bindVar (VarInfo::ID id)
 Binds the given variable to the next free Var::Num for its VarKind. More...
 
Var bindUnusedVar (VarKind vk)
 Creates a new variable of the given kind and immediately binds it. More...
 
InFlightDiagnostic emitErrorIfAnyUnbound (AsmParser &parser) const
 
Ranks getRanks () const
 Returns the current ranks of bound variables. More...
 
Var getVar (VarInfo::ID id) const
 Gets the Var identified by the VarInfo::ID, raising an assertion failure if the variable is not bound. More...
 

Detailed Description

Definition at line 318 of file Var.h.

Constructor & Destructor Documentation

◆ VarEnv()

mlir::sparse_tensor::ir_detail::VarEnv::VarEnv ( )
inline

Definition at line 329 of file Var.h.

Member Function Documentation

◆ access() [1/2]

VarInfo const* mlir::sparse_tensor::ir_detail::VarEnv::access ( std::optional< VarInfo::ID oid) const
inline

Definition at line 342 of file Var.h.

References access().

◆ access() [2/2]

VarInfo const& mlir::sparse_tensor::ir_detail::VarEnv::access ( VarInfo::ID  id) const
inline

Gets the underlying storage for the VarInfo identified by the VarInfo::ID.

NOTE: The returned reference can become dangling if the VarEnv object is mutated during the lifetime of the pointer. Therefore, client code should not store the reference nor otherwise allow it to live too long.

Definition at line 338 of file Var.h.

Referenced by access(), bindVar(), getVar(), isInternalConsistent(), and isUsageConsistent().

◆ bindUnusedVar()

Var VarEnv::bindUnusedVar ( VarKind  vk)

Creates a new variable of the given kind and immediately binds it.

This should only be used whenever the variable is known to be unused and therefore does not have a name.

Definition at line 221 of file Var.cpp.

Referenced by bindVar().

◆ bindVar()

Var VarEnv::bindVar ( VarInfo::ID  id)

Binds the given variable to the next free Var::Num for its VarKind.

Definition at line 222 of file Var.cpp.

References access(), and bindUnusedVar().

◆ create()

std::optional< std::pair< VarInfo::ID, bool > > VarEnv::create ( StringRef  name,
llvm::SMLoc  loc,
VarKind  vk,
bool  verifyUsage = false 
)

Creates a new currently-unbound variable.

When a variable of that name already exists: if verifyUsage is true, then will assert that the variable has the same kind and a consistent location; otherwise, when verifyUsage is false, this is a noop. Returns the identifier for the variable with the given name, and a bool indicating whether a new variable was created.

Definition at line 181 of file Var.cpp.

References isInternalConsistent(), and isUsageConsistent().

Referenced by lookupOrCreate().

◆ emitErrorIfAnyUnbound()

InFlightDiagnostic VarEnv::emitErrorIfAnyUnbound ( AsmParser parser) const

◆ getRanks()

Ranks mlir::sparse_tensor::ir_detail::VarEnv::getRanks ( ) const
inline

Returns the current ranks of bound variables.

This method should only be used after the environment is "finished", since binding new variables will (semantically) invalidate any previously returned Ranks.

Definition at line 390 of file Var.h.

Referenced by mlir::sparse_tensor::ir_detail::DimLvlMapParser::parseDimLvlMap().

◆ getVar()

Var mlir::sparse_tensor::ir_detail::VarEnv::getVar ( VarInfo::ID  id) const
inline

Gets the Var identified by the VarInfo::ID, raising an assertion failure if the variable is not bound.

Definition at line 394 of file Var.h.

References access(), and mlir::sparse_tensor::ir_detail::VarInfo::getVar().

◆ lookup()

std::optional< VarInfo::ID > VarEnv::lookup ( StringRef  name) const

Looks up the variable with the given name.

Definition at line 170 of file Var.cpp.

References isInternalConsistent().

Referenced by lookupOrCreate().

◆ lookupOrCreate()

std::optional< std::pair< VarInfo::ID, bool > > VarEnv::lookupOrCreate ( Policy  creationPolicy,
StringRef  name,
llvm::SMLoc  loc,
VarKind  vk 
)

Looks up or creates a variable according to the given Policy.

Returns nullopt in one of two circumstances: (1) the policy says we Must create, yet the variable already exists; (2) the policy says we MustNot create, yet no such variable exists. Otherwise, if the variable already exists then it is validated against the given kind and location to ensure consistency.

Definition at line 197 of file Var.cpp.

References create(), isUsageConsistent(), lookup(), mlir::sparse_tensor::ir_detail::May, mlir::sparse_tensor::ir_detail::Must, and mlir::sparse_tensor::ir_detail::MustNot.


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