authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-11-08 08:49:03-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-11-08 08:49:34-05:00
loge387d30b26c62c38c7dd3c92657bfed33b993135
tree00d86aaae505d8e8606a8ac8622e31c039d71f67
parent6c15c34421bbecb8eba7abf56e277ec26a4f018c

x86_64: fix signed not of more than 64 bits


1 files changed, 6 insertions(+), 3 deletions(-)

src/arch/x86_64/CodeGen.zig+6-3
...@@ -7433,16 +7433,20 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:...@@ -7433,16 +7433,20 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:
7433 };7433 };
7434 defer if (dst_lock) |lock| self.register_manager.unlockReg(lock);7434 defer if (dst_lock) |lock| self.register_manager.unlockReg(lock);
74357435
7436 const abi_size: u16 = @intCast(src_ty.abiSize(mod));
7436 switch (tag) {7437 switch (tag) {
7437 .not => {7438 .not => {
7438 const limb_abi_size: u16 = @intCast(@min(src_ty.abiSize(mod), 8));7439 const limb_abi_size: u16 = @min(abi_size, 8);
7439 const int_info = if (src_ty.ip_index == .bool_type)7440 const int_info = if (src_ty.ip_index == .bool_type)
7440 std.builtin.Type.Int{ .signedness = .unsigned, .bits = 1 }7441 std.builtin.Type.Int{ .signedness = .unsigned, .bits = 1 }
7441 else7442 else
7442 src_ty.intInfo(mod);7443 src_ty.intInfo(mod);
7443 var byte_off: i32 = 0;7444 var byte_off: i32 = 0;
7444 while (byte_off * 8 < int_info.bits) : (byte_off += limb_abi_size) {7445 while (byte_off * 8 < int_info.bits) : (byte_off += limb_abi_size) {
7445 const limb_bits: u16 = @intCast(@min(int_info.bits - byte_off * 8, limb_abi_size * 8));7446 const limb_bits: u16 = @intCast(@min(switch (int_info.signedness) {
7447 .signed => abi_size * 8,
7448 .unsigned => int_info.bits,
7449 } - byte_off * 8, limb_abi_size * 8));
7446 const limb_ty = try mod.intType(int_info.signedness, limb_bits);7450 const limb_ty = try mod.intType(int_info.signedness, limb_bits);
7447 const limb_mcv = switch (byte_off) {7451 const limb_mcv = switch (byte_off) {
7448 0 => dst_mcv,7452 0 => dst_mcv,
...@@ -7457,7 +7461,6 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:...@@ -7457,7 +7461,6 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:
7457 },7461 },
7458 .neg => {7462 .neg => {
7459 try self.genUnOpMir(.{ ._, .neg }, src_ty, dst_mcv);7463 try self.genUnOpMir(.{ ._, .neg }, src_ty, dst_mcv);
7460 const abi_size: u16 = @intCast(src_ty.abiSize(mod));
7461 const bit_size = src_ty.intInfo(mod).bits;7464 const bit_size = src_ty.intInfo(mod).bits;
7462 if (abi_size * 8 > bit_size) {7465 if (abi_size * 8 > bit_size) {
7463 if (dst_mcv.isRegister()) {7466 if (dst_mcv.isRegister()) {