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...@@ -3180,17 +3180,18 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
3180 // TODO optimize the register allocation3180 // TODO optimize the register allocation
3181 const regs = try self.register_manager.allocRegs(5, .{ null, null, null, null, null }, &.{});3181 const regs = try self.register_manager.allocRegs(5, .{ null, null, null, null, null }, &.{});
3182 const src_reg = regs[0];3182 const src_reg = regs[0];
3183 const dst_reg = regs[2];3183 const dst_reg = regs[1];
3184 const len_reg = regs[2];3184 const len_reg = regs[2];
3185 const count_reg = regs[3];3185 const count_reg = regs[3];
3186 const tmp_reg = regs[4];3186 const tmp_reg = regs[4];
31873187
3188 // add src_reg, fp, #off3188 // sub src_reg, fp, #off
3189 const src_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(off)) |x| x else {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 {
3190 return self.fail("TODO load: set reg to stack offset with all possible offsets", .{});3191 return self.fail("TODO load: set reg to stack offset with all possible offsets", .{});
3191 };3192 };
3192 _ = try self.addInst(.{3193 _ = try self.addInst(.{
3193 .tag = .add,3194 .tag = .sub,
3194 .cond = .al,3195 .cond = .al,
3195 .data = .{ .rr_op = .{3196 .data = .{ .rr_op = .{
3196 .rd = src_reg,3197 .rd = src_reg,
...@@ -3200,8 +3201,8 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro...@@ -3200,8 +3201,8 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
3200 });3201 });
32013202
3202 // sub dst_reg, fp, #stack_offset3203 // sub dst_reg, fp, #stack_offset
3203 const adj_stack_offset = stack_offset + @intCast(u32, ty.abiSize(self.target.*));3204 const adj_dst_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 {3205 const dst_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(adj_dst_offset)) |x| x else {
3205 return self.fail("TODO load: set reg to stack offset with all possible offsets", .{});3206 return self.fail("TODO load: set reg to stack offset with all possible offsets", .{});
3206 };3207 };
3207 _ = try self.addInst(.{3208 _ = try self.addInst(.{
src/codegen.zig+8
...@@ -400,6 +400,14 @@ pub fn generateSymbol(...@@ -400,6 +400,14 @@ pub fn generateSymbol(
400400
401 return Result{ .appended = {} };401 return Result{ .appended = {} };
402 },402 },
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 },
403 else => |t| {411 else => |t| {
404 return Result{412 return Result{
405 .fail = try ErrorMsg.create(413 .fail = try ErrorMsg.create(