Switch types to a SemanticsTypeId. (#2854)

This switches types to using SemanticsTypeId instead of SemanticsNodeId, and lowering pre-builds its list of types. The empty tuple type is special-cased because we don't want to emit it unless it's in-use, but as the implicit return for functions, it's frequently used. Callables use invalid to indicate the implicit return, and that seems undesirable to change due to the size increase.
This commit is contained in:
Jon Ross-Perkins authored and GitHub committed 2023-05-26 11:19:49 -07:00
1 parent a2156f5a4b
commit 1497e1333d
71 files changed
+645 -523

No files matched your search

+16 -16
View File
@@ -45,6 +45,7 @@ TEST(SemanticsIRTest, YAML) {
// cross-references, so this code is only doing loose structural checks.
auto node_id = Yaml::Scalar(MatchesRegex(R"(node\+\d+)"));
auto node_builtin = Yaml::Scalar(MatchesRegex(R"(node\w+)"));
auto type_id = Yaml::Scalar(MatchesRegex(R"(type\d+)"));
EXPECT_THAT(
Yaml::Value::FromText(print_output),
@@ -55,22 +56,21 @@ TEST(SemanticsIRTest, YAML) {
Pair("real_literals", Yaml::Sequence(IsEmpty())),
Pair("strings", Yaml::Sequence(ElementsAre("x"))),
Pair("types", Yaml::Sequence(ElementsAre(node_builtin))),
Pair(
"nodes",
Yaml::Sequence(AllOf(
// kind is required, other parts are optional.
Each(Yaml::Mapping(Contains(Pair("kind", _)))),
// A 0-arg node.
Contains(Yaml::Mapping(ElementsAre(
Pair("kind", "VarStorage"), Pair("type", node_builtin)))),
// A 1-arg node.
Contains(Yaml::Mapping(ElementsAre(
Pair("kind", "IntegerLiteral"), Pair("arg0", "int0"),
Pair("type", node_builtin)))),
// A 2-arg node.
Contains(Yaml::Mapping(ElementsAre(
Pair("kind", "BindName"), Pair("arg0", "str0"),
Pair("arg1", node_id), Pair("type", node_builtin))))))),
Pair("nodes",
Yaml::Sequence(AllOf(
// kind is required, other parts are optional.
Each(Yaml::Mapping(Contains(Pair("kind", _)))),
// A 0-arg node.
Contains(Yaml::Mapping(ElementsAre(
Pair("kind", "VarStorage"), Pair("type", type_id)))),
// A 1-arg node.
Contains(Yaml::Mapping(ElementsAre(
Pair("kind", "IntegerLiteral"), Pair("arg0", "int0"),
Pair("type", type_id)))),
// A 2-arg node.
Contains(Yaml::Mapping(ElementsAre(
Pair("kind", "BindName"), Pair("arg0", "str0"),
Pair("arg1", node_id), Pair("type", type_id))))))),
// This production has only one node block.
Pair("node_blocks",
Yaml::Sequence(ElementsAre(Yaml::Sequence(IsEmpty()),