| ... | ... | @@ -8266,6 +8266,28 @@ fn builtinCall( |
| 8266 | 8266 | } |
| 8267 | 8267 | } |
| 8268 | 8268 | |
| 8269 | // Check function scope-only builtins |
| 8270 | |
| 8271 | if (astgen.fn_block == null) { |
| 8272 | switch (info.tag) { |
| 8273 | .c_va_arg, |
| 8274 | .c_va_copy, |
| 8275 | .c_va_end, |
| 8276 | .c_va_start, |
| 8277 | .work_item_id, |
| 8278 | .work_group_size, |
| 8279 | .work_group_id, |
| 8280 | .set_align_stack, |
| 8281 | .set_cold, |
| 8282 | .return_address, |
| 8283 | .frame_address, |
| 8284 | .breakpoint, |
| 8285 | .src, |
| 8286 | => return astgen.failNode(node, "'{s}' outside function scope", .{builtin_name}), |
| 8287 | else => {}, |
| 8288 | } |
| 8289 | } |
| 8290 | |
| 8269 | 8291 | switch (info.tag) { |
| 8270 | 8292 | .import => { |
| 8271 | 8293 | const node_tags = tree.nodes.items(.tag); |
| ... | ... | @@ -8802,9 +8824,6 @@ fn builtinCall( |
| 8802 | 8824 | return rvalue(gz, ri, .void_value, node); |
| 8803 | 8825 | }, |
| 8804 | 8826 | .c_va_arg => { |
| 8805 | | if (astgen.fn_block == null) { |
| 8806 | | return astgen.failNode(node, "'@cVaArg' outside function scope", .{}); |
| 8807 | | } |
| 8808 | 8827 | const result = try gz.addExtendedPayload(.c_va_arg, Zir.Inst.BinNode{ |
| 8809 | 8828 | .node = gz.nodeIndexToRelative(node), |
| 8810 | 8829 | .lhs = try expr(gz, scope, .{ .rl = .none }, params[0]), |
| ... | ... | @@ -8813,9 +8832,6 @@ fn builtinCall( |
| 8813 | 8832 | return rvalue(gz, ri, result, node); |
| 8814 | 8833 | }, |
| 8815 | 8834 | .c_va_copy => { |
| 8816 | | if (astgen.fn_block == null) { |
| 8817 | | return astgen.failNode(node, "'@cVaCopy' outside function scope", .{}); |
| 8818 | | } |
| 8819 | 8835 | const result = try gz.addExtendedPayload(.c_va_copy, Zir.Inst.UnNode{ |
| 8820 | 8836 | .node = gz.nodeIndexToRelative(node), |
| 8821 | 8837 | .operand = try expr(gz, scope, .{ .rl = .none }, params[0]), |
| ... | ... | @@ -8823,9 +8839,6 @@ fn builtinCall( |
| 8823 | 8839 | return rvalue(gz, ri, result, node); |
| 8824 | 8840 | }, |
| 8825 | 8841 | .c_va_end => { |
| 8826 | | if (astgen.fn_block == null) { |
| 8827 | | return astgen.failNode(node, "'@cVaEnd' outside function scope", .{}); |
| 8828 | | } |
| 8829 | 8842 | const result = try gz.addExtendedPayload(.c_va_end, Zir.Inst.UnNode{ |
| 8830 | 8843 | .node = gz.nodeIndexToRelative(node), |
| 8831 | 8844 | .operand = try expr(gz, scope, .{ .rl = .none }, params[0]), |
| ... | ... | @@ -8833,9 +8846,6 @@ fn builtinCall( |
| 8833 | 8846 | return rvalue(gz, ri, result, node); |
| 8834 | 8847 | }, |
| 8835 | 8848 | .c_va_start => { |
| 8836 | | if (astgen.fn_block == null) { |
| 8837 | | return astgen.failNode(node, "'@cVaStart' outside function scope", .{}); |
| 8838 | | } |
| 8839 | 8849 | if (!astgen.fn_var_args) { |
| 8840 | 8850 | return astgen.failNode(node, "'@cVaStart' in a non-variadic function", .{}); |
| 8841 | 8851 | } |
| ... | ... | @@ -8843,9 +8853,6 @@ fn builtinCall( |
| 8843 | 8853 | }, |
| 8844 | 8854 | |
| 8845 | 8855 | .work_item_id => { |
| 8846 | | if (astgen.fn_block == null) { |
| 8847 | | return astgen.failNode(node, "'@workItemId' outside function scope", .{}); |
| 8848 | | } |
| 8849 | 8856 | const operand = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); |
| 8850 | 8857 | const result = try gz.addExtendedPayload(.work_item_id, Zir.Inst.UnNode{ |
| 8851 | 8858 | .node = gz.nodeIndexToRelative(node), |
| ... | ... | @@ -8854,9 +8861,6 @@ fn builtinCall( |
| 8854 | 8861 | return rvalue(gz, ri, result, node); |
| 8855 | 8862 | }, |
| 8856 | 8863 | .work_group_size => { |
| 8857 | | if (astgen.fn_block == null) { |
| 8858 | | return astgen.failNode(node, "'@workGroupSize' outside function scope", .{}); |
| 8859 | | } |
| 8860 | 8864 | const operand = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); |
| 8861 | 8865 | const result = try gz.addExtendedPayload(.work_group_size, Zir.Inst.UnNode{ |
| 8862 | 8866 | .node = gz.nodeIndexToRelative(node), |
| ... | ... | @@ -8865,9 +8869,6 @@ fn builtinCall( |
| 8865 | 8869 | return rvalue(gz, ri, result, node); |
| 8866 | 8870 | }, |
| 8867 | 8871 | .work_group_id => { |
| 8868 | | if (astgen.fn_block == null) { |
| 8869 | | return astgen.failNode(node, "'@workGroupId' outside function scope", .{}); |
| 8870 | | } |
| 8871 | 8872 | const operand = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); |
| 8872 | 8873 | const result = try gz.addExtendedPayload(.work_group_id, Zir.Inst.UnNode{ |
| 8873 | 8874 | .node = gz.nodeIndexToRelative(node), |