ソースを参照

Rename type's GetInstId to GetTypeInstId, reflecting returned type (#6708)

Discussed briefly [on
Discord](https://discord.com/channels/655572317891461132/655578254970716160/1470442830118912265),
done to reduce confusion.

Assisted-by: Google Antigravity with Gemini 3 Flash
Jon Ross-Perkins 2 ヶ月 前
コミット
2c6d9c7f66
41 ファイル変更99 行追加91 行削除
  1. 1 1
      toolchain/check/action.cpp
  2. 7 5
      toolchain/check/class.cpp
  3. 6 5
      toolchain/check/convert.cpp
  4. 2 2
      toolchain/check/cpp/import.cpp
  5. 2 2
      toolchain/check/cpp/thunk.cpp
  6. 1 1
      toolchain/check/custom_witness.cpp
  7. 5 3
      toolchain/check/deduce.cpp
  8. 3 3
      toolchain/check/diagnostic_emitter.cpp
  9. 1 1
      toolchain/check/eval_inst.cpp
  10. 4 3
      toolchain/check/function.cpp
  11. 1 1
      toolchain/check/generic.cpp
  12. 1 1
      toolchain/check/handle_binding_pattern.cpp
  13. 4 4
      toolchain/check/handle_choice.cpp
  14. 1 1
      toolchain/check/handle_class.cpp
  15. 2 1
      toolchain/check/handle_if_expr.cpp
  16. 4 3
      toolchain/check/handle_impl.cpp
  17. 2 2
      toolchain/check/handle_index.cpp
  18. 1 1
      toolchain/check/handle_loop_statement.cpp
  19. 2 2
      toolchain/check/handle_operator.cpp
  20. 1 1
      toolchain/check/handle_pattern_list.cpp
  21. 2 2
      toolchain/check/handle_struct.cpp
  22. 1 1
      toolchain/check/handle_tuple_literal.cpp
  23. 1 1
      toolchain/check/handle_where.cpp
  24. 11 11
      toolchain/check/import_ref.cpp
  25. 2 2
      toolchain/check/interface.cpp
  26. 2 2
      toolchain/check/member_access.cpp
  27. 1 1
      toolchain/check/name_lookup.cpp
  28. 1 1
      toolchain/check/operator.cpp
  29. 1 1
      toolchain/check/pattern_match.cpp
  30. 1 1
      toolchain/check/subst.cpp
  31. 4 4
      toolchain/check/type.cpp
  32. 6 6
      toolchain/check/type_completion.cpp
  33. 1 1
      toolchain/lower/file_context.cpp
  34. 2 2
      toolchain/lower/handle.cpp
  35. 3 3
      toolchain/sem_ir/builtin_function_kind.cpp
  36. 1 1
      toolchain/sem_ir/dump.cpp
  37. 1 1
      toolchain/sem_ir/inst_fingerprinter.cpp
  38. 1 1
      toolchain/sem_ir/stringify.cpp
  39. 3 3
      toolchain/sem_ir/type.cpp
  40. 2 2
      toolchain/sem_ir/type.h
  41. 1 1
      toolchain/sem_ir/type_iterator.cpp

+ 1 - 1
toolchain/check/action.cpp

@@ -130,7 +130,7 @@ static auto RefineOperand(Context& context, SemIR::LocId loc_id,
     // If the type of the action argument is dependent, refine to an instruction
     // with a concrete type.
     if (OperandIsDependent(context, inst.type_id())) {
-      auto type_inst_id = context.types().GetInstId(inst.type_id());
+      auto type_inst_id = context.types().GetTypeInstId(inst.type_id());
       inst_id = AddDependentActionSpliceImpl(
           context,
           SemIR::LocIdAndInst(

+ 7 - 5
toolchain/check/class.cpp

@@ -42,7 +42,7 @@ auto StartClassDefinition(Context& context, SemIR::Class& class_info,
   // Introduce `Self`.
   context.name_scopes().AddRequiredName(
       class_info.scope_id, SemIR::NameId::SelfType,
-      context.types().GetInstId(class_info.self_type_id));
+      context.types().GetTypeInstId(class_info.self_type_id));
 }
 
 // Checks that the specified finished adapter definition is valid and builds and
@@ -102,7 +102,8 @@ static auto CheckCompleteAdapterClassType(
       context, node_id,
       {.type_id = GetSingletonType(context, SemIR::WitnessType::TypeInstId),
        // TODO: Use InstId from the adapt declaration.
-       .object_repr_type_inst_id = context.types().GetInstId(object_repr_id)});
+       .object_repr_type_inst_id =
+           context.types().GetTypeInstId(object_repr_id)});
 }
 
 static auto AddStructTypeFields(
@@ -271,7 +272,7 @@ static auto CheckCompleteClassType(
   auto base_type_id =
       class_info.GetBaseType(context.sem_ir(), SemIR::SpecificId::None);
   // TODO: Use InstId from base declaration.
-  auto base_type_inst_id = context.types().GetInstId(base_type_id);
+  auto base_type_inst_id = context.types().GetTypeInstId(base_type_id);
   std::optional<SemIR::ClassType> base_class_type;
   if (base_type_id.has_value()) {
     // TODO: If the base class is template dependent, we will need to decide
@@ -289,7 +290,7 @@ static auto CheckCompleteClassType(
   if (defining_vptr) {
     struct_type_fields.push_back(
         {.name_id = SemIR::NameId::Vptr,
-         .type_inst_id = context.types().GetInstId(
+         .type_inst_id = context.types().GetTypeInstId(
              GetPointerType(context, SemIR::VtableType::TypeInstId))});
   }
   if (base_type_id.has_value()) {
@@ -315,7 +316,8 @@ static auto CheckCompleteClassType(
   return AddInst<SemIR::CompleteTypeWitness>(
       context, node_id,
       {.type_id = GetSingletonType(context, SemIR::WitnessType::TypeInstId),
-       .object_repr_type_inst_id = context.types().GetInstId(struct_type_id)});
+       .object_repr_type_inst_id =
+           context.types().GetTypeInstId(struct_type_id)});
 }
 
 auto ComputeClassObjectRepr(Context& context, Parse::ClassDefinitionId node_id,

+ 6 - 5
toolchain/check/convert.cpp

@@ -469,7 +469,7 @@ static auto ConvertTupleToType(Context& context, SemIR::LocId loc_id,
   // TODO: Should we add this as an instruction? It will contain
   // references to local InstIds.
   auto tuple_type_id = GetTupleType(context, type_inst_ids);
-  return context.types().GetInstId(tuple_type_id);
+  return context.types().GetTypeInstId(tuple_type_id);
 }
 
 // Common implementation for ConvertStructToStruct and ConvertStructToClass.
@@ -1258,7 +1258,7 @@ static auto PerformBuiltinConversion(
     if (auto struct_type =
             sem_ir.types().TryGetAs<SemIR::StructType>(value_type_id)) {
       if (struct_type->fields_id == SemIR::StructTypeFieldsId::Empty) {
-        type_value_id = sem_ir.types().GetInstId(value_type_id);
+        type_value_id = sem_ir.types().GetTypeInstId(value_type_id);
       }
     }
 
@@ -1808,7 +1808,7 @@ auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id,
       target.kind == ConversionTarget::Value &&
       (OperandIsDependent(context, expr_id) ||
        OperandIsDependent(context, target.type_id))) {
-    auto target_type_inst_id = context.types().GetInstId(target.type_id);
+    auto target_type_inst_id = context.types().GetTypeInstId(target.type_id);
     return AddDependentActionSplice(
         context, loc_id,
         SemIR::ConvertToValueAction{
@@ -1821,7 +1821,7 @@ auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id,
   // If this is not a builtin conversion, try an `ImplicitAs` conversion.
   if (sem_ir.insts().Get(expr_id).type_id() != target.type_id) {
     SemIR::InstId interface_args[] = {
-        context.types().GetInstId(target.type_id)};
+        context.types().GetTypeInstId(target.type_id)};
     Operator op = {
         .interface_name = GetConversionInterfaceName(target.kind),
         .interface_args_ref = interface_args,
@@ -1993,7 +1993,8 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
 
 auto TypeExpr::ForUnsugared(Context& context, SemIR::TypeId type_id)
     -> TypeExpr {
-  return {.inst_id = context.types().GetInstId(type_id), .type_id = type_id};
+  return {.inst_id = context.types().GetTypeInstId(type_id),
+          .type_id = type_id};
 }
 
 static auto DiagnoseTypeExprEvaluationFailure(Context& context,

+ 2 - 2
toolchain/check/cpp/import.cpp

@@ -819,7 +819,7 @@ static auto MapBuiltinType(Context& context, SemIR::LocId loc_id,
   if (type.isBooleanType()) {
     CARBON_CHECK(ast_context.hasSameType(qual_type, ast_context.BoolTy));
     return ExprAsType(context, Parse::NodeId::None,
-                      context.types().GetInstId(GetSingletonType(
+                      context.types().GetTypeInstId(GetSingletonType(
                           context, SemIR::BoolType::TypeInstId)));
   }
   if (type.isInteger()) {
@@ -989,7 +989,7 @@ static auto MapReferenceType(Context& context, clang::QualType type,
   SemIR::TypeId pointer_type_id =
       GetPointerType(context, referenced_type_expr.inst_id);
   pointer_type_id =
-      GetConstType(context, context.types().GetInstId(pointer_type_id));
+      GetConstType(context, context.types().GetTypeInstId(pointer_type_id));
   return TypeExpr::ForUnsugared(context, pointer_type_id);
 }
 

+ 2 - 2
toolchain/check/cpp/thunk.cpp

@@ -685,7 +685,7 @@ auto PerformCppThunkCall(Context& context, SemIR::LocId loc_id,
       arg_id = AddInst<SemIR::AddrOf>(
           context, loc_id,
           {.type_id = GetPointerType(
-               context, context.types().GetInstId(callee_param_type_id)),
+               context, context.types().GetTypeInstId(callee_param_type_id)),
            .lvalue_id = arg_id});
       arg_id =
           ConvertToValueOfType(context, loc_id, arg_id, thunk_param_type_id);
@@ -705,7 +705,7 @@ auto PerformCppThunkCall(Context& context, SemIR::LocId loc_id,
     auto arg_id = AddInst<SemIR::AddrOf>(
         context, loc_id,
         {.type_id = GetPointerType(
-             context, context.types().GetInstId(
+             context, context.types().GetTypeInstId(
                           context.insts().Get(return_slot_id).type_id())),
          .lvalue_id = return_slot_id});
     thunk_arg_ids.push_back(arg_id);

+ 1 - 1
toolchain/check/custom_witness.cpp

@@ -27,7 +27,7 @@ static auto GetFacetAsType(Context& context,
 
   if (context.types().Is<SemIR::FacetType>(type_type_id)) {
     // It's a facet; access its type.
-    facet_or_type_id = context.types().GetInstId(
+    facet_or_type_id = context.types().GetTypeInstId(
         GetFacetAccessType(context, facet_or_type_id));
   }
   return context.types().GetTypeIdForTypeInstId(facet_or_type_id);

+ 5 - 3
toolchain/check/deduce.cpp

@@ -43,7 +43,8 @@ class DeductionWorklist {
 
   // Adds a single (param, arg) type deduction.
   auto Add(SemIR::TypeId param, SemIR::TypeId arg) -> void {
-    Add(context_->types().GetInstId(param), context_->types().GetInstId(arg));
+    Add(context_->types().GetTypeInstId(param),
+        context_->types().GetTypeInstId(arg));
   }
 
   // Adds a single (param, arg) deduction of a specific.
@@ -300,8 +301,9 @@ auto DeductionContext::Deduce() -> bool {
 
     // If the parameter has a symbolic type, deduce against that.
     if (param_type_id.is_symbolic()) {
-      Add(context().types().GetInstId(param_type_id),
-          context().types().GetInstId(context().insts().Get(arg_id).type_id()));
+      Add(context().types().GetTypeInstId(param_type_id),
+          context().types().GetTypeInstId(
+              context().insts().Get(arg_id).type_id()));
     } else {
       // The argument (e.g. a TupleLiteral of types) may be convertible to a
       // compile-time value (e.g. TupleType) that we can decompose further.

+ 3 - 3
toolchain/check/diagnostic_emitter.cpp

@@ -95,7 +95,7 @@ auto DiagnosticEmitter::ConvertArg(llvm::Any arg) const -> llvm::Any {
     return "`" +
            StringifyConstantInst(
                *sem_ir_,
-               sem_ir_->types().GetInstId(
+               sem_ir_->types().GetTypeInstId(
                    sem_ir_->insts().Get(type_of_expr->inst_id).type_id())) +
            "`";
   }
@@ -107,12 +107,12 @@ auto DiagnosticEmitter::ConvertArg(llvm::Any arg) const -> llvm::Any {
   }
   if (auto* type = llvm::any_cast<TypeIdAsRawType>(&arg)) {
     return StringifyConstantInst(*sem_ir_,
-                                 sem_ir_->types().GetInstId(type->type_id));
+                                 sem_ir_->types().GetTypeInstId(type->type_id));
   }
   if (auto* type_id = llvm::any_cast<SemIR::TypeId>(&arg)) {
     return "`" +
            StringifyConstantInst(*sem_ir_,
-                                 sem_ir_->types().GetInstId(*type_id)) +
+                                 sem_ir_->types().GetTypeInstId(*type_id)) +
            "`";
   }
   if (auto* facet_type_id = llvm::any_cast<SemIR::FacetTypeId>(&arg)) {

+ 1 - 1
toolchain/check/eval_inst.cpp

@@ -527,7 +527,7 @@ auto EvalConstantInst(Context& context, SemIR::InstId inst_id,
     }
     return ConstantEvalResult::NewSamePhase(SemIR::CompleteTypeWitness{
         .type_id = witness_type_id,
-        .object_repr_type_inst_id = context.types().GetInstId(
+        .object_repr_type_inst_id = context.types().GetTypeInstId(
             context.types().GetObjectRepr(complete_type_id))});
   }
 

+ 4 - 3
toolchain/check/function.cpp

@@ -103,7 +103,7 @@ auto MakeBuiltinFunction(Context& context, SemIR::LocId loc_id,
 
     BeginSubpattern(context);
     auto self_type_region_id = EndSubpatternAsExpr(
-        context, context.types().GetInstId(signature.self_type_id));
+        context, context.types().GetTypeInstId(signature.self_type_id));
 
     self_param_id = AddParamPattern(context, loc_id, SemIR::NameId::SelfValue,
                                     self_type_region_id, signature.self_type_id,
@@ -124,7 +124,7 @@ auto MakeBuiltinFunction(Context& context, SemIR::LocId loc_id,
     for (auto param_type_id : signature.param_type_ids) {
       BeginSubpattern(context);
       auto param_type_region_id = EndSubpatternAsExpr(
-          context, context.types().GetInstId(param_type_id));
+          context, context.types().GetTypeInstId(param_type_id));
 
       context.inst_block_stack().AddInstId(AddParamPattern(
           context, loc_id, SemIR::NameId::Underscore, param_type_region_id,
@@ -140,7 +140,8 @@ auto MakeBuiltinFunction(Context& context, SemIR::LocId loc_id,
                                    .type_id = SemIR::TypeId::None};
   if (signature.return_type_id.has_value()) {
     return_form = ExprAsReturnForm(
-        context, loc_id, context.types().GetInstId(signature.return_type_id));
+        context, loc_id,
+        context.types().GetTypeInstId(signature.return_type_id));
     return_patterns_id = AddReturnPatterns(context, loc_id, return_form);
   }
 

+ 1 - 1
toolchain/check/generic.cpp

@@ -209,7 +209,7 @@ static auto AddGenericTypeToEvalBlock(Context& context, SemIR::LocId loc_id,
   // block.
   auto rebuild_generic_constant_callbacks =
       RebuildGenericConstantInEvalBlockCallbacks(&context, loc_id);
-  auto type_inst_id = SubstInst(context, context.types().GetInstId(type_id),
+  auto type_inst_id = SubstInst(context, context.types().GetTypeInstId(type_id),
                                 rebuild_generic_constant_callbacks);
   return context.types().GetTypeIdForTypeConstantId(
       context.constant_values().GetAttached(type_inst_id));

+ 1 - 1
toolchain/check/handle_binding_pattern.cpp

@@ -419,7 +419,7 @@ auto HandleParseNode(Context& context, Parse::FieldNameAndTypeId node_id)
   }
   auto& class_info = context.classes().Get(parent_class_decl->class_id);
   auto field_type_id = GetUnboundElementType(
-      context, context.types().GetInstId(class_info.self_type_id),
+      context, context.types().GetTypeInstId(class_info.self_type_id),
       cast_type_inst_id);
   auto field_id =
       AddInst<SemIR::FieldDecl>(context, node_id,

+ 4 - 4
toolchain/check/handle_choice.cpp

@@ -122,7 +122,7 @@ auto HandleParseNode(Context& context, Parse::ChoiceDefinitionStartId node_id)
 
   context.name_scopes().AddRequiredName(
       class_info.scope_id, SemIR::NameId::SelfType,
-      context.types().GetInstId(self_type_id));
+      context.types().GetTypeInstId(self_type_id));
 
   // Mark the beginning of the choice body.
   context.node_stack().Push(node_id, class_decl.class_id);
@@ -273,7 +273,7 @@ auto HandleParseNode(Context& context, Parse::ChoiceDefinitionId node_id)
   llvm::SmallVector<SemIR::StructTypeField, 1> struct_type_fields;
   struct_type_fields.push_back({
       .name_id = SemIR::NameId::ChoiceDiscriminant,
-      .type_inst_id = context.types().GetInstId(discriminant_type_id),
+      .type_inst_id = context.types().GetTypeInstId(discriminant_type_id),
   });
   auto fields_id =
       context.struct_type_fields().AddCanonical(struct_type_fields);
@@ -281,8 +281,8 @@ auto HandleParseNode(Context& context, Parse::ChoiceDefinitionId node_id)
       context, node_id,
       SemIR::CompleteTypeWitness{
           .type_id = GetSingletonType(context, SemIR::WitnessType::TypeInstId),
-          .object_repr_type_inst_id =
-              context.types().GetInstId(GetStructType(context, fields_id))});
+          .object_repr_type_inst_id = context.types().GetTypeInstId(
+              GetStructType(context, fields_id))});
   auto& class_info = context.classes().Get(class_id);
   class_info.complete_type_witness_id = choice_witness_id;
 

+ 1 - 1
toolchain/check/handle_class.cpp

@@ -529,7 +529,7 @@ auto HandleParseNode(Context& context, Parse::BaseDeclId node_id) -> bool {
   // The `base` value in the class scope has an unbound element type. Instance
   // binding will be performed when it's found by name lookup into an instance.
   auto field_type_id = GetUnboundElementType(
-      context, context.types().GetInstId(class_info.self_type_id),
+      context, context.types().GetTypeInstId(class_info.self_type_id),
       base_info.inst_id);
   class_info.base_id =
       AddInst<SemIR::BaseDecl>(context, node_id,

+ 2 - 1
toolchain/check/handle_if_expr.cpp

@@ -37,7 +37,8 @@ auto HandleParseNode(Context& context, Parse::IfExprIfId node_id) -> bool {
 static auto DecayIntLiteralToSizedInt(Context& context, Parse::NodeId node_id,
                                       SemIR::InstId operand_id)
     -> SemIR::InstId {
-  if (context.types().GetInstId(context.insts().Get(operand_id).type_id()) ==
+  if (context.types().GetTypeInstId(
+          context.insts().Get(operand_id).type_id()) ==
       SemIR::IntLiteralType::TypeInstId) {
     operand_id = ConvertToValueOfType(
         context, node_id, operand_id,

+ 4 - 3
toolchain/check/handle_impl.cpp

@@ -126,9 +126,10 @@ auto HandleParseNode(Context& context, Parse::ImplDefaultSelfAsId node_id)
     // duplicating the handling of the `Self` expression.
     self_inst_id = AddTypeInst(
         context, node_id,
-        SemIR::NameRef{.type_id = SemIR::TypeType::TypeId,
-                       .name_id = SemIR::NameId::SelfType,
-                       .value_id = context.types().GetInstId(self_type_id)});
+        SemIR::NameRef{
+            .type_id = SemIR::TypeType::TypeId,
+            .name_id = SemIR::NameId::SelfType,
+            .value_id = context.types().GetTypeInstId(self_type_id)});
   } else {
     CARBON_DIAGNOSTIC(ImplAsOutsideClass, Error,
                       "`impl as` can only be used in a class");

+ 2 - 2
toolchain/check/handle_index.cpp

@@ -33,8 +33,8 @@ auto HandleParseNode(Context& /*context*/, Parse::IndexExprStartId /*node_id*/)
 static auto PerformIndexWith(Context& context, Parse::NodeId node_id,
                              SemIR::InstId operand_inst_id,
                              SemIR::InstId index_inst_id) -> SemIR::InstId {
-  SemIR::InstId args[] = {
-      context.types().GetInstId(context.insts().Get(index_inst_id).type_id())};
+  SemIR::InstId args[] = {context.types().GetTypeInstId(
+      context.insts().Get(index_inst_id).type_id())};
   Operator op{.interface_name = CoreIdentifier::IndexWith,
               .interface_args_ref = args,
               .op_name = CoreIdentifier::At};

+ 1 - 1
toolchain/check/handle_loop_statement.cpp

@@ -177,7 +177,7 @@ auto HandleParseNode(Context& context, Parse::ForHeaderId node_id) -> bool {
   auto loop_header_id = StartLoopHeader(context, start_node_id);
 
   // Call `<range>.(Iterate.Next)(&cursor)`.
-  auto cursor_type_inst_id = context.types().GetInstId(cursor_type_id);
+  auto cursor_type_inst_id = context.types().GetTypeInstId(cursor_type_id);
   auto cursor_addr_id = AddInst<SemIR::AddrOf>(
       context, node_id,
       {.type_id = GetPointerType(context, cursor_type_inst_id),

+ 2 - 2
toolchain/check/handle_operator.cpp

@@ -39,7 +39,7 @@ static auto HandleBinaryOperator(Context& context,
   // the type of the RHS operand. `as` has different rules and we don't call
   // this function for it.
   SemIR::InstId args[] = {
-      context.types().GetInstId(context.insts().Get(rhs_id).type_id())};
+      context.types().GetTypeInstId(context.insts().Get(rhs_id).type_id())};
   auto result_id = BuildBinaryOperator(context, expr_node_id,
                                        {.interface_name = interface_name,
                                         .interface_args_ref = args,
@@ -277,7 +277,7 @@ auto HandleParseNode(Context& context, Parse::PrefixOperatorAmpId node_id)
       break;
   }
   // TODO: Preserve spelling of type of operand where possible.
-  auto type_inst_id = context.types().GetInstId(type_id);
+  auto type_inst_id = context.types().GetTypeInstId(type_id);
   AddInstAndPush<SemIR::AddrOf>(
       context, node_id,
       SemIR::AddrOf{.type_id = GetPointerType(context, type_inst_id),

+ 1 - 1
toolchain/check/handle_pattern_list.cpp

@@ -80,7 +80,7 @@ auto HandleParseNode(Context& context, Parse::TuplePatternId node_id) -> bool {
   for (auto inst : inst_block) {
     auto type_id = ExtractScrutineeType(context.sem_ir(),
                                         context.insts().Get(inst).type_id());
-    type_inst_ids.push_back(context.types().GetInstId(type_id));
+    type_inst_ids.push_back(context.types().GetTypeInstId(type_id));
   }
   auto type_id = GetPatternType(context, GetTupleType(context, type_inst_ids));
   context.node_stack().Push(

+ 2 - 2
toolchain/check/handle_struct.cpp

@@ -54,8 +54,8 @@ auto HandleParseNode(Context& context, Parse::StructLiteralFieldId node_id)
   auto name_id = context.node_stack().Peek<Parse::NodeCategory::MemberName>();
 
   // Store the name for the type.
-  auto value_type_inst_id =
-      context.types().GetInstId(context.insts().Get(value_inst_id).type_id());
+  auto value_type_inst_id = context.types().GetTypeInstId(
+      context.insts().Get(value_inst_id).type_id());
   context.struct_type_fields_stack().AppendToTop(
       {.name_id = name_id, .type_inst_id = value_type_inst_id});
 

+ 1 - 1
toolchain/check/handle_tuple_literal.cpp

@@ -33,7 +33,7 @@ auto HandleParseNode(Context& context, Parse::TupleLiteralId node_id) -> bool {
   type_inst_ids.reserve(inst_block.size());
   for (auto inst : inst_block) {
     type_inst_ids.push_back(
-        context.types().GetInstId(context.insts().Get(inst).type_id()));
+        context.types().GetTypeInstId(context.insts().Get(inst).type_id()));
   }
   auto type_id = GetTupleType(context, type_inst_ids);
 

+ 1 - 1
toolchain/check/handle_where.cpp

@@ -71,7 +71,7 @@ auto HandleParseNode(Context& context, Parse::WhereOperandId node_id) -> bool {
       AddInstInNoBlock<SemIR::RequirementBaseFacetType>(
           context, SemIR::LocId(node_id),
           {.base_type_inst_id =
-               context.types().GetInstId(self_with_constraints_type_id)}));
+               context.types().GetTypeInstId(self_with_constraints_type_id)}));
 
   // Add a context stack for tracking rewrite constraints, that will be used to
   // allow later constraints to read from them eagerly.

+ 11 - 11
toolchain/check/import_ref.cpp

@@ -1739,7 +1739,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::BoolLiteral inst) -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::BoolType::TypeInstId);
 
   CARBON_CHECK(!resolver.HasNewWork());
@@ -1752,7 +1752,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::BoundMethod inst) -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::BoundMethodType::TypeInstId);
   auto object_id = GetLocalConstantInstId(resolver, inst.object_id);
   auto function_decl_id =
@@ -1789,7 +1789,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver, SemIR::Call inst)
 
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::CharLiteralValue inst) -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::CharLiteralType::TypeInstId);
 
   CARBON_CHECK(!resolver.HasNewWork());
@@ -2020,7 +2020,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::CompleteTypeWitness inst)
     -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::WitnessType::TypeInstId);
   auto object_repr_type_inst_id =
       GetLocalTypeInstId(resolver, inst.object_repr_type_inst_id);
@@ -2075,7 +2075,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::CustomWitness inst) -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::WitnessType::TypeInstId);
 
   auto elements = GetLocalInstBlockContents(resolver, inst.elements_id);
@@ -2126,7 +2126,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::FloatLiteralValue inst)
     -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::FloatLiteralType::TypeInstId);
 
   CARBON_CHECK(!resolver.HasNewWork());
@@ -3167,7 +3167,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::LookupImplWitness inst)
     -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::WitnessType::TypeInstId);
 
   auto query_self_inst_id =
@@ -3196,7 +3196,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::ImplWitness inst) -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::WitnessType::TypeInstId);
 
   auto specific_data = GetLocalSpecificData(resolver, inst.specific_id);
@@ -3266,7 +3266,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
       SemIR::InitForm{
           .type_id =
               resolver.local_types().GetTypeIdForTypeConstantId(type_const_id),
-          .type_component_inst_id = resolver.local_types().GetInstId(
+          .type_component_inst_id = resolver.local_types().GetTypeInstId(
               resolver.local_types().GetTypeIdForTypeConstantId(
                   type_component_const_id)),
           .index = inst.index});
@@ -3373,7 +3373,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::RequireCompleteType inst)
     -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::WitnessType::TypeInstId);
 
   auto complete_type_inst_id =
@@ -3391,7 +3391,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
                                 SemIR::RequireSpecificDefinition inst)
     -> ResolveResult {
-  CARBON_CHECK(resolver.import_types().GetInstId(inst.type_id) ==
+  CARBON_CHECK(resolver.import_types().GetTypeInstId(inst.type_id) ==
                SemIR::RequireSpecificDefinitionType::TypeInstId);
 
   auto specific_data = GetLocalSpecificData(resolver, inst.specific_id);

+ 2 - 2
toolchain/check/interface.cpp

@@ -104,7 +104,7 @@ static auto GetSelfFacetValueForInterfaceMemberSpecific(
   // Create a facet value to be the value of `Self` in the interface.
   // TODO: Pass this in instead of creating it here. The caller sometimes
   // already has a facet value.
-  auto type_inst_id = context.types().GetInstId(self_type_id);
+  auto type_inst_id = context.types().GetTypeInstId(self_type_id);
   auto witnesses_block_id =
       context.inst_blocks().AddCanonical({self_witness_id});
   auto self_value_const_id = TryEvalInst(
@@ -226,7 +226,7 @@ auto GetTypeForSpecificAssociatedEntity(Context& context, SemIR::LocId loc_id,
         context.functions().Get(fn->function_id).generic_id, self_type_id,
         self_witness_id);
     return GetFunctionTypeWithSelfType(
-        context, context.types().GetInstId(interface_fn_type_id),
+        context, context.types().GetTypeInstId(interface_fn_type_id),
         self_facet_id);
   }
 

+ 2 - 2
toolchain/check/member_access.cpp

@@ -566,7 +566,7 @@ static auto PerformActionHelper(Context& context, SemIR::LocId loc_id,
   // this, as the facet should have member names that directly name members of
   // the `impl`.
   auto base_type_as_facet = GetCanonicalFacetOrTypeValue(
-      context, context.types().GetInstId(base_type_id));
+      context, context.types().GetTypeInstId(base_type_id));
   auto base_type_facet_type_id =
       context.insts().Get(base_type_as_facet).type_id();
   if (context.types().Is<SemIR::FacetType>(base_type_facet_type_id)) {
@@ -595,7 +595,7 @@ static auto PerformActionHelper(Context& context, SemIR::LocId loc_id,
 
   // The base type is not a name scope. Try some fallback options.
   if (auto struct_type = context.insts().TryGetAs<SemIR::StructType>(
-          context.types().GetInstId(base_type_id))) {
+          context.types().GetTypeInstId(base_type_id))) {
     // TODO: Do we need to optimize this with a lookup table for O(1)?
     for (auto [i, field] : llvm::enumerate(
              context.struct_type_fields().Get(struct_type->fields_id))) {

+ 1 - 1
toolchain/check/name_lookup.cpp

@@ -492,7 +492,7 @@ auto LookupQualifiedName(Context& context, SemIR::LocId loc_id,
             // The self for member lookup is a type, we need a facet value to
             // replace `Self`.
             facet_value = GetConstantFacetValueForType(
-                context, context.types().GetInstId(self_type_id));
+                context, context.types().GetTypeInstId(self_type_id));
           } else {
             // The self for member lookup is a facet value, use it as is to
             // replace `Self`.

+ 1 - 1
toolchain/check/operator.cpp

@@ -57,7 +57,7 @@ static auto IsCppClassType(Context& context, SemIR::InstId inst_id) -> bool {
 
 // Returns whether the instruction is a value of C++ class type.
 static auto HasCppClassType(Context& context, SemIR::InstId inst_id) -> bool {
-  return IsCppClassType(context, context.types().GetInstId(
+  return IsCppClassType(context, context.types().GetTypeInstId(
                                      context.insts().Get(inst_id).type_id()));
 }
 

+ 1 - 1
toolchain/check/pattern_match.cpp

@@ -445,7 +445,7 @@ auto MatchContext::DoEmitPatternMatch(
   auto return_slot_id = AddInst<SemIR::ReturnSlot>(
       context, SemIR::LocId(entry.pattern_id),
       {.type_id = type_id,
-       .type_inst_id = context.types().GetInstId(type_id),
+       .type_inst_id = context.types().GetTypeInstId(type_id),
        .storage_id = entry.scrutinee_id});
   bool already_in_lookup =
       context.scope_stack()

+ 1 - 1
toolchain/check/subst.cpp

@@ -163,7 +163,7 @@ static auto ExpandOperands(Context& context, Worklist& worklist,
                            SemIR::InstId inst_id) -> void {
   auto inst = context.insts().Get(inst_id);
   if (inst.type_id().has_value()) {
-    worklist.Push(context.types().GetInstId(inst.type_id()));
+    worklist.Push(context.types().GetTypeInstId(inst.type_id()));
   }
   PushOperand(context, worklist, inst.arg0_and_kind());
   PushOperand(context, worklist, inst.arg1_and_kind());

+ 4 - 4
toolchain/check/type.cpp

@@ -140,17 +140,17 @@ auto GetConstType(Context& context, SemIR::TypeInstId inner_type_id)
 auto GetQualifiedType(Context& context, SemIR::TypeId type_id,
                       SemIR::TypeQualifiers quals) -> SemIR::TypeId {
   if (quals.HasAnyOf(SemIR::TypeQualifiers::Const)) {
-    type_id = GetConstType(context, context.types().GetInstId(type_id));
+    type_id = GetConstType(context, context.types().GetTypeInstId(type_id));
     quals.Remove(SemIR::TypeQualifiers::Const);
   }
   if (quals.HasAnyOf(SemIR::TypeQualifiers::MaybeUnformed)) {
     type_id = GetTypeImpl<SemIR::MaybeUnformedType>(
-        context, context.types().GetInstId(type_id));
+        context, context.types().GetTypeInstId(type_id));
     quals.Remove(SemIR::TypeQualifiers::MaybeUnformed);
   }
   if (quals.HasAnyOf(SemIR::TypeQualifiers::Partial)) {
     type_id = GetTypeImpl<SemIR::PartialType>(
-        context, context.types().GetInstId(type_id));
+        context, context.types().GetTypeInstId(type_id));
     quals.Remove(SemIR::TypeQualifiers::Partial);
   }
   CARBON_CHECK(quals == SemIR::TypeQualifiers::None);
@@ -258,7 +258,7 @@ auto GetPatternType(Context& context, SemIR::TypeId scrutinee_type_id)
     return SemIR::ErrorInst::TypeId;
   }
   return GetTypeImpl<SemIR::PatternType>(
-      context, context.types().GetInstId(scrutinee_type_id));
+      context, context.types().GetTypeInstId(scrutinee_type_id));
 }
 
 auto GetUnboundElementType(Context& context, SemIR::TypeInstId class_type_id,

+ 6 - 6
toolchain/check/type_completion.cpp

@@ -328,7 +328,7 @@ auto TypeCompleter::ProcessStep() -> bool {
     return true;
   }
 
-  auto inst_id = context_->types().GetInstId(type_id);
+  auto inst_id = context_->types().GetTypeInstId(type_id);
   auto inst = context_->insts().Get(inst_id);
   auto old_work_list_size = work_list_.size();
 
@@ -484,8 +484,8 @@ auto TypeCompleter::MakePointerValueRepr(
   // TODO: Should we add `const` qualification to `pointee_id`?
   return {.kind = SemIR::ValueRepr::Pointer,
           .aggregate_kind = aggregate_kind,
-          .type_id = GetPointerType(*context_,
-                                    context_->types().GetInstId(pointee_id))};
+          .type_id = GetPointerType(
+              *context_, context_->types().GetTypeInstId(pointee_id))};
 }
 
 auto TypeCompleter::GetNestedInfo(SemIR::TypeId nested_type_id) const
@@ -541,7 +541,7 @@ auto TypeCompleter::BuildInfoForInst(SemIR::TypeId type_id,
                                                   field_type_id)) {
       same_as_object_rep = false;
       field.type_inst_id =
-          context_->types().GetInstId(field_info.value_repr.type_id);
+          context_->types().GetTypeInstId(field_info.value_repr.type_id);
     }
     value_rep_fields.push_back(field);
     // Take the first non-None abstract_class_id, if any.
@@ -584,7 +584,7 @@ auto TypeCompleter::BuildInfoForInst(SemIR::TypeId type_id,
       same_as_object_rep = false;
     }
     value_rep_elements.push_back(
-        context_->types().GetInstId(element_info.value_repr.type_id));
+        context_->types().GetTypeInstId(element_info.value_repr.type_id));
     // Take the first non-None abstract_class_id, if any.
     if (element_info.abstract_class_id.has_value() &&
         !abstract_class_id.has_value()) {
@@ -739,7 +739,7 @@ auto RequireCompleteType(Context& context, SemIR::TypeId type_id,
         SemIR::RequireCompleteType{
             .type_id =
                 GetSingletonType(context, SemIR::WitnessType::TypeInstId),
-            .complete_type_inst_id = context.types().GetInstId(type_id)});
+            .complete_type_inst_id = context.types().GetTypeInstId(type_id)});
   }
 
   return true;

+ 1 - 1
toolchain/lower/file_context.cpp

@@ -75,7 +75,7 @@ auto FileContext::PrepareToLower() -> void {
   // Lower all types that were required to be complete.
   for (auto type_id : sem_ir_->types().complete_types()) {
     if (type_id.index >= 0) {
-      types_.Set(type_id, BuildType(sem_ir_->types().GetInstId(type_id)));
+      types_.Set(type_id, BuildType(sem_ir_->types().GetTypeInstId(type_id)));
     }
   }
 

+ 2 - 2
toolchain/lower/handle.cpp

@@ -26,7 +26,7 @@ static auto IsNamespace(FunctionContext& context, SemIR::InstId inst_id)
   // Note, we don't use context.GetTypeOfInst here. An instruction can't change
   // from being a non-namespace in a generic to being a namespace in a specific,
   // because namespace names are not first-class.
-  auto type_inst_id = context.sem_ir().types().GetInstId(
+  auto type_inst_id = context.sem_ir().types().GetTypeInstId(
       context.sem_ir().insts().Get(inst_id).type_id());
   return type_inst_id == SemIR::NamespaceType::TypeInstId;
 }
@@ -46,7 +46,7 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id,
   // create a ConstantInt from its SemIR value directly.
   llvm::Value* index;
   auto index_type = context.GetTypeIdOfInst(inst.index_id);
-  if (index_type.file->types().GetInstId(index_type.type_id) ==
+  if (index_type.file->types().GetTypeInstId(index_type.type_id) ==
       SemIR::IntLiteralType::TypeInstId) {
     auto value = context.sem_ir().insts().GetAs<SemIR::IntValue>(
         context.sem_ir().constant_values().GetConstantInstId(inst.index_id));

+ 3 - 3
toolchain/sem_ir/builtin_function_kind.cpp

@@ -76,7 +76,7 @@ template <const TypeInstId& BuiltinId>
 struct BuiltinType {
   static auto CheckType(const File& sem_ir, ValidateState& /*state*/,
                         TypeId type_id) -> bool {
-    return sem_ir.types().GetInstId(type_id) == BuiltinId;
+    return sem_ir.types().GetTypeInstId(type_id) == BuiltinId;
   }
 };
 
@@ -199,7 +199,7 @@ struct AnyType {
 struct CoreStringType {
   static auto CheckType(const File& sem_ir, ValidateState& /*state*/,
                         TypeId type_id) -> bool {
-    auto type_inst_id = sem_ir.types().GetInstId(type_id);
+    auto type_inst_id = sem_ir.types().GetTypeInstId(type_id);
     auto class_type = sem_ir.insts().TryGetAs<ClassType>(type_inst_id);
     if (!class_type) {
       return false;
@@ -214,7 +214,7 @@ struct CoreStringType {
 struct CoreCharType {
   static auto CheckType(const File& sem_ir, ValidateState& /*state*/,
                         TypeId type_id) -> bool {
-    auto type_inst_id = sem_ir.types().GetInstId(type_id);
+    auto type_inst_id = sem_ir.types().GetTypeInstId(type_id);
     auto class_type = sem_ir.insts().TryGetAs<ClassType>(type_inst_id);
     if (!class_type) {
       return false;

+ 1 - 1
toolchain/sem_ir/dump.cpp

@@ -462,7 +462,7 @@ LLVM_DUMP_METHOD auto Dump(const File& file, TypeId type_id) -> std::string {
     return out.TakeStr();
   }
 
-  InstId inst_id = file.types().GetInstId(type_id);
+  InstId inst_id = file.types().GetTypeInstId(type_id);
   out << ": " << StringifyConstantInst(file, inst_id) << "; "
       << file.insts().Get(inst_id);
   auto const_id = file.types().GetConstantId(type_id);

+ 1 - 1
toolchain/sem_ir/inst_fingerprinter.cpp

@@ -152,7 +152,7 @@ struct Worklist {
       AddInvalid();
       return;
     }
-    Add(sem_ir->types().GetInstId(type_id));
+    Add(sem_ir->types().GetTypeInstId(type_id));
   }
 
   template <typename T>

+ 1 - 1
toolchain/sem_ir/stringify.cpp

@@ -110,7 +110,7 @@ class StepStack {
 
   // Pushes an instruction by its TypeId.
   auto PushTypeId(TypeId type_id) -> void {
-    PushInstId(sem_ir_->types().GetInstId(type_id));
+    PushInstId(sem_ir_->types().GetTypeInstId(type_id));
   }
 
   // Pushes a specific interface by the interface's entity name.

+ 3 - 3
toolchain/sem_ir/type.cpp

@@ -63,14 +63,14 @@ auto TypeStore::GetAsTypeInstId(InstId inst_id) const -> TypeInstId {
   return TypeInstId::UnsafeMake(inst_id);
 }
 
-auto TypeStore::GetInstId(TypeId type_id) const -> TypeInstId {
+auto TypeStore::GetTypeInstId(TypeId type_id) const -> TypeInstId {
   // The instruction for a TypeId has a value of that TypeId.
   return TypeInstId::UnsafeMake(
       file_->constant_values().GetInstId(GetConstantId(type_id)));
 }
 
 auto TypeStore::GetAsInst(TypeId type_id) const -> Inst {
-  return file_->insts().Get(GetInstId(type_id));
+  return file_->insts().Get(GetTypeInstId(type_id));
 }
 
 auto TypeStore::GetUnattachedType(TypeId type_id) const -> TypeId {
@@ -157,7 +157,7 @@ auto TypeStore::TryGetIntTypeInfo(TypeId int_type_id) const
   if (!object_repr_id.has_value()) {
     return std::nullopt;
   }
-  auto inst_id = file_->types().GetInstId(object_repr_id);
+  auto inst_id = file_->types().GetTypeInstId(object_repr_id);
   if (inst_id == IntLiteralType::TypeInstId) {
     // `Core.IntLiteral` has an unknown bit-width.
     return TypeStore::IntTypeInfo{.is_signed = true, .bit_width = IntId::None};

+ 2 - 2
toolchain/sem_ir/type.h

@@ -83,7 +83,7 @@ class TypeStore : public Yaml::Printable<TypeStore> {
   auto GetAsTypeInstId(InstId inst_id) const -> TypeInstId;
 
   // Returns the ID of the instruction used to define the specified type.
-  auto GetInstId(TypeId type_id) const -> TypeInstId;
+  auto GetTypeInstId(TypeId type_id) const -> TypeInstId;
 
   // Returns the instruction used to define the specified type.
   auto GetAsInst(TypeId type_id) const -> Inst;
@@ -141,7 +141,7 @@ class TypeStore : public Yaml::Printable<TypeStore> {
   // 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);
+    return GetTypeInstId(a) == GetTypeInstId(b);
   }
 
   // Gets the value representation to use for a type. This returns an

+ 1 - 1
toolchain/sem_ir/type_iterator.cpp

@@ -58,7 +58,7 @@ auto TypeIterator::Next() -> Step {
 }
 
 auto TypeIterator::ProcessTypeId(TypeId type_id) -> std::optional<Step> {
-  auto inst_id = sem_ir_->types().GetInstId(type_id);
+  auto inst_id = sem_ir_->types().GetTypeInstId(type_id);
   auto inst = sem_ir_->insts().Get(inst_id);
   CARBON_KIND_SWITCH(inst) {
       // ==== Symbolic types ====