adds a field to SemIR::Interface to indicate whether it is a core interface (#7091)

The existing `GetCoreInterface` has linear-time complexity and adds more
than the search criteria to the `CoreInterfaceCache`. Adding a new field
to `Interface` changes this operation when building packages other than
`Core`, as this should only be set for the core library.
This commit is contained in:
Christopher Di Bella
2026-04-24 17:33:23 +00:00
committed by GitHub
parent 9532effeae
commit f0c4b37c63
14 changed files with 1002 additions and 48 deletions
+7 -7
View File
@@ -220,7 +220,7 @@ static auto BuildDestroyWitness(
}
auto LookupCppImpl(Context& context, SemIR::LocId loc_id,
CoreInterface core_interface,
SemIR::CoreInterface core_interface,
SemIR::ConstantId query_self_const_id,
SemIR::SpecificInterfaceId query_specific_interface_id,
const TypeStructure* best_impl_type_structure,
@@ -231,24 +231,24 @@ auto LookupCppImpl(Context& context, SemIR::LocId loc_id,
static_cast<void>(best_impl_loc_id);
switch (core_interface) {
case CoreInterface::Copy:
case SemIR::CoreInterface::Copy:
return BuildCopyWitness(context, loc_id, query_self_const_id,
query_specific_interface_id);
case CoreInterface::CppUnsafeDeref:
case SemIR::CoreInterface::CppUnsafeDeref:
return BuildCppUnsafeDerefWitness(context, loc_id, query_self_const_id,
query_specific_interface_id);
case CoreInterface::Default:
case SemIR::CoreInterface::Default:
return BuildDefaultWitness(context, loc_id, query_self_const_id,
query_specific_interface_id);
case CoreInterface::Destroy:
case SemIR::CoreInterface::Destroy:
return BuildDestroyWitness(context, loc_id, query_self_const_id,
query_specific_interface_id);
// IntFitsIn is for Carbon integer types only.
case CoreInterface::IntFitsIn:
case SemIR::CoreInterface::IntFitsIn:
return SemIR::InstId::None;
case CoreInterface::Unknown:
case SemIR::CoreInterface::Unknown:
CARBON_FATAL("unexpected CoreInterface `{0}`", core_interface);
}
}