mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +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/context.h"
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/inst.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
@@ -126,7 +127,7 @@ auto BuildReturnWithNoExpr(Context& context, Parse::ReturnStatementId node_id)
|
||||
diag.Emit();
|
||||
}
|
||||
|
||||
context.AddInst<SemIR::Return>(node_id, {});
|
||||
AddInst<SemIR::Return>(context, node_id, {});
|
||||
}
|
||||
|
||||
auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id,
|
||||
@@ -167,8 +168,8 @@ auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id,
|
||||
ConvertToValueOfType(context, node_id, expr_id, return_info.type_id);
|
||||
}
|
||||
|
||||
context.AddInst<SemIR::ReturnExpr>(
|
||||
node_id, {.expr_id = expr_id, .dest_id = return_slot_id});
|
||||
AddInst<SemIR::ReturnExpr>(context, node_id,
|
||||
{.expr_id = expr_id, .dest_id = return_slot_id});
|
||||
}
|
||||
|
||||
auto BuildReturnVar(Context& context, Parse::ReturnStatementId node_id)
|
||||
@@ -192,8 +193,9 @@ auto BuildReturnVar(Context& context, Parse::ReturnStatementId node_id)
|
||||
return_slot_id = SemIR::InstId::None;
|
||||
}
|
||||
|
||||
context.AddInst<SemIR::ReturnExpr>(
|
||||
node_id, {.expr_id = returned_var_id, .dest_id = return_slot_id});
|
||||
AddInst<SemIR::ReturnExpr>(
|
||||
context, node_id,
|
||||
{.expr_id = returned_var_id, .dest_id = return_slot_id});
|
||||
}
|
||||
|
||||
} // namespace Carbon::Check
|
||||
|
||||
Reference in New Issue
Block a user