MLIR
20.0.0git
|
#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::ID > | lookup (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... | |
|
inline |
|
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().
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().
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().
InFlightDiagnostic VarEnv::emitErrorIfAnyUnbound | ( | AsmParser & | parser | ) | const |
Definition at line 229 of file Var.cpp.
References mlir::AsmParser::emitError().
Referenced by mlir::sparse_tensor::ir_detail::DimLvlMapParser::parseDimLvlMap().
|
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().
|
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().
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().
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.