authorgravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2022-01-01 12:51:29+01:00
committergravatar for joachim.schmidt557@outlook.comJoachim Schmidt <joachim.schmidt557@outlook.com> 2022-01-01 12:51:29+01:00
loga722e1fc0bcbae55c6a143ece9f20db8a3212818
tree1674451e2675c0405943438222c0cab9612a6c6f
parent845531dde10d215dc23956e2dc8a9a78125712a8
signaturelock-open Commit is signed but in an unrecognized format.

stage2 codegen: Add generateSymbol for optional stub


2 files changed, 15 insertions(+), 6 deletions(-)

src/arch/arm/CodeGen.zig+7-6
......@@ -3180,17 +3180,18 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
31803180 // TODO optimize the register allocation
31813181 const regs = try self.register_manager.allocRegs(5, .{ null, null, null, null, null }, &.{});
31823182 const src_reg = regs[0];
3183 const dst_reg = regs[2];
3183 const dst_reg = regs[1];
31843184 const len_reg = regs[2];
31853185 const count_reg = regs[3];
31863186 const tmp_reg = regs[4];
31873187
3188 // add src_reg, fp, #off
3189 const src_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(off)) |x| x else {
3188 // sub src_reg, fp, #off
3189 const adj_src_offset = off + @intCast(u32, ty.abiSize(self.target.*));
3190 const src_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(adj_src_offset)) |x| x else {
31903191 return self.fail("TODO load: set reg to stack offset with all possible offsets", .{});
31913192 };
31923193 _ = try self.addInst(.{
3193 .tag = .add,
3194 .tag = .sub,
31943195 .cond = .al,
31953196 .data = .{ .rr_op = .{
31963197 .rd = src_reg,
......@@ -3200,8 +3201,8 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
32003201 });
32013202
32023203 // sub dst_reg, fp, #stack_offset
3203 const adj_stack_offset = stack_offset + @intCast(u32, ty.abiSize(self.target.*));
3204 const dst_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(adj_stack_offset)) |x| x else {
3204 const adj_dst_offset = stack_offset + @intCast(u32, ty.abiSize(self.target.*));
3205 const dst_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(adj_dst_offset)) |x| x else {
32053206 return self.fail("TODO load: set reg to stack offset with all possible offsets", .{});
32063207 };
32073208 _ = try self.addInst(.{
src/codegen.zig+8
......@@ -400,6 +400,14 @@ pub fn generateSymbol(
400400
401401 return Result{ .appended = {} };
402402 },
403 .Optional => {
404 // TODO generateSymbol for optionals
405 const target = bin_file.options.target;
406 const abi_size = try math.cast(usize, typed_value.ty.abiSize(target));
407 try code.writer().writeByteNTimes(0xaa, abi_size);
408
409 return Result{ .appended = {} };
410 },
403411 else => |t| {
404412 return Result{
405413 .fail = try ErrorMsg.create(