mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 20:18:11 +00:00
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.
121 lines
5.6 KiB
Plaintext
121 lines
5.6 KiB
Plaintext
// 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
|
|
//
|
|
// This is checking that the stdin filename is handled consistently across
|
|
// dump flags.
|
|
// TODO: Align lex/parse with check/lower.
|
|
//
|
|
// ARGS: compile - --output=- --phase=lower --no-prelude-import --target=x86_64-linux-gnu --dump-tokens --dump-parse-tree --parse-dump-format=yaml-postorder --dump-sem-ir --dump-raw-sem-ir --dump-llvm-ir
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/stdin.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/stdin.carbon
|
|
|
|
// CHECK:STDOUT: - filename: <stdin>
|
|
// CHECK:STDOUT: tokens:
|
|
// CHECK:STDOUT: - { index: 0, kind: "FileStart", line: 1, column: 1, indent: 1, spelling: "" }
|
|
// CHECK:STDOUT: - { index: 1, kind: "FileEnd", line: 1, column: 1, indent: 1, spelling: "", has_leading_space: true }
|
|
// CHECK:STDOUT: - filename: <stdin>
|
|
// CHECK:STDOUT: parse_tree: [
|
|
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
|
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
|
// CHECK:STDOUT: ]
|
|
// CHECK:STDOUT: ---
|
|
// CHECK:STDOUT: filename: '-'
|
|
// CHECK:STDOUT: sem_ir:
|
|
// CHECK:STDOUT: names: {}
|
|
// CHECK:STDOUT: import_irs:
|
|
// CHECK:STDOUT: 'import_ir(ApiForImpl)': {decl_id: inst<none>, is_export: false}
|
|
// CHECK:STDOUT: 'import_ir(Cpp)': {decl_id: inst<none>, is_export: false}
|
|
// CHECK:STDOUT: import_ir_insts: {}
|
|
// CHECK:STDOUT: clang_decls: {}
|
|
// CHECK:STDOUT: clang_decl_signatures: {}
|
|
// CHECK:STDOUT: default_values: {}
|
|
// CHECK:STDOUT: name_scopes:
|
|
// CHECK:STDOUT: name_scope0: {inst: inst(Package), parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {}}
|
|
// CHECK:STDOUT: entity_names: {}
|
|
// CHECK:STDOUT: functions: {}
|
|
// CHECK:STDOUT: classes: {}
|
|
// CHECK:STDOUT: interfaces: {}
|
|
// CHECK:STDOUT: associated_constants: {}
|
|
// CHECK:STDOUT: impls: {}
|
|
// CHECK:STDOUT: generics: {}
|
|
// CHECK:STDOUT: specifics: {}
|
|
// CHECK:STDOUT: specific_interfaces: {}
|
|
// CHECK:STDOUT: struct_type_fields:
|
|
// CHECK:STDOUT: struct_type_fields_empty: {}
|
|
// CHECK:STDOUT: types:
|
|
// CHECK:STDOUT: 'type(TypeType)':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: 'type(inst(FormType))':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(FormType))}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: 'type(Error)':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: 'type(inst(InstType))':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(InstType))}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: 'type(inst(NamespaceType))':
|
|
// CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
|
|
// CHECK:STDOUT: object_layout:
|
|
// CHECK:STDOUT: size: 0
|
|
// CHECK:STDOUT: alignment: 1
|
|
// CHECK:STDOUT: declared_facet_types:
|
|
// CHECK:STDOUT: 'declared_facet_type(Empty)': {}
|
|
// CHECK:STDOUT: insts:
|
|
// CHECK:STDOUT: 'inst(TypeType)': {kind: FacetType, arg0: declared_facet_type(Empty), type: type(TypeType)}
|
|
// CHECK:STDOUT: 'inst(Package)': {kind: Namespace, arg0: name_scope0, type: type(inst(NamespaceType))}
|
|
// CHECK:STDOUT: bundles: {}
|
|
// CHECK:STDOUT: constant_values:
|
|
// CHECK:STDOUT: values:
|
|
// CHECK:STDOUT: 'inst(TypeType)': concrete_constant(inst(TypeType))
|
|
// CHECK:STDOUT: 'inst(Package)': concrete_constant(inst(Package))
|
|
// CHECK:STDOUT: symbolic_constants: {}
|
|
// CHECK:STDOUT: inst_blocks:
|
|
// CHECK:STDOUT: inst_block_empty: {}
|
|
// CHECK:STDOUT: exports: {}
|
|
// CHECK:STDOUT: generated: {}
|
|
// CHECK:STDOUT: imports: {}
|
|
// CHECK:STDOUT: global_init: {}
|
|
// CHECK:STDOUT: inst_block60000005:
|
|
// CHECK:STDOUT: 0: inst(Package)
|
|
// CHECK:STDOUT: value_stores:
|
|
// CHECK:STDOUT: shared_values:
|
|
// CHECK:STDOUT: ints: {}
|
|
// CHECK:STDOUT: reals: {}
|
|
// CHECK:STDOUT: floats: {}
|
|
// CHECK:STDOUT: identifiers: {}
|
|
// CHECK:STDOUT: strings: {}
|
|
// CHECK:STDOUT: ...
|
|
// CHECK:STDOUT: --- -
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; ---
|
|
// CHECK:STDOUT: ; ModuleID = '-'
|
|
// CHECK:STDOUT: source_filename = "-"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !llvm.dbg.cu = !{!1}
|
|
// CHECK:STDOUT: !llvm.module.flags = !{!2, !3}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !0 = !DIFile(filename: "-", directory: "")
|
|
// CHECK:STDOUT: !1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !0, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
|
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
|
|
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
|
|
// CHECK:STDOUT:
|