authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-06-10 10:25:59+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-17 16:38:59-07:00
log80790be3094f65877231209532c04f7fdb4441a7
tree10c677f0bc95053c7fde3fb64d11c41f455faa90
parent33cf6ef621114daad63d14067b6ff374e664d410

compiler_rt: compile each unit separately for improved archiving


70 files changed, 2003 insertions(+), 1133 deletions(-)

lib/compiler_rt.zig+61-872
......@@ -1,542 +1,69 @@
1const std = @import("std");
21const builtin = @import("builtin");
3const is_test = builtin.is_test;
4const os_tag = builtin.os.tag;
5const arch = builtin.cpu.arch;
6const abi = builtin.abi;
7
8const is_gnu = abi.isGnu();
9const is_mingw = os_tag == .windows and is_gnu;
10const is_darwin = std.Target.Os.Tag.isDarwin(os_tag);
11const is_ppc = arch.isPPC() or arch.isPPC64();
12
13const linkage = if (is_test)
14 std.builtin.GlobalLinkage.Internal
15else
16 std.builtin.GlobalLinkage.Weak;
17
18const strong_linkage = if (is_test)
19 std.builtin.GlobalLinkage.Internal
20else
21 std.builtin.GlobalLinkage.Strong;
2pub const panic = @import("compiler_rt/common.zig").panic;
223
234comptime {
245 // These files do their own comptime exporting logic.
256 _ = @import("compiler_rt/atomics.zig");
26 if (builtin.zig_backend != .stage2_llvm) { // TODO
27 _ = @import("compiler_rt/clear_cache.zig").clear_cache;
28 }
29
30 const __extenddftf2 = @import("compiler_rt/extendXfYf2.zig").__extenddftf2;
31 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage });
32 const __extendsftf2 = @import("compiler_rt/extendXfYf2.zig").__extendsftf2;
33 @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = linkage });
34 const __extendhfsf2 = @import("compiler_rt/extendXfYf2.zig").__extendhfsf2;
35 @export(__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = linkage });
36 const __extendhftf2 = @import("compiler_rt/extendXfYf2.zig").__extendhftf2;
37 @export(__extendhftf2, .{ .name = "__extendhftf2", .linkage = linkage });
38
39 const __extendhfxf2 = @import("compiler_rt/extend_f80.zig").__extendhfxf2;
40 @export(__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = linkage });
41 const __extendsfxf2 = @import("compiler_rt/extend_f80.zig").__extendsfxf2;
42 @export(__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = linkage });
43 const __extenddfxf2 = @import("compiler_rt/extend_f80.zig").__extenddfxf2;
44 @export(__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = linkage });
45 const __extendxftf2 = @import("compiler_rt/extend_f80.zig").__extendxftf2;
46 @export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = linkage });
47
48 const __lesf2 = @import("compiler_rt/compareXf2.zig").__lesf2;
49 @export(__lesf2, .{ .name = "__lesf2", .linkage = linkage });
50 const __ledf2 = @import("compiler_rt/compareXf2.zig").__ledf2;
51 @export(__ledf2, .{ .name = "__ledf2", .linkage = linkage });
52 const __letf2 = @import("compiler_rt/compareXf2.zig").__letf2;
53 @export(__letf2, .{ .name = "__letf2", .linkage = linkage });
54 const __lexf2 = @import("compiler_rt/compareXf2.zig").__lexf2;
55 @export(__lexf2, .{ .name = "__lexf2", .linkage = linkage });
56
57 const __gesf2 = @import("compiler_rt/compareXf2.zig").__gesf2;
58 @export(__gesf2, .{ .name = "__gesf2", .linkage = linkage });
59 const __gedf2 = @import("compiler_rt/compareXf2.zig").__gedf2;
60 @export(__gedf2, .{ .name = "__gedf2", .linkage = linkage });
61 const __getf2 = @import("compiler_rt/compareXf2.zig").__getf2;
62 @export(__getf2, .{ .name = "__getf2", .linkage = linkage });
63 const __gexf2 = @import("compiler_rt/compareXf2.zig").__gexf2;
64 @export(__gexf2, .{ .name = "__gexf2", .linkage = linkage });
65
66 const __eqsf2 = @import("compiler_rt/compareXf2.zig").__eqsf2;
67 @export(__eqsf2, .{ .name = "__eqsf2", .linkage = linkage });
68 const __eqdf2 = @import("compiler_rt/compareXf2.zig").__eqdf2;
69 @export(__eqdf2, .{ .name = "__eqdf2", .linkage = linkage });
70 const __eqxf2 = @import("compiler_rt/compareXf2.zig").__eqxf2;
71 @export(__eqxf2, .{ .name = "__eqxf2", .linkage = linkage });
72
73 const __ltsf2 = @import("compiler_rt/compareXf2.zig").__ltsf2;
74 @export(__ltsf2, .{ .name = "__ltsf2", .linkage = linkage });
75 const __ltdf2 = @import("compiler_rt/compareXf2.zig").__ltdf2;
76 @export(__ltdf2, .{ .name = "__ltdf2", .linkage = linkage });
77 const __ltxf2 = @import("compiler_rt/compareXf2.zig").__ltxf2;
78 @export(__ltxf2, .{ .name = "__ltxf2", .linkage = linkage });
79
80 const __nesf2 = @import("compiler_rt/compareXf2.zig").__nesf2;
81 @export(__nesf2, .{ .name = "__nesf2", .linkage = linkage });
82 const __nedf2 = @import("compiler_rt/compareXf2.zig").__nedf2;
83 @export(__nedf2, .{ .name = "__nedf2", .linkage = linkage });
84 const __nexf2 = @import("compiler_rt/compareXf2.zig").__nexf2;
85 @export(__nexf2, .{ .name = "__nexf2", .linkage = linkage });
86
87 const __gtsf2 = @import("compiler_rt/compareXf2.zig").__gtsf2;
88 @export(__gtsf2, .{ .name = "__gtsf2", .linkage = linkage });
89 const __gtdf2 = @import("compiler_rt/compareXf2.zig").__gtdf2;
90 @export(__gtdf2, .{ .name = "__gtdf2", .linkage = linkage });
91 const __gtxf2 = @import("compiler_rt/compareXf2.zig").__gtxf2;
92 @export(__gtxf2, .{ .name = "__gtxf2", .linkage = linkage });
93
94 if (!is_test) {
95 @export(__lesf2, .{ .name = "__cmpsf2", .linkage = linkage });
96 @export(__ledf2, .{ .name = "__cmpdf2", .linkage = linkage });
97 @export(__letf2, .{ .name = "__cmptf2", .linkage = linkage });
98 @export(__letf2, .{ .name = "__eqtf2", .linkage = linkage });
99 @export(__letf2, .{ .name = "__lttf2", .linkage = linkage });
100 @export(__getf2, .{ .name = "__gttf2", .linkage = linkage });
101 @export(__letf2, .{ .name = "__netf2", .linkage = linkage });
102 @export(__extendhfsf2, .{ .name = "__gnu_h2f_ieee", .linkage = linkage });
103 }
104
105 if (builtin.os.tag == .windows) {
106 // Default stack-probe functions emitted by LLVM
107 if (is_mingw) {
108 const _chkstk = @import("compiler_rt/stack_probe.zig")._chkstk;
109 @export(_chkstk, .{ .name = "_alloca", .linkage = strong_linkage });
110 const ___chkstk_ms = @import("compiler_rt/stack_probe.zig").___chkstk_ms;
111 @export(___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = strong_linkage });
112 } else if (!builtin.link_libc) {
113 // This symbols are otherwise exported by MSVCRT.lib
114 const _chkstk = @import("compiler_rt/stack_probe.zig")._chkstk;
115 @export(_chkstk, .{ .name = "_chkstk", .linkage = strong_linkage });
116 const __chkstk = @import("compiler_rt/stack_probe.zig").__chkstk;
117 @export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage });
118 }
119
120 switch (arch) {
121 .i386 => {
122 const __divti3 = @import("compiler_rt/divti3.zig").__divti3;
123 @export(__divti3, .{ .name = "__divti3", .linkage = linkage });
124 const __modti3 = @import("compiler_rt/modti3.zig").__modti3;
125 @export(__modti3, .{ .name = "__modti3", .linkage = linkage });
126 const __multi3 = @import("compiler_rt/multi3.zig").__multi3;
127 @export(__multi3, .{ .name = "__multi3", .linkage = linkage });
128 const __udivti3 = @import("compiler_rt/udivti3.zig").__udivti3;
129 @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage });
130 const __udivmodti4 = @import("compiler_rt/udivmodti4.zig").__udivmodti4;
131 @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage });
132 const __umodti3 = @import("compiler_rt/umodti3.zig").__umodti3;
133 @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage });
134 },
135 .x86_64 => {
136 // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI
137 // that LLVM expects compiler-rt to have.
138 const __divti3_windows_x86_64 = @import("compiler_rt/divti3.zig").__divti3_windows_x86_64;
139 @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = linkage });
140 const __modti3_windows_x86_64 = @import("compiler_rt/modti3.zig").__modti3_windows_x86_64;
141 @export(__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = linkage });
142 const __multi3_windows_x86_64 = @import("compiler_rt/multi3.zig").__multi3_windows_x86_64;
143 @export(__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = linkage });
144 const __udivti3_windows_x86_64 = @import("compiler_rt/udivti3.zig").__udivti3_windows_x86_64;
145 @export(__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = linkage });
146 const __udivmodti4_windows_x86_64 = @import("compiler_rt/udivmodti4.zig").__udivmodti4_windows_x86_64;
147 @export(__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = linkage });
148 const __umodti3_windows_x86_64 = @import("compiler_rt/umodti3.zig").__umodti3_windows_x86_64;
149 @export(__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = linkage });
150 },
151 else => {},
152 }
153 if (arch.isAARCH64()) {
154 const __chkstk = @import("compiler_rt/stack_probe.zig").__chkstk;
155 @export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage });
156 const __divti3_windows = @import("compiler_rt/divti3.zig").__divti3;
157 @export(__divti3_windows, .{ .name = "__divti3", .linkage = linkage });
158 const __modti3 = @import("compiler_rt/modti3.zig").__modti3;
159 @export(__modti3, .{ .name = "__modti3", .linkage = linkage });
160 const __udivti3_windows = @import("compiler_rt/udivti3.zig").__udivti3;
161 @export(__udivti3_windows, .{ .name = "__udivti3", .linkage = linkage });
162 const __umodti3 = @import("compiler_rt/umodti3.zig").__umodti3;
163 @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage });
164 }
165 } else {
166 const __divti3 = @import("compiler_rt/divti3.zig").__divti3;
167 @export(__divti3, .{ .name = "__divti3", .linkage = linkage });
168 const __modti3 = @import("compiler_rt/modti3.zig").__modti3;
169 @export(__modti3, .{ .name = "__modti3", .linkage = linkage });
170 const __multi3 = @import("compiler_rt/multi3.zig").__multi3;
171 @export(__multi3, .{ .name = "__multi3", .linkage = linkage });
172 const __udivti3 = @import("compiler_rt/udivti3.zig").__udivti3;
173 @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage });
174 const __udivmodti4 = @import("compiler_rt/udivmodti4.zig").__udivmodti4;
175 @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage });
176 const __umodti3 = @import("compiler_rt/umodti3.zig").__umodti3;
177 @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage });
178 }
179
180 const __truncdfhf2 = @import("compiler_rt/truncXfYf2.zig").__truncdfhf2;
181 @export(__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = linkage });
182 const __trunctfhf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfhf2;
183 @export(__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = linkage });
184 const __trunctfdf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfdf2;
185 @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = linkage });
186 const __trunctfsf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfsf2;
187 @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = linkage });
188
189 const __truncdfsf2 = @import("compiler_rt/truncXfYf2.zig").__truncdfsf2;
190 @export(__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = linkage });
191
192 const __truncxfhf2 = @import("compiler_rt/trunc_f80.zig").__truncxfhf2;
193 @export(__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = linkage });
194 const __truncxfsf2 = @import("compiler_rt/trunc_f80.zig").__truncxfsf2;
195 @export(__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = linkage });
196 const __truncxfdf2 = @import("compiler_rt/trunc_f80.zig").__truncxfdf2;
197 @export(__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = linkage });
198 const __trunctfxf2 = @import("compiler_rt/trunc_f80.zig").__trunctfxf2;
199 @export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage });
200
201 switch (arch) {
202 .i386,
203 .x86_64,
204 => {
205 const zig_probe_stack = @import("compiler_rt/stack_probe.zig").zig_probe_stack;
206 @export(zig_probe_stack, .{
207 .name = "__zig_probe_stack",
208 .linkage = linkage,
209 });
210 },
211 else => {},
212 }
213
214 const __unordsf2 = @import("compiler_rt/compareXf2.zig").__unordsf2;
215 @export(__unordsf2, .{ .name = "__unordsf2", .linkage = linkage });
216 const __unorddf2 = @import("compiler_rt/compareXf2.zig").__unorddf2;
217 @export(__unorddf2, .{ .name = "__unorddf2", .linkage = linkage });
218 const __unordtf2 = @import("compiler_rt/compareXf2.zig").__unordtf2;
219 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = linkage });
220
221 const __addsf3 = @import("compiler_rt/addXf3.zig").__addsf3;
222 @export(__addsf3, .{ .name = "__addsf3", .linkage = linkage });
223 const __adddf3 = @import("compiler_rt/addXf3.zig").__adddf3;
224 @export(__adddf3, .{ .name = "__adddf3", .linkage = linkage });
225 const __addxf3 = @import("compiler_rt/addXf3.zig").__addxf3;
226 @export(__addxf3, .{ .name = "__addxf3", .linkage = linkage });
227 const __addtf3 = @import("compiler_rt/addXf3.zig").__addtf3;
228 @export(__addtf3, .{ .name = "__addtf3", .linkage = linkage });
229
230 const __subsf3 = @import("compiler_rt/addXf3.zig").__subsf3;
231 @export(__subsf3, .{ .name = "__subsf3", .linkage = linkage });
232 const __subdf3 = @import("compiler_rt/addXf3.zig").__subdf3;
233 @export(__subdf3, .{ .name = "__subdf3", .linkage = linkage });
234 const __subxf3 = @import("compiler_rt/addXf3.zig").__subxf3;
235 @export(__subxf3, .{ .name = "__subxf3", .linkage = linkage });
236 const __subtf3 = @import("compiler_rt/addXf3.zig").__subtf3;
237 @export(__subtf3, .{ .name = "__subtf3", .linkage = linkage });
238
239 const __mulsf3 = @import("compiler_rt/mulXf3.zig").__mulsf3;
240 @export(__mulsf3, .{ .name = "__mulsf3", .linkage = linkage });
241 const __muldf3 = @import("compiler_rt/mulXf3.zig").__muldf3;
242 @export(__muldf3, .{ .name = "__muldf3", .linkage = linkage });
243 const __mulxf3 = @import("compiler_rt/mulXf3.zig").__mulxf3;
244 @export(__mulxf3, .{ .name = "__mulxf3", .linkage = linkage });
245 const __multf3 = @import("compiler_rt/mulXf3.zig").__multf3;
246 @export(__multf3, .{ .name = "__multf3", .linkage = linkage });
247
248 const __divsf3 = @import("compiler_rt/divsf3.zig").__divsf3;
249 @export(__divsf3, .{ .name = "__divsf3", .linkage = linkage });
250 const __divdf3 = @import("compiler_rt/divdf3.zig").__divdf3;
251 @export(__divdf3, .{ .name = "__divdf3", .linkage = linkage });
252 const __divxf3 = @import("compiler_rt/divxf3.zig").__divxf3;
253 @export(__divxf3, .{ .name = "__divxf3", .linkage = linkage });
254 const __divtf3 = @import("compiler_rt/divtf3.zig").__divtf3;
255 @export(__divtf3, .{ .name = "__divtf3", .linkage = linkage });
256
257 // Integer Bit operations
258 const __clzsi2 = @import("compiler_rt/count0bits.zig").__clzsi2;
259 @export(__clzsi2, .{ .name = "__clzsi2", .linkage = linkage });
260 const __clzdi2 = @import("compiler_rt/count0bits.zig").__clzdi2;
261 @export(__clzdi2, .{ .name = "__clzdi2", .linkage = linkage });
262 const __clzti2 = @import("compiler_rt/count0bits.zig").__clzti2;
263 @export(__clzti2, .{ .name = "__clzti2", .linkage = linkage });
264 const __ctzsi2 = @import("compiler_rt/count0bits.zig").__ctzsi2;
265 @export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = linkage });
266 const __ctzdi2 = @import("compiler_rt/count0bits.zig").__ctzdi2;
267 @export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = linkage });
268 const __ctzti2 = @import("compiler_rt/count0bits.zig").__ctzti2;
269 @export(__ctzti2, .{ .name = "__ctzti2", .linkage = linkage });
270 const __ffssi2 = @import("compiler_rt/count0bits.zig").__ffssi2;
271 @export(__ffssi2, .{ .name = "__ffssi2", .linkage = linkage });
272 const __ffsdi2 = @import("compiler_rt/count0bits.zig").__ffsdi2;
273 @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = linkage });
274 const __ffsti2 = @import("compiler_rt/count0bits.zig").__ffsti2;
275 @export(__ffsti2, .{ .name = "__ffsti2", .linkage = linkage });
276 const __paritysi2 = @import("compiler_rt/parity.zig").__paritysi2;
277 @export(__paritysi2, .{ .name = "__paritysi2", .linkage = linkage });
278 const __paritydi2 = @import("compiler_rt/parity.zig").__paritydi2;
279 @export(__paritydi2, .{ .name = "__paritydi2", .linkage = linkage });
280 const __parityti2 = @import("compiler_rt/parity.zig").__parityti2;
281 @export(__parityti2, .{ .name = "__parityti2", .linkage = linkage });
282 const __popcountsi2 = @import("compiler_rt/popcount.zig").__popcountsi2;
283 @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = linkage });
284 const __popcountdi2 = @import("compiler_rt/popcount.zig").__popcountdi2;
285 @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = linkage });
286 const __popcountti2 = @import("compiler_rt/popcount.zig").__popcountti2;
287 @export(__popcountti2, .{ .name = "__popcountti2", .linkage = linkage });
288 const __bswapsi2 = @import("compiler_rt/bswap.zig").__bswapsi2;
289 @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = linkage });
290 const __bswapdi2 = @import("compiler_rt/bswap.zig").__bswapdi2;
291 @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = linkage });
292 const __bswapti2 = @import("compiler_rt/bswap.zig").__bswapti2;
293 @export(__bswapti2, .{ .name = "__bswapti2", .linkage = linkage });
294
295 // Integral -> Float Conversion
296
297 // Conversion to f32
298 const __floatsisf = @import("compiler_rt/floatXiYf.zig").__floatsisf;
299 @export(__floatsisf, .{ .name = "__floatsisf", .linkage = linkage });
300 const __floatunsisf = @import("compiler_rt/floatXiYf.zig").__floatunsisf;
301 @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage });
302
303 const __floatundisf = @import("compiler_rt/floatXiYf.zig").__floatundisf;
304 @export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage });
305 const __floatdisf = @import("compiler_rt/floatXiYf.zig").__floatdisf;
306 @export(__floatdisf, .{ .name = "__floatdisf", .linkage = linkage });
307
308 const __floattisf = @import("compiler_rt/floatXiYf.zig").__floattisf;
309 @export(__floattisf, .{ .name = "__floattisf", .linkage = linkage });
310 const __floatuntisf = @import("compiler_rt/floatXiYf.zig").__floatuntisf;
311 @export(__floatuntisf, .{ .name = "__floatuntisf", .linkage = linkage });
312
313 // Conversion to f64
314 const __floatsidf = @import("compiler_rt/floatXiYf.zig").__floatsidf;
315 @export(__floatsidf, .{ .name = "__floatsidf", .linkage = linkage });
316 const __floatunsidf = @import("compiler_rt/floatXiYf.zig").__floatunsidf;
317 @export(__floatunsidf, .{ .name = "__floatunsidf", .linkage = linkage });
318
319 const __floatdidf = @import("compiler_rt/floatXiYf.zig").__floatdidf;
320 @export(__floatdidf, .{ .name = "__floatdidf", .linkage = linkage });
321 const __floatundidf = @import("compiler_rt/floatXiYf.zig").__floatundidf;
322 @export(__floatundidf, .{ .name = "__floatundidf", .linkage = linkage });
323
324 const __floattidf = @import("compiler_rt/floatXiYf.zig").__floattidf;
325 @export(__floattidf, .{ .name = "__floattidf", .linkage = linkage });
326 const __floatuntidf = @import("compiler_rt/floatXiYf.zig").__floatuntidf;
327 @export(__floatuntidf, .{ .name = "__floatuntidf", .linkage = linkage });
328
329 // Conversion to f80
330 const __floatsixf = @import("compiler_rt/floatXiYf.zig").__floatsixf;
331 @export(__floatsixf, .{ .name = "__floatsixf", .linkage = linkage });
332 const __floatunsixf = @import("compiler_rt/floatXiYf.zig").__floatunsixf;
333 @export(__floatunsixf, .{ .name = "__floatunsixf", .linkage = linkage });
334
335 const __floatdixf = @import("compiler_rt/floatXiYf.zig").__floatdixf;
336 @export(__floatdixf, .{ .name = "__floatdixf", .linkage = linkage });
337 const __floatundixf = @import("compiler_rt/floatXiYf.zig").__floatundixf;
338 @export(__floatundixf, .{ .name = "__floatundixf", .linkage = linkage });
339
340 const __floattixf = @import("compiler_rt/floatXiYf.zig").__floattixf;
341 @export(__floattixf, .{ .name = "__floattixf", .linkage = linkage });
342 const __floatuntixf = @import("compiler_rt/floatXiYf.zig").__floatuntixf;
343 @export(__floatuntixf, .{ .name = "__floatuntixf", .linkage = linkage });
344
345 // Conversion to f128
346 const __floatsitf = @import("compiler_rt/floatXiYf.zig").__floatsitf;
347 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = linkage });
348 const __floatunsitf = @import("compiler_rt/floatXiYf.zig").__floatunsitf;
349 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = linkage });
350
351 const __floatditf = @import("compiler_rt/floatXiYf.zig").__floatditf;
352 @export(__floatditf, .{ .name = "__floatditf", .linkage = linkage });
353 const __floatunditf = @import("compiler_rt/floatXiYf.zig").__floatunditf;
354 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = linkage });
355
356 const __floattitf = @import("compiler_rt/floatXiYf.zig").__floattitf;
357 @export(__floattitf, .{ .name = "__floattitf", .linkage = linkage });
358 const __floatuntitf = @import("compiler_rt/floatXiYf.zig").__floatuntitf;
359 @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = linkage });
360
361 // Float -> Integral Conversion
362
363 // Conversion from f32
364 const __fixsfsi = @import("compiler_rt/fixXfYi.zig").__fixsfsi;
365 @export(__fixsfsi, .{ .name = "__fixsfsi", .linkage = linkage });
366 const __fixunssfsi = @import("compiler_rt/fixXfYi.zig").__fixunssfsi;
367 @export(__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = linkage });
368
369 const __fixsfdi = @import("compiler_rt/fixXfYi.zig").__fixsfdi;
370 @export(__fixsfdi, .{ .name = "__fixsfdi", .linkage = linkage });
371 const __fixunssfdi = @import("compiler_rt/fixXfYi.zig").__fixunssfdi;
372 @export(__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = linkage });
373
374 const __fixsfti = @import("compiler_rt/fixXfYi.zig").__fixsfti;
375 @export(__fixsfti, .{ .name = "__fixsfti", .linkage = linkage });
376 const __fixunssfti = @import("compiler_rt/fixXfYi.zig").__fixunssfti;
377 @export(__fixunssfti, .{ .name = "__fixunssfti", .linkage = linkage });
378
379 // Conversion from f64
380 const __fixdfsi = @import("compiler_rt/fixXfYi.zig").__fixdfsi;
381 @export(__fixdfsi, .{ .name = "__fixdfsi", .linkage = linkage });
382 const __fixunsdfsi = @import("compiler_rt/fixXfYi.zig").__fixunsdfsi;
383 @export(__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = linkage });
384
385 const __fixdfdi = @import("compiler_rt/fixXfYi.zig").__fixdfdi;
386 @export(__fixdfdi, .{ .name = "__fixdfdi", .linkage = linkage });
387 const __fixunsdfdi = @import("compiler_rt/fixXfYi.zig").__fixunsdfdi;
388 @export(__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = linkage });
389
390 const __fixdfti = @import("compiler_rt/fixXfYi.zig").__fixdfti;
391 @export(__fixdfti, .{ .name = "__fixdfti", .linkage = linkage });
392 const __fixunsdfti = @import("compiler_rt/fixXfYi.zig").__fixunsdfti;
393 @export(__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = linkage });
394
395 // Conversion from f80
396 const __fixxfsi = @import("compiler_rt/fixXfYi.zig").__fixxfsi;
397 @export(__fixxfsi, .{ .name = "__fixxfsi", .linkage = linkage });
398 const __fixunsxfsi = @import("compiler_rt/fixXfYi.zig").__fixunsxfsi;
399 @export(__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = linkage });
400
401 const __fixxfdi = @import("compiler_rt/fixXfYi.zig").__fixxfdi;
402 @export(__fixxfdi, .{ .name = "__fixxfdi", .linkage = linkage });
403 const __fixunsxfdi = @import("compiler_rt/fixXfYi.zig").__fixunsxfdi;
404 @export(__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = linkage });
405
406 const __fixxfti = @import("compiler_rt/fixXfYi.zig").__fixxfti;
407 @export(__fixxfti, .{ .name = "__fixxfti", .linkage = linkage });
408 const __fixunsxfti = @import("compiler_rt/fixXfYi.zig").__fixunsxfti;
409 @export(__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = linkage });
410
411 // Conversion from f128
412 const __fixtfsi = @import("compiler_rt/fixXfYi.zig").__fixtfsi;
413 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = linkage });
414 const __fixunstfsi = @import("compiler_rt/fixXfYi.zig").__fixunstfsi;
415 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = linkage });
416
417 const __fixtfdi = @import("compiler_rt/fixXfYi.zig").__fixtfdi;
418 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = linkage });
419 const __fixunstfdi = @import("compiler_rt/fixXfYi.zig").__fixunstfdi;
420 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = linkage });
421
422 const __fixtfti = @import("compiler_rt/fixXfYi.zig").__fixtfti;
423 @export(__fixtfti, .{ .name = "__fixtfti", .linkage = linkage });
424 const __fixunstfti = @import("compiler_rt/fixXfYi.zig").__fixunstfti;
425 @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = linkage });
426
427 const __udivmoddi4 = @import("compiler_rt/int.zig").__udivmoddi4;
428 @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = linkage });
429
430 const __truncsfhf2 = @import("compiler_rt/truncXfYf2.zig").__truncsfhf2;
431 @export(__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = linkage });
432 if (!is_test) {
433 @export(__truncsfhf2, .{ .name = "__gnu_f2h_ieee", .linkage = linkage });
434 }
435 const __extendsfdf2 = @import("compiler_rt/extendXfYf2.zig").__extendsfdf2;
436 @export(__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = linkage });
437
438 if (is_darwin) {
439 const __isPlatformVersionAtLeast = @import("compiler_rt/os_version_check.zig").__isPlatformVersionAtLeast;
440 @export(__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage });
441 }
442
443 // Integer Arithmetic
444 const __ashldi3 = @import("compiler_rt/shift.zig").__ashldi3;
445 @export(__ashldi3, .{ .name = "__ashldi3", .linkage = linkage });
446 const __ashlti3 = @import("compiler_rt/shift.zig").__ashlti3;
447 @export(__ashlti3, .{ .name = "__ashlti3", .linkage = linkage });
448 const __ashrdi3 = @import("compiler_rt/shift.zig").__ashrdi3;
449 @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = linkage });
450 const __ashrti3 = @import("compiler_rt/shift.zig").__ashrti3;
451 @export(__ashrti3, .{ .name = "__ashrti3", .linkage = linkage });
452 const __lshrdi3 = @import("compiler_rt/shift.zig").__lshrdi3;
453 @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = linkage });
454 const __lshrti3 = @import("compiler_rt/shift.zig").__lshrti3;
455 @export(__lshrti3, .{ .name = "__lshrti3", .linkage = linkage });
456 const __negsi2 = @import("compiler_rt/negXi2.zig").__negsi2;
457 @export(__negsi2, .{ .name = "__negsi2", .linkage = linkage });
458 const __negdi2 = @import("compiler_rt/negXi2.zig").__negdi2;
459 @export(__negdi2, .{ .name = "__negdi2", .linkage = linkage });
460 const __negti2 = @import("compiler_rt/negXi2.zig").__negti2;
461 @export(__negti2, .{ .name = "__negti2", .linkage = linkage });
462
463 const __mulsi3 = @import("compiler_rt/int.zig").__mulsi3;
464 @export(__mulsi3, .{ .name = "__mulsi3", .linkage = linkage });
465 const __muldi3 = @import("compiler_rt/muldi3.zig").__muldi3;
466 @export(__muldi3, .{ .name = "__muldi3", .linkage = linkage });
467 const __divmoddi4 = @import("compiler_rt/int.zig").__divmoddi4;
468 @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = linkage });
469 const __divsi3 = @import("compiler_rt/int.zig").__divsi3;
470 @export(__divsi3, .{ .name = "__divsi3", .linkage = linkage });
471 const __divdi3 = @import("compiler_rt/int.zig").__divdi3;
472 @export(__divdi3, .{ .name = "__divdi3", .linkage = linkage });
473 const __udivsi3 = @import("compiler_rt/int.zig").__udivsi3;
474 @export(__udivsi3, .{ .name = "__udivsi3", .linkage = linkage });
475 const __udivdi3 = @import("compiler_rt/int.zig").__udivdi3;
476 @export(__udivdi3, .{ .name = "__udivdi3", .linkage = linkage });
477 const __modsi3 = @import("compiler_rt/int.zig").__modsi3;
478 @export(__modsi3, .{ .name = "__modsi3", .linkage = linkage });
479 const __moddi3 = @import("compiler_rt/int.zig").__moddi3;
480 @export(__moddi3, .{ .name = "__moddi3", .linkage = linkage });
481 const __umodsi3 = @import("compiler_rt/int.zig").__umodsi3;
482 @export(__umodsi3, .{ .name = "__umodsi3", .linkage = linkage });
483 const __umoddi3 = @import("compiler_rt/int.zig").__umoddi3;
484 @export(__umoddi3, .{ .name = "__umoddi3", .linkage = linkage });
485 const __divmodsi4 = @import("compiler_rt/int.zig").__divmodsi4;
486 @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = linkage });
487 const __udivmodsi4 = @import("compiler_rt/int.zig").__udivmodsi4;
488 @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = linkage });
489
490 // Integer Arithmetic with trapping overflow
491 const __absvsi2 = @import("compiler_rt/absv.zig").__absvsi2;
492 @export(__absvsi2, .{ .name = "__absvsi2", .linkage = linkage });
493 const __absvdi2 = @import("compiler_rt/absv.zig").__absvdi2;
494 @export(__absvdi2, .{ .name = "__absvdi2", .linkage = linkage });
495 const __absvti2 = @import("compiler_rt/absv.zig").__absvti2;
496 @export(__absvti2, .{ .name = "__absvti2", .linkage = linkage });
497 const __negvsi2 = @import("compiler_rt/negv.zig").__negvsi2;
498 @export(__negvsi2, .{ .name = "__negvsi2", .linkage = linkage });
499 const __negvdi2 = @import("compiler_rt/negv.zig").__negvdi2;
500 @export(__negvdi2, .{ .name = "__negvdi2", .linkage = linkage });
501 const __negvti2 = @import("compiler_rt/negv.zig").__negvti2;
502 @export(__negvti2, .{ .name = "__negvti2", .linkage = linkage });
503
504 // Integer arithmetic which returns if overflow
505 const __addosi4 = @import("compiler_rt/addo.zig").__addosi4;
506 @export(__addosi4, .{ .name = "__addosi4", .linkage = linkage });
507 const __addodi4 = @import("compiler_rt/addo.zig").__addodi4;
508 @export(__addodi4, .{ .name = "__addodi4", .linkage = linkage });
509 const __addoti4 = @import("compiler_rt/addo.zig").__addoti4;
510 @export(__addoti4, .{ .name = "__addoti4", .linkage = linkage });
511 const __subosi4 = @import("compiler_rt/subo.zig").__subosi4;
512 @export(__subosi4, .{ .name = "__subosi4", .linkage = linkage });
513 const __subodi4 = @import("compiler_rt/subo.zig").__subodi4;
514 @export(__subodi4, .{ .name = "__subodi4", .linkage = linkage });
515 const __suboti4 = @import("compiler_rt/subo.zig").__suboti4;
516 @export(__suboti4, .{ .name = "__suboti4", .linkage = linkage });
517 const __mulosi4 = @import("compiler_rt/mulo.zig").__mulosi4;
518 @export(__mulosi4, .{ .name = "__mulosi4", .linkage = linkage });
519 const __mulodi4 = @import("compiler_rt/mulo.zig").__mulodi4;
520 @export(__mulodi4, .{ .name = "__mulodi4", .linkage = linkage });
521 const __muloti4 = @import("compiler_rt/mulo.zig").__muloti4;
522 @export(__muloti4, .{ .name = "__muloti4", .linkage = linkage });
523
524 // Integer Comparison
525 // (a < b) => 0
526 // (a == b) => 1
527 // (a > b) => 2
528 const __cmpsi2 = @import("compiler_rt/cmp.zig").__cmpsi2;
529 @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = linkage });
530 const __cmpdi2 = @import("compiler_rt/cmp.zig").__cmpdi2;
531 @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = linkage });
532 const __cmpti2 = @import("compiler_rt/cmp.zig").__cmpti2;
533 @export(__cmpti2, .{ .name = "__cmpti2", .linkage = linkage });
534 const __ucmpsi2 = @import("compiler_rt/cmp.zig").__ucmpsi2;
535 @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = linkage });
536 const __ucmpdi2 = @import("compiler_rt/cmp.zig").__ucmpdi2;
537 @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = linkage });
538 const __ucmpti2 = @import("compiler_rt/cmp.zig").__ucmpti2;
539 @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = linkage });
7 _ = @import("compiler_rt/sin.zig");
8 _ = @import("compiler_rt/cos.zig");
9 _ = @import("compiler_rt/sincos.zig");
10 _ = @import("compiler_rt/ceil.zig");
11 _ = @import("compiler_rt/exp.zig");
12 _ = @import("compiler_rt/exp2.zig");
13 _ = @import("compiler_rt/fabs.zig");
14 _ = @import("compiler_rt/floor.zig");
15 _ = @import("compiler_rt/fma.zig");
16 _ = @import("compiler_rt/fmax.zig");
17 _ = @import("compiler_rt/fmin.zig");
18 _ = @import("compiler_rt/fmod.zig");
19 _ = @import("compiler_rt/log.zig");
20 _ = @import("compiler_rt/log10.zig");
21 _ = @import("compiler_rt/log2.zig");
22 _ = @import("compiler_rt/round.zig");
23 _ = @import("compiler_rt/sqrt.zig");
24 _ = @import("compiler_rt/tan.zig");
25 _ = @import("compiler_rt/trunc.zig");
26 _ = @import("compiler_rt/extendXfYf2.zig");
27 _ = @import("compiler_rt/extend_f80.zig");
28 _ = @import("compiler_rt/compareXf2.zig");
29 _ = @import("compiler_rt/stack_probe.zig");
30 _ = @import("compiler_rt/divti3.zig");
31 _ = @import("compiler_rt/modti3.zig");
32 _ = @import("compiler_rt/multi3.zig");
33 _ = @import("compiler_rt/udivti3.zig");
34 _ = @import("compiler_rt/udivmodti4.zig");
35 _ = @import("compiler_rt/umodti3.zig");
36 _ = @import("compiler_rt/truncXfYf2.zig");
37 _ = @import("compiler_rt/trunc_f80.zig");
38 _ = @import("compiler_rt/addXf3.zig");
39 _ = @import("compiler_rt/mulXf3.zig");
40 _ = @import("compiler_rt/divsf3.zig");
41 _ = @import("compiler_rt/divdf3.zig");
42 _ = @import("compiler_rt/divxf3.zig");
43 _ = @import("compiler_rt/divtf3.zig");
44 _ = @import("compiler_rt/floatXiYf.zig");
45 _ = @import("compiler_rt/fixXfYi.zig");
46 _ = @import("compiler_rt/count0bits.zig");
47 _ = @import("compiler_rt/parity.zig");
48 _ = @import("compiler_rt/popcount.zig");
49 _ = @import("compiler_rt/bswap.zig");
50 _ = @import("compiler_rt/int.zig");
51 _ = @import("compiler_rt/shift.zig");
52 _ = @import("compiler_rt/negXi2.zig");
53 _ = @import("compiler_rt/muldi3.zig");
54 _ = @import("compiler_rt/absv.zig");
55 _ = @import("compiler_rt/negv.zig");
56 _ = @import("compiler_rt/addo.zig");
57 _ = @import("compiler_rt/subo.zig");
58 _ = @import("compiler_rt/mulo.zig");
59 _ = @import("compiler_rt/cmp.zig");
60 _ = @import("compiler_rt/negXf2.zig");
61 _ = @import("compiler_rt/os_version_check.zig");
62 _ = @import("compiler_rt/emutls.zig");
63 _ = @import("compiler_rt/arm.zig");
64 _ = @import("compiler_rt/aulldiv.zig");
65 _ = @import("compiler_rt/sparc.zig");
66 _ = @import("compiler_rt/clear_cache.zig");
54067
54168 // missing: Floating point raised to integer power
54269
......@@ -544,342 +71,4 @@ comptime {
54471 // (a + ib) * (c + id)
54572 // (a + ib) / (c + id)
54673
547 const __negsf2 = @import("compiler_rt/negXf2.zig").__negsf2;
548 @export(__negsf2, .{ .name = "__negsf2", .linkage = linkage });
549 const __negdf2 = @import("compiler_rt/negXf2.zig").__negdf2;
550 @export(__negdf2, .{ .name = "__negdf2", .linkage = linkage });
551
552 if (builtin.link_libc and os_tag == .openbsd) {
553 const __emutls_get_address = @import("compiler_rt/emutls.zig").__emutls_get_address;
554 @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage });
555 }
556
557 if ((arch.isARM() or arch.isThumb()) and !is_test) {
558 const __aeabi_unwind_cpp_pr0 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr0;
559 @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage });
560 const __aeabi_unwind_cpp_pr1 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr1;
561 @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage });
562 const __aeabi_unwind_cpp_pr2 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr2;
563 @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage });
564
565 @export(__muldi3, .{ .name = "__aeabi_lmul", .linkage = linkage });
566
567 const __aeabi_ldivmod = @import("compiler_rt/arm.zig").__aeabi_ldivmod;
568 @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = linkage });
569 const __aeabi_uldivmod = @import("compiler_rt/arm.zig").__aeabi_uldivmod;
570 @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = linkage });
571
572 @export(__divsi3, .{ .name = "__aeabi_idiv", .linkage = linkage });
573 const __aeabi_idivmod = @import("compiler_rt/arm.zig").__aeabi_idivmod;
574 @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = linkage });
575 @export(__udivsi3, .{ .name = "__aeabi_uidiv", .linkage = linkage });
576 const __aeabi_uidivmod = @import("compiler_rt/arm.zig").__aeabi_uidivmod;
577 @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = linkage });
578
579 const __aeabi_memcpy = @import("compiler_rt/arm.zig").__aeabi_memcpy;
580 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = linkage });
581 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy4", .linkage = linkage });
582 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy8", .linkage = linkage });
583
584 const __aeabi_memmove = @import("compiler_rt/arm.zig").__aeabi_memmove;
585 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = linkage });
586 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove4", .linkage = linkage });
587 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove8", .linkage = linkage });
588
589 const __aeabi_memset = @import("compiler_rt/arm.zig").__aeabi_memset;
590 @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = linkage });
591 @export(__aeabi_memset, .{ .name = "__aeabi_memset4", .linkage = linkage });
592 @export(__aeabi_memset, .{ .name = "__aeabi_memset8", .linkage = linkage });
593
594 const __aeabi_memclr = @import("compiler_rt/arm.zig").__aeabi_memclr;
595 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = linkage });
596 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage });
597 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage });
598
599 if (os_tag == .linux) {
600 const __aeabi_read_tp = @import("compiler_rt/arm.zig").__aeabi_read_tp;
601 @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage });
602 }
603
604 const __aeabi_f2d = @import("compiler_rt/extendXfYf2.zig").__aeabi_f2d;
605 @export(__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });
606 const __aeabi_i2d = @import("compiler_rt/floatXiYf.zig").__aeabi_i2d;
607 @export(__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });
608 const __aeabi_l2d = @import("compiler_rt/floatXiYf.zig").__aeabi_l2d;
609 @export(__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });
610 const __aeabi_l2f = @import("compiler_rt/floatXiYf.zig").__aeabi_l2f;
611 @export(__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = linkage });
612 const __aeabi_ui2d = @import("compiler_rt/floatXiYf.zig").__aeabi_ui2d;
613 @export(__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = linkage });
614 const __aeabi_ul2d = @import("compiler_rt/floatXiYf.zig").__aeabi_ul2d;
615 @export(__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = linkage });
616 const __aeabi_ui2f = @import("compiler_rt/floatXiYf.zig").__aeabi_ui2f;
617 @export(__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = linkage });
618 const __aeabi_ul2f = @import("compiler_rt/floatXiYf.zig").__aeabi_ul2f;
619 @export(__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = linkage });
620
621 const __aeabi_fneg = @import("compiler_rt/negXf2.zig").__aeabi_fneg;
622 @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = linkage });
623 const __aeabi_dneg = @import("compiler_rt/negXf2.zig").__aeabi_dneg;
624 @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = linkage });
625
626 const __aeabi_fmul = @import("compiler_rt/mulXf3.zig").__aeabi_fmul;
627 @export(__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = linkage });
628 const __aeabi_dmul = @import("compiler_rt/mulXf3.zig").__aeabi_dmul;
629 @export(__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = linkage });
630
631 const __aeabi_d2h = @import("compiler_rt/truncXfYf2.zig").__aeabi_d2h;
632 @export(__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = linkage });
633
634 const __aeabi_f2ulz = @import("compiler_rt/fixXfYi.zig").__aeabi_f2ulz;
635 @export(__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = linkage });
636 const __aeabi_d2ulz = @import("compiler_rt/fixXfYi.zig").__aeabi_d2ulz;
637 @export(__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = linkage });
638
639 const __aeabi_f2lz = @import("compiler_rt/fixXfYi.zig").__aeabi_f2lz;
640 @export(__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = linkage });
641 const __aeabi_d2lz = @import("compiler_rt/fixXfYi.zig").__aeabi_d2lz;
642 @export(__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = linkage });
643
644 const __aeabi_d2uiz = @import("compiler_rt/fixXfYi.zig").__aeabi_d2uiz;
645 @export(__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = linkage });
646
647 const __aeabi_h2f = @import("compiler_rt/extendXfYf2.zig").__aeabi_h2f;
648 @export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = linkage });
649 const __aeabi_f2h = @import("compiler_rt/truncXfYf2.zig").__aeabi_f2h;
650 @export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = linkage });
651
652 const __aeabi_i2f = @import("compiler_rt/floatXiYf.zig").__aeabi_i2f;
653 @export(__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = linkage });
654 const __aeabi_d2f = @import("compiler_rt/truncXfYf2.zig").__aeabi_d2f;
655 @export(__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = linkage });
656
657 const __aeabi_fadd = @import("compiler_rt/addXf3.zig").__aeabi_fadd;
658 @export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = linkage });
659 const __aeabi_dadd = @import("compiler_rt/addXf3.zig").__aeabi_dadd;
660 @export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = linkage });
661 const __aeabi_fsub = @import("compiler_rt/addXf3.zig").__aeabi_fsub;
662 @export(__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = linkage });
663 const __aeabi_dsub = @import("compiler_rt/addXf3.zig").__aeabi_dsub;
664 @export(__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = linkage });
665
666 const __aeabi_f2uiz = @import("compiler_rt/fixXfYi.zig").__aeabi_f2uiz;
667 @export(__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = linkage });
668
669 const __aeabi_f2iz = @import("compiler_rt/fixXfYi.zig").__aeabi_f2iz;
670 @export(__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = linkage });
671 const __aeabi_d2iz = @import("compiler_rt/fixXfYi.zig").__aeabi_d2iz;
672 @export(__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = linkage });
673
674 const __aeabi_fdiv = @import("compiler_rt/divsf3.zig").__aeabi_fdiv;
675 @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = linkage });
676 const __aeabi_ddiv = @import("compiler_rt/divdf3.zig").__aeabi_ddiv;
677 @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = linkage });
678
679 const __aeabi_llsl = @import("compiler_rt/shift.zig").__aeabi_llsl;
680 @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = linkage });
681 const __aeabi_lasr = @import("compiler_rt/shift.zig").__aeabi_lasr;
682 @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = linkage });
683 const __aeabi_llsr = @import("compiler_rt/shift.zig").__aeabi_llsr;
684 @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = linkage });
685
686 const __aeabi_fcmpeq = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpeq;
687 @export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = linkage });
688 const __aeabi_fcmplt = @import("compiler_rt/compareXf2.zig").__aeabi_fcmplt;
689 @export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = linkage });
690 const __aeabi_fcmple = @import("compiler_rt/compareXf2.zig").__aeabi_fcmple;
691 @export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = linkage });
692 const __aeabi_fcmpge = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpge;
693 @export(__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = linkage });
694 const __aeabi_fcmpgt = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpgt;
695 @export(__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = linkage });
696 const __aeabi_fcmpun = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpun;
697 @export(__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = linkage });
698
699 const __aeabi_dcmpeq = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpeq;
700 @export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = linkage });
701 const __aeabi_dcmplt = @import("compiler_rt/compareXf2.zig").__aeabi_dcmplt;
702 @export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = linkage });
703 const __aeabi_dcmple = @import("compiler_rt/compareXf2.zig").__aeabi_dcmple;
704 @export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = linkage });
705 const __aeabi_dcmpge = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpge;
706 @export(__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = linkage });
707 const __aeabi_dcmpgt = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpgt;
708 @export(__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = linkage });
709 const __aeabi_dcmpun = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpun;
710 @export(__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage });
711 }
712
713 if (arch == .i386 and abi == .msvc) {
714 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
715 const _alldiv = @import("compiler_rt/aulldiv.zig")._alldiv;
716 @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = strong_linkage });
717 const _aulldiv = @import("compiler_rt/aulldiv.zig")._aulldiv;
718 @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = strong_linkage });
719 const _allrem = @import("compiler_rt/aullrem.zig")._allrem;
720 @export(_allrem, .{ .name = "\x01__allrem", .linkage = strong_linkage });
721 const _aullrem = @import("compiler_rt/aullrem.zig")._aullrem;
722 @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage });
723 }
724
725 mathExport("ceil", @import("./compiler_rt/ceil.zig"));
726 mathExport("cos", @import("./compiler_rt/cos.zig"));
727 mathExport("exp", @import("./compiler_rt/exp.zig"));
728 mathExport("exp2", @import("./compiler_rt/exp2.zig"));
729 mathExport("fabs", @import("./compiler_rt/fabs.zig"));
730 mathExport("floor", @import("./compiler_rt/floor.zig"));
731 mathExport("fma", @import("./compiler_rt/fma.zig"));
732 mathExport("fmax", @import("./compiler_rt/fmax.zig"));
733 mathExport("fmin", @import("./compiler_rt/fmin.zig"));
734 mathExport("fmod", @import("./compiler_rt/fmod.zig"));
735 mathExport("log", @import("./compiler_rt/log.zig"));
736 mathExport("log10", @import("./compiler_rt/log10.zig"));
737 mathExport("log2", @import("./compiler_rt/log2.zig"));
738 mathExport("round", @import("./compiler_rt/round.zig"));
739 mathExport("sin", @import("./compiler_rt/sin.zig"));
740 mathExport("sincos", @import("./compiler_rt/sincos.zig"));
741 mathExport("sqrt", @import("./compiler_rt/sqrt.zig"));
742 mathExport("tan", @import("./compiler_rt/tan.zig"));
743 mathExport("trunc", @import("./compiler_rt/trunc.zig"));
744
745 if (arch.isSPARC()) {
746 // SPARC systems use a different naming scheme
747 const _Qp_add = @import("compiler_rt/sparc.zig")._Qp_add;
748 @export(_Qp_add, .{ .name = "_Qp_add", .linkage = linkage });
749 const _Qp_div = @import("compiler_rt/sparc.zig")._Qp_div;
750 @export(_Qp_div, .{ .name = "_Qp_div", .linkage = linkage });
751 const _Qp_mul = @import("compiler_rt/sparc.zig")._Qp_mul;
752 @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = linkage });
753 const _Qp_sub = @import("compiler_rt/sparc.zig")._Qp_sub;
754 @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = linkage });
755
756 const _Qp_cmp = @import("compiler_rt/sparc.zig")._Qp_cmp;
757 @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = linkage });
758 const _Qp_feq = @import("compiler_rt/sparc.zig")._Qp_feq;
759 @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = linkage });
760 const _Qp_fne = @import("compiler_rt/sparc.zig")._Qp_fne;
761 @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = linkage });
762 const _Qp_flt = @import("compiler_rt/sparc.zig")._Qp_flt;
763 @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = linkage });
764 const _Qp_fle = @import("compiler_rt/sparc.zig")._Qp_fle;
765 @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = linkage });
766 const _Qp_fgt = @import("compiler_rt/sparc.zig")._Qp_fgt;
767 @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = linkage });
768 const _Qp_fge = @import("compiler_rt/sparc.zig")._Qp_fge;
769 @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = linkage });
770
771 const _Qp_itoq = @import("compiler_rt/sparc.zig")._Qp_itoq;
772 @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = linkage });
773 const _Qp_uitoq = @import("compiler_rt/sparc.zig")._Qp_uitoq;
774 @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = linkage });
775 const _Qp_xtoq = @import("compiler_rt/sparc.zig")._Qp_xtoq;
776 @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = linkage });
777 const _Qp_uxtoq = @import("compiler_rt/sparc.zig")._Qp_uxtoq;
778 @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = linkage });
779 const _Qp_stoq = @import("compiler_rt/sparc.zig")._Qp_stoq;
780 @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = linkage });
781 const _Qp_dtoq = @import("compiler_rt/sparc.zig")._Qp_dtoq;
782 @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = linkage });
783 const _Qp_qtoi = @import("compiler_rt/sparc.zig")._Qp_qtoi;
784 @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = linkage });
785 const _Qp_qtoui = @import("compiler_rt/sparc.zig")._Qp_qtoui;
786 @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = linkage });
787 const _Qp_qtox = @import("compiler_rt/sparc.zig")._Qp_qtox;
788 @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = linkage });
789 const _Qp_qtoux = @import("compiler_rt/sparc.zig")._Qp_qtoux;
790 @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = linkage });
791 const _Qp_qtos = @import("compiler_rt/sparc.zig")._Qp_qtos;
792 @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = linkage });
793 const _Qp_qtod = @import("compiler_rt/sparc.zig")._Qp_qtod;
794 @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage });
795 }
796
797 if (is_ppc and !is_test) {
798 @export(__addtf3, .{ .name = "__addkf3", .linkage = linkage });
799 @export(__subtf3, .{ .name = "__subkf3", .linkage = linkage });
800 @export(__multf3, .{ .name = "__mulkf3", .linkage = linkage });
801 @export(__divtf3, .{ .name = "__divkf3", .linkage = linkage });
802 @export(__extendsftf2, .{ .name = "__extendsfkf2", .linkage = linkage });
803 @export(__extenddftf2, .{ .name = "__extenddfkf2", .linkage = linkage });
804 @export(__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = linkage });
805 @export(__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = linkage });
806 @export(__fixtfdi, .{ .name = "__fixkfdi", .linkage = linkage });
807 @export(__fixtfsi, .{ .name = "__fixkfsi", .linkage = linkage });
808 @export(__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = linkage });
809 @export(__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = linkage });
810 @export(__floatsitf, .{ .name = "__floatsikf", .linkage = linkage });
811 @export(__floatditf, .{ .name = "__floatdikf", .linkage = linkage });
812 @export(__floatunditf, .{ .name = "__floatundikf", .linkage = linkage });
813 @export(__floatunsitf, .{ .name = "__floatunsikf", .linkage = linkage });
814 @export(__floatuntitf, .{ .name = "__floatuntikf", .linkage = linkage });
815
816 @export(__letf2, .{ .name = "__eqkf2", .linkage = linkage });
817 @export(__letf2, .{ .name = "__nekf2", .linkage = linkage });
818 @export(__getf2, .{ .name = "__gekf2", .linkage = linkage });
819 @export(__letf2, .{ .name = "__ltkf2", .linkage = linkage });
820 @export(__letf2, .{ .name = "__lekf2", .linkage = linkage });
821 @export(__getf2, .{ .name = "__gtkf2", .linkage = linkage });
822 @export(__unordtf2, .{ .name = "__unordkf2", .linkage = linkage });
823 }
824}
825
826inline fn mathExport(double_name: []const u8, comptime import: type) void {
827 const half_name = "__" ++ double_name ++ "h";
828 const half_fn = @field(import, half_name);
829 const float_name = double_name ++ "f";
830 const float_fn = @field(import, float_name);
831 const double_fn = @field(import, double_name);
832 const long_double_name = double_name ++ "l";
833 const xf80_name = "__" ++ double_name ++ "x";
834 const xf80_fn = @field(import, xf80_name);
835 const quad_name = double_name ++ "q";
836 const quad_fn = @field(import, quad_name);
837
838 @export(half_fn, .{ .name = half_name, .linkage = linkage });
839 @export(float_fn, .{ .name = float_name, .linkage = linkage });
840 @export(double_fn, .{ .name = double_name, .linkage = linkage });
841 @export(xf80_fn, .{ .name = xf80_name, .linkage = linkage });
842 @export(quad_fn, .{ .name = quad_name, .linkage = linkage });
843
844 if (is_test) return;
845
846 const pairs = .{
847 .{ f16, half_fn },
848 .{ f32, float_fn },
849 .{ f64, double_fn },
850 .{ f80, xf80_fn },
851 .{ f128, quad_fn },
852 };
853
854 if (builtin.os.tag == .windows) {
855 // Weak aliases don't work on Windows, so we have to provide the 'l' variants
856 // as additional function definitions that jump to the real definition.
857 const long_double_fn = @field(import, long_double_name);
858 @export(long_double_fn, .{ .name = long_double_name, .linkage = linkage });
859 } else {
860 inline for (pairs) |pair| {
861 const F = pair[0];
862 const func = pair[1];
863 if (builtin.target.longDoubleIs(F)) {
864 @export(func, .{ .name = long_double_name, .linkage = linkage });
865 }
866 }
867 }
868
869 if (is_ppc) {
870 // LLVM PPC backend lowers f128 ops with the suffix `f128` instead of `l`.
871 @export(quad_fn, .{ .name = double_name ++ "f128", .linkage = linkage });
872 }
873}
874
875// Avoid dragging in the runtime safety mechanisms into this .o file,
876// unless we're trying to test this file.
877pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
878 _ = error_return_trace;
879 @setCold(true);
880 if (is_test) {
881 std.debug.panic("{s}", .{msg});
882 } else {
883 unreachable;
884 }
88574}
lib/compiler_rt/absv.zig+10
......@@ -1,6 +1,16 @@
11// absv - absolute oVerflow
22// * @panic, if value can not be represented
33// - absvXi4_generic for unoptimized version
4const std = @import("std");
5const builtin = @import("builtin");
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7pub const panic = @import("common.zig").panic;
8
9comptime {
10 @export(__absvsi2, .{ .name = "__absvsi2", .linkage = linkage });
11 @export(__absvdi2, .{ .name = "__absvdi2", .linkage = linkage });
12 @export(__absvti2, .{ .name = "__absvti2", .linkage = linkage });
13}
414
515inline fn absvXi(comptime ST: type, a: ST) ST {
616 const UT = switch (ST) {
lib/compiler_rt/addXf3.zig+43-16
......@@ -3,9 +3,41 @@
33// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc
44
55const std = @import("std");
6const math = std.math;
76const builtin = @import("builtin");
8const compiler_rt = @import("../compiler_rt.zig");
7const math = std.math;
8const arch = builtin.cpu.arch;
9const is_test = builtin.is_test;
10const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
11
12const common = @import("common.zig");
13const normalize = common.normalize;
14pub const panic = common.panic;
15
16comptime {
17 @export(__addsf3, .{ .name = "__addsf3", .linkage = linkage });
18 @export(__adddf3, .{ .name = "__adddf3", .linkage = linkage });
19 @export(__addxf3, .{ .name = "__addxf3", .linkage = linkage });
20 @export(__addtf3, .{ .name = "__addtf3", .linkage = linkage });
21
22 @export(__subsf3, .{ .name = "__subsf3", .linkage = linkage });
23 @export(__subdf3, .{ .name = "__subdf3", .linkage = linkage });
24 @export(__subxf3, .{ .name = "__subxf3", .linkage = linkage });
25 @export(__subtf3, .{ .name = "__subtf3", .linkage = linkage });
26
27 if (!is_test) {
28 if (arch.isARM() or arch.isThumb()) {
29 @export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = linkage });
30 @export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = linkage });
31 @export(__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = linkage });
32 @export(__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = linkage });
33 }
34
35 if (arch.isPPC() or arch.isPPC64()) {
36 @export(__addkf3, .{ .name = "__addkf3", .linkage = linkage });
37 @export(__subkf3, .{ .name = "__subkf3", .linkage = linkage });
38 }
39 }
40}
941
1042pub fn __addsf3(a: f32, b: f32) callconv(.C) f32 {
1143 return addXf3(f32, a, b);
......@@ -29,6 +61,10 @@ pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 {
2961 return addXf3(f128, a, b);
3062}
3163
64pub fn __addkf3(a: f128, b: f128) callconv(.C) f128 {
65 return @call(.{ .modifier = .always_inline }, __addtf3, .{ a, b });
66}
67
3268pub fn __subsf3(a: f32, b: f32) callconv(.C) f32 {
3369 const neg_b = @bitCast(f32, @bitCast(u32, b) ^ (@as(u32, 1) << 31));
3470 return addXf3(f32, a, neg_b);
......@@ -44,6 +80,10 @@ pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 {
4480 return addXf3(f128, a, neg_b);
4581}
4682
83pub fn __subkf3(a: f128, b: f128) callconv(.C) f128 {
84 return @call(.{ .modifier = .always_inline }, __subtf3, .{ a, b });
85}
86
4787pub fn __aeabi_fadd(a: f32, b: f32) callconv(.AAPCS) f32 {
4888 @setRuntimeSafety(false);
4989 return @call(.{ .modifier = .always_inline }, __addsf3, .{ a, b });
......@@ -65,20 +105,7 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 {
65105}
66106
67107// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
68fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
69 const bits = @typeInfo(T).Float.bits;
70 const Z = std.meta.Int(.unsigned, bits);
71 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
72 const fractionalBits = math.floatFractionalBits(T);
73 const integerBit = @as(Z, 1) << fractionalBits;
74
75 const shift = @clz(std.meta.Int(.unsigned, bits), significand.*) - @clz(Z, integerBit);
76 significand.* <<= @intCast(S, shift);
77 return @as(i32, 1) - shift;
78}
79
80// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
81fn addXf3(comptime T: type, a: T, b: T) T {
108pub fn addXf3(comptime T: type, a: T, b: T) T {
82109 const bits = @typeInfo(T).Float.bits;
83110 const Z = std.meta.Int(.unsigned, bits);
84111 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
lib/compiler_rt/addo.zig+10
......@@ -1,4 +1,14 @@
1const std = @import("std");
12const builtin = @import("builtin");
3const is_test = builtin.is_test;
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 @export(__addosi4, .{ .name = "__addosi4", .linkage = linkage });
9 @export(__addodi4, .{ .name = "__addodi4", .linkage = linkage });
10 @export(__addoti4, .{ .name = "__addoti4", .linkage = linkage });
11}
212
313// addo - add overflow
414// * return a+%b.
lib/compiler_rt/arm.zig+72
......@@ -1,5 +1,45 @@
11// ARM specific builtins
2const std = @import("std");
23const builtin = @import("builtin");
4const arch = builtin.cpu.arch;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 if (!builtin.is_test) {
10 if (arch.isARM() or arch.isThumb()) {
11 @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage });
12 @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage });
13 @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage });
14
15 @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = linkage });
16 @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = linkage });
17
18 @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = linkage });
19 @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = linkage });
20
21 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = linkage });
22 @export(__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = linkage });
23 @export(__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = linkage });
24
25 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = linkage });
26 @export(__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = linkage });
27 @export(__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = linkage });
28
29 @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = linkage });
30 @export(__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = linkage });
31 @export(__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = linkage });
32
33 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = linkage });
34 @export(__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = linkage });
35 @export(__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = linkage });
36
37 if (builtin.os.tag == .linux) {
38 @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage });
39 }
40 }
41 }
42}
343
444const __divmodsi4 = @import("int.zig").__divmodsi4;
545const __udivmodsi4 = @import("int.zig").__udivmodsi4;
......@@ -14,11 +54,27 @@ pub fn __aeabi_memcpy(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
1454 @setRuntimeSafety(false);
1555 _ = memcpy(dest, src, n);
1656}
57pub fn __aeabi_memcpy4(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
58 @setRuntimeSafety(false);
59 _ = memcpy(dest, src, n);
60}
61pub fn __aeabi_memcpy8(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
62 @setRuntimeSafety(false);
63 _ = memcpy(dest, src, n);
64}
1765
1866pub fn __aeabi_memmove(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
1967 @setRuntimeSafety(false);
2068 _ = memmove(dest, src, n);
2169}
70pub fn __aeabi_memmove4(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
71 @setRuntimeSafety(false);
72 _ = memmove(dest, src, n);
73}
74pub fn __aeabi_memmove8(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
75 @setRuntimeSafety(false);
76 _ = memmove(dest, src, n);
77}
2278
2379pub fn __aeabi_memset(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
2480 @setRuntimeSafety(false);
......@@ -26,11 +82,27 @@ pub fn __aeabi_memset(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
2682 // two arguments swapped
2783 _ = memset(dest, c, n);
2884}
85pub fn __aeabi_memset4(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
86 @setRuntimeSafety(false);
87 _ = memset(dest, c, n);
88}
89pub fn __aeabi_memset8(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
90 @setRuntimeSafety(false);
91 _ = memset(dest, c, n);
92}
2993
3094pub fn __aeabi_memclr(dest: [*]u8, n: usize) callconv(.AAPCS) void {
3195 @setRuntimeSafety(false);
3296 _ = memset(dest, 0, n);
3397}
98pub fn __aeabi_memclr4(dest: [*]u8, n: usize) callconv(.AAPCS) void {
99 @setRuntimeSafety(false);
100 _ = memset(dest, 0, n);
101}
102pub fn __aeabi_memclr8(dest: [*]u8, n: usize) callconv(.AAPCS) void {
103 @setRuntimeSafety(false);
104 _ = memset(dest, 0, n);
105}
34106
35107// Dummy functions to avoid errors during the linking phase
36108pub fn __aeabi_unwind_cpp_pr0() callconv(.C) void {}
lib/compiler_rt/atomics.zig+1-1
......@@ -2,8 +2,8 @@ const std = @import("std");
22const builtin = @import("builtin");
33const cpu = builtin.cpu;
44const arch = cpu.arch;
5
65const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
77
88// This parameter is true iff the target architecture supports the bare minimum
99// to implement the atomic load/store intrinsics.
lib/compiler_rt/aulldiv.zig+15
......@@ -1,4 +1,19 @@
1const std = @import("std");
12const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
4const abi = builtin.abi;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 if (arch == .i386 and abi == .msvc) {
10 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
11 @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = linkage });
12 @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = linkage });
13 @export(_allrem, .{ .name = "\x01__allrem", .linkage = linkage });
14 @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = linkage });
15 }
16}
217
318pub fn _alldiv(a: i64, b: i64) callconv(.Stdcall) i64 {
419 @setRuntimeSafety(builtin.is_test);
lib/compiler_rt/bswap.zig+9
......@@ -1,5 +1,14 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const is_test = builtin.is_test;
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = linkage });
9 @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = linkage });
10 @export(__bswapti2, .{ .name = "__bswapti2", .linkage = linkage });
11}
312
413// bswap - byteswap
514// - bswapXi2 for unoptimized big and little endian
lib/compiler_rt/ceil.zig+23
......@@ -5,8 +5,27 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/ceil.c
66
77const std = @import("std");
8const builtin = @import("builtin");
9const arch = builtin.cpu.arch;
810const math = std.math;
911const expect = std.testing.expect;
12const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
13pub const panic = @import("common.zig").panic;
14
15comptime {
16 @export(__ceilh, .{ .name = "__ceilh", .linkage = linkage });
17 @export(ceilf, .{ .name = "ceilf", .linkage = linkage });
18 @export(ceil, .{ .name = "ceil", .linkage = linkage });
19 @export(__ceilx, .{ .name = "__ceilx", .linkage = linkage });
20 @export(ceilq, .{ .name = "ceilq", .linkage = linkage });
21 @export(ceill, .{ .name = "ceill", .linkage = linkage });
22
23 if (!builtin.is_test) {
24 if (arch.isPPC() or arch.isPPC64()) {
25 @export(ceilf128, .{ .name = "ceilf128", .linkage = linkage });
26 }
27 }
28}
1029
1130pub fn __ceilh(x: f16) callconv(.C) f16 {
1231 // TODO: more efficient implementation
......@@ -111,6 +130,10 @@ pub fn ceilq(x: f128) callconv(.C) f128 {
111130 }
112131}
113132
133pub fn ceilf128(x: f128) callconv(.C) f128 {
134 return @call(.{ .modifier = .always_inline }, ceilq, .{x});
135}
136
114137pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble {
115138 switch (@typeInfo(c_longdouble).Float.bits) {
116139 16 => return __ceilh(x),
lib/compiler_rt/clear_cache.zig+8-1
......@@ -2,6 +2,7 @@ const std = @import("std");
22const builtin = @import("builtin");
33const arch = builtin.cpu.arch;
44const os = builtin.os.tag;
5pub const panic = @import("common.zig").panic;
56
67// Ported from llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28
78
......@@ -10,7 +11,13 @@ const os = builtin.os.tag;
1011// It is expected to invalidate the instruction cache for the
1112// specified range.
1213
13pub fn clear_cache(start: usize, end: usize) callconv(.C) void {
14comptime {
15 if (builtin.zig_backend != .stage2_llvm) {
16 _ = clear_cache;
17 }
18}
19
20fn clear_cache(start: usize, end: usize) callconv(.C) void {
1421 const x86 = switch (arch) {
1522 .i386, .x86_64 => true,
1623 else => false,
lib/compiler_rt/cmp.zig+12
......@@ -1,5 +1,17 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const is_test = builtin.is_test;
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = linkage });
9 @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = linkage });
10 @export(__cmpti2, .{ .name = "__cmpti2", .linkage = linkage });
11 @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = linkage });
12 @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = linkage });
13 @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = linkage });
14}
315
416// cmp - signed compare
517// - cmpXi2_generic for unoptimized little and big endian
lib/compiler_rt/common.zig created+144
......@@ -0,0 +1,144 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const math = std.math;
4const is_test = builtin.is_test;
5
6// Avoid dragging in the runtime safety mechanisms into this .o file,
7// unless we're trying to test this file.
8pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
9 _ = error_return_trace;
10 @setCold(true);
11 if (is_test) {
12 std.debug.panic("{s}", .{msg});
13 } else {
14 unreachable;
15 }
16}
17
18pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
19 @setRuntimeSafety(is_test);
20 switch (Z) {
21 u16 => {
22 // 16x16 --> 32 bit multiply
23 const product = @as(u32, a) * @as(u32, b);
24 hi.* = @intCast(u16, product >> 16);
25 lo.* = @truncate(u16, product);
26 },
27 u32 => {
28 // 32x32 --> 64 bit multiply
29 const product = @as(u64, a) * @as(u64, b);
30 hi.* = @truncate(u32, product >> 32);
31 lo.* = @truncate(u32, product);
32 },
33 u64 => {
34 const S = struct {
35 fn loWord(x: u64) u64 {
36 return @truncate(u32, x);
37 }
38 fn hiWord(x: u64) u64 {
39 return @truncate(u32, x >> 32);
40 }
41 };
42 // 64x64 -> 128 wide multiply for platforms that don't have such an operation;
43 // many 64-bit platforms have this operation, but they tend to have hardware
44 // floating-point, so we don't bother with a special case for them here.
45 // Each of the component 32x32 -> 64 products
46 const plolo: u64 = S.loWord(a) * S.loWord(b);
47 const plohi: u64 = S.loWord(a) * S.hiWord(b);
48 const philo: u64 = S.hiWord(a) * S.loWord(b);
49 const phihi: u64 = S.hiWord(a) * S.hiWord(b);
50 // Sum terms that contribute to lo in a way that allows us to get the carry
51 const r0: u64 = S.loWord(plolo);
52 const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo);
53 lo.* = r0 +% (r1 << 32);
54 // Sum terms contributing to hi with the carry from lo
55 hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi;
56 },
57 u128 => {
58 const Word_LoMask = @as(u64, 0x00000000ffffffff);
59 const Word_HiMask = @as(u64, 0xffffffff00000000);
60 const Word_FullMask = @as(u64, 0xffffffffffffffff);
61 const S = struct {
62 fn Word_1(x: u128) u64 {
63 return @truncate(u32, x >> 96);
64 }
65 fn Word_2(x: u128) u64 {
66 return @truncate(u32, x >> 64);
67 }
68 fn Word_3(x: u128) u64 {
69 return @truncate(u32, x >> 32);
70 }
71 fn Word_4(x: u128) u64 {
72 return @truncate(u32, x);
73 }
74 };
75 // 128x128 -> 256 wide multiply for platforms that don't have such an operation;
76 // many 64-bit platforms have this operation, but they tend to have hardware
77 // floating-point, so we don't bother with a special case for them here.
78
79 const product11: u64 = S.Word_1(a) * S.Word_1(b);
80 const product12: u64 = S.Word_1(a) * S.Word_2(b);
81 const product13: u64 = S.Word_1(a) * S.Word_3(b);
82 const product14: u64 = S.Word_1(a) * S.Word_4(b);
83 const product21: u64 = S.Word_2(a) * S.Word_1(b);
84 const product22: u64 = S.Word_2(a) * S.Word_2(b);
85 const product23: u64 = S.Word_2(a) * S.Word_3(b);
86 const product24: u64 = S.Word_2(a) * S.Word_4(b);
87 const product31: u64 = S.Word_3(a) * S.Word_1(b);
88 const product32: u64 = S.Word_3(a) * S.Word_2(b);
89 const product33: u64 = S.Word_3(a) * S.Word_3(b);
90 const product34: u64 = S.Word_3(a) * S.Word_4(b);
91 const product41: u64 = S.Word_4(a) * S.Word_1(b);
92 const product42: u64 = S.Word_4(a) * S.Word_2(b);
93 const product43: u64 = S.Word_4(a) * S.Word_3(b);
94 const product44: u64 = S.Word_4(a) * S.Word_4(b);
95
96 const sum0: u128 = @as(u128, product44);
97 const sum1: u128 = @as(u128, product34) +%
98 @as(u128, product43);
99 const sum2: u128 = @as(u128, product24) +%
100 @as(u128, product33) +%
101 @as(u128, product42);
102 const sum3: u128 = @as(u128, product14) +%
103 @as(u128, product23) +%
104 @as(u128, product32) +%
105 @as(u128, product41);
106 const sum4: u128 = @as(u128, product13) +%
107 @as(u128, product22) +%
108 @as(u128, product31);
109 const sum5: u128 = @as(u128, product12) +%
110 @as(u128, product21);
111 const sum6: u128 = @as(u128, product11);
112
113 const r0: u128 = (sum0 & Word_FullMask) +%
114 ((sum1 & Word_LoMask) << 32);
115 const r1: u128 = (sum0 >> 64) +%
116 ((sum1 >> 32) & Word_FullMask) +%
117 (sum2 & Word_FullMask) +%
118 ((sum3 << 32) & Word_HiMask);
119
120 lo.* = r0 +% (r1 << 64);
121 hi.* = (r1 >> 64) +%
122 (sum1 >> 96) +%
123 (sum2 >> 64) +%
124 (sum3 >> 32) +%
125 sum4 +%
126 (sum5 << 32) +%
127 (sum6 << 64);
128 },
129 else => @compileError("unsupported"),
130 }
131}
132
133// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
134pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
135 const bits = @typeInfo(T).Float.bits;
136 const Z = std.meta.Int(.unsigned, bits);
137 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
138 const fractionalBits = math.floatFractionalBits(T);
139 const integerBit = @as(Z, 1) << fractionalBits;
140
141 const shift = @clz(std.meta.Int(.unsigned, bits), significand.*) - @clz(Z, integerBit);
142 significand.* <<= @intCast(S, shift);
143 return @as(i32, 1) - shift;
144}
lib/compiler_rt/compareXf2.zig+128-16
......@@ -4,6 +4,78 @@
44
55const std = @import("std");
66const builtin = @import("builtin");
7const is_test = builtin.is_test;
8const arch = builtin.cpu.arch;
9const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
10pub const panic = @import("common.zig").panic;
11
12comptime {
13 @export(__lesf2, .{ .name = "__lesf2", .linkage = linkage });
14 @export(__ledf2, .{ .name = "__ledf2", .linkage = linkage });
15 @export(__letf2, .{ .name = "__letf2", .linkage = linkage });
16 @export(__lexf2, .{ .name = "__lexf2", .linkage = linkage });
17
18 @export(__gesf2, .{ .name = "__gesf2", .linkage = linkage });
19 @export(__gedf2, .{ .name = "__gedf2", .linkage = linkage });
20 @export(__getf2, .{ .name = "__getf2", .linkage = linkage });
21 @export(__gexf2, .{ .name = "__gexf2", .linkage = linkage });
22
23 @export(__eqsf2, .{ .name = "__eqsf2", .linkage = linkage });
24 @export(__eqdf2, .{ .name = "__eqdf2", .linkage = linkage });
25 @export(__eqxf2, .{ .name = "__eqxf2", .linkage = linkage });
26
27 @export(__ltsf2, .{ .name = "__ltsf2", .linkage = linkage });
28 @export(__ltdf2, .{ .name = "__ltdf2", .linkage = linkage });
29 @export(__ltxf2, .{ .name = "__ltxf2", .linkage = linkage });
30
31 @export(__nesf2, .{ .name = "__nesf2", .linkage = linkage });
32 @export(__nedf2, .{ .name = "__nedf2", .linkage = linkage });
33 @export(__nexf2, .{ .name = "__nexf2", .linkage = linkage });
34
35 @export(__gtsf2, .{ .name = "__gtsf2", .linkage = linkage });
36 @export(__gtdf2, .{ .name = "__gtdf2", .linkage = linkage });
37 @export(__gtxf2, .{ .name = "__gtxf2", .linkage = linkage });
38
39 @export(__unordsf2, .{ .name = "__unordsf2", .linkage = linkage });
40 @export(__unorddf2, .{ .name = "__unorddf2", .linkage = linkage });
41 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = linkage });
42
43 if (!is_test) {
44 @export(__cmpsf2, .{ .name = "__cmpsf2", .linkage = linkage });
45 @export(__cmpdf2, .{ .name = "__cmpdf2", .linkage = linkage });
46 @export(__cmptf2, .{ .name = "__cmptf2", .linkage = linkage });
47 @export(__eqtf2, .{ .name = "__eqtf2", .linkage = linkage });
48 @export(__lttf2, .{ .name = "__lttf2", .linkage = linkage });
49 @export(__gttf2, .{ .name = "__gttf2", .linkage = linkage });
50 @export(__netf2, .{ .name = "__netf2", .linkage = linkage });
51
52 if (arch.isARM() or arch.isThumb()) {
53 @export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = linkage });
54 @export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = linkage });
55 @export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = linkage });
56 @export(__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = linkage });
57 @export(__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = linkage });
58 @export(__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = linkage });
59
60 @export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = linkage });
61 @export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = linkage });
62 @export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = linkage });
63 @export(__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = linkage });
64 @export(__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = linkage });
65 @export(__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage });
66 }
67
68 if (arch.isPPC() or arch.isPPC64()) {
69 @export(__eqkf2, .{ .name = "__eqkf2", .linkage = linkage });
70 @export(__nekf2, .{ .name = "__nekf2", .linkage = linkage });
71 @export(__gekf2, .{ .name = "__gekf2", .linkage = linkage });
72 @export(__ltkf2, .{ .name = "__ltkf2", .linkage = linkage });
73 @export(__lekf2, .{ .name = "__lekf2", .linkage = linkage });
74 @export(__gtkf2, .{ .name = "__gtkf2", .linkage = linkage });
75 @export(__unordkf2, .{ .name = "__unordkf2", .linkage = linkage });
76 }
77 }
78}
779
880const LE = enum(i32) {
981 Less = -1,
......@@ -98,20 +170,24 @@ pub fn __gesf2(a: f32, b: f32) callconv(.C) i32 {
98170 return @bitCast(i32, float);
99171}
100172
173pub fn __cmpsf2(a: f32, b: f32) callconv(.C) i32 {
174 return @call(.{ .modifier = .always_inline }, __lesf2, .{ a, b });
175}
176
101177pub fn __eqsf2(a: f32, b: f32) callconv(.C) i32 {
102 return __lesf2(a, b);
178 return @call(.{ .modifier = .always_inline }, __lesf2, .{ a, b });
103179}
104180
105181pub fn __ltsf2(a: f32, b: f32) callconv(.C) i32 {
106 return __lesf2(a, b);
182 return @call(.{ .modifier = .always_inline }, __lesf2, .{ a, b });
107183}
108184
109185pub fn __nesf2(a: f32, b: f32) callconv(.C) i32 {
110 return __lesf2(a, b);
186 return @call(.{ .modifier = .always_inline }, __lesf2, .{ a, b });
111187}
112188
113189pub fn __gtsf2(a: f32, b: f32) callconv(.C) i32 {
114 return __gesf2(a, b);
190 return @call(.{ .modifier = .always_inline }, __gesf2, .{ a, b });
115191}
116192
117193// Comparison between f64
......@@ -128,20 +204,24 @@ pub fn __gedf2(a: f64, b: f64) callconv(.C) i32 {
128204 return @bitCast(i32, float);
129205}
130206
207pub fn __cmpdf2(a: f64, b: f64) callconv(.C) i32 {
208 return @call(.{ .modifier = .always_inline }, __ledf2, .{ a, b });
209}
210
131211pub fn __eqdf2(a: f64, b: f64) callconv(.C) i32 {
132 return __ledf2(a, b);
212 return @call(.{ .modifier = .always_inline }, __ledf2, .{ a, b });
133213}
134214
135215pub fn __ltdf2(a: f64, b: f64) callconv(.C) i32 {
136 return __ledf2(a, b);
216 return @call(.{ .modifier = .always_inline }, __ledf2, .{ a, b });
137217}
138218
139219pub fn __nedf2(a: f64, b: f64) callconv(.C) i32 {
140 return __ledf2(a, b);
220 return @call(.{ .modifier = .always_inline }, __ledf2, .{ a, b });
141221}
142222
143223pub fn __gtdf2(a: f64, b: f64) callconv(.C) i32 {
144 return __gedf2(a, b);
224 return @call(.{ .modifier = .always_inline }, __gedf2, .{ a, b });
145225}
146226
147227// Comparison between f80
......@@ -196,19 +276,19 @@ pub fn __gexf2(a: f80, b: f80) callconv(.C) i32 {
196276}
197277
198278pub fn __eqxf2(a: f80, b: f80) callconv(.C) i32 {
199 return __lexf2(a, b);
279 return @call(.{ .modifier = .always_inline }, __lexf2, .{ a, b });
200280}
201281
202282pub fn __ltxf2(a: f80, b: f80) callconv(.C) i32 {
203 return __lexf2(a, b);
283 return @call(.{ .modifier = .always_inline }, __lexf2, .{ a, b });
204284}
205285
206286pub fn __nexf2(a: f80, b: f80) callconv(.C) i32 {
207 return __lexf2(a, b);
287 return @call(.{ .modifier = .always_inline }, __lexf2, .{ a, b });
208288}
209289
210290pub fn __gtxf2(a: f80, b: f80) callconv(.C) i32 {
211 return __gexf2(a, b);
291 return @call(.{ .modifier = .always_inline }, __gexf2, .{ a, b });
212292}
213293
214294// Comparison between f128
......@@ -225,20 +305,48 @@ pub fn __getf2(a: f128, b: f128) callconv(.C) i32 {
225305 return @bitCast(i32, float);
226306}
227307
308pub fn __cmptf2(a: f128, b: f128) callconv(.C) i32 {
309 return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b });
310}
311
228312pub fn __eqtf2(a: f128, b: f128) callconv(.C) i32 {
229 return __letf2(a, b);
313 return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b });
230314}
231315
232316pub fn __lttf2(a: f128, b: f128) callconv(.C) i32 {
233 return __letf2(a, b);
317 return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b });
234318}
235319
236320pub fn __netf2(a: f128, b: f128) callconv(.C) i32 {
237 return __letf2(a, b);
321 return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b });
238322}
239323
240324pub fn __gttf2(a: f128, b: f128) callconv(.C) i32 {
241 return __getf2(a, b);
325 return @call(.{ .modifier = .always_inline }, __getf2, .{ a, b });
326}
327
328pub fn __eqkf2(a: f128, b: f128) callconv(.C) i32 {
329 return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b });
330}
331
332pub fn __nekf2(a: f128, b: f128) callconv(.C) i32 {
333 return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b });
334}
335
336pub fn __gekf2(a: f128, b: f128) callconv(.C) i32 {
337 return @call(.{ .modifier = .always_inline }, __getf2, .{ a, b });
338}
339
340pub fn __ltkf2(a: f128, b: f128) callconv(.C) i32 {
341 return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b });
342}
343
344pub fn __lekf2(a: f128, b: f128) callconv(.C) i32 {
345 return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b });
346}
347
348pub fn __gtkf2(a: f128, b: f128) callconv(.C) i32 {
349 return @call(.{ .modifier = .always_inline }, __getf2, .{ a, b });
242350}
243351
244352// Unordered comparison between f32/f64/f128
......@@ -258,6 +366,10 @@ pub fn __unordtf2(a: f128, b: f128) callconv(.C) i32 {
258366 return unordcmp(f128, a, b);
259367}
260368
369pub fn __unordkf2(a: f128, b: f128) callconv(.C) i32 {
370 return @call(.{ .modifier = .always_inline }, __unordtf2, .{ a, b });
371}
372
261373// ARM EABI intrinsics
262374
263375pub fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 {
lib/compiler_rt/cos.zig+23
......@@ -1,11 +1,30 @@
11const std = @import("std");
2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
24const math = std.math;
35const expect = std.testing.expect;
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7pub const panic = @import("common.zig").panic;
48
59const trig = @import("trig.zig");
610const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
711const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
812
13comptime {
14 @export(__cosh, .{ .name = "__cosh", .linkage = linkage });
15 @export(cosf, .{ .name = "cosf", .linkage = linkage });
16 @export(cos, .{ .name = "cos", .linkage = linkage });
17 @export(__cosx, .{ .name = "__cosx", .linkage = linkage });
18 @export(cosq, .{ .name = "cosq", .linkage = linkage });
19 @export(cosl, .{ .name = "cosl", .linkage = linkage });
20
21 if (!builtin.is_test) {
22 if (arch.isPPC() or arch.isPPC64()) {
23 @export(cosf128, .{ .name = "cosf128", .linkage = linkage });
24 }
25 }
26}
27
928pub fn __cosh(a: f16) callconv(.C) f16 {
1029 // TODO: more efficient implementation
1130 return @floatCast(f16, cosf(a));
......@@ -107,6 +126,10 @@ pub fn cosq(a: f128) callconv(.C) f128 {
107126 return cos(@floatCast(f64, a));
108127}
109128
129pub fn cosf128(a: f128) callconv(.C) f128 {
130 return @call(.{ .modifier = .always_inline }, cosq, .{a});
131}
132
110133pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble {
111134 switch (@typeInfo(c_longdouble).Float.bits) {
112135 16 => return __cosh(x),
lib/compiler_rt/count0bits.zig+15
......@@ -1,5 +1,20 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const is_test = builtin.is_test;
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 @export(__clzsi2, .{ .name = "__clzsi2", .linkage = linkage });
9 @export(__clzdi2, .{ .name = "__clzdi2", .linkage = linkage });
10 @export(__clzti2, .{ .name = "__clzti2", .linkage = linkage });
11 @export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = linkage });
12 @export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = linkage });
13 @export(__ctzti2, .{ .name = "__ctzti2", .linkage = linkage });
14 @export(__ffssi2, .{ .name = "__ffssi2", .linkage = linkage });
15 @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = linkage });
16 @export(__ffsti2, .{ .name = "__ffsti2", .linkage = linkage });
17}
318
419// clz - count leading zeroes
520// - clzXi2 for unoptimized little and big endian
lib/compiler_rt/divdf3.zig+18-119
......@@ -4,6 +4,24 @@
44
55const std = @import("std");
66const builtin = @import("builtin");
7const arch = builtin.cpu.arch;
8const is_test = builtin.is_test;
9const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
10
11const common = @import("common.zig");
12const normalize = common.normalize;
13const wideMultiply = common.wideMultiply;
14pub const panic = common.panic;
15
16comptime {
17 @export(__divdf3, .{ .name = "__divdf3", .linkage = linkage });
18
19 if (!is_test) {
20 if (arch.isARM() or arch.isThumb()) {
21 @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = linkage });
22 }
23 }
24}
725
826pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
927 @setRuntimeSafety(builtin.is_test);
......@@ -202,125 +220,6 @@ pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
202220 }
203221}
204222
205pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
206 @setRuntimeSafety(builtin.is_test);
207 switch (Z) {
208 u32 => {
209 // 32x32 --> 64 bit multiply
210 const product = @as(u64, a) * @as(u64, b);
211 hi.* = @truncate(u32, product >> 32);
212 lo.* = @truncate(u32, product);
213 },
214 u64 => {
215 const S = struct {
216 fn loWord(x: u64) u64 {
217 return @truncate(u32, x);
218 }
219 fn hiWord(x: u64) u64 {
220 return @truncate(u32, x >> 32);
221 }
222 };
223 // 64x64 -> 128 wide multiply for platforms that don't have such an operation;
224 // many 64-bit platforms have this operation, but they tend to have hardware
225 // floating-point, so we don't bother with a special case for them here.
226 // Each of the component 32x32 -> 64 products
227 const plolo: u64 = S.loWord(a) * S.loWord(b);
228 const plohi: u64 = S.loWord(a) * S.hiWord(b);
229 const philo: u64 = S.hiWord(a) * S.loWord(b);
230 const phihi: u64 = S.hiWord(a) * S.hiWord(b);
231 // Sum terms that contribute to lo in a way that allows us to get the carry
232 const r0: u64 = S.loWord(plolo);
233 const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo);
234 lo.* = r0 +% (r1 << 32);
235 // Sum terms contributing to hi with the carry from lo
236 hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi;
237 },
238 u128 => {
239 const Word_LoMask = @as(u64, 0x00000000ffffffff);
240 const Word_HiMask = @as(u64, 0xffffffff00000000);
241 const Word_FullMask = @as(u64, 0xffffffffffffffff);
242 const S = struct {
243 fn Word_1(x: u128) u64 {
244 return @truncate(u32, x >> 96);
245 }
246 fn Word_2(x: u128) u64 {
247 return @truncate(u32, x >> 64);
248 }
249 fn Word_3(x: u128) u64 {
250 return @truncate(u32, x >> 32);
251 }
252 fn Word_4(x: u128) u64 {
253 return @truncate(u32, x);
254 }
255 };
256 // 128x128 -> 256 wide multiply for platforms that don't have such an operation;
257 // many 64-bit platforms have this operation, but they tend to have hardware
258 // floating-point, so we don't bother with a special case for them here.
259
260 const product11: u64 = S.Word_1(a) * S.Word_1(b);
261 const product12: u64 = S.Word_1(a) * S.Word_2(b);
262 const product13: u64 = S.Word_1(a) * S.Word_3(b);
263 const product14: u64 = S.Word_1(a) * S.Word_4(b);
264 const product21: u64 = S.Word_2(a) * S.Word_1(b);
265 const product22: u64 = S.Word_2(a) * S.Word_2(b);
266 const product23: u64 = S.Word_2(a) * S.Word_3(b);
267 const product24: u64 = S.Word_2(a) * S.Word_4(b);
268 const product31: u64 = S.Word_3(a) * S.Word_1(b);
269 const product32: u64 = S.Word_3(a) * S.Word_2(b);
270 const product33: u64 = S.Word_3(a) * S.Word_3(b);
271 const product34: u64 = S.Word_3(a) * S.Word_4(b);
272 const product41: u64 = S.Word_4(a) * S.Word_1(b);
273 const product42: u64 = S.Word_4(a) * S.Word_2(b);
274 const product43: u64 = S.Word_4(a) * S.Word_3(b);
275 const product44: u64 = S.Word_4(a) * S.Word_4(b);
276
277 const sum0: u128 = @as(u128, product44);
278 const sum1: u128 = @as(u128, product34) +%
279 @as(u128, product43);
280 const sum2: u128 = @as(u128, product24) +%
281 @as(u128, product33) +%
282 @as(u128, product42);
283 const sum3: u128 = @as(u128, product14) +%
284 @as(u128, product23) +%
285 @as(u128, product32) +%
286 @as(u128, product41);
287 const sum4: u128 = @as(u128, product13) +%
288 @as(u128, product22) +%
289 @as(u128, product31);
290 const sum5: u128 = @as(u128, product12) +%
291 @as(u128, product21);
292 const sum6: u128 = @as(u128, product11);
293
294 const r0: u128 = (sum0 & Word_FullMask) +%
295 ((sum1 & Word_LoMask) << 32);
296 const r1: u128 = (sum0 >> 64) +%
297 ((sum1 >> 32) & Word_FullMask) +%
298 (sum2 & Word_FullMask) +%
299 ((sum3 << 32) & Word_HiMask);
300
301 lo.* = r0 +% (r1 << 64);
302 hi.* = (r1 >> 64) +%
303 (sum1 >> 96) +%
304 (sum2 >> 64) +%
305 (sum3 >> 32) +%
306 sum4 +%
307 (sum5 << 32) +%
308 (sum6 << 64);
309 },
310 else => @compileError("unsupported"),
311 }
312}
313
314pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
315 @setRuntimeSafety(builtin.is_test);
316 const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
317 const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T);
318
319 const shift = @clz(Z, significand.*) - @clz(Z, integerBit);
320 significand.* <<= @intCast(std.math.Log2Int(Z), shift);
321 return @as(i32, 1) - shift;
322}
323
324223pub fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 {
325224 @setRuntimeSafety(false);
326225 return @call(.{ .modifier = .always_inline }, __divdf3, .{ a, b });
lib/compiler_rt/divsf3.zig+17-11
......@@ -4,6 +4,23 @@
44
55const std = @import("std");
66const builtin = @import("builtin");
7const arch = builtin.cpu.arch;
8const is_test = builtin.is_test;
9const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
10
11const common = @import("common.zig");
12const normalize = common.normalize;
13pub const panic = common.panic;
14
15comptime {
16 @export(__divsf3, .{ .name = "__divsf3", .linkage = linkage });
17
18 if (!is_test) {
19 if (arch.isARM() or arch.isThumb()) {
20 @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = linkage });
21 }
22 }
23}
724
825pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
926 @setRuntimeSafety(builtin.is_test);
......@@ -184,17 +201,6 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
184201 }
185202}
186203
187fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
188 @setRuntimeSafety(builtin.is_test);
189 const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
190 const significandBits = std.math.floatMantissaBits(T);
191 const implicitBit = @as(Z, 1) << significandBits;
192
193 const shift = @clz(Z, significand.*) - @clz(Z, implicitBit);
194 significand.* <<= @intCast(std.math.Log2Int(Z), shift);
195 return 1 - shift;
196}
197
198204pub fn __aeabi_fdiv(a: f32, b: f32) callconv(.AAPCS) f32 {
199205 @setRuntimeSafety(false);
200206 return @call(.{ .modifier = .always_inline }, __divsf3, .{ a, b });
lib/compiler_rt/divtf3.zig+21-2
......@@ -1,8 +1,27 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
4const is_test = builtin.is_test;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
36
4const normalize = @import("divdf3.zig").normalize;
5const wideMultiply = @import("divdf3.zig").wideMultiply;
7const common = @import("common.zig");
8const normalize = common.normalize;
9const wideMultiply = common.wideMultiply;
10pub const panic = common.panic;
11
12comptime {
13 @export(__divtf3, .{ .name = "__divtf3", .linkage = linkage });
14
15 if (!is_test) {
16 if (arch.isPPC() or arch.isPPC64()) {
17 @export(__divkf3, .{ .name = "__divkf3", .linkage = linkage });
18 }
19 }
20}
21
22pub fn __divkf3(a: f128, b: f128) callconv(.C) f128 {
23 return @call(.{ .modifier = .always_inline }, __divtf3, .{ a, b });
24}
625
726pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
827 @setRuntimeSafety(builtin.is_test);
lib/compiler_rt/divti3.zig+27-1
......@@ -1,5 +1,31 @@
1const udivmod = @import("udivmod.zig").udivmod;
1const std = @import("std");
22const builtin = @import("builtin");
3const udivmod = @import("udivmod.zig").udivmod;
4const arch = builtin.cpu.arch;
5const is_test = builtin.is_test;
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7pub const panic = @import("common.zig").panic;
8
9comptime {
10 if (builtin.os.tag == .windows) {
11 switch (arch) {
12 .i386 => {
13 @export(__divti3, .{ .name = "__divti3", .linkage = linkage });
14 },
15 .x86_64 => {
16 // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI
17 // that LLVM expects compiler-rt to have.
18 @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = linkage });
19 },
20 else => {},
21 }
22 if (arch.isAARCH64()) {
23 @export(__divti3, .{ .name = "__divti3", .linkage = linkage });
24 }
25 } else {
26 @export(__divti3, .{ .name = "__divti3", .linkage = linkage });
27 }
28}
329
430pub fn __divti3(a: i128, b: i128) callconv(.C) i128 {
531 @setRuntimeSafety(builtin.is_test);
lib/compiler_rt/divxf3.zig+12-2
......@@ -1,7 +1,17 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const normalize = @import("divdf3.zig").normalize;
4const wideMultiply = @import("divdf3.zig").wideMultiply;
3const arch = builtin.cpu.arch;
4const is_test = builtin.is_test;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6
7const common = @import("common.zig");
8const normalize = common.normalize;
9const wideMultiply = common.wideMultiply;
10pub const panic = common.panic;
11
12comptime {
13 @export(__divxf3, .{ .name = "__divxf3", .linkage = linkage });
14}
515
616pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
717 @setRuntimeSafety(builtin.is_test);
lib/compiler_rt/emutls.zig+13-1
......@@ -6,6 +6,8 @@
66
77const std = @import("std");
88const builtin = @import("builtin");
9const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
10pub const panic = @import("common.zig").panic;
911
1012const abort = std.os.abort;
1113const assert = std.debug.assert;
......@@ -16,7 +18,9 @@ const expect = std.testing.expect;
1618const gcc_word = usize;
1719
1820comptime {
19 assert(builtin.link_libc);
21 if (builtin.link_libc and builtin.os.tag == .openbsd) {
22 @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage });
23 }
2024}
2125
2226/// public entrypoint for generated code using EmulatedTLS
......@@ -319,6 +323,8 @@ const emutls_control = extern struct {
319323};
320324
321325test "simple_allocator" {
326 if (!builtin.link_libc or builtin.os.tag != .openbsd) return error.SkipZigTest;
327
322328 var data1: *[64]u8 = simple_allocator.alloc([64]u8);
323329 defer simple_allocator.free(data1);
324330 for (data1) |*c| {
......@@ -333,6 +339,8 @@ test "simple_allocator" {
333339}
334340
335341test "__emutls_get_address zeroed" {
342 if (!builtin.link_libc or builtin.os.tag != .openbsd) return error.SkipZigTest;
343
336344 var ctl = emutls_control.init(usize, null);
337345 try expect(ctl.object.index == 0);
338346
......@@ -352,6 +360,8 @@ test "__emutls_get_address zeroed" {
352360}
353361
354362test "__emutls_get_address with default_value" {
363 if (!builtin.link_libc or builtin.os.tag != .openbsd) return error.SkipZigTest;
364
355365 var value: usize = 5678; // default value
356366 var ctl = emutls_control.init(usize, &value);
357367 try expect(ctl.object.index == 0);
......@@ -370,6 +380,8 @@ test "__emutls_get_address with default_value" {
370380}
371381
372382test "test default_value with differents sizes" {
383 if (!builtin.link_libc or builtin.os.tag != .openbsd) return error.SkipZigTest;
384
373385 const testType = struct {
374386 fn _testType(comptime T: type, value: T) !void {
375387 var def: T = value;
lib/compiler_rt/exp.zig+23
......@@ -5,8 +5,27 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/exp.c
66
77const std = @import("std");
8const builtin = @import("builtin");
9const arch = builtin.cpu.arch;
810const math = std.math;
911const expect = std.testing.expect;
12const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
13pub const panic = @import("common.zig").panic;
14
15comptime {
16 @export(__exph, .{ .name = "__exph", .linkage = linkage });
17 @export(expf, .{ .name = "expf", .linkage = linkage });
18 @export(exp, .{ .name = "exp", .linkage = linkage });
19 @export(__expx, .{ .name = "__expx", .linkage = linkage });
20 @export(expq, .{ .name = "expq", .linkage = linkage });
21 @export(expl, .{ .name = "expl", .linkage = linkage });
22
23 if (!builtin.is_test) {
24 if (arch.isPPC() or arch.isPPC64()) {
25 @export(expf128, .{ .name = "expf128", .linkage = linkage });
26 }
27 }
28}
1029
1130pub fn __exph(a: f16) callconv(.C) f16 {
1231 // TODO: more efficient implementation
......@@ -182,6 +201,10 @@ pub fn expq(a: f128) callconv(.C) f128 {
182201 return exp(@floatCast(f64, a));
183202}
184203
204pub fn expf128(a: f128) callconv(.C) f128 {
205 return @call(.{ .modifier = .always_inline }, expq, .{a});
206}
207
185208pub fn expl(x: c_longdouble) callconv(.C) c_longdouble {
186209 switch (@typeInfo(c_longdouble).Float.bits) {
187210 16 => return __exph(x),
lib/compiler_rt/exp2.zig+23
......@@ -5,8 +5,27 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/exp2.c
66
77const std = @import("std");
8const builtin = @import("builtin");
9const arch = builtin.cpu.arch;
810const math = std.math;
911const expect = std.testing.expect;
12const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
13pub const panic = @import("common.zig").panic;
14
15comptime {
16 @export(__exp2h, .{ .name = "__exp2h", .linkage = linkage });
17 @export(exp2f, .{ .name = "exp2f", .linkage = linkage });
18 @export(exp2, .{ .name = "exp2", .linkage = linkage });
19 @export(__exp2x, .{ .name = "__exp2x", .linkage = linkage });
20 @export(exp2q, .{ .name = "exp2q", .linkage = linkage });
21 @export(exp2l, .{ .name = "exp2l", .linkage = linkage });
22
23 if (!builtin.is_test) {
24 if (arch.isPPC() or arch.isPPC64()) {
25 @export(exp2f128, .{ .name = "exp2f128", .linkage = linkage });
26 }
27 }
28}
1029
1130pub fn __exp2h(x: f16) callconv(.C) f16 {
1231 // TODO: more efficient implementation
......@@ -149,6 +168,10 @@ pub fn exp2q(x: f128) callconv(.C) f128 {
149168 return exp2(@floatCast(f64, x));
150169}
151170
171pub fn exp2f128(x: f128) callconv(.C) f128 {
172 return @call(.{ .modifier = .always_inline }, exp2q, .{x});
173}
174
152175pub fn exp2l(x: c_longdouble) callconv(.C) c_longdouble {
153176 switch (@typeInfo(c_longdouble).Float.bits) {
154177 16 => return __exp2h(x),
lib/compiler_rt/extendXfYf2.zig+38-2
......@@ -1,7 +1,31 @@
11const std = @import("std");
22const builtin = @import("builtin");
33const is_test = builtin.is_test;
4const native_arch = builtin.cpu.arch;
4const arch = builtin.cpu.arch;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage });
10 @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = linkage });
11 @export(__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = linkage });
12 @export(__extendhftf2, .{ .name = "__extendhftf2", .linkage = linkage });
13 @export(__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = linkage });
14
15 if (!is_test) {
16 @export(__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = linkage });
17
18 if (arch.isARM() or arch.isThumb()) {
19 @export(__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });
20 @export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = linkage });
21 }
22
23 if (arch.isPPC() or arch.isPPC64()) {
24 @export(__extendsfkf2, .{ .name = "__extendsfkf2", .linkage = linkage });
25 @export(__extenddfkf2, .{ .name = "__extenddfkf2", .linkage = linkage });
26 }
27 }
28}
529
630pub fn __extendsfdf2(a: f32) callconv(.C) f64 {
731 return extendXfYf2(f64, f32, @bitCast(u32, a));
......@@ -11,18 +35,30 @@ pub fn __extenddftf2(a: f64) callconv(.C) f128 {
1135 return extendXfYf2(f128, f64, @bitCast(u64, a));
1236}
1337
38pub fn __extenddfkf2(a: f64) callconv(.C) f128 {
39 return @call(.{ .modifier = .always_inline }, __extenddftf2, .{a});
40}
41
1442pub fn __extendsftf2(a: f32) callconv(.C) f128 {
1543 return extendXfYf2(f128, f32, @bitCast(u32, a));
1644}
1745
46pub fn __extendsfkf2(a: f32) callconv(.C) f128 {
47 return @call(.{ .modifier = .always_inline }, __extendsftf2, .{a});
48}
49
1850// AArch64 is the only ABI (at the moment) to support f16 arguments without the
1951// need for extending them to wider fp types.
20pub const F16T = if (native_arch.isAARCH64()) f16 else u16;
52pub const F16T = if (arch.isAARCH64()) f16 else u16;
2153
2254pub fn __extendhfsf2(a: F16T) callconv(.C) f32 {
2355 return extendXfYf2(f32, f16, @bitCast(u16, a));
2456}
2557
58pub fn __gnu_h2f_ieee(a: F16T) callconv(.C) f32 {
59 return @call(.{ .modifier = .always_inline }, __extendhfsf2, .{a});
60}
61
2662pub fn __extendhftf2(a: F16T) callconv(.C) f128 {
2763 return extendXfYf2(f128, f16, @bitCast(u16, a));
2864}
lib/compiler_rt/extend_f80.zig+15-6
......@@ -1,21 +1,30 @@
11const std = @import("std");
22const builtin = @import("builtin");
33const is_test = builtin.is_test;
4const native_arch = builtin.cpu.arch;
4const arch = builtin.cpu.arch;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 @export(__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = linkage });
10 @export(__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = linkage });
11 @export(__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = linkage });
12 @export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = linkage });
13}
514
615// AArch64 is the only ABI (at the moment) to support f16 arguments without the
716// need for extending them to wider fp types.
8pub const F16T = if (native_arch.isAARCH64()) f16 else u16;
17const F16T = if (arch.isAARCH64()) f16 else u16;
918
10pub fn __extendhfxf2(a: F16T) callconv(.C) f80 {
19fn __extendhfxf2(a: F16T) callconv(.C) f80 {
1120 return extendF80(f16, @bitCast(u16, a));
1221}
1322
14pub fn __extendsfxf2(a: f32) callconv(.C) f80 {
23fn __extendsfxf2(a: f32) callconv(.C) f80 {
1524 return extendF80(f32, @bitCast(u32, a));
1625}
1726
18pub fn __extenddfxf2(a: f64) callconv(.C) f80 {
27fn __extenddfxf2(a: f64) callconv(.C) f80 {
1928 return extendF80(f64, @bitCast(u64, a));
2029}
2130
......@@ -86,7 +95,7 @@ inline fn extendF80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(s
8695 return std.math.make_f80(dst);
8796}
8897
89pub fn __extendxftf2(a: f80) callconv(.C) f128 {
98fn __extendxftf2(a: f80) callconv(.C) f128 {
9099 @setRuntimeSafety(builtin.is_test);
91100
92101 const src_int_bit: u64 = 0x8000000000000000;
lib/compiler_rt/fabs.zig+23
......@@ -1,4 +1,23 @@
11const std = @import("std");
2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 @export(__fabsh, .{ .name = "__fabsh", .linkage = linkage });
9 @export(fabsf, .{ .name = "fabsf", .linkage = linkage });
10 @export(fabs, .{ .name = "fabs", .linkage = linkage });
11 @export(__fabsx, .{ .name = "__fabsx", .linkage = linkage });
12 @export(fabsq, .{ .name = "fabsq", .linkage = linkage });
13 @export(fabsl, .{ .name = "fabsl", .linkage = linkage });
14
15 if (!builtin.is_test) {
16 if (arch.isPPC() or arch.isPPC64()) {
17 @export(fabsf128, .{ .name = "fabsf128", .linkage = linkage });
18 }
19 }
20}
221
322pub fn __fabsh(a: f16) callconv(.C) f16 {
423 return generic_fabs(a);
......@@ -20,6 +39,10 @@ pub fn fabsq(a: f128) callconv(.C) f128 {
2039 return generic_fabs(a);
2140}
2241
42pub fn fabsf128(a: f128) callconv(.C) f128 {
43 return @call(.{ .modifier = .always_inline }, fabsq, .{a});
44}
45
2346pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble {
2447 switch (@typeInfo(c_longdouble).Float.bits) {
2548 16 => return __fabsh(x),
lib/compiler_rt/fixXfYi.zig+89-1
......@@ -1,7 +1,79 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const math = std.math;
34const Log2Int = math.Log2Int;
4const is_test = @import("builtin").is_test;
5const arch = builtin.cpu.arch;
6const is_test = builtin.is_test;
7const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
8pub const panic = @import("common.zig").panic;
9
10comptime {
11 // Float -> Integral Conversion
12
13 // Conversion from f32
14 @export(__fixsfsi, .{ .name = "__fixsfsi", .linkage = linkage });
15 @export(__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = linkage });
16
17 @export(__fixsfdi, .{ .name = "__fixsfdi", .linkage = linkage });
18 @export(__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = linkage });
19
20 @export(__fixsfti, .{ .name = "__fixsfti", .linkage = linkage });
21 @export(__fixunssfti, .{ .name = "__fixunssfti", .linkage = linkage });
22
23 // Conversion from f64
24 @export(__fixdfsi, .{ .name = "__fixdfsi", .linkage = linkage });
25 @export(__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = linkage });
26
27 @export(__fixdfdi, .{ .name = "__fixdfdi", .linkage = linkage });
28 @export(__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = linkage });
29
30 @export(__fixdfti, .{ .name = "__fixdfti", .linkage = linkage });
31 @export(__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = linkage });
32
33 // Conversion from f80
34 @export(__fixxfsi, .{ .name = "__fixxfsi", .linkage = linkage });
35 @export(__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = linkage });
36
37 @export(__fixxfdi, .{ .name = "__fixxfdi", .linkage = linkage });
38 @export(__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = linkage });
39
40 @export(__fixxfti, .{ .name = "__fixxfti", .linkage = linkage });
41 @export(__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = linkage });
42
43 // Conversion from f128
44 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = linkage });
45 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = linkage });
46
47 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = linkage });
48 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = linkage });
49
50 @export(__fixtfti, .{ .name = "__fixtfti", .linkage = linkage });
51 @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = linkage });
52
53 if (!is_test) {
54 if (arch.isARM() or arch.isThumb()) {
55 @export(__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = linkage });
56 @export(__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = linkage });
57
58 @export(__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = linkage });
59 @export(__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = linkage });
60
61 @export(__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = linkage });
62
63 @export(__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = linkage });
64
65 @export(__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = linkage });
66 @export(__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = linkage });
67 }
68
69 if (arch.isPPC() or arch.isPPC64()) {
70 @export(__fixkfdi, .{ .name = "__fixkfdi", .linkage = linkage });
71 @export(__fixkfsi, .{ .name = "__fixkfsi", .linkage = linkage });
72 @export(__fixunskfsi, .{ .name = "__fixunskfsi", .linkage = linkage });
73 @export(__fixunskfdi, .{ .name = "__fixunskfdi", .linkage = linkage });
74 }
75 }
76}
577
678pub inline fn fixXfYi(comptime I: type, a: anytype) I {
779 @setRuntimeSafety(is_test);
......@@ -163,18 +235,34 @@ pub fn __fixtfsi(a: f128) callconv(.C) i32 {
163235 return fixXfYi(i32, a);
164236}
165237
238pub fn __fixkfsi(a: f128) callconv(.C) i32 {
239 return __fixtfsi(a);
240}
241
166242pub fn __fixunstfsi(a: f128) callconv(.C) u32 {
167243 return fixXfYi(u32, a);
168244}
169245
246pub fn __fixunskfsi(a: f128) callconv(.C) u32 {
247 return @call(.{ .modifier = .always_inline }, __fixunstfsi, .{a});
248}
249
170250pub fn __fixtfdi(a: f128) callconv(.C) i64 {
171251 return fixXfYi(i64, a);
172252}
173253
254pub fn __fixkfdi(a: f128) callconv(.C) i64 {
255 return @call(.{ .modifier = .always_inline }, __fixtfdi, .{a});
256}
257
174258pub fn __fixunstfdi(a: f128) callconv(.C) u64 {
175259 return fixXfYi(u64, a);
176260}
177261
262pub fn __fixunskfdi(a: f128) callconv(.C) u64 {
263 return @call(.{ .modifier = .always_inline }, __fixunstfdi, .{a});
264}
265
178266pub fn __fixtfti(a: f128) callconv(.C) i128 {
179267 return fixXfYi(i128, a);
180268}
lib/compiler_rt/floatXiYf.zig+90-1
......@@ -1,8 +1,77 @@
11const builtin = @import("builtin");
2const is_test = builtin.is_test;
32const std = @import("std");
43const math = std.math;
54const expect = std.testing.expect;
5const arch = builtin.cpu.arch;
6const is_test = builtin.is_test;
7const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
8pub const panic = @import("common.zig").panic;
9
10comptime {
11 // Integral -> Float Conversion
12
13 // Conversion to f32
14 @export(__floatsisf, .{ .name = "__floatsisf", .linkage = linkage });
15 @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage });
16
17 @export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage });
18 @export(__floatdisf, .{ .name = "__floatdisf", .linkage = linkage });
19
20 @export(__floattisf, .{ .name = "__floattisf", .linkage = linkage });
21 @export(__floatuntisf, .{ .name = "__floatuntisf", .linkage = linkage });
22
23 // Conversion to f64
24 @export(__floatsidf, .{ .name = "__floatsidf", .linkage = linkage });
25 @export(__floatunsidf, .{ .name = "__floatunsidf", .linkage = linkage });
26
27 @export(__floatdidf, .{ .name = "__floatdidf", .linkage = linkage });
28 @export(__floatundidf, .{ .name = "__floatundidf", .linkage = linkage });
29
30 @export(__floattidf, .{ .name = "__floattidf", .linkage = linkage });
31 @export(__floatuntidf, .{ .name = "__floatuntidf", .linkage = linkage });
32
33 // Conversion to f80
34 @export(__floatsixf, .{ .name = "__floatsixf", .linkage = linkage });
35 @export(__floatunsixf, .{ .name = "__floatunsixf", .linkage = linkage });
36
37 @export(__floatdixf, .{ .name = "__floatdixf", .linkage = linkage });
38 @export(__floatundixf, .{ .name = "__floatundixf", .linkage = linkage });
39
40 @export(__floattixf, .{ .name = "__floattixf", .linkage = linkage });
41 @export(__floatuntixf, .{ .name = "__floatuntixf", .linkage = linkage });
42
43 // Conversion to f128
44 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = linkage });
45 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = linkage });
46
47 @export(__floatditf, .{ .name = "__floatditf", .linkage = linkage });
48 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = linkage });
49
50 @export(__floattitf, .{ .name = "__floattitf", .linkage = linkage });
51 @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = linkage });
52
53 if (!is_test) {
54 if (arch.isARM() or arch.isThumb()) {
55 @export(__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });
56 @export(__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });
57 @export(__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = linkage });
58 @export(__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = linkage });
59 @export(__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = linkage });
60 @export(__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = linkage });
61 @export(__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = linkage });
62
63 @export(__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = linkage });
64 }
65
66 if (arch.isPPC() or arch.isPPC64()) {
67 @export(__floatsikf, .{ .name = "__floatsikf", .linkage = linkage });
68 @export(__floatdikf, .{ .name = "__floatdikf", .linkage = linkage });
69 @export(__floatundikf, .{ .name = "__floatundikf", .linkage = linkage });
70 @export(__floatunsikf, .{ .name = "__floatunsikf", .linkage = linkage });
71 @export(__floatuntikf, .{ .name = "__floatuntikf", .linkage = linkage });
72 }
73 }
74}
675
776pub fn floatXiYf(comptime T: type, x: anytype) T {
877 @setRuntimeSafety(is_test);
......@@ -163,18 +232,34 @@ pub fn __floatsitf(a: i32) callconv(.C) f128 {
163232 return floatXiYf(f128, a);
164233}
165234
235pub fn __floatsikf(a: i32) callconv(.C) f128 {
236 return @call(.{ .modifier = .always_inline }, __floatsitf, .{a});
237}
238
166239pub fn __floatunsitf(a: u32) callconv(.C) f128 {
167240 return floatXiYf(f128, a);
168241}
169242
243pub fn __floatunsikf(a: u32) callconv(.C) f128 {
244 return @call(.{ .modifier = .always_inline }, __floatunsitf, .{a});
245}
246
170247pub fn __floatditf(a: i64) callconv(.C) f128 {
171248 return floatXiYf(f128, a);
172249}
173250
251pub fn __floatdikf(a: i64) callconv(.C) f128 {
252 return @call(.{ .modifier = .always_inline }, __floatditf, .{a});
253}
254
174255pub fn __floatunditf(a: u64) callconv(.C) f128 {
175256 return floatXiYf(f128, a);
176257}
177258
259pub fn __floatundikf(a: u64) callconv(.C) f128 {
260 return @call(.{ .modifier = .always_inline }, __floatunditf, .{a});
261}
262
178263pub fn __floattitf(a: i128) callconv(.C) f128 {
179264 return floatXiYf(f128, a);
180265}
......@@ -183,6 +268,10 @@ pub fn __floatuntitf(a: u128) callconv(.C) f128 {
183268 return floatXiYf(f128, a);
184269}
185270
271pub fn __floatuntikf(a: u128) callconv(.C) f128 {
272 return @call(.{ .modifier = .always_inline }, __floatuntitf, .{a});
273}
274
186275// Conversion to f32
187276pub fn __aeabi_ui2f(arg: u32) callconv(.AAPCS) f32 {
188277 return floatXiYf(f32, arg);
lib/compiler_rt/floor.zig+23
......@@ -5,8 +5,27 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/floor.c
66
77const std = @import("std");
8const builtin = @import("builtin");
89const math = std.math;
910const expect = std.testing.expect;
11const arch = builtin.cpu.arch;
12const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
13pub const panic = @import("common.zig").panic;
14
15comptime {
16 @export(__floorh, .{ .name = "__floorh", .linkage = linkage });
17 @export(floorf, .{ .name = "floorf", .linkage = linkage });
18 @export(floor, .{ .name = "floor", .linkage = linkage });
19 @export(__floorx, .{ .name = "__floorx", .linkage = linkage });
20 @export(floorq, .{ .name = "floorq", .linkage = linkage });
21 @export(floorl, .{ .name = "floorl", .linkage = linkage });
22
23 if (!builtin.is_test) {
24 if (arch.isPPC() or arch.isPPC64()) {
25 @export(floorf128, .{ .name = "floorf128", .linkage = linkage });
26 }
27 }
28}
1029
1130pub fn __floorh(x: f16) callconv(.C) f16 {
1231 var u = @bitCast(u16, x);
......@@ -141,6 +160,10 @@ pub fn floorq(x: f128) callconv(.C) f128 {
141160 }
142161}
143162
163pub fn floorf128(x: f128) callconv(.C) f128 {
164 return @call(.{ .modifier = .always_inline }, floorq, .{x});
165}
166
144167pub fn floorl(x: c_longdouble) callconv(.C) c_longdouble {
145168 switch (@typeInfo(c_longdouble).Float.bits) {
146169 16 => return __floorh(x),
lib/compiler_rt/fma.zig+23
......@@ -6,8 +6,27 @@
66// https://git.musl-libc.org/cgit/musl/tree/src/math/fma.c
77
88const std = @import("std");
9const builtin = @import("builtin");
910const math = std.math;
1011const expect = std.testing.expect;
12const arch = builtin.cpu.arch;
13const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
14pub const panic = @import("common.zig").panic;
15
16comptime {
17 @export(__fmah, .{ .name = "__fmah", .linkage = linkage });
18 @export(fmaf, .{ .name = "fmaf", .linkage = linkage });
19 @export(fma, .{ .name = "fma", .linkage = linkage });
20 @export(__fmax, .{ .name = "__fmax", .linkage = linkage });
21 @export(fmaq, .{ .name = "fmaq", .linkage = linkage });
22 @export(fmal, .{ .name = "fmal", .linkage = linkage });
23
24 if (!builtin.is_test) {
25 if (arch.isPPC() or arch.isPPC64()) {
26 @export(fmaf128, .{ .name = "fmaf128", .linkage = linkage });
27 }
28 }
29}
1130
1231pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 {
1332 // TODO: more efficient implementation
......@@ -135,6 +154,10 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.C) f128 {
135154 }
136155}
137156
157pub fn fmaf128(x: f128, y: f128, z: f128) callconv(.C) f128 {
158 return @call(.{ .modifier = .always_inline }, fmaq, .{ x, y, z });
159}
160
138161pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.C) c_longdouble {
139162 switch (@typeInfo(c_longdouble).Float.bits) {
140163 16 => return __fmah(x, y, z),
lib/compiler_rt/fmax.zig+23
......@@ -1,5 +1,24 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const math = std.math;
4const arch = builtin.cpu.arch;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 @export(__fmaxh, .{ .name = "__fmaxh", .linkage = linkage });
10 @export(fmaxf, .{ .name = "fmaxf", .linkage = linkage });
11 @export(fmax, .{ .name = "fmax", .linkage = linkage });
12 @export(__fmaxx, .{ .name = "__fmaxx", .linkage = linkage });
13 @export(fmaxq, .{ .name = "fmaxq", .linkage = linkage });
14 @export(fmaxl, .{ .name = "fmaxl", .linkage = linkage });
15
16 if (!builtin.is_test) {
17 if (arch.isPPC() or arch.isPPC64()) {
18 @export(fmaxf128, .{ .name = "fmaxf128", .linkage = linkage });
19 }
20 }
21}
322
423pub fn __fmaxh(x: f16, y: f16) callconv(.C) f16 {
524 return generic_fmax(f16, x, y);
......@@ -21,6 +40,10 @@ pub fn fmaxq(x: f128, y: f128) callconv(.C) f128 {
2140 return generic_fmax(f128, x, y);
2241}
2342
43pub fn fmaxf128(x: f128, y: f128) callconv(.C) f128 {
44 return @call(.{ .modifier = .always_inline }, fmaxq, .{ x, y });
45}
46
2447pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble {
2548 switch (@typeInfo(c_longdouble).Float.bits) {
2649 16 => return __fmaxh(x, y),
lib/compiler_rt/fmin.zig+23
......@@ -1,5 +1,24 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const math = std.math;
4const arch = builtin.cpu.arch;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 @export(__fminh, .{ .name = "__fminh", .linkage = linkage });
10 @export(fminf, .{ .name = "fminf", .linkage = linkage });
11 @export(fmin, .{ .name = "fmin", .linkage = linkage });
12 @export(__fminx, .{ .name = "__fminx", .linkage = linkage });
13 @export(fminq, .{ .name = "fminq", .linkage = linkage });
14 @export(fminl, .{ .name = "fminl", .linkage = linkage });
15
16 if (!builtin.is_test) {
17 if (arch.isPPC() or arch.isPPC64()) {
18 @export(fminf128, .{ .name = "fminf128", .linkage = linkage });
19 }
20 }
21}
322
423pub fn __fminh(x: f16, y: f16) callconv(.C) f16 {
524 return generic_fmin(f16, x, y);
......@@ -21,6 +40,10 @@ pub fn fminq(x: f128, y: f128) callconv(.C) f128 {
2140 return generic_fmin(f128, x, y);
2241}
2342
43pub fn fminf128(x: f128, y: f128) callconv(.C) f128 {
44 return @call(.{ .modifier = .always_inline }, fminq, .{ x, y });
45}
46
2447pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble {
2548 switch (@typeInfo(c_longdouble).Float.bits) {
2649 16 => return __fminh(x, y),
lib/compiler_rt/fmod.zig+25-1
......@@ -2,7 +2,27 @@ const builtin = @import("builtin");
22const std = @import("std");
33const math = std.math;
44const assert = std.debug.assert;
5const normalize = @import("divdf3.zig").normalize;
5const arch = builtin.cpu.arch;
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7
8const common = @import("common.zig");
9const normalize = common.normalize;
10pub const panic = common.panic;
11
12comptime {
13 @export(__fmodh, .{ .name = "__fmodh", .linkage = linkage });
14 @export(fmodf, .{ .name = "fmodf", .linkage = linkage });
15 @export(fmod, .{ .name = "fmod", .linkage = linkage });
16 @export(__fmodx, .{ .name = "__fmodx", .linkage = linkage });
17 @export(fmodq, .{ .name = "fmodq", .linkage = linkage });
18 @export(fmodl, .{ .name = "fmodl", .linkage = linkage });
19
20 if (!builtin.is_test) {
21 if (arch.isPPC() or arch.isPPC64()) {
22 @export(fmodf128, .{ .name = "fmodf128", .linkage = linkage });
23 }
24 }
25}
626
727pub fn __fmodh(x: f16, y: f16) callconv(.C) f16 {
828 // TODO: more efficient implementation
......@@ -237,6 +257,10 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 {
237257 return amod;
238258}
239259
260pub fn fmodf128(a: f128, b: f128) callconv(.C) f128 {
261 return @call(.{ .modifier = .always_inline }, fmodq, .{ a, b });
262}
263
240264pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble {
241265 switch (@typeInfo(c_longdouble).Float.bits) {
242266 16 => return __fmodh(a, b),
lib/compiler_rt/int.zig+35
......@@ -4,9 +4,36 @@ const std = @import("std");
44const testing = std.testing;
55const maxInt = std.math.maxInt;
66const minInt = std.math.minInt;
7const arch = builtin.cpu.arch;
8const is_test = builtin.is_test;
9const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
10pub const panic = @import("common.zig").panic;
711
812const udivmod = @import("udivmod.zig").udivmod;
913
14comptime {
15 @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = linkage });
16 @export(__mulsi3, .{ .name = "__mulsi3", .linkage = linkage });
17 @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = linkage });
18 @export(__divsi3, .{ .name = "__divsi3", .linkage = linkage });
19 @export(__divdi3, .{ .name = "__divdi3", .linkage = linkage });
20 @export(__udivsi3, .{ .name = "__udivsi3", .linkage = linkage });
21 @export(__udivdi3, .{ .name = "__udivdi3", .linkage = linkage });
22 @export(__modsi3, .{ .name = "__modsi3", .linkage = linkage });
23 @export(__moddi3, .{ .name = "__moddi3", .linkage = linkage });
24 @export(__umodsi3, .{ .name = "__umodsi3", .linkage = linkage });
25 @export(__umoddi3, .{ .name = "__umoddi3", .linkage = linkage });
26 @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = linkage });
27 @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = linkage });
28
29 if (!is_test) {
30 if (arch.isARM() or arch.isThumb()) {
31 @export(__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = linkage });
32 @export(__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = linkage });
33 }
34 }
35}
36
1037pub fn __divmoddi4(a: i64, b: i64, rem: *i64) callconv(.C) i64 {
1138 @setRuntimeSafety(builtin.is_test);
1239
......@@ -187,6 +214,10 @@ pub fn __divsi3(n: i32, d: i32) callconv(.C) i32 {
187214 return @bitCast(i32, (res ^ sign) -% sign);
188215}
189216
217pub fn __aeabi_idiv(n: i32, d: i32) callconv(.C) i32 {
218 return @call(.{ .modifier = .always_inline }, __divsi3, .{ n, d });
219}
220
190221test "test_divsi3" {
191222 const cases = [_][3]i32{
192223 [_]i32{ 0, 1, 0 },
......@@ -253,6 +284,10 @@ pub fn __udivsi3(n: u32, d: u32) callconv(.C) u32 {
253284 return q;
254285}
255286
287pub fn __aeabi_uidiv(n: u32, d: u32) callconv(.C) u32 {
288 return @call(.{ .modifier = .always_inline }, __udivsi3, .{ n, d });
289}
290
256291test "test_udivsi3" {
257292 const cases = [_][3]u32{
258293 [_]u32{ 0x00000000, 0x00000001, 0x00000000 },
lib/compiler_rt/log.zig+23
......@@ -5,8 +5,27 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/ln.c
66
77const std = @import("std");
8const builtin = @import("builtin");
89const math = std.math;
910const testing = std.testing;
11const arch = builtin.cpu.arch;
12const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
13pub const panic = @import("common.zig").panic;
14
15comptime {
16 @export(__logh, .{ .name = "__logh", .linkage = linkage });
17 @export(logf, .{ .name = "logf", .linkage = linkage });
18 @export(log, .{ .name = "log", .linkage = linkage });
19 @export(__logx, .{ .name = "__logx", .linkage = linkage });
20 @export(logq, .{ .name = "logq", .linkage = linkage });
21 @export(logl, .{ .name = "logl", .linkage = linkage });
22
23 if (!builtin.is_test) {
24 if (arch.isPPC() or arch.isPPC64()) {
25 @export(logf128, .{ .name = "logf128", .linkage = linkage });
26 }
27 }
28}
1029
1130pub fn __logh(a: f16) callconv(.C) f16 {
1231 // TODO: more efficient implementation
......@@ -131,6 +150,10 @@ pub fn logq(a: f128) callconv(.C) f128 {
131150 return log(@floatCast(f64, a));
132151}
133152
153pub fn logf128(a: f128) callconv(.C) f128 {
154 return @call(.{ .modifier = .always_inline }, logq, .{a});
155}
156
134157pub fn logl(x: c_longdouble) callconv(.C) c_longdouble {
135158 switch (@typeInfo(c_longdouble).Float.bits) {
136159 16 => return __logh(x),
lib/compiler_rt/log10.zig+23
......@@ -5,9 +5,28 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/log10.c
66
77const std = @import("std");
8const builtin = @import("builtin");
89const math = std.math;
910const testing = std.testing;
1011const maxInt = std.math.maxInt;
12const arch = builtin.cpu.arch;
13const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
14pub const panic = @import("common.zig").panic;
15
16comptime {
17 @export(__log10h, .{ .name = "__log10h", .linkage = linkage });
18 @export(log10f, .{ .name = "log10f", .linkage = linkage });
19 @export(log10, .{ .name = "log10", .linkage = linkage });
20 @export(__log10x, .{ .name = "__log10x", .linkage = linkage });
21 @export(log10q, .{ .name = "log10q", .linkage = linkage });
22 @export(log10l, .{ .name = "log10l", .linkage = linkage });
23
24 if (!builtin.is_test) {
25 if (arch.isPPC() or arch.isPPC64()) {
26 @export(log10f128, .{ .name = "log10f128", .linkage = linkage });
27 }
28 }
29}
1130
1231pub fn __log10h(a: f16) callconv(.C) f16 {
1332 // TODO: more efficient implementation
......@@ -159,6 +178,10 @@ pub fn log10q(a: f128) callconv(.C) f128 {
159178 return log10(@floatCast(f64, a));
160179}
161180
181pub fn log10f128(a: f128) callconv(.C) f128 {
182 return @call(.{ .modifier = .always_inline }, log10q, .{a});
183}
184
162185pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble {
163186 switch (@typeInfo(c_longdouble).Float.bits) {
164187 16 => return __log10h(x),
lib/compiler_rt/log2.zig+23
......@@ -5,9 +5,28 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/log2.c
66
77const std = @import("std");
8const builtin = @import("builtin");
89const math = std.math;
910const expect = std.testing.expect;
1011const maxInt = std.math.maxInt;
12const arch = builtin.cpu.arch;
13const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
14pub const panic = @import("common.zig").panic;
15
16comptime {
17 @export(__log2h, .{ .name = "__log2h", .linkage = linkage });
18 @export(log2f, .{ .name = "log2f", .linkage = linkage });
19 @export(log2, .{ .name = "log2", .linkage = linkage });
20 @export(__log2x, .{ .name = "__log2x", .linkage = linkage });
21 @export(log2q, .{ .name = "log2q", .linkage = linkage });
22 @export(log2l, .{ .name = "log2l", .linkage = linkage });
23
24 if (!builtin.is_test) {
25 if (arch.isPPC() or arch.isPPC64()) {
26 @export(log2f128, .{ .name = "log2f128", .linkage = linkage });
27 }
28 }
29}
1130
1231pub fn __log2h(a: f16) callconv(.C) f16 {
1332 // TODO: more efficient implementation
......@@ -151,6 +170,10 @@ pub fn log2q(a: f128) callconv(.C) f128 {
151170 return log2(@floatCast(f64, a));
152171}
153172
173pub fn log2f128(a: f128) callconv(.C) f128 {
174 return @call(.{ .modifier = .always_inline }, log2q, .{a});
175}
176
154177pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble {
155178 switch (@typeInfo(c_longdouble).Float.bits) {
156179 16 => return __log2h(x),
lib/compiler_rt/modti3.zig+27-2
......@@ -2,9 +2,34 @@
22//
33// https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/modti3.c
44
5const udivmod = @import("udivmod.zig").udivmod;
5const std = @import("std");
66const builtin = @import("builtin");
7const compiler_rt = @import("../compiler_rt.zig");
7const udivmod = @import("udivmod.zig").udivmod;
8const arch = builtin.cpu.arch;
9const is_test = builtin.is_test;
10const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
11pub const panic = @import("common.zig").panic;
12
13comptime {
14 if (builtin.os.tag == .windows) {
15 switch (arch) {
16 .i386 => {
17 @export(__modti3, .{ .name = "__modti3", .linkage = linkage });
18 },
19 .x86_64 => {
20 // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI
21 // that LLVM expects compiler-rt to have.
22 @export(__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = linkage });
23 },
24 else => {},
25 }
26 if (arch.isAARCH64()) {
27 @export(__modti3, .{ .name = "__modti3", .linkage = linkage });
28 }
29 } else {
30 @export(__modti3, .{ .name = "__modti3", .linkage = linkage });
31 }
32}
833
934pub fn __modti3(a: i128, b: i128) callconv(.C) i128 {
1035 @setRuntimeSafety(builtin.is_test);
lib/compiler_rt/mulXf3.zig+26-2
......@@ -5,8 +5,32 @@
55const std = @import("std");
66const math = std.math;
77const builtin = @import("builtin");
8const compiler_rt = @import("../compiler_rt.zig");
8const arch = builtin.cpu.arch;
9const is_test = builtin.is_test;
10const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
11pub const panic = @import("common.zig").panic;
12
13comptime {
14 @export(__mulsf3, .{ .name = "__mulsf3", .linkage = linkage });
15 @export(__muldf3, .{ .name = "__muldf3", .linkage = linkage });
16 @export(__mulxf3, .{ .name = "__mulxf3", .linkage = linkage });
17 @export(__multf3, .{ .name = "__multf3", .linkage = linkage });
18
19 if (!is_test) {
20 if (arch.isARM() or arch.isThumb()) {
21 @export(__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = linkage });
22 @export(__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = linkage });
23 }
24
25 if (arch.isPPC() or arch.isPPC64()) {
26 @export(__mulkf3, .{ .name = "__mulkf3", .linkage = linkage });
27 }
28 }
29}
930
31pub fn __mulkf3(a: f128, b: f128) callconv(.C) f128 {
32 return @call(.{ .modifier = .always_inline }, __multf3, .{ a, b });
33}
1034pub fn __multf3(a: f128, b: f128) callconv(.C) f128 {
1135 return mulXf3(f128, a, b);
1236}
......@@ -30,7 +54,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 {
3054 return @call(.{ .modifier = .always_inline }, __muldf3, .{ a, b });
3155}
3256
33fn mulXf3(comptime T: type, a: T, b: T) T {
57pub fn mulXf3(comptime T: type, a: T, b: T) T {
3458 @setRuntimeSafety(builtin.is_test);
3559 const typeWidth = @typeInfo(T).Float.bits;
3660 const significandBits = math.floatMantissaBits(T);
lib/compiler_rt/muldi3.zig+19-2
......@@ -1,7 +1,20 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const is_test = builtin.is_test;
43const native_endian = builtin.cpu.arch.endian();
4const arch = builtin.cpu.arch;
5const is_test = builtin.is_test;
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7pub const panic = @import("common.zig").panic;
8
9comptime {
10 @export(__muldi3, .{ .name = "__muldi3", .linkage = linkage });
11
12 if (!is_test) {
13 if (arch.isARM() or arch.isThumb()) {
14 @export(__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = linkage });
15 }
16 }
17}
518
619// Ported from
720// https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0/compiler-rt/lib/builtins/muldi3.c
......@@ -20,7 +33,11 @@ const dwords = extern union {
2033 },
2134};
2235
23fn __muldsi3(a: u32, b: u32) i64 {
36pub fn __aeabi_lmul(a: i64, b: i64) callconv(.C) i64 {
37 return @call(.{ .modifier = .always_inline }, __muldi3, .{ a, b });
38}
39
40pub fn __muldsi3(a: u32, b: u32) i64 {
2441 @setRuntimeSafety(is_test);
2542
2643 const bits_in_word_2 = @sizeOf(i32) * 8 / 2;
lib/compiler_rt/mulo.zig+10-1
......@@ -1,6 +1,15 @@
1const builtin = @import("builtin");
21const std = @import("std");
2const builtin = @import("builtin");
33const math = std.math;
4const is_test = builtin.is_test;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 @export(__mulosi4, .{ .name = "__mulosi4", .linkage = linkage });
10 @export(__mulodi4, .{ .name = "__mulodi4", .linkage = linkage });
11 @export(__muloti4, .{ .name = "__muloti4", .linkage = linkage });
12}
413
514// mulo - multiplication overflow
615// * return a*%b.
lib/compiler_rt/multi3.zig+22-2
......@@ -1,13 +1,33 @@
1const compiler_rt = @import("../compiler_rt.zig");
21const std = @import("std");
32const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
44const is_test = builtin.is_test;
55const native_endian = builtin.cpu.arch.endian();
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7pub const panic = @import("common.zig").panic;
68
79// Ported from git@github.com:llvm-project/llvm-project-20170507.git
810// ae684fad6d34858c014c94da69c15e7774a633c3
911// 2018-08-13
1012
13comptime {
14 if (builtin.os.tag == .windows) {
15 switch (arch) {
16 .i386 => {
17 @export(__multi3, .{ .name = "__multi3", .linkage = linkage });
18 },
19 .x86_64 => {
20 // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI
21 // that LLVM expects compiler-rt to have.
22 @export(__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = linkage });
23 },
24 else => {},
25 }
26 } else {
27 @export(__multi3, .{ .name = "__multi3", .linkage = linkage });
28 }
29}
30
1131pub fn __multi3(a: i128, b: i128) callconv(.C) i128 {
1232 @setRuntimeSafety(is_test);
1333 const x = twords{ .all = a };
......@@ -25,7 +45,7 @@ pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
2545 }));
2646}
2747
28fn __mulddi3(a: u64, b: u64) i128 {
48pub fn __mulddi3(a: u64, b: u64) i128 {
2949 const bits_in_dword_2 = (@sizeOf(i64) * 8) / 2;
3050 const lower_mask = ~@as(u64, 0) >> bits_in_dword_2;
3151 var r: twords = undefined;
lib/compiler_rt/negXf2.zig+17
......@@ -1,4 +1,21 @@
11const std = @import("std");
2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
4const is_test = builtin.is_test;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 @export(__negsf2, .{ .name = "__negsf2", .linkage = linkage });
10 @export(__negdf2, .{ .name = "__negdf2", .linkage = linkage });
11
12 if (!is_test) {
13 if (arch.isARM() or arch.isThumb()) {
14 @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = linkage });
15 @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = linkage });
16 }
17 }
18}
219
320pub fn __negsf2(a: f32) callconv(.C) f32 {
421 return negXf2(f32, a);
lib/compiler_rt/negXi2.zig+9
......@@ -1,5 +1,14 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const is_test = builtin.is_test;
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 @export(__negsi2, .{ .name = "__negsi2", .linkage = linkage });
9 @export(__negdi2, .{ .name = "__negdi2", .linkage = linkage });
10 @export(__negti2, .{ .name = "__negti2", .linkage = linkage });
11}
312
413// neg - negate (the number)
514// - negXi2 for unoptimized little and big endian
lib/compiler_rt/negv.zig+11
......@@ -1,6 +1,17 @@
11// negv - negate oVerflow
22// * @panic, if result can not be represented
33// - negvXi4_generic for unoptimized version
4const std = @import("std");
5const builtin = @import("builtin");
6const is_test = builtin.is_test;
7const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
8pub const panic = @import("common.zig").panic;
9
10comptime {
11 @export(__negvsi2, .{ .name = "__negvsi2", .linkage = linkage });
12 @export(__negvdi2, .{ .name = "__negvdi2", .linkage = linkage });
13 @export(__negvti2, .{ .name = "__negvti2", .linkage = linkage });
14}
415
516// assume -0 == 0 is gracefully handled by the hardware
617inline fn negvXi(comptime ST: type, a: ST) ST {
lib/compiler_rt/os_version_check.zig+36-22
......@@ -1,5 +1,17 @@
1const testing = @import("std").testing;
1const std = @import("std");
2const testing = std.testing;
23const builtin = @import("builtin");
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 if (builtin.os.tag.isDarwin()) {
9 @export(IsPlatformVersionAtLeast.__isPlatformVersionAtLeast, .{
10 .name = "__isPlatformVersionAtLeast",
11 .linkage = linkage,
12 });
13 }
14}
315
416// Ported from llvm-project 13.0.0 d7b669b3a30345cfcdb2fde2af6f48aa4b94845d
517//
......@@ -16,34 +28,36 @@ const builtin = @import("builtin");
1628// the newer codepath, which merely calls out to the Darwin _availability_version_check API which is
1729// available on macOS 10.15+, iOS 13+, tvOS 13+ and watchOS 6+.
1830
19inline fn constructVersion(major: u32, minor: u32, subminor: u32) u32 {
20 return ((major & 0xffff) << 16) | ((minor & 0xff) << 8) | (subminor & 0xff);
21}
31const IsPlatformVersionAtLeast = struct {
32 inline fn constructVersion(major: u32, minor: u32, subminor: u32) u32 {
33 return ((major & 0xffff) << 16) | ((minor & 0xff) << 8) | (subminor & 0xff);
34 }
2235
23// Darwin-only
24pub fn __isPlatformVersionAtLeast(platform: u32, major: u32, minor: u32, subminor: u32) callconv(.C) i32 {
25 const build_version = dyld_build_version_t{
26 .platform = platform,
27 .version = constructVersion(major, minor, subminor),
28 };
29 return @boolToInt(_availability_version_check(1, &[_]dyld_build_version_t{build_version}));
30}
36 // Darwin-only
37 fn __isPlatformVersionAtLeast(platform: u32, major: u32, minor: u32, subminor: u32) callconv(.C) i32 {
38 const build_version = dyld_build_version_t{
39 .platform = platform,
40 .version = constructVersion(major, minor, subminor),
41 };
42 return @boolToInt(_availability_version_check(1, &[_]dyld_build_version_t{build_version}));
43 }
3144
32// _availability_version_check darwin API support.
33const dyld_platform_t = u32;
34const dyld_build_version_t = extern struct {
35 platform: dyld_platform_t,
36 version: u32,
45 // _availability_version_check darwin API support.
46 const dyld_platform_t = u32;
47 const dyld_build_version_t = extern struct {
48 platform: dyld_platform_t,
49 version: u32,
50 };
51 // Darwin-only
52 extern "c" fn _availability_version_check(count: u32, versions: [*c]const dyld_build_version_t) bool;
3753};
38// Darwin-only
39extern "c" fn _availability_version_check(count: u32, versions: [*c]const dyld_build_version_t) bool;
4054
4155test "isPlatformVersionAtLeast" {
42 if (!builtin.os.tag.isDarwin()) return error.SkipZigTest;
56 if (!comptime builtin.os.tag.isDarwin()) return error.SkipZigTest;
4357
4458 // Note: this test depends on the actual host OS version since it is merely calling into the
4559 // native Darwin API.
4660 const macos_platform_constant = 1;
47 try testing.expect(__isPlatformVersionAtLeast(macos_platform_constant, 10, 0, 15) == 1);
48 try testing.expect(__isPlatformVersionAtLeast(macos_platform_constant, 99, 0, 0) == 0);
61 try testing.expect(IsPlatformVersionAtLeast.__isPlatformVersionAtLeast(macos_platform_constant, 10, 0, 15) == 1);
62 try testing.expect(IsPlatformVersionAtLeast.__isPlatformVersionAtLeast(macos_platform_constant, 99, 0, 0) == 0);
4963}
lib/compiler_rt/parity.zig+9
......@@ -1,5 +1,14 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const is_test = builtin.is_test;
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 @export(__paritysi2, .{ .name = "__paritysi2", .linkage = linkage });
9 @export(__paritydi2, .{ .name = "__paritydi2", .linkage = linkage });
10 @export(__parityti2, .{ .name = "__parityti2", .linkage = linkage });
11}
312
413// parity - if number of bits set is even => 0, else => 1
514// - pariytXi2_generic for big and little endian
lib/compiler_rt/popcount.zig+9
......@@ -1,5 +1,14 @@
11const builtin = @import("builtin");
22const std = @import("std");
3const is_test = builtin.is_test;
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = linkage });
9 @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = linkage });
10 @export(__popcountti2, .{ .name = "__popcountti2", .linkage = linkage });
11}
312
413// popcount - population count
514// counts the number of 1 bits
lib/compiler_rt/round.zig+23
......@@ -5,8 +5,27 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/round.c
66
77const std = @import("std");
8const builtin = @import("builtin");
89const math = std.math;
910const expect = std.testing.expect;
11const arch = builtin.cpu.arch;
12const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
13pub const panic = @import("common.zig").panic;
14
15comptime {
16 @export(__roundh, .{ .name = "__roundh", .linkage = linkage });
17 @export(roundf, .{ .name = "roundf", .linkage = linkage });
18 @export(round, .{ .name = "round", .linkage = linkage });
19 @export(__roundx, .{ .name = "__roundx", .linkage = linkage });
20 @export(roundq, .{ .name = "roundq", .linkage = linkage });
21 @export(roundl, .{ .name = "roundl", .linkage = linkage });
22
23 if (!builtin.is_test) {
24 if (arch.isPPC() or arch.isPPC64()) {
25 @export(roundf128, .{ .name = "roundf128", .linkage = linkage });
26 }
27 }
28}
1029
1130pub fn __roundh(x: f16) callconv(.C) f16 {
1231 // TODO: more efficient implementation
......@@ -123,6 +142,10 @@ pub fn roundq(x_: f128) callconv(.C) f128 {
123142 }
124143}
125144
145pub fn roundf128(x_: f128) callconv(.C) f128 {
146 return @call(.{ .modifier = .always_inline }, roundq, .{x_});
147}
148
126149pub fn roundl(x: c_longdouble) callconv(.C) c_longdouble {
127150 switch (@typeInfo(c_longdouble).Float.bits) {
128151 16 => return __roundh(x),
lib/compiler_rt/shift.zig+30-8
......@@ -1,13 +1,35 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const Log2Int = std.math.Log2Int;
3const native_endian = @import("builtin").cpu.arch.endian();
4const native_endian = builtin.cpu.arch.endian();
5const arch = builtin.cpu.arch;
6const is_test = builtin.is_test;
7const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
8pub const panic = @import("common.zig").panic;
9
10comptime {
11 @export(__ashldi3, .{ .name = "__ashldi3", .linkage = linkage });
12 @export(__ashlti3, .{ .name = "__ashlti3", .linkage = linkage });
13 @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = linkage });
14 @export(__ashrti3, .{ .name = "__ashrti3", .linkage = linkage });
15 @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = linkage });
16 @export(__lshrti3, .{ .name = "__lshrti3", .linkage = linkage });
17
18 if (!is_test) {
19 if (arch.isARM() or arch.isThumb()) {
20 @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = linkage });
21 @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = linkage });
22 @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = linkage });
23 }
24 }
25}
426
527fn Dwords(comptime T: type, comptime signed_half: bool) type {
628 return extern union {
7 pub const bits = @divExact(@typeInfo(T).Int.bits, 2);
8 pub const HalfTU = std.meta.Int(.unsigned, bits);
9 pub const HalfTS = std.meta.Int(.signed, bits);
10 pub const HalfT = if (signed_half) HalfTS else HalfTU;
29 const bits = @divExact(@typeInfo(T).Int.bits, 2);
30 const HalfTU = std.meta.Int(.unsigned, bits);
31 const HalfTS = std.meta.Int(.signed, bits);
32 const HalfT = if (signed_half) HalfTS else HalfTU;
1133
1234 all: T,
1335 s: if (native_endian == .Little)
......@@ -19,7 +41,7 @@ fn Dwords(comptime T: type, comptime signed_half: bool) type {
1941
2042// Arithmetic shift left
2143// Precondition: 0 <= b < bits_in_dword
22pub inline fn ashlXi3(comptime T: type, a: T, b: i32) T {
44inline fn ashlXi3(comptime T: type, a: T, b: i32) T {
2345 const dwords = Dwords(T, false);
2446 const S = Log2Int(dwords.HalfT);
2547
......@@ -42,7 +64,7 @@ pub inline fn ashlXi3(comptime T: type, a: T, b: i32) T {
4264
4365// Arithmetic shift right
4466// Precondition: 0 <= b < T.bit_count
45pub inline fn ashrXi3(comptime T: type, a: T, b: i32) T {
67inline fn ashrXi3(comptime T: type, a: T, b: i32) T {
4668 const dwords = Dwords(T, true);
4769 const S = Log2Int(dwords.HalfT);
4870
......@@ -69,7 +91,7 @@ pub inline fn ashrXi3(comptime T: type, a: T, b: i32) T {
6991
7092// Logical shift right
7193// Precondition: 0 <= b < T.bit_count
72pub inline fn lshrXi3(comptime T: type, a: T, b: i32) T {
94inline fn lshrXi3(comptime T: type, a: T, b: i32) T {
7395 const dwords = Dwords(T, false);
7496 const S = Log2Int(dwords.HalfT);
7597
lib/compiler_rt/sin.zig+23
......@@ -5,13 +5,32 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/sin.c
66
77const std = @import("std");
8const builtin = @import("builtin");
9const arch = builtin.cpu.arch;
810const math = std.math;
911const expect = std.testing.expect;
12const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
13pub const panic = @import("common.zig").panic;
1014
1115const trig = @import("trig.zig");
1216const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
1317const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
1418
19comptime {
20 @export(__sinh, .{ .name = "__sinh", .linkage = linkage });
21 @export(sinf, .{ .name = "sinf", .linkage = linkage });
22 @export(sin, .{ .name = "sin", .linkage = linkage });
23 @export(__sinx, .{ .name = "__sinx", .linkage = linkage });
24 @export(sinq, .{ .name = "sinq", .linkage = linkage });
25 @export(sinl, .{ .name = "sinl", .linkage = linkage });
26
27 if (!builtin.is_test) {
28 if (arch.isPPC() or arch.isPPC64()) {
29 @export(sinf128, .{ .name = "sinf128", .linkage = linkage });
30 }
31 }
32}
33
1534pub fn __sinh(x: f16) callconv(.C) f16 {
1635 // TODO: more efficient implementation
1736 return @floatCast(f16, sinf(x));
......@@ -111,6 +130,10 @@ pub fn sinq(x: f128) callconv(.C) f128 {
111130 return sin(@floatCast(f64, x));
112131}
113132
133pub fn sinf128(x: f128) callconv(.C) f128 {
134 return @call(.{ .modifier = .always_inline }, sinq, .{x});
135}
136
114137pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble {
115138 switch (@typeInfo(c_longdouble).Float.bits) {
116139 16 => return __sinh(x),
lib/compiler_rt/sincos.zig+24-3
......@@ -1,10 +1,27 @@
11const std = @import("std");
2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
24const math = std.math;
3const sin = @import("sin.zig");
4const cos = @import("cos.zig");
55const trig = @import("trig.zig");
66const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
77const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
8const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
9pub const panic = @import("common.zig").panic;
10
11comptime {
12 @export(__sincosh, .{ .name = "__sincosh", .linkage = linkage });
13 @export(sincosf, .{ .name = "sincosf", .linkage = linkage });
14 @export(sincos, .{ .name = "sincos", .linkage = linkage });
15 @export(__sincosx, .{ .name = "__sincosx", .linkage = linkage });
16 @export(sincosq, .{ .name = "sincosq", .linkage = linkage });
17 @export(sincosl, .{ .name = "sincosl", .linkage = linkage });
18
19 if (!builtin.is_test) {
20 if (arch.isPPC() or arch.isPPC64()) {
21 @export(sincosf128, .{ .name = "sincosf128", .linkage = linkage });
22 }
23 }
24}
825
926pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.C) void {
1027 // TODO: more efficient implementation
......@@ -181,6 +198,10 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void {
181198 r_cos.* = small_cos;
182199}
183200
201pub fn sincosf128(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void {
202 return @call(.{ .modifier = .always_inline }, sincosq, .{ x, r_sin, r_cos });
203}
204
184205pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.C) void {
185206 switch (@typeInfo(c_longdouble).Float.bits) {
186207 16 => return __sincosh(x, r_sin, r_cos),
......@@ -192,7 +213,7 @@ pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) call
192213 }
193214}
194215
195const rem_pio2_generic = @compileError("TODO");
216pub const rem_pio2_generic = @compileError("TODO");
196217
197218/// Ported from musl sincosl.c. Needs the following dependencies to be complete:
198219/// * rem_pio2_generic ported from __rem_pio2l.c
lib/compiler_rt/sparc.zig+34
......@@ -3,6 +3,40 @@
33
44const std = @import("std");
55const builtin = @import("builtin");
6const arch = builtin.cpu.arch;
7const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
8pub const panic = @import("common.zig").panic;
9
10comptime {
11 if (arch.isSPARC()) {
12 // SPARC systems use a different naming scheme
13 @export(_Qp_add, .{ .name = "_Qp_add", .linkage = linkage });
14 @export(_Qp_div, .{ .name = "_Qp_div", .linkage = linkage });
15 @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = linkage });
16 @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = linkage });
17
18 @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = linkage });
19 @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = linkage });
20 @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = linkage });
21 @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = linkage });
22 @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = linkage });
23 @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = linkage });
24 @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = linkage });
25
26 @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = linkage });
27 @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = linkage });
28 @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = linkage });
29 @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = linkage });
30 @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = linkage });
31 @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = linkage });
32 @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = linkage });
33 @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = linkage });
34 @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = linkage });
35 @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = linkage });
36 @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = linkage });
37 @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage });
38 }
39}
640
741// The SPARC Architecture Manual, Version 9:
842// A.13 Floating-Point Compare
lib/compiler_rt/sqrt.zig+23
......@@ -1,5 +1,24 @@
11const std = @import("std");
2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
24const math = std.math;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 @export(__sqrth, .{ .name = "__sqrth", .linkage = linkage });
10 @export(sqrtf, .{ .name = "sqrtf", .linkage = linkage });
11 @export(sqrt, .{ .name = "sqrt", .linkage = linkage });
12 @export(__sqrtx, .{ .name = "__sqrtx", .linkage = linkage });
13 @export(sqrtq, .{ .name = "sqrtq", .linkage = linkage });
14 @export(sqrtl, .{ .name = "sqrtl", .linkage = linkage });
15
16 if (!builtin.is_test) {
17 if (arch.isPPC() or arch.isPPC64()) {
18 @export(sqrtf128, .{ .name = "sqrtf128", .linkage = linkage });
19 }
20 }
21}
322
423pub fn __sqrth(x: f16) callconv(.C) f16 {
524 // TODO: more efficient implementation
......@@ -236,6 +255,10 @@ pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble {
236255 }
237256}
238257
258pub fn sqrtf128(x: f128) callconv(.C) f128 {
259 return @call(.{ .modifier = .always_inline }, sqrtq, .{x});
260}
261
239262test "sqrtf" {
240263 const V = [_]f32{
241264 0.0,
lib/compiler_rt/stack_probe.zig+46-7
......@@ -1,4 +1,43 @@
1const native_arch = @import("builtin").cpu.arch;
1const std = @import("std");
2const builtin = @import("builtin");
3const os_tag = builtin.os.tag;
4const arch = builtin.cpu.arch;
5const abi = builtin.abi;
6const is_test = builtin.is_test;
7
8const is_gnu = abi.isGnu();
9const is_mingw = os_tag == .windows and is_gnu;
10
11const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
12const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong;
13pub const panic = @import("common.zig").panic;
14
15comptime {
16 if (builtin.os.tag == .windows) {
17 // Default stack-probe functions emitted by LLVM
18 if (is_mingw) {
19 @export(_chkstk, .{ .name = "_alloca", .linkage = strong_linkage });
20 @export(___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = strong_linkage });
21 } else if (!builtin.link_libc) {
22 // This symbols are otherwise exported by MSVCRT.lib
23 @export(_chkstk, .{ .name = "_chkstk", .linkage = strong_linkage });
24 @export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage });
25 }
26
27 if (arch.isAARCH64()) {
28 @export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage });
29 }
30 }
31
32 switch (arch) {
33 .i386,
34 .x86_64,
35 => {
36 @export(zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage });
37 },
38 else => {},
39 }
40}
241
342// Zig's own stack-probe routine (available only on x86 and x86_64)
443pub fn zig_probe_stack() callconv(.Naked) void {
......@@ -8,7 +47,7 @@ pub fn zig_probe_stack() callconv(.Naked) void {
847 // invalid so let's update it on the go, otherwise we'll get a segfault
948 // instead of triggering the stack growth.
1049
11 switch (native_arch) {
50 switch (arch) {
1251 .x86_64 => {
1352 // %rax = probe length, %rsp = stack pointer
1453 asm volatile (
......@@ -60,7 +99,7 @@ pub fn zig_probe_stack() callconv(.Naked) void {
6099fn win_probe_stack_only() void {
61100 @setRuntimeSafety(false);
62101
63 switch (native_arch) {
102 switch (arch) {
64103 .x86_64 => {
65104 asm volatile (
66105 \\ push %%rcx
......@@ -105,7 +144,7 @@ fn win_probe_stack_only() void {
105144 },
106145 else => {},
107146 }
108 if (comptime native_arch.isAARCH64()) {
147 if (comptime arch.isAARCH64()) {
109148 // NOTE: page size hardcoded to 4096 for now
110149 asm volatile (
111150 \\ lsl x16, x15, #4
......@@ -127,7 +166,7 @@ fn win_probe_stack_only() void {
127166fn win_probe_stack_adjust_sp() void {
128167 @setRuntimeSafety(false);
129168
130 switch (native_arch) {
169 switch (arch) {
131170 .x86_64 => {
132171 asm volatile (
133172 \\ push %%rcx
......@@ -201,9 +240,9 @@ pub fn _chkstk() callconv(.Naked) void {
201240}
202241pub fn __chkstk() callconv(.Naked) void {
203242 @setRuntimeSafety(false);
204 if (comptime native_arch.isAARCH64()) {
243 if (comptime arch.isAARCH64()) {
205244 @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{});
206 } else switch (native_arch) {
245 } else switch (arch) {
207246 .i386 => @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{}),
208247 .x86_64 => @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{}),
209248 else => unreachable,
lib/compiler_rt/subo.zig+10
......@@ -1,4 +1,14 @@
1const std = @import("std");
12const builtin = @import("builtin");
3const is_test = builtin.is_test;
4const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5pub const panic = @import("common.zig").panic;
6
7comptime {
8 @export(__subosi4, .{ .name = "__subosi4", .linkage = linkage });
9 @export(__subodi4, .{ .name = "__subodi4", .linkage = linkage });
10 @export(__suboti4, .{ .name = "__suboti4", .linkage = linkage });
11}
212
313// subo - subtract overflow
414// * return a-%b.
lib/compiler_rt/tan.zig+24
......@@ -6,6 +6,7 @@
66// https://golang.org/src/math/tan.go
77
88const std = @import("std");
9const builtin = @import("builtin");
910const math = std.math;
1011const expect = std.testing.expect;
1112
......@@ -13,6 +14,25 @@ const kernel = @import("trig.zig");
1314const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
1415const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
1516
17const arch = builtin.cpu.arch;
18const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
19pub const panic = @import("common.zig").panic;
20
21comptime {
22 @export(__tanh, .{ .name = "__tanh", .linkage = linkage });
23 @export(tanf, .{ .name = "tanf", .linkage = linkage });
24 @export(tan, .{ .name = "tan", .linkage = linkage });
25 @export(__tanx, .{ .name = "__tanx", .linkage = linkage });
26 @export(tanq, .{ .name = "tanq", .linkage = linkage });
27 @export(tanl, .{ .name = "tanl", .linkage = linkage });
28
29 if (!builtin.is_test) {
30 if (arch.isPPC() or arch.isPPC64()) {
31 @export(tanf128, .{ .name = "tanf128", .linkage = linkage });
32 }
33 }
34}
35
1636pub fn __tanh(x: f16) callconv(.C) f16 {
1737 // TODO: more efficient implementation
1838 return @floatCast(f16, tanf(x));
......@@ -96,6 +116,10 @@ pub fn tanq(x: f128) callconv(.C) f128 {
96116 return tan(@floatCast(f64, x));
97117}
98118
119pub fn tanf128(x: f128) callconv(.C) f128 {
120 return @call(.{ .modifier = .always_inline }, tanq, .{x});
121}
122
99123pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble {
100124 switch (@typeInfo(c_longdouble).Float.bits) {
101125 16 => return __tanh(x),
lib/compiler_rt/trunc.zig+23
......@@ -5,8 +5,27 @@
55// https://git.musl-libc.org/cgit/musl/tree/src/math/trunc.c
66
77const std = @import("std");
8const builtin = @import("builtin");
89const math = std.math;
910const expect = std.testing.expect;
11const arch = builtin.cpu.arch;
12const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
13pub const panic = @import("common.zig").panic;
14
15comptime {
16 @export(__trunch, .{ .name = "__trunch", .linkage = linkage });
17 @export(truncf, .{ .name = "truncf", .linkage = linkage });
18 @export(trunc, .{ .name = "trunc", .linkage = linkage });
19 @export(__truncx, .{ .name = "__truncx", .linkage = linkage });
20 @export(truncq, .{ .name = "truncq", .linkage = linkage });
21 @export(truncl, .{ .name = "truncl", .linkage = linkage });
22
23 if (!builtin.is_test) {
24 if (arch.isPPC() or arch.isPPC64()) {
25 @export(truncf128, .{ .name = "truncf128", .linkage = linkage });
26 }
27 }
28}
1029
1130pub fn __trunch(x: f16) callconv(.C) f16 {
1231 // TODO: more efficient implementation
......@@ -81,6 +100,10 @@ pub fn truncq(x: f128) callconv(.C) f128 {
81100 }
82101}
83102
103pub fn truncf128(x: f128) callconv(.C) f128 {
104 return @call(.{ .modifier = .always_inline }, truncq, .{x});
105}
106
84107pub fn truncl(x: c_longdouble) callconv(.C) c_longdouble {
85108 switch (@typeInfo(c_longdouble).Float.bits) {
86109 16 => return __trunch(x),
lib/compiler_rt/truncXfYf2.zig+42-2
......@@ -1,17 +1,49 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const native_arch = builtin.cpu.arch;
3const arch = builtin.cpu.arch;
4const is_test = builtin.is_test;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
6pub const panic = @import("common.zig").panic;
7
8comptime {
9 @export(__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = linkage });
10 @export(__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = linkage });
11 @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = linkage });
12 @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = linkage });
13
14 @export(__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = linkage });
15 @export(__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = linkage });
16
17 if (!is_test) {
18 @export(__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = linkage });
19
20 if (arch.isARM() or arch.isThumb()) {
21 @export(__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = linkage });
22 @export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = linkage });
23 @export(__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = linkage });
24 }
25
26 if (arch.isPPC() or arch.isPPC64()) {
27 @export(__trunckfsf2, .{ .name = "__trunckfsf2", .linkage = linkage });
28 @export(__trunckfdf2, .{ .name = "__trunckfdf2", .linkage = linkage });
29 }
30 }
31}
432
533// AArch64 is the only ABI (at the moment) to support f16 arguments without the
634// need for extending them to wider fp types.
735// TODO remove this; do this type selection in the language rather than
836// here in compiler-rt.
9pub const F16T = if (native_arch.isAARCH64()) f16 else u16;
37const F16T = if (arch.isAARCH64()) f16 else u16;
1038
1139pub fn __truncsfhf2(a: f32) callconv(.C) F16T {
1240 return @bitCast(F16T, truncXfYf2(f16, f32, a));
1341}
1442
43pub fn __gnu_f2h_ieee(a: f32) callconv(.C) F16T {
44 return @call(.{ .modifier = .always_inline }, __truncsfhf2, .{a});
45}
46
1547pub fn __truncdfhf2(a: f64) callconv(.C) F16T {
1648 return @bitCast(F16T, truncXfYf2(f16, f64, a));
1749}
......@@ -24,10 +56,18 @@ pub fn __trunctfsf2(a: f128) callconv(.C) f32 {
2456 return truncXfYf2(f32, f128, a);
2557}
2658
59pub fn __trunckfsf2(a: f128) callconv(.C) f32 {
60 return truncXfYf2(f32, f128, a);
61}
62
2763pub fn __trunctfdf2(a: f128) callconv(.C) f64 {
2864 return truncXfYf2(f64, f128, a);
2965}
3066
67pub fn __trunckfdf2(a: f128) callconv(.C) f64 {
68 return truncXfYf2(f64, f128, a);
69}
70
3171pub fn __truncdfsf2(a: f64) callconv(.C) f32 {
3272 return truncXfYf2(f32, f64, a);
3373}
lib/compiler_rt/trunc_f80.zig+12-2
......@@ -1,11 +1,21 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const native_arch = builtin.cpu.arch;
3const arch = builtin.cpu.arch;
44const testing = std.testing;
5const is_test = builtin.is_test;
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7pub const panic = @import("common.zig").panic;
8
9comptime {
10 @export(__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = linkage });
11 @export(__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = linkage });
12 @export(__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = linkage });
13 @export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage });
14}
515
616// AArch64 is the only ABI (at the moment) to support f16 arguments without the
717// need for extending them to wider fp types.
8pub const F16T = if (native_arch.isAARCH64()) f16 else u16;
18const F16T = if (arch.isAARCH64()) f16 else u16;
919
1020pub fn __truncxfhf2(a: f80) callconv(.C) F16T {
1121 return @bitCast(F16T, trunc(f16, a));
lib/compiler_rt/udivmodti4.zig+25-3
......@@ -1,13 +1,35 @@
1const udivmod = @import("udivmod.zig").udivmod;
1const std = @import("std");
22const builtin = @import("builtin");
3const compiler_rt = @import("../compiler_rt.zig");
3const udivmod = @import("udivmod.zig").udivmod;
4const arch = builtin.cpu.arch;
5const is_test = builtin.is_test;
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7pub const panic = @import("common.zig").panic;
8
9comptime {
10 if (builtin.os.tag == .windows) {
11 switch (arch) {
12 .i386 => {
13 @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage });
14 },
15 .x86_64 => {
16 // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI
17 // that LLVM expects compiler-rt to have.
18 @export(__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = linkage });
19 },
20 else => {},
21 }
22 } else {
23 @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage });
24 }
25}
426
527pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.C) u128 {
628 @setRuntimeSafety(builtin.is_test);
729 return udivmod(u128, a, b, maybe_rem);
830}
931
10const v128 = @import("std").meta.Vector(2, u64);
32const v128 = std.meta.Vector(2, u64);
1133pub fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) callconv(.C) v128 {
1234 @setRuntimeSafety(builtin.is_test);
1335 return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem));
lib/compiler_rt/udivti3.zig+30-4
......@@ -1,13 +1,39 @@
1const udivmodti4 = @import("udivmodti4.zig");
1const std = @import("std");
22const builtin = @import("builtin");
3const udivmod = @import("udivmod.zig").udivmod;
4const arch = builtin.cpu.arch;
5const is_test = builtin.is_test;
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7pub const panic = @import("common.zig").panic;
8
9comptime {
10 if (builtin.os.tag == .windows) {
11 switch (arch) {
12 .i386 => {
13 @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage });
14 },
15 .x86_64 => {
16 // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI
17 // that LLVM expects compiler-rt to have.
18 @export(__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = linkage });
19 },
20 else => {},
21 }
22 if (arch.isAARCH64()) {
23 @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage });
24 }
25 } else {
26 @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage });
27 }
28}
329
430pub fn __udivti3(a: u128, b: u128) callconv(.C) u128 {
531 @setRuntimeSafety(builtin.is_test);
6 return udivmodti4.__udivmodti4(a, b, null);
32 return udivmod(u128, a, b, null);
733}
834
9const v128 = @import("std").meta.Vector(2, u64);
35const v128 = std.meta.Vector(2, u64);
1036pub fn __udivti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
1137 @setRuntimeSafety(builtin.is_test);
12 return udivmodti4.__udivmodti4_windows_x86_64(a, b, null);
38 return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), null));
1339}
lib/compiler_rt/umodti3.zig+29-4
......@@ -1,15 +1,40 @@
1const udivmodti4 = @import("udivmodti4.zig");
1const std = @import("std");
22const builtin = @import("builtin");
3const compiler_rt = @import("../compiler_rt.zig");
3const udivmod = @import("udivmod.zig").udivmod;
4const arch = builtin.cpu.arch;
5const is_test = builtin.is_test;
6const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
7pub const panic = @import("common.zig").panic;
8
9comptime {
10 if (builtin.os.tag == .windows) {
11 switch (arch) {
12 .i386 => {
13 @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage });
14 },
15 .x86_64 => {
16 // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI
17 // that LLVM expects compiler-rt to have.
18 @export(__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = linkage });
19 },
20 else => {},
21 }
22 if (arch.isAARCH64()) {
23 @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage });
24 }
25 } else {
26 @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage });
27 }
28}
429
530pub fn __umodti3(a: u128, b: u128) callconv(.C) u128 {
631 @setRuntimeSafety(builtin.is_test);
732 var r: u128 = undefined;
8 _ = udivmodti4.__udivmodti4(a, b, &r);
33 _ = udivmod(u128, a, b, &r);
934 return r;
1035}
1136
12const v128 = @import("std").meta.Vector(2, u64);
37const v128 = std.meta.Vector(2, u64);
1338pub fn __umodti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
1439 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __umodti3, .{
1540 @bitCast(u128, a),
src/Compilation.zig+16-11
......@@ -23,6 +23,7 @@ const mingw = @import("mingw.zig");
2323const libunwind = @import("libunwind.zig");
2424const libcxx = @import("libcxx.zig");
2525const wasi_libc = @import("wasi_libc.zig");
26const compiler_rt = @import("compiler_rt.zig");
2627const fatal = @import("main.zig").fatal;
2728const clangMain = @import("main.zig").clangMain;
2829const Module = @import("Module.zig");
......@@ -131,7 +132,7 @@ libssp_static_lib: ?CRTFile = null,
131132libc_static_lib: ?CRTFile = null,
132133/// Populated when we build the libcompiler_rt static library. A Job to build this is placed in the queue
133134/// and resolved before calling linker.flush().
134compiler_rt_static_lib: ?CRTFile = null,
135compiler_rt_static_lib: compiler_rt.CompilerRtLib = .{},
135136/// Populated when we build the compiler_rt_obj object. A Job to build this is placed in the queue
136137/// and resolved before calling linker.flush().
137138compiler_rt_obj: ?CRTFile = null,
......@@ -175,7 +176,7 @@ pub const CRTFile = struct {
175176 lock: Cache.Lock,
176177 full_object_path: []const u8,
177178
178 fn deinit(self: *CRTFile, gpa: Allocator) void {
179 pub fn deinit(self: *CRTFile, gpa: Allocator) void {
179180 self.lock.release();
180181 gpa.free(self.full_object_path);
181182 self.* = undefined;
......@@ -1978,9 +1979,7 @@ pub fn destroy(self: *Compilation) void {
19781979 if (self.libcxxabi_static_lib) |*crt_file| {
19791980 crt_file.deinit(gpa);
19801981 }
1981 if (self.compiler_rt_static_lib) |*crt_file| {
1982 crt_file.deinit(gpa);
1983 }
1982 self.compiler_rt_static_lib.deinit(gpa);
19841983 if (self.compiler_rt_obj) |*crt_file| {
19851984 crt_file.deinit(gpa);
19861985 }
......@@ -3138,11 +3137,9 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
31383137 const named_frame = tracy.namedFrame("compiler_rt_lib");
31393138 defer named_frame.end();
31403139
3141 comp.buildOutputFromZig(
3142 "compiler_rt.zig",
3143 .Lib,
3140 compiler_rt.buildCompilerRtLib(
3141 comp,
31443142 &comp.compiler_rt_static_lib,
3145 .compiler_rt,
31463143 ) catch |err| switch (err) {
31473144 error.OutOfMemory => return error.OutOfMemory,
31483145 error.SubCompilationFailed => return, // error reported already
......@@ -4897,7 +4894,7 @@ pub fn updateSubCompilation(sub_compilation: *Compilation) !void {
48974894 }
48984895}
48994896
4900fn buildOutputFromZig(
4897pub fn buildOutputFromZig(
49014898 comp: *Compilation,
49024899 src_basename: []const u8,
49034900 output_mode: std.builtin.OutputMode,
......@@ -4914,7 +4911,15 @@ fn buildOutputFromZig(
49144911 .root_src_path = src_basename,
49154912 };
49164913 defer main_pkg.deinitTable(comp.gpa);
4917 const root_name = src_basename[0 .. src_basename.len - std.fs.path.extension(src_basename).len];
4914
4915 const root_name = root_name: {
4916 const basename = if (std.fs.path.dirname(src_basename)) |dirname|
4917 src_basename[dirname.len + 1 ..]
4918 else
4919 src_basename;
4920 const root_name = basename[0 .. basename.len - std.fs.path.extension(basename).len];
4921 break :root_name root_name;
4922 };
49184923 const target = comp.getTarget();
49194924 const bin_basename = try std.zig.binNameAlloc(comp.gpa, .{
49204925 .root_name = root_name,
src/compiler_rt.zig created+186
......@@ -0,0 +1,186 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const Allocator = std.mem.Allocator;
4const mem = std.mem;
5const tracy = @import("tracy.zig");
6const trace = tracy.trace;
7
8const Compilation = @import("Compilation.zig");
9const CRTFile = Compilation.CRTFile;
10const LinkObject = Compilation.LinkObject;
11const Package = @import("Package.zig");
12
13pub const CompilerRtLib = struct {
14 crt_object_files: [sources.len]?CRTFile = undefined,
15 crt_lib_file: ?CRTFile = null,
16
17 pub fn deinit(crt_lib: *CompilerRtLib, gpa: Allocator) void {
18 for (crt_lib.crt_object_files) |*crt_file| {
19 if (crt_file.*) |*cf| {
20 cf.deinit(gpa);
21 }
22 }
23 if (crt_lib.crt_lib_file) |*crt_file| {
24 crt_file.deinit(gpa);
25 }
26 }
27};
28
29pub fn buildCompilerRtLib(comp: *Compilation, compiler_rt_lib: *CompilerRtLib) !void {
30 const tracy_trace = trace(@src());
31 defer tracy_trace.end();
32
33 var progress: std.Progress = .{ .dont_print_on_dumb = true };
34 var progress_node = progress.start("Compile Compiler-RT", sources.len + 1);
35 defer progress_node.end();
36 if (comp.color == .off) progress.terminal = null;
37
38 progress_node.activate();
39
40 var link_objects: [sources.len]LinkObject = undefined;
41 for (sources) |source, i| {
42 var obj_progress_node = progress_node.start(source, 0);
43 obj_progress_node.activate();
44 defer obj_progress_node.end();
45
46 try comp.buildOutputFromZig(source, .Obj, &compiler_rt_lib.crt_object_files[i], .compiler_rt);
47 link_objects[i] = .{
48 .path = compiler_rt_lib.crt_object_files[i].?.full_object_path,
49 .must_link = true,
50 };
51 }
52
53 const root_name = "compiler_rt";
54
55 var lib_progress_node = progress_node.start(root_name, 0);
56 lib_progress_node.activate();
57 defer lib_progress_node.end();
58
59 const target = comp.getTarget();
60 const basename = try std.zig.binNameAlloc(comp.gpa, .{
61 .root_name = root_name,
62 .target = target,
63 .output_mode = .Lib,
64 });
65 errdefer comp.gpa.free(basename);
66
67 // TODO: This is extracted into a local variable to work around a stage1 miscompilation.
68 const emit_bin = Compilation.EmitLoc{
69 .directory = null, // Put it in the cache directory.
70 .basename = basename,
71 };
72 const sub_compilation = try Compilation.create(comp.gpa, .{
73 .local_cache_directory = comp.global_cache_directory,
74 .global_cache_directory = comp.global_cache_directory,
75 .zig_lib_directory = comp.zig_lib_directory,
76 .cache_mode = .whole,
77 .target = target,
78 .root_name = root_name,
79 .main_pkg = null,
80 .output_mode = .Lib,
81 .link_mode = .Static,
82 .function_sections = true,
83 .thread_pool = comp.thread_pool,
84 .libc_installation = comp.bin_file.options.libc_installation,
85 .emit_bin = emit_bin,
86 .optimize_mode = comp.compilerRtOptMode(),
87 .want_sanitize_c = false,
88 .want_stack_check = false,
89 .want_red_zone = comp.bin_file.options.red_zone,
90 .omit_frame_pointer = comp.bin_file.options.omit_frame_pointer,
91 .want_valgrind = false,
92 .want_tsan = false,
93 .want_pic = comp.bin_file.options.pic,
94 .want_pie = comp.bin_file.options.pie,
95 .want_lto = comp.bin_file.options.lto,
96 .emit_h = null,
97 .strip = comp.compilerRtStrip(),
98 .is_native_os = comp.bin_file.options.is_native_os,
99 .is_native_abi = comp.bin_file.options.is_native_abi,
100 .self_exe_path = comp.self_exe_path,
101 .link_objects = &link_objects,
102 .verbose_cc = comp.verbose_cc,
103 .verbose_link = comp.bin_file.options.verbose_link,
104 .verbose_air = comp.verbose_air,
105 .verbose_llvm_ir = comp.verbose_llvm_ir,
106 .verbose_cimport = comp.verbose_cimport,
107 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
108 .clang_passthrough_mode = comp.clang_passthrough_mode,
109 .skip_linker_dependencies = true,
110 .parent_compilation_link_libc = comp.bin_file.options.link_libc,
111 });
112 defer sub_compilation.destroy();
113
114 try sub_compilation.updateSubCompilation();
115
116 compiler_rt_lib.crt_lib_file = .{
117 .full_object_path = try sub_compilation.bin_file.options.emit.?.directory.join(comp.gpa, &[_][]const u8{
118 sub_compilation.bin_file.options.emit.?.sub_path,
119 }),
120 .lock = sub_compilation.bin_file.toOwnedLock(),
121 };
122}
123
124const sources = &[_][]const u8{
125 "compiler_rt/atomics.zig",
126 "compiler_rt/sin.zig",
127 "compiler_rt/cos.zig",
128 "compiler_rt/sincos.zig",
129 "compiler_rt/ceil.zig",
130 "compiler_rt/exp.zig",
131 "compiler_rt/exp2.zig",
132 "compiler_rt/fabs.zig",
133 "compiler_rt/floor.zig",
134 "compiler_rt/fma.zig",
135 "compiler_rt/fmax.zig",
136 "compiler_rt/fmin.zig",
137 "compiler_rt/fmod.zig",
138 "compiler_rt/log.zig",
139 "compiler_rt/log10.zig",
140 "compiler_rt/log2.zig",
141 "compiler_rt/round.zig",
142 "compiler_rt/sqrt.zig",
143 "compiler_rt/tan.zig",
144 "compiler_rt/trunc.zig",
145 "compiler_rt/extendXfYf2.zig",
146 "compiler_rt/extend_f80.zig",
147 "compiler_rt/compareXf2.zig",
148 "compiler_rt/stack_probe.zig",
149 "compiler_rt/divti3.zig",
150 "compiler_rt/modti3.zig",
151 "compiler_rt/multi3.zig",
152 "compiler_rt/udivti3.zig",
153 "compiler_rt/udivmodti4.zig",
154 "compiler_rt/umodti3.zig",
155 "compiler_rt/truncXfYf2.zig",
156 "compiler_rt/trunc_f80.zig",
157 "compiler_rt/addXf3.zig",
158 "compiler_rt/mulXf3.zig",
159 "compiler_rt/divsf3.zig",
160 "compiler_rt/divdf3.zig",
161 "compiler_rt/divxf3.zig",
162 "compiler_rt/divtf3.zig",
163 "compiler_rt/floatXiYf.zig",
164 "compiler_rt/fixXfYi.zig",
165 "compiler_rt/count0bits.zig",
166 "compiler_rt/parity.zig",
167 "compiler_rt/popcount.zig",
168 "compiler_rt/bswap.zig",
169 "compiler_rt/int.zig",
170 "compiler_rt/shift.zig",
171 "compiler_rt/negXi2.zig",
172 "compiler_rt/muldi3.zig",
173 "compiler_rt/absv.zig",
174 "compiler_rt/negv.zig",
175 "compiler_rt/addo.zig",
176 "compiler_rt/subo.zig",
177 "compiler_rt/mulo.zig",
178 "compiler_rt/cmp.zig",
179 "compiler_rt/negXf2.zig",
180 "compiler_rt/os_version_check.zig",
181 "compiler_rt/emutls.zig",
182 "compiler_rt/arm.zig",
183 "compiler_rt/aulldiv.zig",
184 "compiler_rt/sparc.zig",
185 "compiler_rt/clear_cache.zig",
186};
src/link/Coff.zig+1-1
......@@ -1354,7 +1354,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Node) !
13541354 }
13551355 // MSVC compiler_rt is missing some stuff, so we build it unconditionally but
13561356 // and rely on weak linkage to allow MSVC compiler_rt functions to override ours.
1357 if (comp.compiler_rt_static_lib) |lib| {
1357 if (comp.compiler_rt_static_lib.crt_lib_file) |lib| {
13581358 try argv.append(lib.full_object_path);
13591359 }
13601360 }
src/link/Elf.zig+1-1
......@@ -1272,7 +1272,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
12721272 const stack_size = self.base.options.stack_size_override orelse 16777216;
12731273 const allow_shlib_undefined = self.base.options.allow_shlib_undefined orelse !self.base.options.is_native_os;
12741274 const compiler_rt_path: ?[]const u8 = blk: {
1275 if (comp.compiler_rt_static_lib) |x| break :blk x.full_object_path;
1275 if (comp.compiler_rt_static_lib.crt_lib_file) |x| break :blk x.full_object_path;
12761276 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
12771277 break :blk null;
12781278 };
src/link/MachO.zig+1-1
......@@ -738,7 +738,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
738738 try positionals.append(p);
739739 }
740740
741 if (comp.compiler_rt_static_lib) |lib| {
741 if (comp.compiler_rt_static_lib.crt_lib_file) |lib| {
742742 try positionals.append(lib.full_object_path);
743743 }
744744
src/link/Wasm.zig+1-1
......@@ -2255,7 +2255,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
22552255 const is_obj = self.base.options.output_mode == .Obj;
22562256
22572257 const compiler_rt_path: ?[]const u8 = if (self.base.options.include_compiler_rt and !is_obj)
2258 comp.compiler_rt_static_lib.?.full_object_path
2258 comp.compiler_rt_static_lib.crt_lib_file.?.full_object_path
22592259 else
22602260 null;
22612261
src/musl.zig-1
......@@ -4,7 +4,6 @@ const mem = std.mem;
44const path = std.fs.path;
55const assert = std.debug.assert;
66
7const target_util = @import("target.zig");
87const Compilation = @import("Compilation.zig");
98const build_options = @import("build_options");
109