mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Remove forward references from binding patterns (#4494)
This is primarily to free up space in the BindingPattern insts, but as a side effect it moves the link between BindingPattern and its BindName out of the SemIR, and into a transient data structure in Context. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
10e256a241
commit
5759ad8b42
@@ -151,14 +151,17 @@ auto MatchContext::EmitPatternMatch(Context& context,
|
||||
case SemIR::SymbolicBindingPattern::Kind: {
|
||||
CARBON_CHECK(kind_ == MatchKind::Callee);
|
||||
auto binding_pattern = pattern.inst.As<SemIR::AnyBindingPattern>();
|
||||
auto bind_name = context.insts().GetAs<SemIR::AnyBindName>(
|
||||
binding_pattern.bind_name_id);
|
||||
auto cache_entry =
|
||||
context.bind_name_cache().Lookup(binding_pattern.entity_name_id);
|
||||
// The cached bind_name should only be used once.
|
||||
auto bind_name_id =
|
||||
std::exchange(cache_entry.value(), SemIR::InstId::Invalid);
|
||||
auto bind_name = context.insts().GetAs<SemIR::AnyBindName>(bind_name_id);
|
||||
CARBON_CHECK(!bind_name.value_id.is_valid());
|
||||
bind_name.value_id = entry.scrutinee_id;
|
||||
context.ReplaceInstBeforeConstantUse(binding_pattern.bind_name_id,
|
||||
bind_name);
|
||||
context.inst_block_stack().AddInstId(binding_pattern.bind_name_id);
|
||||
results_.push_back(binding_pattern.bind_name_id);
|
||||
context.ReplaceInstBeforeConstantUse(bind_name_id, bind_name);
|
||||
context.inst_block_stack().AddInstId(bind_name_id);
|
||||
results_.push_back(bind_name_id);
|
||||
break;
|
||||
}
|
||||
case CARBON_KIND(SemIR::AddrPattern addr_pattern): {
|
||||
|
||||
Reference in New Issue
Block a user