| ... | @@ -1724,6 +1724,7 @@ pub const DeclGen = struct { | ... | @@ -1724,6 +1724,7 @@ pub const DeclGen = struct { |
| 1724 | | 1724 | |
| 1725 | .bitcast => try self.airBitcast(inst), | 1725 | .bitcast => try self.airBitcast(inst), |
| 1726 | .intcast, .trunc => try self.airIntcast(inst), | 1726 | .intcast, .trunc => try self.airIntcast(inst), |
| | 1727 | .ptrtoint => try self.airPtrToInt(inst), |
| 1727 | .int_to_float => try self.airIntToFloat(inst), | 1728 | .int_to_float => try self.airIntToFloat(inst), |
| 1728 | .float_to_int => try self.airFloatToInt(inst), | 1729 | .float_to_int => try self.airFloatToInt(inst), |
| 1729 | .not => try self.airNot(inst), | 1730 | .not => try self.airNot(inst), |
| ... | @@ -1786,10 +1787,12 @@ pub const DeclGen = struct { | ... | @@ -1786,10 +1787,12 @@ pub const DeclGen = struct { |
| 1786 | .call_never_tail => try self.airCall(inst, .never_tail), | 1787 | .call_never_tail => try self.airCall(inst, .never_tail), |
| 1787 | .call_never_inline => try self.airCall(inst, .never_inline), | 1788 | .call_never_inline => try self.airCall(inst, .never_inline), |
| 1788 | | 1789 | |
| 1789 | .dbg_var_ptr => return, | 1790 | .dbg_inline_begin => return, |
| 1790 | .dbg_var_val => return, | 1791 | .dbg_inline_end => return, |
| 1791 | .dbg_block_begin => return, | 1792 | .dbg_var_ptr => return, |
| 1792 | .dbg_block_end => return, | 1793 | .dbg_var_val => return, |
| | 1794 | .dbg_block_begin => return, |
| | 1795 | .dbg_block_end => return, |
| 1793 | // zig fmt: on | 1796 | // zig fmt: on |
| 1794 | | 1797 | |
| 1795 | else => |tag| return self.todo("implement AIR tag {s}", .{@tagName(tag)}), | 1798 | else => |tag| return self.todo("implement AIR tag {s}", .{@tagName(tag)}), |
| ... | @@ -2131,6 +2134,22 @@ pub const DeclGen = struct { | ... | @@ -2131,6 +2134,22 @@ pub const DeclGen = struct { |
| 2131 | return result_id; | 2134 | return result_id; |
| 2132 | } | 2135 | } |
| 2133 | | 2136 | |
| | 2137 | fn airPtrToInt(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| | 2138 | if (self.liveness.isUnused(inst)) return null; |
| | 2139 | |
| | 2140 | const un_op = self.air.instructions.items(.data)[inst].un_op; |
| | 2141 | const operand_id = try self.resolve(un_op); |
| | 2142 | const result_type_id = try self.resolveTypeId(Type.usize); |
| | 2143 | |
| | 2144 | const result_id = self.spv.allocId(); |
| | 2145 | try self.func.body.emit(self.spv.gpa, .OpConvertPtrToU, .{ |
| | 2146 | .id_result_type = result_type_id, |
| | 2147 | .id_result = result_id, |
| | 2148 | .pointer = operand_id, |
| | 2149 | }); |
| | 2150 | return result_id; |
| | 2151 | } |
| | 2152 | |
| 2134 | fn airIntToFloat(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 2153 | fn airIntToFloat(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2135 | if (self.liveness.isUnused(inst)) return null; | 2154 | if (self.liveness.isUnused(inst)) return null; |
| 2136 | | 2155 | |