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
2023-05-26 11:19:49 -07:00
committed by GitHub
parent a2156f5a4b
commit 1497e1333d
71 changed files with 645 additions and 523 deletions
@@ -34,11 +34,14 @@ auto SemanticsHandleFunctionDefinition(SemanticsContext& context,
auto SemanticsHandleFunctionDefinitionStart(SemanticsContext& context,
ParseTree::Node parse_node)
-> bool {
SemanticsNodeId return_type_id = SemanticsNodeId::Invalid;
SemanticsTypeId return_type_id = SemanticsTypeId::Invalid;
if (context.parse_tree().node_kind(context.node_stack().PeekParseNode()) ==
ParseNodeKind::ReturnType) {
return_type_id =
context.node_stack().PopForNodeId(ParseNodeKind::ReturnType);
context.node_stack().PopForTypeId(ParseNodeKind::ReturnType);
} else {
// Canonicalize the empty tuple for the implicit return.
context.CanonicalizeType(SemanticsNodeId::BuiltinEmptyTupleType);
}
auto param_refs_id =
context.node_stack().PopForNodeBlockId(ParseNodeKind::ParameterList);