Add unit tagging to AssociatedConstantId (#6207)

No update to lldbinit.py because we don't currently have
dumping/debugging support for AssociatedConstantId anyway.
This commit is contained in:
David Blaikie
2025-10-13 23:06:02 +00:00
committed by GitHub
parent ad63950df2
commit b2c2bdde3a
4 changed files with 9 additions and 0 deletions
+1
View File
@@ -36,6 +36,7 @@ File::File(const Parse::Tree* parse_tree, CheckIRId check_ir_id,
value_stores_(&value_stores),
filename_(std::move(filename)),
classes_(IdTag(check_ir_id.index, 0)),
associated_constants_(IdTag(check_ir_id.index, 0)),
impls_(*this),
// The `+1` prevents adding a tag to the global `NameSpace::PackageInstId`
// instruction. It's not a "singleton" instruction, but it's a unique
+4
View File
@@ -54,6 +54,10 @@ auto ClassId::Print(llvm::raw_ostream& out) const -> void {
IdBase::PrintHex(out);
}
auto AssociatedConstantId::Print(llvm::raw_ostream& out) const -> void {
IdBase::PrintHex(out);
}
auto GenericInstIndex::Print(llvm::raw_ostream& out) const -> void {
out << "generic_inst";
if (has_value()) {
+2
View File
@@ -327,6 +327,8 @@ struct AssociatedConstantId : public IdBase<AssociatedConstantId> {
static constexpr llvm::StringLiteral Label = "assoc_const";
using IdBase::IdBase;
auto Print(llvm::raw_ostream& out) const -> void;
};
// The ID of a `FacetTypeInfo`.
+2
View File
@@ -53,6 +53,8 @@ class InstNamer {
auto index = id.index;
if constexpr (std::is_same_v<IdT, ClassId>) {
index = sem_ir_->classes().GetRawIndex(id);
} else if constexpr (std::is_same_v<IdT, AssociatedConstantId>) {
index = sem_ir_->associated_constants().GetRawIndex(id);
}
return static_cast<ScopeId>(GetScopeIdOffset(ScopeIdTypeEnum::For<IdT>) +
index);