Skip to content

Commit 6311826

Browse files
authored
Add unit tagging to VtableId (#6216)
1 parent 45017bf commit 6311826

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

toolchain/sem_ir/file.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ File::File(const Parse::Tree* parse_tree, CheckIRId check_ir_id,
4545
// instruction. It's not a "singleton" instruction, but it's a unique
4646
// instruction id that comes right after the singletons.
4747
insts_(this, SingletonInstKinds.size() + 1),
48+
vtables_(IdTag(check_ir_id.index, 0)),
4849
constant_values_(ConstantId::NotConstant, &insts_),
4950
inst_blocks_(allocator_),
5051
constants_(this) {

toolchain/sem_ir/ids.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ auto ClassId::Print(llvm::raw_ostream& out) const -> void {
6262
IdBase::PrintHex(out);
6363
}
6464

65+
auto VtableId::Print(llvm::raw_ostream& out) const -> void {
66+
IdBase::PrintHex(out);
67+
}
68+
6569
auto AssociatedConstantId::Print(llvm::raw_ostream& out) const -> void {
6670
IdBase::PrintHex(out);
6771
}

toolchain/sem_ir/ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ struct VtableId : public IdBase<VtableId> {
324324
static constexpr llvm::StringLiteral Label = "vtable";
325325

326326
using IdBase::IdBase;
327+
328+
auto Print(llvm::raw_ostream& out) const -> void;
327329
};
328330

329331
// The ID of an `Interface`.

toolchain/sem_ir/inst_namer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class InstNamer {
6363
index = sem_ir_->impls().GetRawIndex(id);
6464
} else if constexpr (std::is_same_v<IdT, SpecificInterfaceId>) {
6565
index = sem_ir_->specific_interfaces().GetRawIndex(id);
66+
} else if constexpr (std::is_same_v<IdT, VtableId>) {
67+
index = sem_ir_->vtables().GetRawIndex(id);
6668
}
6769
return static_cast<ScopeId>(GetScopeIdOffset(ScopeIdTypeEnum::For<IdT>) +
6870
index);

0 commit comments

Comments
 (0)