resolve bit size based target
This commit is contained in:
parent
ef0cfadf8a
commit
5258a60f0e
@ -407,16 +407,15 @@ pub const Key = union(enum) {
|
|||||||
.usize => return .{ .signedness = .signed, .bits = target.cpu.arch.ptrBitWidth() },
|
.usize => return .{ .signedness = .signed, .bits = target.cpu.arch.ptrBitWidth() },
|
||||||
.isize => return .{ .signedness = .unsigned, .bits = target.cpu.arch.ptrBitWidth() },
|
.isize => return .{ .signedness = .unsigned, .bits = target.cpu.arch.ptrBitWidth() },
|
||||||
|
|
||||||
// TODO correctly resolve size based on `target`
|
.c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },
|
||||||
.c_short => return .{ .signedness = .signed, .bits = @bitSizeOf(c_short) },
|
.c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },
|
||||||
.c_ushort => return .{ .signedness = .unsigned, .bits = @bitSizeOf(c_ushort) },
|
.c_int => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },
|
||||||
.c_int => return .{ .signedness = .signed, .bits = @bitSizeOf(c_int) },
|
.c_uint => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) },
|
||||||
.c_uint => return .{ .signedness = .unsigned, .bits = @bitSizeOf(c_uint) },
|
.c_long => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) },
|
||||||
.c_long => return .{ .signedness = .signed, .bits = @bitSizeOf(c_long) },
|
.c_ulong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) },
|
||||||
.c_ulong => return .{ .signedness = .unsigned, .bits = @bitSizeOf(c_ulong) },
|
.c_longlong => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) },
|
||||||
.c_longlong => return .{ .signedness = .signed, .bits = @bitSizeOf(c_longlong) },
|
.c_ulonglong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) },
|
||||||
.c_ulonglong => return .{ .signedness = .unsigned, .bits = @bitSizeOf(c_ulonglong) },
|
.c_longdouble => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longdouble) },
|
||||||
.c_longdouble => return .{ .signedness = .signed, .bits = @bitSizeOf(c_longdouble) },
|
|
||||||
|
|
||||||
// TODO revisit this when error sets support custom int types (comment taken from zig codebase)
|
// TODO revisit this when error sets support custom int types (comment taken from zig codebase)
|
||||||
.anyerror => return .{ .signedness = .unsigned, .bits = 16 },
|
.anyerror => return .{ .signedness = .unsigned, .bits = 16 },
|
||||||
@ -443,15 +442,13 @@ pub const Key = union(enum) {
|
|||||||
/// Asserts the type is a fixed-size float or comptime_float.
|
/// Asserts the type is a fixed-size float or comptime_float.
|
||||||
/// Returns 128 for comptime_float types.
|
/// Returns 128 for comptime_float types.
|
||||||
pub fn floatBits(ty: Key, target: std.Target) u16 {
|
pub fn floatBits(ty: Key, target: std.Target) u16 {
|
||||||
_ = target;
|
|
||||||
return switch (ty.simple) {
|
return switch (ty.simple) {
|
||||||
.f16 => 16,
|
.f16 => 16,
|
||||||
.f32 => 32,
|
.f32 => 32,
|
||||||
.f64 => 64,
|
.f64 => 64,
|
||||||
.f80 => 80,
|
.f80 => 80,
|
||||||
.f128, .comptime_float => 128,
|
.f128, .comptime_float => 128,
|
||||||
// TODO correctly resolve size based on `target`
|
.c_longdouble => target.c_type_bit_size(.longdouble),
|
||||||
.c_longdouble => @bitSizeOf(c_longdouble),
|
|
||||||
|
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user