| ... | ... | @@ -2575,12 +2575,12 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2575 | 2575 | return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); |
| 2576 | 2576 | }, |
| 2577 | 2577 | .register => |reg| { |
| 2578 | | // TODO: strh |
| 2579 | | const offset = if (stack_offset <= math.maxInt(u12)) blk: { |
| 2580 | | break :blk Instruction.Offset.imm(@intCast(u12, stack_offset)); |
| 2581 | | } else Instruction.Offset.reg(try self.copyToTmpRegister(src, MCValue{ .immediate = stack_offset }), 0); |
| 2582 | | |
| 2583 | 2578 | const abi_size = ty.abiSize(self.target.*); |
| 2579 | const adj_off = stack_offset + abi_size; |
| 2580 | const offset = if (adj_off <= math.maxInt(u12)) blk: { |
| 2581 | break :blk Instruction.Offset.imm(@intCast(u12, adj_off)); |
| 2582 | } else Instruction.Offset.reg(try self.copyToTmpRegister(src, MCValue{ .immediate = adj_off }), 0); |
| 2583 | |
| 2584 | 2584 | switch (abi_size) { |
| 2585 | 2585 | 1 => writeInt(u32, try self.code.addManyAsArray(4), Instruction.strb(.al, reg, .fp, .{ |
| 2586 | 2586 | .offset = offset, |
| ... | ... | @@ -2778,21 +2778,21 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2778 | 2778 | writeInt(u32, try self.code.addManyAsArray(4), Instruction.ldr(.al, reg, reg, .{ .offset = Instruction.Offset.none }).toU32()); |
| 2779 | 2779 | }, |
| 2780 | 2780 | .stack_offset => |unadjusted_off| { |
| 2781 | | // TODO: ldrh |
| 2782 | 2781 | // TODO: maybe addressing from sp instead of fp |
| 2783 | | const offset = if (unadjusted_off <= math.maxInt(u12)) blk: { |
| 2784 | | break :blk Instruction.Offset.imm(@intCast(u12, unadjusted_off)); |
| 2785 | | } else Instruction.Offset.reg(try self.copyToTmpRegister(src, MCValue{ .immediate = unadjusted_off }), 0); |
| 2786 | | |
| 2787 | 2782 | // TODO: supply type information to genSetReg as we do to genSetStack |
| 2788 | 2783 | // const abi_size = ty.abiSize(self.target.*); |
| 2789 | 2784 | const abi_size = 4; |
| 2785 | const adj_off = unadjusted_off + abi_size; |
| 2786 | const offset = if (adj_off <= math.maxInt(u12)) blk: { |
| 2787 | break :blk Instruction.Offset.imm(@intCast(u12, adj_off)); |
| 2788 | } else Instruction.Offset.reg(try self.copyToTmpRegister(src, MCValue{ .immediate = adj_off }), 0); |
| 2789 | |
| 2790 | 2790 | switch (abi_size) { |
| 2791 | 2791 | 1 => writeInt(u32, try self.code.addManyAsArray(4), Instruction.ldrb(.al, reg, .fp, .{ |
| 2792 | 2792 | .offset = offset, |
| 2793 | 2793 | .positive = false, |
| 2794 | 2794 | }).toU32()), |
| 2795 | | 2 => return self.fail(src, "TODO implement strh", .{}), |
| 2795 | 2 => return self.fail(src, "TODO implement ldrh", .{}), |
| 2796 | 2796 | 4 => writeInt(u32, try self.code.addManyAsArray(4), Instruction.ldr(.al, reg, .fp, .{ |
| 2797 | 2797 | .offset = offset, |
| 2798 | 2798 | .positive = false, |