| ... | @@ -227,7 +227,7 @@ pub const DeclGen = struct { | ... | @@ -227,7 +227,7 @@ pub const DeclGen = struct { |
| 227 | /// keep track of the previous block. | 227 | /// keep track of the previous block. |
| 228 | fn beginSpvBlock(self: *DeclGen, label_id: IdResult) !void { | 228 | fn beginSpvBlock(self: *DeclGen, label_id: IdResult) !void { |
| 229 | try self.func.body.emit(self.spv.gpa, .OpLabel, .{ .id_result = label_id }); | 229 | try self.func.body.emit(self.spv.gpa, .OpLabel, .{ .id_result = label_id }); |
| 230 | self.current_block_label_id = label_id.toRef(); | 230 | self.current_block_label_id = label_id; |
| 231 | } | 231 | } |
| 232 | | 232 | |
| 233 | /// SPIR-V requires enabling specific integer sizes through capabilities, and so if they are not enabled, we need | 233 | /// SPIR-V requires enabling specific integer sizes through capabilities, and so if they are not enabled, we need |
| ... | @@ -340,7 +340,7 @@ pub const DeclGen = struct { | ... | @@ -340,7 +340,7 @@ pub const DeclGen = struct { |
| 340 | }; | 340 | }; |
| 341 | const decl = self.module.declPtr(fn_decl_index); | 341 | const decl = self.module.declPtr(fn_decl_index); |
| 342 | self.module.markDeclAlive(decl); | 342 | self.module.markDeclAlive(decl); |
| 343 | return self.ids.get(fn_decl_index).?.toRef(); | 343 | return self.ids.get(fn_decl_index).?; |
| 344 | } | 344 | } |
| 345 | | 345 | |
| 346 | const target = self.getTarget(); | 346 | const target = self.getTarget(); |
| ... | @@ -350,7 +350,7 @@ pub const DeclGen = struct { | ... | @@ -350,7 +350,7 @@ pub const DeclGen = struct { |
| 350 | | 350 | |
| 351 | if (val.isUndef()) { | 351 | if (val.isUndef()) { |
| 352 | try section.emit(self.spv.gpa, .OpUndef, .{ .id_result_type = result_type_id, .id_result = result_id }); | 352 | try section.emit(self.spv.gpa, .OpUndef, .{ .id_result_type = result_type_id, .id_result = result_id }); |
| 353 | return result_id.toRef(); | 353 | return result_id; |
| 354 | } | 354 | } |
| 355 | | 355 | |
| 356 | switch (ty.zigTypeTag()) { | 356 | switch (ty.zigTypeTag()) { |
| ... | @@ -538,7 +538,7 @@ pub const DeclGen = struct { | ... | @@ -538,7 +538,7 @@ pub const DeclGen = struct { |
| 538 | else => return self.todo("constant generation of type {s}: {}", .{ @tagName(ty.zigTypeTag()), ty.fmtDebug() }), | 538 | else => return self.todo("constant generation of type {s}: {}", .{ @tagName(ty.zigTypeTag()), ty.fmtDebug() }), |
| 539 | } | 539 | } |
| 540 | | 540 | |
| 541 | return result_id.toRef(); | 541 | return result_id; |
| 542 | } | 542 | } |
| 543 | | 543 | |
| 544 | /// Turn a Zig type into a SPIR-V Type, and return its type result-id. | 544 | /// Turn a Zig type into a SPIR-V Type, and return its type result-id. |
| ... | @@ -766,7 +766,7 @@ pub const DeclGen = struct { | ... | @@ -766,7 +766,7 @@ pub const DeclGen = struct { |
| 766 | .id_result_type = try self.resolveTypeId(decl.ty.fnReturnType()), | 766 | .id_result_type = try self.resolveTypeId(decl.ty.fnReturnType()), |
| 767 | .id_result = result_id, | 767 | .id_result = result_id, |
| 768 | .function_control = .{}, // TODO: We can set inline here if the type requires it. | 768 | .function_control = .{}, // TODO: We can set inline here if the type requires it. |
| 769 | .function_type = prototype_id.toRef(), | 769 | .function_type = prototype_id, |
| 770 | }); | 770 | }); |
| 771 | | 771 | |
| 772 | const params = decl.ty.fnParamLen(); | 772 | const params = decl.ty.fnParamLen(); |
| ... | @@ -780,7 +780,7 @@ pub const DeclGen = struct { | ... | @@ -780,7 +780,7 @@ pub const DeclGen = struct { |
| 780 | .id_result_type = param_type_id, | 780 | .id_result_type = param_type_id, |
| 781 | .id_result = arg_result_id, | 781 | .id_result = arg_result_id, |
| 782 | }); | 782 | }); |
| 783 | self.args.appendAssumeCapacity(arg_result_id.toRef()); | 783 | self.args.appendAssumeCapacity(arg_result_id); |
| 784 | } | 784 | } |
| 785 | | 785 | |
| 786 | // TODO: This could probably be done in a better way... | 786 | // TODO: This could probably be done in a better way... |
| ... | @@ -791,7 +791,7 @@ pub const DeclGen = struct { | ... | @@ -791,7 +791,7 @@ pub const DeclGen = struct { |
| 791 | try self.func.prologue.emit(self.spv.gpa, .OpLabel, .{ | 791 | try self.func.prologue.emit(self.spv.gpa, .OpLabel, .{ |
| 792 | .id_result = root_block_id, | 792 | .id_result = root_block_id, |
| 793 | }); | 793 | }); |
| 794 | self.current_block_label_id = root_block_id.toRef(); | 794 | self.current_block_label_id = root_block_id; |
| 795 | | 795 | |
| 796 | const main_body = self.air.getMainBody(); | 796 | const main_body = self.air.getMainBody(); |
| 797 | try self.genBody(main_body); | 797 | try self.genBody(main_body); |
| ... | @@ -804,7 +804,7 @@ pub const DeclGen = struct { | ... | @@ -804,7 +804,7 @@ pub const DeclGen = struct { |
| 804 | defer self.module.gpa.free(fqn); | 804 | defer self.module.gpa.free(fqn); |
| 805 | | 805 | |
| 806 | try self.spv.sections.debug_names.emit(self.gpa, .OpName, .{ | 806 | try self.spv.sections.debug_names.emit(self.gpa, .OpName, .{ |
| 807 | .target = result_id.toRef(), | 807 | .target = result_id, |
| 808 | .name = fqn, | 808 | .name = fqn, |
| 809 | }); | 809 | }); |
| 810 | } else { | 810 | } else { |
| ... | @@ -928,7 +928,7 @@ pub const DeclGen = struct { | ... | @@ -928,7 +928,7 @@ pub const DeclGen = struct { |
| 928 | .operand_1 = lhs_id, | 928 | .operand_1 = lhs_id, |
| 929 | .operand_2 = rhs_id, | 929 | .operand_2 = rhs_id, |
| 930 | }); | 930 | }); |
| 931 | return result_id.toRef(); | 931 | return result_id; |
| 932 | } | 932 | } |
| 933 | | 933 | |
| 934 | fn airShift(self: *DeclGen, inst: Air.Inst.Index, comptime opcode: Opcode) !?IdRef { | 934 | fn airShift(self: *DeclGen, inst: Air.Inst.Index, comptime opcode: Opcode) !?IdRef { |
| ... | @@ -951,9 +951,9 @@ pub const DeclGen = struct { | ... | @@ -951,9 +951,9 @@ pub const DeclGen = struct { |
| 951 | .id_result_type = result_type_id, | 951 | .id_result_type = result_type_id, |
| 952 | .id_result = result_id, | 952 | .id_result = result_id, |
| 953 | .base = lhs_id, | 953 | .base = lhs_id, |
| 954 | .shift = shift_id.toRef(), | 954 | .shift = shift_id, |
| 955 | }); | 955 | }); |
| 956 | return result_id.toRef(); | 956 | return result_id; |
| 957 | } | 957 | } |
| 958 | | 958 | |
| 959 | fn maskStrangeInt(self: *DeclGen, ty_id: IdResultType, int_id: IdRef, bits: u16) !IdRef { | 959 | fn maskStrangeInt(self: *DeclGen, ty_id: IdResultType, int_id: IdRef, bits: u16) !IdRef { |
| ... | @@ -976,9 +976,9 @@ pub const DeclGen = struct { | ... | @@ -976,9 +976,9 @@ pub const DeclGen = struct { |
| 976 | .id_result_type = ty_id, | 976 | .id_result_type = ty_id, |
| 977 | .id_result = result_id, | 977 | .id_result = result_id, |
| 978 | .operand_1 = int_id, | 978 | .operand_1 = int_id, |
| 979 | .operand_2 = mask_id.toRef(), | 979 | .operand_2 = mask_id, |
| 980 | }); | 980 | }); |
| 981 | return result_id.toRef(); | 981 | return result_id; |
| 982 | } | 982 | } |
| 983 | | 983 | |
| 984 | fn airArithOp( | 984 | fn airArithOp( |
| ... | @@ -1046,7 +1046,7 @@ pub const DeclGen = struct { | ... | @@ -1046,7 +1046,7 @@ pub const DeclGen = struct { |
| 1046 | // TODO: Trap on overflow? Probably going to be annoying. | 1046 | // TODO: Trap on overflow? Probably going to be annoying. |
| 1047 | // TODO: Look into SPV_KHR_no_integer_wrap_decoration which provides NoSignedWrap/NoUnsignedWrap. | 1047 | // TODO: Look into SPV_KHR_no_integer_wrap_decoration which provides NoSignedWrap/NoUnsignedWrap. |
| 1048 | | 1048 | |
| 1049 | return result_id.toRef(); | 1049 | return result_id; |
| 1050 | } | 1050 | } |
| 1051 | | 1051 | |
| 1052 | fn airOverflowArithOp(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 1052 | fn airOverflowArithOp(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| ... | @@ -1089,7 +1089,7 @@ pub const DeclGen = struct { | ... | @@ -1089,7 +1089,7 @@ pub const DeclGen = struct { |
| 1089 | .operand_1 = lhs, | 1089 | .operand_1 = lhs, |
| 1090 | .operand_2 = rhs, | 1090 | .operand_2 = rhs, |
| 1091 | }); | 1091 | }); |
| 1092 | break :blk result_id.toRef(); | 1092 | break :blk result_id; |
| 1093 | }; | 1093 | }; |
| 1094 | | 1094 | |
| 1095 | // Now convert the SPIR-V flavor result into a Zig-flavor result. | 1095 | // Now convert the SPIR-V flavor result into a Zig-flavor result. |
| ... | @@ -1111,7 +1111,7 @@ pub const DeclGen = struct { | ... | @@ -1111,7 +1111,7 @@ pub const DeclGen = struct { |
| 1111 | .id_result = result_id, | 1111 | .id_result = result_id, |
| 1112 | .unsigned_value = overflow, | 1112 | .unsigned_value = overflow, |
| 1113 | }); | 1113 | }); |
| 1114 | break :blk result_id.toRef(); | 1114 | break :blk result_id; |
| 1115 | }; | 1115 | }; |
| 1116 | | 1116 | |
| 1117 | // TODO: If copying this function for borrow, make sure to convert -1 to 1 as appropriate. | 1117 | // TODO: If copying this function for borrow, make sure to convert -1 to 1 as appropriate. |
| ... | @@ -1127,7 +1127,7 @@ pub const DeclGen = struct { | ... | @@ -1127,7 +1127,7 @@ pub const DeclGen = struct { |
| 1127 | casted_overflow, | 1127 | casted_overflow, |
| 1128 | }, | 1128 | }, |
| 1129 | }); | 1129 | }); |
| 1130 | return result_id.toRef(); | 1130 | return result_id; |
| 1131 | } | 1131 | } |
| 1132 | | 1132 | |
| 1133 | fn airShuffle(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 1133 | fn airShuffle(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| ... | @@ -1163,7 +1163,7 @@ pub const DeclGen = struct { | ... | @@ -1163,7 +1163,7 @@ pub const DeclGen = struct { |
| 1163 | self.func.body.writeOperand(spec.LiteralInteger, unsigned); | 1163 | self.func.body.writeOperand(spec.LiteralInteger, unsigned); |
| 1164 | } | 1164 | } |
| 1165 | } | 1165 | } |
| 1166 | return result_id.toRef(); | 1166 | return result_id; |
| 1167 | } | 1167 | } |
| 1168 | | 1168 | |
| 1169 | fn airCmp(self: *DeclGen, inst: Air.Inst.Index, comptime fop: Opcode, comptime sop: Opcode, comptime uop: Opcode) !?IdRef { | 1169 | fn airCmp(self: *DeclGen, inst: Air.Inst.Index, comptime fop: Opcode, comptime sop: Opcode, comptime uop: Opcode) !?IdRef { |
| ... | @@ -1215,7 +1215,7 @@ pub const DeclGen = struct { | ... | @@ -1215,7 +1215,7 @@ pub const DeclGen = struct { |
| 1215 | else => unreachable, | 1215 | else => unreachable, |
| 1216 | } | 1216 | } |
| 1217 | | 1217 | |
| 1218 | return result_id.toRef(); | 1218 | return result_id; |
| 1219 | } | 1219 | } |
| 1220 | | 1220 | |
| 1221 | fn bitcast(self: *DeclGen, target_type_id: IdResultType, value_id: IdRef) !IdRef { | 1221 | fn bitcast(self: *DeclGen, target_type_id: IdResultType, value_id: IdRef) !IdRef { |
| ... | @@ -1225,7 +1225,7 @@ pub const DeclGen = struct { | ... | @@ -1225,7 +1225,7 @@ pub const DeclGen = struct { |
| 1225 | .id_result = result_id, | 1225 | .id_result = result_id, |
| 1226 | .operand = value_id, | 1226 | .operand = value_id, |
| 1227 | }); | 1227 | }); |
| 1228 | return result_id.toRef(); | 1228 | return result_id; |
| 1229 | } | 1229 | } |
| 1230 | | 1230 | |
| 1231 | fn airBitcast(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 1231 | fn airBitcast(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| ... | @@ -1258,7 +1258,7 @@ pub const DeclGen = struct { | ... | @@ -1258,7 +1258,7 @@ pub const DeclGen = struct { |
| 1258 | .unsigned_value = operand_id, | 1258 | .unsigned_value = operand_id, |
| 1259 | }), | 1259 | }), |
| 1260 | } | 1260 | } |
| 1261 | return result_id.toRef(); | 1261 | return result_id; |
| 1262 | } | 1262 | } |
| 1263 | | 1263 | |
| 1264 | fn airNot(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 1264 | fn airNot(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| ... | @@ -1272,7 +1272,7 @@ pub const DeclGen = struct { | ... | @@ -1272,7 +1272,7 @@ pub const DeclGen = struct { |
| 1272 | .id_result = result_id, | 1272 | .id_result = result_id, |
| 1273 | .operand = operand_id, | 1273 | .operand = operand_id, |
| 1274 | }); | 1274 | }); |
| 1275 | return result_id.toRef(); | 1275 | return result_id; |
| 1276 | } | 1276 | } |
| 1277 | | 1277 | |
| 1278 | fn extractField(self: *DeclGen, result_ty: IdResultType, object: IdRef, field: u32) !IdRef { | 1278 | fn extractField(self: *DeclGen, result_ty: IdResultType, object: IdRef, field: u32) !IdRef { |
| ... | @@ -1283,7 +1283,7 @@ pub const DeclGen = struct { | ... | @@ -1283,7 +1283,7 @@ pub const DeclGen = struct { |
| 1283 | .composite = object, | 1283 | .composite = object, |
| 1284 | .indexes = &.{field}, | 1284 | .indexes = &.{field}, |
| 1285 | }); | 1285 | }); |
| 1286 | return result_id.toRef(); | 1286 | return result_id; |
| 1287 | } | 1287 | } |
| 1288 | | 1288 | |
| 1289 | fn airSliceField(self: *DeclGen, inst: Air.Inst.Index, field: u32) !?IdRef { | 1289 | fn airSliceField(self: *DeclGen, inst: Air.Inst.Index, field: u32) !?IdRef { |
| ... | @@ -1314,7 +1314,7 @@ pub const DeclGen = struct { | ... | @@ -1314,7 +1314,7 @@ pub const DeclGen = struct { |
| 1314 | .composite = slice, | 1314 | .composite = slice, |
| 1315 | .indexes = &.{0}, | 1315 | .indexes = &.{0}, |
| 1316 | }); | 1316 | }); |
| 1317 | break :blk result_id.toRef(); | 1317 | break :blk result_id; |
| 1318 | }; | 1318 | }; |
| 1319 | | 1319 | |
| 1320 | const result_id = self.spv.allocId(); | 1320 | const result_id = self.spv.allocId(); |
| ... | @@ -1324,7 +1324,7 @@ pub const DeclGen = struct { | ... | @@ -1324,7 +1324,7 @@ pub const DeclGen = struct { |
| 1324 | .base = slice_ptr, | 1324 | .base = slice_ptr, |
| 1325 | .indexes = &.{index}, | 1325 | .indexes = &.{index}, |
| 1326 | }); | 1326 | }); |
| 1327 | return result_id.toRef(); | 1327 | return result_id; |
| 1328 | } | 1328 | } |
| 1329 | | 1329 | |
| 1330 | fn airSliceElemVal(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 1330 | fn airSliceElemVal(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| ... | @@ -1347,7 +1347,7 @@ pub const DeclGen = struct { | ... | @@ -1347,7 +1347,7 @@ pub const DeclGen = struct { |
| 1347 | .composite = slice, | 1347 | .composite = slice, |
| 1348 | .indexes = &.{0}, | 1348 | .indexes = &.{0}, |
| 1349 | }); | 1349 | }); |
| 1350 | break :blk result_id.toRef(); | 1350 | break :blk result_id; |
| 1351 | }; | 1351 | }; |
| 1352 | | 1352 | |
| 1353 | const elem_ptr = blk: { | 1353 | const elem_ptr = blk: { |
| ... | @@ -1358,7 +1358,7 @@ pub const DeclGen = struct { | ... | @@ -1358,7 +1358,7 @@ pub const DeclGen = struct { |
| 1358 | .base = slice_ptr, | 1358 | .base = slice_ptr, |
| 1359 | .indexes = &.{index}, | 1359 | .indexes = &.{index}, |
| 1360 | }); | 1360 | }); |
| 1361 | break :blk result_id.toRef(); | 1361 | break :blk result_id; |
| 1362 | }; | 1362 | }; |
| 1363 | | 1363 | |
| 1364 | const result_id = self.spv.allocId(); | 1364 | const result_id = self.spv.allocId(); |
| ... | @@ -1367,7 +1367,7 @@ pub const DeclGen = struct { | ... | @@ -1367,7 +1367,7 @@ pub const DeclGen = struct { |
| 1367 | .id_result = result_id, | 1367 | .id_result = result_id, |
| 1368 | .pointer = elem_ptr, | 1368 | .pointer = elem_ptr, |
| 1369 | }); | 1369 | }); |
| 1370 | return result_id.toRef(); | 1370 | return result_id; |
| 1371 | } | 1371 | } |
| 1372 | | 1372 | |
| 1373 | fn airPtrElemPtr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 1373 | fn airPtrElemPtr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| ... | @@ -1392,7 +1392,7 @@ pub const DeclGen = struct { | ... | @@ -1392,7 +1392,7 @@ pub const DeclGen = struct { |
| 1392 | .base = base_ptr, | 1392 | .base = base_ptr, |
| 1393 | .indexes = &.{rhs}, | 1393 | .indexes = &.{rhs}, |
| 1394 | }); | 1394 | }); |
| 1395 | return result_id.toRef(); | 1395 | return result_id; |
| 1396 | } | 1396 | } |
| 1397 | | 1397 | |
| 1398 | fn airStructFieldVal(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 1398 | fn airStructFieldVal(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| ... | @@ -1418,7 +1418,7 @@ pub const DeclGen = struct { | ... | @@ -1418,7 +1418,7 @@ pub const DeclGen = struct { |
| 1418 | .composite = object, | 1418 | .composite = object, |
| 1419 | .indexes = &.{field_index}, | 1419 | .indexes = &.{field_index}, |
| 1420 | }); | 1420 | }); |
| 1421 | return result_id.toRef(); | 1421 | return result_id; |
| 1422 | } | 1422 | } |
| 1423 | | 1423 | |
| 1424 | fn structFieldPtr( | 1424 | fn structFieldPtr( |
| ... | @@ -1446,9 +1446,9 @@ pub const DeclGen = struct { | ... | @@ -1446,9 +1446,9 @@ pub const DeclGen = struct { |
| 1446 | .id_result_type = result_type_id, | 1446 | .id_result_type = result_type_id, |
| 1447 | .id_result = result_id, | 1447 | .id_result = result_id, |
| 1448 | .base = object_ptr, | 1448 | .base = object_ptr, |
| 1449 | .indexes = &.{field_index_id.toRef()}, | 1449 | .indexes = &.{field_index_id}, |
| 1450 | }); | 1450 | }); |
| 1451 | return result_id.toRef(); | 1451 | return result_id; |
| 1452 | }, | 1452 | }, |
| 1453 | }, | 1453 | }, |
| 1454 | else => unreachable, // TODO | 1454 | else => unreachable, // TODO |
| ... | @@ -1483,7 +1483,7 @@ pub const DeclGen = struct { | ... | @@ -1483,7 +1483,7 @@ pub const DeclGen = struct { |
| 1483 | .id_result = result_id, | 1483 | .id_result = result_id, |
| 1484 | .storage_class = storage_class, | 1484 | .storage_class = storage_class, |
| 1485 | }); | 1485 | }); |
| 1486 | return result_id.toRef(); | 1486 | return result_id; |
| 1487 | } | 1487 | } |
| 1488 | | 1488 | |
| 1489 | fn airArg(self: *DeclGen) IdRef { | 1489 | fn airArg(self: *DeclGen) IdRef { |
| ... | @@ -1503,7 +1503,7 @@ pub const DeclGen = struct { | ... | @@ -1503,7 +1503,7 @@ pub const DeclGen = struct { |
| 1503 | var incoming_blocks = try std.ArrayListUnmanaged(IncomingBlock).initCapacity(self.gpa, 4); | 1503 | var incoming_blocks = try std.ArrayListUnmanaged(IncomingBlock).initCapacity(self.gpa, 4); |
| 1504 | | 1504 | |
| 1505 | try self.blocks.putNoClobber(self.gpa, inst, .{ | 1505 | try self.blocks.putNoClobber(self.gpa, inst, .{ |
| 1506 | .label_id = label_id.toRef(), | 1506 | .label_id = label_id, |
| 1507 | .incoming_blocks = &incoming_blocks, | 1507 | .incoming_blocks = &incoming_blocks, |
| 1508 | }); | 1508 | }); |
| 1509 | defer { | 1509 | defer { |
| ... | @@ -1538,7 +1538,7 @@ pub const DeclGen = struct { | ... | @@ -1538,7 +1538,7 @@ pub const DeclGen = struct { |
| 1538 | self.func.body.writeOperand(spec.PairIdRefIdRef, .{ incoming.break_value_id, incoming.src_label_id }); | 1538 | self.func.body.writeOperand(spec.PairIdRefIdRef, .{ incoming.break_value_id, incoming.src_label_id }); |
| 1539 | } | 1539 | } |
| 1540 | | 1540 | |
| 1541 | return result_id.toRef(); | 1541 | return result_id; |
| 1542 | } | 1542 | } |
| 1543 | | 1543 | |
| 1544 | fn airBr(self: *DeclGen, inst: Air.Inst.Index) !void { | 1544 | fn airBr(self: *DeclGen, inst: Air.Inst.Index) !void { |
| ... | @@ -1571,8 +1571,8 @@ pub const DeclGen = struct { | ... | @@ -1571,8 +1571,8 @@ pub const DeclGen = struct { |
| 1571 | | 1571 | |
| 1572 | try self.func.body.emit(self.spv.gpa, .OpBranchConditional, .{ | 1572 | try self.func.body.emit(self.spv.gpa, .OpBranchConditional, .{ |
| 1573 | .condition = condition_id, | 1573 | .condition = condition_id, |
| 1574 | .true_label = then_label_id.toRef(), | 1574 | .true_label = then_label_id, |
| 1575 | .false_label = else_label_id.toRef(), | 1575 | .false_label = else_label_id, |
| 1576 | }); | 1576 | }); |
| 1577 | | 1577 | |
| 1578 | try self.beginSpvBlock(then_label_id); | 1578 | try self.beginSpvBlock(then_label_id); |
| ... | @@ -1610,7 +1610,7 @@ pub const DeclGen = struct { | ... | @@ -1610,7 +1610,7 @@ pub const DeclGen = struct { |
| 1610 | .memory_access = access, | 1610 | .memory_access = access, |
| 1611 | }); | 1611 | }); |
| 1612 | | 1612 | |
| 1613 | return result_id.toRef(); | 1613 | return result_id; |
| 1614 | } | 1614 | } |
| 1615 | | 1615 | |
| 1616 | fn airLoop(self: *DeclGen, inst: Air.Inst.Index) !void { | 1616 | fn airLoop(self: *DeclGen, inst: Air.Inst.Index) !void { |
| ... | @@ -1620,13 +1620,13 @@ pub const DeclGen = struct { | ... | @@ -1620,13 +1620,13 @@ pub const DeclGen = struct { |
| 1620 | const loop_label_id = self.spv.allocId(); | 1620 | const loop_label_id = self.spv.allocId(); |
| 1621 | | 1621 | |
| 1622 | // Jump to the loop entry point | 1622 | // Jump to the loop entry point |
| 1623 | try self.func.body.emit(self.spv.gpa, .OpBranch, .{ .target_label = loop_label_id.toRef() }); | 1623 | try self.func.body.emit(self.spv.gpa, .OpBranch, .{ .target_label = loop_label_id }); |
| 1624 | | 1624 | |
| 1625 | // TODO: Look into OpLoopMerge. | 1625 | // TODO: Look into OpLoopMerge. |
| 1626 | try self.beginSpvBlock(loop_label_id); | 1626 | try self.beginSpvBlock(loop_label_id); |
| 1627 | try self.genBody(body); | 1627 | try self.genBody(body); |
| 1628 | | 1628 | |
| 1629 | try self.func.body.emit(self.spv.gpa, .OpBranch, .{ .target_label = loop_label_id.toRef() }); | 1629 | try self.func.body.emit(self.spv.gpa, .OpBranch, .{ .target_label = loop_label_id }); |
| 1630 | } | 1630 | } |
| 1631 | | 1631 | |
| 1632 | fn airRet(self: *DeclGen, inst: Air.Inst.Index) !void { | 1632 | fn airRet(self: *DeclGen, inst: Air.Inst.Index) !void { |
| ... | @@ -1658,7 +1658,7 @@ pub const DeclGen = struct { | ... | @@ -1658,7 +1658,7 @@ pub const DeclGen = struct { |
| 1658 | .id_result = result_id, | 1658 | .id_result = result_id, |
| 1659 | .pointer = ptr, | 1659 | .pointer = ptr, |
| 1660 | }); | 1660 | }); |
| 1661 | try self.func.body.emit(self.spv.gpa, .OpReturnValue, .{ .value = result_id.toRef() }); | 1661 | try self.func.body.emit(self.spv.gpa, .OpReturnValue, .{ .value = result_id }); |
| 1662 | } | 1662 | } |
| 1663 | | 1663 | |
| 1664 | fn airStore(self: *DeclGen, inst: Air.Inst.Index) !void { | 1664 | fn airStore(self: *DeclGen, inst: Air.Inst.Index) !void { |
| ... | @@ -1730,7 +1730,7 @@ pub const DeclGen = struct { | ... | @@ -1730,7 +1730,7 @@ pub const DeclGen = struct { |
| 1730 | // Emit the instruction before generating the blocks. | 1730 | // Emit the instruction before generating the blocks. |
| 1731 | try self.func.body.emitRaw(self.spv.gpa, .OpSwitch, 2 + (cond_words + 1) * num_conditions); | 1731 | try self.func.body.emitRaw(self.spv.gpa, .OpSwitch, 2 + (cond_words + 1) * num_conditions); |
| 1732 | self.func.body.writeOperand(IdRef, cond); | 1732 | self.func.body.writeOperand(IdRef, cond); |
| 1733 | self.func.body.writeOperand(IdRef, default.toRef()); | 1733 | self.func.body.writeOperand(IdRef, default); |
| 1734 | | 1734 | |
| 1735 | // Emit each of the cases | 1735 | // Emit each of the cases |
| 1736 | { | 1736 | { |
| ... | @@ -1965,6 +1965,6 @@ pub const DeclGen = struct { | ... | @@ -1965,6 +1965,6 @@ pub const DeclGen = struct { |
| 1965 | return null; | 1965 | return null; |
| 1966 | } | 1966 | } |
| 1967 | | 1967 | |
| 1968 | return result_id.toRef(); | 1968 | return result_id; |
| 1969 | } | 1969 | } |
| 1970 | }; | 1970 | }; |