| ... | ... | @@ -9,23 +9,24 @@ pub const Class = enum(u8) { memory, integer, none, float_array, _ }; |
| 9 | 9 | |
| 10 | 10 | /// For `float_array` the second element will be the amount of floats. |
| 11 | 11 | pub fn classifyType(ty: Type, target: std.Target) [2]Class { |
| 12 | | var maybe_float_bits: ?u16 = null; |
| 13 | | const float_count = countFloats(ty, target, &maybe_float_bits); |
| 14 | | if (float_count <= sret_float_count) return .{ .float_array, @intToEnum(Class, float_count) }; |
| 15 | | return classifyTypeInner(ty, target); |
| 16 | | } |
| 17 | | |
| 18 | | fn classifyTypeInner(ty: Type, target: std.Target) [2]Class { |
| 19 | 12 | if (!ty.hasRuntimeBitsIgnoreComptime()) return .{ .none, .none }; |
| 13 | var maybe_float_bits: ?u16 = null; |
| 20 | 14 | switch (ty.zigTypeTag()) { |
| 21 | 15 | .Struct => { |
| 22 | 16 | if (ty.containerLayout() == .Packed) return .{ .integer, .none }; |
| 17 | const float_count = countFloats(ty, target, &maybe_float_bits); |
| 18 | if (float_count <= sret_float_count) return .{ .float_array, @intToEnum(Class, float_count) }; |
| 19 | |
| 23 | 20 | const bit_size = ty.bitSize(target); |
| 24 | 21 | if (bit_size > 128) return .{ .memory, .none }; |
| 25 | 22 | if (bit_size > 64) return .{ .integer, .integer }; |
| 26 | 23 | return .{ .integer, .none }; |
| 27 | 24 | }, |
| 28 | 25 | .Union => { |
| 26 | if (ty.containerLayout() == .Packed) return .{ .integer, .none }; |
| 27 | const float_count = countFloats(ty, target, &maybe_float_bits); |
| 28 | if (float_count <= sret_float_count) return .{ .float_array, @intToEnum(Class, float_count) }; |
| 29 | |
| 29 | 30 | const bit_size = ty.bitSize(target); |
| 30 | 31 | if (bit_size > 128) return .{ .memory, .none }; |
| 31 | 32 | if (bit_size > 64) return .{ .integer, .integer }; |