| ... | @@ -708,7 +708,7 @@ pub const DeclGen = struct { | ... | @@ -708,7 +708,7 @@ pub const DeclGen = struct { |
| 708 | const elem_ty = array_type.child.toType(); | 708 | const elem_ty = array_type.child.toType(); |
| 709 | const elem_ty_ref = try self.resolveType(elem_ty, .indirect); | 709 | const elem_ty_ref = try self.resolveType(elem_ty, .indirect); |
| 710 | | 710 | |
| 711 | const constituents = try self.gpa.alloc(IdRef, ty.arrayLenIncludingSentinel(mod)); | 711 | const constituents = try self.gpa.alloc(IdRef, @as(u32, @intCast(ty.arrayLenIncludingSentinel(mod)))); |
| 712 | defer self.gpa.free(constituents); | 712 | defer self.gpa.free(constituents); |
| 713 | | 713 | |
| 714 | switch (aggregate.storage) { | 714 | switch (aggregate.storage) { |
| ... | @@ -1289,19 +1289,19 @@ pub const DeclGen = struct { | ... | @@ -1289,19 +1289,19 @@ pub const DeclGen = struct { |
| 1289 | } | 1289 | } |
| 1290 | | 1290 | |
| 1291 | const UnionLayout = struct { | 1291 | const UnionLayout = struct { |
| 1292 | active_field: usize, | 1292 | active_field: u32, |
| 1293 | active_field_ty: Type, | 1293 | active_field_ty: Type, |
| 1294 | payload_size: usize, | 1294 | payload_size: u32, |
| 1295 | | 1295 | |
| 1296 | tag_size: usize, | 1296 | tag_size: u32, |
| 1297 | tag_index: usize, | 1297 | tag_index: u32, |
| 1298 | active_field_size: usize, | 1298 | active_field_size: u32, |
| 1299 | active_field_index: usize, | 1299 | active_field_index: u32, |
| 1300 | payload_padding_size: usize, | 1300 | payload_padding_size: u32, |
| 1301 | payload_padding_index: usize, | 1301 | payload_padding_index: u32, |
| 1302 | padding_size: usize, | 1302 | padding_size: u32, |
| 1303 | padding_index: usize, | 1303 | padding_index: u32, |
| 1304 | total_fields: usize, | 1304 | total_fields: u32, |
| 1305 | }; | 1305 | }; |
| 1306 | | 1306 | |
| 1307 | fn unionLayout(self: *DeclGen, ty: Type, maybe_active_field: ?usize) UnionLayout { | 1307 | fn unionLayout(self: *DeclGen, ty: Type, maybe_active_field: ?usize) UnionLayout { |
| ... | @@ -1314,28 +1314,28 @@ pub const DeclGen = struct { | ... | @@ -1314,28 +1314,28 @@ pub const DeclGen = struct { |
| 1314 | const active_field_ty = union_obj.field_types.get(ip)[active_field].toType(); | 1314 | const active_field_ty = union_obj.field_types.get(ip)[active_field].toType(); |
| 1315 | | 1315 | |
| 1316 | var union_layout = UnionLayout{ | 1316 | var union_layout = UnionLayout{ |
| 1317 | .active_field = active_field, | 1317 | .active_field = @intCast(active_field), |
| 1318 | .active_field_ty = active_field_ty, | 1318 | .active_field_ty = active_field_ty, |
| 1319 | .payload_size = layout.payload_size, | 1319 | .payload_size = @intCast(layout.payload_size), |
| 1320 | .tag_size = layout.tag_size, | 1320 | .tag_size = @intCast(layout.tag_size), |
| 1321 | .tag_index = undefined, | 1321 | .tag_index = undefined, |
| 1322 | .active_field_size = undefined, | 1322 | .active_field_size = undefined, |
| 1323 | .active_field_index = undefined, | 1323 | .active_field_index = undefined, |
| 1324 | .payload_padding_size = undefined, | 1324 | .payload_padding_size = undefined, |
| 1325 | .payload_padding_index = undefined, | 1325 | .payload_padding_index = undefined, |
| 1326 | .padding_size = layout.padding, | 1326 | .padding_size = @intCast(layout.padding), |
| 1327 | .padding_index = undefined, | 1327 | .padding_index = undefined, |
| 1328 | .total_fields = undefined, | 1328 | .total_fields = undefined, |
| 1329 | }; | 1329 | }; |
| 1330 | | 1330 | |
| 1331 | union_layout.active_field_size = if (active_field_ty.hasRuntimeBitsIgnoreComptime(mod)) | 1331 | union_layout.active_field_size = if (active_field_ty.hasRuntimeBitsIgnoreComptime(mod)) |
| 1332 | active_field_ty.abiSize(mod) | 1332 | @intCast(active_field_ty.abiSize(mod)) |
| 1333 | else | 1333 | else |
| 1334 | 0; | 1334 | 0; |
| 1335 | union_layout.payload_padding_size = layout.payload_size - union_layout.active_field_size; | 1335 | union_layout.payload_padding_size = @intCast(layout.payload_size - union_layout.active_field_size); |
| 1336 | | 1336 | |
| 1337 | const tag_first = layout.tag_align.compare(.gte, layout.payload_align); | 1337 | const tag_first = layout.tag_align.compare(.gte, layout.payload_align); |
| 1338 | var field_index: usize = 0; | 1338 | var field_index: u32 = 0; |
| 1339 | | 1339 | |
| 1340 | if (union_layout.tag_size != 0 and tag_first) { | 1340 | if (union_layout.tag_size != 0 and tag_first) { |
| 1341 | union_layout.tag_index = field_index; | 1341 | union_layout.tag_index = field_index; |
| ... | @@ -1534,6 +1534,7 @@ pub const DeclGen = struct { | ... | @@ -1534,6 +1534,7 @@ pub const DeclGen = struct { |
| 1534 | .id_result = decl_id, | 1534 | .id_result = decl_id, |
| 1535 | .storage_class = actual_storage_class, | 1535 | .storage_class = actual_storage_class, |
| 1536 | }); | 1536 | }); |
| | 1537 | self.spv.globalPtr(spv_decl_index).?.result_id = decl_id; |
| 1537 | | 1538 | |
| 1538 | // Now emit the instructions that initialize the variable. | 1539 | // Now emit the instructions that initialize the variable. |
| 1539 | const initializer_id = self.spv.allocId(); | 1540 | const initializer_id = self.spv.allocId(); |