mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:31:24 +01:00
Refactor AddInst-family functions to their own file (#4941)
This in particular uses free functions because it's likely to end up more consistent with types (versus a wrapper object for InstStore). Note, this is unlikely to have a performance impact, but if it does, we can look into related approaches (and we've already discussed using LTO). Renames `PendingBlock::AddInst` to `PendingBlock::Add` because `MakeElementAccessInst` expects the matching name to exist.
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "toolchain/check/subpattern.h"
|
||||
|
||||
#include "toolchain/check/inst.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
auto BeginSubpattern(Context& context) -> void {
|
||||
@@ -16,8 +18,9 @@ auto EndSubpatternAsExpr(Context& context, SemIR::InstId result_id)
|
||||
if (context.region_stack().PeekRegion().size() > 1) {
|
||||
// End the exit block with a branch to a successor block, whose contents
|
||||
// will be determined later.
|
||||
context.AddInst(SemIR::LocIdAndInst::NoLoc<SemIR::Branch>(
|
||||
{.target_id = context.inst_blocks().AddDefaultValue()}));
|
||||
AddInst(context,
|
||||
SemIR::LocIdAndInst::NoLoc<SemIR::Branch>(
|
||||
{.target_id = context.inst_blocks().AddDefaultValue()}));
|
||||
} else {
|
||||
// This single-block region will be inserted as a SpliceBlock, so we don't
|
||||
// need control flow out of it.
|
||||
|
||||
Reference in New Issue
Block a user