| ... | @@ -1957,6 +1957,7 @@ const DeclGen = struct { | ... | @@ -1957,6 +1957,7 @@ const DeclGen = struct { |
| 1957 | .int_from_ptr => try self.airIntFromPtr(inst), | 1957 | .int_from_ptr => try self.airIntFromPtr(inst), |
| 1958 | .float_from_int => try self.airFloatFromInt(inst), | 1958 | .float_from_int => try self.airFloatFromInt(inst), |
| 1959 | .int_from_float => try self.airIntFromFloat(inst), | 1959 | .int_from_float => try self.airIntFromFloat(inst), |
| | 1960 | .fpext, .fptrunc => try self.airFloatCast(inst), |
| 1960 | .not => try self.airNot(inst), | 1961 | .not => try self.airNot(inst), |
| 1961 | | 1962 | |
| 1962 | .array_to_slice => try self.airArrayToSlice(inst), | 1963 | .array_to_slice => try self.airArrayToSlice(inst), |
| ... | @@ -2685,6 +2686,23 @@ const DeclGen = struct { | ... | @@ -2685,6 +2686,23 @@ const DeclGen = struct { |
| 2685 | return result_id; | 2686 | return result_id; |
| 2686 | } | 2687 | } |
| 2687 | | 2688 | |
| | 2689 | fn airFloatCast(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| | 2690 | if (self.liveness.isUnused(inst)) return null; |
| | 2691 | |
| | 2692 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| | 2693 | const operand_id = try self.resolve(ty_op.operand); |
| | 2694 | const dest_ty = self.typeOfIndex(inst); |
| | 2695 | const dest_ty_id = try self.resolveTypeId(dest_ty); |
| | 2696 | |
| | 2697 | const result_id = self.spv.allocId(); |
| | 2698 | try self.func.body.emit(self.spv.gpa, .OpFConvert, .{ |
| | 2699 | .id_result_type = dest_ty_id, |
| | 2700 | .id_result = result_id, |
| | 2701 | .float_value = operand_id, |
| | 2702 | }); |
| | 2703 | return result_id; |
| | 2704 | } |
| | 2705 | |
| 2688 | fn airNot(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 2706 | fn airNot(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2689 | if (self.liveness.isUnused(inst)) return null; | 2707 | if (self.liveness.isUnused(inst)) return null; |
| 2690 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | 2708 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |