std.Target: Rename c_type_* functions to camel case

From https://ziglang.org/documentation/master/#Names:

> If `x` is otherwise callable, then `x` should be `camelCase`.
This commit is contained in:
Linus Groh 2024-08-11 13:03:19 +01:00
parent fd434fcd38
commit 4ef956ef14
11 changed files with 109 additions and 109 deletions

View File

@ -5631,15 +5631,15 @@ pub const Result = struct {
}; };
const a_spec = a.ty.canonicalize(.standard).specifier; const a_spec = a.ty.canonicalize(.standard).specifier;
const b_spec = b.ty.canonicalize(.standard).specifier; const b_spec = b.ty.canonicalize(.standard).specifier;
if (p.comp.target.c_type_bit_size(.longdouble) == 128) { if (p.comp.target.cTypeBitSize(.longdouble) == 128) {
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return; if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
} }
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[1])) return; if (try a.floatConversion(b, a_spec, b_spec, p, float_types[1])) return;
if (p.comp.target.c_type_bit_size(.longdouble) == 80) { if (p.comp.target.cTypeBitSize(.longdouble) == 80) {
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return; if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
} }
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[2])) return; if (try a.floatConversion(b, a_spec, b_spec, p, float_types[2])) return;
if (p.comp.target.c_type_bit_size(.longdouble) == 64) { if (p.comp.target.cTypeBitSize(.longdouble) == 64) {
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return; if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
} }
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[3])) return; if (try a.floatConversion(b, a_spec, b_spec, p, float_types[3])) return;

View File

@ -991,19 +991,19 @@ pub fn sizeof(ty: Type, comp: *const Compilation) ?u64 {
.incomplete_array => return if (comp.langopts.emulate == .msvc) @as(?u64, 0) else null, .incomplete_array => return if (comp.langopts.emulate == .msvc) @as(?u64, 0) else null,
.func, .var_args_func, .old_style_func, .void, .bool => 1, .func, .var_args_func, .old_style_func, .void, .bool => 1,
.char, .schar, .uchar => 1, .char, .schar, .uchar => 1,
.short => comp.target.c_type_byte_size(.short), .short => comp.target.cTypeByteSize(.short),
.ushort => comp.target.c_type_byte_size(.ushort), .ushort => comp.target.cTypeByteSize(.ushort),
.int => comp.target.c_type_byte_size(.int), .int => comp.target.cTypeByteSize(.int),
.uint => comp.target.c_type_byte_size(.uint), .uint => comp.target.cTypeByteSize(.uint),
.long => comp.target.c_type_byte_size(.long), .long => comp.target.cTypeByteSize(.long),
.ulong => comp.target.c_type_byte_size(.ulong), .ulong => comp.target.cTypeByteSize(.ulong),
.long_long => comp.target.c_type_byte_size(.longlong), .long_long => comp.target.cTypeByteSize(.longlong),
.ulong_long => comp.target.c_type_byte_size(.ulonglong), .ulong_long => comp.target.cTypeByteSize(.ulonglong),
.long_double => comp.target.c_type_byte_size(.longdouble), .long_double => comp.target.cTypeByteSize(.longdouble),
.int128, .uint128 => 16, .int128, .uint128 => 16,
.fp16, .float16 => 2, .fp16, .float16 => 2,
.float => comp.target.c_type_byte_size(.float), .float => comp.target.cTypeByteSize(.float),
.double => comp.target.c_type_byte_size(.double), .double => comp.target.cTypeByteSize(.double),
.float80 => 16, .float80 => 16,
.float128 => 16, .float128 => 16,
.bit_int => { .bit_int => {
@ -1049,7 +1049,7 @@ pub fn bitSizeof(ty: Type, comp: *const Compilation) ?u64 {
.typeof_expr => ty.data.expr.ty.bitSizeof(comp), .typeof_expr => ty.data.expr.ty.bitSizeof(comp),
.attributed => ty.data.attributed.base.bitSizeof(comp), .attributed => ty.data.attributed.base.bitSizeof(comp),
.bit_int => return ty.data.int.bits, .bit_int => return ty.data.int.bits,
.long_double => comp.target.c_type_bit_size(.longdouble), .long_double => comp.target.cTypeBitSize(.longdouble),
.float80 => return 80, .float80 => return 80,
else => 8 * (ty.sizeof(comp) orelse return null), else => 8 * (ty.sizeof(comp) orelse return null),
}; };
@ -1104,24 +1104,24 @@ pub fn alignof(ty: Type, comp: *const Compilation) u29 {
=> return ty.makeReal().alignof(comp), => return ty.makeReal().alignof(comp),
// zig fmt: on // zig fmt: on
.short => comp.target.c_type_alignment(.short), .short => comp.target.cTypeAlignment(.short),
.ushort => comp.target.c_type_alignment(.ushort), .ushort => comp.target.cTypeAlignment(.ushort),
.int => comp.target.c_type_alignment(.int), .int => comp.target.cTypeAlignment(.int),
.uint => comp.target.c_type_alignment(.uint), .uint => comp.target.cTypeAlignment(.uint),
.long => comp.target.c_type_alignment(.long), .long => comp.target.cTypeAlignment(.long),
.ulong => comp.target.c_type_alignment(.ulong), .ulong => comp.target.cTypeAlignment(.ulong),
.long_long => comp.target.c_type_alignment(.longlong), .long_long => comp.target.cTypeAlignment(.longlong),
.ulong_long => comp.target.c_type_alignment(.ulonglong), .ulong_long => comp.target.cTypeAlignment(.ulonglong),
.bit_int => @min( .bit_int => @min(
std.math.ceilPowerOfTwoPromote(u16, (ty.data.int.bits + 7) / 8), std.math.ceilPowerOfTwoPromote(u16, (ty.data.int.bits + 7) / 8),
16, // comp.target.maxIntAlignment(), please use your own logic for this value as it is implementation-defined 16, // comp.target.maxIntAlignment(), please use your own logic for this value as it is implementation-defined
), ),
.float => comp.target.c_type_alignment(.float), .float => comp.target.cTypeAlignment(.float),
.double => comp.target.c_type_alignment(.double), .double => comp.target.cTypeAlignment(.double),
.long_double => comp.target.c_type_alignment(.longdouble), .long_double => comp.target.cTypeAlignment(.longdouble),
.int128, .uint128 => if (comp.target.cpu.arch == .s390x and comp.target.os.tag == .linux and comp.target.isGnu()) 8 else 16, .int128, .uint128 => if (comp.target.cpu.arch == .s390x and comp.target.os.tag == .linux and comp.target.isGnu()) 8 else 16,
.fp16, .float16 => 2, .fp16, .float16 => 2,

View File

@ -306,7 +306,7 @@ pub const FPSemantics = enum {
/// Only intended for generating float.h macros for the preprocessor /// Only intended for generating float.h macros for the preprocessor
pub fn forType(ty: std.Target.CType, target: std.Target) FPSemantics { pub fn forType(ty: std.Target.CType, target: std.Target) FPSemantics {
std.debug.assert(ty == .float or ty == .double or ty == .longdouble); std.debug.assert(ty == .float or ty == .double or ty == .longdouble);
return switch (target.c_type_bit_size(ty)) { return switch (target.cTypeBitSize(ty)) {
32 => .IEEESingle, 32 => .IEEESingle,
64 => .IEEEDouble, 64 => .IEEEDouble,
80 => .x87ExtendedDouble, 80 => .x87ExtendedDouble,
@ -350,7 +350,7 @@ pub const FPSemantics = enum {
}; };
pub fn isLP64(target: std.Target) bool { pub fn isLP64(target: std.Target) bool {
return target.c_type_bit_size(.int) == 32 and target.ptrBitWidth() == 64; return target.cTypeBitSize(.int) == 32 and target.ptrBitWidth() == 64;
} }
pub fn isKnownWindowsMSVCEnvironment(target: std.Target) bool { pub fn isKnownWindowsMSVCEnvironment(target: std.Target) bool {

View File

@ -2009,7 +2009,7 @@ pub const CType = enum {
longdouble, longdouble,
}; };
pub fn c_type_byte_size(t: Target, c_type: CType) u16 { pub fn cTypeByteSize(t: Target, c_type: CType) u16 {
return switch (c_type) { return switch (c_type) {
.char, .char,
.short, .short,
@ -2022,20 +2022,20 @@ pub fn c_type_byte_size(t: Target, c_type: CType) u16 {
.ulonglong, .ulonglong,
.float, .float,
.double, .double,
=> @divExact(c_type_bit_size(t, c_type), 8), => @divExact(cTypeBitSize(t, c_type), 8),
.longdouble => switch (c_type_bit_size(t, c_type)) { .longdouble => switch (cTypeBitSize(t, c_type)) {
16 => 2, 16 => 2,
32 => 4, 32 => 4,
64 => 8, 64 => 8,
80 => @intCast(std.mem.alignForward(usize, 10, c_type_alignment(t, .longdouble))), 80 => @intCast(std.mem.alignForward(usize, 10, cTypeAlignment(t, .longdouble))),
128 => 16, 128 => 16,
else => unreachable, else => unreachable,
}, },
}; };
} }
pub fn c_type_bit_size(target: Target, c_type: CType) u16 { pub fn cTypeBitSize(target: Target, c_type: CType) u16 {
switch (target.os.tag) { switch (target.os.tag) {
.freestanding, .other => switch (target.cpu.arch) { .freestanding, .other => switch (target.cpu.arch) {
.msp430 => switch (c_type) { .msp430 => switch (c_type) {
@ -2331,7 +2331,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
} }
} }
pub fn c_type_alignment(target: Target, c_type: CType) u16 { pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
// Overrides for unusual alignments // Overrides for unusual alignments
switch (target.cpu.arch) { switch (target.cpu.arch) {
.avr => return 1, .avr => return 1,
@ -2351,7 +2351,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
// Next-power-of-two-aligned, up to a maximum. // Next-power-of-two-aligned, up to a maximum.
return @min( return @min(
std.math.ceilPowerOfTwoAssert(u16, (c_type_bit_size(target, c_type) + 7) / 8), std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
@as(u16, switch (target.cpu.arch) { @as(u16, switch (target.cpu.arch) {
.arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) { .arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
.netbsd => switch (target.abi) { .netbsd => switch (target.abi) {
@ -2423,7 +2423,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
); );
} }
pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 { pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
// Overrides for unusual alignments // Overrides for unusual alignments
switch (target.cpu.arch) { switch (target.cpu.arch) {
.arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) { .arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
@ -2476,7 +2476,7 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
// Next-power-of-two-aligned, up to a maximum. // Next-power-of-two-aligned, up to a maximum.
return @min( return @min(
std.math.ceilPowerOfTwoAssert(u16, (c_type_bit_size(target, c_type) + 7) / 8), std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
@as(u16, switch (target.cpu.arch) { @as(u16, switch (target.cpu.arch) {
.msp430 => 2, .msp430 => 2,

View File

@ -30943,7 +30943,7 @@ fn coerceVarArgParam(
.Array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}), .Array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}),
.Float => float: { .Float => float: {
const target = zcu.getTarget(); const target = zcu.getTarget();
const double_bits = target.c_type_bit_size(.double); const double_bits = target.cTypeBitSize(.double);
const inst_bits = uncasted_ty.floatBits(target); const inst_bits = uncasted_ty.floatBits(target);
if (inst_bits >= double_bits) break :float inst; if (inst_bits >= double_bits) break :float inst;
switch (double_bits) { switch (double_bits) {
@ -30956,21 +30956,21 @@ fn coerceVarArgParam(
if (!try sema.validateExternType(uncasted_ty, .param_ty)) break :int inst; if (!try sema.validateExternType(uncasted_ty, .param_ty)) break :int inst;
const target = zcu.getTarget(); const target = zcu.getTarget();
const uncasted_info = uncasted_ty.intInfo(zcu); const uncasted_info = uncasted_ty.intInfo(zcu);
if (uncasted_info.bits <= target.c_type_bit_size(switch (uncasted_info.signedness) { if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) {
.signed => .int, .signed => .int,
.unsigned => .uint, .unsigned => .uint,
})) break :int try sema.coerce(block, switch (uncasted_info.signedness) { })) break :int try sema.coerce(block, switch (uncasted_info.signedness) {
.signed => Type.c_int, .signed => Type.c_int,
.unsigned => Type.c_uint, .unsigned => Type.c_uint,
}, inst, inst_src); }, inst, inst_src);
if (uncasted_info.bits <= target.c_type_bit_size(switch (uncasted_info.signedness) { if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) {
.signed => .long, .signed => .long,
.unsigned => .ulong, .unsigned => .ulong,
})) break :int try sema.coerce(block, switch (uncasted_info.signedness) { })) break :int try sema.coerce(block, switch (uncasted_info.signedness) {
.signed => Type.c_long, .signed => Type.c_long,
.unsigned => Type.c_ulong, .unsigned => Type.c_ulong,
}, inst, inst_src); }, inst, inst_src);
if (uncasted_info.bits <= target.c_type_bit_size(switch (uncasted_info.signedness) { if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) {
.signed => .longlong, .signed => .longlong,
.unsigned => .ulonglong, .unsigned => .ulonglong,
})) break :int try sema.coerce(block, switch (uncasted_info.signedness) { })) break :int try sema.coerce(block, switch (uncasted_info.signedness) {

View File

@ -1005,15 +1005,15 @@ pub fn abiAlignmentAdvanced(
.f16 => return .{ .scalar = .@"2" }, .f16 => return .{ .scalar = .@"2" },
.f32 => return .{ .scalar = cTypeAlign(target, .float) }, .f32 => return .{ .scalar = cTypeAlign(target, .float) },
.f64 => switch (target.c_type_bit_size(.double)) { .f64 => switch (target.cTypeBitSize(.double)) {
64 => return .{ .scalar = cTypeAlign(target, .double) }, 64 => return .{ .scalar = cTypeAlign(target, .double) },
else => return .{ .scalar = .@"8" }, else => return .{ .scalar = .@"8" },
}, },
.f80 => switch (target.c_type_bit_size(.longdouble)) { .f80 => switch (target.cTypeBitSize(.longdouble)) {
80 => return .{ .scalar = cTypeAlign(target, .longdouble) }, 80 => return .{ .scalar = cTypeAlign(target, .longdouble) },
else => return .{ .scalar = Type.u80.abiAlignment(pt) }, else => return .{ .scalar = Type.u80.abiAlignment(pt) },
}, },
.f128 => switch (target.c_type_bit_size(.longdouble)) { .f128 => switch (target.cTypeBitSize(.longdouble)) {
128 => return .{ .scalar = cTypeAlign(target, .longdouble) }, 128 => return .{ .scalar = cTypeAlign(target, .longdouble) },
else => return .{ .scalar = .@"16" }, else => return .{ .scalar = .@"16" },
}, },
@ -1366,8 +1366,8 @@ pub fn abiSizeAdvanced(
.f32 => return .{ .scalar = 4 }, .f32 => return .{ .scalar = 4 },
.f64 => return .{ .scalar = 8 }, .f64 => return .{ .scalar = 8 },
.f128 => return .{ .scalar = 16 }, .f128 => return .{ .scalar = 16 },
.f80 => switch (target.c_type_bit_size(.longdouble)) { .f80 => switch (target.cTypeBitSize(.longdouble)) {
80 => return .{ .scalar = target.c_type_byte_size(.longdouble) }, 80 => return .{ .scalar = target.cTypeByteSize(.longdouble) },
else => return .{ .scalar = Type.u80.abiSize(pt) }, else => return .{ .scalar = Type.u80.abiSize(pt) },
}, },
@ -1375,16 +1375,16 @@ pub fn abiSizeAdvanced(
.isize, .isize,
=> return .{ .scalar = @divExact(target.ptrBitWidth(), 8) }, => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
.c_char => return .{ .scalar = target.c_type_byte_size(.char) }, .c_char => return .{ .scalar = target.cTypeByteSize(.char) },
.c_short => return .{ .scalar = target.c_type_byte_size(.short) }, .c_short => return .{ .scalar = target.cTypeByteSize(.short) },
.c_ushort => return .{ .scalar = target.c_type_byte_size(.ushort) }, .c_ushort => return .{ .scalar = target.cTypeByteSize(.ushort) },
.c_int => return .{ .scalar = target.c_type_byte_size(.int) }, .c_int => return .{ .scalar = target.cTypeByteSize(.int) },
.c_uint => return .{ .scalar = target.c_type_byte_size(.uint) }, .c_uint => return .{ .scalar = target.cTypeByteSize(.uint) },
.c_long => return .{ .scalar = target.c_type_byte_size(.long) }, .c_long => return .{ .scalar = target.cTypeByteSize(.long) },
.c_ulong => return .{ .scalar = target.c_type_byte_size(.ulong) }, .c_ulong => return .{ .scalar = target.cTypeByteSize(.ulong) },
.c_longlong => return .{ .scalar = target.c_type_byte_size(.longlong) }, .c_longlong => return .{ .scalar = target.cTypeByteSize(.longlong) },
.c_ulonglong => return .{ .scalar = target.c_type_byte_size(.ulonglong) }, .c_ulonglong => return .{ .scalar = target.cTypeByteSize(.ulonglong) },
.c_longdouble => return .{ .scalar = target.c_type_byte_size(.longdouble) }, .c_longdouble => return .{ .scalar = target.cTypeByteSize(.longdouble) },
.anyopaque, .anyopaque,
.void, .void,
@ -1724,16 +1724,16 @@ pub fn bitSizeAdvanced(
.isize, .isize,
=> return target.ptrBitWidth(), => return target.ptrBitWidth(),
.c_char => return target.c_type_bit_size(.char), .c_char => return target.cTypeBitSize(.char),
.c_short => return target.c_type_bit_size(.short), .c_short => return target.cTypeBitSize(.short),
.c_ushort => return target.c_type_bit_size(.ushort), .c_ushort => return target.cTypeBitSize(.ushort),
.c_int => return target.c_type_bit_size(.int), .c_int => return target.cTypeBitSize(.int),
.c_uint => return target.c_type_bit_size(.uint), .c_uint => return target.cTypeBitSize(.uint),
.c_long => return target.c_type_bit_size(.long), .c_long => return target.cTypeBitSize(.long),
.c_ulong => return target.c_type_bit_size(.ulong), .c_ulong => return target.cTypeBitSize(.ulong),
.c_longlong => return target.c_type_bit_size(.longlong), .c_longlong => return target.cTypeBitSize(.longlong),
.c_ulonglong => return target.c_type_bit_size(.ulonglong), .c_ulonglong => return target.cTypeBitSize(.ulonglong),
.c_longdouble => return target.c_type_bit_size(.longdouble), .c_longdouble => return target.cTypeBitSize(.longdouble),
.bool => return 1, .bool => return 1,
.void => return 0, .void => return 0,
@ -2310,15 +2310,15 @@ pub fn intInfo(starting_ty: Type, mod: *Module) InternPool.Key.IntType {
}, },
.usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() }, .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },
.isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() }, .isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },
.c_char_type => return .{ .signedness = mod.getTarget().charSignedness(), .bits = target.c_type_bit_size(.char) }, .c_char_type => return .{ .signedness = mod.getTarget().charSignedness(), .bits = target.cTypeBitSize(.char) },
.c_short_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) }, .c_short_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.short) },
.c_ushort_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) }, .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ushort) },
.c_int_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) }, .c_int_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.int) },
.c_uint_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) }, .c_uint_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.uint) },
.c_long_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) }, .c_long_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.long) },
.c_ulong_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) }, .c_ulong_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ulong) },
.c_longlong_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) }, .c_longlong_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.longlong) },
.c_ulonglong_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) }, .c_ulonglong_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ulonglong) },
else => switch (ip.indexToKey(ty.toIntern())) { else => switch (ip.indexToKey(ty.toIntern())) {
.int_type => |int_type| return int_type, .int_type => |int_type| return int_type,
.struct_type => ty = Type.fromInterned(ip.loadStructType(ty.toIntern()).backingIntTypeUnordered(ip)), .struct_type => ty = Type.fromInterned(ip.loadStructType(ty.toIntern()).backingIntTypeUnordered(ip)),
@ -2427,7 +2427,7 @@ pub fn floatBits(ty: Type, target: Target) u16 {
.f64_type => 64, .f64_type => 64,
.f80_type => 80, .f80_type => 80,
.f128_type, .comptime_float_type => 128, .f128_type, .comptime_float_type => 128,
.c_longdouble_type => target.c_type_bit_size(.longdouble), .c_longdouble_type => target.cTypeBitSize(.longdouble),
else => unreachable, else => unreachable,
}; };
@ -4025,5 +4025,5 @@ pub fn smallestUnsignedBits(max: u64) u16 {
pub const packed_struct_layout_version = 2; pub const packed_struct_layout_version = 2;
fn cTypeAlign(target: Target, c_type: Target.CType) Alignment { fn cTypeAlign(target: Target, c_type: Target.CType) Alignment {
return Alignment.fromByteUnits(target.c_type_alignment(c_type)); return Alignment.fromByteUnits(target.cTypeAlignment(c_type));
} }

View File

@ -8304,7 +8304,7 @@ fn promoteVarArg(func: *Func, ty: Type) Type {
switch (ty.floatBits(func.target.*)) { switch (ty.floatBits(func.target.*)) {
32, 64 => return Type.f64, 32, 64 => return Type.f64,
else => |float_bits| { else => |float_bits| {
assert(float_bits == func.target.c_type_bit_size(.longdouble)); assert(float_bits == func.target.cTypeBitSize(.longdouble));
return Type.c_longdouble; return Type.c_longdouble;
}, },
} }

View File

@ -19374,7 +19374,7 @@ fn promoteVarArg(self: *Self, ty: Type) Type {
switch (ty.floatBits(self.target.*)) { switch (ty.floatBits(self.target.*)) {
32, 64 => return Type.f64, 32, 64 => return Type.f64,
else => |float_bits| { else => |float_bits| {
assert(float_bits == self.target.c_type_bit_size(.longdouble)); assert(float_bits == self.target.cTypeBitSize(.longdouble));
return Type.c_longdouble; return Type.c_longdouble;
}, },
} }

View File

@ -326,9 +326,9 @@ pub fn renderLiteralSuffix(ctype: CType, writer: anytype, pool: *const Pool) @Ty
pub fn floatActiveBits(ctype: CType, mod: *Module) u16 { pub fn floatActiveBits(ctype: CType, mod: *Module) u16 {
const target = &mod.resolved_target.result; const target = &mod.resolved_target.result;
return switch (ctype.index) { return switch (ctype.index) {
.float => target.c_type_bit_size(.float), .float => target.cTypeBitSize(.float),
.double => target.c_type_bit_size(.double), .double => target.cTypeBitSize(.double),
.@"long double", .zig_c_longdouble => target.c_type_bit_size(.longdouble), .@"long double", .zig_c_longdouble => target.cTypeBitSize(.longdouble),
.zig_f16 => 16, .zig_f16 => 16,
.zig_f32 => 32, .zig_f32 => 32,
.zig_f64 => 64, .zig_f64 => 64,
@ -344,17 +344,17 @@ pub fn byteSize(ctype: CType, pool: *const Pool, mod: *Module) u64 {
.basic => |basic_info| switch (basic_info) { .basic => |basic_info| switch (basic_info) {
.void => 0, .void => 0,
.char, .@"signed char", ._Bool, .@"unsigned char", .bool, .uint8_t, .int8_t => 1, .char, .@"signed char", ._Bool, .@"unsigned char", .bool, .uint8_t, .int8_t => 1,
.short => target.c_type_byte_size(.short), .short => target.cTypeByteSize(.short),
.int => target.c_type_byte_size(.int), .int => target.cTypeByteSize(.int),
.long => target.c_type_byte_size(.long), .long => target.cTypeByteSize(.long),
.@"long long" => target.c_type_byte_size(.longlong), .@"long long" => target.cTypeByteSize(.longlong),
.@"unsigned short" => target.c_type_byte_size(.ushort), .@"unsigned short" => target.cTypeByteSize(.ushort),
.@"unsigned int" => target.c_type_byte_size(.uint), .@"unsigned int" => target.cTypeByteSize(.uint),
.@"unsigned long" => target.c_type_byte_size(.ulong), .@"unsigned long" => target.cTypeByteSize(.ulong),
.@"unsigned long long" => target.c_type_byte_size(.ulonglong), .@"unsigned long long" => target.cTypeByteSize(.ulonglong),
.float => target.c_type_byte_size(.float), .float => target.cTypeByteSize(.float),
.double => target.c_type_byte_size(.double), .double => target.cTypeByteSize(.double),
.@"long double" => target.c_type_byte_size(.longdouble), .@"long double" => target.cTypeByteSize(.longdouble),
.size_t, .size_t,
.ptrdiff_t, .ptrdiff_t,
.uintptr_t, .uintptr_t,
@ -364,11 +364,11 @@ pub fn byteSize(ctype: CType, pool: *const Pool, mod: *Module) u64 {
.uint32_t, .int32_t, .zig_f32 => 4, .uint32_t, .int32_t, .zig_f32 => 4,
.uint64_t, .int64_t, .zig_f64 => 8, .uint64_t, .int64_t, .zig_f64 => 8,
.zig_u128, .zig_i128, .zig_f128 => 16, .zig_u128, .zig_i128, .zig_f128 => 16,
.zig_f80 => if (target.c_type_bit_size(.longdouble) == 80) .zig_f80 => if (target.cTypeBitSize(.longdouble) == 80)
target.c_type_byte_size(.longdouble) target.cTypeByteSize(.longdouble)
else else
16, 16,
.zig_c_longdouble => target.c_type_byte_size(.longdouble), .zig_c_longdouble => target.cTypeByteSize(.longdouble),
.va_list => unreachable, .va_list => unreachable,
_ => unreachable, _ => unreachable,
}, },

View File

@ -562,9 +562,9 @@ const DataLayoutBuilder = struct {
.float => &.{ .float, .double, .longdouble }, .float => &.{ .float, .double, .longdouble },
.vector, .aggregate => &.{}, .vector, .aggregate => &.{},
})) |cty| { })) |cty| {
if (self.target.c_type_bit_size(cty) != size) continue; if (self.target.cTypeBitSize(cty) != size) continue;
abi = self.target.c_type_alignment(cty) * 8; abi = self.target.cTypeAlignment(cty) * 8;
pref = self.target.c_type_preferred_alignment(cty) * 8; pref = self.target.cTypePreferredAlignment(cty) * 8;
break; break;
} }
switch (kind) { switch (kind) {
@ -3120,7 +3120,7 @@ pub const Object = struct {
.c_ulong_type, .c_ulong_type,
.c_longlong_type, .c_longlong_type,
.c_ulonglong_type, .c_ulonglong_type,
=> |tag| try o.builder.intType(target.c_type_bit_size( => |tag| try o.builder.intType(target.cTypeBitSize(
@field(std.Target.CType, @tagName(tag)["c_".len .. @tagName(tag).len - "_type".len]), @field(std.Target.CType, @tagName(tag)["c_".len .. @tagName(tag).len - "_type".len]),
)), )),
.c_longdouble_type, .c_longdouble_type,
@ -11778,8 +11778,8 @@ fn backendSupportsF128(target: std.Target) bool {
fn intrinsicsAllowed(scalar_ty: Type, target: std.Target) bool { fn intrinsicsAllowed(scalar_ty: Type, target: std.Target) bool {
return switch (scalar_ty.toIntern()) { return switch (scalar_ty.toIntern()) {
.f16_type => backendSupportsF16(target), .f16_type => backendSupportsF16(target),
.f80_type => (target.c_type_bit_size(.longdouble) == 80) and backendSupportsF80(target), .f80_type => (target.cTypeBitSize(.longdouble) == 80) and backendSupportsF80(target),
.f128_type => (target.c_type_bit_size(.longdouble) == 128) and backendSupportsF128(target), .f128_type => (target.cTypeBitSize(.longdouble) == 128) and backendSupportsF128(target),
else => true, else => true,
}; };
} }

View File

@ -8,7 +8,7 @@
const std = @import("std"); const std = @import("std");
fn c_name(ty: std.Target.CType) []const u8 { fn cName(ty: std.Target.CType) []const u8 {
return switch (ty) { return switch (ty) {
.char => "char", .char => "char",
.short => "short", .short => "short",
@ -46,16 +46,16 @@ pub fn main() !void {
inline for (@typeInfo(std.Target.CType).Enum.fields) |field| { inline for (@typeInfo(std.Target.CType).Enum.fields) |field| {
const c_type: std.Target.CType = @enumFromInt(field.value); const c_type: std.Target.CType = @enumFromInt(field.value);
try stdout.print("_Static_assert(sizeof({0s}) == {1d}, \"sizeof({0s}) == {1d}\");\n", .{ try stdout.print("_Static_assert(sizeof({0s}) == {1d}, \"sizeof({0s}) == {1d}\");\n", .{
c_name(c_type), cName(c_type),
target.c_type_byte_size(c_type), target.cTypeByteSize(c_type),
}); });
try stdout.print("_Static_assert(_Alignof({0s}) == {1d}, \"_Alignof({0s}) == {1d}\");\n", .{ try stdout.print("_Static_assert(_Alignof({0s}) == {1d}, \"_Alignof({0s}) == {1d}\");\n", .{
c_name(c_type), cName(c_type),
target.c_type_alignment(c_type), target.cTypeAlignment(c_type),
}); });
try stdout.print("_Static_assert(__alignof({0s}) == {1d}, \"__alignof({0s}) == {1d}\");\n\n", .{ try stdout.print("_Static_assert(__alignof({0s}) == {1d}, \"__alignof({0s}) == {1d}\");\n\n", .{
c_name(c_type), cName(c_type),
target.c_type_preferred_alignment(c_type), target.cTypePreferredAlignment(c_type),
}); });
} }
} }