authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-27 21:15:22-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-10-27 21:15:22-04:00
log1d1c7ae5de3e981099522a8610764a6595b1b7a1
treeb879cc51fd26ff9d0c12e5b7a05026639968bfdd
parentd03c47bf85b17f7727d2f1fe5bd497b311c9eba7
parent4ecc384f99e5f4c5a320714484866fb48699245f
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #13257 from topolarity/ctype-fixes

stage 2: Update `CType` size/alignment

41 files changed, 542 insertions(+), 355 deletions(-)

lib/compiler_rt/addtf3.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__addkf3, .{ .name = "__addkf3", .linkage = common.linkage });
8 @export(__addtf3, .{ .name = "__addkf3", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage });
11 } else {
12 @export(__addtf3, .{ .name = "__addtf3", .linkage = common.linkage });
1311 }
12 @export(__addtf3, .{ .name = "__addtf3", .linkage = common.linkage });
1413}
1514
1615pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 {
1716 return addf3(f128, a, b);
1817}
1918
20fn __addkf3(a: f128, b: f128) callconv(.C) f128 {
21 return addf3(f128, a, b);
22}
23
2419fn _Qp_add(c: *f128, a: *f128, b: *f128) callconv(.C) void {
2520 c.* = addf3(f128, a.*, b.*);
2621}
lib/compiler_rt/ceil.zig+4-2
......@@ -18,8 +18,10 @@ comptime {
1818 @export(ceilf, .{ .name = "ceilf", .linkage = common.linkage });
1919 @export(ceil, .{ .name = "ceil", .linkage = common.linkage });
2020 @export(__ceilx, .{ .name = "__ceilx", .linkage = common.linkage });
21 const ceilq_sym_name = if (common.want_ppc_abi) "ceilf128" else "ceilq";
22 @export(ceilq, .{ .name = ceilq_sym_name, .linkage = common.linkage });
21 if (common.want_ppc_abi) {
22 @export(ceilq, .{ .name = "ceilf128", .linkage = common.linkage });
23 }
24 @export(ceilq, .{ .name = "ceilq", .linkage = common.linkage });
2325 @export(ceill, .{ .name = "ceill", .linkage = common.linkage });
2426}
2527
lib/compiler_rt/cmptf2.zig+9-26
......@@ -7,10 +7,10 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_ppc_abi) {
10 @export(__eqkf2, .{ .name = "__eqkf2", .linkage = common.linkage });
11 @export(__nekf2, .{ .name = "__nekf2", .linkage = common.linkage });
12 @export(__ltkf2, .{ .name = "__ltkf2", .linkage = common.linkage });
13 @export(__lekf2, .{ .name = "__lekf2", .linkage = common.linkage });
10 @export(__eqtf2, .{ .name = "__eqkf2", .linkage = common.linkage });
11 @export(__netf2, .{ .name = "__nekf2", .linkage = common.linkage });
12 @export(__lttf2, .{ .name = "__ltkf2", .linkage = common.linkage });
13 @export(__letf2, .{ .name = "__lekf2", .linkage = common.linkage });
1414 } else if (common.want_sparc_abi) {
1515 @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage });
1616 @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage });
......@@ -19,13 +19,12 @@ comptime {
1919 @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage });
2020 @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage });
2121 @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage });
22 } else {
23 @export(__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage });
24 @export(__netf2, .{ .name = "__netf2", .linkage = common.linkage });
25 @export(__letf2, .{ .name = "__letf2", .linkage = common.linkage });
26 @export(__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage });
27 @export(__lttf2, .{ .name = "__lttf2", .linkage = common.linkage });
2822 }
23 @export(__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage });
24 @export(__netf2, .{ .name = "__netf2", .linkage = common.linkage });
25 @export(__letf2, .{ .name = "__letf2", .linkage = common.linkage });
26 @export(__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage });
27 @export(__lttf2, .{ .name = "__lttf2", .linkage = common.linkage });
2928}
3029
3130/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
......@@ -64,22 +63,6 @@ fn __lttf2(a: f128, b: f128) callconv(.C) i32 {
6463 return __cmptf2(a, b);
6564}
6665
67fn __eqkf2(a: f128, b: f128) callconv(.C) i32 {
68 return __cmptf2(a, b);
69}
70
71fn __nekf2(a: f128, b: f128) callconv(.C) i32 {
72 return __cmptf2(a, b);
73}
74
75fn __ltkf2(a: f128, b: f128) callconv(.C) i32 {
76 return __cmptf2(a, b);
77}
78
79fn __lekf2(a: f128, b: f128) callconv(.C) i32 {
80 return __cmptf2(a, b);
81}
82
8366const SparcFCMP = enum(i32) {
8467 Equal = 0,
8568 Less = 1,
lib/compiler_rt/cos.zig+4-2
......@@ -16,8 +16,10 @@ comptime {
1616 @export(cosf, .{ .name = "cosf", .linkage = common.linkage });
1717 @export(cos, .{ .name = "cos", .linkage = common.linkage });
1818 @export(__cosx, .{ .name = "__cosx", .linkage = common.linkage });
19 const cosq_sym_name = if (common.want_ppc_abi) "cosf128" else "cosq";
20 @export(cosq, .{ .name = cosq_sym_name, .linkage = common.linkage });
19 if (common.want_ppc_abi) {
20 @export(cosq, .{ .name = "cosf128", .linkage = common.linkage });
21 }
22 @export(cosq, .{ .name = "cosq", .linkage = common.linkage });
2123 @export(cosl, .{ .name = "cosl", .linkage = common.linkage });
2224}
2325
lib/compiler_rt/divtf3.zig+3-7
......@@ -9,22 +9,18 @@ pub const panic = common.panic;
99
1010comptime {
1111 if (common.want_ppc_abi) {
12 @export(__divkf3, .{ .name = "__divkf3", .linkage = common.linkage });
12 // TODO: why did this not error?
13 @export(__divtf3, .{ .name = "__divkf3", .linkage = common.linkage });
1314 } else if (common.want_sparc_abi) {
1415 @export(_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage });
15 } else {
16 @export(__divtf3, .{ .name = "__divtf3", .linkage = common.linkage });
1716 }
17 @export(__divtf3, .{ .name = "__divtf3", .linkage = common.linkage });
1818}
1919
2020pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
2121 return div(a, b);
2222}
2323
24fn __divkf3(a: f128, b: f128) callconv(.C) f128 {
25 return div(a, b);
26}
27
2824fn _Qp_div(c: *f128, a: *const f128, b: *const f128) callconv(.C) void {
2925 c.* = div(a.*, b.*);
3026}
lib/compiler_rt/exp.zig+4-2
......@@ -18,8 +18,10 @@ comptime {
1818 @export(expf, .{ .name = "expf", .linkage = common.linkage });
1919 @export(exp, .{ .name = "exp", .linkage = common.linkage });
2020 @export(__expx, .{ .name = "__expx", .linkage = common.linkage });
21 const expq_sym_name = if (common.want_ppc_abi) "expf128" else "expq";
22 @export(expq, .{ .name = expq_sym_name, .linkage = common.linkage });
21 if (common.want_ppc_abi) {
22 @export(expq, .{ .name = "expf128", .linkage = common.linkage });
23 }
24 @export(expq, .{ .name = "expq", .linkage = common.linkage });
2325 @export(expl, .{ .name = "expl", .linkage = common.linkage });
2426}
2527
lib/compiler_rt/exp2.zig+4-2
......@@ -18,8 +18,10 @@ comptime {
1818 @export(exp2f, .{ .name = "exp2f", .linkage = common.linkage });
1919 @export(exp2, .{ .name = "exp2", .linkage = common.linkage });
2020 @export(__exp2x, .{ .name = "__exp2x", .linkage = common.linkage });
21 const exp2q_sym_name = if (common.want_ppc_abi) "exp2f128" else "exp2q";
22 @export(exp2q, .{ .name = exp2q_sym_name, .linkage = common.linkage });
21 if (common.want_ppc_abi) {
22 @export(exp2q, .{ .name = "exp2f128", .linkage = common.linkage });
23 }
24 @export(exp2q, .{ .name = "exp2q", .linkage = common.linkage });
2325 @export(exp2l, .{ .name = "exp2l", .linkage = common.linkage });
2426}
2527
lib/compiler_rt/extenddftf2.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__extenddfkf2, .{ .name = "__extenddfkf2", .linkage = common.linkage });
8 @export(__extenddftf2, .{ .name = "__extenddfkf2", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = common.linkage });
11 } else {
12 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage });
1311 }
12 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage });
1413}
1514
1615pub fn __extenddftf2(a: f64) callconv(.C) f128 {
1716 return extendf(f128, f64, @bitCast(u64, a));
1817}
1918
20fn __extenddfkf2(a: f64) callconv(.C) f128 {
21 return extendf(f128, f64, @bitCast(u64, a));
22}
23
2419fn _Qp_dtoq(c: *f128, a: f64) callconv(.C) void {
2520 c.* = extendf(f128, f64, @bitCast(u64, a));
2621}
lib/compiler_rt/extendsftf2.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__extendsfkf2, .{ .name = "__extendsfkf2", .linkage = common.linkage });
8 @export(__extendsftf2, .{ .name = "__extendsfkf2", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage });
11 } else {
12 @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage });
1311 }
12 @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage });
1413}
1514
1615pub fn __extendsftf2(a: f32) callconv(.C) f128 {
1716 return extendf(f128, f32, @bitCast(u32, a));
1817}
1918
20fn __extendsfkf2(a: f32) callconv(.C) f128 {
21 return extendf(f128, f32, @bitCast(u32, a));
22}
23
2419fn _Qp_stoq(c: *f128, a: f32) callconv(.C) void {
2520 c.* = extendf(f128, f32, @bitCast(u32, a));
2621}
lib/compiler_rt/fabs.zig+4-2
......@@ -10,8 +10,10 @@ comptime {
1010 @export(fabsf, .{ .name = "fabsf", .linkage = common.linkage });
1111 @export(fabs, .{ .name = "fabs", .linkage = common.linkage });
1212 @export(__fabsx, .{ .name = "__fabsx", .linkage = common.linkage });
13 const fabsq_sym_name = if (common.want_ppc_abi) "fabsf128" else "fabsq";
14 @export(fabsq, .{ .name = fabsq_sym_name, .linkage = common.linkage });
13 if (common.want_ppc_abi) {
14 @export(fabsq, .{ .name = "fabsf128", .linkage = common.linkage });
15 }
16 @export(fabsq, .{ .name = "fabsq", .linkage = common.linkage });
1517 @export(fabsl, .{ .name = "fabsl", .linkage = common.linkage });
1618}
1719
lib/compiler_rt/fixtfdi.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__fixkfdi, .{ .name = "__fixkfdi", .linkage = common.linkage });
8 @export(__fixtfdi, .{ .name = "__fixkfdi", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = common.linkage });
11 } else {
12 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage });
1311 }
12 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage });
1413}
1514
1615pub fn __fixtfdi(a: f128) callconv(.C) i64 {
1716 return floatToInt(i64, a);
1817}
1918
20fn __fixkfdi(a: f128) callconv(.C) i64 {
21 return floatToInt(i64, a);
22}
23
2419fn _Qp_qtox(a: *const f128) callconv(.C) i64 {
2520 return floatToInt(i64, a.*);
2621}
lib/compiler_rt/fixtfsi.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__fixkfsi, .{ .name = "__fixkfsi", .linkage = common.linkage });
8 @export(__fixtfsi, .{ .name = "__fixkfsi", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = common.linkage });
11 } else {
12 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage });
1311 }
12 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage });
1413}
1514
1615pub fn __fixtfsi(a: f128) callconv(.C) i32 {
1716 return floatToInt(i32, a);
1817}
1918
20fn __fixkfsi(a: f128) callconv(.C) i32 {
21 return floatToInt(i32, a);
22}
23
2419fn _Qp_qtoi(a: *const f128) callconv(.C) i32 {
2520 return floatToInt(i32, a.*);
2621}
lib/compiler_rt/fixunstfdi.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__fixunskfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage });
8 @export(__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage });
11 } else {
12 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage });
1311 }
12 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage });
1413}
1514
1615pub fn __fixunstfdi(a: f128) callconv(.C) u64 {
1716 return floatToInt(u64, a);
1817}
1918
20fn __fixunskfdi(a: f128) callconv(.C) u64 {
21 return floatToInt(u64, a);
22}
23
2419fn _Qp_qtoux(a: *const f128) callconv(.C) u64 {
2520 return floatToInt(u64, a.*);
2621}
lib/compiler_rt/fixunstfsi.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__fixunskfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage });
8 @export(__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage });
11 } else {
12 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage });
1311 }
12 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage });
1413}
1514
1615pub fn __fixunstfsi(a: f128) callconv(.C) u32 {
1716 return floatToInt(u32, a);
1817}
1918
20fn __fixunskfsi(a: f128) callconv(.C) u32 {
21 return floatToInt(u32, a);
22}
23
2419fn _Qp_qtoui(a: *const f128) callconv(.C) u32 {
2520 return floatToInt(u32, a.*);
2621}
lib/compiler_rt/floatditf.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__floatdikf, .{ .name = "__floatdikf", .linkage = common.linkage });
8 @export(__floatditf, .{ .name = "__floatdikf", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = common.linkage });
11 } else {
12 @export(__floatditf, .{ .name = "__floatditf", .linkage = common.linkage });
1311 }
12 @export(__floatditf, .{ .name = "__floatditf", .linkage = common.linkage });
1413}
1514
1615pub fn __floatditf(a: i64) callconv(.C) f128 {
1716 return intToFloat(f128, a);
1817}
1918
20fn __floatdikf(a: i64) callconv(.C) f128 {
21 return intToFloat(f128, a);
22}
23
2419fn _Qp_xtoq(c: *f128, a: i64) callconv(.C) void {
2520 c.* = intToFloat(f128, a);
2621}
lib/compiler_rt/floatsitf.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__floatsikf, .{ .name = "__floatsikf", .linkage = common.linkage });
8 @export(__floatsitf, .{ .name = "__floatsikf", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage });
11 } else {
12 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage });
1311 }
12 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage });
1413}
1514
1615pub fn __floatsitf(a: i32) callconv(.C) f128 {
1716 return intToFloat(f128, a);
1817}
1918
20fn __floatsikf(a: i32) callconv(.C) f128 {
21 return intToFloat(f128, a);
22}
23
2419fn _Qp_itoq(c: *f128, a: i32) callconv(.C) void {
2520 c.* = intToFloat(f128, a);
2621}
lib/compiler_rt/floatunditf.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__floatundikf, .{ .name = "__floatundikf", .linkage = common.linkage });
8 @export(__floatunditf, .{ .name = "__floatundikf", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage });
11 } else {
12 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage });
1311 }
12 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage });
1413}
1514
1615pub fn __floatunditf(a: u64) callconv(.C) f128 {
1716 return intToFloat(f128, a);
1817}
1918
20fn __floatundikf(a: u64) callconv(.C) f128 {
21 return intToFloat(f128, a);
22}
23
2419fn _Qp_uxtoq(c: *f128, a: u64) callconv(.C) void {
2520 c.* = intToFloat(f128, a);
2621}
lib/compiler_rt/floatunsitf.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__floatunsikf, .{ .name = "__floatunsikf", .linkage = common.linkage });
8 @export(__floatunsitf, .{ .name = "__floatunsikf", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = common.linkage });
11 } else {
12 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage });
1311 }
12 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage });
1413}
1514
1615pub fn __floatunsitf(a: u32) callconv(.C) f128 {
1716 return intToFloat(f128, a);
1817}
1918
20fn __floatunsikf(a: u32) callconv(.C) f128 {
21 return intToFloat(f128, a);
22}
23
2419fn _Qp_uitoq(c: *f128, a: u32) callconv(.C) void {
2520 c.* = intToFloat(f128, a);
2621}
lib/compiler_rt/floatuntitf.zig+5-4
......@@ -5,12 +5,13 @@ const intToFloat = @import("./int_to_float.zig").intToFloat;
55pub const panic = common.panic;
66
77comptime {
8 const symbol_name = if (common.want_ppc_abi) "__floatuntikf" else "__floatuntitf";
9
108 if (common.want_windows_v2u64_abi) {
11 @export(__floatuntitf_windows_x86_64, .{ .name = symbol_name, .linkage = common.linkage });
9 @export(__floatuntitf_windows_x86_64, .{ .name = "__floatuntitf", .linkage = common.linkage });
1210 } else {
13 @export(__floatuntitf, .{ .name = symbol_name, .linkage = common.linkage });
11 if (common.want_ppc_abi) {
12 @export(__floatuntitf, .{ .name = "__floatuntikf", .linkage = common.linkage });
13 }
14 @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = common.linkage });
1415 }
1516}
1617
lib/compiler_rt/floor.zig+4-2
......@@ -18,8 +18,10 @@ comptime {
1818 @export(floorf, .{ .name = "floorf", .linkage = common.linkage });
1919 @export(floor, .{ .name = "floor", .linkage = common.linkage });
2020 @export(__floorx, .{ .name = "__floorx", .linkage = common.linkage });
21 const floorq_sym_name = if (common.want_ppc_abi) "floorf128" else "floorq";
22 @export(floorq, .{ .name = floorq_sym_name, .linkage = common.linkage });
21 if (common.want_ppc_abi) {
22 @export(floorq, .{ .name = "floorf128", .linkage = common.linkage });
23 }
24 @export(floorq, .{ .name = "floorq", .linkage = common.linkage });
2325 @export(floorl, .{ .name = "floorl", .linkage = common.linkage });
2426}
2527
lib/compiler_rt/fma.zig+4-2
......@@ -19,8 +19,10 @@ comptime {
1919 @export(fmaf, .{ .name = "fmaf", .linkage = common.linkage });
2020 @export(fma, .{ .name = "fma", .linkage = common.linkage });
2121 @export(__fmax, .{ .name = "__fmax", .linkage = common.linkage });
22 const fmaq_sym_name = if (common.want_ppc_abi) "fmaf128" else "fmaq";
23 @export(fmaq, .{ .name = fmaq_sym_name, .linkage = common.linkage });
22 if (common.want_ppc_abi) {
23 @export(fmaq, .{ .name = "fmaf128", .linkage = common.linkage });
24 }
25 @export(fmaq, .{ .name = "fmaq", .linkage = common.linkage });
2426 @export(fmal, .{ .name = "fmal", .linkage = common.linkage });
2527}
2628
lib/compiler_rt/fmax.zig+4-2
......@@ -11,8 +11,10 @@ comptime {
1111 @export(fmaxf, .{ .name = "fmaxf", .linkage = common.linkage });
1212 @export(fmax, .{ .name = "fmax", .linkage = common.linkage });
1313 @export(__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage });
14 const fmaxq_sym_name = if (common.want_ppc_abi) "fmaxf128" else "fmaxq";
15 @export(fmaxq, .{ .name = fmaxq_sym_name, .linkage = common.linkage });
14 if (common.want_ppc_abi) {
15 @export(fmaxq, .{ .name = "fmaxf128", .linkage = common.linkage });
16 }
17 @export(fmaxq, .{ .name = "fmaxq", .linkage = common.linkage });
1618 @export(fmaxl, .{ .name = "fmaxl", .linkage = common.linkage });
1719}
1820
lib/compiler_rt/fmin.zig+4-2
......@@ -11,8 +11,10 @@ comptime {
1111 @export(fminf, .{ .name = "fminf", .linkage = common.linkage });
1212 @export(fmin, .{ .name = "fmin", .linkage = common.linkage });
1313 @export(__fminx, .{ .name = "__fminx", .linkage = common.linkage });
14 const fminq_sym_name = if (common.want_ppc_abi) "fminf128" else "fminq";
15 @export(fminq, .{ .name = fminq_sym_name, .linkage = common.linkage });
14 if (common.want_ppc_abi) {
15 @export(fminq, .{ .name = "fminf128", .linkage = common.linkage });
16 }
17 @export(fminq, .{ .name = "fminq", .linkage = common.linkage });
1618 @export(fminl, .{ .name = "fminl", .linkage = common.linkage });
1719}
1820
lib/compiler_rt/fmod.zig+4-2
......@@ -13,8 +13,10 @@ comptime {
1313 @export(fmodf, .{ .name = "fmodf", .linkage = common.linkage });
1414 @export(fmod, .{ .name = "fmod", .linkage = common.linkage });
1515 @export(__fmodx, .{ .name = "__fmodx", .linkage = common.linkage });
16 const fmodq_sym_name = if (common.want_ppc_abi) "fmodf128" else "fmodq";
17 @export(fmodq, .{ .name = fmodq_sym_name, .linkage = common.linkage });
16 if (common.want_ppc_abi) {
17 @export(fmodq, .{ .name = "fmodf128", .linkage = common.linkage });
18 }
19 @export(fmodq, .{ .name = "fmodq", .linkage = common.linkage });
1820 @export(fmodl, .{ .name = "fmodl", .linkage = common.linkage });
1921}
2022
lib/compiler_rt/getf2.zig+4-13
......@@ -7,15 +7,14 @@ pub const panic = common.panic;
77
88comptime {
99 if (common.want_ppc_abi) {
10 @export(__gekf2, .{ .name = "__gekf2", .linkage = common.linkage });
11 @export(__gtkf2, .{ .name = "__gtkf2", .linkage = common.linkage });
10 @export(__getf2, .{ .name = "__gekf2", .linkage = common.linkage });
11 @export(__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage });
1212 } else if (common.want_sparc_abi) {
1313 // These exports are handled in cmptf2.zig because gt and ge on sparc
1414 // are based on calling _Qp_cmp.
15 } else {
16 @export(__getf2, .{ .name = "__getf2", .linkage = common.linkage });
17 @export(__gttf2, .{ .name = "__gttf2", .linkage = common.linkage });
1815 }
16 @export(__getf2, .{ .name = "__getf2", .linkage = common.linkage });
17 @export(__gttf2, .{ .name = "__gttf2", .linkage = common.linkage });
1918}
2019
2120/// "These functions return a value greater than or equal to zero if neither
......@@ -29,11 +28,3 @@ fn __getf2(a: f128, b: f128) callconv(.C) i32 {
2928fn __gttf2(a: f128, b: f128) callconv(.C) i32 {
3029 return __getf2(a, b);
3130}
32
33fn __gekf2(a: f128, b: f128) callconv(.C) i32 {
34 return __getf2(a, b);
35}
36
37fn __gtkf2(a: f128, b: f128) callconv(.C) i32 {
38 return __getf2(a, b);
39}
lib/compiler_rt/log.zig+4-2
......@@ -18,8 +18,10 @@ comptime {
1818 @export(logf, .{ .name = "logf", .linkage = common.linkage });
1919 @export(log, .{ .name = "log", .linkage = common.linkage });
2020 @export(__logx, .{ .name = "__logx", .linkage = common.linkage });
21 const logq_sym_name = if (common.want_ppc_abi) "logf128" else "logq";
22 @export(logq, .{ .name = logq_sym_name, .linkage = common.linkage });
21 if (common.want_ppc_abi) {
22 @export(logq, .{ .name = "logf128", .linkage = common.linkage });
23 }
24 @export(logq, .{ .name = "logq", .linkage = common.linkage });
2325 @export(logl, .{ .name = "logl", .linkage = common.linkage });
2426}
2527
lib/compiler_rt/log10.zig+4-2
......@@ -19,8 +19,10 @@ comptime {
1919 @export(log10f, .{ .name = "log10f", .linkage = common.linkage });
2020 @export(log10, .{ .name = "log10", .linkage = common.linkage });
2121 @export(__log10x, .{ .name = "__log10x", .linkage = common.linkage });
22 const log10q_sym_name = if (common.want_ppc_abi) "log10f128" else "log10q";
23 @export(log10q, .{ .name = log10q_sym_name, .linkage = common.linkage });
22 if (common.want_ppc_abi) {
23 @export(log10q, .{ .name = "log10f128", .linkage = common.linkage });
24 }
25 @export(log10q, .{ .name = "log10q", .linkage = common.linkage });
2426 @export(log10l, .{ .name = "log10l", .linkage = common.linkage });
2527}
2628
lib/compiler_rt/log2.zig+4-2
......@@ -19,8 +19,10 @@ comptime {
1919 @export(log2f, .{ .name = "log2f", .linkage = common.linkage });
2020 @export(log2, .{ .name = "log2", .linkage = common.linkage });
2121 @export(__log2x, .{ .name = "__log2x", .linkage = common.linkage });
22 const log2q_sym_name = if (common.want_ppc_abi) "log2f128" else "log2q";
23 @export(log2q, .{ .name = log2q_sym_name, .linkage = common.linkage });
22 if (common.want_ppc_abi) {
23 @export(log2q, .{ .name = "log2f128", .linkage = common.linkage });
24 }
25 @export(log2q, .{ .name = "log2q", .linkage = common.linkage });
2426 @export(log2l, .{ .name = "log2l", .linkage = common.linkage });
2527}
2628
lib/compiler_rt/multf3.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__mulkf3, .{ .name = "__mulkf3", .linkage = common.linkage });
8 @export(__multf3, .{ .name = "__mulkf3", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage });
11 } else {
12 @export(__multf3, .{ .name = "__multf3", .linkage = common.linkage });
1311 }
12 @export(__multf3, .{ .name = "__multf3", .linkage = common.linkage });
1413}
1514
1615pub fn __multf3(a: f128, b: f128) callconv(.C) f128 {
1716 return mulf3(f128, a, b);
1817}
1918
20fn __mulkf3(a: f128, b: f128) callconv(.C) f128 {
21 return mulf3(f128, a, b);
22}
23
2419fn _Qp_mul(c: *f128, a: *const f128, b: *const f128) callconv(.C) void {
2520 c.* = mulf3(f128, a.*, b.*);
2621}
lib/compiler_rt/round.zig+4-2
......@@ -18,8 +18,10 @@ comptime {
1818 @export(roundf, .{ .name = "roundf", .linkage = common.linkage });
1919 @export(round, .{ .name = "round", .linkage = common.linkage });
2020 @export(__roundx, .{ .name = "__roundx", .linkage = common.linkage });
21 const roundq_sym_name = if (common.want_ppc_abi) "roundf128" else "roundq";
22 @export(roundq, .{ .name = roundq_sym_name, .linkage = common.linkage });
21 if (common.want_ppc_abi) {
22 @export(roundq, .{ .name = "roundf128", .linkage = common.linkage });
23 }
24 @export(roundq, .{ .name = "roundq", .linkage = common.linkage });
2325 @export(roundl, .{ .name = "roundl", .linkage = common.linkage });
2426}
2527
lib/compiler_rt/sin.zig+4-2
......@@ -22,8 +22,10 @@ comptime {
2222 @export(sinf, .{ .name = "sinf", .linkage = common.linkage });
2323 @export(sin, .{ .name = "sin", .linkage = common.linkage });
2424 @export(__sinx, .{ .name = "__sinx", .linkage = common.linkage });
25 const sinq_sym_name = if (common.want_ppc_abi) "sinf128" else "sinq";
26 @export(sinq, .{ .name = sinq_sym_name, .linkage = common.linkage });
25 if (common.want_ppc_abi) {
26 @export(sinq, .{ .name = "sinf128", .linkage = common.linkage });
27 }
28 @export(sinq, .{ .name = "sinq", .linkage = common.linkage });
2729 @export(sinl, .{ .name = "sinl", .linkage = common.linkage });
2830}
2931
lib/compiler_rt/sincos.zig+4-2
......@@ -14,8 +14,10 @@ comptime {
1414 @export(sincosf, .{ .name = "sincosf", .linkage = common.linkage });
1515 @export(sincos, .{ .name = "sincos", .linkage = common.linkage });
1616 @export(__sincosx, .{ .name = "__sincosx", .linkage = common.linkage });
17 const sincosq_sym_name = if (common.want_ppc_abi) "sincosf128" else "sincosq";
18 @export(sincosq, .{ .name = sincosq_sym_name, .linkage = common.linkage });
17 if (common.want_ppc_abi) {
18 @export(sincosq, .{ .name = "sincosf128", .linkage = common.linkage });
19 }
20 @export(sincosq, .{ .name = "sincosq", .linkage = common.linkage });
1921 @export(sincosl, .{ .name = "sincosl", .linkage = common.linkage });
2022}
2123
lib/compiler_rt/sqrt.zig+4-2
......@@ -11,8 +11,10 @@ comptime {
1111 @export(sqrtf, .{ .name = "sqrtf", .linkage = common.linkage });
1212 @export(sqrt, .{ .name = "sqrt", .linkage = common.linkage });
1313 @export(__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage });
14 const sqrtq_sym_name = if (common.want_ppc_abi) "sqrtf128" else "sqrtq";
15 @export(sqrtq, .{ .name = sqrtq_sym_name, .linkage = common.linkage });
14 if (common.want_ppc_abi) {
15 @export(sqrtq, .{ .name = "sqrtf128", .linkage = common.linkage });
16 }
17 @export(sqrtq, .{ .name = "sqrtq", .linkage = common.linkage });
1618 @export(sqrtl, .{ .name = "sqrtl", .linkage = common.linkage });
1719}
1820
lib/compiler_rt/subtf3.zig+2-7
......@@ -4,22 +4,17 @@ pub const panic = common.panic;
44
55comptime {
66 if (common.want_ppc_abi) {
7 @export(__subkf3, .{ .name = "__subkf3", .linkage = common.linkage });
7 @export(__subtf3, .{ .name = "__subkf3", .linkage = common.linkage });
88 } else if (common.want_sparc_abi) {
99 @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage });
10 } else {
11 @export(__subtf3, .{ .name = "__subtf3", .linkage = common.linkage });
1210 }
11 @export(__subtf3, .{ .name = "__subtf3", .linkage = common.linkage });
1312}
1413
1514pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 {
1615 return sub(a, b);
1716}
1817
19fn __subkf3(a: f128, b: f128) callconv(.C) f128 {
20 return sub(a, b);
21}
22
2318fn _Qp_sub(c: *f128, a: *const f128, b: *const f128) callconv(.C) void {
2419 c.* = sub(a.*, b.*);
2520}
lib/compiler_rt/trunc.zig+4-2
......@@ -18,8 +18,10 @@ comptime {
1818 @export(truncf, .{ .name = "truncf", .linkage = common.linkage });
1919 @export(trunc, .{ .name = "trunc", .linkage = common.linkage });
2020 @export(__truncx, .{ .name = "__truncx", .linkage = common.linkage });
21 const truncq_sym_name = if (common.want_ppc_abi) "truncf128" else "truncq";
22 @export(truncq, .{ .name = truncq_sym_name, .linkage = common.linkage });
21 if (common.want_ppc_abi) {
22 @export(truncq, .{ .name = "truncf128", .linkage = common.linkage });
23 }
24 @export(truncq, .{ .name = "truncq", .linkage = common.linkage });
2325 @export(truncl, .{ .name = "truncl", .linkage = common.linkage });
2426}
2527
lib/compiler_rt/trunctfdf2.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__trunckfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage });
8 @export(__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage });
11 } else {
12 @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage });
1311 }
12 @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage });
1413}
1514
1615pub fn __trunctfdf2(a: f128) callconv(.C) f64 {
1716 return truncf(f64, f128, a);
1817}
1918
20fn __trunckfdf2(a: f128) callconv(.C) f64 {
21 return truncf(f64, f128, a);
22}
23
2419fn _Qp_qtod(a: *const f128) callconv(.C) f64 {
2520 return truncf(f64, f128, a.*);
2621}
lib/compiler_rt/trunctfsf2.zig+2-7
......@@ -5,22 +5,17 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__trunckfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage });
8 @export(__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = common.linkage });
11 } else {
12 @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage });
1311 }
12 @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage });
1413}
1514
1615pub fn __trunctfsf2(a: f128) callconv(.C) f32 {
1716 return truncf(f32, f128, a);
1817}
1918
20fn __trunckfsf2(a: f128) callconv(.C) f32 {
21 return truncf(f32, f128, a);
22}
23
2419fn _Qp_qtos(a: *const f128) callconv(.C) f32 {
2520 return truncf(f32, f128, a.*);
2621}
lib/compiler_rt/unordtf2.zig+2-7
......@@ -5,19 +5,14 @@ pub const panic = common.panic;
55
66comptime {
77 if (common.want_ppc_abi) {
8 @export(__unordkf2, .{ .name = "__unordkf2", .linkage = common.linkage });
8 @export(__unordtf2, .{ .name = "__unordkf2", .linkage = common.linkage });
99 } else if (common.want_sparc_abi) {
1010 // These exports are handled in cmptf2.zig because unordered comparisons
1111 // are based on calling _Qp_cmp.
12 } else {
13 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage });
1412 }
13 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage });
1514}
1615
1716fn __unordtf2(a: f128, b: f128) callconv(.C) i32 {
1817 return comparef.unordcmp(f128, a, b);
1918}
20
21fn __unordkf2(a: f128, b: f128) callconv(.C) i32 {
22 return comparef.unordcmp(f128, a, b);
23}
lib/std/target.zig+1-66
......@@ -1780,71 +1780,6 @@ pub const Target = struct {
17801780 };
17811781 }
17821782
1783 pub inline fn longDoubleIs(target: Target, comptime F: type) bool {
1784 if (target.abi == .msvc or (target.abi == .android and target.cpu.arch == .i386)) {
1785 return F == f64;
1786 }
1787 return switch (F) {
1788 f128 => switch (target.cpu.arch) {
1789 .aarch64 => {
1790 // According to Apple's official guide:
1791 // > The long double type is a double precision IEEE754 binary floating-point type,
1792 // > which makes it identical to the double type. This behavior contrasts to the
1793 // > standard specification, in which a long double is a quad-precision, IEEE754
1794 // > binary, floating-point type.
1795 // https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
1796 return !target.isDarwin();
1797 },
1798
1799 .riscv64,
1800 .aarch64_be,
1801 .aarch64_32,
1802 .s390x,
1803 .mips64,
1804 .mips64el,
1805 .sparc,
1806 .sparc64,
1807 .sparcel,
1808 .powerpc,
1809 .powerpcle,
1810 .powerpc64,
1811 .powerpc64le,
1812 .wasm32,
1813 .wasm64,
1814 => true,
1815
1816 else => false,
1817 },
1818 f80 => switch (target.cpu.arch) {
1819 .x86_64, .i386 => true,
1820 else => false,
1821 },
1822 f64 => switch (target.cpu.arch) {
1823 .aarch64 => target.isDarwin(),
1824
1825 .x86_64,
1826 .i386,
1827 .riscv64,
1828 .aarch64_be,
1829 .aarch64_32,
1830 .s390x,
1831 .mips64,
1832 .mips64el,
1833 .sparc,
1834 .sparc64,
1835 .sparcel,
1836 .powerpc,
1837 .powerpcle,
1838 .powerpc64,
1839 .powerpc64le,
1840 => false,
1841
1842 else => true,
1843 },
1844 else => false,
1845 };
1846 }
1847
18481783 pub inline fn maxIntAlignment(target: Target) u16 {
18491784 return switch (target.cpu.arch) {
18501785 .avr => 1,
......@@ -1872,7 +1807,7 @@ pub const Target = struct {
18721807 => 8,
18731808
18741809 .i386 => return switch (target.os.tag) {
1875 .windows => 8,
1810 .windows, .uefi => 8,
18761811 else => 4,
18771812 },
18781813
src/codegen/llvm.zig+2-2
......@@ -10730,8 +10730,8 @@ fn backendSupportsF128(target: std.Target) bool {
1073010730fn intrinsicsAllowed(scalar_ty: Type, target: std.Target) bool {
1073110731 return switch (scalar_ty.tag()) {
1073210732 .f16 => backendSupportsF16(target),
10733 .f80 => target.longDoubleIs(f80) and backendSupportsF80(target),
10734 .f128 => target.longDoubleIs(f128) and backendSupportsF128(target),
10733 .f80 => (CType.longdouble.sizeInBits(target) == 80) and backendSupportsF80(target),
10734 .f128 => (CType.longdouble.sizeInBits(target) == 128) and backendSupportsF128(target),
1073510735 else => true,
1073610736 };
1073710737}
src/type.zig+414-89
......@@ -2892,41 +2892,24 @@ pub const Type = extern union {
28922892 .anyframe_T,
28932893 => return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) },
28942894
2895 .c_short => return AbiAlignmentAdvanced{ .scalar = @divExact(CType.short.sizeInBits(target), 8) },
2896 .c_ushort => return AbiAlignmentAdvanced{ .scalar = @divExact(CType.ushort.sizeInBits(target), 8) },
2897 .c_int => return AbiAlignmentAdvanced{ .scalar = @divExact(CType.int.sizeInBits(target), 8) },
2898 .c_uint => return AbiAlignmentAdvanced{ .scalar = @divExact(CType.uint.sizeInBits(target), 8) },
2899 .c_long => return AbiAlignmentAdvanced{ .scalar = @divExact(CType.long.sizeInBits(target), 8) },
2900 .c_ulong => return AbiAlignmentAdvanced{ .scalar = @divExact(CType.ulong.sizeInBits(target), 8) },
2901 .c_longlong => switch (target.cpu.arch) {
2902 .i386 => switch (target.os.tag) {
2903 .windows, .uefi => return AbiAlignmentAdvanced{ .scalar = 8 },
2904 else => return AbiAlignmentAdvanced{ .scalar = 4 },
2905 },
2906 else => return AbiAlignmentAdvanced{ .scalar = @divExact(CType.longlong.sizeInBits(target), 8) },
2907 },
2908 .c_ulonglong => switch (target.cpu.arch) {
2909 .i386 => switch (target.os.tag) {
2910 .windows, .uefi => return AbiAlignmentAdvanced{ .scalar = 8 },
2911 else => return AbiAlignmentAdvanced{ .scalar = 4 },
2912 },
2913 else => return AbiAlignmentAdvanced{ .scalar = @divExact(CType.ulonglong.sizeInBits(target), 8) },
2914 },
2895 .c_short => return AbiAlignmentAdvanced{ .scalar = CType.short.alignment(target) },
2896 .c_ushort => return AbiAlignmentAdvanced{ .scalar = CType.ushort.alignment(target) },
2897 .c_int => return AbiAlignmentAdvanced{ .scalar = CType.int.alignment(target) },
2898 .c_uint => return AbiAlignmentAdvanced{ .scalar = CType.uint.alignment(target) },
2899 .c_long => return AbiAlignmentAdvanced{ .scalar = CType.long.alignment(target) },
2900 .c_ulong => return AbiAlignmentAdvanced{ .scalar = CType.ulong.alignment(target) },
2901 .c_longlong => return AbiAlignmentAdvanced{ .scalar = CType.longlong.alignment(target) },
2902 .c_ulonglong => return AbiAlignmentAdvanced{ .scalar = CType.ulonglong.alignment(target) },
2903 .c_longdouble => return AbiAlignmentAdvanced{ .scalar = CType.longdouble.alignment(target) },
29152904
29162905 .f16 => return AbiAlignmentAdvanced{ .scalar = 2 },
2917 .f32 => return AbiAlignmentAdvanced{ .scalar = 4 },
2918 .f64 => switch (target.cpu.arch) {
2919 .i386 => switch (target.os.tag) {
2920 .windows, .uefi => return AbiAlignmentAdvanced{ .scalar = 8 },
2921 else => return AbiAlignmentAdvanced{ .scalar = 4 },
2922 },
2906 .f32 => return AbiAlignmentAdvanced{ .scalar = CType.float.alignment(target) },
2907 .f64 => switch (CType.double.sizeInBits(target)) {
2908 64 => return AbiAlignmentAdvanced{ .scalar = CType.double.alignment(target) },
29232909 else => return AbiAlignmentAdvanced{ .scalar = 8 },
29242910 },
2925 .f128 => return AbiAlignmentAdvanced{ .scalar = 16 },
2926
2927 .f80 => switch (target.cpu.arch) {
2928 .i386 => return AbiAlignmentAdvanced{ .scalar = 4 },
2929 .x86_64 => return AbiAlignmentAdvanced{ .scalar = 16 },
2911 .f80 => switch (CType.longdouble.sizeInBits(target)) {
2912 80 => return AbiAlignmentAdvanced{ .scalar = CType.longdouble.alignment(target) },
29302913 else => {
29312914 var payload: Payload.Bits = .{
29322915 .base = .{ .tag = .int_unsigned },
......@@ -2936,17 +2919,7 @@ pub const Type = extern union {
29362919 return AbiAlignmentAdvanced{ .scalar = abiAlignment(u80_ty, target) };
29372920 },
29382921 },
2939 .c_longdouble => switch (CType.longdouble.sizeInBits(target)) {
2940 16 => return AbiAlignmentAdvanced{ .scalar = abiAlignment(Type.f16, target) },
2941 32 => return AbiAlignmentAdvanced{ .scalar = abiAlignment(Type.f32, target) },
2942 64 => return AbiAlignmentAdvanced{ .scalar = abiAlignment(Type.f64, target) },
2943 80 => if (target.cpu.arch == .i386 and target.isMinGW())
2944 return AbiAlignmentAdvanced{ .scalar = 4 }
2945 else
2946 return AbiAlignmentAdvanced{ .scalar = abiAlignment(Type.f80, target) },
2947 128 => return AbiAlignmentAdvanced{ .scalar = abiAlignment(Type.f128, target) },
2948 else => unreachable,
2949 },
2922 .f128 => return AbiAlignmentAdvanced{ .scalar = 16 },
29502923
29512924 // TODO revisit this when we have the concept of the error tag type
29522925 .anyerror_void_error_union,
......@@ -3411,16 +3384,8 @@ pub const Type = extern union {
34113384 .f32 => return AbiSizeAdvanced{ .scalar = 4 },
34123385 .f64 => return AbiSizeAdvanced{ .scalar = 8 },
34133386 .f128 => return AbiSizeAdvanced{ .scalar = 16 },
3414
3415 .f80 => switch (target.cpu.arch) {
3416 .i386 => switch (target.os.tag) {
3417 .windows => switch (target.abi) {
3418 .msvc => return AbiSizeAdvanced{ .scalar = 16 },
3419 else => return AbiSizeAdvanced{ .scalar = 12 },
3420 },
3421 else => return AbiSizeAdvanced{ .scalar = 12 },
3422 },
3423 .x86_64 => return AbiSizeAdvanced{ .scalar = 16 },
3387 .f80 => switch (CType.longdouble.sizeInBits(target)) {
3388 80 => return AbiSizeAdvanced{ .scalar = std.mem.alignForward(10, CType.longdouble.alignment(target)) },
34243389 else => {
34253390 var payload: Payload.Bits = .{
34263391 .base = .{ .tag = .int_unsigned },
......@@ -6654,45 +6619,80 @@ pub const CType = enum {
66546619 ulonglong,
66556620 longdouble,
66566621
6622 // We don't have a `c_float`/`c_double` type in Zig, but these
6623 // are useful for querying target-correct alignment and checking
6624 // whether C's double is f64 or f32
6625 float,
6626 double,
6627
66576628 pub fn sizeInBits(self: CType, target: Target) u16 {
66586629 switch (target.os.tag) {
66596630 .freestanding, .other => switch (target.cpu.arch) {
66606631 .msp430 => switch (self) {
66616632 .short, .ushort, .int, .uint => return 16,
6662 .long, .ulong => return 32,
6663 .longlong, .ulonglong, .longdouble => return 64,
6633 .float, .long, .ulong => return 32,
6634 .longlong, .ulonglong, .double, .longdouble => return 64,
66646635 },
66656636 .avr => switch (self) {
66666637 .short, .ushort, .int, .uint => return 16,
6667 .long, .ulong, .longdouble => return 32,
6638 .long, .ulong, .float, .double, .longdouble => return 32,
66686639 .longlong, .ulonglong => return 64,
66696640 },
6641 .tce, .tcele => switch (self) {
6642 .short, .ushort => return 16,
6643 .int, .uint, .long, .ulong, .longlong, .ulonglong => return 32,
6644 .float, .double, .longdouble => return 32,
6645 },
6646 .mips64, .mips64el => switch (self) {
6647 .short, .ushort => return 16,
6648 .int, .uint, .float => return 32,
6649 .long, .ulong => return if (target.abi != .gnuabin32) 64 else 32,
6650 .longlong, .ulonglong, .double => return 64,
6651 .longdouble => return 128,
6652 },
6653 .x86_64 => switch (self) {
6654 .short, .ushort => return 16,
6655 .int, .uint, .float => return 32,
6656 .long, .ulong => switch (target.abi) {
6657 .gnux32, .muslx32 => return 32,
6658 else => return 64,
6659 },
6660 .longlong, .ulonglong, .double => return 64,
6661 .longdouble => return 80,
6662 },
66706663 else => switch (self) {
66716664 .short, .ushort => return 16,
6672 .int, .uint => return 32,
6665 .int, .uint, .float => return 32,
66736666 .long, .ulong => return target.cpu.arch.ptrBitWidth(),
6674 .longlong, .ulonglong => return 64,
6667 .longlong, .ulonglong, .double => return 64,
66756668 .longdouble => switch (target.cpu.arch) {
66766669 .i386 => switch (target.abi) {
66776670 .android => return 64,
66786671 else => return 80,
66796672 },
6680 .x86_64 => return 80,
66816673
6674 .powerpc,
6675 .powerpcle,
6676 .powerpc64,
6677 .powerpc64le,
6678 => switch (target.abi) {
6679 .musl,
6680 .musleabi,
6681 .musleabihf,
6682 .muslx32,
6683 => return 64,
6684 else => return 128,
6685 },
6686
6687 .riscv32,
66826688 .riscv64,
66836689 .aarch64,
66846690 .aarch64_be,
66856691 .aarch64_32,
66866692 .s390x,
6687 .mips64,
6688 .mips64el,
66896693 .sparc,
66906694 .sparc64,
66916695 .sparcel,
6692 .powerpc,
6693 .powerpcle,
6694 .powerpc64,
6695 .powerpc64le,
66966696 .wasm32,
66976697 .wasm64,
66986698 => return 128,
......@@ -6716,23 +6716,78 @@ pub const CType = enum {
67166716 .fuchsia,
67176717 .minix,
67186718 => switch (target.cpu.arch) {
6719 .msp430 => switch (self) {
6720 .short, .ushort, .int, .uint => return 16,
6721 .long, .ulong, .float => return 32,
6722 .longlong, .ulonglong, .double, .longdouble => return 64,
6723 },
67196724 .avr => switch (self) {
67206725 .short, .ushort, .int, .uint => return 16,
6721 .long, .ulong, .longdouble => return 32,
6726 .long, .ulong, .float, .double, .longdouble => return 32,
67226727 .longlong, .ulonglong => return 64,
67236728 },
6729 .tce, .tcele => switch (self) {
6730 .short, .ushort => return 16,
6731 .int, .uint, .long, .ulong, .longlong, .ulonglong => return 32,
6732 .float, .double, .longdouble => return 32,
6733 },
6734 .mips64, .mips64el => switch (self) {
6735 .short, .ushort => return 16,
6736 .int, .uint, .float => return 32,
6737 .long, .ulong => return if (target.abi != .gnuabin32) 64 else 32,
6738 .longlong, .ulonglong, .double => return 64,
6739 .longdouble => if (target.os.tag == .freebsd) return 64 else return 128,
6740 },
6741 .x86_64 => switch (self) {
6742 .short, .ushort => return 16,
6743 .int, .uint, .float => return 32,
6744 .long, .ulong => switch (target.abi) {
6745 .gnux32, .muslx32 => return 32,
6746 else => return 64,
6747 },
6748 .longlong, .ulonglong, .double => return 64,
6749 .longdouble => return 80,
6750 },
67246751 else => switch (self) {
67256752 .short, .ushort => return 16,
6726 .int, .uint => return 32,
6753 .int, .uint, .float => return 32,
67276754 .long, .ulong => return target.cpu.arch.ptrBitWidth(),
6728 .longlong, .ulonglong => return 64,
6755 .longlong, .ulonglong, .double => return 64,
67296756 .longdouble => switch (target.cpu.arch) {
67306757 .i386 => switch (target.abi) {
67316758 .android => return 64,
67326759 else => return 80,
67336760 },
6734 .x86_64 => return 80,
67356761
6762 .powerpc,
6763 .powerpcle,
6764 => switch (target.abi) {
6765 .musl,
6766 .musleabi,
6767 .musleabihf,
6768 .muslx32,
6769 => return 64,
6770 else => switch (target.os.tag) {
6771 .freebsd, .netbsd, .openbsd => return 64,
6772 else => return 128,
6773 },
6774 },
6775
6776 .powerpc64,
6777 .powerpc64le,
6778 => switch (target.abi) {
6779 .musl,
6780 .musleabi,
6781 .musleabihf,
6782 .muslx32,
6783 => return 64,
6784 else => switch (target.os.tag) {
6785 .freebsd, .openbsd => return 64,
6786 else => return 128,
6787 },
6788 },
6789
6790 .riscv32,
67366791 .riscv64,
67376792 .aarch64,
67386793 .aarch64_be,
......@@ -6743,10 +6798,6 @@ pub const CType = enum {
67436798 .sparc,
67446799 .sparc64,
67456800 .sparcel,
6746 .powerpc,
6747 .powerpcle,
6748 .powerpc64,
6749 .powerpc64le,
67506801 .wasm32,
67516802 .wasm64,
67526803 => return 128,
......@@ -6756,37 +6807,77 @@ pub const CType = enum {
67566807 },
67576808 },
67586809
6759 .windows, .uefi => switch (self) {
6760 .short, .ushort => return 16,
6761 .int, .uint, .long, .ulong => return 32,
6762 .longlong, .ulonglong => return 64,
6763 .longdouble => switch (target.cpu.arch) {
6764 .i386 => switch (target.abi) {
6765 .gnu => return 80,
6810 .windows, .uefi => switch (target.cpu.arch) {
6811 .i386 => switch (self) {
6812 .short, .ushort => return 16,
6813 .int, .uint, .float => return 32,
6814 .long, .ulong => return 32,
6815 .longlong, .ulonglong, .double => return 64,
6816 .longdouble => switch (target.abi) {
6817 .gnu, .gnuilp32, .cygnus => return 80,
67666818 else => return 64,
67676819 },
6768 .x86_64 => switch (target.abi) {
6769 .gnu => return 80,
6820 },
6821 .x86_64 => switch (self) {
6822 .short, .ushort => return 16,
6823 .int, .uint, .float => return 32,
6824 .long, .ulong => switch (target.abi) {
6825 .cygnus => return 64,
6826 else => return 32,
6827 },
6828 .longlong, .ulonglong, .double => return 64,
6829 .longdouble => switch (target.abi) {
6830 .gnu, .gnuilp32, .cygnus => return 80,
67706831 else => return 64,
67716832 },
6772 else => return 64,
6833 },
6834 else => switch (self) {
6835 .short, .ushort => return 16,
6836 .int, .uint, .float => return 32,
6837 .long, .ulong => return 32,
6838 .longlong, .ulonglong, .double => return 64,
6839 .longdouble => return 64,
67736840 },
67746841 },
67756842
67766843 .macos, .ios, .tvos, .watchos => switch (self) {
67776844 .short, .ushort => return 16,
6778 .int, .uint => return 32,
6779 .long, .ulong, .longlong, .ulonglong => return 64,
6845 .int, .uint, .float => return 32,
6846 .long, .ulong => switch (target.cpu.arch) {
6847 .i386, .arm, .aarch64_32 => return 32,
6848 .x86_64 => switch (target.abi) {
6849 .gnux32, .muslx32 => return 32,
6850 else => return 64,
6851 },
6852 else => return 64,
6853 },
6854 .longlong, .ulonglong, .double => return 64,
67806855 .longdouble => switch (target.cpu.arch) {
6781 .i386, .x86_64 => return 80,
6856 .i386 => switch (target.abi) {
6857 .android => return 64,
6858 else => return 80,
6859 },
6860 .x86_64 => return 80,
6861 else => return 64,
6862 },
6863 },
6864
6865 .nvcl, .cuda => switch (self) {
6866 .short, .ushort => return 16,
6867 .int, .uint, .float => return 32,
6868 .long, .ulong => switch (target.cpu.arch) {
6869 .nvptx => return 32,
6870 .nvptx64 => return 64,
67826871 else => return 64,
67836872 },
6873 .longlong, .ulonglong, .double => return 64,
6874 .longdouble => return 64,
67846875 },
67856876
67866877 .amdhsa, .amdpal => switch (self) {
67876878 .short, .ushort => return 16,
6788 .int, .uint => return 32,
6789 .long, .ulong, .longlong, .ulonglong => return 64,
6879 .int, .uint, .float => return 32,
6880 .long, .ulong, .longlong, .ulonglong, .double => return 64,
67906881 .longdouble => return 128,
67916882 },
67926883
......@@ -6797,8 +6888,6 @@ pub const CType = enum {
67976888 .rtems,
67986889 .nacl,
67996890 .aix,
6800 .cuda,
6801 .nvcl,
68026891 .ps4,
68036892 .ps5,
68046893 .elfiamcu,
......@@ -6814,4 +6903,240 @@ pub const CType = enum {
68146903 => @panic("TODO specify the C integer and float type sizes for this OS"),
68156904 }
68166905 }
6906
6907 pub fn alignment(self: CType, target: Target) u16 {
6908
6909 // Overrides for unusual alignments
6910 switch (target.cpu.arch) {
6911 .avr => switch (self) {
6912 .short, .ushort => return 2,
6913 else => return 1,
6914 },
6915 .i386 => switch (target.os.tag) {
6916 .windows, .uefi => switch (self) {
6917 .longlong, .ulonglong, .double => return 8,
6918 .longdouble => switch (target.abi) {
6919 .gnu, .gnuilp32, .cygnus => return 4,
6920 else => return 8,
6921 },
6922 else => {},
6923 },
6924 else => {},
6925 },
6926 else => {},
6927 }
6928
6929 // Next-power-of-two-aligned, up to a maximum.
6930 return @min(
6931 std.math.ceilPowerOfTwoAssert(u16, (self.sizeInBits(target) + 7) / 8),
6932 switch (target.cpu.arch) {
6933 .arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
6934 .netbsd => switch (target.abi) {
6935 .gnueabi,
6936 .gnueabihf,
6937 .eabi,
6938 .eabihf,
6939 .android,
6940 .musleabi,
6941 .musleabihf,
6942 => 8,
6943
6944 else => @as(u16, 4),
6945 },
6946 .ios, .tvos, .watchos => 4,
6947 else => 8,
6948 },
6949
6950 .msp430,
6951 .avr,
6952 => 2,
6953
6954 .arc,
6955 .csky,
6956 .i386,
6957 .xcore,
6958 .dxil,
6959 .loongarch32,
6960 .tce,
6961 .tcele,
6962 .le32,
6963 .amdil,
6964 .hsail,
6965 .spir,
6966 .spirv32,
6967 .kalimba,
6968 .shave,
6969 .renderscript32,
6970 .ve,
6971 .spu_2,
6972 => 4,
6973
6974 .aarch64_32,
6975 .amdgcn,
6976 .amdil64,
6977 .bpfel,
6978 .bpfeb,
6979 .hexagon,
6980 .hsail64,
6981 .loongarch64,
6982 .m68k,
6983 .mips,
6984 .mipsel,
6985 .sparc,
6986 .sparcel,
6987 .sparc64,
6988 .lanai,
6989 .le64,
6990 .nvptx,
6991 .nvptx64,
6992 .r600,
6993 .s390x,
6994 .spir64,
6995 .spirv64,
6996 .renderscript64,
6997 => 8,
6998
6999 .aarch64,
7000 .aarch64_be,
7001 .mips64,
7002 .mips64el,
7003 .powerpc,
7004 .powerpcle,
7005 .powerpc64,
7006 .powerpc64le,
7007 .riscv32,
7008 .riscv64,
7009 .x86_64,
7010 .wasm32,
7011 .wasm64,
7012 => 16,
7013 },
7014 );
7015 }
7016
7017 pub fn preferredAlignment(self: CType, target: Target) u16 {
7018
7019 // Overrides for unusual alignments
7020 switch (target.cpu.arch) {
7021 .arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
7022 .netbsd => switch (target.abi) {
7023 .gnueabi,
7024 .gnueabihf,
7025 .eabi,
7026 .eabihf,
7027 .android,
7028 .musleabi,
7029 .musleabihf,
7030 => {},
7031
7032 else => switch (self) {
7033 .longdouble => return 4,
7034 else => {},
7035 },
7036 },
7037 .ios, .tvos, .watchos => switch (self) {
7038 .longdouble => return 4,
7039 else => {},
7040 },
7041 else => {},
7042 },
7043 .arc => switch (self) {
7044 .longdouble => return 4,
7045 else => {},
7046 },
7047 .avr => switch (self) {
7048 .int, .uint, .long, .ulong, .float, .longdouble => return 1,
7049 .short, .ushort => return 2,
7050 .double => return 4,
7051 .longlong, .ulonglong => return 8,
7052 },
7053 .i386 => switch (target.os.tag) {
7054 .windows, .uefi => switch (self) {
7055 .longdouble => switch (target.abi) {
7056 .gnu, .gnuilp32, .cygnus => return 4,
7057 else => return 8,
7058 },
7059 else => {},
7060 },
7061 else => switch (self) {
7062 .longdouble => return 4,
7063 else => {},
7064 },
7065 },
7066 else => {},
7067 }
7068
7069 // Next-power-of-two-aligned, up to a maximum.
7070 return @min(
7071 std.math.ceilPowerOfTwoAssert(u16, (self.sizeInBits(target) + 7) / 8),
7072 switch (target.cpu.arch) {
7073 .msp430 => @as(u16, 2),
7074
7075 .csky,
7076 .xcore,
7077 .dxil,
7078 .loongarch32,
7079 .tce,
7080 .tcele,
7081 .le32,
7082 .amdil,
7083 .hsail,
7084 .spir,
7085 .spirv32,
7086 .kalimba,
7087 .shave,
7088 .renderscript32,
7089 .ve,
7090 .spu_2,
7091 => 4,
7092
7093 .arc,
7094 .arm,
7095 .armeb,
7096 .avr,
7097 .thumb,
7098 .thumbeb,
7099 .aarch64_32,
7100 .amdgcn,
7101 .amdil64,
7102 .bpfel,
7103 .bpfeb,
7104 .hexagon,
7105 .hsail64,
7106 .i386,
7107 .loongarch64,
7108 .m68k,
7109 .mips,
7110 .mipsel,
7111 .sparc,
7112 .sparcel,
7113 .sparc64,
7114 .lanai,
7115 .le64,
7116 .nvptx,
7117 .nvptx64,
7118 .r600,
7119 .s390x,
7120 .spir64,
7121 .spirv64,
7122 .renderscript64,
7123 => 8,
7124
7125 .aarch64,
7126 .aarch64_be,
7127 .mips64,
7128 .mips64el,
7129 .powerpc,
7130 .powerpcle,
7131 .powerpc64,
7132 .powerpc64le,
7133 .riscv32,
7134 .riscv64,
7135 .x86_64,
7136 .wasm32,
7137 .wasm64,
7138 => 16,
7139 },
7140 );
7141 }
68177142};