Skip to content

Commit b4ed867

Browse files
committed
compiler-rt: break up functions even more
The purpose of this branch is to switch to using an object file for each independent function, in order to make linking simpler - instead of relying on `-ffunction-sections` and `--gc-sections`, which involves the linker doing the work of linking everything and then undoing work via garbage collection, this will allow the linker to only include the compilation units that are depended on in the first place. This commit makes progress towards that goal.
1 parent 26e86be commit b4ed867

File tree

127 files changed

+2785
-2093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+2785
-2093
lines changed

lib/compiler_rt.zig

+127-20
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,59 @@
1-
const builtin = @import("builtin");
21
pub const panic = @import("compiler_rt/common.zig").panic;
32

43
comptime {
5-
// TODO moving these around makes or breaks compilation of zig1.o for some reason
6-
// Perhaps, until we switch to stage2, exports should be duplicated between this file
7-
// and files included as a standalone units?
84
_ = @import("compiler_rt/atomics.zig");
9-
_ = @import("compiler_rt/addXf3.zig");
10-
_ = @import("compiler_rt/mulXf3.zig");
11-
_ = @import("compiler_rt/compareXf2.zig");
12-
_ = @import("compiler_rt/extendXfYf2.zig");
13-
_ = @import("compiler_rt/extend_f80.zig");
14-
_ = @import("compiler_rt/truncXfYf2.zig");
15-
_ = @import("compiler_rt/trunc_f80.zig");
5+
6+
_ = @import("compiler_rt/addf3.zig");
7+
_ = @import("compiler_rt/addsf3.zig");
8+
_ = @import("compiler_rt/addtf3.zig");
9+
_ = @import("compiler_rt/addxf3.zig");
10+
_ = @import("compiler_rt/subdf3.zig");
11+
_ = @import("compiler_rt/subsf3.zig");
12+
_ = @import("compiler_rt/subtf3.zig");
13+
_ = @import("compiler_rt/subxf3.zig");
14+
15+
_ = @import("compiler_rt/mulf3.zig");
16+
_ = @import("compiler_rt/muldf3.zig");
17+
_ = @import("compiler_rt/mulsf3.zig");
18+
_ = @import("compiler_rt/multf3.zig");
19+
_ = @import("compiler_rt/mulxf3.zig");
20+
21+
_ = @import("compiler_rt/comparef.zig");
22+
_ = @import("compiler_rt/cmpsf2.zig");
23+
_ = @import("compiler_rt/cmpdf2.zig");
24+
_ = @import("compiler_rt/cmptf2.zig");
25+
_ = @import("compiler_rt/cmpxf2.zig");
26+
_ = @import("compiler_rt/gesf2.zig");
27+
_ = @import("compiler_rt/gedf2.zig");
28+
_ = @import("compiler_rt/getf2.zig");
29+
_ = @import("compiler_rt/gexf2.zig");
30+
_ = @import("compiler_rt/unordsf2.zig");
31+
_ = @import("compiler_rt/unorddf2.zig");
32+
_ = @import("compiler_rt/unordtf2.zig");
33+
34+
_ = @import("compiler_rt/extendf.zig");
35+
_ = @import("compiler_rt/extenddftf2.zig");
36+
_ = @import("compiler_rt/extenddfxf2.zig");
37+
_ = @import("compiler_rt/extendhfsf2.zig");
38+
_ = @import("compiler_rt/extendhftf2.zig");
39+
_ = @import("compiler_rt/extendhfxf2.zig");
40+
_ = @import("compiler_rt/extendsfdf2.zig");
41+
_ = @import("compiler_rt/extendsftf2.zig");
42+
_ = @import("compiler_rt/extendsfxf2.zig");
43+
_ = @import("compiler_rt/extendxftf2.zig");
44+
45+
_ = @import("compiler_rt/truncf.zig");
46+
_ = @import("compiler_rt/truncsfhf2.zig");
47+
_ = @import("compiler_rt/truncdfhf2.zig");
48+
_ = @import("compiler_rt/truncdfsf2.zig");
49+
_ = @import("compiler_rt/trunctfhf2.zig");
50+
_ = @import("compiler_rt/trunctfsf2.zig");
51+
_ = @import("compiler_rt/trunctfdf2.zig");
52+
_ = @import("compiler_rt/trunctfxf2.zig");
53+
_ = @import("compiler_rt/truncxfhf2.zig");
54+
_ = @import("compiler_rt/truncxfsf2.zig");
55+
_ = @import("compiler_rt/truncxfdf2.zig");
56+
1657
_ = @import("compiler_rt/divtf3.zig");
1758
_ = @import("compiler_rt/divsf3.zig");
1859
_ = @import("compiler_rt/divdf3.zig");
@@ -43,35 +84,101 @@ comptime {
4384
_ = @import("compiler_rt/udivti3.zig");
4485
_ = @import("compiler_rt/udivmodti4.zig");
4586
_ = @import("compiler_rt/umodti3.zig");
46-
_ = @import("compiler_rt/floatXiYf.zig");
47-
_ = @import("compiler_rt/fixXfYi.zig");
87+
88+
_ = @import("compiler_rt/int_to_float.zig");
89+
_ = @import("compiler_rt/floatsihf.zig");
90+
_ = @import("compiler_rt/floatsisf.zig");
91+
_ = @import("compiler_rt/floatsidf.zig");
92+
_ = @import("compiler_rt/floatsitf.zig");
93+
_ = @import("compiler_rt/floatsixf.zig");
94+
_ = @import("compiler_rt/floatdihf.zig");
95+
_ = @import("compiler_rt/floatdisf.zig");
96+
_ = @import("compiler_rt/floatdidf.zig");
97+
_ = @import("compiler_rt/floatditf.zig");
98+
_ = @import("compiler_rt/floatdixf.zig");
99+
_ = @import("compiler_rt/floattihf.zig");
100+
_ = @import("compiler_rt/floattisf.zig");
101+
_ = @import("compiler_rt/floattidf.zig");
102+
_ = @import("compiler_rt/floattitf.zig");
103+
_ = @import("compiler_rt/floattixf.zig");
104+
_ = @import("compiler_rt/floatundihf.zig");
105+
_ = @import("compiler_rt/floatundisf.zig");
106+
_ = @import("compiler_rt/floatundidf.zig");
107+
_ = @import("compiler_rt/floatunditf.zig");
108+
_ = @import("compiler_rt/floatundixf.zig");
109+
_ = @import("compiler_rt/floatunsihf.zig");
110+
_ = @import("compiler_rt/floatunsisf.zig");
111+
_ = @import("compiler_rt/floatunsidf.zig");
112+
_ = @import("compiler_rt/floatunsitf.zig");
113+
_ = @import("compiler_rt/floatunsixf.zig");
114+
_ = @import("compiler_rt/floatuntihf.zig");
115+
_ = @import("compiler_rt/floatuntisf.zig");
116+
_ = @import("compiler_rt/floatuntidf.zig");
117+
_ = @import("compiler_rt/floatuntitf.zig");
118+
_ = @import("compiler_rt/floatuntixf.zig");
119+
120+
_ = @import("compiler_rt/float_to_int.zig");
121+
_ = @import("compiler_rt/fixhfsi.zig");
122+
_ = @import("compiler_rt/fixhfdi.zig");
123+
_ = @import("compiler_rt/fixhfti.zig");
124+
_ = @import("compiler_rt/fixsfsi.zig");
125+
_ = @import("compiler_rt/fixsfdi.zig");
126+
_ = @import("compiler_rt/fixsfti.zig");
127+
_ = @import("compiler_rt/fixdfsi.zig");
128+
_ = @import("compiler_rt/fixdfdi.zig");
129+
_ = @import("compiler_rt/fixdfti.zig");
130+
_ = @import("compiler_rt/fixtfsi.zig");
131+
_ = @import("compiler_rt/fixtfdi.zig");
132+
_ = @import("compiler_rt/fixtfti.zig");
133+
_ = @import("compiler_rt/fixxfsi.zig");
134+
_ = @import("compiler_rt/fixxfdi.zig");
135+
_ = @import("compiler_rt/fixxfti.zig");
136+
_ = @import("compiler_rt/fixunshfsi.zig");
137+
_ = @import("compiler_rt/fixunshfdi.zig");
138+
_ = @import("compiler_rt/fixunshfti.zig");
139+
_ = @import("compiler_rt/fixunssfsi.zig");
140+
_ = @import("compiler_rt/fixunssfdi.zig");
141+
_ = @import("compiler_rt/fixunssfti.zig");
142+
_ = @import("compiler_rt/fixunsdfsi.zig");
143+
_ = @import("compiler_rt/fixunsdfdi.zig");
144+
_ = @import("compiler_rt/fixunsdfti.zig");
145+
_ = @import("compiler_rt/fixunstfsi.zig");
146+
_ = @import("compiler_rt/fixunstfdi.zig");
147+
_ = @import("compiler_rt/fixunstfti.zig");
148+
_ = @import("compiler_rt/fixunsxfsi.zig");
149+
_ = @import("compiler_rt/fixunsxfdi.zig");
150+
_ = @import("compiler_rt/fixunsxfti.zig");
151+
48152
_ = @import("compiler_rt/count0bits.zig");
49153
_ = @import("compiler_rt/parity.zig");
50154
_ = @import("compiler_rt/popcount.zig");
51155
_ = @import("compiler_rt/bswap.zig");
52156
_ = @import("compiler_rt/int.zig");
53157
_ = @import("compiler_rt/shift.zig");
158+
54159
_ = @import("compiler_rt/negXi2.zig");
160+
55161
_ = @import("compiler_rt/muldi3.zig");
162+
56163
_ = @import("compiler_rt/absv.zig");
164+
_ = @import("compiler_rt/absvsi2.zig");
165+
_ = @import("compiler_rt/absvdi2.zig");
166+
_ = @import("compiler_rt/absvti2.zig");
167+
57168
_ = @import("compiler_rt/negv.zig");
58169
_ = @import("compiler_rt/addo.zig");
59170
_ = @import("compiler_rt/subo.zig");
60171
_ = @import("compiler_rt/mulo.zig");
61172
_ = @import("compiler_rt/cmp.zig");
173+
62174
_ = @import("compiler_rt/negXf2.zig");
175+
63176
_ = @import("compiler_rt/os_version_check.zig");
64177
_ = @import("compiler_rt/emutls.zig");
65178
_ = @import("compiler_rt/arm.zig");
66179
_ = @import("compiler_rt/aulldiv.zig");
67180
_ = @import("compiler_rt/aullrem.zig");
68-
_ = @import("compiler_rt/sparc.zig");
69181
_ = @import("compiler_rt/clear_cache.zig");
70182

71-
// missing: Floating point raised to integer power
72-
73-
// missing: Complex arithmetic
74-
// (a + ib) * (c + id)
75-
// (a + ib) / (c + id)
76-
183+
_ = @import("compiler_rt/sparc.zig");
77184
}

lib/compiler_rt/absv.zig

+3-27
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
// absv - absolute oVerflow
2-
// * @panic, if value can not be represented
3-
// - absvXi4_generic for unoptimized version
4-
const std = @import("std");
5-
const builtin = @import("builtin");
6-
const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7-
pub const panic = @import("common.zig").panic;
8-
9-
comptime {
10-
@export(__absvsi2, .{ .name = "__absvsi2", .linkage = linkage });
11-
@export(__absvdi2, .{ .name = "__absvdi2", .linkage = linkage });
12-
@export(__absvti2, .{ .name = "__absvti2", .linkage = linkage });
13-
}
14-
15-
inline fn absvXi(comptime ST: type, a: ST) ST {
1+
/// absv - absolute oVerflow
2+
/// * @panic if value can not be represented
3+
pub inline fn absv(comptime ST: type, a: ST) ST {
164
const UT = switch (ST) {
175
i32 => u32,
186
i64 => u64,
@@ -31,18 +19,6 @@ inline fn absvXi(comptime ST: type, a: ST) ST {
3119
return x;
3220
}
3321

34-
pub fn __absvsi2(a: i32) callconv(.C) i32 {
35-
return absvXi(i32, a);
36-
}
37-
38-
pub fn __absvdi2(a: i64) callconv(.C) i64 {
39-
return absvXi(i64, a);
40-
}
41-
42-
pub fn __absvti2(a: i128) callconv(.C) i128 {
43-
return absvXi(i128, a);
44-
}
45-
4622
test {
4723
_ = @import("absvsi2_test.zig");
4824
_ = @import("absvdi2_test.zig");

lib/compiler_rt/absvdi2.zig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const common = @import("./common.zig");
2+
const absv = @import("./absv.zig").absv;
3+
4+
pub const panic = common.panic;
5+
6+
comptime {
7+
@export(__absvdi2, .{ .name = "__absvdi2", .linkage = common.linkage });
8+
}
9+
10+
fn __absvdi2(a: i64) callconv(.C) i64 {
11+
return absv(i64, a);
12+
}

lib/compiler_rt/absvsi2.zig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const common = @import("./common.zig");
2+
const absv = @import("./absv.zig").absv;
3+
4+
pub const panic = common.panic;
5+
6+
comptime {
7+
@export(__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage });
8+
}
9+
10+
fn __absvsi2(a: i32) callconv(.C) i32 {
11+
return absv(i32, a);
12+
}

lib/compiler_rt/absvti2.zig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const common = @import("./common.zig");
2+
const absv = @import("./absv.zig").absv;
3+
4+
pub const panic = common.panic;
5+
6+
comptime {
7+
@export(__absvti2, .{ .name = "__absvti2", .linkage = common.linkage });
8+
}
9+
10+
fn __absvti2(a: i128) callconv(.C) i128 {
11+
return absv(i128, a);
12+
}

lib/compiler_rt/adddf3.zig

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const common = @import("./common.zig");
2+
const addf3 = @import("./addf3.zig").addf3;
3+
4+
pub const panic = common.panic;
5+
6+
comptime {
7+
if (common.want_aeabi) {
8+
@export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = common.linkage });
9+
} else {
10+
@export(__adddf3, .{ .name = "__adddf3", .linkage = common.linkage });
11+
}
12+
}
13+
14+
fn __adddf3(a: f64, b: f64) callconv(.C) f64 {
15+
return addf3(f64, a, b);
16+
}
17+
18+
fn __aeabi_dadd(a: f64, b: f64) callconv(.AAPCS) f64 {
19+
return addf3(f64, a, b);
20+
}

0 commit comments

Comments
 (0)