Replace form insts with actions (#7100)

See
[here](https://docs.google.com/document/d/1rWcueFwIfZox6GKVGxiUG4cBzjrZ6djXiIDGyJDtrE4/edit?tab=t.0)
for the design doc.

This also removes the default value of the `result_type_inst_id`
parameter of `HandleAction`, moves it before the action in the parameter
list, and documents it. This solves two problems:
- The default made it easy to forget, leading to unnecessary
`TypeOfInst` instructions.
- When it was present, putting it after the fairly "bulky" action
argument tended to make the callsite harder to read.
This commit is contained in:
Geoff Romer
2026-04-29 18:13:42 +00:00
committed by GitHub
parent 0124aae041
commit 4c9049346d
97 changed files with 1181 additions and 834 deletions
+13 -6
View File
@@ -655,15 +655,22 @@ auto EvalConstantInst(Context& context, SemIR::SpliceInst inst)
// being spliced. Note that `inst.inst_id` is the instruction being spliced,
// so we need to go through another round of obtaining the constant value in
// addition to the one performed by the eval infrastructure.
if (auto inst_value =
context.insts().TryGetAs<SemIR::InstValue>(inst.inst_id)) {
auto nested_inst = context.insts().Get(inst.inst_id);
if (auto inst_value = nested_inst.TryAs<SemIR::InstValue>()) {
return ConstantEvalResult::Existing(
context.constant_values().Get(inst_value->inst_id));
}
// TODO: Consider creating a new `ValueOfInst` instruction analogous to
// `TypeOfInst` to defer determining the constant value until we know the
// instruction. Alternatively, produce a symbolic `SpliceInst` constant.
return ConstantEvalResult::NotConstant;
switch (nested_inst.kind().constant_kind()) {
case SemIR::InstConstantKind::ConstantInstAction:
return ConstantEvalResult::NewSamePhase(inst);
case SemIR::InstConstantKind::InstAction:
// TODO: Consider creating a new `ValueOfInst` instruction analogous to
// `TypeOfInst` to defer determining the constant value until we know the
// instruction. Alternatively, produce a symbolic `SpliceInst` constant.
return ConstantEvalResult::NotConstant;
default:
CARBON_FATAL("Unexpected inst kind for inst splice: {0}", nested_inst);
}
}
auto EvalConstantInst(Context& context, SemIR::StructAccess inst)