mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 12:21:06 +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:
@@ -6,6 +6,7 @@
|
||||
#include "toolchain/check/control_flow.h"
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/handle.h"
|
||||
#include "toolchain/check/inst.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
@@ -60,7 +61,7 @@ auto HandleParseNode(Context& context, Parse::WhileStatementId node_id)
|
||||
context.break_continue_stack().pop_back();
|
||||
|
||||
// Add the loop backedge.
|
||||
context.AddInst<SemIR::Branch>(node_id, {.target_id = loop_header_id});
|
||||
AddInst<SemIR::Branch>(context, node_id, {.target_id = loop_header_id});
|
||||
context.inst_block_stack().Pop();
|
||||
|
||||
// Start emitting the loop exit block.
|
||||
@@ -101,8 +102,8 @@ auto HandleParseNode(Context& context, Parse::BreakStatementStartId node_id)
|
||||
"`break` can only be used in a loop");
|
||||
context.emitter().Emit(node_id, BreakOutsideLoop);
|
||||
} else {
|
||||
context.AddInst<SemIR::Branch>(node_id,
|
||||
{.target_id = stack.back().break_target});
|
||||
AddInst<SemIR::Branch>(context, node_id,
|
||||
{.target_id = stack.back().break_target});
|
||||
}
|
||||
|
||||
context.inst_block_stack().Pop();
|
||||
@@ -126,8 +127,8 @@ auto HandleParseNode(Context& context, Parse::ContinueStatementStartId node_id)
|
||||
"`continue` can only be used in a loop");
|
||||
context.emitter().Emit(node_id, ContinueOutsideLoop);
|
||||
} else {
|
||||
context.AddInst<SemIR::Branch>(node_id,
|
||||
{.target_id = stack.back().continue_target});
|
||||
AddInst<SemIR::Branch>(context, node_id,
|
||||
{.target_id = stack.back().continue_target});
|
||||
}
|
||||
|
||||
context.inst_block_stack().Pop();
|
||||
|
||||
Reference in New Issue
Block a user