authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-11-11 00:38:49+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-11-11 14:34:53+01:00
log993eb22a772323bfeef87cf783672c33b6a2cfa2
tree075b7edd4c487f0faa20792c1a01c0471eb8635d
parentf512676d0b4220a5f771110982657140c363a146

stage2 aarch64: add .memory prong in genSetReg


1 files changed, 11 insertions(+), 5 deletions(-)

src/codegen.zig+11-5
......@@ -2572,17 +2572,23 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
25722572 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movz(reg, @truncate(u16, x), 0).toU32());
25732573 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @intCast(u16, x >> 16), 16).toU32());
25742574 } else if (x <= math.maxInt(u32)) {
2575 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movz(reg, @intCast(u16, x), 0).toU32());
2576 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @intCast(u16, x >> 16), 16).toU32());
2575 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movz(reg, @truncate(u16, x), 0).toU32());
2576 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @truncate(u16, x >> 16), 16).toU32());
25772577 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @intCast(u16, x >> 32), 32).toU32());
25782578 } else {
2579 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movz(reg, @intCast(u16, x), 0).toU32());
2580 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @intCast(u16, x >> 16), 16).toU32());
2581 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @intCast(u16, x >> 32), 32).toU32());
2579 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movz(reg, @truncate(u16, x), 0).toU32());
2580 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @truncate(u16, x >> 16), 16).toU32());
2581 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @truncate(u16, x >> 32), 32).toU32());
25822582 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @intCast(u16, x >> 48), 48).toU32());
25832583 }
25842584 },
25852585 .register => return self.fail(src, "TODO implement genSetReg for aarch64 {}", .{mcv}),
2586 .memory => |addr| {
2587 // The value is in memory at a hard-coded address.
2588 // If the type is a pointer, it means the pointer address is at this memory location.
2589 try self.genSetReg(src, reg, .{ .immediate = addr });
2590 mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.ldr(reg, .{ .rn = reg }).toU32());
2591 },
25862592 else => return self.fail(src, "TODO implement genSetReg for aarch64 {}", .{mcv}),
25872593 },
25882594 .riscv64 => switch (mcv) {