| author | |
| committer | |
| log | 4ef956ef140a1c8cf606cd9b6a9606c0a85bf934 |
| tree | 681414566bb7b57ba50e0a6182336040ef184d6b |
| parent | fd434fcd3802cd51778cfc44bde8e6ff83f808bd |
From https://ziglang.org/documentation/master/#Names:
> If `x` is otherwise callable, then `x` should be `camelCase`.11 files changed, 109 insertions(+), 109 deletions(-)
lib/compiler/aro/aro/Parser.zig+3-3| ... | ... | @@ -5631,15 +5631,15 @@ pub const Result = struct { |
| 5631 | 5631 | }; |
| 5632 | 5632 | const a_spec = a.ty.canonicalize(.standard).specifier; |
| 5633 | 5633 | const b_spec = b.ty.canonicalize(.standard).specifier; |
| 5634 | if (p.comp.target.c_type_bit_size(.longdouble) == 128) { | |
| 5634 | if (p.comp.target.cTypeBitSize(.longdouble) == 128) { | |
| 5635 | 5635 | if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return; |
| 5636 | 5636 | } |
| 5637 | 5637 | if (try a.floatConversion(b, a_spec, b_spec, p, float_types[1])) return; |
| 5638 | if (p.comp.target.c_type_bit_size(.longdouble) == 80) { | |
| 5638 | if (p.comp.target.cTypeBitSize(.longdouble) == 80) { | |
| 5639 | 5639 | if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return; |
| 5640 | 5640 | } |
| 5641 | 5641 | if (try a.floatConversion(b, a_spec, b_spec, p, float_types[2])) return; |
| 5642 | if (p.comp.target.c_type_bit_size(.longdouble) == 64) { | |
| 5642 | if (p.comp.target.cTypeBitSize(.longdouble) == 64) { | |
| 5643 | 5643 | if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return; |
| 5644 | 5644 | } |
| 5645 | 5645 | if (try a.floatConversion(b, a_spec, b_spec, p, float_types[3])) return; |
lib/compiler/aro/aro/Type.zig+23-23| ... | ... | @@ -991,19 +991,19 @@ pub fn sizeof(ty: Type, comp: *const Compilation) ?u64 { |
| 991 | 991 | .incomplete_array => return if (comp.langopts.emulate == .msvc) @as(?u64, 0) else null, |
| 992 | 992 | .func, .var_args_func, .old_style_func, .void, .bool => 1, |
| 993 | 993 | .char, .schar, .uchar => 1, |
| 994 | .short => comp.target.c_type_byte_size(.short), | |
| 995 | .ushort => comp.target.c_type_byte_size(.ushort), | |
| 996 | .int => comp.target.c_type_byte_size(.int), | |
| 997 | .uint => comp.target.c_type_byte_size(.uint), | |
| 998 | .long => comp.target.c_type_byte_size(.long), | |
| 999 | .ulong => comp.target.c_type_byte_size(.ulong), | |
| 1000 | .long_long => comp.target.c_type_byte_size(.longlong), | |
| 1001 | .ulong_long => comp.target.c_type_byte_size(.ulonglong), | |
| 1002 | .long_double => comp.target.c_type_byte_size(.longdouble), | |
| 994 | .short => comp.target.cTypeByteSize(.short), | |
| 995 | .ushort => comp.target.cTypeByteSize(.ushort), | |
| 996 | .int => comp.target.cTypeByteSize(.int), | |
| 997 | .uint => comp.target.cTypeByteSize(.uint), | |
| 998 | .long => comp.target.cTypeByteSize(.long), | |
| 999 | .ulong => comp.target.cTypeByteSize(.ulong), | |
| 1000 | .long_long => comp.target.cTypeByteSize(.longlong), | |
| 1001 | .ulong_long => comp.target.cTypeByteSize(.ulonglong), | |
| 1002 | .long_double => comp.target.cTypeByteSize(.longdouble), | |
| 1003 | 1003 | .int128, .uint128 => 16, |
| 1004 | 1004 | .fp16, .float16 => 2, |
| 1005 | .float => comp.target.c_type_byte_size(.float), | |
| 1006 | .double => comp.target.c_type_byte_size(.double), | |
| 1005 | .float => comp.target.cTypeByteSize(.float), | |
| 1006 | .double => comp.target.cTypeByteSize(.double), | |
| 1007 | 1007 | .float80 => 16, |
| 1008 | 1008 | .float128 => 16, |
| 1009 | 1009 | .bit_int => { |
| ... | ... | @@ -1049,7 +1049,7 @@ pub fn bitSizeof(ty: Type, comp: *const Compilation) ?u64 { |
| 1049 | 1049 | .typeof_expr => ty.data.expr.ty.bitSizeof(comp), |
| 1050 | 1050 | .attributed => ty.data.attributed.base.bitSizeof(comp), |
| 1051 | 1051 | .bit_int => return ty.data.int.bits, |
| 1052 | .long_double => comp.target.c_type_bit_size(.longdouble), | |
| 1052 | .long_double => comp.target.cTypeBitSize(.longdouble), | |
| 1053 | 1053 | .float80 => return 80, |
| 1054 | 1054 | else => 8 * (ty.sizeof(comp) orelse return null), |
| 1055 | 1055 | }; |
| ... | ... | @@ -1104,24 +1104,24 @@ pub fn alignof(ty: Type, comp: *const Compilation) u29 { |
| 1104 | 1104 | => return ty.makeReal().alignof(comp), |
| 1105 | 1105 | // zig fmt: on |
| 1106 | 1106 | |
| 1107 | .short => comp.target.c_type_alignment(.short), | |
| 1108 | .ushort => comp.target.c_type_alignment(.ushort), | |
| 1109 | .int => comp.target.c_type_alignment(.int), | |
| 1110 | .uint => comp.target.c_type_alignment(.uint), | |
| 1107 | .short => comp.target.cTypeAlignment(.short), | |
| 1108 | .ushort => comp.target.cTypeAlignment(.ushort), | |
| 1109 | .int => comp.target.cTypeAlignment(.int), | |
| 1110 | .uint => comp.target.cTypeAlignment(.uint), | |
| 1111 | 1111 | |
| 1112 | .long => comp.target.c_type_alignment(.long), | |
| 1113 | .ulong => comp.target.c_type_alignment(.ulong), | |
| 1114 | .long_long => comp.target.c_type_alignment(.longlong), | |
| 1115 | .ulong_long => comp.target.c_type_alignment(.ulonglong), | |
| 1112 | .long => comp.target.cTypeAlignment(.long), | |
| 1113 | .ulong => comp.target.cTypeAlignment(.ulong), | |
| 1114 | .long_long => comp.target.cTypeAlignment(.longlong), | |
| 1115 | .ulong_long => comp.target.cTypeAlignment(.ulonglong), | |
| 1116 | 1116 | |
| 1117 | 1117 | .bit_int => @min( |
| 1118 | 1118 | std.math.ceilPowerOfTwoPromote(u16, (ty.data.int.bits + 7) / 8), |
| 1119 | 1119 | 16, // comp.target.maxIntAlignment(), please use your own logic for this value as it is implementation-defined |
| 1120 | 1120 | ), |
| 1121 | 1121 | |
| 1122 | .float => comp.target.c_type_alignment(.float), | |
| 1123 | .double => comp.target.c_type_alignment(.double), | |
| 1124 | .long_double => comp.target.c_type_alignment(.longdouble), | |
| 1122 | .float => comp.target.cTypeAlignment(.float), | |
| 1123 | .double => comp.target.cTypeAlignment(.double), | |
| 1124 | .long_double => comp.target.cTypeAlignment(.longdouble), | |
| 1125 | 1125 | |
| 1126 | 1126 | .int128, .uint128 => if (comp.target.cpu.arch == .s390x and comp.target.os.tag == .linux and comp.target.isGnu()) 8 else 16, |
| 1127 | 1127 | .fp16, .float16 => 2, |
lib/compiler/aro/aro/target.zig+2-2| ... | ... | @@ -306,7 +306,7 @@ pub const FPSemantics = enum { |
| 306 | 306 | /// Only intended for generating float.h macros for the preprocessor |
| 307 | 307 | pub fn forType(ty: std.Target.CType, target: std.Target) FPSemantics { |
| 308 | 308 | std.debug.assert(ty == .float or ty == .double or ty == .longdouble); |
| 309 | return switch (target.c_type_bit_size(ty)) { | |
| 309 | return switch (target.cTypeBitSize(ty)) { | |
| 310 | 310 | 32 => .IEEESingle, |
| 311 | 311 | 64 => .IEEEDouble, |
| 312 | 312 | 80 => .x87ExtendedDouble, |
| ... | ... | @@ -350,7 +350,7 @@ pub const FPSemantics = enum { |
| 350 | 350 | }; |
| 351 | 351 | |
| 352 | 352 | pub fn isLP64(target: std.Target) bool { |
| 353 | return target.c_type_bit_size(.int) == 32 and target.ptrBitWidth() == 64; | |
| 353 | return target.cTypeBitSize(.int) == 32 and target.ptrBitWidth() == 64; | |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | pub fn isKnownWindowsMSVCEnvironment(target: std.Target) bool { |
lib/std/Target.zig+9-9| ... | ... | @@ -2009,7 +2009,7 @@ pub const CType = enum { |
| 2009 | 2009 | longdouble, |
| 2010 | 2010 | }; |
| 2011 | 2011 | |
| 2012 | pub fn c_type_byte_size(t: Target, c_type: CType) u16 { | |
| 2012 | pub fn cTypeByteSize(t: Target, c_type: CType) u16 { | |
| 2013 | 2013 | return switch (c_type) { |
| 2014 | 2014 | .char, |
| 2015 | 2015 | .short, |
| ... | ... | @@ -2022,20 +2022,20 @@ pub fn c_type_byte_size(t: Target, c_type: CType) u16 { |
| 2022 | 2022 | .ulonglong, |
| 2023 | 2023 | .float, |
| 2024 | 2024 | .double, |
| 2025 | => @divExact(c_type_bit_size(t, c_type), 8), | |
| 2025 | => @divExact(cTypeBitSize(t, c_type), 8), | |
| 2026 | 2026 | |
| 2027 | .longdouble => switch (c_type_bit_size(t, c_type)) { | |
| 2027 | .longdouble => switch (cTypeBitSize(t, c_type)) { | |
| 2028 | 2028 | 16 => 2, |
| 2029 | 2029 | 32 => 4, |
| 2030 | 2030 | 64 => 8, |
| 2031 | 80 => @intCast(std.mem.alignForward(usize, 10, c_type_alignment(t, .longdouble))), | |
| 2031 | 80 => @intCast(std.mem.alignForward(usize, 10, cTypeAlignment(t, .longdouble))), | |
| 2032 | 2032 | 128 => 16, |
| 2033 | 2033 | else => unreachable, |
| 2034 | 2034 | }, |
| 2035 | 2035 | }; |
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | pub fn c_type_bit_size(target: Target, c_type: CType) u16 { | |
| 2038 | pub fn cTypeBitSize(target: Target, c_type: CType) u16 { | |
| 2039 | 2039 | switch (target.os.tag) { |
| 2040 | 2040 | .freestanding, .other => switch (target.cpu.arch) { |
| 2041 | 2041 | .msp430 => switch (c_type) { |
| ... | ... | @@ -2331,7 +2331,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 { |
| 2331 | 2331 | } |
| 2332 | 2332 | } |
| 2333 | 2333 | |
| 2334 | pub fn c_type_alignment(target: Target, c_type: CType) u16 { | |
| 2334 | pub fn cTypeAlignment(target: Target, c_type: CType) u16 { | |
| 2335 | 2335 | // Overrides for unusual alignments |
| 2336 | 2336 | switch (target.cpu.arch) { |
| 2337 | 2337 | .avr => return 1, |
| ... | ... | @@ -2351,7 +2351,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 { |
| 2351 | 2351 | |
| 2352 | 2352 | // Next-power-of-two-aligned, up to a maximum. |
| 2353 | 2353 | return @min( |
| 2354 | std.math.ceilPowerOfTwoAssert(u16, (c_type_bit_size(target, c_type) + 7) / 8), | |
| 2354 | std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8), | |
| 2355 | 2355 | @as(u16, switch (target.cpu.arch) { |
| 2356 | 2356 | .arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) { |
| 2357 | 2357 | .netbsd => switch (target.abi) { |
| ... | ... | @@ -2423,7 +2423,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 { |
| 2423 | 2423 | ); |
| 2424 | 2424 | } |
| 2425 | 2425 | |
| 2426 | pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 { | |
| 2426 | pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 { | |
| 2427 | 2427 | // Overrides for unusual alignments |
| 2428 | 2428 | switch (target.cpu.arch) { |
| 2429 | 2429 | .arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) { |
| ... | ... | @@ -2476,7 +2476,7 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 { |
| 2476 | 2476 | |
| 2477 | 2477 | // Next-power-of-two-aligned, up to a maximum. |
| 2478 | 2478 | return @min( |
| 2479 | std.math.ceilPowerOfTwoAssert(u16, (c_type_bit_size(target, c_type) + 7) / 8), | |
| 2479 | std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8), | |
| 2480 | 2480 | @as(u16, switch (target.cpu.arch) { |
| 2481 | 2481 | .msp430 => 2, |
| 2482 | 2482 |
src/Sema.zig+4-4| ... | ... | @@ -30943,7 +30943,7 @@ fn coerceVarArgParam( |
| 30943 | 30943 | .Array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}), |
| 30944 | 30944 | .Float => float: { |
| 30945 | 30945 | const target = zcu.getTarget(); |
| 30946 | const double_bits = target.c_type_bit_size(.double); | |
| 30946 | const double_bits = target.cTypeBitSize(.double); | |
| 30947 | 30947 | const inst_bits = uncasted_ty.floatBits(target); |
| 30948 | 30948 | if (inst_bits >= double_bits) break :float inst; |
| 30949 | 30949 | switch (double_bits) { |
| ... | ... | @@ -30956,21 +30956,21 @@ fn coerceVarArgParam( |
| 30956 | 30956 | if (!try sema.validateExternType(uncasted_ty, .param_ty)) break :int inst; |
| 30957 | 30957 | const target = zcu.getTarget(); |
| 30958 | 30958 | const uncasted_info = uncasted_ty.intInfo(zcu); |
| 30959 | if (uncasted_info.bits <= target.c_type_bit_size(switch (uncasted_info.signedness) { | |
| 30959 | if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) { | |
| 30960 | 30960 | .signed => .int, |
| 30961 | 30961 | .unsigned => .uint, |
| 30962 | 30962 | })) break :int try sema.coerce(block, switch (uncasted_info.signedness) { |
| 30963 | 30963 | .signed => Type.c_int, |
| 30964 | 30964 | .unsigned => Type.c_uint, |
| 30965 | 30965 | }, inst, inst_src); |
| 30966 | if (uncasted_info.bits <= target.c_type_bit_size(switch (uncasted_info.signedness) { | |
| 30966 | if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) { | |
| 30967 | 30967 | .signed => .long, |
| 30968 | 30968 | .unsigned => .ulong, |
| 30969 | 30969 | })) break :int try sema.coerce(block, switch (uncasted_info.signedness) { |
| 30970 | 30970 | .signed => Type.c_long, |
| 30971 | 30971 | .unsigned => Type.c_ulong, |
| 30972 | 30972 | }, inst, inst_src); |
| 30973 | if (uncasted_info.bits <= target.c_type_bit_size(switch (uncasted_info.signedness) { | |
| 30973 | if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) { | |
| 30974 | 30974 | .signed => .longlong, |
| 30975 | 30975 | .unsigned => .ulonglong, |
| 30976 | 30976 | })) break :int try sema.coerce(block, switch (uncasted_info.signedness) { |
src/Type.zig+36-36| ... | ... | @@ -1005,15 +1005,15 @@ pub fn abiAlignmentAdvanced( |
| 1005 | 1005 | |
| 1006 | 1006 | .f16 => return .{ .scalar = .@"2" }, |
| 1007 | 1007 | .f32 => return .{ .scalar = cTypeAlign(target, .float) }, |
| 1008 | .f64 => switch (target.c_type_bit_size(.double)) { | |
| 1008 | .f64 => switch (target.cTypeBitSize(.double)) { | |
| 1009 | 1009 | 64 => return .{ .scalar = cTypeAlign(target, .double) }, |
| 1010 | 1010 | else => return .{ .scalar = .@"8" }, |
| 1011 | 1011 | }, |
| 1012 | .f80 => switch (target.c_type_bit_size(.longdouble)) { | |
| 1012 | .f80 => switch (target.cTypeBitSize(.longdouble)) { | |
| 1013 | 1013 | 80 => return .{ .scalar = cTypeAlign(target, .longdouble) }, |
| 1014 | 1014 | else => return .{ .scalar = Type.u80.abiAlignment(pt) }, |
| 1015 | 1015 | }, |
| 1016 | .f128 => switch (target.c_type_bit_size(.longdouble)) { | |
| 1016 | .f128 => switch (target.cTypeBitSize(.longdouble)) { | |
| 1017 | 1017 | 128 => return .{ .scalar = cTypeAlign(target, .longdouble) }, |
| 1018 | 1018 | else => return .{ .scalar = .@"16" }, |
| 1019 | 1019 | }, |
| ... | ... | @@ -1366,8 +1366,8 @@ pub fn abiSizeAdvanced( |
| 1366 | 1366 | .f32 => return .{ .scalar = 4 }, |
| 1367 | 1367 | .f64 => return .{ .scalar = 8 }, |
| 1368 | 1368 | .f128 => return .{ .scalar = 16 }, |
| 1369 | .f80 => switch (target.c_type_bit_size(.longdouble)) { | |
| 1370 | 80 => return .{ .scalar = target.c_type_byte_size(.longdouble) }, | |
| 1369 | .f80 => switch (target.cTypeBitSize(.longdouble)) { | |
| 1370 | 80 => return .{ .scalar = target.cTypeByteSize(.longdouble) }, | |
| 1371 | 1371 | else => return .{ .scalar = Type.u80.abiSize(pt) }, |
| 1372 | 1372 | }, |
| 1373 | 1373 | |
| ... | ... | @@ -1375,16 +1375,16 @@ pub fn abiSizeAdvanced( |
| 1375 | 1375 | .isize, |
| 1376 | 1376 | => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 1377 | 1377 | |
| 1378 | .c_char => return .{ .scalar = target.c_type_byte_size(.char) }, | |
| 1379 | .c_short => return .{ .scalar = target.c_type_byte_size(.short) }, | |
| 1380 | .c_ushort => return .{ .scalar = target.c_type_byte_size(.ushort) }, | |
| 1381 | .c_int => return .{ .scalar = target.c_type_byte_size(.int) }, | |
| 1382 | .c_uint => return .{ .scalar = target.c_type_byte_size(.uint) }, | |
| 1383 | .c_long => return .{ .scalar = target.c_type_byte_size(.long) }, | |
| 1384 | .c_ulong => return .{ .scalar = target.c_type_byte_size(.ulong) }, | |
| 1385 | .c_longlong => return .{ .scalar = target.c_type_byte_size(.longlong) }, | |
| 1386 | .c_ulonglong => return .{ .scalar = target.c_type_byte_size(.ulonglong) }, | |
| 1387 | .c_longdouble => return .{ .scalar = target.c_type_byte_size(.longdouble) }, | |
| 1378 | .c_char => return .{ .scalar = target.cTypeByteSize(.char) }, | |
| 1379 | .c_short => return .{ .scalar = target.cTypeByteSize(.short) }, | |
| 1380 | .c_ushort => return .{ .scalar = target.cTypeByteSize(.ushort) }, | |
| 1381 | .c_int => return .{ .scalar = target.cTypeByteSize(.int) }, | |
| 1382 | .c_uint => return .{ .scalar = target.cTypeByteSize(.uint) }, | |
| 1383 | .c_long => return .{ .scalar = target.cTypeByteSize(.long) }, | |
| 1384 | .c_ulong => return .{ .scalar = target.cTypeByteSize(.ulong) }, | |
| 1385 | .c_longlong => return .{ .scalar = target.cTypeByteSize(.longlong) }, | |
| 1386 | .c_ulonglong => return .{ .scalar = target.cTypeByteSize(.ulonglong) }, | |
| 1387 | .c_longdouble => return .{ .scalar = target.cTypeByteSize(.longdouble) }, | |
| 1388 | 1388 | |
| 1389 | 1389 | .anyopaque, |
| 1390 | 1390 | .void, |
| ... | ... | @@ -1724,16 +1724,16 @@ pub fn bitSizeAdvanced( |
| 1724 | 1724 | .isize, |
| 1725 | 1725 | => return target.ptrBitWidth(), |
| 1726 | 1726 | |
| 1727 | .c_char => return target.c_type_bit_size(.char), | |
| 1728 | .c_short => return target.c_type_bit_size(.short), | |
| 1729 | .c_ushort => return target.c_type_bit_size(.ushort), | |
| 1730 | .c_int => return target.c_type_bit_size(.int), | |
| 1731 | .c_uint => return target.c_type_bit_size(.uint), | |
| 1732 | .c_long => return target.c_type_bit_size(.long), | |
| 1733 | .c_ulong => return target.c_type_bit_size(.ulong), | |
| 1734 | .c_longlong => return target.c_type_bit_size(.longlong), | |
| 1735 | .c_ulonglong => return target.c_type_bit_size(.ulonglong), | |
| 1736 | .c_longdouble => return target.c_type_bit_size(.longdouble), | |
| 1727 | .c_char => return target.cTypeBitSize(.char), | |
| 1728 | .c_short => return target.cTypeBitSize(.short), | |
| 1729 | .c_ushort => return target.cTypeBitSize(.ushort), | |
| 1730 | .c_int => return target.cTypeBitSize(.int), | |
| 1731 | .c_uint => return target.cTypeBitSize(.uint), | |
| 1732 | .c_long => return target.cTypeBitSize(.long), | |
| 1733 | .c_ulong => return target.cTypeBitSize(.ulong), | |
| 1734 | .c_longlong => return target.cTypeBitSize(.longlong), | |
| 1735 | .c_ulonglong => return target.cTypeBitSize(.ulonglong), | |
| 1736 | .c_longdouble => return target.cTypeBitSize(.longdouble), | |
| 1737 | 1737 | |
| 1738 | 1738 | .bool => return 1, |
| 1739 | 1739 | .void => return 0, |
| ... | ... | @@ -2310,15 +2310,15 @@ pub fn intInfo(starting_ty: Type, mod: *Module) InternPool.Key.IntType { |
| 2310 | 2310 | }, |
| 2311 | 2311 | .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() }, |
| 2312 | 2312 | .isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() }, |
| 2313 | .c_char_type => return .{ .signedness = mod.getTarget().charSignedness(), .bits = target.c_type_bit_size(.char) }, | |
| 2314 | .c_short_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) }, | |
| 2315 | .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) }, | |
| 2316 | .c_int_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) }, | |
| 2317 | .c_uint_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) }, | |
| 2318 | .c_long_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) }, | |
| 2319 | .c_ulong_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) }, | |
| 2320 | .c_longlong_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) }, | |
| 2321 | .c_ulonglong_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) }, | |
| 2313 | .c_char_type => return .{ .signedness = mod.getTarget().charSignedness(), .bits = target.cTypeBitSize(.char) }, | |
| 2314 | .c_short_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.short) }, | |
| 2315 | .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ushort) }, | |
| 2316 | .c_int_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.int) }, | |
| 2317 | .c_uint_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.uint) }, | |
| 2318 | .c_long_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.long) }, | |
| 2319 | .c_ulong_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ulong) }, | |
| 2320 | .c_longlong_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.longlong) }, | |
| 2321 | .c_ulonglong_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ulonglong) }, | |
| 2322 | 2322 | else => switch (ip.indexToKey(ty.toIntern())) { |
| 2323 | 2323 | .int_type => |int_type| return int_type, |
| 2324 | 2324 | .struct_type => ty = Type.fromInterned(ip.loadStructType(ty.toIntern()).backingIntTypeUnordered(ip)), |
| ... | ... | @@ -2427,7 +2427,7 @@ pub fn floatBits(ty: Type, target: Target) u16 { |
| 2427 | 2427 | .f64_type => 64, |
| 2428 | 2428 | .f80_type => 80, |
| 2429 | 2429 | .f128_type, .comptime_float_type => 128, |
| 2430 | .c_longdouble_type => target.c_type_bit_size(.longdouble), | |
| 2430 | .c_longdouble_type => target.cTypeBitSize(.longdouble), | |
| 2431 | 2431 | |
| 2432 | 2432 | else => unreachable, |
| 2433 | 2433 | }; |
| ... | ... | @@ -4025,5 +4025,5 @@ pub fn smallestUnsignedBits(max: u64) u16 { |
| 4025 | 4025 | pub const packed_struct_layout_version = 2; |
| 4026 | 4026 | |
| 4027 | 4027 | fn cTypeAlign(target: Target, c_type: Target.CType) Alignment { |
| 4028 | return Alignment.fromByteUnits(target.c_type_alignment(c_type)); | |
| 4028 | return Alignment.fromByteUnits(target.cTypeAlignment(c_type)); | |
| 4029 | 4029 | } |
src/arch/riscv64/CodeGen.zig+1-1| ... | ... | @@ -8304,7 +8304,7 @@ fn promoteVarArg(func: *Func, ty: Type) Type { |
| 8304 | 8304 | switch (ty.floatBits(func.target.*)) { |
| 8305 | 8305 | 32, 64 => return Type.f64, |
| 8306 | 8306 | else => |float_bits| { |
| 8307 | assert(float_bits == func.target.c_type_bit_size(.longdouble)); | |
| 8307 | assert(float_bits == func.target.cTypeBitSize(.longdouble)); | |
| 8308 | 8308 | return Type.c_longdouble; |
| 8309 | 8309 | }, |
| 8310 | 8310 | } |
src/arch/x86_64/CodeGen.zig+1-1| ... | ... | @@ -19374,7 +19374,7 @@ fn promoteVarArg(self: *Self, ty: Type) Type { |
| 19374 | 19374 | switch (ty.floatBits(self.target.*)) { |
| 19375 | 19375 | 32, 64 => return Type.f64, |
| 19376 | 19376 | else => |float_bits| { |
| 19377 | assert(float_bits == self.target.c_type_bit_size(.longdouble)); | |
| 19377 | assert(float_bits == self.target.cTypeBitSize(.longdouble)); | |
| 19378 | 19378 | return Type.c_longdouble; |
| 19379 | 19379 | }, |
| 19380 | 19380 | } |
src/codegen/c/Type.zig+17-17| ... | ... | @@ -326,9 +326,9 @@ pub fn renderLiteralSuffix(ctype: CType, writer: anytype, pool: *const Pool) @Ty |
| 326 | 326 | pub fn floatActiveBits(ctype: CType, mod: *Module) u16 { |
| 327 | 327 | const target = &mod.resolved_target.result; |
| 328 | 328 | return switch (ctype.index) { |
| 329 | .float => target.c_type_bit_size(.float), | |
| 330 | .double => target.c_type_bit_size(.double), | |
| 331 | .@"long double", .zig_c_longdouble => target.c_type_bit_size(.longdouble), | |
| 329 | .float => target.cTypeBitSize(.float), | |
| 330 | .double => target.cTypeBitSize(.double), | |
| 331 | .@"long double", .zig_c_longdouble => target.cTypeBitSize(.longdouble), | |
| 332 | 332 | .zig_f16 => 16, |
| 333 | 333 | .zig_f32 => 32, |
| 334 | 334 | .zig_f64 => 64, |
| ... | ... | @@ -344,17 +344,17 @@ pub fn byteSize(ctype: CType, pool: *const Pool, mod: *Module) u64 { |
| 344 | 344 | .basic => |basic_info| switch (basic_info) { |
| 345 | 345 | .void => 0, |
| 346 | 346 | .char, .@"signed char", ._Bool, .@"unsigned char", .bool, .uint8_t, .int8_t => 1, |
| 347 | .short => target.c_type_byte_size(.short), | |
| 348 | .int => target.c_type_byte_size(.int), | |
| 349 | .long => target.c_type_byte_size(.long), | |
| 350 | .@"long long" => target.c_type_byte_size(.longlong), | |
| 351 | .@"unsigned short" => target.c_type_byte_size(.ushort), | |
| 352 | .@"unsigned int" => target.c_type_byte_size(.uint), | |
| 353 | .@"unsigned long" => target.c_type_byte_size(.ulong), | |
| 354 | .@"unsigned long long" => target.c_type_byte_size(.ulonglong), | |
| 355 | .float => target.c_type_byte_size(.float), | |
| 356 | .double => target.c_type_byte_size(.double), | |
| 357 | .@"long double" => target.c_type_byte_size(.longdouble), | |
| 347 | .short => target.cTypeByteSize(.short), | |
| 348 | .int => target.cTypeByteSize(.int), | |
| 349 | .long => target.cTypeByteSize(.long), | |
| 350 | .@"long long" => target.cTypeByteSize(.longlong), | |
| 351 | .@"unsigned short" => target.cTypeByteSize(.ushort), | |
| 352 | .@"unsigned int" => target.cTypeByteSize(.uint), | |
| 353 | .@"unsigned long" => target.cTypeByteSize(.ulong), | |
| 354 | .@"unsigned long long" => target.cTypeByteSize(.ulonglong), | |
| 355 | .float => target.cTypeByteSize(.float), | |
| 356 | .double => target.cTypeByteSize(.double), | |
| 357 | .@"long double" => target.cTypeByteSize(.longdouble), | |
| 358 | 358 | .size_t, |
| 359 | 359 | .ptrdiff_t, |
| 360 | 360 | .uintptr_t, |
| ... | ... | @@ -364,11 +364,11 @@ pub fn byteSize(ctype: CType, pool: *const Pool, mod: *Module) u64 { |
| 364 | 364 | .uint32_t, .int32_t, .zig_f32 => 4, |
| 365 | 365 | .uint64_t, .int64_t, .zig_f64 => 8, |
| 366 | 366 | .zig_u128, .zig_i128, .zig_f128 => 16, |
| 367 | .zig_f80 => if (target.c_type_bit_size(.longdouble) == 80) | |
| 368 | target.c_type_byte_size(.longdouble) | |
| 367 | .zig_f80 => if (target.cTypeBitSize(.longdouble) == 80) | |
| 368 | target.cTypeByteSize(.longdouble) | |
| 369 | 369 | else |
| 370 | 370 | 16, |
| 371 | .zig_c_longdouble => target.c_type_byte_size(.longdouble), | |
| 371 | .zig_c_longdouble => target.cTypeByteSize(.longdouble), | |
| 372 | 372 | .va_list => unreachable, |
| 373 | 373 | _ => unreachable, |
| 374 | 374 | }, |
src/codegen/llvm.zig+6-6| ... | ... | @@ -562,9 +562,9 @@ const DataLayoutBuilder = struct { |
| 562 | 562 | .float => &.{ .float, .double, .longdouble }, |
| 563 | 563 | .vector, .aggregate => &.{}, |
| 564 | 564 | })) |cty| { |
| 565 | if (self.target.c_type_bit_size(cty) != size) continue; | |
| 566 | abi = self.target.c_type_alignment(cty) * 8; | |
| 567 | pref = self.target.c_type_preferred_alignment(cty) * 8; | |
| 565 | if (self.target.cTypeBitSize(cty) != size) continue; | |
| 566 | abi = self.target.cTypeAlignment(cty) * 8; | |
| 567 | pref = self.target.cTypePreferredAlignment(cty) * 8; | |
| 568 | 568 | break; |
| 569 | 569 | } |
| 570 | 570 | switch (kind) { |
| ... | ... | @@ -3120,7 +3120,7 @@ pub const Object = struct { |
| 3120 | 3120 | .c_ulong_type, |
| 3121 | 3121 | .c_longlong_type, |
| 3122 | 3122 | .c_ulonglong_type, |
| 3123 | => |tag| try o.builder.intType(target.c_type_bit_size( | |
| 3123 | => |tag| try o.builder.intType(target.cTypeBitSize( | |
| 3124 | 3124 | @field(std.Target.CType, @tagName(tag)["c_".len .. @tagName(tag).len - "_type".len]), |
| 3125 | 3125 | )), |
| 3126 | 3126 | .c_longdouble_type, |
| ... | ... | @@ -11778,8 +11778,8 @@ fn backendSupportsF128(target: std.Target) bool { |
| 11778 | 11778 | fn intrinsicsAllowed(scalar_ty: Type, target: std.Target) bool { |
| 11779 | 11779 | return switch (scalar_ty.toIntern()) { |
| 11780 | 11780 | .f16_type => backendSupportsF16(target), |
| 11781 | .f80_type => (target.c_type_bit_size(.longdouble) == 80) and backendSupportsF80(target), | |
| 11782 | .f128_type => (target.c_type_bit_size(.longdouble) == 128) and backendSupportsF128(target), | |
| 11781 | .f80_type => (target.cTypeBitSize(.longdouble) == 80) and backendSupportsF80(target), | |
| 11782 | .f128_type => (target.cTypeBitSize(.longdouble) == 128) and backendSupportsF128(target), | |
| 11783 | 11783 | else => true, |
| 11784 | 11784 | }; |
| 11785 | 11785 | } |
tools/generate_c_size_and_align_checks.zig+7-7| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | |
| 9 | 9 | const std = @import("std"); |
| 10 | 10 | |
| 11 | fn c_name(ty: std.Target.CType) []const u8 { | |
| 11 | fn cName(ty: std.Target.CType) []const u8 { | |
| 12 | 12 | return switch (ty) { |
| 13 | 13 | .char => "char", |
| 14 | 14 | .short => "short", |
| ... | ... | @@ -46,16 +46,16 @@ pub fn main() !void { |
| 46 | 46 | inline for (@typeInfo(std.Target.CType).Enum.fields) |field| { |
| 47 | 47 | const c_type: std.Target.CType = @enumFromInt(field.value); |
| 48 | 48 | try stdout.print("_Static_assert(sizeof({0s}) == {1d}, \"sizeof({0s}) == {1d}\");\n", .{ |
| 49 | c_name(c_type), | |
| 50 | target.c_type_byte_size(c_type), | |
| 49 | cName(c_type), | |
| 50 | target.cTypeByteSize(c_type), | |
| 51 | 51 | }); |
| 52 | 52 | try stdout.print("_Static_assert(_Alignof({0s}) == {1d}, \"_Alignof({0s}) == {1d}\");\n", .{ |
| 53 | c_name(c_type), | |
| 54 | target.c_type_alignment(c_type), | |
| 53 | cName(c_type), | |
| 54 | target.cTypeAlignment(c_type), | |
| 55 | 55 | }); |
| 56 | 56 | try stdout.print("_Static_assert(__alignof({0s}) == {1d}, \"__alignof({0s}) == {1d}\");\n\n", .{ |
| 57 | c_name(c_type), | |
| 58 | target.c_type_preferred_alignment(c_type), | |
| 57 | cName(c_type), | |
| 58 | target.cTypePreferredAlignment(c_type), | |
| 59 | 59 | }); |
| 60 | 60 | } |
| 61 | 61 | } |