diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index e83f5cec58bf..05a86a3a19d0 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -1184,7 +1184,12 @@ auto TryEvalInst(Context& context, SemIR::InstId inst_id, SemIR::Inst inst) return context.constant_values().Get(typed_inst.value_id); } case CARBON_KIND(SemIR::NameRef typed_inst): { - return context.constant_values().Get(typed_inst.value_id); + // Map from an instance-specific constant value to the canonical value. + // TODO: Remove this once we properly model instructions with + // instance-dependent constant values. + return GetConstantInInstance( + context, SemIR::GenericInstanceId::Invalid, + context.constant_values().Get(typed_inst.value_id)); } case CARBON_KIND(SemIR::Converted typed_inst): { return context.constant_values().Get(typed_inst.result_id); diff --git a/toolchain/check/function.cpp b/toolchain/check/function.cpp index 551719e02148..7aafb42b18b9 100644 --- a/toolchain/check/function.cpp +++ b/toolchain/check/function.cpp @@ -30,7 +30,8 @@ auto CheckFunctionTypeMatches(Context& context, prev_return_type_id = SubstType(context, prev_return_type_id, substitutions); } - if (new_return_type_id != prev_return_type_id) { + if (!context.types().AreEqualAcrossDeclarations(new_return_type_id, + prev_return_type_id)) { CARBON_DIAGNOSTIC( FunctionRedeclReturnTypeDiffers, Error, "Function redeclaration differs because return type is `{0}`.", diff --git a/toolchain/check/generic.cpp b/toolchain/check/generic.cpp index d3bd2c4b6346..4f96b1f4a645 100644 --- a/toolchain/check/generic.cpp +++ b/toolchain/check/generic.cpp @@ -4,6 +4,9 @@ #include "toolchain/check/generic.h" +#include "common/map.h" +#include "toolchain/check/generic_region_stack.h" +#include "toolchain/check/subst.h" #include "toolchain/sem_ir/ids.h" namespace Carbon::Check { @@ -23,6 +26,161 @@ auto StartGenericDefinition(Context& context) -> void { context.generic_region_stack().Push(); } +// Adds an instruction `generic_inst_id` to the eval block for a generic region, +// which is the current instruction block. The instruction `generic_inst_id` is +// expected to compute the value of the constant described by `const_inst_id` in +// each instance of the generic. Forms and returns a corresponding symbolic +// constant ID that refers to the substituted value of that instruction in each +// instance of the generic. +static auto AddGenericConstantToEvalBlock( + Context& context, SemIR::GenericId generic_id, + SemIR::GenericInstIndex::Region region, SemIR::InstId const_inst_id, + SemIR::InstId generic_inst_id) -> SemIR::ConstantId { + auto index = SemIR::GenericInstIndex( + region, context.inst_block_stack().PeekCurrentBlockContents().size()); + context.inst_block_stack().AddInstId(generic_inst_id); + return context.constant_values().AddSymbolicConstant( + {.inst_id = const_inst_id, .generic_id = generic_id, .index = index}); +} + +namespace { +// Substitution callbacks to rebuild a generic type in the eval block for a +// generic region. +class RebuildGenericTypeInEvalBlockCallbacks : public SubstInstCallbacks { + public: + RebuildGenericTypeInEvalBlockCallbacks( + Context& context, SemIR::GenericId generic_id, + SemIR::GenericInstIndex::Region region, + Map& constants_in_generic) + : context_(context), + generic_id_(generic_id), + region_(region), + constants_in_generic_(constants_in_generic) {} + + // Check for instructions for which we already have a mapping into the eval + // block, and substitute them for the instructions in the eval block. Note + // that this will at least include mappings for the `BindSymbolicName` + // instructions that introduce our parameters. + auto Subst(SemIR::InstId& inst_id) const -> bool override { + if (context_.constant_values().Get(inst_id).is_template()) { + // This instruction is a template constant, so can't contain any + // bindings that need to be substituted. + return true; + } + + // If this instruction is in the map, return the known result. + if (auto result = constants_in_generic_.Lookup(inst_id)) { + inst_id = result.value(); + CARBON_CHECK(inst_id.is_valid()); + return true; + } + return false; + } + + // Build a new instruction in the eval block corresponding to the given + // constant. + auto Rebuild(SemIR::InstId orig_inst_id, SemIR::Inst new_inst) const + -> SemIR::InstId override { + // TODO: Add a function on `Context` to add the instruction without + // inserting it into the dependent instructions list or computing a constant + // value for it. + auto inst_id = context_.sem_ir().insts().AddInNoBlock( + SemIR::LocIdAndInst::NoLoc(new_inst)); + auto result = constants_in_generic_.Insert(orig_inst_id, inst_id); + CARBON_CHECK(result.is_inserted()) + << "Substituted into an instruction that was already in the map."; + auto const_id = AddGenericConstantToEvalBlock( + context_, generic_id_, region_, orig_inst_id, inst_id); + context_.constant_values().Set(inst_id, const_id); + return inst_id; + } + + private: + Context& context_; + SemIR::GenericId generic_id_; + SemIR::GenericInstIndex::Region region_; + Map& constants_in_generic_; +}; +} // namespace + +// Adds instructions to compute the substituted version of `type_id` in each +// instance of a generic into the eval block for the generic, which is the +// current instruction block. Returns a symbolic type ID that refers to the +// substituted type in each instance of the generic. +static auto AddGenericTypeToEvalBlock( + Context& context, SemIR::GenericId generic_id, + SemIR::GenericInstIndex::Region region, + Map& constants_in_generic, + SemIR::TypeId type_id) -> SemIR::TypeId { + // Substitute into the type's constant instruction and rebuild it in the eval + // block. + auto type_inst_id = + SubstInst(context, context.types().GetInstId(type_id), + RebuildGenericTypeInEvalBlockCallbacks( + context, generic_id, region, constants_in_generic)); + return context.GetTypeIdForTypeInst(type_inst_id); +} + +// Builds and returns a block of instructions whose constant values need to be +// evaluated in order to resolve a generic instance. +static auto MakeGenericEvalBlock(Context& context, SemIR::GenericId generic_id, + SemIR::GenericInstIndex::Region region) + -> SemIR::InstBlockId { + context.inst_block_stack().Push(); + + Map constants_in_generic; + // TODO: For the definition region, populate constants from the declaration. + // TODO: Add `BindSymbolicName` instructions for enclosing generics to the + // map. + + // The work done in this loop might invalidate iterators into the generic + // region stack, but shouldn't add new dependent instructions to the current + // region. + auto num_dependent_insts = + context.generic_region_stack().PeekDependentInsts().size(); + for (auto i : llvm::seq(num_dependent_insts)) { + auto [inst_id, dep_kind] = + context.generic_region_stack().PeekDependentInsts()[i]; + + // If the type is symbolic, replace it with a type specific to this generic. + if ((dep_kind & GenericRegionStack::DependencyKind::SymbolicType) != + GenericRegionStack::DependencyKind::None) { + auto inst = context.insts().Get(inst_id); + inst.SetType(AddGenericTypeToEvalBlock( + context, generic_id, region, constants_in_generic, inst.type_id())); + context.sem_ir().insts().Set(inst_id, inst); + } + + // If the instruction has a symbolic constant value, then make a note that + // we'll need to evaluate this instruction in the generic instance. Update + // the constant value of the instruction to refer to the result of that + // eventual evaluation. + if ((dep_kind & GenericRegionStack::DependencyKind::SymbolicConstant) != + GenericRegionStack::DependencyKind::None) { + auto const_inst_id = context.constant_values().GetConstantInstId(inst_id); + + // Create a new symbolic constant representing this instruction in this + // generic, if it doesn't already exist. + auto result = constants_in_generic.Insert(const_inst_id, inst_id); + auto const_id = + result.is_inserted() + ? AddGenericConstantToEvalBlock(context, generic_id, region, + const_inst_id, inst_id) + : context.constant_values().Get(result.value()); + context.constant_values().Set(inst_id, const_id); + } + } + + CARBON_CHECK(num_dependent_insts == + context.generic_region_stack().PeekDependentInsts().size()) + << "Building eval block added new dependent insts, for example " + << context.insts().Get(context.generic_region_stack() + .PeekDependentInsts()[num_dependent_insts] + .inst_id); + + return context.inst_block_stack().Pop(); +} + auto FinishGenericDecl(Context& context, SemIR::InstId decl_id) -> SemIR::GenericId { auto all_bindings = @@ -37,10 +195,15 @@ auto FinishGenericDecl(Context& context, SemIR::InstId decl_id) } auto bindings_id = context.inst_blocks().Add(all_bindings); - // TODO: Track the list of dependent instructions in this region. - context.generic_region_stack().Pop(); - return context.generics().Add( + auto generic_id = context.generics().Add( SemIR::Generic{.decl_id = decl_id, .bindings_id = bindings_id}); + + auto decl_block_id = MakeGenericEvalBlock( + context, generic_id, SemIR::GenericInstIndex::Region::Declaration); + context.generic_region_stack().Pop(); + + context.generics().Get(generic_id).decl_block_id = decl_block_id; + return generic_id; } auto FinishGenericRedecl(Context& context, SemIR::InstId /*decl_id*/, @@ -98,4 +261,35 @@ auto MakeGenericSelfInstance(Context& context, SemIR::GenericId generic_id) return MakeGenericInstance(context, generic_id, args_id); } +auto GetConstantInInstance(Context& context, + SemIR::GenericInstanceId /*instance_id*/, + SemIR::ConstantId const_id) -> SemIR::ConstantId { + if (!const_id.is_symbolic()) { + // Type does not depend on a generic parameter. + return const_id; + } + + const auto& symbolic = + context.constant_values().GetSymbolicConstant(const_id); + if (!symbolic.generic_id.is_valid()) { + // Constant is an abstract symbolic constant, not an instance-specific one. + return const_id; + } + + // TODO: Look up the value in the generic instance. For now, return the + // canonical constant value. + return context.constant_values().Get(symbolic.inst_id); +} + +auto GetTypeInInstance(Context& context, SemIR::GenericInstanceId instance_id, + SemIR::TypeId type_id) -> SemIR::TypeId { + auto const_id = context.types().GetConstantId(type_id); + auto inst_const_id = GetConstantInInstance(context, instance_id, const_id); + if (inst_const_id == const_id) { + // Common case: not an instance constant. + return type_id; + } + return context.GetTypeIdForTypeConstant(inst_const_id); +} + } // namespace Carbon::Check diff --git a/toolchain/check/generic.h b/toolchain/check/generic.h index d7c11161b51d..8a028cb1af41 100644 --- a/toolchain/check/generic.h +++ b/toolchain/check/generic.h @@ -45,6 +45,23 @@ auto MakeGenericInstance(Context& context, SemIR::GenericId generic_id, auto MakeGenericSelfInstance(Context& context, SemIR::GenericId generic_id) -> SemIR::GenericInstanceId; +// Gets the substituted value of a constant within a specified instance of a +// generic. Note that this does not perform substitution, and will return +// `Invalid` if the substituted constant value is not yet known. +// +// TODO: Move this to sem_ir so that lowering can use it. +auto GetConstantInInstance(Context& context, + SemIR::GenericInstanceId instance_id, + SemIR::ConstantId const_id) -> SemIR::ConstantId; + +// Gets the substituted value of a type within a specified instance of a +// generic. Note that this does not perform substitution, and will return +// `Invalid` if the substituted type is not yet known. +// +// TODO: Move this to sem_ir so that lowering can use it. +auto GetTypeInInstance(Context& context, SemIR::GenericInstanceId instance_id, + SemIR::TypeId type_id) -> SemIR::TypeId; + } // namespace Carbon::Check #endif // CARBON_TOOLCHAIN_CHECK_GENERIC_H_ diff --git a/toolchain/check/handle_function.cpp b/toolchain/check/handle_function.cpp index 634c71b68513..27e48a8a68c4 100644 --- a/toolchain/check/handle_function.cpp +++ b/toolchain/check/handle_function.cpp @@ -274,6 +274,16 @@ static auto BuildFunctionDecl(Context& context, } function_decl.type_id = context.GetFunctionType(function_decl.function_id); + // TODO: Temporarily replace the return type with the canonical return type. + // This is a placeholder to avoid breaking tests before generic type + // substitution is ready. + if (return_storage_id.is_valid()) { + auto return_storage = context.insts().Get(return_storage_id); + return_storage.SetType(GetTypeInInstance( + context, SemIR::GenericInstanceId::Invalid, return_storage.type_id())); + context.sem_ir().insts().Set(return_storage_id, return_storage); + } + // Write the function ID into the FunctionDecl. context.ReplaceInstBeforeConstantUse(decl_id, function_decl); diff --git a/toolchain/check/handle_name.cpp b/toolchain/check/handle_name.cpp index e1e35632401c..2149a01e58c3 100644 --- a/toolchain/check/handle_name.cpp +++ b/toolchain/check/handle_name.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/check/context.h" +#include "toolchain/check/generic.h" #include "toolchain/check/handle.h" #include "toolchain/check/member_access.h" #include "toolchain/check/name_component.h" @@ -80,10 +81,14 @@ static auto GetIdentifierAsName(Context& context, Parse::NodeId node_id) static auto HandleNameAsExpr(Context& context, Parse::NodeId node_id, SemIR::NameId name_id) -> bool { auto value_id = context.LookupUnqualifiedName(node_id, name_id); + // TODO: Lookup should produce this. + auto instance_id = SemIR::GenericInstanceId::Invalid; auto value = context.insts().Get(value_id); + auto type_id = GetTypeInInstance(context, instance_id, value.type_id()); + CARBON_CHECK(type_id.is_valid()) << "Missing type for " << value; + context.AddInstAndPush( - node_id, - {.type_id = value.type_id(), .name_id = name_id, .value_id = value_id}); + node_id, {.type_id = type_id, .name_id = name_id, .value_id = value_id}); return true; } diff --git a/toolchain/check/member_access.cpp b/toolchain/check/member_access.cpp index af644a99e0d9..3fcd8a635833 100644 --- a/toolchain/check/member_access.cpp +++ b/toolchain/check/member_access.cpp @@ -132,7 +132,7 @@ static auto LookupInterfaceWitness(Context& context, // considering impls that are for the same interface we're querying. We can // also skip impls that mention any types that aren't part of our impl query. for (const auto& impl : context.impls().array_ref()) { - if (!context.constant_values().EqualAcrossDeclarations( + if (!context.constant_values().AreEqualAcrossDeclarations( context.types().GetConstantId(impl.self_id), type_const_id)) { continue; } diff --git a/toolchain/check/merge.cpp b/toolchain/check/merge.cpp index 2c7c3cb1bfb7..de85034f8f23 100644 --- a/toolchain/check/merge.cpp +++ b/toolchain/check/merge.cpp @@ -174,8 +174,9 @@ static auto CheckRedeclParam(Context& context, auto new_param_ref = context.insts().Get(new_param_ref_id); auto prev_param_ref = context.insts().Get(prev_param_ref_id); if (new_param_ref.kind() != prev_param_ref.kind() || - new_param_ref.type_id() != - SubstType(context, prev_param_ref.type_id(), substitutions)) { + !context.types().AreEqualAcrossDeclarations( + new_param_ref.type_id(), + SubstType(context, prev_param_ref.type_id(), substitutions))) { diagnose(); return false; } diff --git a/toolchain/check/subst.cpp b/toolchain/check/subst.cpp index 7c87be577959..57916002677d 100644 --- a/toolchain/check/subst.cpp +++ b/toolchain/check/subst.cpp @@ -8,6 +8,7 @@ #include "toolchain/check/generic.h" #include "toolchain/sem_ir/copy_on_write_block.h" #include "toolchain/sem_ir/ids.h" +#include "toolchain/sem_ir/inst.h" namespace Carbon::Check { @@ -40,6 +41,7 @@ class Worklist { auto back() -> WorklistItem& { return worklist_.back(); } auto Push(SemIR::InstId inst_id) -> void { + CARBON_CHECK(inst_id.is_valid()); worklist_.push_back({.inst_id = inst_id, .is_expanded = false, .next_index = static_cast(worklist_.size() + 1)}); @@ -61,7 +63,9 @@ static auto PushOperand(Context& context, Worklist& worklist, SemIR::IdKind kind, int32_t arg) -> void { switch (kind) { case SemIR::IdKind::For: - worklist.Push(SemIR::InstId(arg)); + if (auto inst_id = SemIR::InstId(arg); inst_id.is_valid()) { + worklist.Push(inst_id); + } break; case SemIR::IdKind::For: if (auto type_id = SemIR::TypeId(arg); type_id.is_valid()) { @@ -106,8 +110,13 @@ static auto ExpandOperands(Context& context, Worklist& worklist, static auto PopOperand(Context& context, Worklist& worklist, SemIR::IdKind kind, int32_t arg) -> int32_t { switch (kind) { - case SemIR::IdKind::For: + case SemIR::IdKind::For: { + auto inst_id = SemIR::InstId(arg); + if (!inst_id.is_valid()) { + return arg; + } return worklist.Pop().index; + } case SemIR::IdKind::For: { auto type_id = SemIR::TypeId(arg); if (!type_id.is_valid()) { @@ -137,7 +146,7 @@ static auto PopOperand(Context& context, Worklist& worklist, SemIR::IdKind kind, return new_type_block.GetCanonical().index; } case SemIR::IdKind::For: { - auto instance_id = static_cast(arg); + auto instance_id = SemIR::GenericInstanceId(arg); if (!instance_id.is_valid()) { return arg; } @@ -146,7 +155,7 @@ static auto PopOperand(Context& context, Worklist& worklist, SemIR::IdKind kind, PopOperand(context, worklist, SemIR::IdKind::For, instance.args_id.index); return MakeGenericInstance(context, instance.generic_id, - static_cast(args_id)) + SemIR::InstBlockId(args_id)) .index; } default: @@ -155,9 +164,9 @@ static auto PopOperand(Context& context, Worklist& worklist, SemIR::IdKind kind, } // Pops the operands of the specified instruction off the worklist and rebuilds -// the instruction with the updated operands. -static auto Rebuild(Context& context, Worklist& worklist, SemIR::InstId inst_id) - -> SemIR::InstId { +// the instruction with the updated operands if it has changed. +static auto Rebuild(Context& context, Worklist& worklist, SemIR::InstId inst_id, + const SubstInstCallbacks& callbacks) -> SemIR::InstId { auto inst = context.insts().Get(inst_id); auto kinds = inst.ArgKinds(); @@ -175,28 +184,12 @@ static auto Rebuild(Context& context, Worklist& worklist, SemIR::InstId inst_id) // TODO: Do we need to require this type to be complete? inst.SetType(SemIR::TypeId(type_id)); inst.SetArgs(arg0, arg1); - auto result_id = TryEvalInst(context, SemIR::InstId::Invalid, inst); - CARBON_CHECK(result_id.is_constant()) - << "Substitution into constant produced non-constant"; - return context.constant_values().GetInstId(result_id); + return callbacks.Rebuild(inst_id, inst); } -auto SubstConstant(Context& context, SemIR::ConstantId const_id, - Substitutions substitutions) -> SemIR::ConstantId { - CARBON_CHECK(const_id.is_constant()) << "Substituting into non-constant"; - - if (substitutions.empty()) { - // Nothing to substitute. - return const_id; - } - - if (!const_id.is_symbolic()) { - // A template constant can't contain a reference to a symbolic binding. - return const_id; - } - - // TODO: Consider caching; we may perform the same substitutions repeatedly. - Worklist worklist(context.constant_values().GetInstId(const_id)); +auto SubstInst(Context& context, SemIR::InstId inst_id, + const SubstInstCallbacks& callbacks) -> SemIR::InstId { + Worklist worklist(inst_id); // For each instruction that forms part of the constant, we will visit it // twice: @@ -217,35 +210,12 @@ auto SubstConstant(Context& context, SemIR::ConstantId const_id, if (item.is_expanded) { // Rebuild this item if necessary. Note that this might pop items from the // worklist but does not reallocate, so does not invalidate `item`. - item.inst_id = Rebuild(context, worklist, item.inst_id); + item.inst_id = Rebuild(context, worklist, item.inst_id, callbacks); index = item.next_index; continue; } - if (context.constant_values().Get(item.inst_id).is_template()) { - // This instruction is a template constant, so can't contain any - // bindings that need to be substituted. - index = item.next_index; - continue; - } - - if (auto bind = - context.insts().TryGetAs(item.inst_id)) { - // This is a symbolic binding. Check if we're substituting it. - - // 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 == - bind_index) { - // This is the binding we're replacing. Perform substitution. - item.inst_id = context.constant_values().GetInstId(replacement_id); - break; - } - } - - // If it's not being substituted, don't look through it. Its constant - // value doesn't depend on its operand. + if (callbacks.Subst(item.inst_id)) { index = item.next_index; continue; } @@ -264,14 +234,89 @@ auto SubstConstant(Context& context, SemIR::ConstantId const_id, worklist.back().next_index = index; index = first_operand; } else { - // No need to rebuild this instruction. + // No need to rebuild this instruction: its operands can't be changed by + // substitution because it has none. index = next_index; } } CARBON_CHECK(worklist.size() == 1) << "Unexpected data left behind in work list"; - return context.constant_values().Get(worklist.back().inst_id); + return worklist.back().inst_id; +} + +namespace { +// Callbacks for performing substitution of a set of Substitutions into a +// symbolic constant. +class SubstConstantCallbacks : public SubstInstCallbacks { + public: + SubstConstantCallbacks(Context& context, Substitutions substitutions) + : context_(context), substitutions_(substitutions) {} + + // Applies the given Substitutions to an instruction, in order to replace + // BindSymbolicName instructions with the value of the binding. + auto Subst(SemIR::InstId& inst_id) const -> bool override { + if (context_.constant_values().Get(inst_id).is_template()) { + // This instruction is a template constant, so can't contain any + // bindings that need to be substituted. + return true; + } + + auto bind = context_.insts().TryGetAs(inst_id); + if (!bind) { + return false; + } + + // This is a symbolic binding. Check if we're substituting it. + // 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 == + bind_index) { + // This is the binding we're replacing. Perform substitution. + inst_id = context_.constant_values().GetInstId(replacement_id); + return true; + } + } + + // If it's not being substituted, don't look through it. Its constant + // value doesn't depend on its operand. + return true; + } + + // Rebuilds an instruction by building a new constant. + auto Rebuild(SemIR::InstId /*old_inst_id*/, SemIR::Inst new_inst) const + -> SemIR::InstId override { + auto result_id = TryEvalInst(context_, SemIR::InstId::Invalid, new_inst); + CARBON_CHECK(result_id.is_constant()) + << "Substitution into constant produced non-constant"; + return context_.constant_values().GetInstId(result_id); + } + + private: + Context& context_; + Substitutions substitutions_; +}; +} // namespace + +auto SubstConstant(Context& context, SemIR::ConstantId const_id, + Substitutions substitutions) -> SemIR::ConstantId { + CARBON_CHECK(const_id.is_constant()) << "Substituting into non-constant"; + + if (substitutions.empty()) { + // Nothing to substitute. + return const_id; + } + + if (!const_id.is_symbolic()) { + // A template constant can't contain a reference to a symbolic binding. + return const_id; + } + + auto subst_inst_id = + SubstInst(context, context.constant_values().GetInstId(const_id), + SubstConstantCallbacks(context, substitutions)); + return context.constant_values().Get(subst_inst_id); } auto SubstType(Context& context, SemIR::TypeId type_id, diff --git a/toolchain/check/subst.h b/toolchain/check/subst.h index 8cef1ed056c3..1faf6e9b9650 100644 --- a/toolchain/check/subst.h +++ b/toolchain/check/subst.h @@ -10,6 +10,34 @@ namespace Carbon::Check { +// Callbacks used by SubstInst to recursively substitute into and rebuild an +// instruction. +class SubstInstCallbacks { + public: + // Performs any needed substitution into an instruction. The instruction ID + // should be updated as necessary to represent the new instruction. Returns + // true if the resulting instruction ID is fully-substituted, or false if + // substitution may be needed into operands of the instruction. + virtual auto Subst(SemIR::InstId& inst_id) const -> bool = 0; + + // Rebuilds an instruction whose operands were changed by substitution. + // `orig_inst_id` is the instruction prior to substitution, and `new_inst` is + // the substituted instruction. Returns the new instruction ID to use to refer + // to `new_inst`. + virtual auto Rebuild(SemIR::InstId orig_inst_id, SemIR::Inst new_inst) const + -> SemIR::InstId = 0; +}; + +// Performs substitution into `inst_id` and its operands recursively, using +// `callbacks` to process each instruction. For each instruction encountered, +// calls `Subst` to perform substitution on that instruction. +// +// If `Subst` returns false, the instruction is decomposed into its operands, +// which are substituted recursively, and if any of them change then `Rebuild` +// is used to build a new instruction with the substituted operands. +auto SubstInst(Context& context, SemIR::InstId inst_id, + const SubstInstCallbacks& callbacks) -> SemIR::InstId; + // A substitution that is being performed. struct Substitution { // The index of a `BindSymbolicName` instruction that is being replaced. diff --git a/toolchain/check/testdata/array/generic_empty.carbon b/toolchain/check/testdata/array/generic_empty.carbon index a5a82dc672a5..8dc53cd8be6a 100644 --- a/toolchain/check/testdata/array/generic_empty.carbon +++ b/toolchain/check/testdata/array/generic_empty.carbon @@ -35,7 +35,7 @@ fn G(T:! type) { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %T.loc11_6.1: type = param T -// CHECK:STDOUT: @G.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = constants.%T] +// CHECK:STDOUT: @G.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @G.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon b/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon index 5dca2899dad7..84461a1c63f6 100644 --- a/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon +++ b/toolchain/check/testdata/basics/no_prelude/raw_ir.carbon @@ -28,7 +28,7 @@ fn Foo[T:! type](n: T) -> (T, ()) { // 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: functions: -// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: block5, return_storage: inst+15, return_slot: present, body: [block9]} +// CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, param_refs: block5, return_storage: inst+15, return_slot: present, body: [block10]} // CHECK:STDOUT: classes: {} // CHECK:STDOUT: generics: // CHECK:STDOUT: generic0: {decl: inst+16, bindings: block8} @@ -38,9 +38,11 @@ fn Foo[T:! type](n: T) -> (T, ()) { // CHECK:STDOUT: type1: {constant: symbolic 0, value_rep: {kind: copy, type: type1}} // CHECK:STDOUT: type2: {constant: template inst+8, value_rep: {kind: none, type: type2}} // CHECK:STDOUT: type3: {constant: template inst+10, value_rep: {kind: unknown, type: type}} -// CHECK:STDOUT: type4: {constant: symbolic 1, value_rep: {kind: pointer, type: type6}} -// CHECK:STDOUT: type5: {constant: template inst+17, value_rep: {kind: none, type: type2}} -// CHECK:STDOUT: type6: {constant: symbolic 2, value_rep: {kind: copy, type: type6}} +// CHECK:STDOUT: type4: {constant: symbolic 1, value_rep: {kind: pointer, type: type8}} +// CHECK:STDOUT: type5: {constant: symbolic 2, value_rep: {kind: copy, type: type5}} +// CHECK:STDOUT: type6: {constant: symbolic 3, value_rep: {kind: unknown, type: type}} +// CHECK:STDOUT: type7: {constant: template inst+17, value_rep: {kind: none, type: type2}} +// CHECK:STDOUT: type8: {constant: symbolic 4, value_rep: {kind: copy, type: type8}} // CHECK:STDOUT: type_blocks: // CHECK:STDOUT: type_block0: {} // CHECK:STDOUT: type_block1: @@ -55,8 +57,8 @@ fn Foo[T:! type](n: T) -> (T, ()) { // 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+4': {kind: NameRef, arg0: name1, arg1: inst+2, type: typeTypeType} -// CHECK:STDOUT: 'inst+5': {kind: Param, arg0: name2, type: type1} -// CHECK:STDOUT: 'inst+6': {kind: BindName, arg0: bind_name1, arg1: inst+5, type: type1} +// CHECK:STDOUT: 'inst+5': {kind: Param, arg0: name2, type: type5} +// CHECK:STDOUT: 'inst+6': {kind: BindName, arg0: bind_name1, arg1: inst+5, type: type5} // 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: type2} @@ -66,37 +68,37 @@ fn Foo[T:! type](n: T) -> (T, ()) { // CHECK:STDOUT: 'inst+13': {kind: TupleType, arg0: type_block2, type: typeTypeType} // CHECK:STDOUT: 'inst+14': {kind: Converted, arg0: inst+11, arg1: inst+13, type: typeTypeType} // CHECK:STDOUT: 'inst+15': {kind: VarStorage, arg0: nameReturnSlot, type: type4} -// CHECK:STDOUT: 'inst+16': {kind: FunctionDecl, arg0: function0, arg1: block7, type: type5} +// CHECK:STDOUT: 'inst+16': {kind: FunctionDecl, arg0: function0, arg1: block7, type: type7} // CHECK:STDOUT: 'inst+17': {kind: FunctionType, arg0: function0, type: typeTypeType} -// CHECK:STDOUT: 'inst+18': {kind: StructValue, arg0: empty, type: type5} +// CHECK:STDOUT: 'inst+18': {kind: StructValue, arg0: empty, type: type7} // CHECK:STDOUT: 'inst+19': {kind: PointerType, arg0: type4, type: typeTypeType} // CHECK:STDOUT: 'inst+20': {kind: NameRef, arg0: name2, arg1: inst+6, type: type1} // CHECK:STDOUT: 'inst+21': {kind: TupleLiteral, arg0: empty, type: type2} -// CHECK:STDOUT: 'inst+22': {kind: TupleLiteral, arg0: block10, type: type4} +// CHECK:STDOUT: 'inst+22': {kind: TupleLiteral, arg0: block11, type: type4} // CHECK:STDOUT: 'inst+23': {kind: TupleAccess, arg0: inst+15, arg1: element0, type: type1} // CHECK:STDOUT: 'inst+24': {kind: InitializeFrom, arg0: inst+20, arg1: inst+23, type: type1} // CHECK:STDOUT: 'inst+25': {kind: TupleAccess, arg0: inst+15, arg1: element1, type: type2} // CHECK:STDOUT: 'inst+26': {kind: TupleInit, arg0: empty, arg1: inst+25, type: type2} -// CHECK:STDOUT: 'inst+27': {kind: TupleValue, arg0: block12, type: type2} +// CHECK:STDOUT: 'inst+27': {kind: TupleValue, arg0: block13, type: type2} // CHECK:STDOUT: 'inst+28': {kind: Converted, arg0: inst+21, arg1: inst+26, type: type2} -// CHECK:STDOUT: 'inst+29': {kind: TupleInit, arg0: block11, arg1: inst+15, type: type4} +// CHECK:STDOUT: 'inst+29': {kind: TupleInit, arg0: block12, arg1: inst+15, type: type4} // CHECK:STDOUT: 'inst+30': {kind: Converted, arg0: inst+22, arg1: inst+29, type: type4} // CHECK:STDOUT: 'inst+31': {kind: ReturnExpr, arg0: inst+30, arg1: inst+15} // CHECK:STDOUT: constant_values: // CHECK:STDOUT: 'inst+0': template inst+0 -// CHECK:STDOUT: 'inst+2': symbolic 0 +// CHECK:STDOUT: 'inst+2': symbolic 2 // CHECK:STDOUT: 'inst+3': symbolic 0 -// CHECK:STDOUT: 'inst+4': symbolic 0 -// CHECK:STDOUT: 'inst+7': symbolic 0 +// CHECK:STDOUT: 'inst+4': symbolic 2 +// CHECK:STDOUT: 'inst+7': symbolic 2 // CHECK:STDOUT: 'inst+8': template inst+8 // CHECK:STDOUT: 'inst+10': template inst+10 // CHECK:STDOUT: 'inst+12': template inst+8 // CHECK:STDOUT: 'inst+13': symbolic 1 -// CHECK:STDOUT: 'inst+14': symbolic 1 +// CHECK:STDOUT: 'inst+14': symbolic 3 // CHECK:STDOUT: 'inst+16': template inst+18 // CHECK:STDOUT: 'inst+17': template inst+17 // CHECK:STDOUT: 'inst+18': template inst+18 -// CHECK:STDOUT: 'inst+19': symbolic 2 +// CHECK:STDOUT: 'inst+19': symbolic 4 // CHECK:STDOUT: 'inst+26': template inst+27 // CHECK:STDOUT: 'inst+27': template inst+27 // CHECK:STDOUT: 'inst+28': template inst+27 @@ -128,6 +130,9 @@ fn Foo[T:! type](n: T) -> (T, ()) { // CHECK:STDOUT: block8: // CHECK:STDOUT: 0: inst+2 // CHECK:STDOUT: block9: +// CHECK:STDOUT: 0: inst+2 +// CHECK:STDOUT: 1: inst+14 +// CHECK:STDOUT: block10: // CHECK:STDOUT: 0: inst+20 // CHECK:STDOUT: 1: inst+21 // CHECK:STDOUT: 2: inst+22 @@ -139,14 +144,14 @@ fn Foo[T:! type](n: T) -> (T, ()) { // CHECK:STDOUT: 8: inst+29 // CHECK:STDOUT: 9: inst+30 // CHECK:STDOUT: 10: inst+31 -// CHECK:STDOUT: block10: +// CHECK:STDOUT: block11: // CHECK:STDOUT: 0: inst+20 // CHECK:STDOUT: 1: inst+21 -// CHECK:STDOUT: block11: +// CHECK:STDOUT: block12: // CHECK:STDOUT: 0: inst+24 // CHECK:STDOUT: 1: inst+28 -// CHECK:STDOUT: block12: {} -// CHECK:STDOUT: block13: +// CHECK:STDOUT: block13: {} +// CHECK:STDOUT: block14: // CHECK:STDOUT: 0: inst+0 // CHECK:STDOUT: 1: inst+16 // CHECK:STDOUT: ... diff --git a/toolchain/check/testdata/builtins/int/make_type_signed.carbon b/toolchain/check/testdata/builtins/int/make_type_signed.carbon index 1af453f4a481..6b86137c0f54 100644 --- a/toolchain/check/testdata/builtins/int/make_type_signed.carbon +++ b/toolchain/check/testdata/builtins/int/make_type_signed.carbon @@ -177,19 +177,19 @@ var m: Int(1000000000); // CHECK:STDOUT: %.loc14_17.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_17.2: type = converted %int.make_type_32, %.loc14_17.1 [template = i32] // CHECK:STDOUT: %N.loc14_13.1: i32 = param N -// CHECK:STDOUT: @Symbolic.%N: i32 = bind_symbolic_name N 0, %N.loc14_13.1 [symbolic = constants.%N] +// CHECK:STDOUT: @Symbolic.%N: i32 = bind_symbolic_name N 0, %N.loc14_13.1 [symbolic = @Symbolic.%N (constants.%N)] // CHECK:STDOUT: %Int.ref.loc14_25: %Int.type = name_ref Int, imports.%import_ref.1 [template = constants.%Int] -// CHECK:STDOUT: %N.ref.loc14_29: i32 = name_ref N, @Symbolic.%N [symbolic = constants.%N] -// CHECK:STDOUT: %int.make_type_signed.loc14_28: init type = call %Int.ref.loc14_25(%N.ref.loc14_29) [symbolic = constants.%.6] -// CHECK:STDOUT: %.loc14_30.1: type = value_of_initializer %int.make_type_signed.loc14_28 [symbolic = constants.%.6] -// CHECK:STDOUT: %.loc14_30.2: type = converted %int.make_type_signed.loc14_28, %.loc14_30.1 [symbolic = constants.%.6] -// CHECK:STDOUT: %x.loc14_22.1: %.6 = param x -// CHECK:STDOUT: @Symbolic.%x: %.6 = bind_name x, %x.loc14_22.1 +// CHECK:STDOUT: %N.ref.loc14_29: i32 = name_ref N, @Symbolic.%N [symbolic = @Symbolic.%N (constants.%N)] +// CHECK:STDOUT: %int.make_type_signed.loc14_28: init type = call %Int.ref.loc14_25(%N.ref.loc14_29) [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] +// CHECK:STDOUT: %.loc14_30.1: type = value_of_initializer %int.make_type_signed.loc14_28 [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] +// CHECK:STDOUT: %.loc14_30.2: type = converted %int.make_type_signed.loc14_28, %.loc14_30.1 [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] +// CHECK:STDOUT: %x.loc14_22.1: file.%int.make_type_signed.loc14_28 (%.6) = param x +// CHECK:STDOUT: @Symbolic.%x: file.%int.make_type_signed.loc14_28 (%.6) = bind_name x, %x.loc14_22.1 // CHECK:STDOUT: %Int.ref.loc14_36: %Int.type = name_ref Int, imports.%import_ref.1 [template = constants.%Int] -// CHECK:STDOUT: %N.ref.loc14_40: i32 = name_ref N, @Symbolic.%N [symbolic = constants.%N] -// CHECK:STDOUT: %int.make_type_signed.loc14_39: init type = call %Int.ref.loc14_36(%N.ref.loc14_40) [symbolic = constants.%.6] -// CHECK:STDOUT: %.loc14_41.1: type = value_of_initializer %int.make_type_signed.loc14_39 [symbolic = constants.%.6] -// CHECK:STDOUT: %.loc14_41.2: type = converted %int.make_type_signed.loc14_39, %.loc14_41.1 [symbolic = constants.%.6] +// CHECK:STDOUT: %N.ref.loc14_40: i32 = name_ref N, @Symbolic.%N [symbolic = @Symbolic.%N (constants.%N)] +// CHECK:STDOUT: %int.make_type_signed.loc14_39: init type = call %Int.ref.loc14_36(%N.ref.loc14_40) [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] +// CHECK:STDOUT: %.loc14_41.1: type = value_of_initializer %int.make_type_signed.loc14_39 [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] +// CHECK:STDOUT: %.loc14_41.2: type = converted %int.make_type_signed.loc14_39, %.loc14_41.1 [symbolic = %int.make_type_signed.loc14_28 (constants.%.6)] // CHECK:STDOUT: @Symbolic.%return: ref %.6 = var // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -210,7 +210,7 @@ var m: Int(1000000000); // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Symbolic(%N: i32, %x: %.6) -> %.6 +// CHECK:STDOUT: fn @Symbolic(%N: i32, %x: file.%int.make_type_signed.loc14_28 (%.6)) -> %.6 // CHECK:STDOUT: generic [%N: i32] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.ref: %.6 = name_ref x, %x diff --git a/toolchain/check/testdata/builtins/int/make_type_unsigned.carbon b/toolchain/check/testdata/builtins/int/make_type_unsigned.carbon index 76bf25226e66..1779bda7b027 100644 --- a/toolchain/check/testdata/builtins/int/make_type_unsigned.carbon +++ b/toolchain/check/testdata/builtins/int/make_type_unsigned.carbon @@ -177,19 +177,19 @@ var m: UInt(1000000000); // CHECK:STDOUT: %.loc14_17.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_17.2: type = converted %int.make_type_32, %.loc14_17.1 [template = i32] // CHECK:STDOUT: %N.loc14_13.1: i32 = param N -// CHECK:STDOUT: @Symbolic.%N: i32 = bind_symbolic_name N 0, %N.loc14_13.1 [symbolic = constants.%N] +// CHECK:STDOUT: @Symbolic.%N: i32 = bind_symbolic_name N 0, %N.loc14_13.1 [symbolic = @Symbolic.%N (constants.%N)] // CHECK:STDOUT: %UInt.ref.loc14_25: %UInt.type = name_ref UInt, imports.%import_ref.1 [template = constants.%UInt] -// CHECK:STDOUT: %N.ref.loc14_30: i32 = name_ref N, @Symbolic.%N [symbolic = constants.%N] -// CHECK:STDOUT: %int.make_type_unsigned.loc14_29: init type = call %UInt.ref.loc14_25(%N.ref.loc14_30) [symbolic = constants.%.6] -// CHECK:STDOUT: %.loc14_31.1: type = value_of_initializer %int.make_type_unsigned.loc14_29 [symbolic = constants.%.6] -// CHECK:STDOUT: %.loc14_31.2: type = converted %int.make_type_unsigned.loc14_29, %.loc14_31.1 [symbolic = constants.%.6] -// CHECK:STDOUT: %x.loc14_22.1: %.6 = param x -// CHECK:STDOUT: @Symbolic.%x: %.6 = bind_name x, %x.loc14_22.1 +// CHECK:STDOUT: %N.ref.loc14_30: i32 = name_ref N, @Symbolic.%N [symbolic = @Symbolic.%N (constants.%N)] +// CHECK:STDOUT: %int.make_type_unsigned.loc14_29: init type = call %UInt.ref.loc14_25(%N.ref.loc14_30) [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] +// CHECK:STDOUT: %.loc14_31.1: type = value_of_initializer %int.make_type_unsigned.loc14_29 [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] +// CHECK:STDOUT: %.loc14_31.2: type = converted %int.make_type_unsigned.loc14_29, %.loc14_31.1 [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] +// CHECK:STDOUT: %x.loc14_22.1: file.%int.make_type_unsigned.loc14_29 (%.6) = param x +// CHECK:STDOUT: @Symbolic.%x: file.%int.make_type_unsigned.loc14_29 (%.6) = bind_name x, %x.loc14_22.1 // CHECK:STDOUT: %UInt.ref.loc14_37: %UInt.type = name_ref UInt, imports.%import_ref.1 [template = constants.%UInt] -// CHECK:STDOUT: %N.ref.loc14_42: i32 = name_ref N, @Symbolic.%N [symbolic = constants.%N] -// CHECK:STDOUT: %int.make_type_unsigned.loc14_41: init type = call %UInt.ref.loc14_37(%N.ref.loc14_42) [symbolic = constants.%.6] -// CHECK:STDOUT: %.loc14_43.1: type = value_of_initializer %int.make_type_unsigned.loc14_41 [symbolic = constants.%.6] -// CHECK:STDOUT: %.loc14_43.2: type = converted %int.make_type_unsigned.loc14_41, %.loc14_43.1 [symbolic = constants.%.6] +// CHECK:STDOUT: %N.ref.loc14_42: i32 = name_ref N, @Symbolic.%N [symbolic = @Symbolic.%N (constants.%N)] +// CHECK:STDOUT: %int.make_type_unsigned.loc14_41: init type = call %UInt.ref.loc14_37(%N.ref.loc14_42) [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] +// CHECK:STDOUT: %.loc14_43.1: type = value_of_initializer %int.make_type_unsigned.loc14_41 [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] +// CHECK:STDOUT: %.loc14_43.2: type = converted %int.make_type_unsigned.loc14_41, %.loc14_43.1 [symbolic = %int.make_type_unsigned.loc14_29 (constants.%.6)] // CHECK:STDOUT: @Symbolic.%return: ref %.6 = var // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -210,7 +210,7 @@ var m: UInt(1000000000); // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Symbolic(%N: i32, %x: %.6) -> %.6 +// CHECK:STDOUT: fn @Symbolic(%N: i32, %x: file.%int.make_type_unsigned.loc14_29 (%.6)) -> %.6 // CHECK:STDOUT: generic [%N: i32] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.ref: %.6 = name_ref x, %x diff --git a/toolchain/check/testdata/class/fail_generic_method.carbon b/toolchain/check/testdata/class/fail_generic_method.carbon index e3654eddc231..a0c5c3fb6056 100644 --- a/toolchain/check/testdata/class/fail_generic_method.carbon +++ b/toolchain/check/testdata/class/fail_generic_method.carbon @@ -63,14 +63,14 @@ fn Class(N:! i32).F[self: Self](n: T) {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc32_14.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc32_14.2: type = converted %int.make_type_32, %.loc32_14.1 [template = i32] // CHECK:STDOUT: %N.loc32_10.1: i32 = param N -// CHECK:STDOUT: %N.loc32_10.2: i32 = bind_symbolic_name N 0, %N.loc32_10.1 [symbolic = constants.%N] +// CHECK:STDOUT: %N.loc32_10.2: i32 = bind_symbolic_name N 0, %N.loc32_10.1 [symbolic = %N.loc32_10.2 (constants.%N)] // CHECK:STDOUT: %Self.ref: = name_ref Self, [template = ] // CHECK:STDOUT: %self.loc32_21.1: = param self // CHECK:STDOUT: @.1.%self: = bind_name self, %self.loc32_21.1 @@ -85,12 +85,12 @@ fn Class(N:! i32).F[self: Self](n: T) {} // CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] // CHECK:STDOUT: %.loc12: %.2 = field_decl a, element0 [template] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class.2 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %self.loc13_8.1: %Class.2 = param self -// CHECK:STDOUT: %self.loc13_8.2: %Class.2 = bind_name self, %self.loc13_8.1 -// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %n.loc13_20.1: %T = param n -// CHECK:STDOUT: %n.loc13_20.2: %T = bind_name n, %n.loc13_20.1 +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class.2 [symbolic = %Self.ref (constants.%Class.2)] +// CHECK:STDOUT: %self.loc13_8.1: @Class.%Self.ref (%Class.2) = param self +// CHECK:STDOUT: %self.loc13_8.2: @Class.%Self.ref (%Class.2) = bind_name self, %self.loc13_8.1 +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc13 (constants.%T)] +// CHECK:STDOUT: %n.loc13_20.1: @Class.%T.ref.loc13 (%T) = param n +// CHECK:STDOUT: %n.loc13_20.2: @Class.%T.ref.loc13 (%T) = bind_name n, %n.loc13_20.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -99,7 +99,7 @@ fn Class(N:! i32).F[self: Self](n: T) {} // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F[@Class.%self.loc13_8.2: %Class.2](@Class.%n.loc13_20.2: %T) +// CHECK:STDOUT: fn @F[@Class.%self.loc13_8.2: @Class.%Self.ref (%Class.2)](@Class.%n.loc13_20.2: @Class.%T.ref.loc13 (%T)) // CHECK:STDOUT: generic [file.%T.loc11_13.2: type]; // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; diff --git a/toolchain/check/testdata/class/generic/basic.carbon b/toolchain/check/testdata/class/generic/basic.carbon index b8964c725353..82ae63d9b3b4 100644 --- a/toolchain/check/testdata/class/generic/basic.carbon +++ b/toolchain/check/testdata/class/generic/basic.carbon @@ -50,27 +50,27 @@ class Class(T:! type) { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: %GetAddr.decl: %GetAddr.type = fn_decl @GetAddr [template = constants.%GetAddr] { -// CHECK:STDOUT: %Self.ref.loc12: type = name_ref Self, constants.%Class.2 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %.loc12_29: type = ptr_type %Class.2 [symbolic = constants.%.2] -// CHECK:STDOUT: %self.loc12_19.1: %.2 = param self -// CHECK:STDOUT: %self.loc12_19.3: %.2 = bind_name self, %self.loc12_19.1 -// CHECK:STDOUT: %.loc12_14: %.2 = addr_pattern %self.loc12_19.3 -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12_38: type = ptr_type %T [symbolic = constants.%.3] +// CHECK:STDOUT: %Self.ref.loc12: type = name_ref Self, constants.%Class.2 [symbolic = %Self.ref.loc12 (constants.%Class.2)] +// CHECK:STDOUT: %.loc12_29: type = ptr_type %Class.2 [symbolic = %.loc12_29 (constants.%.2)] +// CHECK:STDOUT: %self.loc12_19.1: @Class.%.loc12_29 (%.2) = param self +// CHECK:STDOUT: %self.loc12_19.3: @Class.%.loc12_29 (%.2) = bind_name self, %self.loc12_19.1 +// CHECK:STDOUT: %.loc12_14: @Class.%.loc12_29 (%.2) = addr_pattern %self.loc12_19.3 +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12 (constants.%T)] +// CHECK:STDOUT: %.loc12_38: type = ptr_type %T [symbolic = %.loc12_38 (constants.%.3)] // CHECK:STDOUT: %return.var.loc12: ref %.3 = var // CHECK:STDOUT: } // CHECK:STDOUT: %GetValue.decl: %GetValue.type = fn_decl @GetValue [template = constants.%GetValue] { -// CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class.2 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %self.loc17_15.1: %Class.2 = param self -// CHECK:STDOUT: %self.loc17_15.2: %Class.2 = bind_name self, %self.loc17_15.1 -// CHECK:STDOUT: %T.ref.loc17: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] +// CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, constants.%Class.2 [symbolic = %Self.ref.loc17 (constants.%Class.2)] +// CHECK:STDOUT: %self.loc17_15.1: @Class.%Self.ref.loc17 (%Class.2) = param self +// CHECK:STDOUT: %self.loc17_15.2: @Class.%Self.ref.loc17 (%Class.2) = bind_name self, %self.loc17_15.1 +// CHECK:STDOUT: %T.ref.loc17: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc17 (constants.%T)] // CHECK:STDOUT: %return.var.loc17: ref %T = var // CHECK:STDOUT: } // CHECK:STDOUT: %T.ref.loc21: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] @@ -83,7 +83,7 @@ class Class(T:! type) { // CHECK:STDOUT: .k = %.loc21 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @GetAddr[addr @Class.%self.loc12_19.3: %.2]() -> %.3 +// CHECK:STDOUT: fn @GetAddr[addr @Class.%self.loc12_19.3: @Class.%.loc12_29 (%.2)]() -> %.3 // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %.2 = name_ref self, @Class.%self.loc12_19.3 @@ -94,7 +94,7 @@ class Class(T:! type) { // CHECK:STDOUT: return %.loc13_12 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @GetValue[@Class.%self.loc17_15.2: %Class.2]() -> %T +// CHECK:STDOUT: fn @GetValue[@Class.%self.loc17_15.2: @Class.%Self.ref.loc17 (%Class.2)]() -> %T // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %Class.2 = name_ref self, @Class.%self.loc17_15.2 diff --git a/toolchain/check/testdata/class/generic/call.carbon b/toolchain/check/testdata/class/generic/call.carbon index e3a7b90e8d5f..f05eacabb732 100644 --- a/toolchain/check/testdata/class/generic/call.carbon +++ b/toolchain/check/testdata/class/generic/call.carbon @@ -99,12 +99,12 @@ var a: Class(5, i32*); // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_27.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_27.2: type = converted %int.make_type_32.loc4, %.loc4_27.1 [template = i32] // CHECK:STDOUT: %N.loc4_23.1: i32 = param N -// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = constants.%N] +// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = %N.loc4_23.2 (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Class.ref.loc6: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32] @@ -166,12 +166,12 @@ var a: Class(5, i32*); // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_27.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_27.2: type = converted %int.make_type_32.loc4, %.loc4_27.1 [template = i32] // CHECK:STDOUT: %N.loc4_23.1: i32 = param N -// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = constants.%N] +// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = %N.loc4_23.2 (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32] @@ -225,12 +225,12 @@ var a: Class(5, i32*); // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_27.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_27.2: type = converted %int.make_type_32.loc4, %.loc4_27.1 [template = i32] // CHECK:STDOUT: %N.loc4_23.1: i32 = param N -// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = constants.%N] +// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = %N.loc4_23.2 (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32] @@ -285,12 +285,12 @@ var a: Class(5, i32*); // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc4_27.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32] // CHECK:STDOUT: %.loc4_27.2: type = converted %int.make_type_32.loc4, %.loc4_27.1 [template = i32] // CHECK:STDOUT: %N.loc4_23.1: i32 = param N -// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = constants.%N] +// CHECK:STDOUT: %N.loc4_23.2: i32 = bind_symbolic_name N 1, %N.loc4_23.1 [symbolic = %N.loc4_23.2 (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.1] // CHECK:STDOUT: %.loc12_14: i32 = int_literal 5 [template = constants.%.3] diff --git a/toolchain/check/testdata/class/generic/fail_todo_use.carbon b/toolchain/check/testdata/class/generic/fail_todo_use.carbon index aecc6b5a7524..693ad7cb1fc4 100644 --- a/toolchain/check/testdata/class/generic/fail_todo_use.carbon +++ b/toolchain/check/testdata/class/generic/fail_todo_use.carbon @@ -76,7 +76,7 @@ fn Run() -> i32 { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] @@ -89,13 +89,13 @@ fn Run() -> i32 { // CHECK:STDOUT: class @Class // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: %Get.decl: %Get.type = fn_decl @Get [template = constants.%Get] { -// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class.2 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %.loc12_25: type = ptr_type %Class.2 [symbolic = constants.%.2] -// CHECK:STDOUT: %self.loc12_15.1: %.2 = param self -// CHECK:STDOUT: %self.loc12_15.3: %.2 = bind_name self, %self.loc12_15.1 -// CHECK:STDOUT: %.loc12_10: %.2 = addr_pattern %self.loc12_15.3 -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12_34: type = ptr_type %T [symbolic = constants.%.3] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class.2 [symbolic = %Self.ref (constants.%Class.2)] +// CHECK:STDOUT: %.loc12_25: type = ptr_type %Class.2 [symbolic = %.loc12_25 (constants.%.2)] +// CHECK:STDOUT: %self.loc12_15.1: @Class.%.loc12_25 (%.2) = param self +// CHECK:STDOUT: %self.loc12_15.3: @Class.%.loc12_25 (%.2) = bind_name self, %self.loc12_15.1 +// CHECK:STDOUT: %.loc12_10: @Class.%.loc12_25 (%.2) = addr_pattern %self.loc12_15.3 +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12 (constants.%T)] +// CHECK:STDOUT: %.loc12_34: type = ptr_type %T [symbolic = %.loc12_34 (constants.%.3)] // CHECK:STDOUT: %return.var: ref %.3 = var // CHECK:STDOUT: } // CHECK:STDOUT: %T.ref.loc16: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] @@ -107,7 +107,7 @@ fn Run() -> i32 { // CHECK:STDOUT: .k = %.loc16 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Get[addr @Class.%self.loc12_15.3: %.2]() -> %.3 +// CHECK:STDOUT: fn @Get[addr @Class.%self.loc12_15.3: @Class.%.loc12_25 (%.2)]() -> %.3 // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %.2 = name_ref self, @Class.%self.loc12_15.3 diff --git a/toolchain/check/testdata/class/generic/import.carbon b/toolchain/check/testdata/class/generic/import.carbon index 25d92b5da5a1..15359f02b526 100644 --- a/toolchain/check/testdata/class/generic/import.carbon +++ b/toolchain/check/testdata/class/generic/import.carbon @@ -128,11 +128,11 @@ class Class(U:! type) { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %CompleteClass.decl: %CompleteClass.type = class_decl @CompleteClass [template = constants.%CompleteClass.1] { // CHECK:STDOUT: %T.loc6_21.1: type = param T -// CHECK:STDOUT: %T.loc6_21.2: type = bind_symbolic_name T 0, %T.loc6_21.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc6_21.2: type = bind_symbolic_name T 0, %T.loc6_21.1 [symbolic = %T.loc6_21.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, %CompleteClass.decl [template = constants.%CompleteClass.1] @@ -546,7 +546,7 @@ class Class(U:! type) { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %U.loc9_13.1: type = param U -// CHECK:STDOUT: %U.loc9_13.2: type = bind_symbolic_name U 0, %U.loc9_13.1 [symbolic = constants.%U] +// CHECK:STDOUT: %U.loc9_13.2: type = bind_symbolic_name U 0, %U.loc9_13.1 [symbolic = %U.loc9_13.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/member_inline.carbon b/toolchain/check/testdata/class/generic/member_inline.carbon index 8bf594490b6d..8c1cbe408812 100644 --- a/toolchain/check/testdata/class/generic/member_inline.carbon +++ b/toolchain/check/testdata/class/generic/member_inline.carbon @@ -36,17 +36,17 @@ class Class(T:! type) { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %T.ref.loc12_11: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %n.loc12_8.1: %T = param n -// CHECK:STDOUT: %n.loc12_8.2: %T = bind_name n, %n.loc12_8.1 -// CHECK:STDOUT: %T.ref.loc12_17: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] +// CHECK:STDOUT: %T.ref.loc12_11: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12_11 (constants.%T)] +// CHECK:STDOUT: %n.loc12_8.1: @Class.%T.ref.loc12_11 (%T) = param n +// CHECK:STDOUT: %n.loc12_8.2: @Class.%T.ref.loc12_11 (%T) = bind_name n, %n.loc12_8.1 +// CHECK:STDOUT: %T.ref.loc12_17: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12_11 (constants.%T)] // CHECK:STDOUT: %return.var: ref %T = var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -55,7 +55,7 @@ class Class(T:! type) { // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(@Class.%n.loc12_8.2: %T) -> %T +// CHECK:STDOUT: fn @F(@Class.%n.loc12_8.2: @Class.%T.ref.loc12_11 (%T)) -> %T // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n.ref: %T = name_ref n, @Class.%n.loc12_8.2 diff --git a/toolchain/check/testdata/class/generic/member_out_of_line.carbon b/toolchain/check/testdata/class/generic/member_out_of_line.carbon index 3656b468654e..acec2aaae175 100644 --- a/toolchain/check/testdata/class/generic/member_out_of_line.carbon +++ b/toolchain/check/testdata/class/generic/member_out_of_line.carbon @@ -121,7 +121,7 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc4_13.1: type = param T -// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = %T.loc4_13.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc8_10.1: type = param T @@ -137,10 +137,10 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: class @Class // CHECK:STDOUT: generic [file.%T.loc4_13.2: type] { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %T.ref.loc5_11: type = name_ref T, file.%T.loc4_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %n.loc5_8.1: %T = param n -// CHECK:STDOUT: %n.loc5_8.2: %T = bind_name n, %n.loc5_8.1 -// CHECK:STDOUT: %T.ref.loc5_17: type = name_ref T, file.%T.loc4_13.2 [symbolic = constants.%T] +// CHECK:STDOUT: %T.ref.loc5_11: type = name_ref T, file.%T.loc4_13.2 [symbolic = %T.ref.loc5_11 (constants.%T)] +// CHECK:STDOUT: %n.loc5_8.1: @Class.%T.ref.loc5_11 (%T) = param n +// CHECK:STDOUT: %n.loc5_8.2: @Class.%T.ref.loc5_11 (%T) = bind_name n, %n.loc5_8.1 +// CHECK:STDOUT: %T.ref.loc5_17: type = name_ref T, file.%T.loc4_13.2 [symbolic = %T.ref.loc5_11 (constants.%T)] // CHECK:STDOUT: %return.var: ref %T = var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -183,7 +183,7 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %A.decl: %A.type = class_decl @A [template = constants.%A.1] { // CHECK:STDOUT: %T.loc4_9.1: type = param T -// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = %T.loc4_9.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc10_6.1: type = param T @@ -203,9 +203,9 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: class @A // CHECK:STDOUT: generic [file.%T.loc4_9.2: type] { // CHECK:STDOUT: %B.decl: %B.type = class_decl @B [template = constants.%B.1] { -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_9.2 [symbolic = constants.%T] -// CHECK:STDOUT: %N.loc5_11.1: %T = param N -// CHECK:STDOUT: %N.loc5_11.2: %T = bind_symbolic_name N 1, %N.loc5_11.1 [symbolic = constants.%N] +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_9.2 [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %N.loc5_11.1: @A.%T.ref (%T) = param N +// CHECK:STDOUT: %N.loc5_11.2: @A.%T.ref (%T) = bind_symbolic_name N 1, %N.loc5_11.1 [symbolic = %N.loc5_11.2 (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -214,14 +214,14 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @B -// CHECK:STDOUT: generic [file.%T.loc4_9.2: type, @A.%N.loc5_11.2: %T] { +// CHECK:STDOUT: generic [file.%T.loc4_9.2: type, @A.%N.loc5_11.2: @A.%T.ref (%T)] { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%B.2 [symbolic = constants.%B.2] -// CHECK:STDOUT: %self.loc6_10.1: %B.2 = param self -// CHECK:STDOUT: %self.loc6_10.2: %B.2 = bind_name self, %self.loc6_10.1 -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_9.2 [symbolic = constants.%T] -// CHECK:STDOUT: %a.loc6_22.1: %T = param a -// CHECK:STDOUT: %a.loc6_22.2: %T = bind_name a, %a.loc6_22.1 +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%B.2 [symbolic = %Self.ref (constants.%B.2)] +// CHECK:STDOUT: %self.loc6_10.1: @B.%Self.ref (%B.2) = param self +// CHECK:STDOUT: %self.loc6_10.2: @B.%Self.ref (%B.2) = bind_name self, %self.loc6_10.1 +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_9.2 [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %a.loc6_22.1: @B.%T.ref (%T) = param a +// CHECK:STDOUT: %a.loc6_22.2: @B.%T.ref (%T) = bind_name a, %a.loc6_22.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -230,7 +230,7 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F[%self: %B.2](%a: %T) -// CHECK:STDOUT: generic [file.%T.loc4_9.2: type, @A.%N.loc5_11.2: %T] { +// CHECK:STDOUT: generic [file.%T.loc4_9.2: type, @A.%N.loc5_11.2: @A.%T.ref (%T)] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -258,7 +258,7 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %NotGeneric.decl: type = class_decl @NotGeneric [template = constants.%NotGeneric] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { // CHECK:STDOUT: %T.loc15_15.1: type = param T -// CHECK:STDOUT: %T.loc15_15.2: type = bind_symbolic_name T 0, %T.loc15_15.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc15_15.2: type = bind_symbolic_name T 0, %T.loc15_15.1 [symbolic = %T.loc15_15.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -302,7 +302,7 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Generic.decl: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc4_15.1: type = param T -// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] {} // CHECK:STDOUT: } @@ -349,13 +349,13 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Generic.decl: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc4_15.1: type = param T -// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { // CHECK:STDOUT: %T.loc15_12.1: type = param T -// CHECK:STDOUT: %T.loc15_12.2: type = bind_symbolic_name T 0, %T.loc15_12.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc15_12.2: type = bind_symbolic_name T 0, %T.loc15_12.1 [symbolic = %T.loc15_12.2 (constants.%T)] // CHECK:STDOUT: %U.loc15_22.1: type = param U -// CHECK:STDOUT: %U.loc15_22.2: type = bind_symbolic_name U 1, %U.loc15_22.1 [symbolic = constants.%U] +// CHECK:STDOUT: %U.loc15_22.2: type = bind_symbolic_name U 1, %U.loc15_22.1 [symbolic = %U.loc15_22.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -402,13 +402,13 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Generic.decl: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc4_15.1: type = param T -// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.3] { // CHECK:STDOUT: %.loc14_17.1: %.1 = tuple_literal () // CHECK:STDOUT: %.loc14_17.2: type = converted %.loc14_17.1, constants.%.1 [template = constants.%.1] // CHECK:STDOUT: %T.loc14_12.1: %.1 = param T -// CHECK:STDOUT: %T.loc14_12.2: %.1 = bind_symbolic_name T 0, %T.loc14_12.1 [symbolic = constants.%T.2] +// CHECK:STDOUT: %T.loc14_12.2: %.1 = bind_symbolic_name T 0, %T.loc14_12.1 [symbolic = %T.loc14_12.2 (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/redeclare.carbon b/toolchain/check/testdata/class/generic/redeclare.carbon index f6bc54f3d4cd..89f4c16fd551 100644 --- a/toolchain/check/testdata/class/generic/redeclare.carbon +++ b/toolchain/check/testdata/class/generic/redeclare.carbon @@ -106,7 +106,7 @@ class E(U:! type) {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Generic.decl.loc4: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc4_15.1: type = param T -// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T 0, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %Generic.decl.loc6: %Generic.type = class_decl @Generic [template = constants.%Generic.1] { // CHECK:STDOUT: %T.loc6_15.1: type = param T @@ -142,7 +142,7 @@ class E(U:! type) {} // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %T.loc12_9.1: type = param T -// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = %T.loc12_9.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -188,14 +188,14 @@ class E(U:! type) {} // CHECK:STDOUT: %.loc4_13.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc4_13.2: type = converted %int.make_type_32, %.loc4_13.1 [template = i32] // CHECK:STDOUT: %N.loc4_9.1: i32 = param N -// CHECK:STDOUT: %N.loc4_9.2: i32 = bind_symbolic_name N 0, %N.loc4_9.1 [symbolic = constants.%N.1] +// CHECK:STDOUT: %N.loc4_9.2: i32 = bind_symbolic_name N 0, %N.loc4_9.1 [symbolic = %N.loc4_9.2 (constants.%N.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %T.loc12_9.1: type = param T -// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = constants.%T] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc12_9.2 [symbolic = constants.%T] -// CHECK:STDOUT: %N.loc12_19.1: %T = param N -// CHECK:STDOUT: %N.loc12_19.2: %T = bind_symbolic_name N 1, %N.loc12_19.1 [symbolic = constants.%N.2] +// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = %T.loc12_9.2 (constants.%T)] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc12_9.2 [symbolic = %T.loc12_9.2 (constants.%T)] +// CHECK:STDOUT: %N.loc12_19.1: file.%T.loc12_9.2 (%T) = param N +// CHECK:STDOUT: %N.loc12_19.2: file.%T.loc12_9.2 (%T) = bind_symbolic_name N 1, %N.loc12_19.1 [symbolic = %N.loc12_19.2 (constants.%N.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -203,7 +203,7 @@ class E(U:! type) {} // CHECK:STDOUT: generic [file.%N.loc4_9.2: i32]; // CHECK:STDOUT: // CHECK:STDOUT: class @.1 -// CHECK:STDOUT: generic [file.%T.loc12_9.2: type, file.%N.loc12_19.2: %T] { +// CHECK:STDOUT: generic [file.%T.loc12_9.2: type, file.%N.loc12_19.2: file.%T.loc12_9.2 (%T)] { // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%.3 // CHECK:STDOUT: } @@ -240,16 +240,16 @@ class E(U:! type) {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] { // CHECK:STDOUT: %T.loc4_9.1: type = param T -// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = %T.loc4_9.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %T.loc12_9.1: type = param T -// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc12_9.2: type = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = %T.loc12_9.2 (constants.%T)] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc12_23.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc12_23.2: type = converted %int.make_type_32, %.loc12_23.1 [template = i32] // CHECK:STDOUT: %U.loc12_19.1: i32 = param U -// CHECK:STDOUT: %U.loc12_19.2: i32 = bind_symbolic_name U 1, %U.loc12_19.1 [symbolic = constants.%U] +// CHECK:STDOUT: %U.loc12_19.2: i32 = bind_symbolic_name U 1, %U.loc12_19.1 [symbolic = %U.loc12_19.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -294,14 +294,14 @@ class E(U:! type) {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %D.decl: %D.type = class_decl @D [template = constants.%D.1] { // CHECK:STDOUT: %T.loc4_9.1: type = param T -// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = %T.loc4_9.2 (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc12_13.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc12_13.2: type = converted %int.make_type_32, %.loc12_13.1 [template = i32] // CHECK:STDOUT: %T.loc12_9.1: i32 = param T -// CHECK:STDOUT: %T.loc12_9.2: i32 = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = constants.%T.2] +// CHECK:STDOUT: %T.loc12_9.2: i32 = bind_symbolic_name T 0, %T.loc12_9.1 [symbolic = %T.loc12_9.2 (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -340,11 +340,11 @@ class E(U:! type) {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %E.decl: %E.type = class_decl @E [template = constants.%E.1] { // CHECK:STDOUT: %T.loc4_9.1: type = param T -// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_9.2: type = bind_symbolic_name T 0, %T.loc4_9.1 [symbolic = %T.loc4_9.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %U.loc11_9.1: type = param U -// CHECK:STDOUT: %U.loc11_9.2: type = bind_symbolic_name U 0, %U.loc11_9.1 [symbolic = constants.%U] +// CHECK:STDOUT: %U.loc11_9.2: type = bind_symbolic_name U 0, %U.loc11_9.1 [symbolic = %U.loc11_9.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/self.carbon b/toolchain/check/testdata/class/generic/self.carbon index bbd4a5e667e4..adf22b1f98de 100644 --- a/toolchain/check/testdata/class/generic/self.carbon +++ b/toolchain/check/testdata/class/generic/self.carbon @@ -46,22 +46,22 @@ class Class(T:! type) { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: %MakeSelf.decl: %MakeSelf.type = fn_decl @MakeSelf [template = constants.%MakeSelf] { -// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class.2 [symbolic = constants.%Class.2] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class.2 [symbolic = %Self.ref (constants.%Class.2)] // CHECK:STDOUT: %return.var.loc14: ref %Class.2 = var // CHECK:STDOUT: } // CHECK:STDOUT: %MakeClass.decl: %MakeClass.type = fn_decl @MakeClass [template = constants.%MakeClass] { // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc15_26: init type = call %Class.ref(%T.ref) [symbolic = constants.%Class.2] -// CHECK:STDOUT: %.loc15_28.1: type = value_of_initializer %.loc15_26 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %.loc15_28.2: type = converted %.loc15_26, %.loc15_28.1 [symbolic = constants.%Class.2] +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %.loc15_26: init type = call %Class.ref(%T.ref) [symbolic = %.loc15_26 (constants.%Class.2)] +// CHECK:STDOUT: %.loc15_28.1: type = value_of_initializer %.loc15_26 [symbolic = %.loc15_26 (constants.%Class.2)] +// CHECK:STDOUT: %.loc15_28.2: type = converted %.loc15_26, %.loc15_28.1 [symbolic = %.loc15_26 (constants.%Class.2)] // CHECK:STDOUT: %return.var.loc15: ref %Class.2 = var // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} diff --git a/toolchain/check/testdata/class/generic_method.carbon b/toolchain/check/testdata/class/generic_method.carbon index eba393779a96..d3fef58a5ad8 100644 --- a/toolchain/check/testdata/class/generic_method.carbon +++ b/toolchain/check/testdata/class/generic_method.carbon @@ -39,7 +39,7 @@ fn Class(T:! type).F[self: Self](n: T) {} // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc16_10.1: type = param T @@ -58,12 +58,12 @@ fn Class(T:! type).F[self: Self](n: T) {} // CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] // CHECK:STDOUT: %.loc12: %.2 = field_decl a, element0 [template] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class.2 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %self.loc13_8.1: %Class.2 = param self -// CHECK:STDOUT: %self.loc13_8.2: %Class.2 = bind_name self, %self.loc13_8.1 -// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %n.loc13_20.1: %T = param n -// CHECK:STDOUT: %n.loc13_20.2: %T = bind_name n, %n.loc13_20.1 +// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class.2 [symbolic = %Self.ref (constants.%Class.2)] +// CHECK:STDOUT: %self.loc13_8.1: @Class.%Self.ref (%Class.2) = param self +// CHECK:STDOUT: %self.loc13_8.2: @Class.%Self.ref (%Class.2) = bind_name self, %self.loc13_8.1 +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc13 (constants.%T)] +// CHECK:STDOUT: %n.loc13_20.1: @Class.%T.ref.loc13 (%T) = param n +// CHECK:STDOUT: %n.loc13_20.2: @Class.%T.ref.loc13 (%T) = bind_name n, %n.loc13_20.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: diff --git a/toolchain/check/testdata/eval/fail_symbolic.carbon b/toolchain/check/testdata/eval/fail_symbolic.carbon index 9404e78ec40c..f85a4c994083 100644 --- a/toolchain/check/testdata/eval/fail_symbolic.carbon +++ b/toolchain/check/testdata/eval/fail_symbolic.carbon @@ -44,7 +44,7 @@ fn G(N:! i32) { // CHECK:STDOUT: %.loc12_10.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc12_10.2: type = converted %int.make_type_32, %.loc12_10.1 [template = i32] // CHECK:STDOUT: %N.loc12_6.1: i32 = param N -// CHECK:STDOUT: @G.%N: i32 = bind_symbolic_name N 0, %N.loc12_6.1 [symbolic = constants.%N] +// CHECK:STDOUT: @G.%N: i32 = bind_symbolic_name N 0, %N.loc12_6.1 [symbolic = @G.%N (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/eval/symbolic.carbon b/toolchain/check/testdata/eval/symbolic.carbon index 370b369a8730..5b3999892ba6 100644 --- a/toolchain/check/testdata/eval/symbolic.carbon +++ b/toolchain/check/testdata/eval/symbolic.carbon @@ -43,7 +43,7 @@ fn F(T:! type) { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc12_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc12_6.1 [symbolic = constants.%T] +// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc12_6.1 [symbolic = @F.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/builtin/method.carbon b/toolchain/check/testdata/function/builtin/method.carbon index a1185bfd48f5..debe90653de9 100644 --- a/toolchain/check/testdata/function/builtin/method.carbon +++ b/toolchain/check/testdata/function/builtin/method.carbon @@ -82,19 +82,19 @@ var arr: [i32; 1.(I.F)(2)]; // CHECK:STDOUT: interface @I { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %self.loc12_8.1: %Self = param self -// CHECK:STDOUT: %self.loc12_8.2: %Self = bind_name self, %self.loc12_8.1 -// CHECK:STDOUT: %Self.ref.loc12_27: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_27.1: type = facet_type_access %Self.ref.loc12_27 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_27.2: type = converted %Self.ref.loc12_27, %.loc12_27.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %other.loc12_20.1: %Self = param other -// CHECK:STDOUT: %other.loc12_20.2: %Self = bind_name other, %other.loc12_20.1 -// CHECK:STDOUT: %Self.ref.loc12_36: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_36.1: type = facet_type_access %Self.ref.loc12_36 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_36.2: type = converted %Self.ref.loc12_36, %.loc12_36.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %self.loc12_8.1: @I.%Self.ref.loc12_14 (%Self) = param self +// CHECK:STDOUT: %self.loc12_8.2: @I.%Self.ref.loc12_14 (%Self) = bind_name self, %self.loc12_8.1 +// CHECK:STDOUT: %Self.ref.loc12_27: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_27.1: type = facet_type_access %Self.ref.loc12_27 [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_27.2: type = converted %Self.ref.loc12_27, %.loc12_27.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %other.loc12_20.1: @I.%Self.ref.loc12_14 (%Self) = param other +// CHECK:STDOUT: %other.loc12_20.2: @I.%Self.ref.loc12_14 (%Self) = bind_name other, %other.loc12_20.1 +// CHECK:STDOUT: %Self.ref.loc12_36: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_36.1: type = facet_type_access %Self.ref.loc12_36 [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_36.2: type = converted %Self.ref.loc12_36, %.loc12_36.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] // CHECK:STDOUT: %return.var: ref %Self = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_40: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] @@ -129,7 +129,7 @@ var arr: [i32; 1.(I.F)(2)]; // CHECK:STDOUT: witness = %.1 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1[@I.%self.loc12_8.2: %Self](@I.%other.loc12_20.2: %Self) -> %Self +// CHECK:STDOUT: fn @F.1[@I.%self.loc12_8.2: @I.%Self.ref.loc12_14 (%Self)](@I.%other.loc12_20.2: @I.%Self.ref.loc12_14 (%Self)) -> %Self // CHECK:STDOUT: generic [@I.%Self: %.1]; // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; diff --git a/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon b/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon index 5d1fc25d82e3..1e9adc3897dc 100644 --- a/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon +++ b/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon @@ -58,19 +58,19 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4); // CHECK:STDOUT: interface @Add { // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %Op.decl: %Op.type = fn_decl @Op [template = constants.%Op] { -// CHECK:STDOUT: %Self.ref.loc7_15: %.2 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc7_15.1: type = facet_type_access %Self.ref.loc7_15 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc7_15.2: type = converted %Self.ref.loc7_15, %.loc7_15.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %self.loc7_9.1: %Self = param self -// CHECK:STDOUT: %self.loc7_9.2: %Self = bind_name self, %self.loc7_9.1 -// CHECK:STDOUT: %Self.ref.loc7_28: %.2 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc7_28.1: type = facet_type_access %Self.ref.loc7_28 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc7_28.2: type = converted %Self.ref.loc7_28, %.loc7_28.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %other.loc7_21.1: %Self = param other -// CHECK:STDOUT: %other.loc7_21.2: %Self = bind_name other, %other.loc7_21.1 -// CHECK:STDOUT: %Self.ref.loc7_37: %.2 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc7_37.1: type = facet_type_access %Self.ref.loc7_37 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc7_37.2: type = converted %Self.ref.loc7_37, %.loc7_37.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self.ref.loc7_15: %.2 = name_ref Self, %Self [symbolic = %Self.ref.loc7_15 (constants.%Self)] +// CHECK:STDOUT: %.loc7_15.1: type = facet_type_access %Self.ref.loc7_15 [symbolic = %Self.ref.loc7_15 (constants.%Self)] +// CHECK:STDOUT: %.loc7_15.2: type = converted %Self.ref.loc7_15, %.loc7_15.1 [symbolic = %Self.ref.loc7_15 (constants.%Self)] +// CHECK:STDOUT: %self.loc7_9.1: @Add.%Self.ref.loc7_15 (%Self) = param self +// CHECK:STDOUT: %self.loc7_9.2: @Add.%Self.ref.loc7_15 (%Self) = bind_name self, %self.loc7_9.1 +// CHECK:STDOUT: %Self.ref.loc7_28: %.2 = name_ref Self, %Self [symbolic = %Self.ref.loc7_15 (constants.%Self)] +// CHECK:STDOUT: %.loc7_28.1: type = facet_type_access %Self.ref.loc7_28 [symbolic = %Self.ref.loc7_15 (constants.%Self)] +// CHECK:STDOUT: %.loc7_28.2: type = converted %Self.ref.loc7_28, %.loc7_28.1 [symbolic = %Self.ref.loc7_15 (constants.%Self)] +// CHECK:STDOUT: %other.loc7_21.1: @Add.%Self.ref.loc7_15 (%Self) = param other +// CHECK:STDOUT: %other.loc7_21.2: @Add.%Self.ref.loc7_15 (%Self) = bind_name other, %other.loc7_21.1 +// CHECK:STDOUT: %Self.ref.loc7_37: %.2 = name_ref Self, %Self [symbolic = %Self.ref.loc7_15 (constants.%Self)] +// CHECK:STDOUT: %.loc7_37.1: type = facet_type_access %Self.ref.loc7_37 [symbolic = %Self.ref.loc7_15 (constants.%Self)] +// CHECK:STDOUT: %.loc7_37.2: type = converted %Self.ref.loc7_37, %.loc7_37.1 [symbolic = %Self.ref.loc7_15 (constants.%Self)] // CHECK:STDOUT: %return.var: ref %Self = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc7_41: %.3 = assoc_entity element0, %Op.decl [template = constants.%.4] @@ -83,7 +83,7 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4); // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op[@Add.%self.loc7_9.2: %Self](@Add.%other.loc7_21.2: %Self) -> %Self +// CHECK:STDOUT: fn @Op[@Add.%self.loc7_9.2: @Add.%Self.ref.loc7_15 (%Self)](@Add.%other.loc7_21.2: @Add.%Self.ref.loc7_15 (%Self)) -> %Self // CHECK:STDOUT: generic [@Add.%Self: %.2]; // CHECK:STDOUT: // CHECK:STDOUT: --- user.carbon diff --git a/toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon b/toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon index 4a1a59160c17..40ec90f4b23a 100644 --- a/toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon +++ b/toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon @@ -41,9 +41,9 @@ fn F(N:! i32, a: [i32; N]*); // CHECK:STDOUT: %.loc14_10.1: type = value_of_initializer %int.make_type_32.loc14_10 [template = i32] // CHECK:STDOUT: %.loc14_10.2: type = converted %int.make_type_32.loc14_10, %.loc14_10.1 [template = i32] // CHECK:STDOUT: %N.loc14_6.1: i32 = param N -// CHECK:STDOUT: @F.%N: i32 = bind_symbolic_name N 0, %N.loc14_6.1 [symbolic = constants.%N] +// CHECK:STDOUT: @F.%N: i32 = bind_symbolic_name N 0, %N.loc14_6.1 [symbolic = @F.%N (constants.%N)] // CHECK:STDOUT: %int.make_type_32.loc14_19: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %N.ref: i32 = name_ref N, @F.%N [symbolic = constants.%N] +// CHECK:STDOUT: %N.ref: i32 = name_ref N, @F.%N [symbolic = @F.%N (constants.%N)] // CHECK:STDOUT: %.loc14_19.1: type = value_of_initializer %int.make_type_32.loc14_19 [template = i32] // CHECK:STDOUT: %.loc14_19.2: type = converted %int.make_type_32.loc14_19, %.loc14_19.1 [template = i32] // CHECK:STDOUT: %.loc14_25: type = array_type %N.ref, i32 [template = ] diff --git a/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon index 203c2e79739b..7f074834f6d8 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon @@ -33,9 +33,9 @@ fn F(T:! type, U:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc11_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = constants.%T] +// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T (constants.%T)] // CHECK:STDOUT: %U.loc11_16.1: type = param U -// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc11_16.1 [symbolic = constants.%U] +// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc11_16.1 [symbolic = @F.%U (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/indirect_generic_type.carbon b/toolchain/check/testdata/function/generic/no_prelude/indirect_generic_type.carbon new file mode 100644 index 000000000000..30b9b910b3f7 --- /dev/null +++ b/toolchain/check/testdata/function/generic/no_prelude/indirect_generic_type.carbon @@ -0,0 +1,52 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/generic/no_prelude/indirect_generic_type.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/no_prelude/indirect_generic_type.carbon + +fn F(T:! type, p: T**) -> T* { + return *p; +} + +// CHECK:STDOUT: --- indirect_generic_type.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic] +// CHECK:STDOUT: %.1: type = ptr_type %T [symbolic] +// CHECK:STDOUT: %.2: type = ptr_type %.1 [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F [template] +// CHECK:STDOUT: %.3: type = tuple_type () [template] +// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { +// CHECK:STDOUT: %T.loc11_6.1: type = param T +// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %T.ref.loc11_19: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %.loc11_20: type = ptr_type %T [symbolic = %.loc11_20 (constants.%.1)] +// CHECK:STDOUT: %.loc11_21: type = ptr_type %.1 [symbolic = %.loc11_21 (constants.%.2)] +// CHECK:STDOUT: %p.loc11_16.1: file.%.loc11_21 (%.2) = param p +// CHECK:STDOUT: @F.%p: file.%.loc11_21 (%.2) = bind_name p, %p.loc11_16.1 +// CHECK:STDOUT: %T.ref.loc11_27: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %.loc11_28: type = ptr_type %T [symbolic = %.loc11_20 (constants.%.1)] +// CHECK:STDOUT: @F.%return: ref %.1 = var +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F(%T: type, %p: file.%.loc11_21 (%.2)) -> %.1 +// CHECK:STDOUT: generic [%T: type] { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %p.ref: %.2 = name_ref p, %p +// CHECK:STDOUT: %.loc12_10.1: ref %.1 = deref %p.ref +// CHECK:STDOUT: %.loc12_10.2: %.1 = bind_value %.loc12_10.1 +// CHECK:STDOUT: return %.loc12_10.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon index 4383b2da5fd0..a2866b32e01c 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon @@ -29,7 +29,7 @@ fn F(T:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc11_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = constants.%T] +// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon index df4646e250d1..493a397f9f87 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon @@ -28,16 +28,16 @@ fn F(T:! type, n: T) -> T { // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc11_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = constants.%T] -// CHECK:STDOUT: %T.ref.loc11_19: type = name_ref T, @F.%T [symbolic = constants.%T] -// CHECK:STDOUT: %n.loc11_16.1: %T = param n -// CHECK:STDOUT: @F.%n: %T = bind_name n, %n.loc11_16.1 -// CHECK:STDOUT: %T.ref.loc11_25: type = name_ref T, @F.%T [symbolic = constants.%T] +// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc11_6.1 [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %T.ref.loc11_19: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %n.loc11_16.1: @F.%T (%T) = param n +// CHECK:STDOUT: @F.%n: @F.%T (%T) = bind_name n, %n.loc11_16.1 +// CHECK:STDOUT: %T.ref.loc11_25: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] // CHECK:STDOUT: @F.%return: ref %T = var // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%T: type, %n: %T) -> %T +// CHECK:STDOUT: fn @F(%T: type, %n: @F.%T (%T)) -> %T // CHECK:STDOUT: generic [%T: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] diff --git a/toolchain/check/testdata/function/generic/redeclare.carbon b/toolchain/check/testdata/function/generic/redeclare.carbon index 537d36fa7338..afe5077bd043 100644 --- a/toolchain/check/testdata/function/generic/redeclare.carbon +++ b/toolchain/check/testdata/function/generic/redeclare.carbon @@ -120,9 +120,9 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl.loc4: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc4_6.1: type = param T -// CHECK:STDOUT: %T.loc4_6.2: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = constants.%T] -// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, %T.loc4_6.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = constants.%.1] +// CHECK:STDOUT: %T.loc4_6.2: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = %T.loc4_6.2 (constants.%T)] +// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, %T.loc4_6.2 [symbolic = %T.loc4_6.2 (constants.%T)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = %.loc4 (constants.%.1)] // CHECK:STDOUT: %return.var.loc4: ref %.1 = var // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl.loc6: %F.type = fn_decl @F [template = constants.%F] { @@ -168,20 +168,20 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc4_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = constants.%T] +// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T (constants.%T)] // CHECK:STDOUT: %U.loc4_16.1: type = param U -// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = constants.%U] -// CHECK:STDOUT: %T.ref: type = name_ref T, @F.%T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = constants.%.1] +// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = @F.%U (constants.%U)] +// CHECK:STDOUT: %T.ref: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T [symbolic = %.loc4 (constants.%.1)] // CHECK:STDOUT: @F.%return: ref %.1 = var // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] { // CHECK:STDOUT: %T.loc13_6.1: type = param T -// CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 0, %T.loc13_6.1 [symbolic = constants.%T] +// CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 0, %T.loc13_6.1 [symbolic = @.1.%T (constants.%T)] // CHECK:STDOUT: %U.loc13_16.1: type = param U -// CHECK:STDOUT: @.1.%U: type = bind_symbolic_name U 1, %U.loc13_16.1 [symbolic = constants.%U] -// CHECK:STDOUT: %U.ref: type = name_ref U, @.1.%U [symbolic = constants.%U] -// CHECK:STDOUT: %.loc13: type = ptr_type %U [symbolic = constants.%.3] +// CHECK:STDOUT: @.1.%U: type = bind_symbolic_name U 1, %U.loc13_16.1 [symbolic = @.1.%U (constants.%U)] +// CHECK:STDOUT: %U.ref: type = name_ref U, @.1.%U [symbolic = @.1.%U (constants.%U)] +// CHECK:STDOUT: %.loc13: type = ptr_type %U [symbolic = %.loc13 (constants.%.3)] // CHECK:STDOUT: @.1.%return: ref %.3 = var // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -223,20 +223,20 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc4_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T (constants.%T.1)] // CHECK:STDOUT: %U.loc4_16.1: type = param U -// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = constants.%U.1] -// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, @F.%T [symbolic = constants.%T.1] -// CHECK:STDOUT: %.loc4: type = ptr_type %T.1 [symbolic = constants.%.1] +// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = @F.%U (constants.%U.1)] +// CHECK:STDOUT: %T.ref.loc4: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T.1)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T.1 [symbolic = %.loc4 (constants.%.1)] // CHECK:STDOUT: @F.%return: ref %.1 = var // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] { // CHECK:STDOUT: %U.loc13_6.1: type = param U -// CHECK:STDOUT: @.1.%U: type = bind_symbolic_name U 0, %U.loc13_6.1 [symbolic = constants.%U.2] +// CHECK:STDOUT: @.1.%U: type = bind_symbolic_name U 0, %U.loc13_6.1 [symbolic = @.1.%U (constants.%U.2)] // CHECK:STDOUT: %T.loc13_16.1: type = param T -// CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 1, %T.loc13_16.1 [symbolic = constants.%T.2] -// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, @.1.%T [symbolic = constants.%T.2] -// CHECK:STDOUT: %.loc13: type = ptr_type %T.2 [symbolic = constants.%.3] +// CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 1, %T.loc13_16.1 [symbolic = @.1.%T (constants.%T.2)] +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, @.1.%T [symbolic = @.1.%T (constants.%T.2)] +// CHECK:STDOUT: %.loc13: type = ptr_type %T.2 [symbolic = %.loc13 (constants.%.3)] // CHECK:STDOUT: @.1.%return: ref %.3 = var // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -278,20 +278,20 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc4_6.1: type = param T -// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: @F.%T: type = bind_symbolic_name T 0, %T.loc4_6.1 [symbolic = @F.%T (constants.%T.1)] // CHECK:STDOUT: %U.loc4_16.1: type = param U -// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = constants.%U.1] -// CHECK:STDOUT: %T.ref: type = name_ref T, @F.%T [symbolic = constants.%T.1] -// CHECK:STDOUT: %.loc4: type = ptr_type %T.1 [symbolic = constants.%.1] +// CHECK:STDOUT: @F.%U: type = bind_symbolic_name U 1, %U.loc4_16.1 [symbolic = @F.%U (constants.%U.1)] +// CHECK:STDOUT: %T.ref: type = name_ref T, @F.%T [symbolic = @F.%T (constants.%T.1)] +// CHECK:STDOUT: %.loc4: type = ptr_type %T.1 [symbolic = %.loc4 (constants.%.1)] // CHECK:STDOUT: @F.%return: ref %.1 = var // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.4] { // CHECK:STDOUT: %U.loc13_6.1: type = param U -// CHECK:STDOUT: @.1.%U: type = bind_symbolic_name U 0, %U.loc13_6.1 [symbolic = constants.%U.2] +// CHECK:STDOUT: @.1.%U: type = bind_symbolic_name U 0, %U.loc13_6.1 [symbolic = @.1.%U (constants.%U.2)] // CHECK:STDOUT: %T.loc13_16.1: type = param T -// CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 1, %T.loc13_16.1 [symbolic = constants.%T.2] -// CHECK:STDOUT: %U.ref: type = name_ref U, @.1.%U [symbolic = constants.%U.2] -// CHECK:STDOUT: %.loc13: type = ptr_type %U.2 [symbolic = constants.%.3] +// CHECK:STDOUT: @.1.%T: type = bind_symbolic_name T 1, %T.loc13_16.1 [symbolic = @.1.%T (constants.%T.2)] +// CHECK:STDOUT: %U.ref: type = name_ref U, @.1.%U [symbolic = @.1.%U (constants.%U.2)] +// CHECK:STDOUT: %.loc13: type = ptr_type %U.2 [symbolic = %.loc13 (constants.%.3)] // CHECK:STDOUT: @.1.%return: ref %.3 = var // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/impl/compound.carbon b/toolchain/check/testdata/impl/compound.carbon index 2fedd309afba..110a5d37bd53 100644 --- a/toolchain/check/testdata/impl/compound.carbon +++ b/toolchain/check/testdata/impl/compound.carbon @@ -130,11 +130,11 @@ fn InstanceCallIndirect(p: i32*) { // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: %G.decl: %G.type.1 = fn_decl @G.1 [template = constants.%G.1] { -// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc13_14.1: type = facet_type_access %Self.ref [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc13_14.2: type = converted %Self.ref, %.loc13_14.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %self.loc13_8.1: %Self = param self -// CHECK:STDOUT: %self.loc13_8.2: %Self = bind_name self, %self.loc13_8.1 +// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %.loc13_14.1: type = facet_type_access %Self.ref [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %.loc13_14.2: type = converted %Self.ref, %.loc13_14.1 [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %self.loc13_8.1: @Simple.%Self.ref (%Self) = param self +// CHECK:STDOUT: %self.loc13_8.2: @Simple.%Self.ref (%Self) = bind_name self, %self.loc13_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc13_21: %.5 = assoc_entity element1, %G.decl [template = constants.%.6] // CHECK:STDOUT: @@ -165,7 +165,7 @@ fn InstanceCallIndirect(p: i32*) { // CHECK:STDOUT: fn @F.1() // CHECK:STDOUT: generic [@Simple.%Self: %.1]; // CHECK:STDOUT: -// CHECK:STDOUT: fn @G.1[@Simple.%self.loc13_8.2: %Self]() +// CHECK:STDOUT: fn @G.1[@Simple.%self.loc13_8.2: @Simple.%Self.ref (%Self)]() // CHECK:STDOUT: generic [@Simple.%Self: %.1]; // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; diff --git a/toolchain/check/testdata/impl/fail_call_invalid.carbon b/toolchain/check/testdata/impl/fail_call_invalid.carbon index 8af872c0786f..be616325efc4 100644 --- a/toolchain/check/testdata/impl/fail_call_invalid.carbon +++ b/toolchain/check/testdata/impl/fail_call_invalid.carbon @@ -73,11 +73,11 @@ fn InstanceCall(n: i32) { // CHECK:STDOUT: interface @Simple { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %G.decl: %G.type.1 = fn_decl @G.1 [template = constants.%G.1] { -// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref, %.loc12_14.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %self.loc12_8.1: %Self = param self -// CHECK:STDOUT: %self.loc12_8.2: %Self = bind_name self, %self.loc12_8.1 +// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref, %.loc12_14.1 [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %self.loc12_8.1: @Simple.%Self.ref (%Self) = param self +// CHECK:STDOUT: %self.loc12_8.2: @Simple.%Self.ref (%Self) = bind_name self, %self.loc12_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_21: %.3 = assoc_entity element0, %G.decl [template = constants.%.4] // CHECK:STDOUT: @@ -100,7 +100,7 @@ fn InstanceCall(n: i32) { // CHECK:STDOUT: witness = %.1 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G.1[@Simple.%self.loc12_8.2: %Self]() +// CHECK:STDOUT: fn @G.1[@Simple.%self.loc12_8.2: @Simple.%Self.ref (%Self)]() // CHECK:STDOUT: generic [@Simple.%Self: %.1]; // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; diff --git a/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon b/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon index f4e21c5a866c..2a383b9cbf84 100644 --- a/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon +++ b/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon @@ -51,7 +51,7 @@ class C { // CHECK:STDOUT: %Core: = namespace %Core.import, [template] {} // CHECK:STDOUT: %GenericInterface.decl: %GenericInterface.type = interface_decl @GenericInterface [template = constants.%GenericInterface] { // CHECK:STDOUT: %T.loc11_28.1: type = param T -// CHECK:STDOUT: %T.loc11_28.2: type = bind_symbolic_name T 0, %T.loc11_28.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc11_28.2: type = bind_symbolic_name T 0, %T.loc11_28.1 [symbolic = %T.loc11_28.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: } @@ -60,9 +60,9 @@ class C { // CHECK:STDOUT: generic [file.%T.loc11_28.2: type] { // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_28.2 [symbolic = constants.%T] -// CHECK:STDOUT: %x.loc12_8.1: %T = param x -// CHECK:STDOUT: %x.loc12_8.2: %T = bind_name x, %x.loc12_8.1 +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_28.2 [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %x.loc12_8.1: @GenericInterface.%T.ref (%T) = param x +// CHECK:STDOUT: %x.loc12_8.2: @GenericInterface.%T.ref (%T) = bind_name x, %x.loc12_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: @@ -74,9 +74,9 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: impl @impl: %C as %.2 { // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { -// CHECK:STDOUT: %T.ref: type = name_ref T, @C.%T.loc19_23.2 [symbolic = constants.%T] -// CHECK:STDOUT: %x.loc20_10.1: %T = param x -// CHECK:STDOUT: %x.loc20_10.2: %T = bind_name x, %x.loc20_10.1 +// CHECK:STDOUT: %T.ref: type = name_ref T, @C.%T.loc19_23.2 [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %x.loc20_10.1: @impl.%T.ref (%T) = param x +// CHECK:STDOUT: %x.loc20_10.2: @impl.%T.ref (%T) = bind_name x, %x.loc20_10.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.1: = interface_witness (%F.decl) [template = constants.%.5] // CHECK:STDOUT: @@ -101,10 +101,10 @@ class C { // CHECK:STDOUT: has_error // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1(@GenericInterface.%x.loc12_8.2: %T) +// CHECK:STDOUT: fn @F.1(@GenericInterface.%x.loc12_8.2: @GenericInterface.%T.ref (%T)) // CHECK:STDOUT: generic [file.%T.loc11_28.2: type, @GenericInterface.%Self: %.2]; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2(@impl.%x.loc20_10.2: %T) +// CHECK:STDOUT: fn @F.2(@impl.%x.loc20_10.2: @impl.%T.ref (%T)) // CHECK:STDOUT: generic [@C.%T.loc19_23.2: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon b/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon index 1efeddeb3175..8c59808a3a5e 100644 --- a/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon +++ b/toolchain/check/testdata/impl/fail_impl_bad_assoc_fn.carbon @@ -413,26 +413,26 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: interface @SelfNested { // CHECK:STDOUT: %Self: %.9 = bind_symbolic_name Self 0 [symbolic = constants.%Self.3] // CHECK:STDOUT: %F.decl: %F.type.13 = fn_decl @F.13 [template = constants.%F.14] { -// CHECK:STDOUT: %Self.ref.loc188_12: %.9 = name_ref Self, %Self [symbolic = constants.%Self.3] -// CHECK:STDOUT: %.loc188_16.1: type = facet_type_access %Self.ref.loc188_12 [symbolic = constants.%Self.3] -// CHECK:STDOUT: %.loc188_16.2: type = converted %Self.ref.loc188_12, %.loc188_16.1 [symbolic = constants.%Self.3] -// CHECK:STDOUT: %.loc188_16.3: type = ptr_type %Self.3 [symbolic = constants.%.10] -// CHECK:STDOUT: %Self.ref.loc188_24: %.9 = name_ref Self, %Self [symbolic = constants.%Self.3] -// CHECK:STDOUT: %.loc188_24.1: type = facet_type_access %Self.ref.loc188_24 [symbolic = constants.%Self.3] -// CHECK:STDOUT: %.loc188_24.2: type = converted %Self.ref.loc188_24, %.loc188_24.1 [symbolic = constants.%Self.3] +// CHECK:STDOUT: %Self.ref.loc188_12: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_16.1: type = facet_type_access %Self.ref.loc188_12 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_16.2: type = converted %Self.ref.loc188_12, %.loc188_16.1 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_16.3: type = ptr_type %Self.3 [symbolic = %.loc188_16.3 (constants.%.10)] +// CHECK:STDOUT: %Self.ref.loc188_24: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_24.1: type = facet_type_access %Self.ref.loc188_24 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_24.2: type = converted %Self.ref.loc188_24, %.loc188_24.1 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc188_34.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc188_34.2: type = converted %int.make_type_32, %.loc188_34.1 [template = i32] -// CHECK:STDOUT: %.loc188_37: type = struct_type {.x: %Self.3, .y: i32} [symbolic = constants.%.11] +// CHECK:STDOUT: %.loc188_37: type = struct_type {.x: %Self.3, .y: i32} [symbolic = %.loc188_37 (constants.%.11)] // CHECK:STDOUT: %.loc188_38.1: %.12 = tuple_literal (%.loc188_16.3, %.loc188_37) -// CHECK:STDOUT: %.loc188_38.2: type = converted %.loc188_38.1, constants.%.13 [symbolic = constants.%.13] -// CHECK:STDOUT: %x.loc188_8.1: %.13 = param x -// CHECK:STDOUT: %x.loc188_8.2: %.13 = bind_name x, %x.loc188_8.1 -// CHECK:STDOUT: %Self.ref.loc188_45: %.9 = name_ref Self, %Self [symbolic = constants.%Self.3] +// CHECK:STDOUT: %.loc188_38.2: type = converted %.loc188_38.1, constants.%.13 [symbolic = %.loc188_38.2 (constants.%.13)] +// CHECK:STDOUT: %x.loc188_8.1: @SelfNested.%.loc188_38.2 (%.13) = param x +// CHECK:STDOUT: %x.loc188_8.2: @SelfNested.%.loc188_38.2 (%.13) = bind_name x, %x.loc188_8.1 +// CHECK:STDOUT: %Self.ref.loc188_45: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] // CHECK:STDOUT: %.loc188_51: i32 = int_literal 4 [template = constants.%.14] -// CHECK:STDOUT: %.loc188_45.1: type = facet_type_access %Self.ref.loc188_45 [symbolic = constants.%Self.3] -// CHECK:STDOUT: %.loc188_45.2: type = converted %Self.ref.loc188_45, %.loc188_45.1 [symbolic = constants.%Self.3] -// CHECK:STDOUT: %.loc188_52: type = array_type %.loc188_51, %Self.3 [symbolic = constants.%.15] +// CHECK:STDOUT: %.loc188_45.1: type = facet_type_access %Self.ref.loc188_45 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_45.2: type = converted %Self.ref.loc188_45, %.loc188_45.1 [symbolic = %Self.ref.loc188_12 (constants.%Self.3)] +// CHECK:STDOUT: %.loc188_52: type = array_type %.loc188_51, %Self.3 [symbolic = %.loc188_52 (constants.%.15)] // CHECK:STDOUT: %return.var: ref %.15 = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc188_53: %.16 = assoc_entity element0, %F.decl [template = constants.%.17] @@ -880,7 +880,7 @@ class SelfNestedBadReturnType { // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.13(@SelfNested.%x.loc188_8.2: %.13) -> %.15 +// CHECK:STDOUT: fn @F.13(@SelfNested.%x.loc188_8.2: @SelfNested.%.loc188_38.2 (%.13)) -> %.15 // CHECK:STDOUT: generic [@SelfNested.%Self: %.9]; // CHECK:STDOUT: // CHECK:STDOUT: fn @F.14(@impl.14.%x.loc200_10.2: %.20) -> %.21; diff --git a/toolchain/check/testdata/impl/lookup/instance_method.carbon b/toolchain/check/testdata/impl/lookup/instance_method.carbon index b1847b0de715..bcdc189de8c4 100644 --- a/toolchain/check/testdata/impl/lookup/instance_method.carbon +++ b/toolchain/check/testdata/impl/lookup/instance_method.carbon @@ -78,11 +78,11 @@ fn F(c: C) -> i32 { // CHECK:STDOUT: interface @I { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc14_14.1: type = facet_type_access %Self.ref [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc14_14.2: type = converted %Self.ref, %.loc14_14.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %self.loc14_8.1: %Self = param self -// CHECK:STDOUT: %self.loc14_8.2: %Self = bind_name self, %self.loc14_8.1 +// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %.loc14_14.1: type = facet_type_access %Self.ref [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %.loc14_14.2: type = converted %Self.ref, %.loc14_14.1 [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %self.loc14_8.1: @I.%Self.ref (%Self) = param self +// CHECK:STDOUT: %self.loc14_8.2: @I.%Self.ref (%Self) = bind_name self, %self.loc14_8.1 // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_25.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_25.2: type = converted %int.make_type_32, %.loc14_25.1 [template = i32] @@ -125,7 +125,7 @@ fn F(c: C) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1[@I.%self.loc14_8.2: %Self]() -> i32 +// CHECK:STDOUT: fn @F.1[@I.%self.loc14_8.2: @I.%Self.ref (%Self)]() -> i32 // CHECK:STDOUT: generic [@I.%Self: %.1]; // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2[@impl.%self.loc19_10.2: %C]() -> i32; diff --git a/toolchain/check/testdata/impl/no_prelude/import_self.carbon b/toolchain/check/testdata/impl/no_prelude/import_self.carbon index 791686337c90..3fe431134afb 100644 --- a/toolchain/check/testdata/impl/no_prelude/import_self.carbon +++ b/toolchain/check/testdata/impl/no_prelude/import_self.carbon @@ -52,19 +52,19 @@ fn F(x: (), y: ()) -> () { // CHECK:STDOUT: interface @Add { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %Op.decl: %Op.type = fn_decl @Op [template = constants.%Op] { -// CHECK:STDOUT: %Self.ref.loc5_15: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %self.loc5_9.1: %Self = param self -// CHECK:STDOUT: %self.loc5_9.2: %Self = bind_name self, %self.loc5_9.1 -// CHECK:STDOUT: %Self.ref.loc5_28: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %other.loc5_21.1: %Self = param other -// CHECK:STDOUT: %other.loc5_21.2: %Self = bind_name other, %other.loc5_21.1 -// CHECK:STDOUT: %Self.ref.loc5_37: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self.ref.loc5_15: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc5_15 (constants.%Self)] +// CHECK:STDOUT: %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = %Self.ref.loc5_15 (constants.%Self)] +// CHECK:STDOUT: %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = %Self.ref.loc5_15 (constants.%Self)] +// CHECK:STDOUT: %self.loc5_9.1: @Add.%Self.ref.loc5_15 (%Self) = param self +// CHECK:STDOUT: %self.loc5_9.2: @Add.%Self.ref.loc5_15 (%Self) = bind_name self, %self.loc5_9.1 +// CHECK:STDOUT: %Self.ref.loc5_28: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc5_15 (constants.%Self)] +// CHECK:STDOUT: %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = %Self.ref.loc5_15 (constants.%Self)] +// CHECK:STDOUT: %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = %Self.ref.loc5_15 (constants.%Self)] +// CHECK:STDOUT: %other.loc5_21.1: @Add.%Self.ref.loc5_15 (%Self) = param other +// CHECK:STDOUT: %other.loc5_21.2: @Add.%Self.ref.loc5_15 (%Self) = bind_name other, %other.loc5_21.1 +// CHECK:STDOUT: %Self.ref.loc5_37: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc5_15 (constants.%Self)] +// CHECK:STDOUT: %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = %Self.ref.loc5_15 (constants.%Self)] +// CHECK:STDOUT: %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = %Self.ref.loc5_15 (constants.%Self)] // CHECK:STDOUT: %return.var: ref %Self = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc5_41: %.3 = assoc_entity element0, %Op.decl [template = constants.%.4] @@ -75,7 +75,7 @@ fn F(x: (), y: ()) -> () { // CHECK:STDOUT: witness = (%Op.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Op[@Add.%self.loc5_9.2: %Self](@Add.%other.loc5_21.2: %Self) -> %Self +// CHECK:STDOUT: fn @Op[@Add.%self.loc5_9.2: @Add.%Self.ref.loc5_15 (%Self)](@Add.%other.loc5_21.2: @Add.%Self.ref.loc5_15 (%Self)) -> %Self // CHECK:STDOUT: generic [@Add.%Self: %.1]; // CHECK:STDOUT: // CHECK:STDOUT: --- b.carbon diff --git a/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon b/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon index 77205b61006f..b5cbd8724e78 100644 --- a/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon +++ b/toolchain/check/testdata/impl/no_prelude/self_in_class.carbon @@ -56,9 +56,9 @@ class A { // CHECK:STDOUT: interface @DefaultConstructible { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %Make.decl: %Make.type.1 = fn_decl @Make.1 [template = constants.%Make.1] { -// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_16.1: type = facet_type_access %Self.ref [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_16.2: type = converted %Self.ref, %.loc12_16.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self.ref: %.1 = name_ref Self, %Self [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %.loc12_16.1: type = facet_type_access %Self.ref [symbolic = %Self.ref (constants.%Self)] +// CHECK:STDOUT: %.loc12_16.2: type = converted %Self.ref, %.loc12_16.1 [symbolic = %Self.ref (constants.%Self)] // CHECK:STDOUT: %return.var: ref %Self = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_20: %.3 = assoc_entity element0, %Make.decl [template = constants.%.4] diff --git a/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon b/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon index 612eb45fbf14..ebf60e7a25b0 100644 --- a/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon +++ b/toolchain/check/testdata/impl/no_prelude/self_in_signature.carbon @@ -114,19 +114,19 @@ impl D as SelfNested { // CHECK:STDOUT: interface @UseSelf { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self.1] // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { -// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = constants.%Self.1] -// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = constants.%Self.1] -// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = constants.%Self.1] -// CHECK:STDOUT: %self.loc12_8.1: %Self.1 = param self -// CHECK:STDOUT: %self.loc12_8.2: %Self.1 = bind_name self, %self.loc12_8.1 -// CHECK:STDOUT: %Self.ref.loc12_23: %.1 = name_ref Self, %Self [symbolic = constants.%Self.1] -// CHECK:STDOUT: %.loc12_23.1: type = facet_type_access %Self.ref.loc12_23 [symbolic = constants.%Self.1] -// CHECK:STDOUT: %.loc12_23.2: type = converted %Self.ref.loc12_23, %.loc12_23.1 [symbolic = constants.%Self.1] -// CHECK:STDOUT: %x.loc12_20.1: %Self.1 = param x -// CHECK:STDOUT: %x.loc12_20.2: %Self.1 = bind_name x, %x.loc12_20.1 -// CHECK:STDOUT: %Self.ref.loc12_32: %.1 = name_ref Self, %Self [symbolic = constants.%Self.1] -// CHECK:STDOUT: %.loc12_32.1: type = facet_type_access %Self.ref.loc12_32 [symbolic = constants.%Self.1] -// CHECK:STDOUT: %.loc12_32.2: type = converted %Self.ref.loc12_32, %.loc12_32.1 [symbolic = constants.%Self.1] +// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] +// CHECK:STDOUT: %self.loc12_8.1: @UseSelf.%Self.ref.loc12_14 (%Self.1) = param self +// CHECK:STDOUT: %self.loc12_8.2: @UseSelf.%Self.ref.loc12_14 (%Self.1) = bind_name self, %self.loc12_8.1 +// CHECK:STDOUT: %Self.ref.loc12_23: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_23.1: type = facet_type_access %Self.ref.loc12_23 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_23.2: type = converted %Self.ref.loc12_23, %.loc12_23.1 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] +// CHECK:STDOUT: %x.loc12_20.1: @UseSelf.%Self.ref.loc12_14 (%Self.1) = param x +// CHECK:STDOUT: %x.loc12_20.2: @UseSelf.%Self.ref.loc12_14 (%Self.1) = bind_name x, %x.loc12_20.1 +// CHECK:STDOUT: %Self.ref.loc12_32: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_32.1: type = facet_type_access %Self.ref.loc12_32 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] +// CHECK:STDOUT: %.loc12_32.2: type = converted %Self.ref.loc12_32, %.loc12_32.1 [symbolic = %Self.ref.loc12_14 (constants.%Self.1)] // CHECK:STDOUT: %return.var: ref %Self.1 = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_36: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] @@ -140,20 +140,20 @@ impl D as SelfNested { // CHECK:STDOUT: interface @SelfNested { // CHECK:STDOUT: %Self: %.9 = bind_symbolic_name Self 0 [symbolic = constants.%Self.2] // CHECK:STDOUT: %F.decl: %F.type.4 = fn_decl @F.4 [template = constants.%F.4] { -// CHECK:STDOUT: %Self.ref.loc28_12: %.9 = name_ref Self, %Self [symbolic = constants.%Self.2] -// CHECK:STDOUT: %.loc28_16.1: type = facet_type_access %Self.ref.loc28_12 [symbolic = constants.%Self.2] -// CHECK:STDOUT: %.loc28_16.2: type = converted %Self.ref.loc28_12, %.loc28_16.1 [symbolic = constants.%Self.2] -// CHECK:STDOUT: %.loc28_16.3: type = ptr_type %Self.2 [symbolic = constants.%.10] -// CHECK:STDOUT: %Self.ref.loc28_24: %.9 = name_ref Self, %Self [symbolic = constants.%Self.2] -// CHECK:STDOUT: %.loc28_24.1: type = facet_type_access %Self.ref.loc28_24 [symbolic = constants.%Self.2] -// CHECK:STDOUT: %.loc28_24.2: type = converted %Self.ref.loc28_24, %.loc28_24.1 [symbolic = constants.%Self.2] +// CHECK:STDOUT: %Self.ref.loc28_12: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_16.1: type = facet_type_access %Self.ref.loc28_12 [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_16.2: type = converted %Self.ref.loc28_12, %.loc28_16.1 [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_16.3: type = ptr_type %Self.2 [symbolic = %.loc28_16.3 (constants.%.10)] +// CHECK:STDOUT: %Self.ref.loc28_24: %.9 = name_ref Self, %Self [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_24.1: type = facet_type_access %Self.ref.loc28_24 [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] +// CHECK:STDOUT: %.loc28_24.2: type = converted %Self.ref.loc28_24, %.loc28_24.1 [symbolic = %Self.ref.loc28_12 (constants.%Self.2)] // CHECK:STDOUT: %.loc28_35.1: %.2 = tuple_literal () // CHECK:STDOUT: %.loc28_35.2: type = converted %.loc28_35.1, constants.%.2 [template = constants.%.2] -// CHECK:STDOUT: %.loc28_36: type = struct_type {.x: %Self.2, .y: %.2} [symbolic = constants.%.11] +// CHECK:STDOUT: %.loc28_36: type = struct_type {.x: %Self.2, .y: %.2} [symbolic = %.loc28_36 (constants.%.11)] // CHECK:STDOUT: %.loc28_37.1: %.12 = tuple_literal (%.loc28_16.3, %.loc28_36) -// CHECK:STDOUT: %.loc28_37.2: type = converted %.loc28_37.1, constants.%.13 [symbolic = constants.%.13] -// CHECK:STDOUT: %x.loc28_8.1: %.13 = param x -// CHECK:STDOUT: %x.loc28_8.2: %.13 = bind_name x, %x.loc28_8.1 +// CHECK:STDOUT: %.loc28_37.2: type = converted %.loc28_37.1, constants.%.13 [symbolic = %.loc28_37.2 (constants.%.13)] +// CHECK:STDOUT: %x.loc28_8.1: @SelfNested.%.loc28_37.2 (%.13) = param x +// CHECK:STDOUT: %x.loc28_8.2: @SelfNested.%.loc28_37.2 (%.13) = bind_name x, %x.loc28_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc28_39: %.14 = assoc_entity element0, %F.decl [template = constants.%.15] // CHECK:STDOUT: @@ -249,7 +249,7 @@ impl D as SelfNested { // CHECK:STDOUT: .Self = constants.%D // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.1[@UseSelf.%self.loc12_8.2: %Self.1](@UseSelf.%x.loc12_20.2: %Self.1) -> %Self.1 +// CHECK:STDOUT: fn @F.1[@UseSelf.%self.loc12_8.2: @UseSelf.%Self.ref.loc12_14 (%Self.1)](@UseSelf.%x.loc12_20.2: @UseSelf.%Self.ref.loc12_14 (%Self.1)) -> %Self.1 // CHECK:STDOUT: generic [@UseSelf.%Self: %.1]; // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2[@impl.1.%self.loc20_8.2: %C](@impl.1.%x.loc20_17.2: %C) -> @impl.1.%return.var: %C { @@ -268,7 +268,7 @@ impl D as SelfNested { // CHECK:STDOUT: return %.loc24_48 to @impl.2.%return.var // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.4(@SelfNested.%x.loc28_8.2: %.13) +// CHECK:STDOUT: fn @F.4(@SelfNested.%x.loc28_8.2: @SelfNested.%.loc28_37.2 (%.13)) // CHECK:STDOUT: generic [@SelfNested.%Self: %.9]; // CHECK:STDOUT: // CHECK:STDOUT: fn @F.5(@impl.3.%x.loc32_8.2: %.18); diff --git a/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon index 3b2405dc9482..56a74642efdb 100644 --- a/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon +++ b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon @@ -34,7 +34,7 @@ fn F(T:! Empty) { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, %Empty.decl [template = constants.%.1] // CHECK:STDOUT: %T.loc13_6.1: %.1 = param T -// CHECK:STDOUT: @F.%T: %.1 = bind_symbolic_name T 0, %T.loc13_6.1 [symbolic = constants.%T] +// CHECK:STDOUT: @F.%T: %.1 = bind_symbolic_name T 0, %T.loc13_6.1 [symbolic = @F.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon b/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon index 99f6c6519508..ce50b4cbaef1 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon @@ -69,22 +69,22 @@ interface DifferentParams(T:! ()) {} // CHECK:STDOUT: %NotGeneric.decl: type = interface_decl @NotGeneric [template = constants.%.1] {} // CHECK:STDOUT: %.decl.loc19: %.type.1 = interface_decl @.1 [template = constants.%.3] { // CHECK:STDOUT: %T.loc19_22.1: type = param T -// CHECK:STDOUT: %T.loc19_22.2: type = bind_symbolic_name T 0, %T.loc19_22.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: %T.loc19_22.2: type = bind_symbolic_name T 0, %T.loc19_22.1 [symbolic = %T.loc19_22.2 (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %Generic.decl: %Generic.type = interface_decl @Generic [template = constants.%Generic] { // CHECK:STDOUT: %T.loc21_19.1: type = param T -// CHECK:STDOUT: %T.loc21_19.2: type = bind_symbolic_name T 0, %T.loc21_19.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: %T.loc21_19.2: type = bind_symbolic_name T 0, %T.loc21_19.1 [symbolic = %T.loc21_19.2 (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl.loc29: type = interface_decl @.2 [template = constants.%.5] {} // CHECK:STDOUT: %DifferentParams.decl: %DifferentParams.type = interface_decl @DifferentParams [template = constants.%DifferentParams] { // CHECK:STDOUT: %T.loc31_27.1: type = param T -// CHECK:STDOUT: %T.loc31_27.2: type = bind_symbolic_name T 0, %T.loc31_27.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: %T.loc31_27.2: type = bind_symbolic_name T 0, %T.loc31_27.1 [symbolic = %T.loc31_27.2 (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl.loc38: %.type.2 = interface_decl @.3 [template = constants.%.6] { // CHECK:STDOUT: %.loc38_32.1: %.2 = tuple_literal () // CHECK:STDOUT: %.loc38_32.2: type = converted %.loc38_32.1, constants.%.2 [template = constants.%.2] // CHECK:STDOUT: %T.loc38_27.1: %.2 = param T -// CHECK:STDOUT: %T.loc38_27.2: %.2 = bind_symbolic_name T 0, %T.loc38_27.1 [symbolic = constants.%T.2] +// CHECK:STDOUT: %T.loc38_27.2: %.2 = bind_symbolic_name T 0, %T.loc38_27.1 [symbolic = %T.loc38_27.2 (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon index 27b19b643140..8aff5758f337 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon @@ -52,17 +52,17 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: %CallStatic.decl: %CallStatic.type = fn_decl @CallStatic [template = constants.%CallStatic] { // CHECK:STDOUT: %Interface.ref.loc13: type = name_ref Interface, %Interface.decl [template = constants.%.1] // CHECK:STDOUT: %T.loc13_15.1: %.1 = param T -// CHECK:STDOUT: @CallStatic.%T: %.1 = bind_symbolic_name T 0, %T.loc13_15.1 [symbolic = constants.%T] +// CHECK:STDOUT: @CallStatic.%T: %.1 = bind_symbolic_name T 0, %T.loc13_15.1 [symbolic = @CallStatic.%T (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %CallFacet.decl: %CallFacet.type = fn_decl @CallFacet [template = constants.%CallFacet] { // CHECK:STDOUT: %Interface.ref.loc21: type = name_ref Interface, %Interface.decl [template = constants.%.1] // CHECK:STDOUT: %T.loc21_14.1: %.1 = param T -// CHECK:STDOUT: @CallFacet.%T: %.1 = bind_symbolic_name T 0, %T.loc21_14.1 [symbolic = constants.%T] -// CHECK:STDOUT: %T.ref: %.1 = name_ref T, @CallFacet.%T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc21_32.1: type = facet_type_access %T.ref [symbolic = constants.%T] -// CHECK:STDOUT: %.loc21_32.2: type = converted %T.ref, %.loc21_32.1 [symbolic = constants.%T] -// CHECK:STDOUT: %x.loc21_29.1: %T = param x -// CHECK:STDOUT: @CallFacet.%x: %T = bind_name x, %x.loc21_29.1 +// CHECK:STDOUT: @CallFacet.%T: %.1 = bind_symbolic_name T 0, %T.loc21_14.1 [symbolic = @CallFacet.%T (constants.%T)] +// CHECK:STDOUT: %T.ref: %.1 = name_ref T, @CallFacet.%T [symbolic = @CallFacet.%T (constants.%T)] +// CHECK:STDOUT: %.loc21_32.1: type = facet_type_access %T.ref [symbolic = @CallFacet.%T (constants.%T)] +// CHECK:STDOUT: %.loc21_32.2: type = converted %T.ref, %.loc21_32.1 [symbolic = @CallFacet.%T (constants.%T)] +// CHECK:STDOUT: %x.loc21_29.1: @CallFacet.%T (%T) = param x +// CHECK:STDOUT: @CallFacet.%x: @CallFacet.%T (%T) = bind_name x, %x.loc21_29.1 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -88,7 +88,7 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @CallFacet(%T: %.1, %x: %T) +// CHECK:STDOUT: fn @CallFacet(%T: %.1, %x: @CallFacet.%T (%T)) // CHECK:STDOUT: generic [%T: %.1] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.ref: %T = name_ref x, %x diff --git a/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon index 57cb9a537056..a8aef588092a 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon @@ -44,19 +44,19 @@ fn I(T:! type).F[self: Self]() -> Self { return self; } // CHECK:STDOUT: } // CHECK:STDOUT: %I.decl: %I.type = interface_decl @I [template = constants.%I] { // CHECK:STDOUT: %T.loc11_13.1: type = param T -// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc11_13.2: type = bind_symbolic_name T 0, %T.loc11_13.1 [symbolic = %T.loc11_13.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.5] { // CHECK:STDOUT: %T.loc22_6.1: type = param T -// CHECK:STDOUT: %T.loc22_6.2: type = bind_symbolic_name T 0, %T.loc22_6.1 [symbolic = constants.%T] -// CHECK:STDOUT: %Self.ref.loc22_24: %.2 = name_ref Self, @I.%Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc22_24.1: type = facet_type_access %Self.ref.loc22_24 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc22_24.2: type = converted %Self.ref.loc22_24, %.loc22_24.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %self.loc22_18.1: %Self = param self -// CHECK:STDOUT: @.1.%self: %Self = bind_name self, %self.loc22_18.1 -// CHECK:STDOUT: %Self.ref.loc22_35: %.2 = name_ref Self, @I.%Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc22_35.1: type = facet_type_access %Self.ref.loc22_35 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc22_35.2: type = converted %Self.ref.loc22_35, %.loc22_35.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %T.loc22_6.2: type = bind_symbolic_name T 0, %T.loc22_6.1 [symbolic = %T.loc22_6.2 (constants.%T)] +// CHECK:STDOUT: %Self.ref.loc22_24: (%.2) = name_ref Self, @I.%Self [symbolic = %Self.ref.loc22_24 (constants.%Self)] +// CHECK:STDOUT: %.loc22_24.1: type = facet_type_access %Self.ref.loc22_24 [symbolic = %Self.ref.loc22_24 (constants.%Self)] +// CHECK:STDOUT: %.loc22_24.2: type = converted %Self.ref.loc22_24, %.loc22_24.1 [symbolic = %Self.ref.loc22_24 (constants.%Self)] +// CHECK:STDOUT: %self.loc22_18.1: file.%Self.ref.loc22_24 (%Self) = param self +// CHECK:STDOUT: @.1.%self: file.%Self.ref.loc22_24 (%Self) = bind_name self, %self.loc22_18.1 +// CHECK:STDOUT: %Self.ref.loc22_35: (%.2) = name_ref Self, @I.%Self [symbolic = %Self.ref.loc22_24 (constants.%Self)] +// CHECK:STDOUT: %.loc22_35.1: type = facet_type_access %Self.ref.loc22_35 [symbolic = %Self.ref.loc22_24 (constants.%Self)] +// CHECK:STDOUT: %.loc22_35.2: type = converted %Self.ref.loc22_35, %.loc22_35.1 [symbolic = %Self.ref.loc22_24 (constants.%Self)] // CHECK:STDOUT: @.1.%return: ref %Self = var // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -65,14 +65,14 @@ fn I(T:! type).F[self: Self]() -> Self { return self; } // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Self.ref.loc13_14: %.2 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc13_14.1: type = facet_type_access %Self.ref.loc13_14 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc13_14.2: type = converted %Self.ref.loc13_14, %.loc13_14.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %self.loc13_8.1: %Self = param self -// CHECK:STDOUT: %self.loc13_8.2: %Self = bind_name self, %self.loc13_8.1 -// CHECK:STDOUT: %Self.ref.loc13_25: %.2 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc13_25.1: type = facet_type_access %Self.ref.loc13_25 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc13_25.2: type = converted %Self.ref.loc13_25, %.loc13_25.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self.ref.loc13_14: %.2 = name_ref Self, %Self [symbolic = %Self.ref.loc13_14 (constants.%Self)] +// CHECK:STDOUT: %.loc13_14.1: type = facet_type_access %Self.ref.loc13_14 [symbolic = %Self.ref.loc13_14 (constants.%Self)] +// CHECK:STDOUT: %.loc13_14.2: type = converted %Self.ref.loc13_14, %.loc13_14.1 [symbolic = %Self.ref.loc13_14 (constants.%Self)] +// CHECK:STDOUT: %self.loc13_8.1: @I.%Self.ref.loc13_14 (%Self) = param self +// CHECK:STDOUT: %self.loc13_8.2: @I.%Self.ref.loc13_14 (%Self) = bind_name self, %self.loc13_8.1 +// CHECK:STDOUT: %Self.ref.loc13_25: %.2 = name_ref Self, %Self [symbolic = %Self.ref.loc13_14 (constants.%Self)] +// CHECK:STDOUT: %.loc13_25.1: type = facet_type_access %Self.ref.loc13_25 [symbolic = %Self.ref.loc13_14 (constants.%Self)] +// CHECK:STDOUT: %.loc13_25.2: type = converted %Self.ref.loc13_25, %.loc13_25.1 [symbolic = %Self.ref.loc13_14 (constants.%Self)] // CHECK:STDOUT: %return.var: ref %Self = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc13_29: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] @@ -83,10 +83,10 @@ fn I(T:! type).F[self: Self]() -> Self { return self; } // CHECK:STDOUT: witness = (%F.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F[@I.%self.loc13_8.2: %Self]() -> %Self +// CHECK:STDOUT: fn @F[@I.%self.loc13_8.2: @I.%Self.ref.loc13_14 (%Self)]() -> %Self // CHECK:STDOUT: generic [file.%T.loc11_13.2: type, @I.%Self: %.2]; // CHECK:STDOUT: -// CHECK:STDOUT: fn @.1[%self: %Self]() -> %Self +// CHECK:STDOUT: fn @.1[%self: file.%Self.ref.loc22_24 (%Self)]() -> %Self // CHECK:STDOUT: generic [file.%T.loc22_6.2: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %Self = name_ref self, %self diff --git a/toolchain/check/testdata/interface/no_prelude/generic.carbon b/toolchain/check/testdata/interface/no_prelude/generic.carbon index 9a49f26ed228..b71c38bba05a 100644 --- a/toolchain/check/testdata/interface/no_prelude/generic.carbon +++ b/toolchain/check/testdata/interface/no_prelude/generic.carbon @@ -108,20 +108,20 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: } // CHECK:STDOUT: %Simple.decl: %Simple.type = interface_decl @Simple [template = constants.%Simple] { // CHECK:STDOUT: %T.loc4_18.1: type = param T -// CHECK:STDOUT: %T.loc4_18.2: type = bind_symbolic_name T 0, %T.loc4_18.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: %T.loc4_18.2: type = bind_symbolic_name T 0, %T.loc4_18.1 [symbolic = %T.loc4_18.2 (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} // CHECK:STDOUT: %WithAssocFn.decl: %WithAssocFn.type = interface_decl @WithAssocFn [template = constants.%WithAssocFn] { // CHECK:STDOUT: %T.loc8_23.1: type = param T -// CHECK:STDOUT: %T.loc8_23.2: type = bind_symbolic_name T 0, %T.loc8_23.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: %T.loc8_23.2: type = bind_symbolic_name T 0, %T.loc8_23.1 [symbolic = %T.loc8_23.2 (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} // CHECK:STDOUT: %WithImplicitArgs.decl: %WithImplicitArgs.type = interface_decl @WithImplicitArgs [template = constants.%WithImplicitArgs] { // CHECK:STDOUT: %T.loc22_28.1: type = param T -// CHECK:STDOUT: %T.loc22_28.2: type = bind_symbolic_name T 0, %T.loc22_28.1 [symbolic = constants.%T.1] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc22_28.2 [symbolic = constants.%T.1] -// CHECK:STDOUT: %N.loc22_38.1: %T.1 = param N -// CHECK:STDOUT: %N.loc22_38.2: %T.1 = bind_symbolic_name N 1, %N.loc22_38.1 [symbolic = constants.%N] +// CHECK:STDOUT: %T.loc22_28.2: type = bind_symbolic_name T 0, %T.loc22_28.1 [symbolic = %T.loc22_28.2 (constants.%T.1)] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc22_28.2 [symbolic = %T.loc22_28.2 (constants.%T.1)] +// CHECK:STDOUT: %N.loc22_38.1: file.%T.loc22_28.2 (%T.1) = param N +// CHECK:STDOUT: %N.loc22_38.2: file.%T.loc22_28.2 (%T.1) = bind_symbolic_name N 1, %N.loc22_38.1 [symbolic = %N.loc22_38.2 (constants.%N)] // CHECK:STDOUT: } // CHECK:STDOUT: %Receive.decl: %Receive.type = fn_decl @Receive [template = constants.%Receive] { // CHECK:STDOUT: %Simple.ref.loc24: %Simple.type = name_ref Simple, %Simple.decl [template = constants.%Simple] @@ -130,7 +130,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %.loc24_24.1: type = value_of_initializer %.loc24_22 [template = constants.%.7] // CHECK:STDOUT: %.loc24_24.2: type = converted %.loc24_22, %.loc24_24.1 [template = constants.%.7] // CHECK:STDOUT: %T.loc24_12.1: %.7 = param T -// CHECK:STDOUT: @Receive.%T: %.7 = bind_symbolic_name T 0, %T.loc24_12.1 [symbolic = constants.%T.2] +// CHECK:STDOUT: @Receive.%T: %.7 = bind_symbolic_name T 0, %T.loc24_12.1 [symbolic = @Receive.%T (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: %Pass.decl: %Pass.type = fn_decl @Pass [template = constants.%Pass] { // CHECK:STDOUT: %Simple.ref.loc25: %Simple.type = name_ref Simple, %Simple.decl [template = constants.%Simple] @@ -139,7 +139,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %.loc25_21.1: type = value_of_initializer %.loc25_19 [template = constants.%.7] // CHECK:STDOUT: %.loc25_21.2: type = converted %.loc25_19, %.loc25_21.1 [template = constants.%.7] // CHECK:STDOUT: %T.loc25_9.1: %.7 = param T -// CHECK:STDOUT: @Pass.%T: %.7 = bind_symbolic_name T 0, %T.loc25_9.1 [symbolic = constants.%T.2] +// CHECK:STDOUT: @Pass.%T: %.7 = bind_symbolic_name T 0, %T.loc25_9.1 [symbolic = @Pass.%T (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -168,7 +168,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @WithImplicitArgs -// CHECK:STDOUT: generic [file.%T.loc22_28.2: type, file.%N.loc22_38.2: %T.1]; +// CHECK:STDOUT: generic [file.%T.loc22_28.2: type, file.%N.loc22_38.2: file.%T.loc22_28.2 (%T.1)]; // CHECK:STDOUT: // CHECK:STDOUT: impl @impl.1: %C as %.7 { // CHECK:STDOUT: %.1: = interface_witness () [template = constants.%.8] @@ -269,7 +269,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: } // CHECK:STDOUT: %Generic.decl: %Generic.type = interface_decl @Generic [template = constants.%Generic] { // CHECK:STDOUT: %T.loc4_19.1: type = param T -// CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T 0, %T.loc4_19.1 [symbolic = constants.%T.1] +// CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T 0, %T.loc4_19.1 [symbolic = %T.loc4_19.2 (constants.%T.1)] // CHECK:STDOUT: } // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} @@ -280,7 +280,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %.loc9_19.1: type = value_of_initializer %.loc9_17 [template = constants.%.4] // CHECK:STDOUT: %.loc9_19.2: type = converted %.loc9_17, %.loc9_19.1 [template = constants.%.4] // CHECK:STDOUT: %T.loc9_6.1: %.4 = param T -// CHECK:STDOUT: @F.%T: %.4 = bind_symbolic_name T 0, %T.loc9_6.1 [symbolic = constants.%T.2] +// CHECK:STDOUT: @F.%T: %.4 = bind_symbolic_name T 0, %T.loc9_6.1 [symbolic = @F.%T (constants.%T.2)] // CHECK:STDOUT: } // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %Generic.ref.loc10: %Generic.type = name_ref Generic, %Generic.decl [template = constants.%Generic] @@ -289,7 +289,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: %.loc10_19.1: type = value_of_initializer %.loc10_17 [template = constants.%.5] // CHECK:STDOUT: %.loc10_19.2: type = converted %.loc10_17, %.loc10_19.1 [template = constants.%.5] // CHECK:STDOUT: %T.loc10_6.1: %.5 = param T -// CHECK:STDOUT: @G.%T: %.5 = bind_symbolic_name T 0, %T.loc10_6.1 [symbolic = constants.%T.3] +// CHECK:STDOUT: @G.%T: %.5 = bind_symbolic_name T 0, %T.loc10_6.1 [symbolic = @G.%T (constants.%T.3)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/generic_binding_after_assoc_const.carbon b/toolchain/check/testdata/interface/no_prelude/generic_binding_after_assoc_const.carbon index 6118ce8ad482..2a689eb58cd6 100644 --- a/toolchain/check/testdata/interface/no_prelude/generic_binding_after_assoc_const.carbon +++ b/toolchain/check/testdata/interface/no_prelude/generic_binding_after_assoc_const.carbon @@ -46,14 +46,14 @@ interface I { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %T.loc12_8.1: type = param T -// CHECK:STDOUT: %T.loc12_8.2: type = bind_symbolic_name T 1, %T.loc12_8.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc12_8.2: type = bind_symbolic_name T 1, %T.loc12_8.1 [symbolic = %T.loc12_8.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: %U: type = assoc_const_decl U [template] // CHECK:STDOUT: %.loc13: %.5 = assoc_entity element1, %U [template = constants.%.6] // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %T.loc16_8.1: type = param T -// CHECK:STDOUT: %T.loc16_8.2: type = bind_symbolic_name T 1, %T.loc16_8.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc16_8.2: type = bind_symbolic_name T 1, %T.loc16_8.1 [symbolic = %T.loc16_8.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %.loc16: %.7 = assoc_entity element2, %G.decl [template = constants.%.8] // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/generic_import.carbon b/toolchain/check/testdata/interface/no_prelude/generic_import.carbon index a0e45fb471e5..66f37982ee93 100644 --- a/toolchain/check/testdata/interface/no_prelude/generic_import.carbon +++ b/toolchain/check/testdata/interface/no_prelude/generic_import.carbon @@ -48,7 +48,7 @@ impl C as AddWith(C) { // CHECK:STDOUT: } // CHECK:STDOUT: %AddWith.decl: %AddWith.type = interface_decl @AddWith [template = constants.%AddWith] { // CHECK:STDOUT: %T.loc4_19.1: type = param T -// CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T 0, %T.loc4_19.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T 0, %T.loc4_19.1 [symbolic = %T.loc4_19.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/self.carbon b/toolchain/check/testdata/interface/no_prelude/self.carbon index 21d5ac20fb35..343b646a2caf 100644 --- a/toolchain/check/testdata/interface/no_prelude/self.carbon +++ b/toolchain/check/testdata/interface/no_prelude/self.carbon @@ -34,14 +34,14 @@ interface UseSelf { // CHECK:STDOUT: interface @UseSelf { // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = constants.%Self] -// CHECK:STDOUT: %self.loc12_8.1: %Self = param self -// CHECK:STDOUT: %self.loc12_8.2: %Self = bind_name self, %self.loc12_8.1 -// CHECK:STDOUT: %Self.ref.loc12_25: %.1 = name_ref Self, %Self [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_25.1: type = facet_type_access %Self.ref.loc12_25 [symbolic = constants.%Self] -// CHECK:STDOUT: %.loc12_25.2: type = converted %Self.ref.loc12_25, %.loc12_25.1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self.ref.loc12_14: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.1: type = facet_type_access %Self.ref.loc12_14 [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_14.2: type = converted %Self.ref.loc12_14, %.loc12_14.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %self.loc12_8.1: @UseSelf.%Self.ref.loc12_14 (%Self) = param self +// CHECK:STDOUT: %self.loc12_8.2: @UseSelf.%Self.ref.loc12_14 (%Self) = bind_name self, %self.loc12_8.1 +// CHECK:STDOUT: %Self.ref.loc12_25: %.1 = name_ref Self, %Self [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_25.1: type = facet_type_access %Self.ref.loc12_25 [symbolic = %Self.ref.loc12_14 (constants.%Self)] +// CHECK:STDOUT: %.loc12_25.2: type = converted %Self.ref.loc12_25, %.loc12_25.1 [symbolic = %Self.ref.loc12_14 (constants.%Self)] // CHECK:STDOUT: %return.var: ref %Self = var // CHECK:STDOUT: } // CHECK:STDOUT: %.loc12_29: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] @@ -52,6 +52,6 @@ interface UseSelf { // CHECK:STDOUT: witness = (%F.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F[@UseSelf.%self.loc12_8.2: %Self]() -> %Self +// CHECK:STDOUT: fn @F[@UseSelf.%self.loc12_8.2: @UseSelf.%Self.ref.loc12_14 (%Self)]() -> %Self // CHECK:STDOUT: generic [@UseSelf.%Self: %.1]; // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/fail_params.carbon b/toolchain/check/testdata/namespace/fail_params.carbon index c6a94a17e0ba..935d57d9290b 100644 --- a/toolchain/check/testdata/namespace/fail_params.carbon +++ b/toolchain/check/testdata/namespace/fail_params.carbon @@ -84,7 +84,7 @@ fn D(T:! type).F() {} // CHECK:STDOUT: %D: = namespace [template] {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %T.loc39_6.1: type = param T -// CHECK:STDOUT: %T.loc39_6.2: type = bind_symbolic_name T 0, %T.loc39_6.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc39_6.2: type = bind_symbolic_name T 0, %T.loc39_6.1 [symbolic = %T.loc39_6.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/fail_export_name_params.carbon b/toolchain/check/testdata/packages/no_prelude/fail_export_name_params.carbon index ec123f5c665c..2fbd83d252ca 100644 --- a/toolchain/check/testdata/packages/no_prelude/fail_export_name_params.carbon +++ b/toolchain/check/testdata/packages/no_prelude/fail_export_name_params.carbon @@ -48,11 +48,11 @@ export C2(T:! type); // CHECK:STDOUT: } // CHECK:STDOUT: %C1.decl: %C1.type = class_decl @C1 [template = constants.%C1.1] { // CHECK:STDOUT: %T.loc4_10.1: type = param T -// CHECK:STDOUT: %T.loc4_10.2: type = bind_symbolic_name T 0, %T.loc4_10.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc4_10.2: type = bind_symbolic_name T 0, %T.loc4_10.1 [symbolic = %T.loc4_10.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %C2.decl: %C2.type = class_decl @C2 [template = constants.%C2.1] { // CHECK:STDOUT: %T.loc5_10.1: type = param T -// CHECK:STDOUT: %T.loc5_10.2: type = bind_symbolic_name T 0, %T.loc5_10.1 [symbolic = constants.%T] +// CHECK:STDOUT: %T.loc5_10.2: type = bind_symbolic_name T 0, %T.loc5_10.1 [symbolic = %T.loc5_10.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/import.carbon b/toolchain/check/testdata/struct/import.carbon index 6a93d75d032f..52115d83f901 100644 --- a/toolchain/check/testdata/struct/import.carbon +++ b/toolchain/check/testdata/struct/import.carbon @@ -133,7 +133,7 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %.loc8_27.2: type = converted %int.make_type_32.loc8_27, %.loc8_27.1 [template = i32] // CHECK:STDOUT: %.loc8_30: type = struct_type {.a: i32, .b: i32} [template = constants.%.11] // CHECK:STDOUT: %S.loc8_9.1: %.11 = param S -// CHECK:STDOUT: %S.loc8_9.2: %.11 = bind_symbolic_name S 0, %S.loc8_9.1 [symbolic = constants.%S] +// CHECK:STDOUT: %S.loc8_9.2: %.11 = bind_symbolic_name S 0, %S.loc8_9.1 [symbolic = %S.loc8_9.2 (constants.%S)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %C.ref: %C.type = name_ref C, %C.decl [template = constants.%C.1] diff --git a/toolchain/check/testdata/tuples/import.carbon b/toolchain/check/testdata/tuples/import.carbon index 059b738975c4..d00aa3a782f5 100644 --- a/toolchain/check/testdata/tuples/import.carbon +++ b/toolchain/check/testdata/tuples/import.carbon @@ -148,7 +148,7 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %.loc7_22.5: type = converted %int.make_type_32.loc7_19, %.loc7_22.4 [template = i32] // CHECK:STDOUT: %.loc7_22.6: type = converted %.loc7_22.1, constants.%.9 [template = constants.%.9] // CHECK:STDOUT: %X.loc7_9.1: %.9 = param X -// CHECK:STDOUT: %X.loc7_9.2: %.9 = bind_symbolic_name X 0, %X.loc7_9.1 [symbolic = constants.%X] +// CHECK:STDOUT: %X.loc7_9.2: %.9 = bind_symbolic_name X 0, %X.loc7_9.1 [symbolic = %X.loc7_9.2 (constants.%X)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %C.ref: %C.type = name_ref C, %C.decl [template = constants.%C.1] diff --git a/toolchain/sem_ir/constant.h b/toolchain/sem_ir/constant.h index e437050e16ef..18af50611a57 100644 --- a/toolchain/sem_ir/constant.h +++ b/toolchain/sem_ir/constant.h @@ -78,7 +78,7 @@ class ConstantValueStore { // Returns whether two constant IDs represent the same constant value. This // includes the case where they might be in different generics and thus might // have different ConstantIds, but are still symbolically equal. - auto EqualAcrossDeclarations(ConstantId a, ConstantId b) const -> bool { + auto AreEqualAcrossDeclarations(ConstantId a, ConstantId b) const -> bool { return GetInstId(a) == GetInstId(b); } diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index 64de8562dd56..520059f1547c 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -317,10 +317,14 @@ class Formatter { } auto FormatGeneric(GenericId generic_id) -> void { + const auto& generic = sem_ir_.generics().Get(generic_id); + WrapLine(); out_ << "generic ["; - FormatParamList(sem_ir_.generics().Get(generic_id).bindings_id); + FormatParamList(generic.bindings_id); out_ << "]"; + // TODO: Format at least the portions of the declaration and definition + // blocks that don't duplicate portions of the generic body. } auto FormatParamList(InstBlockId param_refs_id) -> void { @@ -465,9 +469,7 @@ class Formatter { out_ << (pending_constant_value_.is_symbolic() ? "symbolic" : "template"); if (!pending_constant_value_is_self_) { out_ << " = "; - FormatInstName( - sem_ir_.constant_values().GetInstId(pending_constant_value_)); - // TODO: For a symbolic constant, include the generic and index. + FormatConstant(pending_constant_value_); } } else { out_ << pending_constant_value_; @@ -878,6 +880,35 @@ class Formatter { auto FormatImplName(ImplId id) -> void { out_ << inst_namer_.GetNameFor(id); } + auto FormatConstant(ConstantId id) -> void { + if (!id.is_valid()) { + out_ << ""; + return; + } + + // For a symbolic constant in a generic, list the constant value in the + // generic first, and the canonical constant second. + if (id.is_symbolic()) { + const auto& symbolic_constant = + sem_ir_.constant_values().GetSymbolicConstant(id); + if (symbolic_constant.generic_id.is_valid()) { + CARBON_CHECK(symbolic_constant.index.region() == + GenericInstIndex::Region::Declaration) + << "TODO: implement formatting of definition constants"; + const auto& generic = + sem_ir_.generics().Get(symbolic_constant.generic_id); + FormatInstName(sem_ir_.inst_blocks().Get( + generic.decl_block_id)[symbolic_constant.index.index()]); + out_ << " ("; + FormatInstName(sem_ir_.constant_values().GetInstId(id)); + out_ << ")"; + return; + } + } + + FormatInstName(sem_ir_.constant_values().GetInstId(id)); + } + auto FormatType(TypeId id) -> void { if (!id.is_valid()) { out_ << "invalid"; @@ -885,7 +916,7 @@ class Formatter { // Types are formatted in the `constants` scope because they only refer to // constants. llvm::SaveAndRestore file_scope(scope_, InstNamer::ScopeId::Constants); - FormatInstName(sem_ir_.types().GetInstId(id)); + FormatConstant(sem_ir_.types().GetConstantId(id)); } } diff --git a/toolchain/sem_ir/generic.h b/toolchain/sem_ir/generic.h index 825c6dcdbdb3..48cbadfb4d0d 100644 --- a/toolchain/sem_ir/generic.h +++ b/toolchain/sem_ir/generic.h @@ -28,6 +28,13 @@ struct Generic : public Printable { // The index in this block will match the `bind_index` in the name binding // instruction's `BindNameInfo`. InstBlockId bindings_id; + + // The following members are set at the end of the corresponding region of the + // generic. + + // A block of instructions that should be evaluated to compute the values and + // instructions needed by the declaration of the generic. + InstBlockId decl_block_id = InstBlockId::Invalid; }; // An instance of a generic entity, such as an instance of a generic function. @@ -43,6 +50,14 @@ struct GenericInstance : Printable { GenericId generic_id; // Argument values, corresponding to the bindings in `Generic::bindings_id`. InstBlockId args_id; + + // The following members are set when the corresponding region of the generic + // instance is resolved. + + // The values and instructions produced by evaluating the decl block of the + // generic. These are the constant values and types and the instantiated + // template-dependent instructions needed by the declaration of this instance. + InstBlockId decl_block_id = InstBlockId::Invalid; }; // Provides storage for deduplicated instances of generics. diff --git a/toolchain/sem_ir/type.h b/toolchain/sem_ir/type.h index 74b3eab5f3c4..d70a23eb5293 100644 --- a/toolchain/sem_ir/type.h +++ b/toolchain/sem_ir/type.h @@ -70,6 +70,13 @@ class TypeStore : public ValueStore { return GetAsInst(type_id).TryAs(); } + // Returns whether two type IDs represent the same type. This includes the + // case where they might be in different generics and thus might have + // different ConstantIds, but are still symbolically equal. + auto AreEqualAcrossDeclarations(TypeId a, TypeId b) const -> bool { + return GetInstId(a) == GetInstId(b); + } + // Gets the value representation to use for a type. This returns an // invalid type if the given type is not complete. auto GetValueRepr(TypeId type_id) const -> ValueRepr {