| ... | ... | @@ -372,7 +372,8 @@ pub const DeclGen = struct { |
| 372 | 372 | // As of yet, there is no vector support in the self-hosted compiler. |
| 373 | 373 | .Vector => self.todo("implement arithmeticTypeInfo for Vector", .{}), |
| 374 | 374 | // TODO: For which types is this the case? |
| 375 | | else => self.todo("implement arithmeticTypeInfo for {}", .{ty.fmt(self.module)}), |
| 375 | // else => self.todo("implement arithmeticTypeInfo for {}", .{ty.fmt(self.module)}), |
| 376 | else => unreachable, |
| 376 | 377 | }; |
| 377 | 378 | } |
| 378 | 379 | |
| ... | ... | @@ -1712,7 +1713,7 @@ pub const DeclGen = struct { |
| 1712 | 1713 | .shl => try self.airShift(inst, .OpShiftLeftLogical), |
| 1713 | 1714 | |
| 1714 | 1715 | .bitcast => try self.airBitcast(inst), |
| 1715 | | .intcast, .trunc => try self.airIntcast(inst), |
| 1716 | .intcast, .trunc => try self.airIntCast(inst), |
| 1716 | 1717 | .ptrtoint => try self.airPtrToInt(inst), |
| 1717 | 1718 | .int_to_float => try self.airIntToFloat(inst), |
| 1718 | 1719 | .float_to_int => try self.airFloatToInt(inst), |
| ... | ... | @@ -2162,15 +2163,19 @@ pub const DeclGen = struct { |
| 2162 | 2163 | return try self.bitcast(result_type_id, operand_id); |
| 2163 | 2164 | } |
| 2164 | 2165 | |
| 2165 | | fn airIntcast(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2166 | fn airIntCast(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2166 | 2167 | if (self.liveness.isUnused(inst)) return null; |
| 2167 | 2168 | |
| 2168 | 2169 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 2169 | 2170 | const operand_id = try self.resolve(ty_op.operand); |
| 2170 | 2171 | const dest_ty = self.air.typeOfIndex(inst); |
| 2171 | | const dest_info = try self.arithmeticTypeInfo(dest_ty); |
| 2172 | 2172 | const dest_ty_id = try self.resolveTypeId(dest_ty); |
| 2173 | 2173 | |
| 2174 | const target = self.getTarget(); |
| 2175 | const dest_info = dest_ty.intInfo(target); |
| 2176 | |
| 2177 | // TODO: Masking? |
| 2178 | |
| 2174 | 2179 | const result_id = self.spv.allocId(); |
| 2175 | 2180 | switch (dest_info.signedness) { |
| 2176 | 2181 | .signed => try self.func.body.emit(self.spv.gpa, .OpSConvert, .{ |