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