//===- Var.cpp ------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "Var.h" #include "DimLvlMap.h" usingnamespacemlir; usingnamespacemlir::sparse_tensor; usingnamespacemlir::sparse_tensor::ir_detail; //===----------------------------------------------------------------------===// // `VarKind` helpers. //===----------------------------------------------------------------------===// /// For use in foreach loops. static constexpr const VarKind everyVarKind[] = …; //===----------------------------------------------------------------------===// // `Var` implementation. //===----------------------------------------------------------------------===// std::string Var::str() const { … } void Var::print(AsmPrinter &printer) const { … } void Var::print(llvm::raw_ostream &os) const { … } void Var::dump() const { … } //===----------------------------------------------------------------------===// // `Ranks` implementation. //===----------------------------------------------------------------------===// bool Ranks::operator==(Ranks const &other) const { … } bool Ranks::isValid(DimLvlExpr expr) const { … } //===----------------------------------------------------------------------===// // `VarSet` implementation. //===----------------------------------------------------------------------===// VarSet::VarSet(Ranks const &ranks) { … } bool VarSet::contains(Var var) const { … } void VarSet::add(Var var) { … } void VarSet::add(VarSet const &other) { … } void VarSet::add(DimLvlExpr expr) { … } //===----------------------------------------------------------------------===// // `VarInfo` implementation. //===----------------------------------------------------------------------===// void VarInfo::setNum(Var::Num n) { … } //===----------------------------------------------------------------------===// // `VarEnv` implementation. //===----------------------------------------------------------------------===// /// Helper function for `assertUsageConsistency` to better handle SMLoc /// mismatches. LLVM_ATTRIBUTE_UNUSED static llvm::SMLoc minSMLoc(AsmParser &parser, llvm::SMLoc sm1, llvm::SMLoc sm2) { … } bool isInternalConsistent(VarEnv const &env, VarInfo::ID id, StringRef name) { … } bool isUsageConsistent(VarEnv const &env, VarInfo::ID id, llvm::SMLoc loc, VarKind vk) { … } std::optional<VarInfo::ID> VarEnv::lookup(StringRef name) const { … } std::optional<std::pair<VarInfo::ID, bool>> VarEnv::create(StringRef name, llvm::SMLoc loc, VarKind vk, bool verifyUsage) { … } std::optional<std::pair<VarInfo::ID, bool>> VarEnv::lookupOrCreate(Policy creationPolicy, StringRef name, llvm::SMLoc loc, VarKind vk) { … } Var VarEnv::bindUnusedVar(VarKind vk) { … } Var VarEnv::bindVar(VarInfo::ID id) { … } InFlightDiagnostic VarEnv::emitErrorIfAnyUnbound(AsmParser &parser) const { … } //===----------------------------------------------------------------------===//