mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Make SemIR::TypeType be an empty FacetType instruction (#7813)
The type `type` is now a `FacetType` inst with no constraints. This brings the model implemented in the toolchain into better alignment with the language design. The `SemIR::TypeType` struct remains as a scope for holding the `TypeInstId`, `ConstantId`, and `TypeId` constants, but is not an `InstKind` anymore. The `TypeType` inst looks a lot like singletons, but there are many `FacetType` insts so it doesn't quite fit that model. So we put it alongside singletons with a fixed inst id but refer to it as a more general "builtin" inst that is not a singleton. `Namespace::PackageInstId` is similar, and we group it with `TypeType` conceptually as another builtin instruction with a fixed id. No conversion is needed anymore to use a `type` as a facet, since types also have a `FacetType` type. This simplifies and removes a number of helpers and branches throughout the code. The `TypeType` inst is now part of the constant store, so we end up printing it in the constants block in every test. But it's also named `type` rather than `%type` to preserve the majority of existing formatting behaviour, though this does look different from other constants. Assisted-by: Opus 5 was used to generate a first draft and validate the refactoring. Though nearly everything non-trivial the tool wrote has been modified or rewritten.
This commit is contained in:
@@ -599,6 +599,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_no_data_members_value_param_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %EmptyClass: type = class_type @EmptyClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %foo_empty_param.cpp_overload_set.type: type = cpp_overload_set_type @foo_empty_param.cpp_overload_set [concrete]
|
||||
@@ -637,6 +638,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- fail_import_non_copyable_param_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %NonCopyableClass: type = class_type @NonCopyableClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %foo_non_copyable_param.cpp_overload_set.type: type = cpp_overload_set_type @foo_non_copyable_param.cpp_overload_set [concrete]
|
||||
@@ -672,6 +674,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- pass_move_only_param_temporary.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %foo_move_only_param.cpp_overload_set.type: type = cpp_overload_set_type @foo_move_only_param.cpp_overload_set [concrete]
|
||||
// CHECK:STDOUT: %foo_move_only_param.cpp_overload_set.value: %foo_move_only_param.cpp_overload_set.type = cpp_overload_set_value @foo_move_only_param.cpp_overload_set [concrete]
|
||||
@@ -724,6 +727,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_single_data_member_value_param_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %SingleMemberClass: type = class_type @SingleMemberClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %foo_single_member_param.cpp_overload_set.type: type = cpp_overload_set_type @foo_single_member_param.cpp_overload_set [concrete]
|
||||
@@ -762,6 +766,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_multiple_data_members_value_param_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %MultipleMembersClass: type = class_type @MultipleMembersClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %foo_multiple_members_param.cpp_overload_set.type: type = cpp_overload_set_type @foo_multiple_members_param.cpp_overload_set [concrete]
|
||||
@@ -800,6 +805,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_in_namespace_value_param_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %InNamespaceClass: type = class_type @InNamespaceClass [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.d8e: type = pattern_type %InNamespaceClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
@@ -881,6 +887,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_in_relative_namespace_value_param_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %InRelativeNamespaceClass: type = class_type @InRelativeNamespaceClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %foo.cpp_overload_set.type: type = cpp_overload_set_type @foo.cpp_overload_set [concrete]
|
||||
@@ -928,6 +935,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_in_outer_definition.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %OuterClass: type = class_type @OuterClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %InnerClass: type = class_type @InnerClass [concrete]
|
||||
@@ -1005,6 +1013,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_and_static_method_call_before.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %StaticMethodClass: type = class_type @StaticMethodClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %StaticMethodClass.bar.cpp_overload_set.type: type = cpp_overload_set_type @StaticMethodClass.bar.cpp_overload_set [concrete]
|
||||
@@ -1053,6 +1062,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_and_static_method_call_after.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %StaticMethodClass: type = class_type @StaticMethodClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %foo_static_method_param.cpp_overload_set.type: type = cpp_overload_set_type @foo_static_method_param.cpp_overload_set [concrete]
|
||||
@@ -1101,6 +1111,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_decl_pointer_param_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %DeclPointerParamClass: type = class_type @DeclPointerParamClass [concrete]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %DeclPointerParamClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
@@ -1137,6 +1148,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_pointer_param_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %DefPointerParamClass: type = class_type @DefPointerParamClass [concrete]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %DefPointerParamClass [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
@@ -1173,6 +1185,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_value_return_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
||||
// CHECK:STDOUT: %foo_def_value_return.cpp_overload_set.type: type = cpp_overload_set_type @foo_def_value_return.cpp_overload_set [concrete]
|
||||
// CHECK:STDOUT: %foo_def_value_return.cpp_overload_set.value: %foo_def_value_return.cpp_overload_set.type = cpp_overload_set_value @foo_def_value_return.cpp_overload_set [concrete]
|
||||
@@ -1214,6 +1227,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_decl_pointer_return_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %foo_decl_pointer_return.cpp_overload_set.type: type = cpp_overload_set_type @foo_decl_pointer_return.cpp_overload_set [concrete]
|
||||
// CHECK:STDOUT: %foo_decl_pointer_return.cpp_overload_set.value: %foo_decl_pointer_return.cpp_overload_set.type = cpp_overload_set_value @foo_decl_pointer_return.cpp_overload_set [concrete]
|
||||
// CHECK:STDOUT: %DeclPointerReturnClass: type = class_type @DeclPointerReturnClass [concrete]
|
||||
@@ -1246,6 +1260,7 @@ fn F() {
|
||||
// CHECK:STDOUT: --- import_definition_pointer_return_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
||||
// CHECK:STDOUT: %foo_def_pointer_return.cpp_overload_set.type: type = cpp_overload_set_type @foo_def_pointer_return.cpp_overload_set [concrete]
|
||||
// CHECK:STDOUT: %foo_def_pointer_return.cpp_overload_set.value: %foo_def_pointer_return.cpp_overload_set.type = cpp_overload_set_value @foo_def_pointer_return.cpp_overload_set [concrete]
|
||||
// CHECK:STDOUT: %DefPointerReturnClass: type = class_type @DefPointerReturnClass [concrete]
|
||||
|
||||
Reference in New Issue
Block a user