From 326609857dfef084eec08183ad54630678add5fe Mon Sep 17 00:00:00 2001 From: Geoff Romer Date: Fri, 19 Jul 2024 15:43:50 -0700 Subject: [PATCH] Rename BindNameInfo to EntityName (#4090) --- toolchain/check/context.cpp | 4 +- toolchain/check/context.h | 4 +- toolchain/check/eval.cpp | 11 +++-- toolchain/check/handle_alias.cpp | 4 +- toolchain/check/handle_binding_pattern.cpp | 14 +++---- toolchain/check/handle_export.cpp | 8 ++-- toolchain/check/handle_interface.cpp | 4 +- toolchain/check/handle_let_and_var.cpp | 4 +- toolchain/check/impl.cpp | 3 +- toolchain/check/import.cpp | 18 ++++----- toolchain/check/import_ref.cpp | 32 +++++++-------- toolchain/check/import_ref.h | 2 +- toolchain/check/member_access.cpp | 3 +- toolchain/check/subst.cpp | 2 +- .../testdata/basics/builtin_insts.carbon | 2 +- .../multifile_raw_and_textual_ir.carbon | 8 ++-- .../basics/no_prelude/multifile_raw_ir.carbon | 8 ++-- .../no_prelude/raw_and_textual_ir.carbon | 6 +-- .../testdata/basics/no_prelude/raw_ir.carbon | 12 +++--- toolchain/sem_ir/BUILD | 2 +- .../sem_ir/{bind_name.h => entity_name.h} | 40 +++++++++---------- toolchain/sem_ir/file.cpp | 10 +++-- toolchain/sem_ir/file.h | 10 ++--- toolchain/sem_ir/formatter.cpp | 8 ++-- toolchain/sem_ir/generic.h | 2 +- toolchain/sem_ir/id_kind.h | 2 +- toolchain/sem_ir/ids.h | 14 +++---- toolchain/sem_ir/inst_namer.cpp | 3 +- toolchain/sem_ir/typed_insts.h | 18 ++++----- toolchain/sem_ir/yaml_test.cpp | 2 +- 30 files changed, 135 insertions(+), 125 deletions(-) rename toolchain/sem_ir/{bind_name.h => entity_name.h} (51%) diff --git a/toolchain/check/context.cpp b/toolchain/check/context.cpp index ca579121abbcc..203819fd45a81 100644 --- a/toolchain/check/context.cpp +++ b/toolchain/check/context.cpp @@ -369,14 +369,14 @@ static auto LookupInImportIRScopes(Context& context, SemIRLoc loc, import_ir.sem_ir, import_scope_entry.inst_id); } else { // Add the first result found. - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = name_id, .parent_scope_id = scope_id, .bind_index = SemIR::CompileTimeBindIndex::Invalid}); result_id = AddImportRef( context, {.ir_id = import_ir_id, .inst_id = import_scope_entry.inst_id}, - bind_name_id); + entity_name_id); LoadImportRef(context, result_id); } } diff --git a/toolchain/check/context.h b/toolchain/check/context.h index 8e9805198e01f..508a5a8bd69ad 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -410,7 +410,9 @@ class Context { auto string_literal_values() -> CanonicalValueStore& { return sem_ir().string_literal_values(); } - auto bind_names() -> SemIR::BindNameStore& { return sem_ir().bind_names(); } + auto entity_names() -> SemIR::EntityNameStore& { + return sem_ir().entity_names(); + } auto functions() -> ValueStore& { return sem_ir().functions(); } diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index 31564a3aa9c32..e31cd7197f334 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -84,7 +84,9 @@ struct EvalContext { auto ints() -> CanonicalValueStore& { return sem_ir().ints(); } auto floats() -> FloatValueStore& { return sem_ir().floats(); } - auto bind_names() -> SemIR::BindNameStore& { return sem_ir().bind_names(); } + auto entity_names() -> SemIR::EntityNameStore& { + return sem_ir().entity_names(); + } auto functions() -> const ValueStore& { return sem_ir().functions(); } @@ -1322,7 +1324,8 @@ auto TryEvalInstInContext(EvalContext& eval_context, SemIR::InstId inst_id, break; case CARBON_KIND(SemIR::BindSymbolicName bind): { - const auto& bind_name = eval_context.bind_names().Get(bind.bind_name_id); + const auto& bind_name = + eval_context.entity_names().Get(bind.entity_name_id); // If we know which instance we're evaluating within and this is an // argument of that instance, its constant value is the corresponding @@ -1346,8 +1349,8 @@ auto TryEvalInstInContext(EvalContext& eval_context, SemIR::InstId inst_id, // The constant form of a symbolic binding is an idealized form of the // original, with no equivalent value. - bind.bind_name_id = - eval_context.bind_names().MakeCanonical(bind.bind_name_id); + bind.entity_name_id = + eval_context.entity_names().MakeCanonical(bind.entity_name_id); bind.value_id = SemIR::InstId::Invalid; return MakeConstantResult(eval_context.context, bind, Phase::Symbolic); } diff --git a/toolchain/check/handle_alias.cpp b/toolchain/check/handle_alias.cpp index 63953ebeb243b..ce1ecc858a286 100644 --- a/toolchain/check/handle_alias.cpp +++ b/toolchain/check/handle_alias.cpp @@ -34,7 +34,7 @@ auto HandleParseNode(Context& context, Parse::AliasId /*node_id*/) -> bool { context.decl_introducer_state_stack().Pop(); LimitModifiersOnDecl(context, introducer, KeywordModifierSet::Access); - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = name_context.name_id_for_new_inst(), .parent_scope_id = name_context.parent_scope_id_for_new_inst(), .bind_index = SemIR::CompileTimeBindIndex::Invalid}); @@ -61,7 +61,7 @@ auto HandleParseNode(Context& context, Parse::AliasId /*node_id*/) -> bool { } auto alias_id = context.AddInst( name_context.loc_id, {.type_id = alias_type_id, - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = alias_value_id}); // Add the name of the binding to the current scope. diff --git a/toolchain/check/handle_binding_pattern.cpp b/toolchain/check/handle_binding_pattern.cpp index 2c9e4146bac0b..3843e9cc09dfa 100644 --- a/toolchain/check/handle_binding_pattern.cpp +++ b/toolchain/check/handle_binding_pattern.cpp @@ -37,7 +37,7 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, SemIR::InstId value_id) -> SemIR::LocIdAndInst { // TODO: Eventually the name will need to support associations with other // scopes, but right now we don't support qualified names here. - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = name_id, .parent_scope_id = context.scope_stack().PeekNameScopeId(), // TODO: Don't allocate a compile-time binding index for an associated @@ -49,13 +49,13 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, // TODO: Create a `BindTemplateName` instead inside a `template` pattern. return SemIR::LocIdAndInst( name_node, SemIR::BindSymbolicName{.type_id = type_id, - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = value_id}); } else { - return SemIR::LocIdAndInst(name_node, - SemIR::BindName{.type_id = type_id, - .bind_name_id = bind_name_id, - .value_id = value_id}); + return SemIR::LocIdAndInst( + name_node, SemIR::BindName{.type_id = type_id, + .entity_name_id = entity_name_id, + .value_id = value_id}); } }; @@ -206,7 +206,7 @@ auto HandleParseNode(Context& context, Parse::AddrId node_id) -> bool { if (auto self_param = context.insts().TryGetAs(self_param_id); self_param && - context.bind_names().Get(self_param->bind_name_id).name_id == + context.entity_names().Get(self_param->entity_name_id).name_id == SemIR::NameId::SelfValue) { // TODO: The type of an `addr_pattern` should probably be the non-pointer // type, because that's the type that the pattern matches. diff --git a/toolchain/check/handle_export.cpp b/toolchain/check/handle_export.cpp index 9e660b2025bf6..1389e10fb6b5f 100644 --- a/toolchain/check/handle_export.cpp +++ b/toolchain/check/handle_export.cpp @@ -70,15 +70,15 @@ auto HandleParseNode(Context& context, Parse::ExportDeclId node_id) -> bool { auto export_id = context.AddInst( node_id, {.type_id = import_ref->type_id, - .bind_name_id = import_ref->bind_name_id, + .entity_name_id = import_ref->entity_name_id, .value_id = inst_id}); context.AddExport(export_id); // Replace the ImportRef in name lookup, both for the above duplicate // diagnostic and so that cross-package imports can find it easily. - auto bind_name = context.bind_names().Get(import_ref->bind_name_id); - auto& parent_scope = context.name_scopes().Get(bind_name.parent_scope_id); - auto lookup = parent_scope.name_map.Lookup(bind_name.name_id); + auto entity_name = context.entity_names().Get(import_ref->entity_name_id); + auto& parent_scope = context.name_scopes().Get(entity_name.parent_scope_id); + auto lookup = parent_scope.name_map.Lookup(entity_name.name_id); auto& scope_inst_id = parent_scope.names[lookup.value()].inst_id; CARBON_CHECK(scope_inst_id == inst_id); scope_inst_id = export_id; diff --git a/toolchain/check/handle_interface.cpp b/toolchain/check/handle_interface.cpp index 63c021c6ad6cc..0bbc33ebb255f 100644 --- a/toolchain/check/handle_interface.cpp +++ b/toolchain/check/handle_interface.cpp @@ -168,13 +168,13 @@ auto HandleParseNode(Context& context, // We model `Self` as a symbolic binding whose type is the interface. // Because there is no equivalent non-symbolic value, we use `Invalid` as // the `value_id` on the `BindSymbolicName`. - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = SemIR::NameId::SelfType, .parent_scope_id = interface_info.scope_id, .bind_index = context.scope_stack().AddCompileTimeBinding()}); interface_info.self_param_id = context.AddInst( SemIR::LocId::Invalid, {.type_id = self_type_id, - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = SemIR::InstId::Invalid}); context.scope_stack().PushCompileTimeBinding(interface_info.self_param_id); context.name_scopes().AddRequiredName(interface_info.scope_id, diff --git a/toolchain/check/handle_let_and_var.cpp b/toolchain/check/handle_let_and_var.cpp index b7aae94ca2d1c..3d9c8f0249593 100644 --- a/toolchain/check/handle_let_and_var.cpp +++ b/toolchain/check/handle_let_and_var.cpp @@ -81,7 +81,7 @@ static auto BuildAssociatedConstantDecl(Context& context, // Replace the tentative BindName instruction with the associated constant // declaration. auto name_id = - context.bind_names().Get(binding_pattern->bind_name_id).name_id; + context.entity_names().Get(binding_pattern->entity_name_id).name_id; context.ReplaceLocIdAndInstBeforeConstantUse( pattern_id, SemIR::LocIdAndInst(node_id, SemIR::AssociatedConstantDecl{ @@ -107,7 +107,7 @@ static auto HandleNameBinding(Context& context, SemIR::InstId pattern_id, // the variable. auto name_context = context.decl_name_stack().MakeUnqualifiedName( context.insts().GetLocId(pattern_id), - context.bind_names().Get(bind_name->bind_name_id).name_id); + context.entity_names().Get(bind_name->entity_name_id).name_id); context.decl_name_stack().AddNameOrDiagnoseDuplicate( name_context, pattern_id, access_kind); return bind_name->value_id; diff --git a/toolchain/check/impl.cpp b/toolchain/check/impl.cpp index dc9fcc67d87e8..9aeadc285ec95 100644 --- a/toolchain/check/impl.cpp +++ b/toolchain/check/impl.cpp @@ -87,7 +87,8 @@ static auto BuildInterfaceWitness( auto self_bind = context.insts().GetAs(interface.self_param_id); Substitution substitutions[1] = { - {.bind_id = context.bind_names().Get(self_bind.bind_name_id).bind_index, + {.bind_id = + context.entity_names().Get(self_bind.entity_name_id).bind_index, .replacement_id = context.types().GetConstantId(impl.self_id)}}; for (auto decl_id : assoc_entities) { diff --git a/toolchain/check/import.cpp b/toolchain/check/import.cpp index ae72ecd1929d4..0e2140ffbe6ae 100644 --- a/toolchain/check/import.cpp +++ b/toolchain/check/import.cpp @@ -31,9 +31,9 @@ static auto GetImportName(const SemIR::File& import_sem_ir, case SemIR::BindSymbolicName::Kind: case SemIR::ExportDecl::Kind: { auto bind_inst = import_inst.As(); - const auto& bind_name = - import_sem_ir.bind_names().Get(bind_inst.bind_name_id); - return {bind_name.name_id, bind_name.parent_scope_id}; + const auto& entity_name = + import_sem_ir.entity_names().Get(bind_inst.entity_name_id); + return {entity_name.name_id, entity_name.parent_scope_id}; } case CARBON_KIND(SemIR::ClassDecl class_decl): { @@ -156,7 +156,7 @@ static auto CopySingleNameScopeFromImportIR( SemIR::NameId name_id) -> SemIR::NameScopeId { // Produce the namespace for the entry. auto make_import_id = [&]() { - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = name_id, .parent_scope_id = parent_scope_id, .bind_index = SemIR::CompileTimeBindIndex::Invalid}); @@ -165,7 +165,7 @@ static auto CopySingleNameScopeFromImportIR( return context.AddInst( import_ir_inst_id, {.type_id = namespace_type_id, .import_ir_inst_id = import_ir_inst_id, - .bind_name_id = bind_name_id}); + .entity_name_id = entity_name_id}); }; auto [namespace_scope_id, namespace_const_id, _] = AddNamespace(context, namespace_type_id, name_id, parent_scope_id, @@ -239,7 +239,7 @@ static auto AddImportRefOrMerge(Context& context, SemIR::ImportIRId ir_id, // Leave a placeholder that the inst comes from the other IR. auto& parent_scope = context.name_scopes().Get(parent_scope_id); auto insert = parent_scope.name_map.Insert(name_id, [&] { - auto bind_name_id = context.bind_names().Add( + auto entity_name_id = context.entity_names().Add( {.name_id = name_id, .parent_scope_id = parent_scope_id, .bind_index = SemIR::CompileTimeBindIndex::Invalid}); @@ -248,7 +248,7 @@ static auto AddImportRefOrMerge(Context& context, SemIR::ImportIRId ir_id, {.name_id = name_id, .inst_id = AddImportRef(context, {.ir_id = ir_id, .inst_id = import_inst_id}, - bind_name_id), + entity_name_id), .access_kind = SemIR::AccessKind::Public}); return index; }); @@ -310,14 +310,14 @@ static auto ImportScopeFromApiFile(Context& context, .impl_parent_scope_id = impl_scope_id}); } else { // Add an ImportRef for other instructions. - auto impl_bind_name_id = context.bind_names().Add( + auto impl_entity_name_id = context.entity_names().Add( {.name_id = impl_name_id, .parent_scope_id = impl_scope_id, .bind_index = SemIR::CompileTimeBindIndex::Invalid}); auto import_ref_id = AddImportRef(context, {.ir_id = SemIR::ImportIRId::ApiForImpl, .inst_id = api_entry.inst_id}, - impl_bind_name_id); + impl_entity_name_id); impl_scope.AddRequired({.name_id = impl_name_id, .inst_id = import_ref_id, .access_kind = api_entry.access_kind}); diff --git a/toolchain/check/import_ref.cpp b/toolchain/check/import_ref.cpp index 255364c31dea3..369114020197f 100644 --- a/toolchain/check/import_ref.cpp +++ b/toolchain/check/import_ref.cpp @@ -54,10 +54,10 @@ auto AddImportIR(Context& context, SemIR::ImportIR import_ir) } auto AddImportRef(Context& context, SemIR::ImportIRInst import_ir_inst, - SemIR::BindNameId bind_name_id) -> SemIR::InstId { + SemIR::EntityNameId entity_name_id) -> SemIR::InstId { auto import_ir_inst_id = context.import_ir_insts().Add(import_ir_inst); SemIR::ImportRefUnloaded inst = {.import_ir_inst_id = import_ir_inst_id, - .bind_name_id = bind_name_id}; + .entity_name_id = entity_name_id}; auto import_ref_id = context.AddPlaceholderInstInNoBlock( SemIR::LocIdAndInst(import_ir_inst_id, inst)); @@ -114,7 +114,7 @@ auto VerifySameCanonicalImportIRInst(Context& context, SemIR::InstId prev_id, } auto conflict_id = AddImportRef(context, {.ir_id = new_ir_id, .inst_id = new_inst_id}, - SemIR::BindNameId::Invalid); + SemIR::EntityNameId::Invalid); context.DiagnoseDuplicateName(conflict_id, prev_id); } @@ -519,13 +519,13 @@ class ImportRefResolver { if (bind_inst) { switch (bind_inst->kind) { case SemIR::BindName::Kind: { - auto bind_name_id = context_.bind_names().Add( + auto entity_name_id = context_.entity_names().Add( {.name_id = name_id, .parent_scope_id = SemIR::NameScopeId::Invalid, .bind_index = SemIR::CompileTimeBindIndex::Invalid}); new_param_id = context_.AddInstInNoBlock( AddImportIRInst(bind_id), {.type_id = type_id, - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = new_param_id}); break; } @@ -648,7 +648,7 @@ class ImportRefResolver { for (auto entry : import_scope.names) { auto ref_id = AddImportRef( context_, {.ir_id = import_ir_id_, .inst_id = entry.inst_id}, - SemIR::BindNameId::Invalid); + SemIR::EntityNameId::Invalid); new_scope.AddRequired({.name_id = GetLocalNameId(entry.name_id), .inst_id = ref_id, .access_kind = entry.access_kind}); @@ -669,7 +669,7 @@ class ImportRefResolver { for (auto inst_id : associated_entities) { new_associated_entities.push_back( AddImportRef(context_, {.ir_id = import_ir_id_, .inst_id = inst_id}, - SemIR::BindNameId::Invalid)); + SemIR::EntityNameId::Invalid)); } return context_.inst_blocks().Add(new_associated_entities); } @@ -810,7 +810,7 @@ class ImportRefResolver { // Add a lazy reference to the target declaration. auto decl_id = AddImportRef( context_, {.ir_id = import_ir_id_, .inst_id = inst.decl_id}, - SemIR::BindNameId::Invalid); + SemIR::EntityNameId::Invalid); return ResolveAs( {.type_id = context_.GetTypeIdForTypeConstant(type_const_id), @@ -873,16 +873,16 @@ class ImportRefResolver { return ResolveResult::Retry(); } - const auto& import_bind_info = - import_ir_.bind_names().Get(inst.bind_name_id); - auto name_id = GetLocalNameId(import_bind_info.name_id); - auto bind_name_id = context_.bind_names().Add( + const auto& import_entity_name = + import_ir_.entity_names().Get(inst.entity_name_id); + auto name_id = GetLocalNameId(import_entity_name.name_id); + auto entity_name_id = context_.entity_names().Add( {.name_id = name_id, .parent_scope_id = SemIR::NameScopeId::Invalid, - .bind_index = import_bind_info.bind_index}); + .bind_index = import_entity_name.bind_index}); return ResolveAs( {.type_id = context_.GetTypeIdForTypeConstant(type_id), - .bind_name_id = bind_name_id, + .entity_name_id = entity_name_id, .value_id = SemIR::InstId::Invalid}); } @@ -1603,7 +1603,7 @@ auto LoadImportRef(Context& context, SemIR::InstId inst_id) -> void { inst_id, SemIR::ImportRefLoaded{.type_id = type_id, .import_ir_inst_id = inst->import_ir_inst_id, - .bind_name_id = inst->bind_name_id}); + .entity_name_id = inst->entity_name_id}); // Store the constant for both the ImportRefLoaded and indirect instructions. context.constant_values().Set(inst_id, constant_id); @@ -1633,7 +1633,7 @@ static auto ImportImpl(Context& context, SemIR::ImportIRId import_ir_id, auto& impl = context.impls().Get(impl_id); impl.witness_id = AddImportRef( context, {.ir_id = import_ir_id, .inst_id = import_impl.witness_id}, - SemIR::BindNameId::Invalid); + SemIR::EntityNameId::Invalid); } } diff --git a/toolchain/check/import_ref.h b/toolchain/check/import_ref.h index 9d8d1821fbad2..5b5bc9235537d 100644 --- a/toolchain/check/import_ref.h +++ b/toolchain/check/import_ref.h @@ -22,7 +22,7 @@ auto AddImportIR(Context& context, SemIR::ImportIR import_ir) // Adds an import_ref instruction for the specified instruction in the // specified IR. The import_ref is initially marked as unused. auto AddImportRef(Context& context, SemIR::ImportIRInst import_ir_inst, - SemIR::BindNameId bind_name_id) -> SemIR::InstId; + SemIR::EntityNameId entity_name_id) -> SemIR::InstId; // Returns the canonical IR inst for an entity. Returns an invalid ir_id for the // current IR. diff --git a/toolchain/check/member_access.cpp b/toolchain/check/member_access.cpp index 76072fc9c4dd1..10267fe32dd95 100644 --- a/toolchain/check/member_access.cpp +++ b/toolchain/check/member_access.cpp @@ -197,7 +197,8 @@ static auto PerformImplLookup(Context& context, Parse::NodeId node_id, auto self_param = context.insts().GetAs(interface.self_param_id); Substitution substitutions[1] = { - {.bind_id = context.bind_names().Get(self_param.bind_name_id).bind_index, + {.bind_id = + context.entity_names().Get(self_param.entity_name_id).bind_index, .replacement_id = type_const_id}}; auto subst_type_id = SubstType(context, assoc_type.entity_type_id, substitutions); diff --git a/toolchain/check/subst.cpp b/toolchain/check/subst.cpp index 979e0873d71b0..cd7c53f3cdf27 100644 --- a/toolchain/check/subst.cpp +++ b/toolchain/check/subst.cpp @@ -271,7 +271,7 @@ class SubstConstantCallbacks final : public SubstInstCallbacks { // TODO: Consider building a hash map for substitutions. We might have a // lot of them. for (auto [bind_index, replacement_id] : substitutions_) { - if (context_.bind_names().Get(bind->bind_name_id).bind_index == + if (context_.entity_names().Get(bind->entity_name_id).bind_index == bind_index) { // This is the binding we're replacing. Perform substitution. inst_id = context_.constant_values().GetInstId(replacement_id); diff --git a/toolchain/check/testdata/basics/builtin_insts.carbon b/toolchain/check/testdata/basics/builtin_insts.carbon index 727e96f94a186..d6646722c2515 100644 --- a/toolchain/check/testdata/basics/builtin_insts.carbon +++ b/toolchain/check/testdata/basics/builtin_insts.carbon @@ -18,7 +18,7 @@ // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {}} -// CHECK:STDOUT: bind_names: {} +// CHECK:STDOUT: entity_names: {} // CHECK:STDOUT: functions: {} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: generics: {} diff --git a/toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon index fa77788bee2e3..67c1da8117939 100644 --- a/toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon +++ b/toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon @@ -34,7 +34,7 @@ fn B() { // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name0: inst+1}} -// CHECK:STDOUT: bind_names: {} +// CHECK:STDOUT: entity_names: {} // CHECK:STDOUT: functions: // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: empty, body: [block4]} // CHECK:STDOUT: classes: {} @@ -107,8 +107,8 @@ fn B() { // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name1: inst+2, name0: inst+3}} // CHECK:STDOUT: name_scope1: {inst: inst+2, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {}} -// CHECK:STDOUT: bind_names: -// CHECK:STDOUT: bind_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind} +// CHECK:STDOUT: entity_names: +// CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind} // CHECK:STDOUT: functions: // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: empty, body: [block4]} // CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1, param_refs: empty} @@ -133,7 +133,7 @@ fn B() { // CHECK:STDOUT: 'inst+5': {kind: TupleType, arg0: type_block0, type: typeTypeType} // CHECK:STDOUT: 'inst+6': {kind: StructValue, arg0: empty, type: type(inst+4)} // CHECK:STDOUT: 'inst+7': {kind: NameRef, arg0: name1, arg1: inst+2, type: type(instNamespaceType)} -// CHECK:STDOUT: 'inst+8': {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: bind_name0, type: type(inst+10)} +// CHECK:STDOUT: 'inst+8': {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name0, type: type(inst+10)} // CHECK:STDOUT: 'inst+9': {kind: FunctionDecl, arg0: function1, arg1: empty, type: type(inst+10)} // CHECK:STDOUT: 'inst+10': {kind: FunctionType, arg0: function1, type: typeTypeType} // CHECK:STDOUT: 'inst+11': {kind: StructValue, arg0: empty, type: type(inst+10)} diff --git a/toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon b/toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon index 278588e377ce7..d2e51c371da02 100644 --- a/toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon +++ b/toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon @@ -34,7 +34,7 @@ fn B() { // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name0: inst+1}} -// CHECK:STDOUT: bind_names: {} +// CHECK:STDOUT: entity_names: {} // CHECK:STDOUT: functions: // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: empty, body: [block4]} // CHECK:STDOUT: classes: {} @@ -86,8 +86,8 @@ fn B() { // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name1: inst+2, name0: inst+3}} // CHECK:STDOUT: name_scope1: {inst: inst+2, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {}} -// CHECK:STDOUT: bind_names: -// CHECK:STDOUT: bind_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind} +// CHECK:STDOUT: entity_names: +// CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind} // CHECK:STDOUT: functions: // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: empty, body: [block4]} // CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1, param_refs: empty} @@ -112,7 +112,7 @@ fn B() { // CHECK:STDOUT: 'inst+5': {kind: TupleType, arg0: type_block0, type: typeTypeType} // CHECK:STDOUT: 'inst+6': {kind: StructValue, arg0: empty, type: type(inst+4)} // CHECK:STDOUT: 'inst+7': {kind: NameRef, arg0: name1, arg1: inst+2, type: type(instNamespaceType)} -// CHECK:STDOUT: 'inst+8': {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: bind_name0, type: type(inst+10)} +// CHECK:STDOUT: 'inst+8': {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name0, type: type(inst+10)} // CHECK:STDOUT: 'inst+9': {kind: FunctionDecl, arg0: function1, arg1: empty, type: type(inst+10)} // CHECK:STDOUT: 'inst+10': {kind: FunctionType, arg0: function1, type: typeTypeType} // CHECK:STDOUT: 'inst+11': {kind: StructValue, arg0: empty, type: type(inst+10)} diff --git a/toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon index 320c89d71669e..9d0ab4655985a 100644 --- a/toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon +++ b/toolchain/check/testdata/basics/no_prelude/raw_and_textual_ir.carbon @@ -24,8 +24,8 @@ fn Foo(n: ()) -> ((), ()) { // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name0: inst+14}} -// CHECK:STDOUT: bind_names: -// CHECK:STDOUT: bind_name0: {name: name1, parent_scope: name_scope, index: comp_time_bind} +// CHECK:STDOUT: entity_names: +// CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope, index: comp_time_bind} // CHECK:STDOUT: functions: // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: block4, return_storage: inst+13, return_slot: present, body: [block7]} // CHECK:STDOUT: classes: {} @@ -50,7 +50,7 @@ fn Foo(n: ()) -> ((), ()) { // CHECK:STDOUT: 'inst+2': {kind: TupleLiteral, arg0: empty, type: type(inst+1)} // CHECK:STDOUT: 'inst+3': {kind: Converted, arg0: inst+2, arg1: inst+1, type: typeTypeType} // CHECK:STDOUT: 'inst+4': {kind: Param, arg0: name1, type: type(inst+1)} -// CHECK:STDOUT: 'inst+5': {kind: BindName, arg0: bind_name0, arg1: inst+4, type: type(inst+1)} +// CHECK:STDOUT: 'inst+5': {kind: BindName, arg0: entity_name0, arg1: inst+4, type: type(inst+1)} // CHECK:STDOUT: 'inst+6': {kind: TupleLiteral, arg0: empty, type: type(inst+1)} // CHECK:STDOUT: 'inst+7': {kind: TupleLiteral, arg0: empty, type: type(inst+1)} // CHECK:STDOUT: 'inst+8': {kind: TupleType, arg0: type_block1, type: typeTypeType} diff --git a/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon b/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon index 1a6e87a9b50a7..638e32b378f8d 100644 --- a/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon +++ b/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon @@ -24,9 +24,9 @@ fn Foo[T:! type](n: T) -> (T, ()) { // CHECK:STDOUT: import_ir_insts: {} // CHECK:STDOUT: name_scopes: // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {name0: inst+16}} -// CHECK:STDOUT: bind_names: -// CHECK:STDOUT: bind_name0: {name: name1, parent_scope: name_scope, index: comp_time_bind0} -// CHECK:STDOUT: bind_name1: {name: name2, parent_scope: name_scope, index: comp_time_bind} +// CHECK:STDOUT: entity_names: +// CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope, index: comp_time_bind0} +// CHECK:STDOUT: entity_name1: {name: name2, parent_scope: name_scope, index: comp_time_bind} // CHECK:STDOUT: functions: // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: block5, return_storage: inst+15, return_slot: present, body: [block12]} // CHECK:STDOUT: classes: {} @@ -56,11 +56,11 @@ fn Foo[T:! type](n: T) -> (T, ()) { // CHECK:STDOUT: insts: // CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst, type: type(instNamespaceType)} // CHECK:STDOUT: 'inst+1': {kind: Param, arg0: name1, type: typeTypeType} -// CHECK:STDOUT: 'inst+2': {kind: BindSymbolicName, arg0: bind_name0, arg1: inst+1, type: typeTypeType} -// CHECK:STDOUT: 'inst+3': {kind: BindSymbolicName, arg0: bind_name0, arg1: inst, type: typeTypeType} +// CHECK:STDOUT: 'inst+2': {kind: BindSymbolicName, arg0: entity_name0, arg1: inst+1, type: typeTypeType} +// CHECK:STDOUT: 'inst+3': {kind: BindSymbolicName, arg0: entity_name0, arg1: inst, type: typeTypeType} // CHECK:STDOUT: 'inst+4': {kind: NameRef, arg0: name1, arg1: inst+2, type: typeTypeType} // CHECK:STDOUT: 'inst+5': {kind: Param, arg0: name2, type: type(symbolicConstant2)} -// CHECK:STDOUT: 'inst+6': {kind: BindName, arg0: bind_name1, arg1: inst+5, type: type(symbolicConstant2)} +// CHECK:STDOUT: 'inst+6': {kind: BindName, arg0: entity_name1, arg1: inst+5, type: type(symbolicConstant2)} // CHECK:STDOUT: 'inst+7': {kind: NameRef, arg0: name1, arg1: inst+2, type: typeTypeType} // CHECK:STDOUT: 'inst+8': {kind: TupleType, arg0: type_block0, type: typeTypeType} // CHECK:STDOUT: 'inst+9': {kind: TupleLiteral, arg0: empty, type: type(inst+8)} diff --git a/toolchain/sem_ir/BUILD b/toolchain/sem_ir/BUILD index 41703714ccc72..bf1e86d9df2fa 100644 --- a/toolchain/sem_ir/BUILD +++ b/toolchain/sem_ir/BUILD @@ -90,11 +90,11 @@ cc_library( "name.cpp", ], hdrs = [ - "bind_name.h", "builtin_function_kind.h", "class.h", "constant.h", "copy_on_write_block.h", + "entity_name.h", "file.h", "function.h", "generic.h", diff --git a/toolchain/sem_ir/bind_name.h b/toolchain/sem_ir/entity_name.h similarity index 51% rename from toolchain/sem_ir/bind_name.h rename to toolchain/sem_ir/entity_name.h index 9328acfbefe59..d4a6e0eed9bab 100644 --- a/toolchain/sem_ir/bind_name.h +++ b/toolchain/sem_ir/entity_name.h @@ -2,8 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef CARBON_TOOLCHAIN_SEM_IR_BIND_NAME_H_ -#define CARBON_TOOLCHAIN_SEM_IR_BIND_NAME_H_ +#ifndef CARBON_TOOLCHAIN_SEM_IR_ENTITY_NAME_H_ +#define CARBON_TOOLCHAIN_SEM_IR_ENTITY_NAME_H_ #include "common/hashing.h" #include "common/set.h" @@ -12,15 +12,15 @@ namespace Carbon::SemIR { -struct BindNameInfo : public Printable { +struct EntityName : public Printable { auto Print(llvm::raw_ostream& out) const -> void { out << "{name: " << name_id << ", parent_scope: " << parent_scope_id << ", index: " << bind_index << "}"; } - friend auto CarbonHashtableEq(const BindNameInfo& lhs, - const BindNameInfo& rhs) -> bool { - return std::memcmp(&lhs, &rhs, sizeof(BindNameInfo)) == 0; + friend auto CarbonHashtableEq(const EntityName& lhs, const EntityName& rhs) + -> bool { + return std::memcmp(&lhs, &rhs, sizeof(EntityName)) == 0; } // The name. @@ -31,46 +31,46 @@ struct BindNameInfo : public Printable { CompileTimeBindIndex bind_index; }; -// Hashing for BindNameInfo. See common/hashing.h. -inline auto CarbonHashValue(const BindNameInfo& value, uint64_t seed) +// Hashing for EntityName. See common/hashing.h. +inline auto CarbonHashValue(const EntityName& value, uint64_t seed) -> HashCode { Hasher hasher(seed); hasher.HashRaw(value); return static_cast(hasher); } -// Value store for BindNameInfo. In addition to the regular ValueStore -// functionality, this can provide optional canonical IDs for BindNameInfos. -struct BindNameStore : public ValueStore { +// Value store for EntityName. In addition to the regular ValueStore +// functionality, this can provide optional canonical IDs for EntityNames. +struct EntityNameStore : public ValueStore { public: // Convert an ID to a canonical ID. All calls to this with equivalent - // `BindNameInfo`s will return the same `BindNameId`. - auto MakeCanonical(BindNameId id) -> BindNameId; + // `EntityName`s will return the same `EntityNameId`. + auto MakeCanonical(EntityNameId id) -> EntityNameId; private: class KeyContext; - Set canonical_ids_; + Set canonical_ids_; }; -class BindNameStore::KeyContext : public TranslatingKeyContext { +class EntityNameStore::KeyContext : public TranslatingKeyContext { public: - explicit KeyContext(const BindNameStore* store) : store_(store) {} + explicit KeyContext(const EntityNameStore* store) : store_(store) {} // Note that it is safe to return a `const` reference here as the underlying // object's lifetime is provided by the `store_`. - auto TranslateKey(BindNameId id) const -> const BindNameInfo& { + auto TranslateKey(EntityNameId id) const -> const EntityName& { return store_->Get(id); } private: - const BindNameStore* store_; + const EntityNameStore* store_; }; -inline auto BindNameStore::MakeCanonical(BindNameId id) -> BindNameId { +inline auto EntityNameStore::MakeCanonical(EntityNameId id) -> EntityNameId { return canonical_ids_.Insert(id, KeyContext(this)).key(); } } // namespace Carbon::SemIR -#endif // CARBON_TOOLCHAIN_SEM_IR_BIND_NAME_H_ +#endif // CARBON_TOOLCHAIN_SEM_IR_ENTITY_NAME_H_ diff --git a/toolchain/sem_ir/file.cpp b/toolchain/sem_ir/file.cpp index dd99fd2d1badd..fcd7c4dddffce 100644 --- a/toolchain/sem_ir/file.cpp +++ b/toolchain/sem_ir/file.cpp @@ -145,7 +145,7 @@ auto File::OutputYaml(bool include_builtins) const -> Yaml::OutputMapping { map.Add("import_irs", import_irs_.OutputYaml()); map.Add("import_ir_insts", import_ir_insts_.OutputYaml()); map.Add("name_scopes", name_scopes_.OutputYaml()); - map.Add("bind_names", bind_names_.OutputYaml()); + map.Add("entity_names", entity_names_.OutputYaml()); map.Add("functions", functions_.OutputYaml()); map.Add("classes", classes_.OutputYaml()); map.Add("generics", generics_.OutputYaml()); @@ -191,7 +191,8 @@ auto File::OutputYaml(bool include_builtins) const -> Yaml::OutputMapping { auto File::CollectMemUsage(MemUsage& mem_usage, llvm::StringRef label) const -> void { mem_usage.Add(MemUsage::ConcatLabel(label, "allocator_"), allocator_); - mem_usage.Collect(MemUsage::ConcatLabel(label, "bind_names_"), bind_names_); + mem_usage.Collect(MemUsage::ConcatLabel(label, "entity_names_"), + entity_names_); mem_usage.Collect(MemUsage::ConcatLabel(label, "functions_"), functions_); mem_usage.Collect(MemUsage::ConcatLabel(label, "classes_"), classes_); mem_usage.Collect(MemUsage::ConcatLabel(label, "interfaces_"), interfaces_); @@ -296,9 +297,10 @@ static auto StringifyTypeExprImpl(const SemIR::File& outer_sem_ir, case BindAlias::Kind: case BindSymbolicName::Kind: case ExportDecl::Kind: { - auto name_id = untyped_inst.As().bind_name_id; + auto name_id = + untyped_inst.As().entity_name_id; out << sem_ir.names().GetFormatted( - sem_ir.bind_names().Get(name_id).name_id); + sem_ir.entity_names().Get(name_id).name_id); break; } case CARBON_KIND(ClassType inst): { diff --git a/toolchain/sem_ir/file.h b/toolchain/sem_ir/file.h index e8b4dd4694a25..f3a663352d45c 100644 --- a/toolchain/sem_ir/file.h +++ b/toolchain/sem_ir/file.h @@ -12,9 +12,9 @@ #include "llvm/Support/FormatVariadic.h" #include "toolchain/base/value_store.h" #include "toolchain/base/yaml.h" -#include "toolchain/sem_ir/bind_name.h" #include "toolchain/sem_ir/class.h" #include "toolchain/sem_ir/constant.h" +#include "toolchain/sem_ir/entity_name.h" #include "toolchain/sem_ir/function.h" #include "toolchain/sem_ir/generic.h" #include "toolchain/sem_ir/ids.h" @@ -108,8 +108,8 @@ class File : public Printable { return value_stores_->string_literal_values(); } - auto bind_names() -> BindNameStore& { return bind_names_; } - auto bind_names() const -> const BindNameStore& { return bind_names_; } + auto entity_names() -> EntityNameStore& { return entity_names_; } + auto entity_names() const -> const EntityNameStore& { return entity_names_; } auto functions() -> ValueStore& { return functions_; } auto functions() const -> const ValueStore& { return functions_; } auto classes() -> ValueStore& { return classes_; } @@ -186,8 +186,8 @@ class File : public Printable { // TODO: If SemIR starts linking back to tokens, reuse its filename. std::string filename_; - // Storage for bind names. - BindNameStore bind_names_; + // Storage for EntityNames. + EntityNameStore entity_names_; // Storage for callable objects. ValueStore functions_; diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index ea3fb27cd5d71..0cb984d66d5a0 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -607,9 +607,9 @@ class FormatterImpl { // A BindSymbolicName with no value is a purely symbolic binding, such as // the `Self` in an interface. Don't print out `invalid` for the value. if (inst.value_id.is_valid()) { - FormatArgs(inst.bind_name_id, inst.value_id); + FormatArgs(inst.entity_name_id, inst.value_id); } else { - FormatArgs(inst.bind_name_id); + FormatArgs(inst.entity_name_id); } } @@ -811,8 +811,8 @@ class FormatterImpl { auto FormatArg(BuiltinInstKind kind) -> void { out_ << kind.label(); } - auto FormatArg(BindNameId id) -> void { - const auto& info = sem_ir_.bind_names().Get(id); + auto FormatArg(EntityNameId id) -> void { + const auto& info = sem_ir_.entity_names().Get(id); FormatName(info.name_id); if (info.bind_index.is_valid()) { out_ << " " << info.bind_index.index; diff --git a/toolchain/sem_ir/generic.h b/toolchain/sem_ir/generic.h index 810c7553fa229..af57c6dac5a3c 100644 --- a/toolchain/sem_ir/generic.h +++ b/toolchain/sem_ir/generic.h @@ -35,7 +35,7 @@ struct Generic : public Printable { InstId decl_id; // A block containing the IDs of compile time bindings in this generic scope. // The index in this block will match the `bind_index` in the name binding - // instruction's `BindNameInfo`. + // instruction's `EntityName`. InstBlockId bindings_id; // The self instance of this generic, which is an instance where every generic // parameter's argument is that same parameter. For example, the self instance diff --git a/toolchain/sem_ir/id_kind.h b/toolchain/sem_ir/id_kind.h index f1aac1bf473b2..bfc13d1bfb7ad 100644 --- a/toolchain/sem_ir/id_kind.h +++ b/toolchain/sem_ir/id_kind.h @@ -120,7 +120,7 @@ using IdKind = TypeEnum< // From base/value_store.h. IntId, RealId, FloatId, StringLiteralValueId, // From sem_ir/id.h. - InstId, ConstantId, BindNameId, CompileTimeBindIndex, FunctionId, ClassId, + InstId, ConstantId, EntityNameId, CompileTimeBindIndex, FunctionId, ClassId, InterfaceId, ImplId, GenericId, GenericInstanceId, ImportIRId, ImportIRInstId, LocId, BoolValue, IntKind, NameId, NameScopeId, InstBlockId, TypeId, TypeBlockId, ElementIndex, FloatKind>; diff --git a/toolchain/sem_ir/ids.h b/toolchain/sem_ir/ids.h index bd2c080607799..dac42ca2bdf5f 100644 --- a/toolchain/sem_ir/ids.h +++ b/toolchain/sem_ir/ids.h @@ -18,7 +18,7 @@ namespace Carbon::SemIR { // Forward declare indexed types, for integration with ValueStore. class File; class Inst; -struct BindNameInfo; +struct EntityName; struct Class; struct Function; struct Generic; @@ -194,21 +194,21 @@ constexpr ConstantId ConstantId::Error = ConstantId::ForTemplateConstant(InstId::BuiltinError); constexpr ConstantId ConstantId::Invalid = ConstantId(InvalidIndex); -// The ID of a bind name. -struct BindNameId : public IdBase, public Printable { - using ValueType = BindNameInfo; +// The ID of a EntityName. +struct EntityNameId : public IdBase, public Printable { + using ValueType = EntityName; // An explicitly invalid ID. - static const BindNameId Invalid; + static const EntityNameId Invalid; using IdBase::IdBase; auto Print(llvm::raw_ostream& out) const -> void { - out << "bind_name"; + out << "entity_name"; IdBase::Print(out); } }; -constexpr BindNameId BindNameId::Invalid = BindNameId(InvalidIndex); +constexpr EntityNameId EntityNameId::Invalid = EntityNameId(InvalidIndex); // The index of a compile-time binding. This is the de Bruijn level for the // binding -- that is, this is the number of other compile time bindings whose diff --git a/toolchain/sem_ir/inst_namer.cpp b/toolchain/sem_ir/inst_namer.cpp index 470b6f1566126..a6b6a4c7dc6d4 100644 --- a/toolchain/sem_ir/inst_namer.cpp +++ b/toolchain/sem_ir/inst_namer.cpp @@ -407,7 +407,8 @@ auto InstNamer::CollectNamesInBlock(ScopeId scope_id, case BindSymbolicName::Kind: case ExportDecl::Kind: { auto inst = untyped_inst.As(); - add_inst_name_id(sem_ir_.bind_names().Get(inst.bind_name_id).name_id); + add_inst_name_id( + sem_ir_.entity_names().Get(inst.entity_name_id).name_id); continue; } case CARBON_KIND(Call inst): { diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index f9a10f74049a8..d5c19a233cba9 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -237,7 +237,7 @@ struct AnyBindName { InstKind kind; TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; InstId value_id; }; @@ -250,7 +250,7 @@ struct AnyBindNameOrExportDecl { InstKind kind; TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; InstId value_id; }; @@ -260,7 +260,7 @@ struct BindAlias { InstKind::BindAlias.Define({.ir_name = "bind_alias"}); TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; InstId value_id; }; @@ -271,7 +271,7 @@ struct BindName { InstKind::BindName.Define({.ir_name = "bind_name"}); TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; // The value is inline in the inst so that value access doesn't require an // indirection. InstId value_id; @@ -285,7 +285,7 @@ struct BindSymbolicName { .constant_kind = InstConstantKind::SymbolicOnly}); TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; InstId value_id; }; @@ -501,7 +501,7 @@ struct ExportDecl { InstKind::ExportDecl.Define({.ir_name = "export"}); TypeId type_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; // The exported entity. InstId value_id; }; @@ -635,7 +635,7 @@ struct AnyImportRef { ImportIRInstId import_ir_inst_id; // A BindName is currently only set on directly imported names. It is not // generically available. - BindNameId bind_name_id; + EntityNameId entity_name_id; }; // An imported entity that is not yet been loaded. @@ -646,7 +646,7 @@ struct ImportRefUnloaded { {.ir_name = "import_ref", .is_lowered = false}); ImportIRInstId import_ir_inst_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; }; // A imported entity that is loaded, and may be used. @@ -658,7 +658,7 @@ struct ImportRefLoaded { TypeId type_id; ImportIRInstId import_ir_inst_id; - BindNameId bind_name_id; + EntityNameId entity_name_id; }; // Finalizes the initialization of `dest_id` from the initializer expression diff --git a/toolchain/sem_ir/yaml_test.cpp b/toolchain/sem_ir/yaml_test.cpp index a48243ffbefeb..2de0e54f24ec4 100644 --- a/toolchain/sem_ir/yaml_test.cpp +++ b/toolchain/sem_ir/yaml_test.cpp @@ -58,7 +58,7 @@ TEST(SemIRTest, YAML) { Pair("import_irs", Yaml::Mapping(SizeIs(1))), Pair("import_ir_insts", Yaml::Mapping(SizeIs(0))), Pair("name_scopes", Yaml::Mapping(SizeIs(1))), - Pair("bind_names", Yaml::Mapping(SizeIs(1))), + Pair("entity_names", Yaml::Mapping(SizeIs(1))), Pair("functions", Yaml::Mapping(SizeIs(1))), Pair("classes", Yaml::Mapping(SizeIs(0))), Pair("generics", Yaml::Mapping(SizeIs(0))),