astgen.c: port @select builtin (ZIR_EXT_SELECT)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5326,7 +5326,33 @@ static uint32_t builtinCallMultiArg(GenZir* gz, Scope* scope, ResultLoc rl,
|
||||
gz, ZIR_INST_SHUFFLE, node, payload_index);
|
||||
return rvalue(gz, rl, result, node);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
// @select — AstGen.zig:9664-9673.
|
||||
// clang-format off
|
||||
if (name_len == 6 && memcmp(source + name_start, "select", 6) == 0
|
||||
&& param_count == 4) {
|
||||
uint32_t elem_type = typeExpr(gz, scope, params[0]);
|
||||
uint32_t pred = expr(gz, scope, params[1]);
|
||||
uint32_t a = expr(gz, scope, params[2]);
|
||||
uint32_t b = expr(gz, scope, params[3]);
|
||||
// Select payload: node_offset, elem_type, pred, a, b (5 words).
|
||||
ensureExtraCapacity(ag, 5);
|
||||
uint32_t payload_index = ag->extra_len;
|
||||
ag->extra[ag->extra_len++]
|
||||
= (uint32_t)((int32_t)node - (int32_t)gz->decl_node_index);
|
||||
ag->extra[ag->extra_len++] = elem_type;
|
||||
ag->extra[ag->extra_len++] = pred;
|
||||
ag->extra[ag->extra_len++] = a;
|
||||
ag->extra[ag->extra_len++] = b;
|
||||
uint32_t result = addExtendedPayload(
|
||||
gz, (uint16_t)ZIR_EXT_SELECT, payload_index);
|
||||
return rvalue(gz, rl, result, node);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
// @TypeOf multi-arg (AstGen.zig:9120-9146).
|
||||
// clang-format off
|
||||
if (name_len == 6 && memcmp(source + name_start, "TypeOf", 6) == 0) {
|
||||
// Reserve extra space: 3 (TypeOfPeer payload) + param_count (refs).
|
||||
uint32_t payload_size = 3; // src_node, body_len, body_index
|
||||
|
||||
@@ -1279,7 +1279,7 @@ const corpus_files = .{
|
||||
"../test/behavior/ref_var_in_if_after_if_2nd_switch_prong.zig",
|
||||
"../test/behavior/return_address.zig",
|
||||
"../test/behavior/saturating_arithmetic.zig",
|
||||
//"../test/behavior/select.zig",
|
||||
"../test/behavior/select.zig",
|
||||
"../test/behavior/shuffle.zig",
|
||||
//"../test/behavior/sizeof_and_typeof.zig",
|
||||
"../test/behavior/slice_sentinel_comptime.zig",
|
||||
|
||||
Reference in New Issue
Block a user