| author | |
| committer | |
| log | d59fc1ac0418d452dc2c1a7701a08af862dc210a |
| tree | 075ceb2807aa49f1e2e55f8ca1f3883d29cbb80a |
| parent | 9349c9c4b1b964d00241bcc310951bfcd22ee86e |
2 files changed, 18 insertions(+), 2 deletions(-)
src/stage1/astgen.cpp+5-2| ... | ... | @@ -4599,8 +4599,11 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4599 | 4599 | } |
| 4600 | 4600 | case BuiltinFnIdShuffle: |
| 4601 | 4601 | { |
| 4602 | // Used for the type expr and the mask expr | |
| 4603 | Scope *comptime_scope = create_comptime_scope(ag->codegen, node, scope); | |
| 4604 | ||
| 4602 | 4605 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4603 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); | |
| 4606 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, comptime_scope); | |
| 4604 | 4607 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4605 | 4608 | return arg0_value; |
| 4606 | 4609 | |
| ... | ... | @@ -4615,7 +4618,7 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4615 | 4618 | return arg2_value; |
| 4616 | 4619 | |
| 4617 | 4620 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 4618 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope); | |
| 4621 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, comptime_scope); | |
| 4619 | 4622 | if (arg3_value == ag->codegen->invalid_inst_src) |
| 4620 | 4623 | return arg3_value; |
| 4621 | 4624 |
test/behavior/vector.zig+13| ... | ... | @@ -632,3 +632,16 @@ test "vector reduce operation" { |
| 632 | 632 | try S.doTheTest(); |
| 633 | 633 | comptime try S.doTheTest(); |
| 634 | 634 | } |
| 635 | ||
| 636 | test "mask parameter of @shuffle is comptime scope" { | |
| 637 | const __v4hi = std.meta.Vector(4, i16); | |
| 638 | var v4_a = __v4hi{ 0, 0, 0, 0 }; | |
| 639 | var v4_b = __v4hi{ 0, 0, 0, 0 }; | |
| 640 | var shuffled: __v4hi = @shuffle(i16, v4_a, v4_b, std.meta.Vector(4, i32){ | |
| 641 | std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len), | |
| 642 | std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len), | |
| 643 | std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len), | |
| 644 | std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len), | |
| 645 | }); | |
| 646 | _ = shuffled; | |
| 647 | } |