| ... | ... | @@ -2572,17 +2572,23 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2572 | 2572 | mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movz(reg, @truncate(u16, x), 0).toU32()); |
| 2573 | 2573 | mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @intCast(u16, x >> 16), 16).toU32()); |
| 2574 | 2574 | } 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()); |
| 2577 | 2577 | mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @intCast(u16, x >> 32), 32).toU32()); |
| 2578 | 2578 | } 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()); |
| 2582 | 2582 | mem.writeIntLittle(u32, try self.code.addManyAsArray(4), Instruction.movk(reg, @intCast(u16, x >> 48), 48).toU32()); |
| 2583 | 2583 | } |
| 2584 | 2584 | }, |
| 2585 | 2585 | .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 | }, |
| 2586 | 2592 | else => return self.fail(src, "TODO implement genSetReg for aarch64 {}", .{mcv}), |
| 2587 | 2593 | }, |
| 2588 | 2594 | .riscv64 => switch (mcv) { |