| ... | ... | @@ -1460,6 +1460,7 @@ fn arrayInitExpr( |
| 1460 | 1460 | mem.eql(u8, tree.tokenSlice(tree.nodeMainToken(array_type.ast.elem_count)), "_")) |
| 1461 | 1461 | { |
| 1462 | 1462 | const len_inst = try gz.addInt(array_init.ast.elements.len); |
| 1463 | const saved_cursor = astgen.saveSourceCursor(); |
| 1463 | 1464 | const elem_type = try typeExpr(gz, scope, array_type.ast.elem_type); |
| 1464 | 1465 | if (array_type.ast.sentinel == .none) { |
| 1465 | 1466 | const array_type_inst = try gz.addPlNode(.array_type, type_expr, Zir.Inst.Bin{ |
| ... | ... | @@ -1468,6 +1469,7 @@ fn arrayInitExpr( |
| 1468 | 1469 | }); |
| 1469 | 1470 | break :inst .{ array_type_inst, elem_type }; |
| 1470 | 1471 | } else { |
| 1472 | astgen.restoreSourceCursor(saved_cursor); |
| 1471 | 1473 | const sentinel_node = array_type.ast.sentinel.unwrap().?; |
| 1472 | 1474 | const sentinel = try comptimeExpr(gz, scope, .{ .rl = .{ .ty = elem_type } }, sentinel_node, .array_sentinel); |
| 1473 | 1475 | const array_type_inst = try gz.addPlNode( |
| ... | ... | @@ -1729,6 +1731,7 @@ fn structInitExpr( |
| 1729 | 1731 | mem.eql(u8, tree.tokenSlice(tree.nodeMainToken(array_type.ast.elem_count)), "_"); |
| 1730 | 1732 | if (struct_init.ast.fields.len == 0) { |
| 1731 | 1733 | if (is_inferred_array_len) { |
| 1734 | const saved_cursor = astgen.saveSourceCursor(); |
| 1732 | 1735 | const elem_type = try typeExpr(gz, scope, array_type.ast.elem_type); |
| 1733 | 1736 | const array_type_inst = if (array_type.ast.sentinel == .none) blk: { |
| 1734 | 1737 | break :blk try gz.addPlNode(.array_type, type_expr, Zir.Inst.Bin{ |
| ... | ... | @@ -1736,6 +1739,7 @@ fn structInitExpr( |
| 1736 | 1739 | .rhs = elem_type, |
| 1737 | 1740 | }); |
| 1738 | 1741 | } else blk: { |
| 1742 | astgen.restoreSourceCursor(saved_cursor); |
| 1739 | 1743 | const sentinel_node = array_type.ast.sentinel.unwrap().?; |
| 1740 | 1744 | const sentinel = try comptimeExpr(gz, scope, .{ .rl = .{ .ty = elem_type } }, sentinel_node, .array_sentinel); |
| 1741 | 1745 | break :blk try gz.addPlNode( |
| ... | ... | @@ -3135,6 +3139,11 @@ fn varDecl( |
| 3135 | 3139 | return astgen.failTok(tree.nodeMainToken(section_node), "cannot set section of local variable '{s}'", .{ident_name_raw}); |
| 3136 | 3140 | } |
| 3137 | 3141 | |
| 3142 | const type_inst: Zir.Inst.Ref = if (var_decl.ast.type_node.unwrap()) |type_node| |
| 3143 | try typeExpr(gz, scope, type_node) |
| 3144 | else |
| 3145 | .none; |
| 3146 | |
| 3138 | 3147 | const align_inst: Zir.Inst.Ref = if (var_decl.ast.align_node.unwrap()) |align_node| |
| 3139 | 3148 | try comptimeExpr(gz, scope, coerced_align_ri, align_node, .@"align") |
| 3140 | 3149 | else |
| ... | ... | @@ -3155,8 +3164,8 @@ fn varDecl( |
| 3155 | 3164 | if (align_inst == .none and |
| 3156 | 3165 | !astgen.nodes_need_rl.contains(node)) |
| 3157 | 3166 | { |
| 3158 | | const result_info: ResultInfo = if (var_decl.ast.type_node.unwrap()) |type_node| .{ |
| 3159 | | .rl = .{ .ty = try typeExpr(gz, scope, type_node) }, |
| 3167 | const result_info: ResultInfo = if (type_inst != .none) .{ |
| 3168 | .rl = .{ .ty = type_inst }, |
| 3160 | 3169 | .ctx = .const_init, |
| 3161 | 3170 | } else .{ .rl = .none, .ctx = .const_init }; |
| 3162 | 3171 | const init_inst: Zir.Inst.Ref = try nameStratExpr(gz, scope, result_info, init_node, .dbg_var) orelse |
| ... | ... | @@ -3185,8 +3194,7 @@ fn varDecl( |
| 3185 | 3194 | const is_comptime = gz.is_comptime or |
| 3186 | 3195 | tree.nodeTag(init_node) == .@"comptime"; |
| 3187 | 3196 | |
| 3188 | | const init_rl: ResultInfo.Loc = if (var_decl.ast.type_node.unwrap()) |type_node| init_rl: { |
| 3189 | | const type_inst = try typeExpr(gz, scope, type_node); |
| 3197 | const init_rl: ResultInfo.Loc = if (type_inst != .none) init_rl: { |
| 3190 | 3198 | if (align_inst == .none) { |
| 3191 | 3199 | break :init_rl .{ .ptr = .{ .inst = try gz.addUnNode(.alloc, type_inst, node) } }; |
| 3192 | 3200 | } else { |
| ... | ... | @@ -3254,8 +3262,7 @@ fn varDecl( |
| 3254 | 3262 | if (var_decl.comptime_token != null and gz.is_comptime) |
| 3255 | 3263 | return astgen.failTok(var_decl.comptime_token.?, "'comptime var' is redundant in comptime scope", .{}); |
| 3256 | 3264 | const is_comptime = var_decl.comptime_token != null or gz.is_comptime; |
| 3257 | | const alloc: Zir.Inst.Ref, const resolve_inferred: bool, const result_info: ResultInfo = if (var_decl.ast.type_node.unwrap()) |type_node| a: { |
| 3258 | | const type_inst = try typeExpr(gz, scope, type_node); |
| 3265 | const alloc: Zir.Inst.Ref, const resolve_inferred: bool, const result_info: ResultInfo = if (type_inst != .none) a: { |
| 3259 | 3266 | const alloc = alloc: { |
| 3260 | 3267 | if (align_inst == .none) { |
| 3261 | 3268 | const tag: Zir.Inst.Tag = if (is_comptime) |
| ... | ... | @@ -3433,6 +3440,7 @@ fn assignDestructureMaybeDecls( |
| 3433 | 3440 | const is_comptime = full.comptime_token != null or gz.is_comptime; |
| 3434 | 3441 | const value_is_comptime = tree.nodeTag(full.ast.value_expr) == .@"comptime"; |
| 3435 | 3442 | |
| 3443 | const saved_cursor = astgen.saveSourceCursor(); |
| 3436 | 3444 | // When declaring consts via a destructure, we always use a result pointer. |
| 3437 | 3445 | // This avoids the need to create tuple types, and is also likely easier to |
| 3438 | 3446 | // optimize, since it's a bit tricky for the optimizer to "split up" the |
| ... | ... | @@ -3482,14 +3490,18 @@ fn assignDestructureMaybeDecls( |
| 3482 | 3490 | // We also mark `const`s as comptime if the RHS is definitely comptime-known. |
| 3483 | 3491 | const this_variable_comptime = is_comptime or (is_const and value_is_comptime); |
| 3484 | 3492 | |
| 3493 | const type_inst = if (full_var_decl.ast.type_node.unwrap()) |type_node| |
| 3494 | try typeExpr(gz, scope, type_node) |
| 3495 | else |
| 3496 | .none; |
| 3497 | |
| 3485 | 3498 | const align_inst: Zir.Inst.Ref = if (full_var_decl.ast.align_node.unwrap()) |align_node| |
| 3486 | 3499 | try comptimeExpr(gz, scope, coerced_align_ri, align_node, .@"align") |
| 3487 | 3500 | else |
| 3488 | 3501 | .none; |
| 3489 | 3502 | |
| 3490 | | if (full_var_decl.ast.type_node.unwrap()) |type_node| { |
| 3503 | if (type_inst != .none) { |
| 3491 | 3504 | // Typed alloc |
| 3492 | | const type_inst = try typeExpr(gz, scope, type_node); |
| 3493 | 3505 | const ptr = if (align_inst == .none) ptr: { |
| 3494 | 3506 | const tag: Zir.Inst.Tag = if (this_variable_comptime) |
| 3495 | 3507 | .alloc_comptime_mut |
| ... | ... | @@ -3556,6 +3568,7 @@ fn assignDestructureMaybeDecls( |
| 3556 | 3568 | if (any_lvalue_expr) { |
| 3557 | 3569 | // At least one variable was an lvalue expr. Iterate again in order to |
| 3558 | 3570 | // evaluate the lvalues from within the possible block_comptime. |
| 3571 | astgen.restoreSourceCursor(saved_cursor); |
| 3559 | 3572 | for (rl_components, full.ast.variables) |*variable_rl, variable_node| { |
| 3560 | 3573 | if (variable_rl.* != .typed_ptr) continue; |
| 3561 | 3574 | switch (tree.nodeTag(variable_node)) { |
| ... | ... | @@ -3889,7 +3902,9 @@ fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node. |
| 3889 | 3902 | return astgen.failNode(len_node, "unable to infer array size", .{}); |
| 3890 | 3903 | } |
| 3891 | 3904 | const len = try reachableExprComptime(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, len_node, node, .array_length); |
| 3905 | const saved_cursor = astgen.saveSourceCursor(); |
| 3892 | 3906 | const elem_type = try typeExpr(gz, scope, extra.elem_type); |
| 3907 | astgen.restoreSourceCursor(saved_cursor); |
| 3893 | 3908 | const sentinel = try reachableExprComptime(gz, scope, .{ .rl = .{ .coerced_ty = elem_type } }, extra.sentinel, node, .array_sentinel); |
| 3894 | 3909 | |
| 3895 | 3910 | const result = try gz.addPlNode(.array_type_sentinel, node, Zir.Inst.ArrayTypeSentinel{ |
| ... | ... | @@ -4061,43 +4076,41 @@ fn fnDecl( |
| 4061 | 4076 | // We include a function *type*, not a value. |
| 4062 | 4077 | const type_inst = try fnProtoExprInner(&type_gz, &type_gz.base, .{ .rl = .none }, decl_node, fn_proto, true); |
| 4063 | 4078 | _ = try type_gz.addBreakWithSrcNode(.break_inline, decl_inst, type_inst, decl_node); |
| 4079 | astgen.restoreSourceCursor(saved_cursor); |
| 4064 | 4080 | } |
| 4065 | 4081 | |
| 4066 | 4082 | var align_gz = type_gz.makeSubBlock(scope); |
| 4067 | 4083 | defer align_gz.unstack(); |
| 4068 | 4084 | |
| 4069 | 4085 | if (fn_proto.ast.align_expr.unwrap()) |align_expr| { |
| 4070 | | astgen.restoreSourceCursor(saved_cursor); |
| 4071 | 4086 | const inst = try expr(&align_gz, &align_gz.base, coerced_align_ri, align_expr); |
| 4072 | 4087 | _ = try align_gz.addBreakWithSrcNode(.break_inline, decl_inst, inst, decl_node); |
| 4073 | 4088 | } |
| 4074 | 4089 | |
| 4075 | | var linksection_gz = align_gz.makeSubBlock(scope); |
| 4076 | | defer linksection_gz.unstack(); |
| 4077 | | |
| 4078 | | if (fn_proto.ast.section_expr.unwrap()) |section_expr| { |
| 4079 | | astgen.restoreSourceCursor(saved_cursor); |
| 4080 | | const inst = try expr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, section_expr); |
| 4081 | | _ = try linksection_gz.addBreakWithSrcNode(.break_inline, decl_inst, inst, decl_node); |
| 4082 | | } |
| 4083 | | |
| 4084 | | var addrspace_gz = linksection_gz.makeSubBlock(scope); |
| 4090 | var addrspace_gz = align_gz.makeSubBlock(scope); |
| 4085 | 4091 | defer addrspace_gz.unstack(); |
| 4086 | 4092 | |
| 4087 | 4093 | if (fn_proto.ast.addrspace_expr.unwrap()) |addrspace_expr| { |
| 4088 | | astgen.restoreSourceCursor(saved_cursor); |
| 4089 | 4094 | const addrspace_ty = try addrspace_gz.addStdLangValue(addrspace_expr, .address_space); |
| 4090 | 4095 | const inst = try expr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, addrspace_expr); |
| 4091 | 4096 | _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, inst, decl_node); |
| 4092 | 4097 | } |
| 4093 | 4098 | |
| 4094 | | var value_gz = addrspace_gz.makeSubBlock(scope); |
| 4099 | var linksection_gz = addrspace_gz.makeSubBlock(scope); |
| 4100 | defer linksection_gz.unstack(); |
| 4101 | |
| 4102 | if (fn_proto.ast.section_expr.unwrap()) |section_expr| { |
| 4103 | const inst = try expr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, section_expr); |
| 4104 | _ = try linksection_gz.addBreakWithSrcNode(.break_inline, decl_inst, inst, decl_node); |
| 4105 | } |
| 4106 | |
| 4107 | var value_gz = linksection_gz.makeSubBlock(scope); |
| 4095 | 4108 | defer value_gz.unstack(); |
| 4096 | 4109 | |
| 4097 | 4110 | if (!is_extern) { |
| 4098 | 4111 | // We include a function *value*, not a type. |
| 4099 | 4112 | astgen.restoreSourceCursor(saved_cursor); |
| 4100 | | try astgen.fnDeclInner(&value_gz, &value_gz.base, saved_cursor, decl_inst, decl_node, body_node.unwrap().?, fn_proto); |
| 4113 | try astgen.fnDeclInner(&value_gz, &value_gz.base, decl_inst, decl_node, body_node.unwrap().?, fn_proto); |
| 4101 | 4114 | } |
| 4102 | 4115 | |
| 4103 | 4116 | // *Now* we can incorporate the full source code into the hasher. |
| ... | ... | @@ -4119,8 +4132,8 @@ fn fnDecl( |
| 4119 | 4132 | |
| 4120 | 4133 | .type_gz = &type_gz, |
| 4121 | 4134 | .align_gz = &align_gz, |
| 4122 | | .linksection_gz = &linksection_gz, |
| 4123 | 4135 | .addrspace_gz = &addrspace_gz, |
| 4136 | .linksection_gz = &linksection_gz, |
| 4124 | 4137 | .value_gz = &value_gz, |
| 4125 | 4138 | }); |
| 4126 | 4139 | } |
| ... | ... | @@ -4129,7 +4142,6 @@ fn fnDeclInner( |
| 4129 | 4142 | astgen: *AstGen, |
| 4130 | 4143 | decl_gz: *GenZir, |
| 4131 | 4144 | scope: *Scope, |
| 4132 | | saved_cursor: SourceCursor, |
| 4133 | 4145 | decl_inst: Zir.Inst.Index, |
| 4134 | 4146 | decl_node: Ast.Node.Index, |
| 4135 | 4147 | body_node: Ast.Node.Index, |
| ... | ... | @@ -4266,27 +4278,6 @@ fn fnDeclInner( |
| 4266 | 4278 | // instructions inside the expression blocks for cc and ret_ty to use the function |
| 4267 | 4279 | // instruction as the body to break from. |
| 4268 | 4280 | |
| 4269 | | var ret_gz = decl_gz.makeSubBlock(params_scope); |
| 4270 | | defer ret_gz.unstack(); |
| 4271 | | any_param_used = false; // we will check this later |
| 4272 | | const ret_ref: Zir.Inst.Ref = inst: { |
| 4273 | | // Parameters are in scope for the return type, so we use `params_scope` here. |
| 4274 | | // The calling convention will not have parameters in scope, so we'll just use `scope`. |
| 4275 | | // See #22263 for a proposal to solve the inconsistency here. |
| 4276 | | const inst = try fullBodyExpr(&ret_gz, params_scope, coerced_type_ri, fn_proto.ast.return_type.unwrap().?, .normal); |
| 4277 | | if (ret_gz.instructionsSlice().len == 0) { |
| 4278 | | // In this case we will send a len=0 body which can be encoded more efficiently. |
| 4279 | | break :inst inst; |
| 4280 | | } |
| 4281 | | _ = try ret_gz.addBreak(.break_inline, @fromBackingInt(@intCast(0)), inst); |
| 4282 | | break :inst inst; |
| 4283 | | }; |
| 4284 | | const ret_body_param_refs = try astgen.fetchRemoveRefEntries(param_insts.items); |
| 4285 | | const ret_ty_is_generic = any_param_used; |
| 4286 | | |
| 4287 | | // We're jumping back in source, so restore the cursor. |
| 4288 | | astgen.restoreSourceCursor(saved_cursor); |
| 4289 | | |
| 4290 | 4281 | var cc_gz = decl_gz.makeSubBlock(scope); |
| 4291 | 4282 | defer cc_gz.unstack(); |
| 4292 | 4283 | const cc_ref: Zir.Inst.Ref = blk: { |
| ... | ... | @@ -4312,6 +4303,24 @@ fn fnDeclInner( |
| 4312 | 4303 | } |
| 4313 | 4304 | }; |
| 4314 | 4305 | |
| 4306 | var ret_gz = decl_gz.makeSubBlock(params_scope); |
| 4307 | defer ret_gz.unstack(); |
| 4308 | any_param_used = false; // we will check this later |
| 4309 | const ret_ref: Zir.Inst.Ref = inst: { |
| 4310 | // Parameters are in scope for the return type, so we use `params_scope` here. |
| 4311 | // The calling convention will not have parameters in scope, so we'll just use `scope`. |
| 4312 | // See #22263 for a proposal to solve the inconsistency here. |
| 4313 | const inst = try fullBodyExpr(&ret_gz, params_scope, coerced_type_ri, fn_proto.ast.return_type.unwrap().?, .normal); |
| 4314 | if (ret_gz.instructionsSlice().len == 0) { |
| 4315 | // In this case we will send a len=0 body which can be encoded more efficiently. |
| 4316 | break :inst inst; |
| 4317 | } |
| 4318 | _ = try ret_gz.addBreak(.break_inline, @fromBackingInt(@intCast(0)), inst); |
| 4319 | break :inst inst; |
| 4320 | }; |
| 4321 | const ret_body_param_refs = try astgen.fetchRemoveRefEntries(param_insts.items); |
| 4322 | const ret_ty_is_generic = any_param_used; |
| 4323 | |
| 4315 | 4324 | var body_gz: GenZir = .{ |
| 4316 | 4325 | .is_comptime = false, |
| 4317 | 4326 | .src_baseline = fn_proto.ast.proto_node, |
| ... | ... | @@ -4490,14 +4499,6 @@ fn globalVarDecl( |
| 4490 | 4499 | _ = try align_gz.addBreakWithSrcNode(.break_inline, decl_inst, align_inst, node); |
| 4491 | 4500 | } |
| 4492 | 4501 | |
| 4493 | | var linksection_gz = type_gz.makeSubBlock(scope); |
| 4494 | | defer linksection_gz.unstack(); |
| 4495 | | |
| 4496 | | if (var_decl.ast.section_node.unwrap()) |section_node| { |
| 4497 | | const linksection_inst = try expr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, section_node); |
| 4498 | | _ = try linksection_gz.addBreakWithSrcNode(.break_inline, decl_inst, linksection_inst, node); |
| 4499 | | } |
| 4500 | | |
| 4501 | 4502 | var addrspace_gz = type_gz.makeSubBlock(scope); |
| 4502 | 4503 | defer addrspace_gz.unstack(); |
| 4503 | 4504 | |
| ... | ... | @@ -4507,6 +4508,14 @@ fn globalVarDecl( |
| 4507 | 4508 | _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node); |
| 4508 | 4509 | } |
| 4509 | 4510 | |
| 4511 | var linksection_gz = type_gz.makeSubBlock(scope); |
| 4512 | defer linksection_gz.unstack(); |
| 4513 | |
| 4514 | if (var_decl.ast.section_node.unwrap()) |section_node| { |
| 4515 | const linksection_inst = try expr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, section_node); |
| 4516 | _ = try linksection_gz.addBreakWithSrcNode(.break_inline, decl_inst, linksection_inst, node); |
| 4517 | } |
| 4518 | |
| 4510 | 4519 | var init_gz = type_gz.makeSubBlock(scope); |
| 4511 | 4520 | defer init_gz.unstack(); |
| 4512 | 4521 | |
| ... | ... | @@ -4536,8 +4545,8 @@ fn globalVarDecl( |
| 4536 | 4545 | |
| 4537 | 4546 | .type_gz = &type_gz, |
| 4538 | 4547 | .align_gz = &align_gz, |
| 4539 | | .linksection_gz = &linksection_gz, |
| 4540 | 4548 | .addrspace_gz = &addrspace_gz, |
| 4549 | .linksection_gz = &linksection_gz, |
| 4541 | 4550 | .value_gz = &init_gz, |
| 4542 | 4551 | }); |
| 4543 | 4552 | } |
| ... | ... | @@ -4599,8 +4608,8 @@ fn comptimeDecl( |
| 4599 | 4608 | .linkage = .normal, |
| 4600 | 4609 | .type_gz = &dummy_gz, |
| 4601 | 4610 | .align_gz = &dummy_gz, |
| 4602 | | .linksection_gz = &dummy_gz, |
| 4603 | 4611 | .addrspace_gz = &dummy_gz, |
| 4612 | .linksection_gz = &dummy_gz, |
| 4604 | 4613 | .value_gz = &comptime_gz, |
| 4605 | 4614 | }); |
| 4606 | 4615 | } |
| ... | ... | @@ -7734,10 +7743,6 @@ fn switchExpr( |
| 7734 | 7743 | }; |
| 7735 | 7744 | |
| 7736 | 7745 | if (capture != .none) assert(any_has_payload_capture); |
| 7737 | | if (is_err_switch) { |
| 7738 | | assert(!any_payload_is_ref); // should have failed by now |
| 7739 | | assert(!any_has_tag_capture); // should have failed by now |
| 7740 | | } |
| 7741 | 7746 | |
| 7742 | 7747 | prong_body: { |
| 7743 | 7748 | scratch_scope.instructions_top = parent_gz.instructions.items.len; |
| ... | ... | @@ -7844,6 +7849,10 @@ fn switchExpr( |
| 7844 | 7849 | } |
| 7845 | 7850 | } |
| 7846 | 7851 | } |
| 7852 | if (is_err_switch) { |
| 7853 | assert(!any_payload_is_ref); // should have failed by now |
| 7854 | assert(!any_has_tag_capture); // should have failed by now |
| 7855 | } |
| 7847 | 7856 | assert(scalar_case_index + multi_case_index + @intFromBool(has_else) == case_nodes.len); |
| 7848 | 7857 | assert(multi_items_infos_start + multi_item_offset == bodies_start); |
| 7849 | 7858 | |
| ... | ... | @@ -11527,8 +11536,8 @@ const GenZir = struct { |
| 11527 | 11536 | |
| 11528 | 11537 | /// Must be called with the following stack set up: |
| 11529 | 11538 | /// * gz (bottom) |
| 11530 | | /// * ret_gz |
| 11531 | 11539 | /// * cc_gz |
| 11540 | /// * ret_gz |
| 11532 | 11541 | /// * body_gz (top) |
| 11533 | 11542 | /// Unstacks all of those except for `gz`. |
| 11534 | 11543 | fn addFunc( |
| ... | ... | @@ -11575,16 +11584,16 @@ const GenZir = struct { |
| 11575 | 11584 | stacked_gz = body_gz; |
| 11576 | 11585 | break :body body; |
| 11577 | 11586 | } else &.{}; |
| 11578 | | const cc_body: []const Zir.Inst.Index = if (args.cc_gz) |cc_gz| body: { |
| 11579 | | const cc_body = cc_gz.instructionsSliceUptoOpt(stacked_gz); |
| 11580 | | stacked_gz = cc_gz; |
| 11581 | | break :body cc_body; |
| 11582 | | } else &.{}; |
| 11583 | 11587 | const ret_body: []const Zir.Inst.Index = if (args.ret_gz) |ret_gz| body: { |
| 11584 | 11588 | const ret_body = ret_gz.instructionsSliceUptoOpt(stacked_gz); |
| 11585 | 11589 | stacked_gz = ret_gz; |
| 11586 | 11590 | break :body ret_body; |
| 11587 | 11591 | } else &.{}; |
| 11592 | const cc_body: []const Zir.Inst.Index = if (args.cc_gz) |cc_gz| body: { |
| 11593 | const cc_body = cc_gz.instructionsSliceUptoOpt(stacked_gz); |
| 11594 | stacked_gz = cc_gz; |
| 11595 | break :body cc_body; |
| 11596 | } else &.{}; |
| 11588 | 11597 | break :bodies .{ body, cc_body, ret_body }; |
| 11589 | 11598 | }; |
| 11590 | 11599 | |
| ... | ... | @@ -11725,8 +11734,8 @@ const GenZir = struct { |
| 11725 | 11734 | |
| 11726 | 11735 | // Order is important when unstacking. |
| 11727 | 11736 | if (args.body_gz) |body_gz| body_gz.unstack(); |
| 11728 | | if (args.cc_gz) |cc_gz| cc_gz.unstack(); |
| 11729 | 11737 | if (args.ret_gz) |ret_gz| ret_gz.unstack(); |
| 11738 | if (args.cc_gz) |cc_gz| cc_gz.unstack(); |
| 11730 | 11739 | |
| 11731 | 11740 | astgen.instructions.appendAssumeCapacity(.{ |
| 11732 | 11741 | .tag = tag, |
| ... | ... | @@ -13502,10 +13511,10 @@ fn setDeclaration( |
| 13502 | 13511 | /// Must be stacked on `type_gz`. |
| 13503 | 13512 | align_gz: *GenZir, |
| 13504 | 13513 | /// Must be stacked on `align_gz`. |
| 13505 | | linksection_gz: *GenZir, |
| 13506 | | /// Must be stacked on `linksection_gz`. |
| 13507 | 13514 | addrspace_gz: *GenZir, |
| 13508 | | /// Must be stacked on `addrspace_gz` and have nothing stacked on top of it. |
| 13515 | /// Must be stacked on `addrspace_gz`. |
| 13516 | linksection_gz: *GenZir, |
| 13517 | /// Must be stacked on `linksection_gz` and have nothing stacked on top of it. |
| 13509 | 13518 | value_gz: *GenZir, |
| 13510 | 13519 | }, |
| 13511 | 13520 | ) !void { |
| ... | ... | @@ -13513,9 +13522,9 @@ fn setDeclaration( |
| 13513 | 13522 | const gpa = astgen.gpa; |
| 13514 | 13523 | |
| 13515 | 13524 | const type_body = args.type_gz.instructionsSliceUpto(args.align_gz); |
| 13516 | | const align_body = args.align_gz.instructionsSliceUpto(args.linksection_gz); |
| 13517 | | const linksection_body = args.linksection_gz.instructionsSliceUpto(args.addrspace_gz); |
| 13518 | | const addrspace_body = args.addrspace_gz.instructionsSliceUpto(args.value_gz); |
| 13525 | const align_body = args.align_gz.instructionsSliceUpto(args.addrspace_gz); |
| 13526 | const addrspace_body = args.addrspace_gz.instructionsSliceUpto(args.linksection_gz); |
| 13527 | const linksection_body = args.linksection_gz.instructionsSliceUpto(args.value_gz); |
| 13519 | 13528 | const value_body = args.value_gz.instructionsSlice(); |
| 13520 | 13529 | |
| 13521 | 13530 | const has_name = args.name != .empty; |