| ... | @@ -1317,8 +1317,37 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo | ... | @@ -1317,8 +1317,37 @@ fn load(self: *Self, dst_mcv: MCValue, ptr: MCValue, ptr_ty: Type) InnerError!vo |
| 1317 | .stack_offset => |off| { | 1317 | .stack_offset => |off| { |
| 1318 | if (elem_ty.abiSize(self.target.*) <= 4) { | 1318 | if (elem_ty.abiSize(self.target.*) <= 4) { |
| 1319 | const tmp_reg = try self.register_manager.allocReg(null, &.{}); | 1319 | const tmp_reg = try self.register_manager.allocReg(null, &.{}); |
| 1320 | try self.load(.{ .register = tmp_reg }, ptr, elem_ty); | 1320 | try self.load(.{ .register = tmp_reg }, ptr, ptr_ty); |
| 1321 | return self.genSetStack(elem_ty, off, MCValue{ .register = tmp_reg }); | 1321 | try self.genSetStack(elem_ty, off, MCValue{ .register = tmp_reg }); |
| | 1322 | } else if (elem_ty.abiSize(self.target.*) == 8) { |
| | 1323 | // TODO generalize this: maybe add a |
| | 1324 | // genArmMemcpy function which manually copies |
| | 1325 | // data if the size is below a certain |
| | 1326 | // threshold and calls "memcpy" if the size is |
| | 1327 | // larger |
| | 1328 | |
| | 1329 | const usize_ty = Type.initTag(.usize); |
| | 1330 | const tmp_regs = try self.register_manager.allocRegs(2, .{ null, null }, &.{}); |
| | 1331 | _ = try self.addInst(.{ |
| | 1332 | .tag = .ldr, |
| | 1333 | .cond = .al, |
| | 1334 | .data = .{ .rr_offset = .{ |
| | 1335 | .rt = tmp_regs[0], |
| | 1336 | .rn = reg, |
| | 1337 | .offset = .{ .offset = Instruction.Offset.none }, |
| | 1338 | } }, |
| | 1339 | }); |
| | 1340 | _ = try self.addInst(.{ |
| | 1341 | .tag = .ldr, |
| | 1342 | .cond = .al, |
| | 1343 | .data = .{ .rr_offset = .{ |
| | 1344 | .rt = tmp_regs[1], |
| | 1345 | .rn = reg, |
| | 1346 | .offset = .{ .offset = Instruction.Offset.imm(4) }, |
| | 1347 | } }, |
| | 1348 | }); |
| | 1349 | try self.genSetStack(usize_ty, off, MCValue{ .register = tmp_regs[0] }); |
| | 1350 | try self.genSetStack(usize_ty, off + 4, MCValue{ .register = tmp_regs[1] }); |
| 1322 | } else { | 1351 | } else { |
| 1323 | return self.fail("TODO implement memcpy", .{}); | 1352 | return self.fail("TODO implement memcpy", .{}); |
| 1324 | } | 1353 | } |