aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arch/arm/CodeGen.zig13
-rw-r--r--src/codegen.zig8
2 files changed, 15 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(.{
diff --git a/src/codegen.zig b/src/codegen.zig
index fdbdb7d5c1..9de13ee657 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -400,6 +400,14 @@ pub fn generateSymbol(
return Result{ .appended = {} };
},
+ .Optional => {
+ // TODO generateSymbol for optionals
+ const target = bin_file.options.target;
+ const abi_size = try math.cast(usize, typed_value.ty.abiSize(target));
+ try code.writer().writeByteNTimes(0xaa, abi_size);
+
+ return Result{ .appended = {} };
+ },
else => |t| {
return Result{
.fail = try ErrorMsg.create(