diff options
| author | joachimschmidt557 <joachim.schmidt557@outlook.com> | 2022-01-01 12:51:29 +0100 |
|---|---|---|
| committer | joachimschmidt557 <joachim.schmidt557@outlook.com> | 2022-01-01 12:51:29 +0100 |
| commit | a722e1fc0bcbae55c6a143ece9f20db8a3212818 (patch) | |
| tree | 1674451e2675c0405943438222c0cab9612a6c6f /src/arch | |
| parent | 845531dde10d215dc23956e2dc8a9a78125712a8 (diff) | |
| download | zig-a722e1fc0bcbae55c6a143ece9f20db8a3212818.tar.gz zig-a722e1fc0bcbae55c6a143ece9f20db8a3212818.zip | |
stage2 codegen: Add generateSymbol for optional stub
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/arm/CodeGen.zig | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/arch/arm/CodeGen.zig b/src/arch/arm/CodeGen.zig index d1c7c7ecf0..e90c0ad5e4 100644 --- a/src/arch/arm/CodeGen.zig +++ b/src/arch/arm/CodeGen.zig @@ -3180,17 +3180,18 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro // TODO optimize the register allocation const regs = try self.register_manager.allocRegs(5, .{ null, null, null, null, null }, &.{}); const src_reg = regs[0]; - const dst_reg = regs[2]; + const dst_reg = regs[1]; const len_reg = regs[2]; const count_reg = regs[3]; const tmp_reg = regs[4]; - // add src_reg, fp, #off - const src_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(off)) |x| x else { + // sub src_reg, fp, #off + const adj_src_offset = off + @intCast(u32, ty.abiSize(self.target.*)); + const src_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(adj_src_offset)) |x| x else { return self.fail("TODO load: set reg to stack offset with all possible offsets", .{}); }; _ = try self.addInst(.{ - .tag = .add, + .tag = .sub, .cond = .al, .data = .{ .rr_op = .{ .rd = src_reg, @@ -3200,8 +3201,8 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro }); // sub dst_reg, fp, #stack_offset - const adj_stack_offset = stack_offset + @intCast(u32, ty.abiSize(self.target.*)); - const dst_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(adj_stack_offset)) |x| x else { + const adj_dst_offset = stack_offset + @intCast(u32, ty.abiSize(self.target.*)); + const dst_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(adj_dst_offset)) |x| x else { return self.fail("TODO load: set reg to stack offset with all possible offsets", .{}); }; _ = try self.addInst(.{ |
