From 25ec2dbc1e2302d1138749262b588d3e438fcd55 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Sat, 17 Oct 2020 18:04:53 -0600 Subject: Add builtin.Signedness, use it instead of is_signed --- src/Module.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index 81dc72e601..7ef32abcc3 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -2633,7 +2633,7 @@ pub fn cmpNumeric( dest_float_type = lhs.ty; } else { const int_info = lhs.ty.intInfo(self.getTarget()); - lhs_bits = int_info.bits + @boolToInt(!int_info.signed and dest_int_is_signed); + lhs_bits = int_info.bits + @boolToInt(int_info.signedness == .unsigned and dest_int_is_signed); } var rhs_bits: usize = undefined; @@ -2668,7 +2668,7 @@ pub fn cmpNumeric( dest_float_type = rhs.ty; } else { const int_info = rhs.ty.intInfo(self.getTarget()); - rhs_bits = int_info.bits + @boolToInt(!int_info.signed and dest_int_is_signed); + rhs_bits = int_info.bits + @boolToInt(int_info.signedness == .unsigned and dest_int_is_signed); } const dest_type = if (dest_float_type) |ft| ft else blk: { @@ -2817,9 +2817,9 @@ pub fn coerce(self: *Module, scope: *Scope, dest_type: Type, inst: *Inst) !*Inst const src_info = inst.ty.intInfo(self.getTarget()); const dst_info = dest_type.intInfo(self.getTarget()); - if ((src_info.signed == dst_info.signed and dst_info.bits >= src_info.bits) or + if ((src_info.signedness == dst_info.signedness and dst_info.bits >= src_info.bits) or // small enough unsigned ints can get casted to large enough signed ints - (src_info.signed and !dst_info.signed and dst_info.bits > src_info.bits)) + (src_info.signedness == .signed and dst_info.signedness == .unsigned and dst_info.bits > src_info.bits)) { const b = try self.requireRuntimeBlock(scope, inst.src); return self.addUnOp(b, inst.src, dest_type, .intcast, inst); -- cgit v1.2.3