| ... | @@ -8266,6 +8266,28 @@ fn builtinCall( | ... | @@ -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 | switch (info.tag) { | 8291 | switch (info.tag) { |
| 8270 | .import => { | 8292 | .import => { |
| 8271 | const node_tags = tree.nodes.items(.tag); | 8293 | const node_tags = tree.nodes.items(.tag); |
| ... | @@ -8802,9 +8824,6 @@ fn builtinCall( | ... | @@ -8802,9 +8824,6 @@ fn builtinCall( |
| 8802 | return rvalue(gz, ri, .void_value, node); | 8824 | return rvalue(gz, ri, .void_value, node); |
| 8803 | }, | 8825 | }, |
| 8804 | .c_va_arg => { | 8826 | .c_va_arg => { |
| 8805 | if (astgen.fn_block == null) { | | |
| 8806 | return astgen.failNode(node, "'@cVaArg' outside function scope", .{}); | | |
| 8807 | } | | |
| 8808 | const result = try gz.addExtendedPayload(.c_va_arg, Zir.Inst.BinNode{ | 8827 | const result = try gz.addExtendedPayload(.c_va_arg, Zir.Inst.BinNode{ |
| 8809 | .node = gz.nodeIndexToRelative(node), | 8828 | .node = gz.nodeIndexToRelative(node), |
| 8810 | .lhs = try expr(gz, scope, .{ .rl = .none }, params[0]), | 8829 | .lhs = try expr(gz, scope, .{ .rl = .none }, params[0]), |
| ... | @@ -8813,9 +8832,6 @@ fn builtinCall( | ... | @@ -8813,9 +8832,6 @@ fn builtinCall( |
| 8813 | return rvalue(gz, ri, result, node); | 8832 | return rvalue(gz, ri, result, node); |
| 8814 | }, | 8833 | }, |
| 8815 | .c_va_copy => { | 8834 | .c_va_copy => { |
| 8816 | if (astgen.fn_block == null) { | | |
| 8817 | return astgen.failNode(node, "'@cVaCopy' outside function scope", .{}); | | |
| 8818 | } | | |
| 8819 | const result = try gz.addExtendedPayload(.c_va_copy, Zir.Inst.UnNode{ | 8835 | const result = try gz.addExtendedPayload(.c_va_copy, Zir.Inst.UnNode{ |
| 8820 | .node = gz.nodeIndexToRelative(node), | 8836 | .node = gz.nodeIndexToRelative(node), |
| 8821 | .operand = try expr(gz, scope, .{ .rl = .none }, params[0]), | 8837 | .operand = try expr(gz, scope, .{ .rl = .none }, params[0]), |
| ... | @@ -8823,9 +8839,6 @@ fn builtinCall( | ... | @@ -8823,9 +8839,6 @@ fn builtinCall( |
| 8823 | return rvalue(gz, ri, result, node); | 8839 | return rvalue(gz, ri, result, node); |
| 8824 | }, | 8840 | }, |
| 8825 | .c_va_end => { | 8841 | .c_va_end => { |
| 8826 | if (astgen.fn_block == null) { | | |
| 8827 | return astgen.failNode(node, "'@cVaEnd' outside function scope", .{}); | | |
| 8828 | } | | |
| 8829 | const result = try gz.addExtendedPayload(.c_va_end, Zir.Inst.UnNode{ | 8842 | const result = try gz.addExtendedPayload(.c_va_end, Zir.Inst.UnNode{ |
| 8830 | .node = gz.nodeIndexToRelative(node), | 8843 | .node = gz.nodeIndexToRelative(node), |
| 8831 | .operand = try expr(gz, scope, .{ .rl = .none }, params[0]), | 8844 | .operand = try expr(gz, scope, .{ .rl = .none }, params[0]), |
| ... | @@ -8833,9 +8846,6 @@ fn builtinCall( | ... | @@ -8833,9 +8846,6 @@ fn builtinCall( |
| 8833 | return rvalue(gz, ri, result, node); | 8846 | return rvalue(gz, ri, result, node); |
| 8834 | }, | 8847 | }, |
| 8835 | .c_va_start => { | 8848 | .c_va_start => { |
| 8836 | if (astgen.fn_block == null) { | | |
| 8837 | return astgen.failNode(node, "'@cVaStart' outside function scope", .{}); | | |
| 8838 | } | | |
| 8839 | if (!astgen.fn_var_args) { | 8849 | if (!astgen.fn_var_args) { |
| 8840 | return astgen.failNode(node, "'@cVaStart' in a non-variadic function", .{}); | 8850 | return astgen.failNode(node, "'@cVaStart' in a non-variadic function", .{}); |
| 8841 | } | 8851 | } |
| ... | @@ -8843,9 +8853,6 @@ fn builtinCall( | ... | @@ -8843,9 +8853,6 @@ fn builtinCall( |
| 8843 | }, | 8853 | }, |
| 8844 | | 8854 | |
| 8845 | .work_item_id => { | 8855 | .work_item_id => { |
| 8846 | if (astgen.fn_block == null) { | | |
| 8847 | return astgen.failNode(node, "'@workItemId' outside function scope", .{}); | | |
| 8848 | } | | |
| 8849 | const operand = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); | 8856 | const operand = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); |
| 8850 | const result = try gz.addExtendedPayload(.work_item_id, Zir.Inst.UnNode{ | 8857 | const result = try gz.addExtendedPayload(.work_item_id, Zir.Inst.UnNode{ |
| 8851 | .node = gz.nodeIndexToRelative(node), | 8858 | .node = gz.nodeIndexToRelative(node), |
| ... | @@ -8854,9 +8861,6 @@ fn builtinCall( | ... | @@ -8854,9 +8861,6 @@ fn builtinCall( |
| 8854 | return rvalue(gz, ri, result, node); | 8861 | return rvalue(gz, ri, result, node); |
| 8855 | }, | 8862 | }, |
| 8856 | .work_group_size => { | 8863 | .work_group_size => { |
| 8857 | if (astgen.fn_block == null) { | | |
| 8858 | return astgen.failNode(node, "'@workGroupSize' outside function scope", .{}); | | |
| 8859 | } | | |
| 8860 | const operand = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); | 8864 | const operand = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); |
| 8861 | const result = try gz.addExtendedPayload(.work_group_size, Zir.Inst.UnNode{ | 8865 | const result = try gz.addExtendedPayload(.work_group_size, Zir.Inst.UnNode{ |
| 8862 | .node = gz.nodeIndexToRelative(node), | 8866 | .node = gz.nodeIndexToRelative(node), |
| ... | @@ -8865,9 +8869,6 @@ fn builtinCall( | ... | @@ -8865,9 +8869,6 @@ fn builtinCall( |
| 8865 | return rvalue(gz, ri, result, node); | 8869 | return rvalue(gz, ri, result, node); |
| 8866 | }, | 8870 | }, |
| 8867 | .work_group_id => { | 8871 | .work_group_id => { |
| 8868 | if (astgen.fn_block == null) { | | |
| 8869 | return astgen.failNode(node, "'@workGroupId' outside function scope", .{}); | | |
| 8870 | } | | |
| 8871 | const operand = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); | 8872 | const operand = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); |
| 8872 | const result = try gz.addExtendedPayload(.work_group_id, Zir.Inst.UnNode{ | 8873 | const result = try gz.addExtendedPayload(.work_group_id, Zir.Inst.UnNode{ |
| 8873 | .node = gz.nodeIndexToRelative(node), | 8874 | .node = gz.nodeIndexToRelative(node), |