mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 14:41:06 +01:00
Support constant InstActions (#7671)
Treat `InstConstantKind::InstAction` the same as `InstConstantKind::ConstInstAction`. Drop `ConstInstAction`, since the two now behave the same. Fix eval for specifics in a couple places to handle `InstId::None`.
This commit is contained in:
@@ -173,10 +173,9 @@ class EvalContext {
|
||||
}
|
||||
|
||||
auto inst_id = specific_eval_info_->values[symbolic_info.index.index()];
|
||||
CARBON_CHECK(inst_id.has_value(),
|
||||
"Forward reference in eval block: index {0} referenced "
|
||||
"before evaluation",
|
||||
symbolic_info.index.index());
|
||||
if (!inst_id.has_value()) {
|
||||
return SemIR::ConstantId::NotConstant;
|
||||
}
|
||||
return constant_values().Get(inst_id);
|
||||
}
|
||||
|
||||
@@ -3152,9 +3151,7 @@ static auto TryEvalTypedInst(EvalContext& eval_context, SemIR::InstId inst_id,
|
||||
if constexpr (ConstantKind == SemIR::InstConstantKind::Always ||
|
||||
ConstantKind == SemIR::InstConstantKind::WheneverPossible) {
|
||||
return MakeConstantResult(eval_context.context(), inst, phase);
|
||||
} else if constexpr (ConstantKind ==
|
||||
SemIR::InstConstantKind::ConstantInstAction ||
|
||||
ConstantKind == SemIR::InstConstantKind::InstAction) {
|
||||
} else if constexpr (ConstantKind == SemIR::InstConstantKind::InstAction) {
|
||||
auto result_inst_id = PerformDelayedAction(
|
||||
eval_context.context(), SemIR::LocId(inst_id), inst.As<InstT>());
|
||||
if (result_inst_id.has_value()) {
|
||||
@@ -3528,12 +3525,12 @@ auto TryEvalBlockForSpecific(Context& context, SemIR::LocId loc_id,
|
||||
for (auto [i, inst_id] : llvm::enumerate(eval_block)) {
|
||||
auto const_id = TryEvalInstInContext(eval_context, inst_id,
|
||||
context.insts().Get(inst_id));
|
||||
CARBON_CHECK(const_id.has_value(), "Failed to evaluate {0} in eval block",
|
||||
context.insts().Get(inst_id));
|
||||
if (const_id == SemIR::ErrorInst::ConstantId) {
|
||||
has_error = true;
|
||||
}
|
||||
result[i] = context.constant_values().GetInstId(const_id);
|
||||
CARBON_CHECK(result[i].has_value(), "Failed to evaluate {0} in eval block",
|
||||
context.insts().Get(inst_id));
|
||||
}
|
||||
|
||||
return {context.inst_blocks().Add(result), has_error};
|
||||
|
||||
Reference in New Issue
Block a user