| ... | ... | @@ -28,19 +28,20 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class { |
| 28 | 28 | if (!ty.hasRuntimeBitsIgnoreComptime(mod)) return none; |
| 29 | 29 | switch (ty.zigTypeTag(mod)) { |
| 30 | 30 | .Struct => { |
| 31 | | if (ty.containerLayout(mod) == .Packed) { |
| 31 | const struct_type = mod.typeToStruct(ty).?; |
| 32 | if (struct_type.layout == .Packed) { |
| 32 | 33 | if (ty.bitSize(mod) <= 64) return direct; |
| 33 | 34 | return .{ .direct, .direct }; |
| 34 | 35 | } |
| 35 | | if (ty.structFieldCount(mod) > 1) { |
| 36 | if (struct_type.field_types.len > 1) { |
| 36 | 37 | // The struct type is non-scalar. |
| 37 | 38 | return memory; |
| 38 | 39 | } |
| 39 | | const field_ty = ty.structFieldType(0, mod); |
| 40 | | const resolved_align = ty.structFieldAlign(0, mod); |
| 41 | | if (resolved_align.compare(.gt, field_ty.abiAlignment(mod))) { |
| 42 | | // The struct's alignment is greater than natural alignment. |
| 43 | | return memory; |
| 40 | const field_ty = struct_type.field_types.get(ip)[0].toType(); |
| 41 | const explicit_align = struct_type.fieldAlign(ip, 0); |
| 42 | if (explicit_align != .none) { |
| 43 | if (explicit_align.compareStrict(.gt, field_ty.abiAlignment(mod))) |
| 44 | return memory; |
| 44 | 45 | } |
| 45 | 46 | return classifyType(field_ty, mod); |
| 46 | 47 | }, |