authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-01 19:49:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-02 13:16:17-07:00
log6b14c58f63a177c26ed7ac51c25738ecb115462d
tree5197dba1170c3fb727e559b7c3b105d576f7c871
parent9dc25dd0b695c907e861bfd5a974cf454e657228

compiler-rt: simplify implementations

This improves readability as well as compatibility with stage2. Most of compiler-rt is now enabled for stage2 with just a few functions disabled (until stage2 passes more behavior tests).

18 files changed, 1152 insertions(+), 999 deletions(-)

lib/std/special/compiler_rt.zig+498-486
...@@ -22,6 +22,12 @@ else...@@ -22,6 +22,12 @@ else
22const long_double_is_f128 = builtin.target.longDoubleIsF128();22const long_double_is_f128 = builtin.target.longDoubleIsF128();
2323
24comptime {24comptime {
25 // These files do their own comptime exporting logic.
26 if (!builtin.zig_is_stage2) {
27 _ = @import("compiler_rt/atomics.zig");
28 }
29 _ = @import("compiler_rt/clear_cache.zig").clear_cache;
30
25 const __extenddftf2 = @import("compiler_rt/extendXfYf2.zig").__extenddftf2;31 const __extenddftf2 = @import("compiler_rt/extendXfYf2.zig").__extenddftf2;
26 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage });32 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage });
27 const __extendsftf2 = @import("compiler_rt/extendXfYf2.zig").__extendsftf2;33 const __extendsftf2 = @import("compiler_rt/extendXfYf2.zig").__extendsftf2;
...@@ -171,16 +177,16 @@ comptime {...@@ -171,16 +177,16 @@ comptime {
171 const __truncdfsf2 = @import("compiler_rt/truncXfYf2.zig").__truncdfsf2;177 const __truncdfsf2 = @import("compiler_rt/truncXfYf2.zig").__truncdfsf2;
172 @export(__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = linkage });178 @export(__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = linkage });
173179
174 if (!builtin.zig_is_stage2) {180 if (!long_double_is_f128) {
175 if (!long_double_is_f128) {181 // TODO implement these
176 // TODO implement these182 //const __extendxftf2 = @import("compiler_rt/extendXfYf2.zig").__extendxftf2;
177 //const __extendxftf2 = @import("compiler_rt/extendXfYf2.zig").__extendxftf2;183 //@export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = linkage });
178 //@export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = linkage });
179184
180 //const __trunctfxf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfxf2;185 //const __trunctfxf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfxf2;
181 //@export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage });186 //@export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage });
182 }187 }
183188
189 if (!builtin.zig_is_stage2) {
184 switch (arch) {190 switch (arch) {
185 .i386,191 .i386,
186 .x86_64,192 .x86_64,
...@@ -193,30 +199,29 @@ comptime {...@@ -193,30 +199,29 @@ comptime {
193 },199 },
194 else => {},200 else => {},
195 }201 }
202 }
196203
197 // __clear_cache manages its own logic about whether to be exported or not.204 const __unordsf2 = @import("compiler_rt/compareXf2.zig").__unordsf2;
198 _ = @import("compiler_rt/clear_cache.zig").clear_cache;205 @export(__unordsf2, .{ .name = "__unordsf2", .linkage = linkage });
199206 const __unorddf2 = @import("compiler_rt/compareXf2.zig").__unorddf2;
200 const __unordsf2 = @import("compiler_rt/compareXf2.zig").__unordsf2;207 @export(__unorddf2, .{ .name = "__unorddf2", .linkage = linkage });
201 @export(__unordsf2, .{ .name = "__unordsf2", .linkage = linkage });208 const __unordtf2 = @import("compiler_rt/compareXf2.zig").__unordtf2;
202 const __unorddf2 = @import("compiler_rt/compareXf2.zig").__unorddf2;209 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = linkage });
203 @export(__unorddf2, .{ .name = "__unorddf2", .linkage = linkage });210
204 const __unordtf2 = @import("compiler_rt/compareXf2.zig").__unordtf2;211 const __addsf3 = @import("compiler_rt/addXf3.zig").__addsf3;
205 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = linkage });212 @export(__addsf3, .{ .name = "__addsf3", .linkage = linkage });
206213 const __adddf3 = @import("compiler_rt/addXf3.zig").__adddf3;
207 const __addsf3 = @import("compiler_rt/addXf3.zig").__addsf3;214 @export(__adddf3, .{ .name = "__adddf3", .linkage = linkage });
208 @export(__addsf3, .{ .name = "__addsf3", .linkage = linkage });215 const __addtf3 = @import("compiler_rt/addXf3.zig").__addtf3;
209 const __adddf3 = @import("compiler_rt/addXf3.zig").__adddf3;216 @export(__addtf3, .{ .name = "__addtf3", .linkage = linkage });
210 @export(__adddf3, .{ .name = "__adddf3", .linkage = linkage });217 const __subsf3 = @import("compiler_rt/addXf3.zig").__subsf3;
211 const __addtf3 = @import("compiler_rt/addXf3.zig").__addtf3;218 @export(__subsf3, .{ .name = "__subsf3", .linkage = linkage });
212 @export(__addtf3, .{ .name = "__addtf3", .linkage = linkage });219 const __subdf3 = @import("compiler_rt/addXf3.zig").__subdf3;
213 const __subsf3 = @import("compiler_rt/addXf3.zig").__subsf3;220 @export(__subdf3, .{ .name = "__subdf3", .linkage = linkage });
214 @export(__subsf3, .{ .name = "__subsf3", .linkage = linkage });221 const __subtf3 = @import("compiler_rt/addXf3.zig").__subtf3;
215 const __subdf3 = @import("compiler_rt/addXf3.zig").__subdf3;222 @export(__subtf3, .{ .name = "__subtf3", .linkage = linkage });
216 @export(__subdf3, .{ .name = "__subdf3", .linkage = linkage });
217 const __subtf3 = @import("compiler_rt/addXf3.zig").__subtf3;
218 @export(__subtf3, .{ .name = "__subtf3", .linkage = linkage });
219223
224 if (!builtin.zig_is_stage2) {
220 const __mulsf3 = @import("compiler_rt/mulXf3.zig").__mulsf3;225 const __mulsf3 = @import("compiler_rt/mulXf3.zig").__mulsf3;
221 @export(__mulsf3, .{ .name = "__mulsf3", .linkage = linkage });226 @export(__mulsf3, .{ .name = "__mulsf3", .linkage = linkage });
222 const __muldf3 = @import("compiler_rt/mulXf3.zig").__muldf3;227 const __muldf3 = @import("compiler_rt/mulXf3.zig").__muldf3;
...@@ -230,21 +235,23 @@ comptime {...@@ -230,21 +235,23 @@ comptime {
230 @export(__divdf3, .{ .name = "__divdf3", .linkage = linkage });235 @export(__divdf3, .{ .name = "__divdf3", .linkage = linkage });
231 const __divtf3 = @import("compiler_rt/divtf3.zig").__divtf3;236 const __divtf3 = @import("compiler_rt/divtf3.zig").__divtf3;
232 @export(__divtf3, .{ .name = "__divtf3", .linkage = linkage });237 @export(__divtf3, .{ .name = "__divtf3", .linkage = linkage });
238 }
233239
234 // Integral bit manipulation240 // Integral bit manipulation
235 const __ashldi3 = @import("compiler_rt/shift.zig").__ashldi3;241 const __ashldi3 = @import("compiler_rt/shift.zig").__ashldi3;
236 @export(__ashldi3, .{ .name = "__ashldi3", .linkage = linkage });242 @export(__ashldi3, .{ .name = "__ashldi3", .linkage = linkage });
237 const __ashlti3 = @import("compiler_rt/shift.zig").__ashlti3;243 const __ashlti3 = @import("compiler_rt/shift.zig").__ashlti3;
238 @export(__ashlti3, .{ .name = "__ashlti3", .linkage = linkage });244 @export(__ashlti3, .{ .name = "__ashlti3", .linkage = linkage });
239 const __ashrdi3 = @import("compiler_rt/shift.zig").__ashrdi3;245 const __ashrdi3 = @import("compiler_rt/shift.zig").__ashrdi3;
240 @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = linkage });246 @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = linkage });
241 const __ashrti3 = @import("compiler_rt/shift.zig").__ashrti3;247 const __ashrti3 = @import("compiler_rt/shift.zig").__ashrti3;
242 @export(__ashrti3, .{ .name = "__ashrti3", .linkage = linkage });248 @export(__ashrti3, .{ .name = "__ashrti3", .linkage = linkage });
243 const __lshrdi3 = @import("compiler_rt/shift.zig").__lshrdi3;249 const __lshrdi3 = @import("compiler_rt/shift.zig").__lshrdi3;
244 @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = linkage });250 @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = linkage });
245 const __lshrti3 = @import("compiler_rt/shift.zig").__lshrti3;251 const __lshrti3 = @import("compiler_rt/shift.zig").__lshrti3;
246 @export(__lshrti3, .{ .name = "__lshrti3", .linkage = linkage });252 @export(__lshrti3, .{ .name = "__lshrti3", .linkage = linkage });
247253
254 if (!builtin.zig_is_stage2) {
248 const __clzsi2 = @import("compiler_rt/count0bits.zig").__clzsi2;255 const __clzsi2 = @import("compiler_rt/count0bits.zig").__clzsi2;
249 @export(__clzsi2, .{ .name = "__clzsi2", .linkage = linkage });256 @export(__clzsi2, .{ .name = "__clzsi2", .linkage = linkage });
250 const __clzdi2 = @import("compiler_rt/count0bits.zig").__clzdi2;257 const __clzdi2 = @import("compiler_rt/count0bits.zig").__clzdi2;
...@@ -263,461 +270,466 @@ comptime {...@@ -263,461 +270,466 @@ comptime {
263 @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = linkage });270 @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = linkage });
264 const __ffsti2 = @import("compiler_rt/count0bits.zig").__ffsti2;271 const __ffsti2 = @import("compiler_rt/count0bits.zig").__ffsti2;
265 @export(__ffsti2, .{ .name = "__ffsti2", .linkage = linkage });272 @export(__ffsti2, .{ .name = "__ffsti2", .linkage = linkage });
273 }
266274
267 const __paritysi2 = @import("compiler_rt/parity.zig").__paritysi2;275 const __paritysi2 = @import("compiler_rt/parity.zig").__paritysi2;
268 @export(__paritysi2, .{ .name = "__paritysi2", .linkage = linkage });276 @export(__paritysi2, .{ .name = "__paritysi2", .linkage = linkage });
269 const __paritydi2 = @import("compiler_rt/parity.zig").__paritydi2;277 const __paritydi2 = @import("compiler_rt/parity.zig").__paritydi2;
270 @export(__paritydi2, .{ .name = "__paritydi2", .linkage = linkage });278 @export(__paritydi2, .{ .name = "__paritydi2", .linkage = linkage });
271 const __parityti2 = @import("compiler_rt/parity.zig").__parityti2;279 const __parityti2 = @import("compiler_rt/parity.zig").__parityti2;
272 @export(__parityti2, .{ .name = "__parityti2", .linkage = linkage });280 @export(__parityti2, .{ .name = "__parityti2", .linkage = linkage });
273 const __popcountsi2 = @import("compiler_rt/popcount.zig").__popcountsi2;281
274 @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = linkage });282 const __popcountsi2 = @import("compiler_rt/popcount.zig").__popcountsi2;
275 const __popcountdi2 = @import("compiler_rt/popcount.zig").__popcountdi2;283 @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = linkage });
276 @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = linkage });284 const __popcountdi2 = @import("compiler_rt/popcount.zig").__popcountdi2;
277 const __popcountti2 = @import("compiler_rt/popcount.zig").__popcountti2;285 @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = linkage });
278 @export(__popcountti2, .{ .name = "__popcountti2", .linkage = linkage });286 const __popcountti2 = @import("compiler_rt/popcount.zig").__popcountti2;
279 const __bswapsi2 = @import("compiler_rt/bswap.zig").__bswapsi2;287 @export(__popcountti2, .{ .name = "__popcountti2", .linkage = linkage });
280 @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = linkage });288
281 const __bswapdi2 = @import("compiler_rt/bswap.zig").__bswapdi2;289 const __bswapsi2 = @import("compiler_rt/bswap.zig").__bswapsi2;
282 @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = linkage });290 @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = linkage });
283 const __bswapti2 = @import("compiler_rt/bswap.zig").__bswapti2;291 const __bswapdi2 = @import("compiler_rt/bswap.zig").__bswapdi2;
284 @export(__bswapti2, .{ .name = "__bswapti2", .linkage = linkage });292 @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = linkage });
285293 const __bswapti2 = @import("compiler_rt/bswap.zig").__bswapti2;
286 // Integral / floating point conversion (part 1/2)294 @export(__bswapti2, .{ .name = "__bswapti2", .linkage = linkage });
287 const __floatsidf = @import("compiler_rt/floatsiXf.zig").__floatsidf;295
288 @export(__floatsidf, .{ .name = "__floatsidf", .linkage = linkage });296 // Integral / floating point conversion (part 1/2)
289 const __floatsisf = @import("compiler_rt/floatsiXf.zig").__floatsisf;297 const __floatsidf = @import("compiler_rt/floatsiXf.zig").__floatsidf;
290 @export(__floatsisf, .{ .name = "__floatsisf", .linkage = linkage });298 @export(__floatsidf, .{ .name = "__floatsidf", .linkage = linkage });
291 const __floatdidf = @import("compiler_rt/floatdidf.zig").__floatdidf;299 const __floatsisf = @import("compiler_rt/floatsiXf.zig").__floatsisf;
292 @export(__floatdidf, .{ .name = "__floatdidf", .linkage = linkage });300 @export(__floatsisf, .{ .name = "__floatsisf", .linkage = linkage });
293 const __floatsitf = @import("compiler_rt/floatsiXf.zig").__floatsitf;301 const __floatdidf = @import("compiler_rt/floatdidf.zig").__floatdidf;
294 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = linkage });302 @export(__floatdidf, .{ .name = "__floatdidf", .linkage = linkage });
295303 const __floatsitf = @import("compiler_rt/floatsiXf.zig").__floatsitf;
296 const __floatunsisf = @import("compiler_rt/floatunsisf.zig").__floatunsisf;304 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = linkage });
297 @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage });305
306 const __floatunsisf = @import("compiler_rt/floatunsisf.zig").__floatunsisf;
307 @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage });
308 if (!builtin.zig_is_stage2) {
298 const __floatundisf = @import("compiler_rt/floatundisf.zig").__floatundisf;309 const __floatundisf = @import("compiler_rt/floatundisf.zig").__floatundisf;
299 @export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage });310 @export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage });
300 const __floatunsidf = @import("compiler_rt/floatunsidf.zig").__floatunsidf;311 }
301 @export(__floatunsidf, .{ .name = "__floatunsidf", .linkage = linkage });312 const __floatunsidf = @import("compiler_rt/floatunsidf.zig").__floatunsidf;
302 const __floatundidf = @import("compiler_rt/floatundidf.zig").__floatundidf;313 @export(__floatunsidf, .{ .name = "__floatunsidf", .linkage = linkage });
303 @export(__floatundidf, .{ .name = "__floatundidf", .linkage = linkage });314 const __floatundidf = @import("compiler_rt/floatundidf.zig").__floatundidf;
304315 @export(__floatundidf, .{ .name = "__floatundidf", .linkage = linkage });
305 const __floatditf = @import("compiler_rt/floatditf.zig").__floatditf;316
306 @export(__floatditf, .{ .name = "__floatditf", .linkage = linkage });317 const __floatditf = @import("compiler_rt/floatditf.zig").__floatditf;
307 const __floattitf = @import("compiler_rt/floattitf.zig").__floattitf;318 @export(__floatditf, .{ .name = "__floatditf", .linkage = linkage });
308 @export(__floattitf, .{ .name = "__floattitf", .linkage = linkage });319 const __floattitf = @import("compiler_rt/floattitf.zig").__floattitf;
309 const __floattidf = @import("compiler_rt/floattidf.zig").__floattidf;320 @export(__floattitf, .{ .name = "__floattitf", .linkage = linkage });
310 @export(__floattidf, .{ .name = "__floattidf", .linkage = linkage });321 const __floattidf = @import("compiler_rt/floattidf.zig").__floattidf;
311 const __floattisf = @import("compiler_rt/floatXisf.zig").__floattisf;322 @export(__floattidf, .{ .name = "__floattidf", .linkage = linkage });
312 @export(__floattisf, .{ .name = "__floattisf", .linkage = linkage });323 const __floattisf = @import("compiler_rt/floatXisf.zig").__floattisf;
313 const __floatdisf = @import("compiler_rt/floatXisf.zig").__floatdisf;324 @export(__floattisf, .{ .name = "__floattisf", .linkage = linkage });
314 @export(__floatdisf, .{ .name = "__floatdisf", .linkage = linkage });325 const __floatdisf = @import("compiler_rt/floatXisf.zig").__floatdisf;
315326 @export(__floatdisf, .{ .name = "__floatdisf", .linkage = linkage });
316 const __floatunditf = @import("compiler_rt/floatunditf.zig").__floatunditf;327
317 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = linkage });328 const __floatunditf = @import("compiler_rt/floatunditf.zig").__floatunditf;
318 const __floatunsitf = @import("compiler_rt/floatunsitf.zig").__floatunsitf;329 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = linkage });
319 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = linkage });330 const __floatunsitf = @import("compiler_rt/floatunsitf.zig").__floatunsitf;
320331 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = linkage });
321 const __floatuntitf = @import("compiler_rt/floatuntitf.zig").__floatuntitf;332
322 @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = linkage });333 const __floatuntitf = @import("compiler_rt/floatuntitf.zig").__floatuntitf;
323 const __floatuntidf = @import("compiler_rt/floatuntidf.zig").__floatuntidf;334 @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = linkage });
324 @export(__floatuntidf, .{ .name = "__floatuntidf", .linkage = linkage });335 const __floatuntidf = @import("compiler_rt/floatuntidf.zig").__floatuntidf;
325 const __floatuntisf = @import("compiler_rt/floatuntisf.zig").__floatuntisf;336 @export(__floatuntidf, .{ .name = "__floatuntidf", .linkage = linkage });
326 @export(__floatuntisf, .{ .name = "__floatuntisf", .linkage = linkage });337 const __floatuntisf = @import("compiler_rt/floatuntisf.zig").__floatuntisf;
327338 @export(__floatuntisf, .{ .name = "__floatuntisf", .linkage = linkage });
328 const __truncsfhf2 = @import("compiler_rt/truncXfYf2.zig").__truncsfhf2;339
329 @export(__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = linkage });340 const __truncsfhf2 = @import("compiler_rt/truncXfYf2.zig").__truncsfhf2;
330 if (!is_test) {341 @export(__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = linkage });
331 @export(__truncsfhf2, .{ .name = "__gnu_f2h_ieee", .linkage = linkage });342 if (!is_test) {
332 }343 @export(__truncsfhf2, .{ .name = "__gnu_f2h_ieee", .linkage = linkage });
333 const __extendsfdf2 = @import("compiler_rt/extendXfYf2.zig").__extendsfdf2;344 }
334 @export(__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = linkage });345 const __extendsfdf2 = @import("compiler_rt/extendXfYf2.zig").__extendsfdf2;
335346 @export(__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = linkage });
336 // Integral / floating point conversion (part 2/2)347
337 const __fixunssfsi = @import("compiler_rt/fixunssfsi.zig").__fixunssfsi;348 // Integral / floating point conversion (part 2/2)
338 @export(__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = linkage });349 const __fixunssfsi = @import("compiler_rt/fixunssfsi.zig").__fixunssfsi;
339 const __fixunssfdi = @import("compiler_rt/fixunssfdi.zig").__fixunssfdi;350 @export(__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = linkage });
340 @export(__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = linkage });351 const __fixunssfdi = @import("compiler_rt/fixunssfdi.zig").__fixunssfdi;
341 const __fixunssfti = @import("compiler_rt/fixunssfti.zig").__fixunssfti;352 @export(__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = linkage });
342 @export(__fixunssfti, .{ .name = "__fixunssfti", .linkage = linkage });353 const __fixunssfti = @import("compiler_rt/fixunssfti.zig").__fixunssfti;
343354 @export(__fixunssfti, .{ .name = "__fixunssfti", .linkage = linkage });
344 const __fixunsdfsi = @import("compiler_rt/fixunsdfsi.zig").__fixunsdfsi;355
345 @export(__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = linkage });356 const __fixunsdfsi = @import("compiler_rt/fixunsdfsi.zig").__fixunsdfsi;
346 const __fixunsdfdi = @import("compiler_rt/fixunsdfdi.zig").__fixunsdfdi;357 @export(__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = linkage });
347 @export(__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = linkage });358 const __fixunsdfdi = @import("compiler_rt/fixunsdfdi.zig").__fixunsdfdi;
348 const __fixunsdfti = @import("compiler_rt/fixunsdfti.zig").__fixunsdfti;359 @export(__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = linkage });
349 @export(__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = linkage });360 const __fixunsdfti = @import("compiler_rt/fixunsdfti.zig").__fixunsdfti;
350361 @export(__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = linkage });
351 const __fixunstfsi = @import("compiler_rt/fixunstfsi.zig").__fixunstfsi;362
352 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = linkage });363 const __fixunstfsi = @import("compiler_rt/fixunstfsi.zig").__fixunstfsi;
353 const __fixunstfdi = @import("compiler_rt/fixunstfdi.zig").__fixunstfdi;364 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = linkage });
354 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = linkage });365 const __fixunstfdi = @import("compiler_rt/fixunstfdi.zig").__fixunstfdi;
355 const __fixunstfti = @import("compiler_rt/fixunstfti.zig").__fixunstfti;366 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = linkage });
356 @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = linkage });367 const __fixunstfti = @import("compiler_rt/fixunstfti.zig").__fixunstfti;
357368 @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = linkage });
358 const __fixdfdi = @import("compiler_rt/fixdfdi.zig").__fixdfdi;369
359 @export(__fixdfdi, .{ .name = "__fixdfdi", .linkage = linkage });370 const __fixdfdi = @import("compiler_rt/fixdfdi.zig").__fixdfdi;
360 const __fixdfsi = @import("compiler_rt/fixdfsi.zig").__fixdfsi;371 @export(__fixdfdi, .{ .name = "__fixdfdi", .linkage = linkage });
361 @export(__fixdfsi, .{ .name = "__fixdfsi", .linkage = linkage });372 const __fixdfsi = @import("compiler_rt/fixdfsi.zig").__fixdfsi;
362 const __fixdfti = @import("compiler_rt/fixdfti.zig").__fixdfti;373 @export(__fixdfsi, .{ .name = "__fixdfsi", .linkage = linkage });
363 @export(__fixdfti, .{ .name = "__fixdfti", .linkage = linkage });374 const __fixdfti = @import("compiler_rt/fixdfti.zig").__fixdfti;
364 const __fixsfdi = @import("compiler_rt/fixsfdi.zig").__fixsfdi;375 @export(__fixdfti, .{ .name = "__fixdfti", .linkage = linkage });
365 @export(__fixsfdi, .{ .name = "__fixsfdi", .linkage = linkage });376 const __fixsfdi = @import("compiler_rt/fixsfdi.zig").__fixsfdi;
366 const __fixsfsi = @import("compiler_rt/fixsfsi.zig").__fixsfsi;377 @export(__fixsfdi, .{ .name = "__fixsfdi", .linkage = linkage });
367 @export(__fixsfsi, .{ .name = "__fixsfsi", .linkage = linkage });378 const __fixsfsi = @import("compiler_rt/fixsfsi.zig").__fixsfsi;
368 const __fixsfti = @import("compiler_rt/fixsfti.zig").__fixsfti;379 @export(__fixsfsi, .{ .name = "__fixsfsi", .linkage = linkage });
369 @export(__fixsfti, .{ .name = "__fixsfti", .linkage = linkage });380 const __fixsfti = @import("compiler_rt/fixsfti.zig").__fixsfti;
370 const __fixtfdi = @import("compiler_rt/fixtfdi.zig").__fixtfdi;381 @export(__fixsfti, .{ .name = "__fixsfti", .linkage = linkage });
371 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = linkage });382 const __fixtfdi = @import("compiler_rt/fixtfdi.zig").__fixtfdi;
372 const __fixtfsi = @import("compiler_rt/fixtfsi.zig").__fixtfsi;383 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = linkage });
373 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = linkage });384 const __fixtfsi = @import("compiler_rt/fixtfsi.zig").__fixtfsi;
374 const __fixtfti = @import("compiler_rt/fixtfti.zig").__fixtfti;385 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = linkage });
375 @export(__fixtfti, .{ .name = "__fixtfti", .linkage = linkage });386 const __fixtfti = @import("compiler_rt/fixtfti.zig").__fixtfti;
376387 @export(__fixtfti, .{ .name = "__fixtfti", .linkage = linkage });
377 const __udivmoddi4 = @import("compiler_rt/int.zig").__udivmoddi4;388
378 @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = linkage });389 const __udivmoddi4 = @import("compiler_rt/int.zig").__udivmoddi4;
379390 @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = linkage });
380 if (is_darwin) {391
381 const __isPlatformVersionAtLeast = @import("compiler_rt/os_version_check.zig").__isPlatformVersionAtLeast;392 if (is_darwin) {
382 @export(__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage });393 const __isPlatformVersionAtLeast = @import("compiler_rt/os_version_check.zig").__isPlatformVersionAtLeast;
383 }394 @export(__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage });
395 }
384396
385 // Integral arithmetic397 // Integral arithmetic
386 const __negsi2 = @import("compiler_rt/negXi2.zig").__negsi2;398 const __negsi2 = @import("compiler_rt/negXi2.zig").__negsi2;
387 @export(__negsi2, .{ .name = "__negsi2", .linkage = linkage });399 @export(__negsi2, .{ .name = "__negsi2", .linkage = linkage });
388 const __negdi2 = @import("compiler_rt/negXi2.zig").__negdi2;400 const __negdi2 = @import("compiler_rt/negXi2.zig").__negdi2;
389 @export(__negdi2, .{ .name = "__negdi2", .linkage = linkage });401 @export(__negdi2, .{ .name = "__negdi2", .linkage = linkage });
390 const __negti2 = @import("compiler_rt/negXi2.zig").__negti2;402 const __negti2 = @import("compiler_rt/negXi2.zig").__negti2;
391 @export(__negti2, .{ .name = "__negti2", .linkage = linkage });403 @export(__negti2, .{ .name = "__negti2", .linkage = linkage });
392 const __mulsi3 = @import("compiler_rt/int.zig").__mulsi3;404 const __mulsi3 = @import("compiler_rt/int.zig").__mulsi3;
393 @export(__mulsi3, .{ .name = "__mulsi3", .linkage = linkage });405 @export(__mulsi3, .{ .name = "__mulsi3", .linkage = linkage });
394 const __muldi3 = @import("compiler_rt/muldi3.zig").__muldi3;406 const __muldi3 = @import("compiler_rt/muldi3.zig").__muldi3;
395 @export(__muldi3, .{ .name = "__muldi3", .linkage = linkage });407 @export(__muldi3, .{ .name = "__muldi3", .linkage = linkage });
396 const __divmoddi4 = @import("compiler_rt/int.zig").__divmoddi4;408 const __divmoddi4 = @import("compiler_rt/int.zig").__divmoddi4;
397 @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = linkage });409 @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = linkage });
398 const __divsi3 = @import("compiler_rt/int.zig").__divsi3;410 const __divsi3 = @import("compiler_rt/int.zig").__divsi3;
399 @export(__divsi3, .{ .name = "__divsi3", .linkage = linkage });411 @export(__divsi3, .{ .name = "__divsi3", .linkage = linkage });
400 const __divdi3 = @import("compiler_rt/int.zig").__divdi3;412 const __divdi3 = @import("compiler_rt/int.zig").__divdi3;
401 @export(__divdi3, .{ .name = "__divdi3", .linkage = linkage });413 @export(__divdi3, .{ .name = "__divdi3", .linkage = linkage });
402 const __udivsi3 = @import("compiler_rt/int.zig").__udivsi3;414 const __udivsi3 = @import("compiler_rt/int.zig").__udivsi3;
403 @export(__udivsi3, .{ .name = "__udivsi3", .linkage = linkage });415 @export(__udivsi3, .{ .name = "__udivsi3", .linkage = linkage });
404 const __udivdi3 = @import("compiler_rt/int.zig").__udivdi3;416 const __udivdi3 = @import("compiler_rt/int.zig").__udivdi3;
405 @export(__udivdi3, .{ .name = "__udivdi3", .linkage = linkage });417 @export(__udivdi3, .{ .name = "__udivdi3", .linkage = linkage });
406 const __modsi3 = @import("compiler_rt/int.zig").__modsi3;418 const __modsi3 = @import("compiler_rt/int.zig").__modsi3;
407 @export(__modsi3, .{ .name = "__modsi3", .linkage = linkage });419 @export(__modsi3, .{ .name = "__modsi3", .linkage = linkage });
408 const __moddi3 = @import("compiler_rt/int.zig").__moddi3;420 const __moddi3 = @import("compiler_rt/int.zig").__moddi3;
409 @export(__moddi3, .{ .name = "__moddi3", .linkage = linkage });421 @export(__moddi3, .{ .name = "__moddi3", .linkage = linkage });
410 const __umodsi3 = @import("compiler_rt/int.zig").__umodsi3;422 const __umodsi3 = @import("compiler_rt/int.zig").__umodsi3;
411 @export(__umodsi3, .{ .name = "__umodsi3", .linkage = linkage });423 @export(__umodsi3, .{ .name = "__umodsi3", .linkage = linkage });
412 const __umoddi3 = @import("compiler_rt/int.zig").__umoddi3;424 const __umoddi3 = @import("compiler_rt/int.zig").__umoddi3;
413 @export(__umoddi3, .{ .name = "__umoddi3", .linkage = linkage });425 @export(__umoddi3, .{ .name = "__umoddi3", .linkage = linkage });
414 const __divmodsi4 = @import("compiler_rt/int.zig").__divmodsi4;426 const __divmodsi4 = @import("compiler_rt/int.zig").__divmodsi4;
415 @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = linkage });427 @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = linkage });
416 const __udivmodsi4 = @import("compiler_rt/int.zig").__udivmodsi4;428 const __udivmodsi4 = @import("compiler_rt/int.zig").__udivmodsi4;
417 @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = linkage });429 @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = linkage });
418430
419 // Integral arithmetic with trapping overflow431 // Integral arithmetic with trapping overflow
420 const __absvsi2 = @import("compiler_rt/absv.zig").__absvsi2;432 const __absvsi2 = @import("compiler_rt/absv.zig").__absvsi2;
421 @export(__absvsi2, .{ .name = "__absvsi2", .linkage = linkage });433 @export(__absvsi2, .{ .name = "__absvsi2", .linkage = linkage });
422 const __absvdi2 = @import("compiler_rt/absv.zig").__absvdi2;434 const __absvdi2 = @import("compiler_rt/absv.zig").__absvdi2;
423 @export(__absvdi2, .{ .name = "__absvdi2", .linkage = linkage });435 @export(__absvdi2, .{ .name = "__absvdi2", .linkage = linkage });
424 const __absvti2 = @import("compiler_rt/absv.zig").__absvti2;436 const __absvti2 = @import("compiler_rt/absv.zig").__absvti2;
425 @export(__absvti2, .{ .name = "__absvti2", .linkage = linkage });437 @export(__absvti2, .{ .name = "__absvti2", .linkage = linkage });
426 const __negvsi2 = @import("compiler_rt/negv.zig").__negvsi2;438 const __negvsi2 = @import("compiler_rt/negv.zig").__negvsi2;
427 @export(__negvsi2, .{ .name = "__negvsi2", .linkage = linkage });439 @export(__negvsi2, .{ .name = "__negvsi2", .linkage = linkage });
428 const __negvdi2 = @import("compiler_rt/negv.zig").__negvdi2;440 const __negvdi2 = @import("compiler_rt/negv.zig").__negvdi2;
429 @export(__negvdi2, .{ .name = "__negvdi2", .linkage = linkage });441 @export(__negvdi2, .{ .name = "__negvdi2", .linkage = linkage });
430 const __negvti2 = @import("compiler_rt/negv.zig").__negvti2;442 const __negvti2 = @import("compiler_rt/negv.zig").__negvti2;
431 @export(__negvti2, .{ .name = "__negvti2", .linkage = linkage });443 @export(__negvti2, .{ .name = "__negvti2", .linkage = linkage });
432444
433 // missing: Integral arithmetic which returns if overflow445 // missing: Integral arithmetic which returns if overflow
434446
435 // Integral comparison447 // Integral comparison
436 // (a < b) => 0448 // (a < b) => 0
437 // (a == b) => 1449 // (a == b) => 1
438 // (a > b) => 2450 // (a > b) => 2
439 const __cmpsi2 = @import("compiler_rt/cmp.zig").__cmpsi2;451 const __cmpsi2 = @import("compiler_rt/cmp.zig").__cmpsi2;
440 @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = linkage });452 @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = linkage });
441 const __cmpdi2 = @import("compiler_rt/cmp.zig").__cmpdi2;453 const __cmpdi2 = @import("compiler_rt/cmp.zig").__cmpdi2;
442 @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = linkage });454 @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = linkage });
443 const __cmpti2 = @import("compiler_rt/cmp.zig").__cmpti2;455 const __cmpti2 = @import("compiler_rt/cmp.zig").__cmpti2;
444 @export(__cmpti2, .{ .name = "__cmpti2", .linkage = linkage });456 @export(__cmpti2, .{ .name = "__cmpti2", .linkage = linkage });
445 const __ucmpsi2 = @import("compiler_rt/cmp.zig").__ucmpsi2;457 const __ucmpsi2 = @import("compiler_rt/cmp.zig").__ucmpsi2;
446 @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = linkage });458 @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = linkage });
447 const __ucmpdi2 = @import("compiler_rt/cmp.zig").__ucmpdi2;459 const __ucmpdi2 = @import("compiler_rt/cmp.zig").__ucmpdi2;
448 @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = linkage });460 @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = linkage });
449 const __ucmpti2 = @import("compiler_rt/cmp.zig").__ucmpti2;461 const __ucmpti2 = @import("compiler_rt/cmp.zig").__ucmpti2;
450 @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = linkage });462 @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = linkage });
451463
452 // missing: Floating point raised to integer power464 // missing: Floating point raised to integer power
453465
454 // missing: Complex arithmetic466 // missing: Complex arithmetic
455 // (a + ib) * (c + id)467 // (a + ib) * (c + id)
456 // (a + ib) / (c + id)468 // (a + ib) / (c + id)
457469
458 const __negsf2 = @import("compiler_rt/negXf2.zig").__negsf2;470 const __negsf2 = @import("compiler_rt/negXf2.zig").__negsf2;
459 @export(__negsf2, .{ .name = "__negsf2", .linkage = linkage });471 @export(__negsf2, .{ .name = "__negsf2", .linkage = linkage });
460 const __negdf2 = @import("compiler_rt/negXf2.zig").__negdf2;472 const __negdf2 = @import("compiler_rt/negXf2.zig").__negdf2;
461 @export(__negdf2, .{ .name = "__negdf2", .linkage = linkage });473 @export(__negdf2, .{ .name = "__negdf2", .linkage = linkage });
462474
463 if (builtin.link_libc and os_tag == .openbsd) {475 if (builtin.link_libc and os_tag == .openbsd) {
464 const __emutls_get_address = @import("compiler_rt/emutls.zig").__emutls_get_address;476 const __emutls_get_address = @import("compiler_rt/emutls.zig").__emutls_get_address;
465 @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage });477 @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage });
466 }478 }
467479
468 if ((arch.isARM() or arch.isThumb()) and !is_test) {480 if ((arch.isARM() or arch.isThumb()) and !is_test) {
469 const __aeabi_unwind_cpp_pr0 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr0;481 const __aeabi_unwind_cpp_pr0 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr0;
470 @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage });482 @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage });
471 const __aeabi_unwind_cpp_pr1 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr1;483 const __aeabi_unwind_cpp_pr1 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr1;
472 @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage });484 @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage });
473 const __aeabi_unwind_cpp_pr2 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr2;485 const __aeabi_unwind_cpp_pr2 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr2;
474 @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage });486 @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage });
475487
476 @export(__muldi3, .{ .name = "__aeabi_lmul", .linkage = linkage });488 @export(__muldi3, .{ .name = "__aeabi_lmul", .linkage = linkage });
477489
478 const __aeabi_ldivmod = @import("compiler_rt/arm.zig").__aeabi_ldivmod;490 const __aeabi_ldivmod = @import("compiler_rt/arm.zig").__aeabi_ldivmod;
479 @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = linkage });491 @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = linkage });
480 const __aeabi_uldivmod = @import("compiler_rt/arm.zig").__aeabi_uldivmod;492 const __aeabi_uldivmod = @import("compiler_rt/arm.zig").__aeabi_uldivmod;
481 @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = linkage });493 @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = linkage });
482494
483 @export(__divsi3, .{ .name = "__aeabi_idiv", .linkage = linkage });495 @export(__divsi3, .{ .name = "__aeabi_idiv", .linkage = linkage });
484 const __aeabi_idivmod = @import("compiler_rt/arm.zig").__aeabi_idivmod;496 const __aeabi_idivmod = @import("compiler_rt/arm.zig").__aeabi_idivmod;
485 @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = linkage });497 @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = linkage });
486 @export(__udivsi3, .{ .name = "__aeabi_uidiv", .linkage = linkage });498 @export(__udivsi3, .{ .name = "__aeabi_uidiv", .linkage = linkage });
487 const __aeabi_uidivmod = @import("compiler_rt/arm.zig").__aeabi_uidivmod;499 const __aeabi_uidivmod = @import("compiler_rt/arm.zig").__aeabi_uidivmod;
488 @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = linkage });500 @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = linkage });
489501
490 const __aeabi_memcpy = @import("compiler_rt/arm.zig").__aeabi_memcpy;502 const __aeabi_memcpy = @import("compiler_rt/arm.zig").__aeabi_memcpy;
491 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = linkage });503 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = linkage });
492 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy4", .linkage = linkage });504 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy4", .linkage = linkage });
493 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy8", .linkage = linkage });505 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy8", .linkage = linkage });
494506
495 const __aeabi_memmove = @import("compiler_rt/arm.zig").__aeabi_memmove;507 const __aeabi_memmove = @import("compiler_rt/arm.zig").__aeabi_memmove;
496 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = linkage });508 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = linkage });
497 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove4", .linkage = linkage });509 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove4", .linkage = linkage });
498 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove8", .linkage = linkage });510 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove8", .linkage = linkage });
499511
500 const __aeabi_memset = @import("compiler_rt/arm.zig").__aeabi_memset;512 const __aeabi_memset = @import("compiler_rt/arm.zig").__aeabi_memset;
501 @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = linkage });513 @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = linkage });
502 @export(__aeabi_memset, .{ .name = "__aeabi_memset4", .linkage = linkage });514 @export(__aeabi_memset, .{ .name = "__aeabi_memset4", .linkage = linkage });
503 @export(__aeabi_memset, .{ .name = "__aeabi_memset8", .linkage = linkage });515 @export(__aeabi_memset, .{ .name = "__aeabi_memset8", .linkage = linkage });
504516
505 const __aeabi_memclr = @import("compiler_rt/arm.zig").__aeabi_memclr;517 const __aeabi_memclr = @import("compiler_rt/arm.zig").__aeabi_memclr;
506 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = linkage });518 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = linkage });
507 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage });519 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage });
508 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage });520 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage });
509521
510 if (os_tag == .linux) {522 if (os_tag == .linux) {
511 const __aeabi_read_tp = @import("compiler_rt/arm.zig").__aeabi_read_tp;523 const __aeabi_read_tp = @import("compiler_rt/arm.zig").__aeabi_read_tp;
512 @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage });524 @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage });
513 }
514
515 const __aeabi_f2d = @import("compiler_rt/extendXfYf2.zig").__aeabi_f2d;
516 @export(__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });
517 const __aeabi_i2d = @import("compiler_rt/floatsiXf.zig").__aeabi_i2d;
518 @export(__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });
519 const __aeabi_l2d = @import("compiler_rt/floatdidf.zig").__aeabi_l2d;
520 @export(__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });
521 const __aeabi_l2f = @import("compiler_rt/floatXisf.zig").__aeabi_l2f;
522 @export(__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = linkage });
523 const __aeabi_ui2d = @import("compiler_rt/floatunsidf.zig").__aeabi_ui2d;
524 @export(__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = linkage });
525 const __aeabi_ul2d = @import("compiler_rt/floatundidf.zig").__aeabi_ul2d;
526 @export(__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = linkage });
527 const __aeabi_ui2f = @import("compiler_rt/floatunsisf.zig").__aeabi_ui2f;
528 @export(__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = linkage });
529 const __aeabi_ul2f = @import("compiler_rt/floatundisf.zig").__aeabi_ul2f;
530 @export(__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = linkage });
531
532 const __aeabi_fneg = @import("compiler_rt/negXf2.zig").__aeabi_fneg;
533 @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = linkage });
534 const __aeabi_dneg = @import("compiler_rt/negXf2.zig").__aeabi_dneg;
535 @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = linkage });
536
537 const __aeabi_fmul = @import("compiler_rt/mulXf3.zig").__aeabi_fmul;
538 @export(__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = linkage });
539 const __aeabi_dmul = @import("compiler_rt/mulXf3.zig").__aeabi_dmul;
540 @export(__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = linkage });
541
542 const __aeabi_d2h = @import("compiler_rt/truncXfYf2.zig").__aeabi_d2h;
543 @export(__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = linkage });
544
545 const __aeabi_f2ulz = @import("compiler_rt/fixunssfdi.zig").__aeabi_f2ulz;
546 @export(__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = linkage });
547 const __aeabi_d2ulz = @import("compiler_rt/fixunsdfdi.zig").__aeabi_d2ulz;
548 @export(__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = linkage });
549
550 const __aeabi_f2lz = @import("compiler_rt/fixsfdi.zig").__aeabi_f2lz;
551 @export(__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = linkage });
552 const __aeabi_d2lz = @import("compiler_rt/fixdfdi.zig").__aeabi_d2lz;
553 @export(__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = linkage });
554
555 const __aeabi_d2uiz = @import("compiler_rt/fixunsdfsi.zig").__aeabi_d2uiz;
556 @export(__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = linkage });
557
558 const __aeabi_h2f = @import("compiler_rt/extendXfYf2.zig").__aeabi_h2f;
559 @export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = linkage });
560 const __aeabi_f2h = @import("compiler_rt/truncXfYf2.zig").__aeabi_f2h;
561 @export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = linkage });
562
563 const __aeabi_i2f = @import("compiler_rt/floatsiXf.zig").__aeabi_i2f;
564 @export(__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = linkage });
565 const __aeabi_d2f = @import("compiler_rt/truncXfYf2.zig").__aeabi_d2f;
566 @export(__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = linkage });
567
568 const __aeabi_fadd = @import("compiler_rt/addXf3.zig").__aeabi_fadd;
569 @export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = linkage });
570 const __aeabi_dadd = @import("compiler_rt/addXf3.zig").__aeabi_dadd;
571 @export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = linkage });
572 const __aeabi_fsub = @import("compiler_rt/addXf3.zig").__aeabi_fsub;
573 @export(__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = linkage });
574 const __aeabi_dsub = @import("compiler_rt/addXf3.zig").__aeabi_dsub;
575 @export(__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = linkage });
576
577 const __aeabi_f2uiz = @import("compiler_rt/fixunssfsi.zig").__aeabi_f2uiz;
578 @export(__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = linkage });
579
580 const __aeabi_f2iz = @import("compiler_rt/fixsfsi.zig").__aeabi_f2iz;
581 @export(__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = linkage });
582 const __aeabi_d2iz = @import("compiler_rt/fixdfsi.zig").__aeabi_d2iz;
583 @export(__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = linkage });
584
585 const __aeabi_fdiv = @import("compiler_rt/divsf3.zig").__aeabi_fdiv;
586 @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = linkage });
587 const __aeabi_ddiv = @import("compiler_rt/divdf3.zig").__aeabi_ddiv;
588 @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = linkage });
589
590 const __aeabi_llsl = @import("compiler_rt/shift.zig").__aeabi_llsl;
591 @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = linkage });
592 const __aeabi_lasr = @import("compiler_rt/shift.zig").__aeabi_lasr;
593 @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = linkage });
594 const __aeabi_llsr = @import("compiler_rt/shift.zig").__aeabi_llsr;
595 @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = linkage });
596
597 const __aeabi_fcmpeq = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpeq;
598 @export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = linkage });
599 const __aeabi_fcmplt = @import("compiler_rt/compareXf2.zig").__aeabi_fcmplt;
600 @export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = linkage });
601 const __aeabi_fcmple = @import("compiler_rt/compareXf2.zig").__aeabi_fcmple;
602 @export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = linkage });
603 const __aeabi_fcmpge = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpge;
604 @export(__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = linkage });
605 const __aeabi_fcmpgt = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpgt;
606 @export(__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = linkage });
607 const __aeabi_fcmpun = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpun;
608 @export(__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = linkage });
609
610 const __aeabi_dcmpeq = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpeq;
611 @export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = linkage });
612 const __aeabi_dcmplt = @import("compiler_rt/compareXf2.zig").__aeabi_dcmplt;
613 @export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = linkage });
614 const __aeabi_dcmple = @import("compiler_rt/compareXf2.zig").__aeabi_dcmple;
615 @export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = linkage });
616 const __aeabi_dcmpge = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpge;
617 @export(__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = linkage });
618 const __aeabi_dcmpgt = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpgt;
619 @export(__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = linkage });
620 const __aeabi_dcmpun = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpun;
621 @export(__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage });
622 }525 }
623526
624 if (arch == .i386 and abi == .msvc) {527 const __aeabi_f2d = @import("compiler_rt/extendXfYf2.zig").__aeabi_f2d;
625 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins528 @export(__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage });
626 const _alldiv = @import("compiler_rt/aulldiv.zig")._alldiv;529 const __aeabi_i2d = @import("compiler_rt/floatsiXf.zig").__aeabi_i2d;
627 @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = strong_linkage });530 @export(__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage });
628 const _aulldiv = @import("compiler_rt/aulldiv.zig")._aulldiv;531 const __aeabi_l2d = @import("compiler_rt/floatdidf.zig").__aeabi_l2d;
629 @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = strong_linkage });532 @export(__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage });
630 const _allrem = @import("compiler_rt/aullrem.zig")._allrem;533 const __aeabi_l2f = @import("compiler_rt/floatXisf.zig").__aeabi_l2f;
631 @export(_allrem, .{ .name = "\x01__allrem", .linkage = strong_linkage });534 @export(__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = linkage });
632 const _aullrem = @import("compiler_rt/aullrem.zig")._aullrem;535 const __aeabi_ui2d = @import("compiler_rt/floatunsidf.zig").__aeabi_ui2d;
633 @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage });536 @export(__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = linkage });
634 }537 const __aeabi_ul2d = @import("compiler_rt/floatundidf.zig").__aeabi_ul2d;
538 @export(__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = linkage });
539 const __aeabi_ui2f = @import("compiler_rt/floatunsisf.zig").__aeabi_ui2f;
540 @export(__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = linkage });
541 const __aeabi_ul2f = @import("compiler_rt/floatundisf.zig").__aeabi_ul2f;
542 @export(__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = linkage });
543
544 const __aeabi_fneg = @import("compiler_rt/negXf2.zig").__aeabi_fneg;
545 @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = linkage });
546 const __aeabi_dneg = @import("compiler_rt/negXf2.zig").__aeabi_dneg;
547 @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = linkage });
548
549 const __aeabi_fmul = @import("compiler_rt/mulXf3.zig").__aeabi_fmul;
550 @export(__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = linkage });
551 const __aeabi_dmul = @import("compiler_rt/mulXf3.zig").__aeabi_dmul;
552 @export(__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = linkage });
553
554 const __aeabi_d2h = @import("compiler_rt/truncXfYf2.zig").__aeabi_d2h;
555 @export(__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = linkage });
556
557 const __aeabi_f2ulz = @import("compiler_rt/fixunssfdi.zig").__aeabi_f2ulz;
558 @export(__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = linkage });
559 const __aeabi_d2ulz = @import("compiler_rt/fixunsdfdi.zig").__aeabi_d2ulz;
560 @export(__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = linkage });
561
562 const __aeabi_f2lz = @import("compiler_rt/fixsfdi.zig").__aeabi_f2lz;
563 @export(__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = linkage });
564 const __aeabi_d2lz = @import("compiler_rt/fixdfdi.zig").__aeabi_d2lz;
565 @export(__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = linkage });
566
567 const __aeabi_d2uiz = @import("compiler_rt/fixunsdfsi.zig").__aeabi_d2uiz;
568 @export(__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = linkage });
569
570 const __aeabi_h2f = @import("compiler_rt/extendXfYf2.zig").__aeabi_h2f;
571 @export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = linkage });
572 const __aeabi_f2h = @import("compiler_rt/truncXfYf2.zig").__aeabi_f2h;
573 @export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = linkage });
574
575 const __aeabi_i2f = @import("compiler_rt/floatsiXf.zig").__aeabi_i2f;
576 @export(__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = linkage });
577 const __aeabi_d2f = @import("compiler_rt/truncXfYf2.zig").__aeabi_d2f;
578 @export(__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = linkage });
579
580 const __aeabi_fadd = @import("compiler_rt/addXf3.zig").__aeabi_fadd;
581 @export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = linkage });
582 const __aeabi_dadd = @import("compiler_rt/addXf3.zig").__aeabi_dadd;
583 @export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = linkage });
584 const __aeabi_fsub = @import("compiler_rt/addXf3.zig").__aeabi_fsub;
585 @export(__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = linkage });
586 const __aeabi_dsub = @import("compiler_rt/addXf3.zig").__aeabi_dsub;
587 @export(__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = linkage });
588
589 const __aeabi_f2uiz = @import("compiler_rt/fixunssfsi.zig").__aeabi_f2uiz;
590 @export(__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = linkage });
591
592 const __aeabi_f2iz = @import("compiler_rt/fixsfsi.zig").__aeabi_f2iz;
593 @export(__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = linkage });
594 const __aeabi_d2iz = @import("compiler_rt/fixdfsi.zig").__aeabi_d2iz;
595 @export(__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = linkage });
596
597 const __aeabi_fdiv = @import("compiler_rt/divsf3.zig").__aeabi_fdiv;
598 @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = linkage });
599 const __aeabi_ddiv = @import("compiler_rt/divdf3.zig").__aeabi_ddiv;
600 @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = linkage });
601
602 const __aeabi_llsl = @import("compiler_rt/shift.zig").__aeabi_llsl;
603 @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = linkage });
604 const __aeabi_lasr = @import("compiler_rt/shift.zig").__aeabi_lasr;
605 @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = linkage });
606 const __aeabi_llsr = @import("compiler_rt/shift.zig").__aeabi_llsr;
607 @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = linkage });
608
609 const __aeabi_fcmpeq = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpeq;
610 @export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = linkage });
611 const __aeabi_fcmplt = @import("compiler_rt/compareXf2.zig").__aeabi_fcmplt;
612 @export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = linkage });
613 const __aeabi_fcmple = @import("compiler_rt/compareXf2.zig").__aeabi_fcmple;
614 @export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = linkage });
615 const __aeabi_fcmpge = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpge;
616 @export(__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = linkage });
617 const __aeabi_fcmpgt = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpgt;
618 @export(__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = linkage });
619 const __aeabi_fcmpun = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpun;
620 @export(__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = linkage });
621
622 const __aeabi_dcmpeq = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpeq;
623 @export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = linkage });
624 const __aeabi_dcmplt = @import("compiler_rt/compareXf2.zig").__aeabi_dcmplt;
625 @export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = linkage });
626 const __aeabi_dcmple = @import("compiler_rt/compareXf2.zig").__aeabi_dcmple;
627 @export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = linkage });
628 const __aeabi_dcmpge = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpge;
629 @export(__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = linkage });
630 const __aeabi_dcmpgt = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpgt;
631 @export(__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = linkage });
632 const __aeabi_dcmpun = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpun;
633 @export(__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage });
634 }
635635
636 if (arch.isSPARC()) {636 if (arch == .i386 and abi == .msvc) {
637 // SPARC systems use a different naming scheme637 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
638 const _Qp_add = @import("compiler_rt/sparc.zig")._Qp_add;638 const _alldiv = @import("compiler_rt/aulldiv.zig")._alldiv;
639 @export(_Qp_add, .{ .name = "_Qp_add", .linkage = linkage });639 @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = strong_linkage });
640 const _Qp_div = @import("compiler_rt/sparc.zig")._Qp_div;640 const _aulldiv = @import("compiler_rt/aulldiv.zig")._aulldiv;
641 @export(_Qp_div, .{ .name = "_Qp_div", .linkage = linkage });641 @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = strong_linkage });
642 const _Qp_mul = @import("compiler_rt/sparc.zig")._Qp_mul;642 const _allrem = @import("compiler_rt/aullrem.zig")._allrem;
643 @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = linkage });643 @export(_allrem, .{ .name = "\x01__allrem", .linkage = strong_linkage });
644 const _Qp_sub = @import("compiler_rt/sparc.zig")._Qp_sub;644 const _aullrem = @import("compiler_rt/aullrem.zig")._aullrem;
645 @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = linkage });645 @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage });
646646 }
647 const _Qp_cmp = @import("compiler_rt/sparc.zig")._Qp_cmp;
648 @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = linkage });
649 const _Qp_feq = @import("compiler_rt/sparc.zig")._Qp_feq;
650 @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = linkage });
651 const _Qp_fne = @import("compiler_rt/sparc.zig")._Qp_fne;
652 @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = linkage });
653 const _Qp_flt = @import("compiler_rt/sparc.zig")._Qp_flt;
654 @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = linkage });
655 const _Qp_fle = @import("compiler_rt/sparc.zig")._Qp_fle;
656 @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = linkage });
657 const _Qp_fgt = @import("compiler_rt/sparc.zig")._Qp_fgt;
658 @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = linkage });
659 const _Qp_fge = @import("compiler_rt/sparc.zig")._Qp_fge;
660 @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = linkage });
661
662 const _Qp_itoq = @import("compiler_rt/sparc.zig")._Qp_itoq;
663 @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = linkage });
664 const _Qp_uitoq = @import("compiler_rt/sparc.zig")._Qp_uitoq;
665 @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = linkage });
666 const _Qp_xtoq = @import("compiler_rt/sparc.zig")._Qp_xtoq;
667 @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = linkage });
668 const _Qp_uxtoq = @import("compiler_rt/sparc.zig")._Qp_uxtoq;
669 @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = linkage });
670 const _Qp_stoq = @import("compiler_rt/sparc.zig")._Qp_stoq;
671 @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = linkage });
672 const _Qp_dtoq = @import("compiler_rt/sparc.zig")._Qp_dtoq;
673 @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = linkage });
674 const _Qp_qtoi = @import("compiler_rt/sparc.zig")._Qp_qtoi;
675 @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = linkage });
676 const _Qp_qtoui = @import("compiler_rt/sparc.zig")._Qp_qtoui;
677 @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = linkage });
678 const _Qp_qtox = @import("compiler_rt/sparc.zig")._Qp_qtox;
679 @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = linkage });
680 const _Qp_qtoux = @import("compiler_rt/sparc.zig")._Qp_qtoux;
681 @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = linkage });
682 const _Qp_qtos = @import("compiler_rt/sparc.zig")._Qp_qtos;
683 @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = linkage });
684 const _Qp_qtod = @import("compiler_rt/sparc.zig")._Qp_qtod;
685 @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage });
686 }
687647
688 if ((arch == .powerpc or arch.isPPC64()) and !is_test) {648 if (arch.isSPARC()) {
689 @export(__addtf3, .{ .name = "__addkf3", .linkage = linkage });649 // SPARC systems use a different naming scheme
690 @export(__subtf3, .{ .name = "__subkf3", .linkage = linkage });650 const _Qp_add = @import("compiler_rt/sparc.zig")._Qp_add;
691 @export(__multf3, .{ .name = "__mulkf3", .linkage = linkage });651 @export(_Qp_add, .{ .name = "_Qp_add", .linkage = linkage });
692 @export(__divtf3, .{ .name = "__divkf3", .linkage = linkage });652 const _Qp_div = @import("compiler_rt/sparc.zig")._Qp_div;
693 @export(__extendsftf2, .{ .name = "__extendsfkf2", .linkage = linkage });653 @export(_Qp_div, .{ .name = "_Qp_div", .linkage = linkage });
694 @export(__extenddftf2, .{ .name = "__extenddfkf2", .linkage = linkage });654 const _Qp_mul = @import("compiler_rt/sparc.zig")._Qp_mul;
695 @export(__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = linkage });655 @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = linkage });
696 @export(__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = linkage });656 const _Qp_sub = @import("compiler_rt/sparc.zig")._Qp_sub;
697 @export(__fixtfdi, .{ .name = "__fixkfdi", .linkage = linkage });657 @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = linkage });
698 @export(__fixtfsi, .{ .name = "__fixkfsi", .linkage = linkage });658
699 @export(__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = linkage });659 const _Qp_cmp = @import("compiler_rt/sparc.zig")._Qp_cmp;
700 @export(__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = linkage });660 @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = linkage });
701 @export(__floatsitf, .{ .name = "__floatsikf", .linkage = linkage });661 const _Qp_feq = @import("compiler_rt/sparc.zig")._Qp_feq;
702 @export(__floatditf, .{ .name = "__floatdikf", .linkage = linkage });662 @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = linkage });
703 @export(__floatunditf, .{ .name = "__floatundikf", .linkage = linkage });663 const _Qp_fne = @import("compiler_rt/sparc.zig")._Qp_fne;
704 @export(__floatunsitf, .{ .name = "__floatunsikf", .linkage = linkage });664 @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = linkage });
705665 const _Qp_flt = @import("compiler_rt/sparc.zig")._Qp_flt;
706 @export(__letf2, .{ .name = "__eqkf2", .linkage = linkage });666 @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = linkage });
707 @export(__letf2, .{ .name = "__nekf2", .linkage = linkage });667 const _Qp_fle = @import("compiler_rt/sparc.zig")._Qp_fle;
708 @export(__getf2, .{ .name = "__gekf2", .linkage = linkage });668 @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = linkage });
709 @export(__letf2, .{ .name = "__ltkf2", .linkage = linkage });669 const _Qp_fgt = @import("compiler_rt/sparc.zig")._Qp_fgt;
710 @export(__letf2, .{ .name = "__lekf2", .linkage = linkage });670 @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = linkage });
711 @export(__getf2, .{ .name = "__gtkf2", .linkage = linkage });671 const _Qp_fge = @import("compiler_rt/sparc.zig")._Qp_fge;
712 @export(__unordtf2, .{ .name = "__unordkf2", .linkage = linkage });672 @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = linkage });
713 }673
674 const _Qp_itoq = @import("compiler_rt/sparc.zig")._Qp_itoq;
675 @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = linkage });
676 const _Qp_uitoq = @import("compiler_rt/sparc.zig")._Qp_uitoq;
677 @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = linkage });
678 const _Qp_xtoq = @import("compiler_rt/sparc.zig")._Qp_xtoq;
679 @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = linkage });
680 const _Qp_uxtoq = @import("compiler_rt/sparc.zig")._Qp_uxtoq;
681 @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = linkage });
682 const _Qp_stoq = @import("compiler_rt/sparc.zig")._Qp_stoq;
683 @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = linkage });
684 const _Qp_dtoq = @import("compiler_rt/sparc.zig")._Qp_dtoq;
685 @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = linkage });
686 const _Qp_qtoi = @import("compiler_rt/sparc.zig")._Qp_qtoi;
687 @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = linkage });
688 const _Qp_qtoui = @import("compiler_rt/sparc.zig")._Qp_qtoui;
689 @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = linkage });
690 const _Qp_qtox = @import("compiler_rt/sparc.zig")._Qp_qtox;
691 @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = linkage });
692 const _Qp_qtoux = @import("compiler_rt/sparc.zig")._Qp_qtoux;
693 @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = linkage });
694 const _Qp_qtos = @import("compiler_rt/sparc.zig")._Qp_qtos;
695 @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = linkage });
696 const _Qp_qtod = @import("compiler_rt/sparc.zig")._Qp_qtod;
697 @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage });
698 }
714699
715 _ = @import("compiler_rt/atomics.zig");700 if ((arch == .powerpc or arch.isPPC64()) and !is_test) {
701 @export(__addtf3, .{ .name = "__addkf3", .linkage = linkage });
702 @export(__subtf3, .{ .name = "__subkf3", .linkage = linkage });
703 @export(__multf3, .{ .name = "__mulkf3", .linkage = linkage });
704 @export(__divtf3, .{ .name = "__divkf3", .linkage = linkage });
705 @export(__extendsftf2, .{ .name = "__extendsfkf2", .linkage = linkage });
706 @export(__extenddftf2, .{ .name = "__extenddfkf2", .linkage = linkage });
707 @export(__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = linkage });
708 @export(__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = linkage });
709 @export(__fixtfdi, .{ .name = "__fixkfdi", .linkage = linkage });
710 @export(__fixtfsi, .{ .name = "__fixkfsi", .linkage = linkage });
711 @export(__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = linkage });
712 @export(__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = linkage });
713 @export(__floatsitf, .{ .name = "__floatsikf", .linkage = linkage });
714 @export(__floatditf, .{ .name = "__floatdikf", .linkage = linkage });
715 @export(__floatunditf, .{ .name = "__floatundikf", .linkage = linkage });
716 @export(__floatunsitf, .{ .name = "__floatunsikf", .linkage = linkage });
717
718 @export(__letf2, .{ .name = "__eqkf2", .linkage = linkage });
719 @export(__letf2, .{ .name = "__nekf2", .linkage = linkage });
720 @export(__getf2, .{ .name = "__gekf2", .linkage = linkage });
721 @export(__letf2, .{ .name = "__ltkf2", .linkage = linkage });
722 @export(__letf2, .{ .name = "__lekf2", .linkage = linkage });
723 @export(__getf2, .{ .name = "__gtkf2", .linkage = linkage });
724 @export(__unordtf2, .{ .name = "__unordkf2", .linkage = linkage });
725 }
716726
727 @export(floorf, .{ .name = "floorf", .linkage = linkage });
728 @export(floor, .{ .name = "floor", .linkage = linkage });
729 @export(floorl, .{ .name = "floorl", .linkage = linkage });
730
731 if (!builtin.zig_is_stage2) {
717 @export(fmaq, .{ .name = "fmaq", .linkage = linkage });732 @export(fmaq, .{ .name = "fmaq", .linkage = linkage });
718 @export(floorf, .{ .name = "floorf", .linkage = linkage });
719 @export(floor, .{ .name = "floor", .linkage = linkage });
720 @export(floorl, .{ .name = "floorl", .linkage = linkage });
721 }733 }
722}734}
723735
lib/std/special/compiler_rt/absv.zig+29-24
...@@ -2,31 +2,36 @@...@@ -2,31 +2,36 @@
2// * @panic, if value can not be represented2// * @panic, if value can not be represented
3// - absvXi4_generic for unoptimized version3// - absvXi4_generic for unoptimized version
44
5fn absvXi_generic(comptime ST: type) fn (a: ST) callconv(.C) ST {5inline fn absvXi(comptime ST: type, a: ST) ST {
6 return struct {6 const UT = switch (ST) {
7 fn f(a: ST) callconv(.C) ST {7 i32 => u32,
8 const UT = switch (ST) {8 i64 => u64,
9 i32 => u32,9 i128 => u128,
10 i64 => u64,10 else => unreachable,
11 i128 => u128,11 };
12 else => unreachable,12 // taken from Bit Twiddling Hacks
13 };13 // compute the integer absolute value (abs) without branching
14 // taken from Bit Twiddling Hacks14 var x: ST = a;
15 // compute the integer absolute value (abs) without branching15 const N: UT = @bitSizeOf(ST);
16 var x: ST = a;16 const sign: ST = a >> N - 1;
17 const N: UT = @bitSizeOf(ST);17 x +%= sign;
18 const sign: ST = a >> N - 1;18 x ^= sign;
19 x +%= sign;19 if (x < 0)
20 x ^= sign;20 @panic("compiler_rt absv: overflow");
21 if (x < 0)21 return x;
22 @panic("compiler_rt absv: overflow");22}
23 return x;23
24 }24pub fn __absvsi2(a: i32) callconv(.C) i32 {
25 }.f;25 return absvXi(i32, a);
26}
27
28pub fn __absvdi2(a: i64) callconv(.C) i64 {
29 return absvXi(i64, a);
30}
31
32pub fn __absvti2(a: i128) callconv(.C) i128 {
33 return absvXi(i128, a);
26}34}
27pub const __absvsi2 = absvXi_generic(i32);
28pub const __absvdi2 = absvXi_generic(i64);
29pub const __absvti2 = absvXi_generic(i128);
3035
31test {36test {
32 _ = @import("absvsi2_test.zig");37 _ = @import("absvsi2_test.zig");
lib/std/special/compiler_rt/atomics.zig+272-182
...@@ -131,213 +131,303 @@ comptime {...@@ -131,213 +131,303 @@ comptime {
131// Specialized versions of the GCC atomic builtin functions.131// Specialized versions of the GCC atomic builtin functions.
132// LLVM emits those iff the object size is known and the pointers are correctly132// LLVM emits those iff the object size is known and the pointers are correctly
133// aligned.133// aligned.
134inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T {
135 _ = model;
136 if (@sizeOf(T) > largest_atomic_size) {
137 var sl = spinlocks.get(@ptrToInt(src));
138 defer sl.release();
139 return src.*;
140 } else {
141 return @atomicLoad(T, src, .SeqCst);
142 }
143}
134144
135fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T {145fn __atomic_load_1(src: *u8, model: i32) callconv(.C) u8 {
136 return struct {146 return atomic_load_N(u8, src, model);
137 fn atomic_load_N(src: *T, model: i32) callconv(.C) T {
138 _ = model;
139 if (@sizeOf(T) > largest_atomic_size) {
140 var sl = spinlocks.get(@ptrToInt(src));
141 defer sl.release();
142 return src.*;
143 } else {
144 return @atomicLoad(T, src, .SeqCst);
145 }
146 }
147 }.atomic_load_N;
148}147}
149148
150comptime {149fn __atomic_load_2(src: *u16, model: i32) callconv(.C) u16 {
151 if (supports_atomic_ops) {150 return atomic_load_N(u16, src, model);
152 const atomicLoad_u8 = atomicLoadFn(u8);
153 const atomicLoad_u16 = atomicLoadFn(u16);
154 const atomicLoad_u32 = atomicLoadFn(u32);
155 const atomicLoad_u64 = atomicLoadFn(u64);
156 @export(atomicLoad_u8, .{ .name = "__atomic_load_1", .linkage = linkage });
157 @export(atomicLoad_u16, .{ .name = "__atomic_load_2", .linkage = linkage });
158 @export(atomicLoad_u32, .{ .name = "__atomic_load_4", .linkage = linkage });
159 @export(atomicLoad_u64, .{ .name = "__atomic_load_8", .linkage = linkage });
160 }
161}151}
162152
163fn atomicStoreFn(comptime T: type) fn (*T, T, i32) callconv(.C) void {153fn __atomic_load_4(src: *u32, model: i32) callconv(.C) u32 {
164 return struct {154 return atomic_load_N(u32, src, model);
165 fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void {
166 _ = model;
167 if (@sizeOf(T) > largest_atomic_size) {
168 var sl = spinlocks.get(@ptrToInt(dst));
169 defer sl.release();
170 dst.* = value;
171 } else {
172 @atomicStore(T, dst, value, .SeqCst);
173 }
174 }
175 }.atomic_store_N;
176}155}
177156
178comptime {157fn __atomic_load_8(src: *u64, model: i32) callconv(.C) u64 {
179 if (supports_atomic_ops) {158 return atomic_load_N(u64, src, model);
180 const atomicStore_u8 = atomicStoreFn(u8);159}
181 const atomicStore_u16 = atomicStoreFn(u16);160
182 const atomicStore_u32 = atomicStoreFn(u32);161inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void {
183 const atomicStore_u64 = atomicStoreFn(u64);162 _ = model;
184 @export(atomicStore_u8, .{ .name = "__atomic_store_1", .linkage = linkage });163 if (@sizeOf(T) > largest_atomic_size) {
185 @export(atomicStore_u16, .{ .name = "__atomic_store_2", .linkage = linkage });164 var sl = spinlocks.get(@ptrToInt(dst));
186 @export(atomicStore_u32, .{ .name = "__atomic_store_4", .linkage = linkage });165 defer sl.release();
187 @export(atomicStore_u64, .{ .name = "__atomic_store_8", .linkage = linkage });166 dst.* = value;
167 } else {
168 @atomicStore(T, dst, value, .SeqCst);
188 }169 }
189}170}
190171
191fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T {172fn __atomic_store_1(dst: *u8, value: u8, model: i32) callconv(.C) void {
192 return struct {173 return atomic_store_N(u8, dst, value, model);
193 fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T {
194 _ = model;
195 if (@sizeOf(T) > largest_atomic_size) {
196 var sl = spinlocks.get(@ptrToInt(ptr));
197 defer sl.release();
198 const value = ptr.*;
199 ptr.* = val;
200 return value;
201 } else {
202 return @atomicRmw(T, ptr, .Xchg, val, .SeqCst);
203 }
204 }
205 }.atomic_exchange_N;
206}174}
207175
208comptime {176fn __atomic_store_2(dst: *u16, value: u16, model: i32) callconv(.C) void {
209 if (supports_atomic_ops) {177 return atomic_store_N(u16, dst, value, model);
210 const atomicExchange_u8 = atomicExchangeFn(u8);178}
211 const atomicExchange_u16 = atomicExchangeFn(u16);179
212 const atomicExchange_u32 = atomicExchangeFn(u32);180fn __atomic_store_4(dst: *u32, value: u32, model: i32) callconv(.C) void {
213 const atomicExchange_u64 = atomicExchangeFn(u64);181 return atomic_store_N(u32, dst, value, model);
214 @export(atomicExchange_u8, .{ .name = "__atomic_exchange_1", .linkage = linkage });182}
215 @export(atomicExchange_u16, .{ .name = "__atomic_exchange_2", .linkage = linkage });183
216 @export(atomicExchange_u32, .{ .name = "__atomic_exchange_4", .linkage = linkage });184fn __atomic_store_8(dst: *u64, value: u64, model: i32) callconv(.C) void {
217 @export(atomicExchange_u64, .{ .name = "__atomic_exchange_8", .linkage = linkage });185 return atomic_store_N(u64, dst, value, model);
186}
187
188inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T {
189 _ = model;
190 if (@sizeOf(T) > largest_atomic_size) {
191 var sl = spinlocks.get(@ptrToInt(ptr));
192 defer sl.release();
193 const value = ptr.*;
194 ptr.* = val;
195 return value;
196 } else {
197 return @atomicRmw(T, ptr, .Xchg, val, .SeqCst);
218 }198 }
219}199}
220200
221fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 {201fn __atomic_exchange_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
222 return struct {202 return atomic_exchange_N(u8, ptr, val, model);
223 fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 {203}
224 _ = success;204
225 _ = failure;205fn __atomic_exchange_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
226 if (@sizeOf(T) > largest_atomic_size) {206 return atomic_exchange_N(u16, ptr, val, model);
227 var sl = spinlocks.get(@ptrToInt(ptr));207}
228 defer sl.release();208
229 const value = ptr.*;209fn __atomic_exchange_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
230 if (value == expected.*) {210 return atomic_exchange_N(u32, ptr, val, model);
231 ptr.* = desired;211}
232 return 1;212
233 }213fn __atomic_exchange_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
234 expected.* = value;214 return atomic_exchange_N(u64, ptr, val, model);
235 return 0;215}
236 } else {216
237 if (@cmpxchgStrong(T, ptr, expected.*, desired, .SeqCst, .SeqCst)) |old_value| {217inline fn atomic_compare_exchange_N(
238 expected.* = old_value;218 comptime T: type,
239 return 0;219 ptr: *T,
240 }220 expected: *T,
241 return 1;221 desired: T,
242 }222 success: i32,
223 failure: i32,
224) i32 {
225 _ = success;
226 _ = failure;
227 if (@sizeOf(T) > largest_atomic_size) {
228 var sl = spinlocks.get(@ptrToInt(ptr));
229 defer sl.release();
230 const value = ptr.*;
231 if (value == expected.*) {
232 ptr.* = desired;
233 return 1;
243 }234 }
244 }.atomic_compare_exchange_N;235 expected.* = value;
236 return 0;
237 } else {
238 if (@cmpxchgStrong(T, ptr, expected.*, desired, .SeqCst, .SeqCst)) |old_value| {
239 expected.* = old_value;
240 return 0;
241 }
242 return 1;
243 }
245}244}
246245
247comptime {246fn __atomic_compare_exchange_1(ptr: *u8, expected: *u8, desired: u8, success: i32, failure: i32) callconv(.C) i32 {
248 if (supports_atomic_ops) {247 return atomic_compare_exchange_N(u8, ptr, expected, desired, success, failure);
249 const atomicCompareExchange_u8 = atomicCompareExchangeFn(u8);248}
250 const atomicCompareExchange_u16 = atomicCompareExchangeFn(u16);249
251 const atomicCompareExchange_u32 = atomicCompareExchangeFn(u32);250fn __atomic_compare_exchange_2(ptr: *u16, expected: *u16, desired: u16, success: i32, failure: i32) callconv(.C) i32 {
252 const atomicCompareExchange_u64 = atomicCompareExchangeFn(u64);251 return atomic_compare_exchange_N(u16, ptr, expected, desired, success, failure);
253 @export(atomicCompareExchange_u8, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage });252}
254 @export(atomicCompareExchange_u16, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage });253
255 @export(atomicCompareExchange_u32, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage });254fn __atomic_compare_exchange_4(ptr: *u32, expected: *u32, desired: u32, success: i32, failure: i32) callconv(.C) i32 {
256 @export(atomicCompareExchange_u64, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage });255 return atomic_compare_exchange_N(u32, ptr, expected, desired, success, failure);
256}
257
258fn __atomic_compare_exchange_8(ptr: *u64, expected: *u64, desired: u64, success: i32, failure: i32) callconv(.C) i32 {
259 return atomic_compare_exchange_N(u64, ptr, expected, desired, success, failure);
260}
261
262inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr: *T, val: T, model: i32) T {
263 _ = model;
264 if (@sizeOf(T) > largest_atomic_size) {
265 var sl = spinlocks.get(@ptrToInt(ptr));
266 defer sl.release();
267
268 const value = ptr.*;
269 ptr.* = switch (op) {
270 .Add => value +% val,
271 .Sub => value -% val,
272 .And => value & val,
273 .Nand => ~(value & val),
274 .Or => value | val,
275 .Xor => value ^ val,
276 else => @compileError("unsupported atomic op"),
277 };
278
279 return value;
257 }280 }
281
282 return @atomicRmw(T, ptr, op, val, .SeqCst);
258}283}
259284
260fn fetchFn(comptime T: type, comptime op: std.builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T {285fn __atomic_fetch_add_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
261 return struct {286 return fetch_op_N(u8, .Add, ptr, val, model);
262 pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T {287}
263 _ = model;
264 if (@sizeOf(T) > largest_atomic_size) {
265 var sl = spinlocks.get(@ptrToInt(ptr));
266 defer sl.release();
267
268 const value = ptr.*;
269 ptr.* = switch (op) {
270 .Add => value +% val,
271 .Sub => value -% val,
272 .And => value & val,
273 .Nand => ~(value & val),
274 .Or => value | val,
275 .Xor => value ^ val,
276 else => @compileError("unsupported atomic op"),
277 };
278
279 return value;
280 }
281288
282 return @atomicRmw(T, ptr, op, val, .SeqCst);289fn __atomic_fetch_add_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
283 }290 return fetch_op_N(u16, .Add, ptr, val, model);
284 }.fetch_op_N;291}
292
293fn __atomic_fetch_add_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
294 return fetch_op_N(u32, .Add, ptr, val, model);
295}
296
297fn __atomic_fetch_add_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
298 return fetch_op_N(u64, .Add, ptr, val, model);
299}
300
301fn __atomic_fetch_sub_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
302 return fetch_op_N(u8, .Sub, ptr, val, model);
303}
304
305fn __atomic_fetch_sub_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
306 return fetch_op_N(u16, .Sub, ptr, val, model);
307}
308
309fn __atomic_fetch_sub_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
310 return fetch_op_N(u32, .Sub, ptr, val, model);
311}
312
313fn __atomic_fetch_sub_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
314 return fetch_op_N(u64, .Sub, ptr, val, model);
315}
316
317fn __atomic_fetch_and_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
318 return fetch_op_N(u8, .And, ptr, val, model);
319}
320
321fn __atomic_fetch_and_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
322 return fetch_op_N(u16, .And, ptr, val, model);
323}
324
325fn __atomic_fetch_and_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
326 return fetch_op_N(u32, .And, ptr, val, model);
327}
328
329fn __atomic_fetch_and_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
330 return fetch_op_N(u64, .And, ptr, val, model);
331}
332
333fn __atomic_fetch_or_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
334 return fetch_op_N(u8, .Or, ptr, val, model);
335}
336
337fn __atomic_fetch_or_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
338 return fetch_op_N(u16, .Or, ptr, val, model);
339}
340
341fn __atomic_fetch_or_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
342 return fetch_op_N(u32, .Or, ptr, val, model);
343}
344
345fn __atomic_fetch_or_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
346 return fetch_op_N(u64, .Or, ptr, val, model);
347}
348
349fn __atomic_fetch_xor_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
350 return fetch_op_N(u8, .Xor, ptr, val, model);
351}
352
353fn __atomic_fetch_xor_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
354 return fetch_op_N(u16, .Xor, ptr, val, model);
355}
356
357fn __atomic_fetch_xor_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
358 return fetch_op_N(u32, .Xor, ptr, val, model);
359}
360
361fn __atomic_fetch_xor_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
362 return fetch_op_N(u64, .Xor, ptr, val, model);
363}
364
365fn __atomic_fetch_nand_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
366 return fetch_op_N(u8, .Nand, ptr, val, model);
367}
368
369fn __atomic_fetch_nand_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
370 return fetch_op_N(u16, .Nand, ptr, val, model);
371}
372
373fn __atomic_fetch_nand_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
374 return fetch_op_N(u32, .Nand, ptr, val, model);
375}
376
377fn __atomic_fetch_nand_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
378 return fetch_op_N(u64, .Nand, ptr, val, model);
285}379}
286380
287comptime {381comptime {
288 if (supports_atomic_ops) {382 if (supports_atomic_ops) {
289 const fetch_add_u8 = fetchFn(u8, .Add);383 @export(__atomic_fetch_add_1, .{ .name = "__atomic_fetch_add_1", .linkage = linkage });
290 const fetch_add_u16 = fetchFn(u16, .Add);384 @export(__atomic_fetch_add_2, .{ .name = "__atomic_fetch_add_2", .linkage = linkage });
291 const fetch_add_u32 = fetchFn(u32, .Add);385 @export(__atomic_fetch_add_4, .{ .name = "__atomic_fetch_add_4", .linkage = linkage });
292 const fetch_add_u64 = fetchFn(u64, .Add);386 @export(__atomic_fetch_add_8, .{ .name = "__atomic_fetch_add_8", .linkage = linkage });
293 @export(fetch_add_u8, .{ .name = "__atomic_fetch_add_1", .linkage = linkage });387
294 @export(fetch_add_u16, .{ .name = "__atomic_fetch_add_2", .linkage = linkage });388 @export(__atomic_fetch_sub_1, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage });
295 @export(fetch_add_u32, .{ .name = "__atomic_fetch_add_4", .linkage = linkage });389 @export(__atomic_fetch_sub_2, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage });
296 @export(fetch_add_u64, .{ .name = "__atomic_fetch_add_8", .linkage = linkage });390 @export(__atomic_fetch_sub_4, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage });
297391 @export(__atomic_fetch_sub_8, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage });
298 const fetch_sub_u8 = fetchFn(u8, .Sub);392
299 const fetch_sub_u16 = fetchFn(u16, .Sub);393 @export(__atomic_fetch_and_1, .{ .name = "__atomic_fetch_and_1", .linkage = linkage });
300 const fetch_sub_u32 = fetchFn(u32, .Sub);394 @export(__atomic_fetch_and_2, .{ .name = "__atomic_fetch_and_2", .linkage = linkage });
301 const fetch_sub_u64 = fetchFn(u64, .Sub);395 @export(__atomic_fetch_and_4, .{ .name = "__atomic_fetch_and_4", .linkage = linkage });
302 @export(fetch_sub_u8, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage });396 @export(__atomic_fetch_and_8, .{ .name = "__atomic_fetch_and_8", .linkage = linkage });
303 @export(fetch_sub_u16, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage });397
304 @export(fetch_sub_u32, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage });398 @export(__atomic_fetch_or_1, .{ .name = "__atomic_fetch_or_1", .linkage = linkage });
305 @export(fetch_sub_u64, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage });399 @export(__atomic_fetch_or_2, .{ .name = "__atomic_fetch_or_2", .linkage = linkage });
306400 @export(__atomic_fetch_or_4, .{ .name = "__atomic_fetch_or_4", .linkage = linkage });
307 const fetch_and_u8 = fetchFn(u8, .And);401 @export(__atomic_fetch_or_8, .{ .name = "__atomic_fetch_or_8", .linkage = linkage });
308 const fetch_and_u16 = fetchFn(u16, .And);402
309 const fetch_and_u32 = fetchFn(u32, .And);403 @export(__atomic_fetch_xor_1, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage });
310 const fetch_and_u64 = fetchFn(u64, .And);404 @export(__atomic_fetch_xor_2, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage });
311 @export(fetch_and_u8, .{ .name = "__atomic_fetch_and_1", .linkage = linkage });405 @export(__atomic_fetch_xor_4, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage });
312 @export(fetch_and_u16, .{ .name = "__atomic_fetch_and_2", .linkage = linkage });406 @export(__atomic_fetch_xor_8, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage });
313 @export(fetch_and_u32, .{ .name = "__atomic_fetch_and_4", .linkage = linkage });407
314 @export(fetch_and_u64, .{ .name = "__atomic_fetch_and_8", .linkage = linkage });408 @export(__atomic_fetch_nand_1, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage });
315409 @export(__atomic_fetch_nand_2, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage });
316 const fetch_or_u8 = fetchFn(u8, .Or);410 @export(__atomic_fetch_nand_4, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage });
317 const fetch_or_u16 = fetchFn(u16, .Or);411 @export(__atomic_fetch_nand_8, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage });
318 const fetch_or_u32 = fetchFn(u32, .Or);412
319 const fetch_or_u64 = fetchFn(u64, .Or);413 @export(__atomic_load_1, .{ .name = "__atomic_load_1", .linkage = linkage });
320 @export(fetch_or_u8, .{ .name = "__atomic_fetch_or_1", .linkage = linkage });414 @export(__atomic_load_2, .{ .name = "__atomic_load_2", .linkage = linkage });
321 @export(fetch_or_u16, .{ .name = "__atomic_fetch_or_2", .linkage = linkage });415 @export(__atomic_load_4, .{ .name = "__atomic_load_4", .linkage = linkage });
322 @export(fetch_or_u32, .{ .name = "__atomic_fetch_or_4", .linkage = linkage });416 @export(__atomic_load_8, .{ .name = "__atomic_load_8", .linkage = linkage });
323 @export(fetch_or_u64, .{ .name = "__atomic_fetch_or_8", .linkage = linkage });417
324418 @export(__atomic_store_1, .{ .name = "__atomic_store_1", .linkage = linkage });
325 const fetch_xor_u8 = fetchFn(u8, .Xor);419 @export(__atomic_store_2, .{ .name = "__atomic_store_2", .linkage = linkage });
326 const fetch_xor_u16 = fetchFn(u16, .Xor);420 @export(__atomic_store_4, .{ .name = "__atomic_store_4", .linkage = linkage });
327 const fetch_xor_u32 = fetchFn(u32, .Xor);421 @export(__atomic_store_8, .{ .name = "__atomic_store_8", .linkage = linkage });
328 const fetch_xor_u64 = fetchFn(u64, .Xor);422
329 @export(fetch_xor_u8, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage });423 @export(__atomic_exchange_1, .{ .name = "__atomic_exchange_1", .linkage = linkage });
330 @export(fetch_xor_u16, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage });424 @export(__atomic_exchange_2, .{ .name = "__atomic_exchange_2", .linkage = linkage });
331 @export(fetch_xor_u32, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage });425 @export(__atomic_exchange_4, .{ .name = "__atomic_exchange_4", .linkage = linkage });
332 @export(fetch_xor_u64, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage });426 @export(__atomic_exchange_8, .{ .name = "__atomic_exchange_8", .linkage = linkage });
333427
334 const fetch_nand_u8 = fetchFn(u8, .Nand);428 @export(__atomic_compare_exchange_1, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage });
335 const fetch_nand_u16 = fetchFn(u16, .Nand);429 @export(__atomic_compare_exchange_2, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage });
336 const fetch_nand_u32 = fetchFn(u32, .Nand);430 @export(__atomic_compare_exchange_4, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage });
337 const fetch_nand_u64 = fetchFn(u64, .Nand);431 @export(__atomic_compare_exchange_8, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage });
338 @export(fetch_nand_u8, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage });
339 @export(fetch_nand_u16, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage });
340 @export(fetch_nand_u32, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage });
341 @export(fetch_nand_u64, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage });
342 }432 }
343}433}
lib/std/special/compiler_rt/bswap.zig+55-55
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4// bswap - byteswap4// bswap - byteswap
5// - bswapXi2_generic for unoptimized big and little endian5// - bswapXi2 for unoptimized big and little endian
6// ie for u326// ie for u32
7// DE AD BE EF <- little|big endian7// DE AD BE EF <- little|big endian
8// FE BE AD DE <- big|little endian8// FE BE AD DE <- big|little endian
...@@ -11,64 +11,64 @@ const builtin = @import("builtin");...@@ -11,64 +11,64 @@ const builtin = @import("builtin");
11// 00 00 ff 00 << 1*8 (2n right byte)11// 00 00 ff 00 << 1*8 (2n right byte)
12// 00 00 00 ff << 3*8 (rightmost byte)12// 00 00 00 ff << 3*8 (rightmost byte)
1313
14fn bswapXi2_generic(comptime T: type) fn (a: T) callconv(.C) T {14inline fn bswapXi2(comptime T: type, a: T) T {
15 return struct {15 @setRuntimeSafety(builtin.is_test);
16 fn f(a: T) callconv(.C) T {16 switch (@bitSizeOf(T)) {
17 @setRuntimeSafety(builtin.is_test);17 32 => {
18 switch (@bitSizeOf(T)) {18 // zig fmt: off
19 32 => {19 return (((a & 0xff000000) >> 24)
20 // zig fmt: off20 | ((a & 0x00ff0000) >> 8 )
21 return (((a & 0xff000000) >> 24)21 | ((a & 0x0000ff00) << 8 )
22 | ((a & 0x00ff0000) >> 8 )22 | ((a & 0x000000ff) << 24));
23 | ((a & 0x0000ff00) << 8 )23 // zig fmt: on
24 | ((a & 0x000000ff) << 24));24 },
25 // zig fmt: on25 64 => {
26 },26 // zig fmt: off
27 64 => {27 return (((a & 0xff00000000000000) >> 56)
28 // zig fmt: off28 | ((a & 0x00ff000000000000) >> 40 )
29 return (((a & 0xff00000000000000) >> 56)29 | ((a & 0x0000ff0000000000) >> 24 )
30 | ((a & 0x00ff000000000000) >> 40 )30 | ((a & 0x000000ff00000000) >> 8 )
31 | ((a & 0x0000ff0000000000) >> 24 )31 | ((a & 0x00000000ff000000) << 8 )
32 | ((a & 0x000000ff00000000) >> 8 )32 | ((a & 0x0000000000ff0000) << 24 )
33 | ((a & 0x00000000ff000000) << 8 )33 | ((a & 0x000000000000ff00) << 40 )
34 | ((a & 0x0000000000ff0000) << 24 )34 | ((a & 0x00000000000000ff) << 56));
35 | ((a & 0x000000000000ff00) << 40 )35 // zig fmt: on
36 | ((a & 0x00000000000000ff) << 56));36 },
37 // zig fmt: on37 128 => {
38 },38 // zig fmt: off
39 128 => {39 return (((a & 0xff000000000000000000000000000000) >> 120)
40 // zig fmt: off40 | ((a & 0x00ff0000000000000000000000000000) >> 104)
41 return (((a & 0xff000000000000000000000000000000) >> 120)41 | ((a & 0x0000ff00000000000000000000000000) >> 88 )
42 | ((a & 0x00ff0000000000000000000000000000) >> 104)42 | ((a & 0x000000ff000000000000000000000000) >> 72 )
43 | ((a & 0x0000ff00000000000000000000000000) >> 88 )43 | ((a & 0x00000000ff0000000000000000000000) >> 56 )
44 | ((a & 0x000000ff000000000000000000000000) >> 72 )44 | ((a & 0x0000000000ff00000000000000000000) >> 40 )
45 | ((a & 0x00000000ff0000000000000000000000) >> 56 )45 | ((a & 0x000000000000ff000000000000000000) >> 24 )
46 | ((a & 0x0000000000ff00000000000000000000) >> 40 )46 | ((a & 0x00000000000000ff0000000000000000) >> 8 )
47 | ((a & 0x000000000000ff000000000000000000) >> 24 )47 | ((a & 0x0000000000000000ff00000000000000) << 8 )
48 | ((a & 0x00000000000000ff0000000000000000) >> 8 )48 | ((a & 0x000000000000000000ff000000000000) << 24 )
49 | ((a & 0x0000000000000000ff00000000000000) << 8 )49 | ((a & 0x00000000000000000000ff0000000000) << 40 )
50 | ((a & 0x000000000000000000ff000000000000) << 24 )50 | ((a & 0x0000000000000000000000ff00000000) << 56 )
51 | ((a & 0x00000000000000000000ff0000000000) << 40 )51 | ((a & 0x000000000000000000000000ff000000) << 72 )
52 | ((a & 0x0000000000000000000000ff00000000) << 56 )52 | ((a & 0x00000000000000000000000000ff0000) << 88 )
53 | ((a & 0x000000000000000000000000ff000000) << 72 )53 | ((a & 0x0000000000000000000000000000ff00) << 104)
54 | ((a & 0x00000000000000000000000000ff0000) << 88 )54 | ((a & 0x000000000000000000000000000000ff) << 120));
55 | ((a & 0x0000000000000000000000000000ff00) << 104)55 // zig fmt: on
56 | ((a & 0x000000000000000000000000000000ff) << 120));56 },
57 // zig fmt: on57 else => unreachable,
58 },58 }
59 else => {
60 unreachable;
61 },
62 }
63 }
64 }.f;
65}59}
6660
67pub const __bswapsi2 = bswapXi2_generic(u32);61pub fn __bswapsi2(a: u32) callconv(.C) u32 {
62 return bswapXi2(u32, a);
63}
6864
69pub const __bswapdi2 = bswapXi2_generic(u64);65pub fn __bswapdi2(a: u64) callconv(.C) u64 {
66 return bswapXi2(u64, a);
67}
7068
71pub const __bswapti2 = bswapXi2_generic(u128);69pub fn __bswapti2(a: u128) callconv(.C) u128 {
70 return bswapXi2(u128, a);
71}
7272
73test {73test {
74 _ = @import("bswapsi2_test.zig");74 _ = @import("bswapsi2_test.zig");
lib/std/special/compiler_rt/cmp.zig+34-22
...@@ -11,28 +11,40 @@ const builtin = @import("builtin");...@@ -11,28 +11,40 @@ const builtin = @import("builtin");
11// a == b => 111// a == b => 1
12// a > b => 212// a > b => 2
1313
14fn XcmpXi2_generic(comptime T: type) fn (a: T, b: T) callconv(.C) i32 {14inline fn XcmpXi2(comptime T: type, a: T, b: T) i32 {
15 return struct {15 @setRuntimeSafety(builtin.is_test);
16 fn f(a: T, b: T) callconv(.C) i32 {16 var cmp1: i32 = 0;
17 @setRuntimeSafety(builtin.is_test);17 var cmp2: i32 = 0;
18 var cmp1: i32 = 0;18 if (a > b)
19 var cmp2: i32 = 0;19 cmp1 = 1;
20 if (a > b)20 if (a < b)
21 cmp1 = 1;21 cmp2 = 1;
22 if (a < b)22 return cmp1 - cmp2 + 1;
23 cmp2 = 1;23}
24 return cmp1 - cmp2 + 1;24
25 }25pub fn __cmpsi2(a: i32, b: i32) callconv(.C) i32 {
26 }.f;26 return XcmpXi2(i32, a, b);
27}27}
2828
29pub const __cmpsi2 = XcmpXi2_generic(i32);29pub fn __cmpdi2(a: i64, b: i64) callconv(.C) i32 {
30pub const __cmpdi2 = XcmpXi2_generic(i64);30 return XcmpXi2(i64, a, b);
31pub const __cmpti2 = XcmpXi2_generic(i128);31}
3232
33pub const __ucmpsi2 = XcmpXi2_generic(u32);33pub fn __cmpti2(a: i128, b: i128) callconv(.C) i32 {
34pub const __ucmpdi2 = XcmpXi2_generic(u64);34 return XcmpXi2(i128, a, b);
35pub const __ucmpti2 = XcmpXi2_generic(u128);35}
36
37pub fn __ucmpsi2(a: u32, b: u32) callconv(.C) i32 {
38 return XcmpXi2(u32, a, b);
39}
40
41pub fn __ucmpdi2(a: u64, b: u64) callconv(.C) i32 {
42 return XcmpXi2(u64, a, b);
43}
44
45pub fn __ucmpti2(a: u128, b: u128) callconv(.C) i32 {
46 return XcmpXi2(u128, a, b);
47}
3648
37test {49test {
38 _ = @import("cmpsi2_test.zig");50 _ = @import("cmpsi2_test.zig");
lib/std/special/compiler_rt/count0bits.zig+122-116
...@@ -2,44 +2,40 @@ const std = @import("std");...@@ -2,44 +2,40 @@ const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4// clz - count leading zeroes4// clz - count leading zeroes
5// - clzXi2_generic for unoptimized little and big endian5// - clzXi2 for unoptimized little and big endian
6// - __clzsi2_thumb1: assume a != 06// - __clzsi2_thumb1: assume a != 0
7// - __clzsi2_arm32: assume a != 07// - __clzsi2_arm32: assume a != 0
88
9// ctz - count trailing zeroes9// ctz - count trailing zeroes
10// - ctzXi2_generic for unoptimized little and big endian10// - ctzXi2 for unoptimized little and big endian
1111
12// ffs - find first set12// ffs - find first set
13// * ffs = (a == 0) => 0, (a != 0) => ctz + 113// * ffs = (a == 0) => 0, (a != 0) => ctz + 1
14// * dont pay for `if (x == 0) return shift;` inside ctz14// * dont pay for `if (x == 0) return shift;` inside ctz
15// - ffsXi2_generic for unoptimized little and big endian15// - ffsXi2 for unoptimized little and big endian
1616
17fn clzXi2_generic(comptime T: type) fn (a: T) callconv(.C) i32 {17inline fn clzXi2(comptime T: type, a: T) i32 {
18 return struct {18 @setRuntimeSafety(builtin.is_test);
19 fn f(a: T) callconv(.C) i32 {19
20 @setRuntimeSafety(builtin.is_test);20 var x = switch (@bitSizeOf(T)) {
2121 32 => @bitCast(u32, a),
22 var x = switch (@bitSizeOf(T)) {22 64 => @bitCast(u64, a),
23 32 => @bitCast(u32, a),23 128 => @bitCast(u128, a),
24 64 => @bitCast(u64, a),24 else => unreachable,
25 128 => @bitCast(u128, a),25 };
26 else => unreachable,26 var n: T = @bitSizeOf(T);
27 };27 // Count first bit set using binary search, from Hacker's Delight
28 var n: T = @bitSizeOf(T);28 var y: @TypeOf(x) = 0;
29 // Count first bit set using binary search, from Hacker's Delight29 comptime var shift: u8 = @bitSizeOf(T);
30 var y: @TypeOf(x) = 0;30 inline while (shift > 0) {
31 comptime var shift: u8 = @bitSizeOf(T);31 shift = shift >> 1;
32 inline while (shift > 0) {32 y = x >> shift;
33 shift = shift >> 1;33 if (y != 0) {
34 y = x >> shift;34 n = n - shift;
35 if (y != 0) {35 x = y;
36 n = n - shift;
37 x = y;
38 }
39 }
40 return @intCast(i32, n - @bitCast(T, x));
41 }36 }
42 }.f;37 }
38 return @intCast(i32, n - @bitCast(T, x));
43}39}
4440
45fn __clzsi2_thumb1() callconv(.Naked) void {41fn __clzsi2_thumb1() callconv(.Naked) void {
...@@ -125,103 +121,113 @@ fn __clzsi2_arm32() callconv(.Naked) void {...@@ -125,103 +121,113 @@ fn __clzsi2_arm32() callconv(.Naked) void {
125 unreachable;121 unreachable;
126}122}
127123
128pub const __clzsi2 = impl: {124fn clzsi2_generic(a: i32) callconv(.C) i32 {
129 switch (builtin.cpu.arch) {125 return clzXi2(i32, a);
130 .arm, .armeb, .thumb, .thumbeb => {126}
131 const use_thumb1 =127
132 (builtin.cpu.arch.isThumb() or128pub const __clzsi2 = switch (builtin.cpu.arch) {
133 std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and129 .arm, .armeb, .thumb, .thumbeb => impl: {
134 !std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);130 const use_thumb1 =
135131 (builtin.cpu.arch.isThumb() or
136 if (use_thumb1) {132 std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
137 break :impl __clzsi2_thumb1;133 !std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);
138 }134
139 // From here on we're either targeting Thumb2 or ARM.135 if (use_thumb1) {
140 else if (!builtin.cpu.arch.isThumb()) {136 break :impl __clzsi2_thumb1;
141 break :impl __clzsi2_arm32;137 }
142 }138 // From here on we're either targeting Thumb2 or ARM.
143 // Use the generic implementation otherwise.139 else if (!builtin.cpu.arch.isThumb()) {
144 else break :impl clzXi2_generic(i32);140 break :impl __clzsi2_arm32;
145 },141 }
146 else => break :impl clzXi2_generic(i32),142 // Use the generic implementation otherwise.
147 }143 else break :impl clzsi2_generic;
144 },
145 else => clzsi2_generic,
148};146};
149147
150pub const __clzdi2 = clzXi2_generic(i64);148pub fn __clzdi2(a: i64) callconv(.C) i32 {
151149 return clzXi2(i64, a);
152pub const __clzti2 = clzXi2_generic(i128);150}
153151
154fn ctzXi2_generic(comptime T: type) fn (a: T) callconv(.C) i32 {152pub fn __clzti2(a: i128) callconv(.C) i32 {
155 return struct {153 return clzXi2(i128, a);
156 fn f(a: T) callconv(.C) i32 {154}
157 @setRuntimeSafety(builtin.is_test);155
158156inline fn ctzXi2(comptime T: type, a: T) i32 {
159 var x = switch (@bitSizeOf(T)) {157 @setRuntimeSafety(builtin.is_test);
160 32 => @bitCast(u32, a),158
161 64 => @bitCast(u64, a),159 var x = switch (@bitSizeOf(T)) {
162 128 => @bitCast(u128, a),160 32 => @bitCast(u32, a),
163 else => unreachable,161 64 => @bitCast(u64, a),
164 };162 128 => @bitCast(u128, a),
165 var n: T = 1;163 else => unreachable,
166 // Number of trailing zeroes as binary search, from Hacker's Delight164 };
167 var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));165 var n: T = 1;
168 comptime var shift = @bitSizeOf(T);166 // Number of trailing zeroes as binary search, from Hacker's Delight
169 if (x == 0) return shift;167 var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));
170 inline while (shift > 1) {168 comptime var shift = @bitSizeOf(T);
171 shift = shift >> 1;169 if (x == 0) return shift;
172 mask = mask >> shift;170 inline while (shift > 1) {
173 if ((x & mask) == 0) {171 shift = shift >> 1;
174 n = n + shift;172 mask = mask >> shift;
175 x = x >> shift;173 if ((x & mask) == 0) {
176 }174 n = n + shift;
177 }175 x = x >> shift;
178 return @intCast(i32, n - @bitCast(T, (x & 1)));
179 }176 }
180 }.f;177 }
178 return @intCast(i32, n - @bitCast(T, (x & 1)));
179}
180
181pub fn __ctzsi2(a: i32) callconv(.C) i32 {
182 return ctzXi2(i32, a);
181}183}
182184
183pub const __ctzsi2 = ctzXi2_generic(i32);185pub fn __ctzdi2(a: i64) callconv(.C) i32 {
184186 return ctzXi2(i64, a);
185pub const __ctzdi2 = ctzXi2_generic(i64);187}
186188
187pub const __ctzti2 = ctzXi2_generic(i128);189pub fn __ctzti2(a: i128) callconv(.C) i32 {
188190 return ctzXi2(i128, a);
189fn ffsXi2_generic(comptime T: type) fn (a: T) callconv(.C) i32 {191}
190 return struct {192
191 fn f(a: T) callconv(.C) i32 {193inline fn ffsXi2(comptime T: type, a: T) i32 {
192 @setRuntimeSafety(builtin.is_test);194 @setRuntimeSafety(builtin.is_test);
193195
194 var x = switch (@bitSizeOf(T)) {196 var x = switch (@bitSizeOf(T)) {
195 32 => @bitCast(u32, a),197 32 => @bitCast(u32, a),
196 64 => @bitCast(u64, a),198 64 => @bitCast(u64, a),
197 128 => @bitCast(u128, a),199 128 => @bitCast(u128, a),
198 else => unreachable,200 else => unreachable,
199 };201 };
200 var n: T = 1;202 var n: T = 1;
201 // adapted from Number of trailing zeroes (see ctzXi2_generic)203 // adapted from Number of trailing zeroes (see ctzXi2)
202 var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));204 var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));
203 comptime var shift = @bitSizeOf(T);205 comptime var shift = @bitSizeOf(T);
204 // In contrast to ctz return 0206 // In contrast to ctz return 0
205 if (x == 0) return 0;207 if (x == 0) return 0;
206 inline while (shift > 1) {208 inline while (shift > 1) {
207 shift = shift >> 1;209 shift = shift >> 1;
208 mask = mask >> shift;210 mask = mask >> shift;
209 if ((x & mask) == 0) {211 if ((x & mask) == 0) {
210 n = n + shift;212 n = n + shift;
211 x = x >> shift;213 x = x >> shift;
212 }
213 }
214 // return ctz + 1
215 return @intCast(i32, n - @bitCast(T, (x & 1))) + @as(i32, 1);
216 }214 }
217 }.f;215 }
216 // return ctz + 1
217 return @intCast(i32, n - @bitCast(T, (x & 1))) + @as(i32, 1);
218}218}
219219
220pub const __ffssi2 = ffsXi2_generic(i32);220pub fn __ffssi2(a: i32) callconv(.C) i32 {
221 return ffsXi2(i32, a);
222}
221223
222pub const __ffsdi2 = ffsXi2_generic(i64);224pub fn __ffsdi2(a: i64) callconv(.C) i32 {
225 return ffsXi2(i64, a);
226}
223227
224pub const __ffsti2 = ffsXi2_generic(i128);228pub fn __ffsti2(a: i128) callconv(.C) i32 {
229 return ffsXi2(i128, a);
230}
225231
226test {232test {
227 _ = @import("clzsi2_test.zig");233 _ = @import("clzsi2_test.zig");
lib/std/special/compiler_rt/fixuint.zig+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1const is_test = @import("builtin").is_test;1const is_test = @import("builtin").is_test;
2const Log2Int = @import("std").math.Log2Int;2const Log2Int = @import("std").math.Log2Int;
33
4pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t {4pub inline fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t {
5 @setRuntimeSafety(is_test);5 @setRuntimeSafety(is_test);
66
7 const rep_t = switch (fp_t) {7 const rep_t = switch (fp_t) {
lib/std/special/compiler_rt/floatXisf.zig+4-7
...@@ -4,7 +4,7 @@ const maxInt = std.math.maxInt;...@@ -4,7 +4,7 @@ const maxInt = std.math.maxInt;
44
5const FLT_MANT_DIG = 24;5const FLT_MANT_DIG = 24;
66
7fn __floatXisf(comptime T: type, arg: T) f32 {7inline fn floatXisf(comptime T: type, arg: T) f32 {
8 @setRuntimeSafety(builtin.is_test);8 @setRuntimeSafety(builtin.is_test);
99
10 const bits = @typeInfo(T).Int.bits;10 const bits = @typeInfo(T).Int.bits;
...@@ -71,18 +71,15 @@ fn __floatXisf(comptime T: type, arg: T) f32 {...@@ -71,18 +71,15 @@ fn __floatXisf(comptime T: type, arg: T) f32 {
71}71}
7272
73pub fn __floatdisf(arg: i64) callconv(.C) f32 {73pub fn __floatdisf(arg: i64) callconv(.C) f32 {
74 @setRuntimeSafety(builtin.is_test);74 return floatXisf(i64, arg);
75 return @call(.{ .modifier = .always_inline }, __floatXisf, .{ i64, arg });
76}75}
7776
78pub fn __floattisf(arg: i128) callconv(.C) f32 {77pub fn __floattisf(arg: i128) callconv(.C) f32 {
79 @setRuntimeSafety(builtin.is_test);78 return floatXisf(i128, arg);
80 return @call(.{ .modifier = .always_inline }, __floatXisf, .{ i128, arg });
81}79}
8280
83pub fn __aeabi_l2f(arg: i64) callconv(.AAPCS) f32 {81pub fn __aeabi_l2f(arg: i64) callconv(.AAPCS) f32 {
84 @setRuntimeSafety(false);82 return floatXisf(i64, arg);
85 return @call(.{ .modifier = .always_inline }, __floatdisf, .{arg});
86}83}
8784
88test {85test {
lib/std/special/compiler_rt/floatsiXf.zig+6-6
...@@ -2,7 +2,7 @@ const builtin = @import("builtin");...@@ -2,7 +2,7 @@ const builtin = @import("builtin");
2const std = @import("std");2const std = @import("std");
3const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
44
5fn floatsiXf(comptime T: type, a: i32) T {5inline fn floatsiXf(comptime T: type, a: i32) T {
6 @setRuntimeSafety(builtin.is_test);6 @setRuntimeSafety(builtin.is_test);
77
8 const bits = @typeInfo(T).Float.bits;8 const bits = @typeInfo(T).Float.bits;
...@@ -56,27 +56,27 @@ fn floatsiXf(comptime T: type, a: i32) T {...@@ -56,27 +56,27 @@ fn floatsiXf(comptime T: type, a: i32) T {
5656
57pub fn __floatsisf(arg: i32) callconv(.C) f32 {57pub fn __floatsisf(arg: i32) callconv(.C) f32 {
58 @setRuntimeSafety(builtin.is_test);58 @setRuntimeSafety(builtin.is_test);
59 return @call(.{ .modifier = .always_inline }, floatsiXf, .{ f32, arg });59 return floatsiXf(f32, arg);
60}60}
6161
62pub fn __floatsidf(arg: i32) callconv(.C) f64 {62pub fn __floatsidf(arg: i32) callconv(.C) f64 {
63 @setRuntimeSafety(builtin.is_test);63 @setRuntimeSafety(builtin.is_test);
64 return @call(.{ .modifier = .always_inline }, floatsiXf, .{ f64, arg });64 return floatsiXf(f64, arg);
65}65}
6666
67pub fn __floatsitf(arg: i32) callconv(.C) f128 {67pub fn __floatsitf(arg: i32) callconv(.C) f128 {
68 @setRuntimeSafety(builtin.is_test);68 @setRuntimeSafety(builtin.is_test);
69 return @call(.{ .modifier = .always_inline }, floatsiXf, .{ f128, arg });69 return floatsiXf(f128, arg);
70}70}
7171
72pub fn __aeabi_i2d(arg: i32) callconv(.AAPCS) f64 {72pub fn __aeabi_i2d(arg: i32) callconv(.AAPCS) f64 {
73 @setRuntimeSafety(false);73 @setRuntimeSafety(false);
74 return @call(.{ .modifier = .always_inline }, __floatsidf, .{arg});74 return floatsiXf(f64, arg);
75}75}
7676
77pub fn __aeabi_i2f(arg: i32) callconv(.AAPCS) f32 {77pub fn __aeabi_i2f(arg: i32) callconv(.AAPCS) f32 {
78 @setRuntimeSafety(false);78 @setRuntimeSafety(false);
79 return @call(.{ .modifier = .always_inline }, __floatsisf, .{arg});79 return floatsiXf(f32, arg);
80}80}
8181
82fn test_one_floatsitf(a: i32, expected: u128) !void {82fn test_one_floatsitf(a: i32, expected: u128) !void {
lib/std/special/compiler_rt/floatundisf.zig+6-3
...@@ -4,7 +4,7 @@ const maxInt = std.math.maxInt;...@@ -4,7 +4,7 @@ const maxInt = std.math.maxInt;
44
5const FLT_MANT_DIG = 24;5const FLT_MANT_DIG = 24;
66
7pub fn __floatundisf(arg: u64) callconv(.C) f32 {7inline fn floatundisf(arg: u64) f32 {
8 @setRuntimeSafety(builtin.is_test);8 @setRuntimeSafety(builtin.is_test);
99
10 if (arg == 0) return 0;10 if (arg == 0) return 0;
...@@ -56,9 +56,12 @@ pub fn __floatundisf(arg: u64) callconv(.C) f32 {...@@ -56,9 +56,12 @@ pub fn __floatundisf(arg: u64) callconv(.C) f32 {
56 return @bitCast(f32, result);56 return @bitCast(f32, result);
57}57}
5858
59pub fn __floatundisf(arg: u64) callconv(.C) f32 {
60 return floatundisf(arg);
61}
62
59pub fn __aeabi_ul2f(arg: u64) callconv(.AAPCS) f32 {63pub fn __aeabi_ul2f(arg: u64) callconv(.AAPCS) f32 {
60 @setRuntimeSafety(false);64 return floatundisf(arg);
61 return @call(.{ .modifier = .always_inline }, __floatundisf, .{arg});
62}65}
6366
64fn test__floatundisf(a: u64, expected: f32) !void {67fn test__floatundisf(a: u64, expected: f32) !void {
lib/std/special/compiler_rt/floatunsidf.zig+6-3
...@@ -4,7 +4,7 @@ const maxInt = std.math.maxInt;...@@ -4,7 +4,7 @@ const maxInt = std.math.maxInt;
44
5const implicitBit = @as(u64, 1) << 52;5const implicitBit = @as(u64, 1) << 52;
66
7pub fn __floatunsidf(arg: u32) callconv(.C) f64 {7inline fn floatunsidf(arg: u32) f64 {
8 @setRuntimeSafety(builtin.is_test);8 @setRuntimeSafety(builtin.is_test);
99
10 if (arg == 0) return 0.0;10 if (arg == 0) return 0.0;
...@@ -18,9 +18,12 @@ pub fn __floatunsidf(arg: u32) callconv(.C) f64 {...@@ -18,9 +18,12 @@ pub fn __floatunsidf(arg: u32) callconv(.C) f64 {
18 return @bitCast(f64, mant | (exp + 1023) << 52);18 return @bitCast(f64, mant | (exp + 1023) << 52);
19}19}
2020
21pub fn __floatunsidf(arg: u32) callconv(.C) f64 {
22 return floatunsidf(arg);
23}
24
21pub fn __aeabi_ui2d(arg: u32) callconv(.AAPCS) f64 {25pub fn __aeabi_ui2d(arg: u32) callconv(.AAPCS) f64 {
22 @setRuntimeSafety(false);26 return floatunsidf(arg);
23 return @call(.{ .modifier = .always_inline }, __floatunsidf, .{arg});
24}27}
2528
26fn test_one_floatunsidf(a: u32, expected: u64) !void {29fn test_one_floatunsidf(a: u32, expected: u64) !void {
lib/std/special/compiler_rt/floatunsisf.zig+6-3
...@@ -6,7 +6,7 @@ const significandBits = 23;...@@ -6,7 +6,7 @@ const significandBits = 23;
6const exponentBias = 127;6const exponentBias = 127;
7const implicitBit = @as(u32, 1) << significandBits;7const implicitBit = @as(u32, 1) << significandBits;
88
9pub fn __floatunsisf(arg: u32) callconv(.C) f32 {9inline fn floatunsisf(arg: u32) f32 {
10 @setRuntimeSafety(builtin.is_test);10 @setRuntimeSafety(builtin.is_test);
1111
12 if (arg == 0) return 0.0;12 if (arg == 0) return 0.0;
...@@ -38,9 +38,12 @@ pub fn __floatunsisf(arg: u32) callconv(.C) f32 {...@@ -38,9 +38,12 @@ pub fn __floatunsisf(arg: u32) callconv(.C) f32 {
38 return @bitCast(f32, result);38 return @bitCast(f32, result);
39}39}
4040
41pub fn __floatunsisf(arg: u32) callconv(.C) f32 {
42 return floatunsisf(arg);
43}
44
41pub fn __aeabi_ui2f(arg: u32) callconv(.AAPCS) f32 {45pub fn __aeabi_ui2f(arg: u32) callconv(.AAPCS) f32 {
42 @setRuntimeSafety(false);46 return floatunsisf(arg);
43 return @call(.{ .modifier = .always_inline }, __floatunsisf, .{arg});
44}47}
4548
46fn test_one_floatunsisf(a: u32, expected: u32) !void {49fn test_one_floatunsisf(a: u32, expected: u32) !void {
lib/std/special/compiler_rt/negXi2.zig+13-11
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4// neg - negate (the number)4// neg - negate (the number)
5// - negXi2_generic for unoptimized little and big endian5// - negXi2 for unoptimized little and big endian
66
7// sfffffff = 2^31-17// sfffffff = 2^31-1
8// two's complement inverting bits and add 1 would result in -INT_MIN == 08// two's complement inverting bits and add 1 would result in -INT_MIN == 0
...@@ -11,20 +11,22 @@ const builtin = @import("builtin");...@@ -11,20 +11,22 @@ const builtin = @import("builtin");
11// * size optimized builds11// * size optimized builds
12// * machines that dont support carry operations12// * machines that dont support carry operations
1313
14fn negXi2_generic(comptime T: type) fn (a: T) callconv(.C) T {14inline fn negXi2(comptime T: type, a: T) T {
15 return struct {15 @setRuntimeSafety(builtin.is_test);
16 fn f(a: T) callconv(.C) T {16 return -a;
17 @setRuntimeSafety(builtin.is_test);
18 return -a;
19 }
20 }.f;
21}17}
2218
23pub const __negsi2 = negXi2_generic(i32);19pub fn __negsi2(a: i32) callconv(.C) i32 {
20 return negXi2(i32, a);
21}
2422
25pub const __negdi2 = negXi2_generic(i64);23pub fn __negdi2(a: i64) callconv(.C) i64 {
24 return negXi2(i64, a);
25}
2626
27pub const __negti2 = negXi2_generic(i128);27pub fn __negti2(a: i128) callconv(.C) i128 {
28 return negXi2(i128, a);
29}
2830
29test {31test {
30 _ = @import("negsi2_test.zig");32 _ = @import("negsi2_test.zig");
lib/std/special/compiler_rt/negv.zig+24-19
...@@ -3,26 +3,31 @@...@@ -3,26 +3,31 @@
3// - negvXi4_generic for unoptimized version3// - negvXi4_generic for unoptimized version
44
5// assume -0 == 0 is gracefully handled by the hardware5// assume -0 == 0 is gracefully handled by the hardware
6fn negvXi_generic(comptime ST: type) fn (a: ST) callconv(.C) ST {6inline fn negvXi(comptime ST: type, a: ST) ST {
7 return struct {7 const UT = switch (ST) {
8 fn f(a: ST) callconv(.C) ST {8 i32 => u32,
9 const UT = switch (ST) {9 i64 => u64,
10 i32 => u32,10 i128 => u128,
11 i64 => u64,11 else => unreachable,
12 i128 => u128,12 };
13 else => unreachable,13 const N: UT = @bitSizeOf(ST);
14 };14 const min: ST = @bitCast(ST, (@as(UT, 1) << (N - 1)));
15 const N: UT = @bitSizeOf(ST);15 if (a == min)
16 const min: ST = @bitCast(ST, (@as(UT, 1) << (N - 1)));16 @panic("compiler_rt negv: overflow");
17 if (a == min)17 return -a;
18 @panic("compiler_rt negv: overflow");18}
19 return -a;19
20 }20pub fn __negvsi2(a: i32) callconv(.C) i32 {
21 }.f;21 return negvXi(i32, a);
22}
23
24pub fn __negvdi2(a: i64) callconv(.C) i64 {
25 return negvXi(i64, a);
26}
27
28pub fn __negvti2(a: i128) callconv(.C) i128 {
29 return negvXi(i128, a);
22}30}
23pub const __negvsi2 = negvXi_generic(i32);
24pub const __negvdi2 = negvXi_generic(i64);
25pub const __negvti2 = negvXi_generic(i128);
2631
27test {32test {
28 _ = @import("negvsi2_test.zig");33 _ = @import("negvsi2_test.zig");
lib/std/special/compiler_rt/parity.zig+25-23
...@@ -4,34 +4,36 @@ const builtin = @import("builtin");...@@ -4,34 +4,36 @@ const builtin = @import("builtin");
4// parity - if number of bits set is even => 0, else => 14// parity - if number of bits set is even => 0, else => 1
5// - pariytXi2_generic for big and little endian5// - pariytXi2_generic for big and little endian
66
7fn parityXi2_generic(comptime T: type) fn (a: T) callconv(.C) i32 {7inline fn parityXi2(comptime T: type, a: T) i32 {
8 return struct {8 @setRuntimeSafety(builtin.is_test);
9 fn f(a: T) callconv(.C) i32 {
10 @setRuntimeSafety(builtin.is_test);
119
12 var x = switch (@bitSizeOf(T)) {10 var x = switch (@bitSizeOf(T)) {
13 32 => @bitCast(u32, a),11 32 => @bitCast(u32, a),
14 64 => @bitCast(u64, a),12 64 => @bitCast(u64, a),
15 128 => @bitCast(u128, a),13 128 => @bitCast(u128, a),
16 else => unreachable,14 else => unreachable,
17 };15 };
18 // Bit Twiddling Hacks: Compute parity in parallel16 // Bit Twiddling Hacks: Compute parity in parallel
19 comptime var shift: u8 = @bitSizeOf(T) / 2;17 comptime var shift: u8 = @bitSizeOf(T) / 2;
20 inline while (shift > 2) {18 inline while (shift > 2) {
21 x ^= x >> shift;19 x ^= x >> shift;
22 shift = shift >> 1;20 shift = shift >> 1;
23 }21 }
24 x &= 0xf;22 x &= 0xf;
25 return (@intCast(u16, 0x6996) >> @intCast(u4, x)) & 1; // optimization for >>2 and >>123 return (@intCast(u16, 0x6996) >> @intCast(u4, x)) & 1; // optimization for >>2 and >>1
26 }
27 }.f;
28}24}
2925
30pub const __paritysi2 = parityXi2_generic(i32);26pub fn __paritysi2(a: i32) callconv(.C) i32 {
27 return parityXi2(i32, a);
28}
3129
32pub const __paritydi2 = parityXi2_generic(i64);30pub fn __paritydi2(a: i64) callconv(.C) i32 {
31 return parityXi2(i64, a);
32}
3333
34pub const __parityti2 = parityXi2_generic(i128);34pub fn __parityti2(a: i128) callconv(.C) i32 {
35 return parityXi2(i128, a);
36}
3537
36test {38test {
37 _ = @import("paritysi2_test.zig");39 _ = @import("paritysi2_test.zig");
lib/std/special/compiler_rt/popcount.zig+27-25
...@@ -10,35 +10,37 @@ const std = @import("std");...@@ -10,35 +10,37 @@ const std = @import("std");
10// TAOCP: Combinational Algorithms, Bitwise Tricks And Techniques,10// TAOCP: Combinational Algorithms, Bitwise Tricks And Techniques,
11// subsubsection "Working with the rightmost bits" and "Sideways addition".11// subsubsection "Working with the rightmost bits" and "Sideways addition".
1212
13fn popcountXi2_generic(comptime ST: type) fn (a: ST) callconv(.C) i32 {13inline fn popcountXi2(comptime ST: type, a: ST) i32 {
14 return struct {14 @setRuntimeSafety(builtin.is_test);
15 fn f(a: ST) callconv(.C) i32 {15 const UT = switch (ST) {
16 @setRuntimeSafety(builtin.is_test);16 i32 => u32,
17 const UT = switch (ST) {17 i64 => u64,
18 i32 => u32,18 i128 => u128,
19 i64 => u64,19 else => unreachable,
20 i128 => u128,20 };
21 else => unreachable,21 var x = @bitCast(UT, a);
22 };22 x -= (x >> 1) & (~@as(UT, 0) / 3); // 0x55...55, aggregate duos
23 var x = @bitCast(UT, a);23 x = ((x >> 2) & (~@as(UT, 0) / 5)) // 0x33...33, aggregate nibbles
24 x -= (x >> 1) & (~@as(UT, 0) / 3); // 0x55...55, aggregate duos24 + (x & (~@as(UT, 0) / 5));
25 x = ((x >> 2) & (~@as(UT, 0) / 5)) // 0x33...33, aggregate nibbles25 x += x >> 4;
26 + (x & (~@as(UT, 0) / 5));26 x &= ~@as(UT, 0) / 17; // 0x0F...0F, aggregate bytes
27 x += x >> 4;27 // 8 most significant bits of x + (x<<8) + (x<<16) + ..
28 x &= ~@as(UT, 0) / 17; // 0x0F...0F, aggregate bytes28 x *%= ~@as(UT, 0) / 255; // 0x01...01
29 // 8 most significant bits of x + (x<<8) + (x<<16) + ..29 x >>= (@bitSizeOf(ST) - 8);
30 x *%= ~@as(UT, 0) / 255; // 0x01...0130 return @intCast(i32, x);
31 x >>= (@bitSizeOf(ST) - 8);
32 return @intCast(i32, x);
33 }
34 }.f;
35}31}
3632
37pub const __popcountsi2 = popcountXi2_generic(i32);33pub fn __popcountsi2(a: i32) callconv(.C) i32 {
34 return popcountXi2(i32, a);
35}
3836
39pub const __popcountdi2 = popcountXi2_generic(i64);37pub fn __popcountdi2(a: i64) callconv(.C) i32 {
38 return popcountXi2(i64, a);
39}
4040
41pub const __popcountti2 = popcountXi2_generic(i128);41pub fn __popcountti2(a: i128) callconv(.C) i32 {
42 return popcountXi2(i128, a);
43}
4244
43test {45test {
44 _ = @import("popcountsi2_test.zig");46 _ = @import("popcountsi2_test.zig");
lib/std/special/compiler_rt/shift.zig+12-12
...@@ -19,7 +19,7 @@ fn Dwords(comptime T: type, comptime signed_half: bool) type {...@@ -19,7 +19,7 @@ fn Dwords(comptime T: type, comptime signed_half: bool) type {
1919
20// Arithmetic shift left20// Arithmetic shift left
21// Precondition: 0 <= b < bits_in_dword21// Precondition: 0 <= b < bits_in_dword
22pub fn ashlXi3(comptime T: type, a: T, b: i32) T {22pub inline fn ashlXi3(comptime T: type, a: T, b: i32) T {
23 const dwords = Dwords(T, false);23 const dwords = Dwords(T, false);
24 const S = Log2Int(dwords.HalfT);24 const S = Log2Int(dwords.HalfT);
2525
...@@ -42,7 +42,7 @@ pub fn ashlXi3(comptime T: type, a: T, b: i32) T {...@@ -42,7 +42,7 @@ pub fn ashlXi3(comptime T: type, a: T, b: i32) T {
4242
43// Arithmetic shift right43// Arithmetic shift right
44// Precondition: 0 <= b < T.bit_count44// Precondition: 0 <= b < T.bit_count
45pub fn ashrXi3(comptime T: type, a: T, b: i32) T {45pub inline fn ashrXi3(comptime T: type, a: T, b: i32) T {
46 const dwords = Dwords(T, true);46 const dwords = Dwords(T, true);
47 const S = Log2Int(dwords.HalfT);47 const S = Log2Int(dwords.HalfT);
4848
...@@ -69,7 +69,7 @@ pub fn ashrXi3(comptime T: type, a: T, b: i32) T {...@@ -69,7 +69,7 @@ pub fn ashrXi3(comptime T: type, a: T, b: i32) T {
6969
70// Logical shift right70// Logical shift right
71// Precondition: 0 <= b < T.bit_count71// Precondition: 0 <= b < T.bit_count
72pub fn lshrXi3(comptime T: type, a: T, b: i32) T {72pub inline fn lshrXi3(comptime T: type, a: T, b: i32) T {
73 const dwords = Dwords(T, false);73 const dwords = Dwords(T, false);
74 const S = Log2Int(dwords.HalfT);74 const S = Log2Int(dwords.HalfT);
7575
...@@ -91,32 +91,32 @@ pub fn lshrXi3(comptime T: type, a: T, b: i32) T {...@@ -91,32 +91,32 @@ pub fn lshrXi3(comptime T: type, a: T, b: i32) T {
91}91}
9292
93pub fn __ashldi3(a: i64, b: i32) callconv(.C) i64 {93pub fn __ashldi3(a: i64, b: i32) callconv(.C) i64 {
94 return @call(.{ .modifier = .always_inline }, ashlXi3, .{ i64, a, b });94 return ashlXi3(i64, a, b);
95}95}
96pub fn __ashlti3(a: i128, b: i32) callconv(.C) i128 {96pub fn __ashlti3(a: i128, b: i32) callconv(.C) i128 {
97 return @call(.{ .modifier = .always_inline }, ashlXi3, .{ i128, a, b });97 return ashlXi3(i128, a, b);
98}98}
99pub fn __ashrdi3(a: i64, b: i32) callconv(.C) i64 {99pub fn __ashrdi3(a: i64, b: i32) callconv(.C) i64 {
100 return @call(.{ .modifier = .always_inline }, ashrXi3, .{ i64, a, b });100 return ashrXi3(i64, a, b);
101}101}
102pub fn __ashrti3(a: i128, b: i32) callconv(.C) i128 {102pub fn __ashrti3(a: i128, b: i32) callconv(.C) i128 {
103 return @call(.{ .modifier = .always_inline }, ashrXi3, .{ i128, a, b });103 return ashrXi3(i128, a, b);
104}104}
105pub fn __lshrdi3(a: i64, b: i32) callconv(.C) i64 {105pub fn __lshrdi3(a: i64, b: i32) callconv(.C) i64 {
106 return @call(.{ .modifier = .always_inline }, lshrXi3, .{ i64, a, b });106 return lshrXi3(i64, a, b);
107}107}
108pub fn __lshrti3(a: i128, b: i32) callconv(.C) i128 {108pub fn __lshrti3(a: i128, b: i32) callconv(.C) i128 {
109 return @call(.{ .modifier = .always_inline }, lshrXi3, .{ i128, a, b });109 return lshrXi3(i128, a, b);
110}110}
111111
112pub fn __aeabi_llsl(a: i64, b: i32) callconv(.AAPCS) i64 {112pub fn __aeabi_llsl(a: i64, b: i32) callconv(.AAPCS) i64 {
113 return __ashldi3(a, b);113 return ashlXi3(i64, a, b);
114}114}
115pub fn __aeabi_lasr(a: i64, b: i32) callconv(.AAPCS) i64 {115pub fn __aeabi_lasr(a: i64, b: i32) callconv(.AAPCS) i64 {
116 return __ashrdi3(a, b);116 return ashrXi3(i64, a, b);
117}117}
118pub fn __aeabi_llsr(a: i64, b: i32) callconv(.AAPCS) i64 {118pub fn __aeabi_llsr(a: i64, b: i32) callconv(.AAPCS) i64 {
119 return __lshrdi3(a, b);119 return lshrXi3(i64, a, b);
120}120}
121121
122test {122test {
src/type.zig+12-1
...@@ -4603,7 +4603,18 @@ pub const CType = enum {...@@ -4603,7 +4603,18 @@ pub const CType = enum {
4603 .longlong,4603 .longlong,
4604 .ulonglong,4604 .ulonglong,
4605 => return 64,4605 => return 64,
4606 .longdouble => @panic("TODO figure out what kind of float `long double` is on this target"),4606 .longdouble => switch (target.cpu.arch) {
4607 .riscv64,
4608 .aarch64,
4609 .aarch64_be,
4610 .aarch64_32,
4611 .s390x,
4612 .mips64,
4613 .mips64el,
4614 => return 128,
4615
4616 else => return 80,
4617 },
4607 },4618 },
46084619
4609 .windows, .uefi => switch (self) {4620 .windows, .uefi => switch (self) {