mirror of
https://github.com/ziglang/zig.git
synced 2025-12-23 14:43:17 +00:00
stage2 codegen: Add generateSymbol for optional stub
This commit is contained in:
parent
845531dde1
commit
a722e1fc0b
@ -3180,17 +3180,18 @@ fn genSetStack(self: *Self, ty: Type, stack_offset: u32, mcv: MCValue) InnerErro
|
|||||||
// TODO optimize the register allocation
|
// TODO optimize the register allocation
|
||||||
const regs = try self.register_manager.allocRegs(5, .{ null, null, null, null, null }, &.{});
|
const regs = try self.register_manager.allocRegs(5, .{ null, null, null, null, null }, &.{});
|
||||||
const src_reg = regs[0];
|
const src_reg = regs[0];
|
||||||
const dst_reg = regs[2];
|
const dst_reg = regs[1];
|
||||||
const len_reg = regs[2];
|
const len_reg = regs[2];
|
||||||
const count_reg = regs[3];
|
const count_reg = regs[3];
|
||||||
const tmp_reg = regs[4];
|
const tmp_reg = regs[4];
|
||||||
|
|
||||||
// add src_reg, fp, #off
|
// sub src_reg, fp, #off
|
||||||
const src_offset_op: Instruction.Operand = if (Instruction.Operand.fromU32(off)) |x| x else {
|
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", .{});
|
return self.fail("TODO load: set reg to stack offset with all possible offsets", .{});
|
||||||
};
|
};
|
||||||
_ = try self.addInst(.{
|
_ = try self.addInst(.{
|
||||||
.tag = .add,
|
.tag = .sub,
|
||||||
.cond = .al,
|
.cond = .al,
|
||||||
.data = .{ .rr_op = .{
|
.data = .{ .rr_op = .{
|
||||||
.rd = src_reg,
|
.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
|
// sub dst_reg, fp, #stack_offset
|
||||||
const adj_stack_offset = stack_offset + @intCast(u32, ty.abiSize(self.target.*));
|
const adj_dst_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 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", .{});
|
return self.fail("TODO load: set reg to stack offset with all possible offsets", .{});
|
||||||
};
|
};
|
||||||
_ = try self.addInst(.{
|
_ = try self.addInst(.{
|
||||||
|
|||||||
@ -400,6 +400,14 @@ pub fn generateSymbol(
|
|||||||
|
|
||||||
return Result{ .appended = {} };
|
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| {
|
else => |t| {
|
||||||
return Result{
|
return Result{
|
||||||
.fail = try ErrorMsg.create(
|
.fail = try ErrorMsg.create(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user