| ... | ... | @@ -5671,13 +5671,31 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void { |
| 5671 | 5671 | } |
| 5672 | 5672 | |
| 5673 | 5673 | fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void { |
| 5674 | | const vector_ty = self.air.typeOfIndex(inst); |
| 5675 | | const len = vector_ty.vectorLen(); |
| 5674 | const result_ty = self.air.typeOfIndex(inst); |
| 5675 | const len = result_ty.vectorLen(); |
| 5676 | 5676 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| 5677 | 5677 | const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]); |
| 5678 | const abi_size = @intCast(u32, result_ty.abiSize(self.target.*)); |
| 5679 | const abi_align = result_ty.abiAlignment(self.target.*); |
| 5678 | 5680 | const result: MCValue = res: { |
| 5679 | 5681 | if (self.liveness.isUnused(inst)) break :res MCValue.dead; |
| 5680 | | return self.fail("TODO implement airAggregateInit for x86_64", .{}); |
| 5682 | switch (result_ty.zigTypeTag()) { |
| 5683 | .Struct => { |
| 5684 | const stack_offset = @intCast(i32, try self.allocMem(inst, abi_size, abi_align)); |
| 5685 | for (elements) |elem, elem_i| { |
| 5686 | if (result_ty.structFieldValueComptime(elem_i) != null) continue; // comptime elem |
| 5687 | |
| 5688 | const elem_ty = result_ty.structFieldType(elem_i); |
| 5689 | const elem_off = result_ty.structFieldOffset(elem_i, self.target.*); |
| 5690 | const elem_mcv = try self.resolveInst(elem); |
| 5691 | try self.genSetStack(elem_ty, stack_offset - @intCast(i32, elem_off), elem_mcv, .{}); |
| 5692 | } |
| 5693 | break :res MCValue{ .stack_offset = stack_offset }; |
| 5694 | }, |
| 5695 | .Array => return self.fail("TODO implement aggregate_init for arrays", .{}), |
| 5696 | .Vector => return self.fail("TODO implement aggregate_init for vectors", .{}), |
| 5697 | else => unreachable, |
| 5698 | } |
| 5681 | 5699 | }; |
| 5682 | 5700 | |
| 5683 | 5701 | if (elements.len <= Liveness.bpi - 1) { |