authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-09 18:47:03-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-09 20:03:15-08:00
log74608293afa6d825c6482d2253eed28a89705351
tree8c88af9f9790d33cd6d9b74b3aecab1c2dcfcf2b
parent6c7814fabd5cc94dce13ed02e5313069be9af482

compiler_rt: common -> compiler_rt

use the "symbol" helper function in all exports move all declarations from common.zig to compiler_rt.zig flatten the tree structure somewhat (move contents of tiny files into parent files) No functional changes.

191 files changed, 1607 insertions(+), 1690 deletions(-)

lib/compiler_rt.zig+402-23
......@@ -1,5 +1,6 @@
11const builtin = @import("builtin");
22const ofmt_c = builtin.object_format == .c;
3const native_endian = builtin.cpu.arch.endian();
34
45const std = @import("std");
56
......@@ -57,13 +58,12 @@ comptime {
5758 _ = @import("compiler_rt/cmp.zig");
5859
5960 _ = @import("compiler_rt/shift.zig");
60 _ = @import("compiler_rt/negXi2.zig");
61 symbol(&__negsi2, "__negsi2");
62 symbol(&__negdi2, "__negdi2");
63 symbol(&__negti2, "__negti2");
6164 _ = @import("compiler_rt/int.zig");
6265 _ = @import("compiler_rt/mulXi3.zig");
63 _ = @import("compiler_rt/divti3.zig");
64 _ = @import("compiler_rt/udivti3.zig");
65 _ = @import("compiler_rt/modti3.zig");
66 _ = @import("compiler_rt/umodti3.zig");
66 _ = @import("compiler_rt/udivmod.zig");
6767
6868 _ = @import("compiler_rt/absv.zig");
6969 _ = @import("compiler_rt/absvsi2.zig");
......@@ -108,9 +108,6 @@ comptime {
108108 _ = @import("compiler_rt/trunctfxf2.zig");
109109
110110 _ = @import("compiler_rt/int_from_float.zig");
111 _ = @import("compiler_rt/fixhfsi.zig");
112 _ = @import("compiler_rt/fixhfdi.zig");
113 _ = @import("compiler_rt/fixhfti.zig");
114111 _ = @import("compiler_rt/fixhfei.zig");
115112 _ = @import("compiler_rt/fixsfsi.zig");
116113 _ = @import("compiler_rt/fixsfdi.zig");
......@@ -126,8 +123,8 @@ comptime {
126123 _ = @import("compiler_rt/fixtfei.zig");
127124 _ = @import("compiler_rt/fixxfsi.zig");
128125 _ = @import("compiler_rt/fixxfdi.zig");
129 _ = @import("compiler_rt/fixxfti.zig");
130126 _ = @import("compiler_rt/fixxfei.zig");
127
131128 _ = @import("compiler_rt/fixunshfsi.zig");
132129 _ = @import("compiler_rt/fixunshfdi.zig");
133130 _ = @import("compiler_rt/fixunshfti.zig");
......@@ -193,16 +190,10 @@ comptime {
193190
194191 // comparison
195192 _ = @import("compiler_rt/comparef.zig");
196 _ = @import("compiler_rt/cmphf2.zig");
197 _ = @import("compiler_rt/cmpsf2.zig");
198193 _ = @import("compiler_rt/cmpdf2.zig");
199194 _ = @import("compiler_rt/cmptf2.zig");
200195 _ = @import("compiler_rt/cmpxf2.zig");
201 _ = @import("compiler_rt/unordhf2.zig");
202 _ = @import("compiler_rt/unordsf2.zig");
203196 _ = @import("compiler_rt/unorddf2.zig");
204 _ = @import("compiler_rt/unordxf2.zig");
205 _ = @import("compiler_rt/unordtf2.zig");
206197 _ = @import("compiler_rt/gehf2.zig");
207198 _ = @import("compiler_rt/gesf2.zig");
208199 _ = @import("compiler_rt/gedf2.zig");
......@@ -236,11 +227,17 @@ comptime {
236227 _ = @import("compiler_rt/divxf3.zig");
237228 _ = @import("compiler_rt/divtf3.zig");
238229
239 _ = @import("compiler_rt/neghf2.zig");
240 _ = @import("compiler_rt/negsf2.zig");
241 _ = @import("compiler_rt/negdf2.zig");
242 _ = @import("compiler_rt/negtf2.zig");
243 _ = @import("compiler_rt/negxf2.zig");
230 symbol(&__neghf2, "__neghf2");
231 if (want_aeabi) {
232 symbol(&__aeabi_fneg, "__aeabi_fneg");
233 symbol(&__aeabi_dneg, "__aeabi_dneg");
234 } else {
235 symbol(&__negsf2, "__negsf2");
236 symbol(&__negdf2, "__negdf2");
237 }
238 if (want_ppc_abi) symbol(&__negtf2, "__negkf2");
239 symbol(&__negtf2, "__negtf2");
240 symbol(&__negxf2, "__negxf2");
244241
245242 // other
246243 _ = @import("compiler_rt/powiXf2.zig");
......@@ -281,7 +278,6 @@ comptime {
281278 // BigInt. Alphabetically sorted.
282279 _ = @import("compiler_rt/divmodei4.zig");
283280 _ = @import("compiler_rt/udivmodei4.zig");
284 _ = @import("compiler_rt/udivmodti4.zig");
285281
286282 // extra
287283 _ = @import("compiler_rt/os_version_check.zig");
......@@ -302,10 +298,13 @@ comptime {
302298 }
303299
304300 _ = @import("compiler_rt/memcpy.zig");
305 _ = @import("compiler_rt/memset.zig");
301 if (!ofmt_c) {
302 symbol(&memset, "memset");
303 symbol(&__memset, "__memset");
304 }
306305 _ = @import("compiler_rt/memmove.zig");
307306 symbol(&memcmp, "memcmp");
308 _ = @import("compiler_rt/bcmp.zig");
307 symbol(&bcmp, "bcmp");
309308 _ = @import("compiler_rt/ssp.zig");
310309 symbol(&strlen, "strlen");
311310 }
......@@ -345,3 +344,383 @@ test "memcmp" {
345344 try std.testing.expect(memcmp(arr0, arr4, 3) < 0);
346345 try std.testing.expect(memcmp(arr4, arr0, 3) > 0);
347346}
347
348pub const PreferredLoadStoreElement = element: {
349 if (std.simd.suggestVectorLength(u8)) |vec_size| {
350 const Vec = @Vector(vec_size, u8);
351
352 if (@sizeOf(Vec) == vec_size and std.math.isPowerOfTwo(vec_size)) {
353 break :element Vec;
354 }
355 }
356 break :element usize;
357};
358
359pub const want_aeabi = switch (builtin.abi) {
360 .eabi,
361 .eabihf,
362 .musleabi,
363 .musleabihf,
364 .gnueabi,
365 .gnueabihf,
366 .android,
367 .androideabi,
368 => switch (builtin.cpu.arch) {
369 .arm, .armeb, .thumb, .thumbeb => true,
370 else => false,
371 },
372 else => false,
373};
374
375/// These functions are required on Windows on ARM. They are provided by MSVC libc, but in libc-less
376/// builds or when linking MinGW libc they are our responsibility.
377/// Temporarily used for thumb-uefi until https://github.com/ziglang/zig/issues/21630 is addressed.
378pub const want_windows_arm_abi = e: {
379 if (!builtin.cpu.arch.isArm()) break :e false;
380 switch (builtin.os.tag) {
381 .windows, .uefi => {},
382 else => break :e false,
383 }
384 // The ABI is needed, but it's only our reponsibility if libc won't provide it.
385 break :e builtin.abi.isGnu() or !builtin.link_libc;
386};
387
388/// These functions are required by on Windows on x86 on some ABIs. They are provided by MSVC libc,
389/// but in libc-less builds they are our responsibility.
390pub const want_windows_x86_msvc_abi = e: {
391 if (builtin.cpu.arch != .x86) break :e false;
392 if (builtin.os.tag != .windows) break :e false;
393 switch (builtin.abi) {
394 .none, .msvc, .itanium => {},
395 else => break :e false,
396 }
397 // The ABI is needed, but it's only our responsibility if libc won't provide it.
398 break :e !builtin.link_libc;
399};
400
401pub const want_ppc_abi = builtin.cpu.arch.isPowerPC();
402
403pub const want_float_exceptions = !builtin.cpu.arch.isWasm();
404
405// Libcalls that involve u128 on Windows x86-64 are expected by LLVM to use the
406// calling convention of @Vector(2, u64), rather than what's standard.
407pub const want_windows_v2u64_abi = builtin.os.tag == .windows and builtin.cpu.arch == .x86_64 and !ofmt_c;
408
409/// This governs whether to use these symbol names for f16/f32 conversions
410/// rather than the standard names:
411/// * __gnu_f2h_ieee
412/// * __gnu_h2f_ieee
413/// Known correct configurations:
414/// x86_64-freestanding-none => true
415/// x86_64-linux-none => true
416/// x86_64-linux-gnu => true
417/// x86_64-linux-musl => true
418/// x86_64-linux-eabi => true
419/// arm-linux-musleabihf => true
420/// arm-linux-gnueabihf => true
421/// arm-linux-eabihf => false
422/// wasm32-wasi-musl => false
423/// wasm32-freestanding-none => false
424/// x86_64-windows-gnu => true
425/// x86_64-windows-msvc => true
426/// any-macos-any => false
427pub const gnu_f16_abi = switch (builtin.cpu.arch) {
428 .wasm32,
429 .wasm64,
430 .riscv64,
431 .riscv64be,
432 .riscv32,
433 .riscv32be,
434 => false,
435
436 .x86, .x86_64 => true,
437
438 .arm, .armeb, .thumb, .thumbeb => switch (builtin.abi) {
439 .eabi, .eabihf => false,
440 else => true,
441 },
442
443 else => !builtin.os.tag.isDarwin(),
444};
445
446pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
447
448/// This seems to mostly correspond to `clang::TargetInfo::HasFloat16`.
449pub fn F16T(comptime OtherType: type) type {
450 return switch (builtin.cpu.arch) {
451 .amdgcn,
452 .arm,
453 .armeb,
454 .thumb,
455 .thumbeb,
456 .aarch64,
457 .aarch64_be,
458 .hexagon,
459 .loongarch32,
460 .loongarch64,
461 .nvptx,
462 .nvptx64,
463 .riscv32,
464 .riscv32be,
465 .riscv64,
466 .riscv64be,
467 .s390x,
468 .spirv32,
469 .spirv64,
470 => f16,
471 .x86, .x86_64 => if (builtin.target.os.tag.isDarwin()) switch (OtherType) {
472 // Starting with LLVM 16, Darwin uses different abi for f16
473 // depending on the type of the other return/argument..???
474 f32, f64 => u16,
475 f80, f128 => f16,
476 else => unreachable,
477 } else f16,
478 else => u16,
479 };
480}
481
482pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
483 switch (Z) {
484 u16 => {
485 // 16x16 --> 32 bit multiply
486 const product = @as(u32, a) * @as(u32, b);
487 hi.* = @intCast(product >> 16);
488 lo.* = @truncate(product);
489 },
490 u32 => {
491 // 32x32 --> 64 bit multiply
492 const product = @as(u64, a) * @as(u64, b);
493 hi.* = @truncate(product >> 32);
494 lo.* = @truncate(product);
495 },
496 u64 => {
497 const S = struct {
498 fn loWord(x: u64) u64 {
499 return @as(u32, @truncate(x));
500 }
501 fn hiWord(x: u64) u64 {
502 return @as(u32, @truncate(x >> 32));
503 }
504 };
505 // 64x64 -> 128 wide multiply for platforms that don't have such an operation;
506 // many 64-bit platforms have this operation, but they tend to have hardware
507 // floating-point, so we don't bother with a special case for them here.
508 // Each of the component 32x32 -> 64 products
509 const plolo: u64 = S.loWord(a) * S.loWord(b);
510 const plohi: u64 = S.loWord(a) * S.hiWord(b);
511 const philo: u64 = S.hiWord(a) * S.loWord(b);
512 const phihi: u64 = S.hiWord(a) * S.hiWord(b);
513 // Sum terms that contribute to lo in a way that allows us to get the carry
514 const r0: u64 = S.loWord(plolo);
515 const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo);
516 lo.* = r0 +% (r1 << 32);
517 // Sum terms contributing to hi with the carry from lo
518 hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi;
519 },
520 u128 => {
521 const Word_LoMask: u64 = 0x00000000ffffffff;
522 const Word_HiMask: u64 = 0xffffffff00000000;
523 const Word_FullMask: u64 = 0xffffffffffffffff;
524 const S = struct {
525 fn Word_1(x: u128) u64 {
526 return @as(u32, @truncate(x >> 96));
527 }
528 fn Word_2(x: u128) u64 {
529 return @as(u32, @truncate(x >> 64));
530 }
531 fn Word_3(x: u128) u64 {
532 return @as(u32, @truncate(x >> 32));
533 }
534 fn Word_4(x: u128) u64 {
535 return @as(u32, @truncate(x));
536 }
537 };
538 // 128x128 -> 256 wide multiply for platforms that don't have such an operation;
539 // many 64-bit platforms have this operation, but they tend to have hardware
540 // floating-point, so we don't bother with a special case for them here.
541
542 const product11: u64 = S.Word_1(a) * S.Word_1(b);
543 const product12: u64 = S.Word_1(a) * S.Word_2(b);
544 const product13: u64 = S.Word_1(a) * S.Word_3(b);
545 const product14: u64 = S.Word_1(a) * S.Word_4(b);
546 const product21: u64 = S.Word_2(a) * S.Word_1(b);
547 const product22: u64 = S.Word_2(a) * S.Word_2(b);
548 const product23: u64 = S.Word_2(a) * S.Word_3(b);
549 const product24: u64 = S.Word_2(a) * S.Word_4(b);
550 const product31: u64 = S.Word_3(a) * S.Word_1(b);
551 const product32: u64 = S.Word_3(a) * S.Word_2(b);
552 const product33: u64 = S.Word_3(a) * S.Word_3(b);
553 const product34: u64 = S.Word_3(a) * S.Word_4(b);
554 const product41: u64 = S.Word_4(a) * S.Word_1(b);
555 const product42: u64 = S.Word_4(a) * S.Word_2(b);
556 const product43: u64 = S.Word_4(a) * S.Word_3(b);
557 const product44: u64 = S.Word_4(a) * S.Word_4(b);
558
559 const sum0: u128 = @as(u128, product44);
560 const sum1: u128 = @as(u128, product34) +%
561 @as(u128, product43);
562 const sum2: u128 = @as(u128, product24) +%
563 @as(u128, product33) +%
564 @as(u128, product42);
565 const sum3: u128 = @as(u128, product14) +%
566 @as(u128, product23) +%
567 @as(u128, product32) +%
568 @as(u128, product41);
569 const sum4: u128 = @as(u128, product13) +%
570 @as(u128, product22) +%
571 @as(u128, product31);
572 const sum5: u128 = @as(u128, product12) +%
573 @as(u128, product21);
574 const sum6: u128 = @as(u128, product11);
575
576 const r0: u128 = (sum0 & Word_FullMask) +%
577 ((sum1 & Word_LoMask) << 32);
578 const r1: u128 = (sum0 >> 64) +%
579 ((sum1 >> 32) & Word_FullMask) +%
580 (sum2 & Word_FullMask) +%
581 ((sum3 << 32) & Word_HiMask);
582
583 lo.* = r0 +% (r1 << 64);
584 hi.* = (r1 >> 64) +%
585 (sum1 >> 96) +%
586 (sum2 >> 64) +%
587 (sum3 >> 32) +%
588 sum4 +%
589 (sum5 << 32) +%
590 (sum6 << 64);
591 },
592 else => @compileError("unsupported"),
593 }
594}
595
596pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).float.bits)) i32 {
597 const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
598 const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T);
599
600 const shift = @clz(significand.*) - @clz(integerBit);
601 significand.* <<= @as(std.math.Log2Int(Z), @intCast(shift));
602 return @as(i32, 1) - shift;
603}
604
605pub inline fn fneg(a: anytype) @TypeOf(a) {
606 const F = @TypeOf(a);
607 const bits = @typeInfo(F).float.bits;
608 const U = @Int(.unsigned, bits);
609 const sign_bit_mask = @as(U, 1) << (bits - 1);
610 const negated = @as(U, @bitCast(a)) ^ sign_bit_mask;
611 return @bitCast(negated);
612}
613
614fn __negxf2(a: f80) callconv(.c) f80 {
615 return fneg(a);
616}
617
618fn __neghf2(a: f16) callconv(.c) f16 {
619 return fneg(a);
620}
621
622fn __negdf2(a: f64) callconv(.c) f64 {
623 return fneg(a);
624}
625
626fn __aeabi_dneg(a: f64) callconv(.{ .arm_aapcs = .{} }) f64 {
627 return fneg(a);
628}
629
630fn __negtf2(a: f128) callconv(.c) f128 {
631 return fneg(a);
632}
633
634fn __negsf2(a: f32) callconv(.c) f32 {
635 return fneg(a);
636}
637
638fn __aeabi_fneg(a: f32) callconv(.{ .arm_aapcs = .{} }) f32 {
639 return fneg(a);
640}
641
642/// Allows to access underlying bits as two equally sized lower and higher
643/// signed or unsigned integers.
644pub fn HalveInt(comptime T: type, comptime signed_half: bool) type {
645 return extern union {
646 pub const bits = @divExact(@typeInfo(T).int.bits, 2);
647 pub const HalfTU = std.meta.Int(.unsigned, bits);
648 pub const HalfTS = std.meta.Int(.signed, bits);
649 pub const HalfT = if (signed_half) HalfTS else HalfTU;
650
651 all: T,
652 s: if (native_endian == .little)
653 extern struct { low: HalfT, high: HalfT }
654 else
655 extern struct { high: HalfT, low: HalfT },
656 };
657}
658
659pub fn __negsi2(a: i32) callconv(.c) i32 {
660 return negXi2(i32, a);
661}
662
663pub fn __negdi2(a: i64) callconv(.c) i64 {
664 return negXi2(i64, a);
665}
666
667pub fn __negti2(a: i128) callconv(.c) i128 {
668 return negXi2(i128, a);
669}
670
671inline fn negXi2(comptime T: type, a: T) T {
672 return -a;
673}
674
675pub fn memset(dest: ?[*]u8, c: u8, len: usize) callconv(.c) ?[*]u8 {
676 @setRuntimeSafety(false);
677
678 if (len != 0) {
679 var d = dest.?;
680 var n = len;
681 while (true) {
682 d[0] = c;
683 n -= 1;
684 if (n == 0) break;
685 d += 1;
686 }
687 }
688
689 return dest;
690}
691
692pub fn __memset(dest: ?[*]u8, c: u8, n: usize, dest_n: usize) callconv(.c) ?[*]u8 {
693 if (dest_n < n)
694 @panic("buffer overflow");
695 return memset(dest, c, n);
696}
697
698pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.c) c_int {
699 @setRuntimeSafety(false);
700
701 var index: usize = 0;
702 while (index != n) : (index += 1) {
703 if (vl[index] != vr[index]) {
704 return 1;
705 }
706 }
707
708 return 0;
709}
710
711test "bcmp" {
712 const base_arr = &[_]u8{ 1, 1, 1 };
713 const arr1 = &[_]u8{ 1, 1, 1 };
714 const arr2 = &[_]u8{ 1, 0, 1 };
715 const arr3 = &[_]u8{ 1, 2, 1 };
716
717 try std.testing.expect(bcmp(base_arr[0..], arr1[0..], base_arr.len) == 0);
718 try std.testing.expect(bcmp(base_arr[0..], arr2[0..], base_arr.len) != 0);
719 try std.testing.expect(bcmp(base_arr[0..], arr3[0..], base_arr.len) != 0);
720}
721
722test {
723 _ = @import("compiler_rt/negsi2_test.zig");
724 _ = @import("compiler_rt/negdi2_test.zig");
725 _ = @import("compiler_rt/negti2_test.zig");
726}
lib/compiler_rt/aarch64_outline_atomics.zig+102-101
......@@ -1,7 +1,8 @@
11//! This file is generated by tools/gen_outline_atomics.zig.
22const builtin = @import("builtin");
33const std = @import("std");
4const common = @import("common.zig");
4const compiler_rt = @import("../compiler_rt.zig");
5const symbol = compiler_rt.symbol;
56const always_has_lse = builtin.cpu.has(.aarch64, .lse);
67
78/// This default is overridden at runtime after inspecting CPU properties.
......@@ -2024,104 +2025,104 @@ fn __aarch64_cas16_acq_rel() align(16) callconv(.naked) void {
20242025}
20252026
20262027comptime {
2027 @export(&__aarch64_cas1_relax, .{ .name = "__aarch64_cas1_relax", .linkage = common.linkage, .visibility = common.visibility });
2028 @export(&__aarch64_swp1_relax, .{ .name = "__aarch64_swp1_relax", .linkage = common.linkage, .visibility = common.visibility });
2029 @export(&__aarch64_ldadd1_relax, .{ .name = "__aarch64_ldadd1_relax", .linkage = common.linkage, .visibility = common.visibility });
2030 @export(&__aarch64_ldclr1_relax, .{ .name = "__aarch64_ldclr1_relax", .linkage = common.linkage, .visibility = common.visibility });
2031 @export(&__aarch64_ldeor1_relax, .{ .name = "__aarch64_ldeor1_relax", .linkage = common.linkage, .visibility = common.visibility });
2032 @export(&__aarch64_ldset1_relax, .{ .name = "__aarch64_ldset1_relax", .linkage = common.linkage, .visibility = common.visibility });
2033 @export(&__aarch64_cas1_acq, .{ .name = "__aarch64_cas1_acq", .linkage = common.linkage, .visibility = common.visibility });
2034 @export(&__aarch64_swp1_acq, .{ .name = "__aarch64_swp1_acq", .linkage = common.linkage, .visibility = common.visibility });
2035 @export(&__aarch64_ldadd1_acq, .{ .name = "__aarch64_ldadd1_acq", .linkage = common.linkage, .visibility = common.visibility });
2036 @export(&__aarch64_ldclr1_acq, .{ .name = "__aarch64_ldclr1_acq", .linkage = common.linkage, .visibility = common.visibility });
2037 @export(&__aarch64_ldeor1_acq, .{ .name = "__aarch64_ldeor1_acq", .linkage = common.linkage, .visibility = common.visibility });
2038 @export(&__aarch64_ldset1_acq, .{ .name = "__aarch64_ldset1_acq", .linkage = common.linkage, .visibility = common.visibility });
2039 @export(&__aarch64_cas1_rel, .{ .name = "__aarch64_cas1_rel", .linkage = common.linkage, .visibility = common.visibility });
2040 @export(&__aarch64_swp1_rel, .{ .name = "__aarch64_swp1_rel", .linkage = common.linkage, .visibility = common.visibility });
2041 @export(&__aarch64_ldadd1_rel, .{ .name = "__aarch64_ldadd1_rel", .linkage = common.linkage, .visibility = common.visibility });
2042 @export(&__aarch64_ldclr1_rel, .{ .name = "__aarch64_ldclr1_rel", .linkage = common.linkage, .visibility = common.visibility });
2043 @export(&__aarch64_ldeor1_rel, .{ .name = "__aarch64_ldeor1_rel", .linkage = common.linkage, .visibility = common.visibility });
2044 @export(&__aarch64_ldset1_rel, .{ .name = "__aarch64_ldset1_rel", .linkage = common.linkage, .visibility = common.visibility });
2045 @export(&__aarch64_cas1_acq_rel, .{ .name = "__aarch64_cas1_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2046 @export(&__aarch64_swp1_acq_rel, .{ .name = "__aarch64_swp1_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2047 @export(&__aarch64_ldadd1_acq_rel, .{ .name = "__aarch64_ldadd1_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2048 @export(&__aarch64_ldclr1_acq_rel, .{ .name = "__aarch64_ldclr1_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2049 @export(&__aarch64_ldeor1_acq_rel, .{ .name = "__aarch64_ldeor1_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2050 @export(&__aarch64_ldset1_acq_rel, .{ .name = "__aarch64_ldset1_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2051 @export(&__aarch64_cas2_relax, .{ .name = "__aarch64_cas2_relax", .linkage = common.linkage, .visibility = common.visibility });
2052 @export(&__aarch64_swp2_relax, .{ .name = "__aarch64_swp2_relax", .linkage = common.linkage, .visibility = common.visibility });
2053 @export(&__aarch64_ldadd2_relax, .{ .name = "__aarch64_ldadd2_relax", .linkage = common.linkage, .visibility = common.visibility });
2054 @export(&__aarch64_ldclr2_relax, .{ .name = "__aarch64_ldclr2_relax", .linkage = common.linkage, .visibility = common.visibility });
2055 @export(&__aarch64_ldeor2_relax, .{ .name = "__aarch64_ldeor2_relax", .linkage = common.linkage, .visibility = common.visibility });
2056 @export(&__aarch64_ldset2_relax, .{ .name = "__aarch64_ldset2_relax", .linkage = common.linkage, .visibility = common.visibility });
2057 @export(&__aarch64_cas2_acq, .{ .name = "__aarch64_cas2_acq", .linkage = common.linkage, .visibility = common.visibility });
2058 @export(&__aarch64_swp2_acq, .{ .name = "__aarch64_swp2_acq", .linkage = common.linkage, .visibility = common.visibility });
2059 @export(&__aarch64_ldadd2_acq, .{ .name = "__aarch64_ldadd2_acq", .linkage = common.linkage, .visibility = common.visibility });
2060 @export(&__aarch64_ldclr2_acq, .{ .name = "__aarch64_ldclr2_acq", .linkage = common.linkage, .visibility = common.visibility });
2061 @export(&__aarch64_ldeor2_acq, .{ .name = "__aarch64_ldeor2_acq", .linkage = common.linkage, .visibility = common.visibility });
2062 @export(&__aarch64_ldset2_acq, .{ .name = "__aarch64_ldset2_acq", .linkage = common.linkage, .visibility = common.visibility });
2063 @export(&__aarch64_cas2_rel, .{ .name = "__aarch64_cas2_rel", .linkage = common.linkage, .visibility = common.visibility });
2064 @export(&__aarch64_swp2_rel, .{ .name = "__aarch64_swp2_rel", .linkage = common.linkage, .visibility = common.visibility });
2065 @export(&__aarch64_ldadd2_rel, .{ .name = "__aarch64_ldadd2_rel", .linkage = common.linkage, .visibility = common.visibility });
2066 @export(&__aarch64_ldclr2_rel, .{ .name = "__aarch64_ldclr2_rel", .linkage = common.linkage, .visibility = common.visibility });
2067 @export(&__aarch64_ldeor2_rel, .{ .name = "__aarch64_ldeor2_rel", .linkage = common.linkage, .visibility = common.visibility });
2068 @export(&__aarch64_ldset2_rel, .{ .name = "__aarch64_ldset2_rel", .linkage = common.linkage, .visibility = common.visibility });
2069 @export(&__aarch64_cas2_acq_rel, .{ .name = "__aarch64_cas2_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2070 @export(&__aarch64_swp2_acq_rel, .{ .name = "__aarch64_swp2_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2071 @export(&__aarch64_ldadd2_acq_rel, .{ .name = "__aarch64_ldadd2_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2072 @export(&__aarch64_ldclr2_acq_rel, .{ .name = "__aarch64_ldclr2_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2073 @export(&__aarch64_ldeor2_acq_rel, .{ .name = "__aarch64_ldeor2_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2074 @export(&__aarch64_ldset2_acq_rel, .{ .name = "__aarch64_ldset2_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2075 @export(&__aarch64_cas4_relax, .{ .name = "__aarch64_cas4_relax", .linkage = common.linkage, .visibility = common.visibility });
2076 @export(&__aarch64_swp4_relax, .{ .name = "__aarch64_swp4_relax", .linkage = common.linkage, .visibility = common.visibility });
2077 @export(&__aarch64_ldadd4_relax, .{ .name = "__aarch64_ldadd4_relax", .linkage = common.linkage, .visibility = common.visibility });
2078 @export(&__aarch64_ldclr4_relax, .{ .name = "__aarch64_ldclr4_relax", .linkage = common.linkage, .visibility = common.visibility });
2079 @export(&__aarch64_ldeor4_relax, .{ .name = "__aarch64_ldeor4_relax", .linkage = common.linkage, .visibility = common.visibility });
2080 @export(&__aarch64_ldset4_relax, .{ .name = "__aarch64_ldset4_relax", .linkage = common.linkage, .visibility = common.visibility });
2081 @export(&__aarch64_cas4_acq, .{ .name = "__aarch64_cas4_acq", .linkage = common.linkage, .visibility = common.visibility });
2082 @export(&__aarch64_swp4_acq, .{ .name = "__aarch64_swp4_acq", .linkage = common.linkage, .visibility = common.visibility });
2083 @export(&__aarch64_ldadd4_acq, .{ .name = "__aarch64_ldadd4_acq", .linkage = common.linkage, .visibility = common.visibility });
2084 @export(&__aarch64_ldclr4_acq, .{ .name = "__aarch64_ldclr4_acq", .linkage = common.linkage, .visibility = common.visibility });
2085 @export(&__aarch64_ldeor4_acq, .{ .name = "__aarch64_ldeor4_acq", .linkage = common.linkage, .visibility = common.visibility });
2086 @export(&__aarch64_ldset4_acq, .{ .name = "__aarch64_ldset4_acq", .linkage = common.linkage, .visibility = common.visibility });
2087 @export(&__aarch64_cas4_rel, .{ .name = "__aarch64_cas4_rel", .linkage = common.linkage, .visibility = common.visibility });
2088 @export(&__aarch64_swp4_rel, .{ .name = "__aarch64_swp4_rel", .linkage = common.linkage, .visibility = common.visibility });
2089 @export(&__aarch64_ldadd4_rel, .{ .name = "__aarch64_ldadd4_rel", .linkage = common.linkage, .visibility = common.visibility });
2090 @export(&__aarch64_ldclr4_rel, .{ .name = "__aarch64_ldclr4_rel", .linkage = common.linkage, .visibility = common.visibility });
2091 @export(&__aarch64_ldeor4_rel, .{ .name = "__aarch64_ldeor4_rel", .linkage = common.linkage, .visibility = common.visibility });
2092 @export(&__aarch64_ldset4_rel, .{ .name = "__aarch64_ldset4_rel", .linkage = common.linkage, .visibility = common.visibility });
2093 @export(&__aarch64_cas4_acq_rel, .{ .name = "__aarch64_cas4_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2094 @export(&__aarch64_swp4_acq_rel, .{ .name = "__aarch64_swp4_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2095 @export(&__aarch64_ldadd4_acq_rel, .{ .name = "__aarch64_ldadd4_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2096 @export(&__aarch64_ldclr4_acq_rel, .{ .name = "__aarch64_ldclr4_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2097 @export(&__aarch64_ldeor4_acq_rel, .{ .name = "__aarch64_ldeor4_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2098 @export(&__aarch64_ldset4_acq_rel, .{ .name = "__aarch64_ldset4_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2099 @export(&__aarch64_cas8_relax, .{ .name = "__aarch64_cas8_relax", .linkage = common.linkage, .visibility = common.visibility });
2100 @export(&__aarch64_swp8_relax, .{ .name = "__aarch64_swp8_relax", .linkage = common.linkage, .visibility = common.visibility });
2101 @export(&__aarch64_ldadd8_relax, .{ .name = "__aarch64_ldadd8_relax", .linkage = common.linkage, .visibility = common.visibility });
2102 @export(&__aarch64_ldclr8_relax, .{ .name = "__aarch64_ldclr8_relax", .linkage = common.linkage, .visibility = common.visibility });
2103 @export(&__aarch64_ldeor8_relax, .{ .name = "__aarch64_ldeor8_relax", .linkage = common.linkage, .visibility = common.visibility });
2104 @export(&__aarch64_ldset8_relax, .{ .name = "__aarch64_ldset8_relax", .linkage = common.linkage, .visibility = common.visibility });
2105 @export(&__aarch64_cas8_acq, .{ .name = "__aarch64_cas8_acq", .linkage = common.linkage, .visibility = common.visibility });
2106 @export(&__aarch64_swp8_acq, .{ .name = "__aarch64_swp8_acq", .linkage = common.linkage, .visibility = common.visibility });
2107 @export(&__aarch64_ldadd8_acq, .{ .name = "__aarch64_ldadd8_acq", .linkage = common.linkage, .visibility = common.visibility });
2108 @export(&__aarch64_ldclr8_acq, .{ .name = "__aarch64_ldclr8_acq", .linkage = common.linkage, .visibility = common.visibility });
2109 @export(&__aarch64_ldeor8_acq, .{ .name = "__aarch64_ldeor8_acq", .linkage = common.linkage, .visibility = common.visibility });
2110 @export(&__aarch64_ldset8_acq, .{ .name = "__aarch64_ldset8_acq", .linkage = common.linkage, .visibility = common.visibility });
2111 @export(&__aarch64_cas8_rel, .{ .name = "__aarch64_cas8_rel", .linkage = common.linkage, .visibility = common.visibility });
2112 @export(&__aarch64_swp8_rel, .{ .name = "__aarch64_swp8_rel", .linkage = common.linkage, .visibility = common.visibility });
2113 @export(&__aarch64_ldadd8_rel, .{ .name = "__aarch64_ldadd8_rel", .linkage = common.linkage, .visibility = common.visibility });
2114 @export(&__aarch64_ldclr8_rel, .{ .name = "__aarch64_ldclr8_rel", .linkage = common.linkage, .visibility = common.visibility });
2115 @export(&__aarch64_ldeor8_rel, .{ .name = "__aarch64_ldeor8_rel", .linkage = common.linkage, .visibility = common.visibility });
2116 @export(&__aarch64_ldset8_rel, .{ .name = "__aarch64_ldset8_rel", .linkage = common.linkage, .visibility = common.visibility });
2117 @export(&__aarch64_cas8_acq_rel, .{ .name = "__aarch64_cas8_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2118 @export(&__aarch64_swp8_acq_rel, .{ .name = "__aarch64_swp8_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2119 @export(&__aarch64_ldadd8_acq_rel, .{ .name = "__aarch64_ldadd8_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2120 @export(&__aarch64_ldclr8_acq_rel, .{ .name = "__aarch64_ldclr8_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2121 @export(&__aarch64_ldeor8_acq_rel, .{ .name = "__aarch64_ldeor8_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2122 @export(&__aarch64_ldset8_acq_rel, .{ .name = "__aarch64_ldset8_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2123 @export(&__aarch64_cas16_relax, .{ .name = "__aarch64_cas16_relax", .linkage = common.linkage, .visibility = common.visibility });
2124 @export(&__aarch64_cas16_acq, .{ .name = "__aarch64_cas16_acq", .linkage = common.linkage, .visibility = common.visibility });
2125 @export(&__aarch64_cas16_rel, .{ .name = "__aarch64_cas16_rel", .linkage = common.linkage, .visibility = common.visibility });
2126 @export(&__aarch64_cas16_acq_rel, .{ .name = "__aarch64_cas16_acq_rel", .linkage = common.linkage, .visibility = common.visibility });
2028 symbol(&__aarch64_cas1_relax, "__aarch64_cas1_relax");
2029 symbol(&__aarch64_swp1_relax, "__aarch64_swp1_relax");
2030 symbol(&__aarch64_ldadd1_relax, "__aarch64_ldadd1_relax");
2031 symbol(&__aarch64_ldclr1_relax, "__aarch64_ldclr1_relax");
2032 symbol(&__aarch64_ldeor1_relax, "__aarch64_ldeor1_relax");
2033 symbol(&__aarch64_ldset1_relax, "__aarch64_ldset1_relax");
2034 symbol(&__aarch64_cas1_acq, "__aarch64_cas1_acq");
2035 symbol(&__aarch64_swp1_acq, "__aarch64_swp1_acq");
2036 symbol(&__aarch64_ldadd1_acq, "__aarch64_ldadd1_acq");
2037 symbol(&__aarch64_ldclr1_acq, "__aarch64_ldclr1_acq");
2038 symbol(&__aarch64_ldeor1_acq, "__aarch64_ldeor1_acq");
2039 symbol(&__aarch64_ldset1_acq, "__aarch64_ldset1_acq");
2040 symbol(&__aarch64_cas1_rel, "__aarch64_cas1_rel");
2041 symbol(&__aarch64_swp1_rel, "__aarch64_swp1_rel");
2042 symbol(&__aarch64_ldadd1_rel, "__aarch64_ldadd1_rel");
2043 symbol(&__aarch64_ldclr1_rel, "__aarch64_ldclr1_rel");
2044 symbol(&__aarch64_ldeor1_rel, "__aarch64_ldeor1_rel");
2045 symbol(&__aarch64_ldset1_rel, "__aarch64_ldset1_rel");
2046 symbol(&__aarch64_cas1_acq_rel, "__aarch64_cas1_acq_rel");
2047 symbol(&__aarch64_swp1_acq_rel, "__aarch64_swp1_acq_rel");
2048 symbol(&__aarch64_ldadd1_acq_rel, "__aarch64_ldadd1_acq_rel");
2049 symbol(&__aarch64_ldclr1_acq_rel, "__aarch64_ldclr1_acq_rel");
2050 symbol(&__aarch64_ldeor1_acq_rel, "__aarch64_ldeor1_acq_rel");
2051 symbol(&__aarch64_ldset1_acq_rel, "__aarch64_ldset1_acq_rel");
2052 symbol(&__aarch64_cas2_relax, "__aarch64_cas2_relax");
2053 symbol(&__aarch64_swp2_relax, "__aarch64_swp2_relax");
2054 symbol(&__aarch64_ldadd2_relax, "__aarch64_ldadd2_relax");
2055 symbol(&__aarch64_ldclr2_relax, "__aarch64_ldclr2_relax");
2056 symbol(&__aarch64_ldeor2_relax, "__aarch64_ldeor2_relax");
2057 symbol(&__aarch64_ldset2_relax, "__aarch64_ldset2_relax");
2058 symbol(&__aarch64_cas2_acq, "__aarch64_cas2_acq");
2059 symbol(&__aarch64_swp2_acq, "__aarch64_swp2_acq");
2060 symbol(&__aarch64_ldadd2_acq, "__aarch64_ldadd2_acq");
2061 symbol(&__aarch64_ldclr2_acq, "__aarch64_ldclr2_acq");
2062 symbol(&__aarch64_ldeor2_acq, "__aarch64_ldeor2_acq");
2063 symbol(&__aarch64_ldset2_acq, "__aarch64_ldset2_acq");
2064 symbol(&__aarch64_cas2_rel, "__aarch64_cas2_rel");
2065 symbol(&__aarch64_swp2_rel, "__aarch64_swp2_rel");
2066 symbol(&__aarch64_ldadd2_rel, "__aarch64_ldadd2_rel");
2067 symbol(&__aarch64_ldclr2_rel, "__aarch64_ldclr2_rel");
2068 symbol(&__aarch64_ldeor2_rel, "__aarch64_ldeor2_rel");
2069 symbol(&__aarch64_ldset2_rel, "__aarch64_ldset2_rel");
2070 symbol(&__aarch64_cas2_acq_rel, "__aarch64_cas2_acq_rel");
2071 symbol(&__aarch64_swp2_acq_rel, "__aarch64_swp2_acq_rel");
2072 symbol(&__aarch64_ldadd2_acq_rel, "__aarch64_ldadd2_acq_rel");
2073 symbol(&__aarch64_ldclr2_acq_rel, "__aarch64_ldclr2_acq_rel");
2074 symbol(&__aarch64_ldeor2_acq_rel, "__aarch64_ldeor2_acq_rel");
2075 symbol(&__aarch64_ldset2_acq_rel, "__aarch64_ldset2_acq_rel");
2076 symbol(&__aarch64_cas4_relax, "__aarch64_cas4_relax");
2077 symbol(&__aarch64_swp4_relax, "__aarch64_swp4_relax");
2078 symbol(&__aarch64_ldadd4_relax, "__aarch64_ldadd4_relax");
2079 symbol(&__aarch64_ldclr4_relax, "__aarch64_ldclr4_relax");
2080 symbol(&__aarch64_ldeor4_relax, "__aarch64_ldeor4_relax");
2081 symbol(&__aarch64_ldset4_relax, "__aarch64_ldset4_relax");
2082 symbol(&__aarch64_cas4_acq, "__aarch64_cas4_acq");
2083 symbol(&__aarch64_swp4_acq, "__aarch64_swp4_acq");
2084 symbol(&__aarch64_ldadd4_acq, "__aarch64_ldadd4_acq");
2085 symbol(&__aarch64_ldclr4_acq, "__aarch64_ldclr4_acq");
2086 symbol(&__aarch64_ldeor4_acq, "__aarch64_ldeor4_acq");
2087 symbol(&__aarch64_ldset4_acq, "__aarch64_ldset4_acq");
2088 symbol(&__aarch64_cas4_rel, "__aarch64_cas4_rel");
2089 symbol(&__aarch64_swp4_rel, "__aarch64_swp4_rel");
2090 symbol(&__aarch64_ldadd4_rel, "__aarch64_ldadd4_rel");
2091 symbol(&__aarch64_ldclr4_rel, "__aarch64_ldclr4_rel");
2092 symbol(&__aarch64_ldeor4_rel, "__aarch64_ldeor4_rel");
2093 symbol(&__aarch64_ldset4_rel, "__aarch64_ldset4_rel");
2094 symbol(&__aarch64_cas4_acq_rel, "__aarch64_cas4_acq_rel");
2095 symbol(&__aarch64_swp4_acq_rel, "__aarch64_swp4_acq_rel");
2096 symbol(&__aarch64_ldadd4_acq_rel, "__aarch64_ldadd4_acq_rel");
2097 symbol(&__aarch64_ldclr4_acq_rel, "__aarch64_ldclr4_acq_rel");
2098 symbol(&__aarch64_ldeor4_acq_rel, "__aarch64_ldeor4_acq_rel");
2099 symbol(&__aarch64_ldset4_acq_rel, "__aarch64_ldset4_acq_rel");
2100 symbol(&__aarch64_cas8_relax, "__aarch64_cas8_relax");
2101 symbol(&__aarch64_swp8_relax, "__aarch64_swp8_relax");
2102 symbol(&__aarch64_ldadd8_relax, "__aarch64_ldadd8_relax");
2103 symbol(&__aarch64_ldclr8_relax, "__aarch64_ldclr8_relax");
2104 symbol(&__aarch64_ldeor8_relax, "__aarch64_ldeor8_relax");
2105 symbol(&__aarch64_ldset8_relax, "__aarch64_ldset8_relax");
2106 symbol(&__aarch64_cas8_acq, "__aarch64_cas8_acq");
2107 symbol(&__aarch64_swp8_acq, "__aarch64_swp8_acq");
2108 symbol(&__aarch64_ldadd8_acq, "__aarch64_ldadd8_acq");
2109 symbol(&__aarch64_ldclr8_acq, "__aarch64_ldclr8_acq");
2110 symbol(&__aarch64_ldeor8_acq, "__aarch64_ldeor8_acq");
2111 symbol(&__aarch64_ldset8_acq, "__aarch64_ldset8_acq");
2112 symbol(&__aarch64_cas8_rel, "__aarch64_cas8_rel");
2113 symbol(&__aarch64_swp8_rel, "__aarch64_swp8_rel");
2114 symbol(&__aarch64_ldadd8_rel, "__aarch64_ldadd8_rel");
2115 symbol(&__aarch64_ldclr8_rel, "__aarch64_ldclr8_rel");
2116 symbol(&__aarch64_ldeor8_rel, "__aarch64_ldeor8_rel");
2117 symbol(&__aarch64_ldset8_rel, "__aarch64_ldset8_rel");
2118 symbol(&__aarch64_cas8_acq_rel, "__aarch64_cas8_acq_rel");
2119 symbol(&__aarch64_swp8_acq_rel, "__aarch64_swp8_acq_rel");
2120 symbol(&__aarch64_ldadd8_acq_rel, "__aarch64_ldadd8_acq_rel");
2121 symbol(&__aarch64_ldclr8_acq_rel, "__aarch64_ldclr8_acq_rel");
2122 symbol(&__aarch64_ldeor8_acq_rel, "__aarch64_ldeor8_acq_rel");
2123 symbol(&__aarch64_ldset8_acq_rel, "__aarch64_ldset8_acq_rel");
2124 symbol(&__aarch64_cas16_relax, "__aarch64_cas16_relax");
2125 symbol(&__aarch64_cas16_acq, "__aarch64_cas16_acq");
2126 symbol(&__aarch64_cas16_rel, "__aarch64_cas16_rel");
2127 symbol(&__aarch64_cas16_acq_rel, "__aarch64_cas16_acq_rel");
21272128}
lib/compiler_rt/absvsi2.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const absv = @import("./absv.zig").absv;
34
45comptime {
5 @export(&__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__absvsi2, "__absvsi2");
67}
78
89pub fn __absvsi2(a: i32) callconv(.c) i32 {
lib/compiler_rt/adddf3.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const addf3 = @import("./addf3.zig").addf3;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_dadd, "__aeabi_dadd");
88 } else {
99 symbol(&__adddf3, "__adddf3");
lib/compiler_rt/addf3.zig+2-2
......@@ -1,7 +1,7 @@
11const std = @import("std");
22const math = std.math;
3const common = @import("./common.zig");
4const normalize = common.normalize;
3const compiler_rt = @import("../compiler_rt.zig");
4const normalize = compiler_rt.normalize;
55
66/// Ported from:
77///
lib/compiler_rt/addhf3.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const addf3 = @import("./addf3.zig").addf3;
34
45comptime {
5 @export(&__addhf3, .{ .name = "__addhf3", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__addhf3, "__addhf3");
67}
78
89fn __addhf3(a: f16, b: f16) callconv(.c) f16 {
lib/compiler_rt/addsf3.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const addf3 = @import("./addf3.zig").addf3;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_fadd, "__aeabi_fadd");
88 } else {
99 symbol(&__addsf3, "__addsf3");
lib/compiler_rt/addtf3.zig+7-6
......@@ -1,13 +1,14 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const addf3 = @import("./addf3.zig").addf3;
34
45comptime {
5 if (common.want_ppc_abi) {
6 @export(&__addtf3, .{ .name = "__addkf3", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 @export(&_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_ppc_abi) {
7 symbol(&__addtf3, "__addkf3");
8 } else if (compiler_rt.want_sparc_abi) {
9 symbol(&_Qp_add, "_Qp_add");
910 }
10 @export(&__addtf3, .{ .name = "__addtf3", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__addtf3, "__addtf3");
1112}
1213
1314pub fn __addtf3(a: f128, b: f128) callconv(.c) f128 {
lib/compiler_rt/addvsi3.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const testing = @import("std").testing;
34
45comptime {
5 @export(&__addvsi3, .{ .name = "__addvsi3", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__addvsi3, "__addvsi3");
67}
78
89pub fn __addvsi3(a: i32, b: i32) callconv(.c) i32 {
lib/compiler_rt/addxf3.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const addf3 = @import("./addf3.zig").addf3;
34
45comptime {
5 @export(&__addxf3, .{ .name = "__addxf3", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__addxf3, "__addxf3");
67}
78
89pub fn __addxf3(a: f80, b: f80) callconv(.c) f80 {
lib/compiler_rt/arm.zig+29-28
......@@ -4,49 +4,50 @@ const std = @import("std");
44const builtin = @import("builtin");
55const target = builtin.target;
66const arch = builtin.cpu.arch;
7const common = @import("common.zig");
7const compiler_rt = @import("../compiler_rt.zig");
8const symbol = compiler_rt.symbol;
89
910comptime {
1011 if (!builtin.is_test) {
1112 if (arch.isArm()) {
12 @export(&__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&__aeabi_unwind_cpp_pr0, "__aeabi_unwind_cpp_pr0");
14 symbol(&__aeabi_unwind_cpp_pr1, "__aeabi_unwind_cpp_pr1");
15 symbol(&__aeabi_unwind_cpp_pr2, "__aeabi_unwind_cpp_pr2");
1516
16 if (common.want_windows_arm_abi) {
17 @export(&__aeabi_ldivmod, .{ .name = "__rt_sdiv64", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__aeabi_uldivmod, .{ .name = "__rt_udiv64", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&__aeabi_idivmod, .{ .name = "__rt_sdiv", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&__aeabi_uidivmod, .{ .name = "__rt_udiv", .linkage = common.linkage, .visibility = common.visibility });
17 if (compiler_rt.want_windows_arm_abi) {
18 symbol(&__aeabi_ldivmod, "__rt_sdiv64");
19 symbol(&__aeabi_uldivmod, "__rt_udiv64");
20 symbol(&__aeabi_idivmod, "__rt_sdiv");
21 symbol(&__aeabi_uidivmod, "__rt_udiv");
2122 }
22 @export(&__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility });
23 symbol(&__aeabi_ldivmod, "__aeabi_ldivmod");
24 symbol(&__aeabi_uldivmod, "__aeabi_uldivmod");
25 symbol(&__aeabi_idivmod, "__aeabi_idivmod");
26 symbol(&__aeabi_uidivmod, "__aeabi_uidivmod");
2627
27 @export(&__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage, .visibility = common.visibility });
28 @export(&__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage, .visibility = common.visibility });
29 @export(&__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage, .visibility = common.visibility });
28 symbol(&__aeabi_memcpy, "__aeabi_memcpy");
29 symbol(&__aeabi_memcpy4, "__aeabi_memcpy4");
30 symbol(&__aeabi_memcpy8, "__aeabi_memcpy8");
3031
31 @export(&__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage, .visibility = common.visibility });
32 @export(&__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage, .visibility = common.visibility });
33 @export(&__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage, .visibility = common.visibility });
32 symbol(&__aeabi_memmove, "__aeabi_memmove");
33 symbol(&__aeabi_memmove4, "__aeabi_memmove4");
34 symbol(&__aeabi_memmove8, "__aeabi_memmove8");
3435
35 @export(&__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage, .visibility = common.visibility });
36 @export(&__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage, .visibility = common.visibility });
37 @export(&__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage, .visibility = common.visibility });
36 symbol(&__aeabi_memset, "__aeabi_memset");
37 symbol(&__aeabi_memset4, "__aeabi_memset4");
38 symbol(&__aeabi_memset8, "__aeabi_memset8");
3839
39 @export(&__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage, .visibility = common.visibility });
40 @export(&__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage, .visibility = common.visibility });
41 @export(&__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage, .visibility = common.visibility });
40 symbol(&__aeabi_memclr, "__aeabi_memclr");
41 symbol(&__aeabi_memclr4, "__aeabi_memclr4");
42 symbol(&__aeabi_memclr8, "__aeabi_memclr8");
4243
4344 if (builtin.os.tag == .linux or builtin.os.tag == .freebsd) {
44 @export(&__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility });
45 symbol(&__aeabi_read_tp, "__aeabi_read_tp");
4546 }
4647
4748 // floating-point helper functions (single+double-precision reverse subtraction, y – x), see subdf3.zig
48 @export(&__aeabi_frsub, .{ .name = "__aeabi_frsub", .linkage = common.linkage, .visibility = common.visibility });
49 @export(&__aeabi_drsub, .{ .name = "__aeabi_drsub", .linkage = common.linkage, .visibility = common.visibility });
49 symbol(&__aeabi_frsub, "__aeabi_frsub");
50 symbol(&__aeabi_drsub, "__aeabi_drsub");
5051 }
5152 }
5253}
lib/compiler_rt/atomics.zig+1-1
......@@ -4,7 +4,7 @@ const arch = cpu.arch;
44
55const std = @import("std");
66
7const common = @import("./common.zig");
7const compiler_rt = @import("../compiler_rt.zig");
88const symbol = @import("../compiler_rt.zig").symbol;
99
1010// This parameter is true iff the target architecture supports the bare minimum
lib/compiler_rt/aulldiv.zig+2-2
......@@ -1,10 +1,10 @@
11const builtin = @import("builtin");
22
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
44const symbol = @import("../compiler_rt.zig").symbol;
55
66comptime {
7 if (common.want_windows_x86_msvc_abi) {
7 if (compiler_rt.want_windows_x86_msvc_abi) {
88 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
99 symbol(&_alldiv, "\x01__alldiv");
1010 symbol(&_aulldiv, "\x01__aulldiv");
lib/compiler_rt/aullrem.zig+5-4
......@@ -3,13 +3,14 @@ const builtin = @import("builtin");
33const arch = builtin.cpu.arch;
44const os = builtin.os.tag;
55const abi = builtin.abi;
6const common = @import("common.zig");
6const compiler_rt = @import("../compiler_rt.zig");
7const symbol = compiler_rt.symbol;
78
89comptime {
9 if (common.want_windows_x86_msvc_abi) {
10 if (compiler_rt.want_windows_x86_msvc_abi) {
1011 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
11 @export(&_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility });
12 symbol(&_allrem, "\x01__allrem");
13 symbol(&_aullrem, "\x01__aullrem");
1314 }
1415}
1516
lib/compiler_rt/bcmp.zig deleted-30
......@@ -1,30 +0,0 @@
1const std = @import("std");
2const common = @import("./common.zig");
3
4comptime {
5 @export(&bcmp, .{ .name = "bcmp", .linkage = common.linkage, .visibility = common.visibility });
6}
7
8pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.c) c_int {
9 @setRuntimeSafety(false);
10
11 var index: usize = 0;
12 while (index != n) : (index += 1) {
13 if (vl[index] != vr[index]) {
14 return 1;
15 }
16 }
17
18 return 0;
19}
20
21test "bcmp" {
22 const base_arr = &[_]u8{ 1, 1, 1 };
23 const arr1 = &[_]u8{ 1, 1, 1 };
24 const arr2 = &[_]u8{ 1, 0, 1 };
25 const arr3 = &[_]u8{ 1, 2, 1 };
26
27 try std.testing.expect(bcmp(base_arr[0..], arr1[0..], base_arr.len) == 0);
28 try std.testing.expect(bcmp(base_arr[0..], arr2[0..], base_arr.len) != 0);
29 try std.testing.expect(bcmp(base_arr[0..], arr3[0..], base_arr.len) != 0);
30}
lib/compiler_rt/bitreverse.zig+5-4
......@@ -1,11 +1,12 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45
56comptime {
6 @export(&__bitreversesi2, .{ .name = "__bitreversesi2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__bitreversedi2, .{ .name = "__bitreversedi2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__bitreverseti2, .{ .name = "__bitreverseti2", .linkage = common.linkage, .visibility = common.visibility });
7 symbol(&__bitreversesi2, "__bitreversesi2");
8 symbol(&__bitreversedi2, "__bitreversedi2");
9 symbol(&__bitreverseti2, "__bitreverseti2");
910}
1011
1112inline fn bitreverseXi2(comptime T: type, a: T) T {
lib/compiler_rt/bswap.zig+5-4
......@@ -1,11 +1,12 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45
56comptime {
6 @export(&__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage, .visibility = common.visibility });
7 symbol(&__bswapsi2, "__bswapsi2");
8 symbol(&__bswapdi2, "__bswapdi2");
9 symbol(&__bswapti2, "__bswapti2");
910}
1011
1112// bswap - byteswap
lib/compiler_rt/clear_cache.zig+3-2
......@@ -2,7 +2,8 @@ const std = @import("std");
22const builtin = @import("builtin");
33const arch = builtin.cpu.arch;
44const os = builtin.os.tag;
5const common = @import("common.zig");
5const compiler_rt = @import("../compiler_rt.zig");
6const symbol = compiler_rt.symbol;
67
78// Ported from llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28
89
......@@ -188,7 +189,7 @@ fn clear_cache(start: usize, end: usize) callconv(.c) void {
188189}
189190
190191fn exportIt() void {
191 @export(&clear_cache, .{ .name = "__clear_cache", .linkage = common.linkage, .visibility = common.visibility });
192 symbol(&clear_cache, "__clear_cache");
192193}
193194
194195// MIPS-only
lib/compiler_rt/cmp.zig+8-7
......@@ -1,14 +1,15 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45
56comptime {
6 @export(&__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage, .visibility = common.visibility });
7 @export(&__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage, .visibility = common.visibility });
7 symbol(&__cmpsi2, "__cmpsi2");
8 symbol(&__cmpdi2, "__cmpdi2");
9 symbol(&__cmpti2, "__cmpti2");
10 symbol(&__ucmpsi2, "__ucmpsi2");
11 symbol(&__ucmpdi2, "__ucmpdi2");
12 symbol(&__ucmpti2, "__ucmpti2");
1213}
1314
1415// cmp - signed compare
lib/compiler_rt/cmpdf2.zig+2-2
......@@ -1,11 +1,11 @@
11///! The quoted behavior definitions are from
22///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
3const common = @import("./common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
44const comparef = @import("./comparef.zig");
55const symbol = @import("../compiler_rt.zig").symbol;
66
77comptime {
8 if (common.want_aeabi) {
8 if (compiler_rt.want_aeabi) {
99 symbol(&__aeabi_dcmpeq, "__aeabi_dcmpeq");
1010 symbol(&__aeabi_dcmplt, "__aeabi_dcmplt");
1111 symbol(&__aeabi_dcmple, "__aeabi_dcmple");
lib/compiler_rt/cmphf2.zig deleted-48
......@@ -1,48 +0,0 @@
1///! The quoted behavior definitions are from
2///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
3const common = @import("./common.zig");
4const comparef = @import("./comparef.zig");
5
6comptime {
7 @export(&__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__nehf2, .{ .name = "__nehf2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__lehf2, .{ .name = "__lehf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__lthf2, .{ .name = "__lthf2", .linkage = common.linkage, .visibility = common.visibility });
12}
13
14/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
15/// if a is greater than b, they return 1; and if a and b are equal they return 0.
16/// If either argument is NaN they return 1..."
17///
18/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`,
19/// and `__lthf2`.
20fn __cmphf2(a: f16, b: f16) callconv(.c) i32 {
21 return @intFromEnum(comparef.cmpf2(f16, comparef.LE, a, b));
22}
23
24/// "These functions return a value less than or equal to zero if neither argument is NaN,
25/// and a is less than or equal to b."
26pub fn __lehf2(a: f16, b: f16) callconv(.c) i32 {
27 return __cmphf2(a, b);
28}
29
30/// "These functions return zero if neither argument is NaN, and a and b are equal."
31/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined
32/// to have the same return value.
33pub fn __eqhf2(a: f16, b: f16) callconv(.c) i32 {
34 return __cmphf2(a, b);
35}
36
37/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
38/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined
39/// to have the same return value.
40pub fn __nehf2(a: f16, b: f16) callconv(.c) i32 {
41 return __cmphf2(a, b);
42}
43
44/// "These functions return a value less than zero if neither argument is NaN, and a
45/// is strictly less than b."
46pub fn __lthf2(a: f16, b: f16) callconv(.c) i32 {
47 return __cmphf2(a, b);
48}
lib/compiler_rt/cmpsf2.zig deleted-66
......@@ -1,66 +0,0 @@
1///! The quoted behavior definitions are from
2///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
3const common = @import("./common.zig");
4const comparef = @import("./comparef.zig");
5
6comptime {
7 if (common.want_aeabi) {
8 @export(&__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage, .visibility = common.visibility });
11 } else {
12 @export(&__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__nesf2, .{ .name = "__nesf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__lesf2, .{ .name = "__lesf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage, .visibility = common.visibility });
17 }
18}
19
20/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
21/// if a is greater than b, they return 1; and if a and b are equal they return 0.
22/// If either argument is NaN they return 1..."
23///
24/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`,
25/// and `__ltsf2`.
26fn __cmpsf2(a: f32, b: f32) callconv(.c) i32 {
27 return @intFromEnum(comparef.cmpf2(f32, comparef.LE, a, b));
28}
29
30/// "These functions return a value less than or equal to zero if neither argument is NaN,
31/// and a is less than or equal to b."
32pub fn __lesf2(a: f32, b: f32) callconv(.c) i32 {
33 return __cmpsf2(a, b);
34}
35
36/// "These functions return zero if neither argument is NaN, and a and b are equal."
37/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined
38/// to have the same return value.
39pub fn __eqsf2(a: f32, b: f32) callconv(.c) i32 {
40 return __cmpsf2(a, b);
41}
42
43/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
44/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined
45/// to have the same return value.
46pub fn __nesf2(a: f32, b: f32) callconv(.c) i32 {
47 return __cmpsf2(a, b);
48}
49
50/// "These functions return a value less than zero if neither argument is NaN, and a
51/// is strictly less than b."
52pub fn __ltsf2(a: f32, b: f32) callconv(.c) i32 {
53 return __cmpsf2(a, b);
54}
55
56fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
57 return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal);
58}
59
60fn __aeabi_fcmplt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
61 return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Less);
62}
63
64fn __aeabi_fcmple(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
65 return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater);
66}
lib/compiler_rt/cmptf2.zig+3-3
......@@ -1,16 +1,16 @@
11///! The quoted behavior definitions are from
22///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
3const common = @import("./common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
44const comparef = @import("./comparef.zig");
55const symbol = @import("../compiler_rt.zig").symbol;
66
77comptime {
8 if (common.want_ppc_abi) {
8 if (compiler_rt.want_ppc_abi) {
99 symbol(&__eqtf2, "__eqkf2");
1010 symbol(&__netf2, "__nekf2");
1111 symbol(&__lttf2, "__ltkf2");
1212 symbol(&__letf2, "__lekf2");
13 } else if (common.want_sparc_abi) {
13 } else if (compiler_rt.want_sparc_abi) {
1414 symbol(&_Qp_cmp, "_Qp_cmp");
1515 symbol(&_Qp_feq, "_Qp_feq");
1616 symbol(&_Qp_fne, "_Qp_fne");
lib/compiler_rt/cmpxf2.zig+7-6
......@@ -1,14 +1,15 @@
11///! The quoted behavior definitions are from
22///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
3const common = @import("./common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const comparef = @import("./comparef.zig");
56
67comptime {
7 @export(&__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__nexf2, .{ .name = "__nexf2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__lexf2, .{ .name = "__lexf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__eqxf2, "__eqxf2");
9 symbol(&__nexf2, "__nexf2");
10 symbol(&__lexf2, "__lexf2");
11 symbol(&__cmpxf2, "__cmpxf2");
12 symbol(&__ltxf2, "__ltxf2");
1213}
1314
1415/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
lib/compiler_rt/common.zig deleted-296
......@@ -1,296 +0,0 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const native_endian = builtin.cpu.arch.endian();
4const ofmt_c = builtin.object_format == .c;
5
6/// Deprecated, everything in common should move to compiler_rt.zig
7pub const linkage = @import("../compiler_rt.zig").linkage;
8
9/// Deprecated, everything in common should move to compiler_rt.zig
10pub const visibility = @import("../compiler_rt.zig").visibility;
11
12pub const PreferredLoadStoreElement = element: {
13 if (std.simd.suggestVectorLength(u8)) |vec_size| {
14 const Vec = @Vector(vec_size, u8);
15
16 if (@sizeOf(Vec) == vec_size and std.math.isPowerOfTwo(vec_size)) {
17 break :element Vec;
18 }
19 }
20 break :element usize;
21};
22
23pub const want_aeabi = switch (builtin.abi) {
24 .eabi,
25 .eabihf,
26 .musleabi,
27 .musleabihf,
28 .gnueabi,
29 .gnueabihf,
30 .android,
31 .androideabi,
32 => switch (builtin.cpu.arch) {
33 .arm, .armeb, .thumb, .thumbeb => true,
34 else => false,
35 },
36 else => false,
37};
38
39/// These functions are required on Windows on ARM. They are provided by MSVC libc, but in libc-less
40/// builds or when linking MinGW libc they are our responsibility.
41/// Temporarily used for thumb-uefi until https://github.com/ziglang/zig/issues/21630 is addressed.
42pub const want_windows_arm_abi = e: {
43 if (!builtin.cpu.arch.isArm()) break :e false;
44 switch (builtin.os.tag) {
45 .windows, .uefi => {},
46 else => break :e false,
47 }
48 // The ABI is needed, but it's only our reponsibility if libc won't provide it.
49 break :e builtin.abi.isGnu() or !builtin.link_libc;
50};
51
52/// These functions are required by on Windows on x86 on some ABIs. They are provided by MSVC libc,
53/// but in libc-less builds they are our responsibility.
54pub const want_windows_x86_msvc_abi = e: {
55 if (builtin.cpu.arch != .x86) break :e false;
56 if (builtin.os.tag != .windows) break :e false;
57 switch (builtin.abi) {
58 .none, .msvc, .itanium => {},
59 else => break :e false,
60 }
61 // The ABI is needed, but it's only our responsibility if libc won't provide it.
62 break :e !builtin.link_libc;
63};
64
65pub const want_ppc_abi = builtin.cpu.arch.isPowerPC();
66
67pub const want_float_exceptions = !builtin.cpu.arch.isWasm();
68
69// Libcalls that involve u128 on Windows x86-64 are expected by LLVM to use the
70// calling convention of @Vector(2, u64), rather than what's standard.
71pub const want_windows_v2u64_abi = builtin.os.tag == .windows and builtin.cpu.arch == .x86_64 and !ofmt_c;
72
73/// This governs whether to use these symbol names for f16/f32 conversions
74/// rather than the standard names:
75/// * __gnu_f2h_ieee
76/// * __gnu_h2f_ieee
77/// Known correct configurations:
78/// x86_64-freestanding-none => true
79/// x86_64-linux-none => true
80/// x86_64-linux-gnu => true
81/// x86_64-linux-musl => true
82/// x86_64-linux-eabi => true
83/// arm-linux-musleabihf => true
84/// arm-linux-gnueabihf => true
85/// arm-linux-eabihf => false
86/// wasm32-wasi-musl => false
87/// wasm32-freestanding-none => false
88/// x86_64-windows-gnu => true
89/// x86_64-windows-msvc => true
90/// any-macos-any => false
91pub const gnu_f16_abi = switch (builtin.cpu.arch) {
92 .wasm32,
93 .wasm64,
94 .riscv64,
95 .riscv64be,
96 .riscv32,
97 .riscv32be,
98 => false,
99
100 .x86, .x86_64 => true,
101
102 .arm, .armeb, .thumb, .thumbeb => switch (builtin.abi) {
103 .eabi, .eabihf => false,
104 else => true,
105 },
106
107 else => !builtin.os.tag.isDarwin(),
108};
109
110pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
111
112/// Deprecated, everything in common should move to compiler_rt.zig
113pub const test_safety = @import("../compiler_rt.zig").test_safety;
114
115/// This seems to mostly correspond to `clang::TargetInfo::HasFloat16`.
116pub fn F16T(comptime OtherType: type) type {
117 return switch (builtin.cpu.arch) {
118 .amdgcn,
119 .arm,
120 .armeb,
121 .thumb,
122 .thumbeb,
123 .aarch64,
124 .aarch64_be,
125 .hexagon,
126 .loongarch32,
127 .loongarch64,
128 .nvptx,
129 .nvptx64,
130 .riscv32,
131 .riscv32be,
132 .riscv64,
133 .riscv64be,
134 .s390x,
135 .spirv32,
136 .spirv64,
137 => f16,
138 .x86, .x86_64 => if (builtin.target.os.tag.isDarwin()) switch (OtherType) {
139 // Starting with LLVM 16, Darwin uses different abi for f16
140 // depending on the type of the other return/argument..???
141 f32, f64 => u16,
142 f80, f128 => f16,
143 else => unreachable,
144 } else f16,
145 else => u16,
146 };
147}
148
149pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
150 switch (Z) {
151 u16 => {
152 // 16x16 --> 32 bit multiply
153 const product = @as(u32, a) * @as(u32, b);
154 hi.* = @intCast(product >> 16);
155 lo.* = @truncate(product);
156 },
157 u32 => {
158 // 32x32 --> 64 bit multiply
159 const product = @as(u64, a) * @as(u64, b);
160 hi.* = @truncate(product >> 32);
161 lo.* = @truncate(product);
162 },
163 u64 => {
164 const S = struct {
165 fn loWord(x: u64) u64 {
166 return @as(u32, @truncate(x));
167 }
168 fn hiWord(x: u64) u64 {
169 return @as(u32, @truncate(x >> 32));
170 }
171 };
172 // 64x64 -> 128 wide multiply for platforms that don't have such an operation;
173 // many 64-bit platforms have this operation, but they tend to have hardware
174 // floating-point, so we don't bother with a special case for them here.
175 // Each of the component 32x32 -> 64 products
176 const plolo: u64 = S.loWord(a) * S.loWord(b);
177 const plohi: u64 = S.loWord(a) * S.hiWord(b);
178 const philo: u64 = S.hiWord(a) * S.loWord(b);
179 const phihi: u64 = S.hiWord(a) * S.hiWord(b);
180 // Sum terms that contribute to lo in a way that allows us to get the carry
181 const r0: u64 = S.loWord(plolo);
182 const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo);
183 lo.* = r0 +% (r1 << 32);
184 // Sum terms contributing to hi with the carry from lo
185 hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi;
186 },
187 u128 => {
188 const Word_LoMask: u64 = 0x00000000ffffffff;
189 const Word_HiMask: u64 = 0xffffffff00000000;
190 const Word_FullMask: u64 = 0xffffffffffffffff;
191 const S = struct {
192 fn Word_1(x: u128) u64 {
193 return @as(u32, @truncate(x >> 96));
194 }
195 fn Word_2(x: u128) u64 {
196 return @as(u32, @truncate(x >> 64));
197 }
198 fn Word_3(x: u128) u64 {
199 return @as(u32, @truncate(x >> 32));
200 }
201 fn Word_4(x: u128) u64 {
202 return @as(u32, @truncate(x));
203 }
204 };
205 // 128x128 -> 256 wide multiply for platforms that don't have such an operation;
206 // many 64-bit platforms have this operation, but they tend to have hardware
207 // floating-point, so we don't bother with a special case for them here.
208
209 const product11: u64 = S.Word_1(a) * S.Word_1(b);
210 const product12: u64 = S.Word_1(a) * S.Word_2(b);
211 const product13: u64 = S.Word_1(a) * S.Word_3(b);
212 const product14: u64 = S.Word_1(a) * S.Word_4(b);
213 const product21: u64 = S.Word_2(a) * S.Word_1(b);
214 const product22: u64 = S.Word_2(a) * S.Word_2(b);
215 const product23: u64 = S.Word_2(a) * S.Word_3(b);
216 const product24: u64 = S.Word_2(a) * S.Word_4(b);
217 const product31: u64 = S.Word_3(a) * S.Word_1(b);
218 const product32: u64 = S.Word_3(a) * S.Word_2(b);
219 const product33: u64 = S.Word_3(a) * S.Word_3(b);
220 const product34: u64 = S.Word_3(a) * S.Word_4(b);
221 const product41: u64 = S.Word_4(a) * S.Word_1(b);
222 const product42: u64 = S.Word_4(a) * S.Word_2(b);
223 const product43: u64 = S.Word_4(a) * S.Word_3(b);
224 const product44: u64 = S.Word_4(a) * S.Word_4(b);
225
226 const sum0: u128 = @as(u128, product44);
227 const sum1: u128 = @as(u128, product34) +%
228 @as(u128, product43);
229 const sum2: u128 = @as(u128, product24) +%
230 @as(u128, product33) +%
231 @as(u128, product42);
232 const sum3: u128 = @as(u128, product14) +%
233 @as(u128, product23) +%
234 @as(u128, product32) +%
235 @as(u128, product41);
236 const sum4: u128 = @as(u128, product13) +%
237 @as(u128, product22) +%
238 @as(u128, product31);
239 const sum5: u128 = @as(u128, product12) +%
240 @as(u128, product21);
241 const sum6: u128 = @as(u128, product11);
242
243 const r0: u128 = (sum0 & Word_FullMask) +%
244 ((sum1 & Word_LoMask) << 32);
245 const r1: u128 = (sum0 >> 64) +%
246 ((sum1 >> 32) & Word_FullMask) +%
247 (sum2 & Word_FullMask) +%
248 ((sum3 << 32) & Word_HiMask);
249
250 lo.* = r0 +% (r1 << 64);
251 hi.* = (r1 >> 64) +%
252 (sum1 >> 96) +%
253 (sum2 >> 64) +%
254 (sum3 >> 32) +%
255 sum4 +%
256 (sum5 << 32) +%
257 (sum6 << 64);
258 },
259 else => @compileError("unsupported"),
260 }
261}
262
263pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).float.bits)) i32 {
264 const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
265 const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T);
266
267 const shift = @clz(significand.*) - @clz(integerBit);
268 significand.* <<= @as(std.math.Log2Int(Z), @intCast(shift));
269 return @as(i32, 1) - shift;
270}
271
272pub inline fn fneg(a: anytype) @TypeOf(a) {
273 const F = @TypeOf(a);
274 const bits = @typeInfo(F).float.bits;
275 const U = @Int(.unsigned, bits);
276 const sign_bit_mask = @as(U, 1) << (bits - 1);
277 const negated = @as(U, @bitCast(a)) ^ sign_bit_mask;
278 return @bitCast(negated);
279}
280
281/// Allows to access underlying bits as two equally sized lower and higher
282/// signed or unsigned integers.
283pub fn HalveInt(comptime T: type, comptime signed_half: bool) type {
284 return extern union {
285 pub const bits = @divExact(@typeInfo(T).int.bits, 2);
286 pub const HalfTU = std.meta.Int(.unsigned, bits);
287 pub const HalfTS = std.meta.Int(.signed, bits);
288 pub const HalfT = if (signed_half) HalfTS else HalfTU;
289
290 all: T,
291 s: if (native_endian == .little)
292 extern struct { low: HalfT, high: HalfT }
293 else
294 extern struct { high: HalfT, low: HalfT },
295 };
296}
lib/compiler_rt/comparef.zig+144
......@@ -1,5 +1,149 @@
11const std = @import("std");
22
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
5
6comptime {
7 if (compiler_rt.want_aeabi) {
8 symbol(&__aeabi_fcmpun, "__aeabi_fcmpun");
9 } else {
10 symbol(&__unordsf2, "__unordsf2");
11 }
12
13 symbol(&__unordxf2, "__unordxf2");
14
15 symbol(&__eqhf2, "__eqhf2");
16 symbol(&__nehf2, "__nehf2");
17 symbol(&__lehf2, "__lehf2");
18 symbol(&__cmphf2, "__cmphf2");
19 symbol(&__lthf2, "__lthf2");
20
21 if (compiler_rt.want_aeabi) {
22 symbol(&__aeabi_fcmpeq, "__aeabi_fcmpeq");
23 symbol(&__aeabi_fcmplt, "__aeabi_fcmplt");
24 symbol(&__aeabi_fcmple, "__aeabi_fcmple");
25 } else {
26 symbol(&__eqsf2, "__eqsf2");
27 symbol(&__nesf2, "__nesf2");
28 symbol(&__lesf2, "__lesf2");
29 symbol(&__cmpsf2, "__cmpsf2");
30 symbol(&__ltsf2, "__ltsf2");
31 }
32
33 if (compiler_rt.want_ppc_abi) {
34 symbol(&__unordtf2, "__unordkf2");
35 } else if (compiler_rt.want_sparc_abi) {
36 // These exports are handled in cmptf2.zig because unordered comparisons
37 // are based on calling _Qp_cmp.
38 }
39 symbol(&__unordtf2, "__unordtf2");
40 symbol(&__unordhf2, "__unordhf2");
41}
42
43pub fn __unordhf2(a: f16, b: f16) callconv(.c) i32 {
44 return unordcmp(f16, a, b);
45}
46
47pub fn __unordtf2(a: f128, b: f128) callconv(.c) i32 {
48 return unordcmp(f128, a, b);
49}
50
51/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
52/// if a is greater than b, they return 1; and if a and b are equal they return 0.
53/// If either argument is NaN they return 1..."
54///
55/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`,
56/// and `__ltsf2`.
57fn __cmpsf2(a: f32, b: f32) callconv(.c) i32 {
58 return @intFromEnum(cmpf2(f32, LE, a, b));
59}
60
61/// "These functions return a value less than or equal to zero if neither argument is NaN,
62/// and a is less than or equal to b."
63pub fn __lesf2(a: f32, b: f32) callconv(.c) i32 {
64 return __cmpsf2(a, b);
65}
66
67/// "These functions return zero if neither argument is NaN, and a and b are equal."
68/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined
69/// to have the same return value.
70pub fn __eqsf2(a: f32, b: f32) callconv(.c) i32 {
71 return __cmpsf2(a, b);
72}
73
74/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
75/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined
76/// to have the same return value.
77pub fn __nesf2(a: f32, b: f32) callconv(.c) i32 {
78 return __cmpsf2(a, b);
79}
80
81/// "These functions return a value less than zero if neither argument is NaN, and a
82/// is strictly less than b."
83pub fn __ltsf2(a: f32, b: f32) callconv(.c) i32 {
84 return __cmpsf2(a, b);
85}
86
87fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
88 return @intFromBool(cmpf2(f32, LE, a, b) == .Equal);
89}
90
91fn __aeabi_fcmplt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
92 return @intFromBool(cmpf2(f32, LE, a, b) == .Less);
93}
94
95fn __aeabi_fcmple(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
96 return @intFromBool(cmpf2(f32, LE, a, b) != .Greater);
97}
98
99/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
100/// if a is greater than b, they return 1; and if a and b are equal they return 0.
101/// If either argument is NaN they return 1..."
102///
103/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`,
104/// and `__lthf2`.
105fn __cmphf2(a: f16, b: f16) callconv(.c) i32 {
106 return @intFromEnum(cmpf2(f16, LE, a, b));
107}
108
109/// "These functions return a value less than or equal to zero if neither argument is NaN,
110/// and a is less than or equal to b."
111fn __lehf2(a: f16, b: f16) callconv(.c) i32 {
112 return __cmphf2(a, b);
113}
114
115/// "These functions return zero if neither argument is NaN, and a and b are equal."
116/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined
117/// to have the same return value.
118fn __eqhf2(a: f16, b: f16) callconv(.c) i32 {
119 return __cmphf2(a, b);
120}
121
122/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
123/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined
124/// to have the same return value.
125fn __nehf2(a: f16, b: f16) callconv(.c) i32 {
126 return __cmphf2(a, b);
127}
128
129/// "These functions return a value less than zero if neither argument is NaN, and a
130/// is strictly less than b."
131fn __lthf2(a: f16, b: f16) callconv(.c) i32 {
132 return __cmphf2(a, b);
133}
134
135fn __unordxf2(a: f80, b: f80) callconv(.c) i32 {
136 return unordcmp(f80, a, b);
137}
138
139pub fn __unordsf2(a: f32, b: f32) callconv(.c) i32 {
140 return unordcmp(f32, a, b);
141}
142
143fn __aeabi_fcmpun(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
144 return unordcmp(f32, a, b);
145}
146
3147pub const LE = enum(i32) {
4148 Less = -1,
5149 Equal = 0,
lib/compiler_rt/comparesf2_test.zig+5-5
......@@ -5,15 +5,15 @@
55const std = @import("std");
66const builtin = @import("builtin");
77
8const __eqsf2 = @import("./cmpsf2.zig").__eqsf2;
9const __lesf2 = @import("./cmpsf2.zig").__lesf2;
10const __ltsf2 = @import("./cmpsf2.zig").__ltsf2;
11const __nesf2 = @import("./cmpsf2.zig").__nesf2;
8const __eqsf2 = @import("./comparef.zig").__eqsf2;
9const __lesf2 = @import("./comparef.zig").__lesf2;
10const __ltsf2 = @import("./comparef.zig").__ltsf2;
11const __nesf2 = @import("./comparef.zig").__nesf2;
1212
1313const __gesf2 = @import("./gesf2.zig").__gesf2;
1414const __gtsf2 = @import("./gesf2.zig").__gtsf2;
1515
16const __unordsf2 = @import("./unordsf2.zig").__unordsf2;
16const __unordsf2 = @import("./comparef.zig").__unordsf2;
1717
1818const TestVector = struct {
1919 a: f32,
lib/compiler_rt/cos.zig+4-4
......@@ -3,7 +3,7 @@ const math = std.math;
33const mem = std.mem;
44const expect = std.testing.expect;
55
6const common = @import("common.zig");
6const compiler_rt = @import("../compiler_rt.zig");
77const symbol = @import("../compiler_rt.zig").symbol;
88const trig = @import("trig.zig");
99const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
......@@ -14,7 +14,7 @@ comptime {
1414 symbol(&cosf, "cosf");
1515 symbol(&cos, "cos");
1616 symbol(&__cosx, "__cosx");
17 if (common.want_ppc_abi) {
17 if (compiler_rt.want_ppc_abi) {
1818 symbol(&cosq, "cosf128");
1919 }
2020 symbol(&cosq, "cosq");
......@@ -40,7 +40,7 @@ pub fn cosf(x: f32) callconv(.c) f32 {
4040 if (ix <= 0x3f490fda) { // |x| ~<= pi/4
4141 if (ix < 0x39800000) { // |x| < 2**-12
4242 // raise inexact if x != 0
43 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
43 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
4444 return 1.0;
4545 }
4646 return trig.__cosdf(x);
......@@ -91,7 +91,7 @@ pub fn cos(x: f64) callconv(.c) f64 {
9191 if (ix <= 0x3fe921fb) {
9292 if (ix < 0x3e46a09e) { // |x| < 2**-27 * sqrt(2)
9393 // raise inexact if x!=0
94 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
94 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
9595 return 1.0;
9696 }
9797 return trig.__cos(x, 0);
lib/compiler_rt/divdf3.zig+4-4
......@@ -3,14 +3,14 @@
33//! https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/divdf3.c
44
55const std = @import("std");
6const common = @import("common.zig");
6const compiler_rt = @import("../compiler_rt.zig");
77const symbol = @import("../compiler_rt.zig").symbol;
88
9const normalize = common.normalize;
10const wideMultiply = common.wideMultiply;
9const normalize = compiler_rt.normalize;
10const wideMultiply = compiler_rt.wideMultiply;
1111
1212comptime {
13 if (common.want_aeabi) {
13 if (compiler_rt.want_aeabi) {
1414 symbol(&__aeabi_ddiv, "__aeabi_ddiv");
1515 } else {
1616 symbol(&__divdf3, "__divdf3");
lib/compiler_rt/divhc3.zig+3-2
......@@ -1,10 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const divc3 = @import("./divc3.zig");
34const Complex = @import("./mulc3.zig").Complex;
45
56comptime {
67 if (@import("builtin").zig_backend != .stage2_c) {
7 @export(&__divhc3, .{ .name = "__divhc3", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__divhc3, "__divhc3");
89 }
910}
1011
lib/compiler_rt/divmodei4.zig+3-3
......@@ -3,7 +3,7 @@ const endian = builtin.cpu.arch.endian();
33
44const std = @import("std");
55
6const common = @import("common.zig");
6const compiler_rt = @import("../compiler_rt.zig");
77const udivmod = @import("udivmodei4.zig").divmod;
88const symbol = @import("../compiler_rt.zig").symbol;
99
......@@ -36,7 +36,7 @@ fn divmod(q: ?[]u32, r: ?[]u32, u: []u32, v: []u32) !void {
3636}
3737
3838pub fn __divei4(q_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) void {
39 @setRuntimeSafety(common.test_safety);
39 @setRuntimeSafety(compiler_rt.test_safety);
4040 const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
4141 const q: []u32 = @ptrCast(@alignCast(q_p[0..byte_size]));
4242 const u: []u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
......@@ -45,7 +45,7 @@ pub fn __divei4(q_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) vo
4545}
4646
4747pub fn __modei4(r_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) void {
48 @setRuntimeSafety(common.test_safety);
48 @setRuntimeSafety(compiler_rt.test_safety);
4949 const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
5050 const r: []u32 = @ptrCast(@alignCast(r_p[0..byte_size]));
5151 const u: []u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
lib/compiler_rt/divsf3.zig+3-3
......@@ -4,12 +4,12 @@
44
55const std = @import("std");
66
7const common = @import("common.zig");
7const compiler_rt = @import("../compiler_rt.zig");
88const symbol = @import("../compiler_rt.zig").symbol;
9const normalize = common.normalize;
9const normalize = compiler_rt.normalize;
1010
1111comptime {
12 if (common.want_aeabi) {
12 if (compiler_rt.want_aeabi) {
1313 symbol(&__aeabi_fdiv, "__aeabi_fdiv");
1414 } else {
1515 symbol(&__divsf3, "__divsf3");
lib/compiler_rt/divtc3.zig+2-2
......@@ -1,11 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const divc3 = @import("./divc3.zig");
33const Complex = @import("./mulc3.zig").Complex;
44const symbol = @import("../compiler_rt.zig").symbol;
55
66comptime {
77 if (@import("builtin").zig_backend != .stage2_c) {
8 if (common.want_ppc_abi)
8 if (compiler_rt.want_ppc_abi)
99 symbol(&__divtc3, "__divkc3");
1010 symbol(&__divtc3, "__divtc3");
1111 }
lib/compiler_rt/divtf3.zig+9-8
......@@ -1,17 +1,18 @@
11const std = @import("std");
22const builtin = @import("builtin");
33
4const common = @import("common.zig");
5const normalize = common.normalize;
6const wideMultiply = common.wideMultiply;
4const compiler_rt = @import("../compiler_rt.zig");
5const symbol = compiler_rt.symbol;
6const normalize = compiler_rt.normalize;
7const wideMultiply = compiler_rt.wideMultiply;
78
89comptime {
9 if (common.want_ppc_abi) {
10 @export(&__divtf3, .{ .name = "__divkf3", .linkage = common.linkage, .visibility = common.visibility });
11 } else if (common.want_sparc_abi) {
12 @export(&_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage, .visibility = common.visibility });
10 if (compiler_rt.want_ppc_abi) {
11 symbol(&__divtf3, "__divkf3");
12 } else if (compiler_rt.want_sparc_abi) {
13 symbol(&_Qp_div, "_Qp_div");
1314 }
14 @export(&__divtf3, .{ .name = "__divtf3", .linkage = common.linkage, .visibility = common.visibility });
15 symbol(&__divtf3, "__divtf3");
1516}
1617
1718pub fn __divtf3(a: f128, b: f128) callconv(.c) f128 {
lib/compiler_rt/divti3.zig deleted-39
......@@ -1,39 +0,0 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const udivmod = @import("udivmod.zig").udivmod;
4const arch = builtin.cpu.arch;
5const common = @import("common.zig");
6
7comptime {
8 if (common.want_windows_v2u64_abi) {
9 @export(&__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });
10 } else {
11 @export(&__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });
12 }
13}
14
15pub fn __divti3(a: i128, b: i128) callconv(.c) i128 {
16 return div(a, b);
17}
18
19const v128 = @Vector(2, u64);
20
21fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.c) v128 {
22 return @bitCast(div(@bitCast(a), @bitCast(b)));
23}
24
25inline fn div(a: i128, b: i128) i128 {
26 const s_a = a >> (128 - 1);
27 const s_b = b >> (128 - 1);
28
29 const an = (a ^ s_a) -% s_a;
30 const bn = (b ^ s_b) -% s_b;
31
32 const r = udivmod(u128, @bitCast(an), @bitCast(bn), null);
33 const s = s_a ^ s_b;
34 return (@as(i128, @bitCast(r)) ^ s) -% s;
35}
36
37test {
38 _ = @import("divti3_test.zig");
39}
lib/compiler_rt/divti3_test.zig+1-1
......@@ -1,4 +1,4 @@
1const __divti3 = @import("divti3.zig").__divti3;
1const __divti3 = @import("udivmod.zig").__divti3;
22const testing = @import("std").testing;
33
44fn test__divti3(a: i128, b: i128, expected: i128) !void {
lib/compiler_rt/divxf3.zig+5-4
......@@ -2,12 +2,13 @@ const std = @import("std");
22const builtin = @import("builtin");
33const arch = builtin.cpu.arch;
44
5const common = @import("common.zig");
6const normalize = common.normalize;
7const wideMultiply = common.wideMultiply;
5const compiler_rt = @import("../compiler_rt.zig");
6const symbol = compiler_rt.symbol;
7const normalize = compiler_rt.normalize;
8const wideMultiply = compiler_rt.wideMultiply;
89
910comptime {
10 @export(&__divxf3, .{ .name = "__divxf3", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__divxf3, "__divxf3");
1112}
1213
1314pub fn __divxf3(a: f80, b: f80) callconv(.c) f80 {
lib/compiler_rt/emutls.zig+3-2
......@@ -5,7 +5,8 @@
55
66const std = @import("std");
77const builtin = @import("builtin");
8const common = @import("common.zig");
8const compiler_rt = @import("../compiler_rt.zig");
9const symbol = compiler_rt.symbol;
910
1011const abort = std.process.abort;
1112const assert = std.debug.assert;
......@@ -17,7 +18,7 @@ const gcc_word = usize;
1718
1819comptime {
1920 if (builtin.link_libc and (builtin.abi.isAndroid() or builtin.abi.isOpenHarmony() or builtin.os.tag == .openbsd)) {
20 @export(&__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage, .visibility = common.visibility });
21 symbol(&__emutls_get_address, "__emutls_get_address");
2122 }
2223}
2324
lib/compiler_rt/exp.zig+7-7
......@@ -13,7 +13,7 @@ const mem = std.mem;
1313const expect = std.testing.expect;
1414const expectEqual = std.testing.expectEqual;
1515
16const common = @import("common.zig");
16const compiler_rt = @import("../compiler_rt.zig");
1717const symbol = @import("../compiler_rt.zig").symbol;
1818
1919comptime {
......@@ -21,7 +21,7 @@ comptime {
2121 symbol(&expf, "expf");
2222 symbol(&exp, "exp");
2323 symbol(&__expx, "__expx");
24 if (common.want_ppc_abi) {
24 if (compiler_rt.want_ppc_abi) {
2525 symbol(&expq, "expf128");
2626 }
2727 symbol(&expq, "expq");
......@@ -61,7 +61,7 @@ pub fn expf(x_: f32) callconv(.c) f32 {
6161 return x * 0x1.0p127;
6262 }
6363 if (sign != 0) {
64 if (common.want_float_exceptions) mem.doNotOptimizeAway(-0x1.0p-149 / x); // overflow
64 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(-0x1.0p-149 / x); // overflow
6565 // x <= -103.972084
6666 if (hx >= 0x42CFF1B5) {
6767 return 0;
......@@ -93,7 +93,7 @@ pub fn expf(x_: f32) callconv(.c) f32 {
9393 hi = x;
9494 lo = 0;
9595 } else {
96 if (common.want_float_exceptions) mem.doNotOptimizeAway(0x1.0p127 + x); // inexact
96 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(0x1.0p127 + x); // inexact
9797 return 1 + x;
9898 }
9999
......@@ -137,11 +137,11 @@ pub fn exp(x_: f64) callconv(.c) f64 {
137137 }
138138 if (x > 709.782712893383973096) {
139139 // overflow if x != inf
140 return if (common.want_float_exceptions) x * 0x1p1023 else std.math.inf(f64);
140 return if (compiler_rt.want_float_exceptions) x * 0x1p1023 else std.math.inf(f64);
141141 }
142142 if (x < -708.39641853226410622) {
143143 // underflow if x != -inf
144 if (common.want_float_exceptions) mem.doNotOptimizeAway(-0x0.0000000000001p-1022 / x);
144 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(-0x0.0000000000001p-1022 / x);
145145 if (x < -745.13321910194110842) {
146146 return 0;
147147 }
......@@ -174,7 +174,7 @@ pub fn exp(x_: f64) callconv(.c) f64 {
174174 lo = 0;
175175 } else {
176176 // inexact if x != 0
177 if (common.want_float_exceptions) mem.doNotOptimizeAway(0x1.0p1023 + x);
177 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(0x1.0p1023 + x);
178178 return 1 + x;
179179 }
180180
lib/compiler_rt/exp2.zig+13-12
......@@ -11,18 +11,19 @@ const math = std.math;
1111const mem = std.mem;
1212const expect = std.testing.expect;
1313const expectEqual = std.testing.expectEqual;
14const common = @import("common.zig");
14const compiler_rt = @import("../compiler_rt.zig");
15const symbol = compiler_rt.symbol;
1516
1617comptime {
17 @export(&__exp2h, .{ .name = "__exp2h", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&exp2f, .{ .name = "exp2f", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&exp2, .{ .name = "exp2", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&__exp2x, .{ .name = "__exp2x", .linkage = common.linkage, .visibility = common.visibility });
21 if (common.want_ppc_abi) {
22 @export(&exp2q, .{ .name = "exp2f128", .linkage = common.linkage, .visibility = common.visibility });
18 symbol(&__exp2h, "__exp2h");
19 symbol(&exp2f, "exp2f");
20 symbol(&exp2, "exp2");
21 symbol(&__exp2x, "__exp2x");
22 if (compiler_rt.want_ppc_abi) {
23 symbol(&exp2q, "exp2f128");
2324 }
24 @export(&exp2q, .{ .name = "exp2q", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&exp2l, .{ .name = "exp2l", .linkage = common.linkage, .visibility = common.visibility });
25 symbol(&exp2q, "exp2q");
26 symbol(&exp2l, "exp2l");
2627}
2728
2829pub fn __exp2h(x: f16) callconv(.c) f16 {
......@@ -54,7 +55,7 @@ pub fn exp2f(x: f32) callconv(.c) f32 {
5455 // x < -126
5556 if (u >= 0x80000000) {
5657 if (u >= 0xC3160000 or u & 0x000FFFF != 0) {
57 if (common.want_float_exceptions) mem.doNotOptimizeAway(-0x1.0p-149 / x);
58 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(-0x1.0p-149 / x);
5859 }
5960 // x <= -150
6061 if (u >= 0xC3160000) {
......@@ -108,7 +109,7 @@ pub fn exp2(x: f64) callconv(.c) f64 {
108109 if (ix >= 0x408FF000) {
109110 // x >= 1024 or nan
110111 if (ix >= 0x40900000 and ux >> 63 == 0) {
111 return if (common.want_float_exceptions) x * 0x1p1023 else std.math.inf(f64);
112 return if (compiler_rt.want_float_exceptions) x * 0x1p1023 else std.math.inf(f64);
112113 }
113114 // -inf or -nan
114115 if (ix >= 0x7FF00000) {
......@@ -118,7 +119,7 @@ pub fn exp2(x: f64) callconv(.c) f64 {
118119 if (ux >> 63 != 0) {
119120 // underflow
120121 if (x <= -1075 or x - 0x1.0p52 + 0x1.0p52 != x) {
121 if (common.want_float_exceptions) mem.doNotOptimizeAway(@as(f32, @floatCast(-0x1.0p-149 / x)));
122 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(@as(f32, @floatCast(-0x1.0p-149 / x)));
122123 }
123124 if (x <= -1075) {
124125 return 0;
lib/compiler_rt/extenddftf2.zig+3-3
......@@ -1,11 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const extendf = @import("./extendf.zig").extendf;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_ppc_abi) {
6 if (compiler_rt.want_ppc_abi) {
77 symbol(&__extenddftf2, "__extenddfkf2");
8 } else if (common.want_sparc_abi) {
8 } else if (compiler_rt.want_sparc_abi) {
99 symbol(&_Qp_dtoq, "_Qp_dtoq");
1010 }
1111 symbol(&__extenddftf2, "__extenddftf2");
lib/compiler_rt/extenddfxf2.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const extend_f80 = @import("./extendf.zig").extend_f80;
34
45comptime {
5 @export(&__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__extenddfxf2, "__extenddfxf2");
67}
78
89pub fn __extenddfxf2(a: f64) callconv(.c) f80 {
lib/compiler_rt/extendf_test.zig+4-2
......@@ -1,12 +1,14 @@
1const builtin = @import("builtin");
2
13const std = @import("std");
24const math = std.math;
3const builtin = @import("builtin");
5
46const __extendhfsf2 = @import("extendhfsf2.zig").__extendhfsf2;
57const __extendhftf2 = @import("extendhftf2.zig").__extendhftf2;
68const __extendsftf2 = @import("extendsftf2.zig").__extendsftf2;
79const __extenddftf2 = @import("extenddftf2.zig").__extenddftf2;
810const __extenddfxf2 = @import("extenddfxf2.zig").__extenddfxf2;
9const F16T = @import("./common.zig").F16T;
11const F16T = @import("../compiler_rt.zig").F16T;
1012
1113fn test__extenddfxf2(a: f64, expected: u80) !void {
1214 const x = __extenddfxf2(a);
lib/compiler_rt/extendhfdf2.zig+2-2
......@@ -1,4 +1,4 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const extendf = @import("./extendf.zig").extendf;
44
......@@ -6,6 +6,6 @@ comptime {
66 symbol(&__extendhfdf2, "__extendhfdf2");
77}
88
9pub fn __extendhfdf2(a: common.F16T(f64)) callconv(.c) f64 {
9pub fn __extendhfdf2(a: compiler_rt.F16T(f64)) callconv(.c) f64 {
1010 return extendf(f64, f16, @as(u16, @bitCast(a)));
1111}
lib/compiler_rt/extendhfsf2.zig+5-5
......@@ -1,21 +1,21 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const extendf = @import("./extendf.zig").extendf;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.gnu_f16_abi) {
6 if (compiler_rt.gnu_f16_abi) {
77 symbol(&__gnu_h2f_ieee, "__gnu_h2f_ieee");
8 } else if (common.want_aeabi) {
8 } else if (compiler_rt.want_aeabi) {
99 symbol(&__aeabi_h2f, "__aeabi_h2f");
1010 }
1111 symbol(&__extendhfsf2, "__extendhfsf2");
1212}
1313
14pub fn __extendhfsf2(a: common.F16T(f32)) callconv(.c) f32 {
14pub fn __extendhfsf2(a: compiler_rt.F16T(f32)) callconv(.c) f32 {
1515 return extendf(f32, f16, @as(u16, @bitCast(a)));
1616}
1717
18fn __gnu_h2f_ieee(a: common.F16T(f32)) callconv(.c) f32 {
18fn __gnu_h2f_ieee(a: compiler_rt.F16T(f32)) callconv(.c) f32 {
1919 return extendf(f32, f16, @as(u16, @bitCast(a)));
2020}
2121
lib/compiler_rt/extendhftf2.zig+4-3
......@@ -1,10 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const extendf = @import("./extendf.zig").extendf;
34
45comptime {
5 @export(&__extendhftf2, .{ .name = "__extendhftf2", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__extendhftf2, "__extendhftf2");
67}
78
8pub fn __extendhftf2(a: common.F16T(f128)) callconv(.c) f128 {
9pub fn __extendhftf2(a: compiler_rt.F16T(f128)) callconv(.c) f128 {
910 return extendf(f128, f16, @as(u16, @bitCast(a)));
1011}
lib/compiler_rt/extendhfxf2.zig+4-3
......@@ -1,10 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const extend_f80 = @import("./extendf.zig").extend_f80;
34
45comptime {
5 @export(&__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__extendhfxf2, "__extendhfxf2");
67}
78
8fn __extendhfxf2(a: common.F16T(f80)) callconv(.c) f80 {
9fn __extendhfxf2(a: compiler_rt.F16T(f80)) callconv(.c) f80 {
910 return extend_f80(f16, @as(u16, @bitCast(a)));
1011}
lib/compiler_rt/extendsfdf2.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const extendf = @import("./extendf.zig").extendf;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_f2d, "__aeabi_f2d");
78 } else {
8 @export(&__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__extendsfdf2, "__extendsfdf2");
910 }
1011}
1112
lib/compiler_rt/extendsftf2.zig+7-6
......@@ -1,13 +1,14 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const extendf = @import("./extendf.zig").extendf;
34
45comptime {
5 if (common.want_ppc_abi) {
6 @export(&__extendsftf2, .{ .name = "__extendsfkf2", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 @export(&_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_ppc_abi) {
7 symbol(&__extendsftf2, "__extendsfkf2");
8 } else if (compiler_rt.want_sparc_abi) {
9 symbol(&_Qp_stoq, "_Qp_stoq");
910 }
10 @export(&__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__extendsftf2, "__extendsftf2");
1112}
1213
1314pub fn __extendsftf2(a: f32) callconv(.c) f128 {
lib/compiler_rt/fabs.zig+10-9
......@@ -1,18 +1,19 @@
11const std = @import("std");
22const builtin = @import("builtin");
33const arch = builtin.cpu.arch;
4const common = @import("common.zig");
4const compiler_rt = @import("../compiler_rt.zig");
5const symbol = compiler_rt.symbol;
56
67comptime {
7 @export(&__fabsh, .{ .name = "__fabsh", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&fabsf, .{ .name = "fabsf", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&fabs, .{ .name = "fabs", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__fabsx, .{ .name = "__fabsx", .linkage = common.linkage, .visibility = common.visibility });
11 if (common.want_ppc_abi) {
12 @export(&fabsq, .{ .name = "fabsf128", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__fabsh, "__fabsh");
9 symbol(&fabsf, "fabsf");
10 symbol(&fabs, "fabs");
11 symbol(&__fabsx, "__fabsx");
12 if (compiler_rt.want_ppc_abi) {
13 symbol(&fabsq, "fabsf128");
1314 }
14 @export(&fabsq, .{ .name = "fabsq", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&fabsl, .{ .name = "fabsl", .linkage = common.linkage, .visibility = common.visibility });
15 symbol(&fabsq, "fabsq");
16 symbol(&fabsl, "fabsl");
1617}
1718
1819pub fn __fabsh(a: f16) callconv(.c) f16 {
lib/compiler_rt/fixdfdi.zig+7-6
......@@ -1,15 +1,16 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const intFromFloat = @import("./int_from_float.zig").intFromFloat;
45
56comptime {
6 if (common.want_aeabi) {
7 @export(&__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_aeabi) {
8 symbol(&__aeabi_d2lz, "__aeabi_d2lz");
89 } else {
9 if (common.want_windows_arm_abi) {
10 @export(&__fixdfdi, .{ .name = "__dtoi64", .linkage = common.linkage, .visibility = common.visibility });
10 if (compiler_rt.want_windows_arm_abi) {
11 symbol(&__fixdfdi, "__dtoi64");
1112 }
12 @export(&__fixdfdi, .{ .name = "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&__fixdfdi, "__fixdfdi");
1314 }
1415}
1516
lib/compiler_rt/fixdfei.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat;
56
67comptime {
7 @export(&__fixdfei, .{ .name = "__fixdfei", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__fixdfei, "__fixdfei");
89}
910
1011pub fn __fixdfei(r: [*]u8, bits: usize, a: f64) callconv(.c) void {
lib/compiler_rt/fixdfsi.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_d2iz, "__aeabi_d2iz");
88 } else {
99 symbol(&__fixdfsi, "__fixdfsi");
lib/compiler_rt/fixdfti.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__fixdfti_windows_x86_64, "__fixdfti");
88 } else {
99 symbol(&__fixdfti, "__fixdfti");
lib/compiler_rt/fixhfdi.zig deleted-10
......@@ -1,10 +0,0 @@
1const common = @import("./common.zig");
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
3
4comptime {
5 @export(&__fixhfdi, .{ .name = "__fixhfdi", .linkage = common.linkage, .visibility = common.visibility });
6}
7
8fn __fixhfdi(a: f16) callconv(.c) i64 {
9 return intFromFloat(i64, a);
10}
lib/compiler_rt/fixhfei.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat;
56
67comptime {
7 @export(&__fixhfei, .{ .name = "__fixhfei", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__fixhfei, "__fixhfei");
89}
910
1011pub fn __fixhfei(r: [*]u8, bits: usize, a: f16) callconv(.c) void {
lib/compiler_rt/fixhfsi.zig deleted-10
......@@ -1,10 +0,0 @@
1const common = @import("./common.zig");
2const intFromFloat = @import("./int_from_float.zig").intFromFloat;
3
4comptime {
5 @export(&__fixhfsi, .{ .name = "__fixhfsi", .linkage = common.linkage, .visibility = common.visibility });
6}
7
8fn __fixhfsi(a: f16) callconv(.c) i32 {
9 return intFromFloat(i32, a);
10}
lib/compiler_rt/fixhfti.zig deleted-21
......@@ -1,21 +0,0 @@
1const builtin = @import("builtin");
2const common = @import("./common.zig");
3const intFromFloat = @import("./int_from_float.zig").intFromFloat;
4
5comptime {
6 if (common.want_windows_v2u64_abi) {
7 @export(&__fixhfti_windows_x86_64, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });
8 } else {
9 @export(&__fixhfti, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });
10 }
11}
12
13pub fn __fixhfti(a: f16) callconv(.c) i128 {
14 return intFromFloat(i128, a);
15}
16
17const v2u64 = @Vector(2, u64);
18
19fn __fixhfti_windows_x86_64(a: f16) callconv(.c) v2u64 {
20 return @bitCast(intFromFloat(i128, a));
21}
lib/compiler_rt/fixsfdi.zig+3-3
......@@ -1,13 +1,13 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
33const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44const symbol = @import("../compiler_rt.zig").symbol;
55
66comptime {
7 if (common.want_aeabi) {
7 if (compiler_rt.want_aeabi) {
88 symbol(&__aeabi_f2lz, "__aeabi_f2lz");
99 } else {
10 if (common.want_windows_arm_abi) {
10 if (compiler_rt.want_windows_arm_abi) {
1111 symbol(&__fixsfdi, "__stoi64");
1212 }
1313 symbol(&__fixsfdi, "__fixsfdi");
lib/compiler_rt/fixsfei.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat;
56
67comptime {
7 @export(&__fixsfei, .{ .name = "__fixsfei", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__fixsfei, "__fixsfei");
89}
910
1011pub fn __fixsfei(r: [*]u8, bits: usize, a: f32) callconv(.c) void {
lib/compiler_rt/fixsfsi.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const intFromFloat = @import("./int_from_float.zig").intFromFloat;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_f2iz, "__aeabi_f2iz");
78 } else {
8 @export(&__fixsfsi, .{ .name = "__fixsfsi", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__fixsfsi, "__fixsfsi");
910 }
1011}
1112
lib/compiler_rt/fixsfti.zig+5-4
......@@ -1,12 +1,13 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const intFromFloat = @import("./int_from_float.zig").intFromFloat;
45
56comptime {
6 if (common.want_windows_v2u64_abi) {
7 @export(&__fixsfti_windows_x86_64, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_windows_v2u64_abi) {
8 symbol(&__fixsfti_windows_x86_64, "__fixsfti");
89 } else {
9 @export(&__fixsfti, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });
10 symbol(&__fixsfti, "__fixsfti");
1011 }
1112}
1213
lib/compiler_rt/fixtfdi.zig+3-3
......@@ -1,11 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_ppc_abi) {
6 if (compiler_rt.want_ppc_abi) {
77 symbol(&__fixtfdi, "__fixkfdi");
8 } else if (common.want_sparc_abi) {
8 } else if (compiler_rt.want_sparc_abi) {
99 symbol(&_Qp_qtox, "_Qp_qtox");
1010 }
1111 symbol(&__fixtfdi, "__fixtfdi");
lib/compiler_rt/fixtfei.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat;
56
67comptime {
7 @export(&__fixtfei, .{ .name = "__fixtfei", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__fixtfei, "__fixtfei");
89}
910
1011pub fn __fixtfei(r: [*]u8, bits: usize, a: f128) callconv(.c) void {
lib/compiler_rt/fixtfsi.zig+3-3
......@@ -1,11 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55comptime {
6 if (common.want_ppc_abi) {
6 if (compiler_rt.want_ppc_abi) {
77 symbol(&__fixtfsi, "__fixkfsi");
8 } else if (common.want_sparc_abi) {
8 } else if (compiler_rt.want_sparc_abi) {
99 symbol(&_Qp_qtoi, "_Qp_qtoi");
1010 }
1111 symbol(&__fixtfsi, "__fixtfsi");
lib/compiler_rt/fixtfti.zig+3-3
......@@ -1,12 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__fixtfti_windows_x86_64, "__fixtfti");
88 } else {
9 if (common.want_ppc_abi)
9 if (compiler_rt.want_ppc_abi)
1010 symbol(&__fixtfti, "__fixkfti");
1111 symbol(&__fixtfti, "__fixtfti");
1212 }
lib/compiler_rt/fixunsdfdi.zig+7-6
......@@ -1,15 +1,16 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const intFromFloat = @import("./int_from_float.zig").intFromFloat;
45
56comptime {
6 if (common.want_aeabi) {
7 @export(&__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_aeabi) {
8 symbol(&__aeabi_d2ulz, "__aeabi_d2ulz");
89 } else {
9 if (common.want_windows_arm_abi) {
10 @export(&__fixunsdfdi, .{ .name = "__dtou64", .linkage = common.linkage, .visibility = common.visibility });
10 if (compiler_rt.want_windows_arm_abi) {
11 symbol(&__fixunsdfdi, "__dtou64");
1112 }
12 @export(&__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&__fixunsdfdi, "__fixunsdfdi");
1314 }
1415}
1516
lib/compiler_rt/fixunsdfsi.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const intFromFloat = @import("./int_from_float.zig").intFromFloat;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_d2uiz, "__aeabi_d2uiz");
78 } else {
8 @export(&__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__fixunsdfsi, "__fixunsdfsi");
910 }
1011}
1112
lib/compiler_rt/fixunsdfti.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__fixunsdfti_windows_x86_64, "__fixunsdfti");
88 } else {
99 symbol(&__fixunsdfti, "__fixunsdfti");
lib/compiler_rt/fixunshfsi.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const intFromFloat = @import("./int_from_float.zig").intFromFloat;
34
45comptime {
5 @export(&__fixunshfsi, .{ .name = "__fixunshfsi", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__fixunshfsi, "__fixunshfsi");
67}
78
89fn __fixunshfsi(a: f16) callconv(.c) u32 {
lib/compiler_rt/fixunshfti.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const intFromFloat = @import("./int_from_float.zig").intFromFloat;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__fixunshfti_windows_x86_64, "__fixunshfti");
88 } else {
99 symbol(&__fixunshfti, "__fixunshfti");
lib/compiler_rt/fixunssfdi.zig+7-6
......@@ -1,15 +1,16 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const intFromFloat = @import("./int_from_float.zig").intFromFloat;
45
56comptime {
6 if (common.want_aeabi) {
7 @export(&__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_aeabi) {
8 symbol(&__aeabi_f2ulz, "__aeabi_f2ulz");
89 } else {
9 if (common.want_windows_arm_abi) {
10 @export(&__fixunssfdi, .{ .name = "__stou64", .linkage = common.linkage, .visibility = common.visibility });
10 if (compiler_rt.want_windows_arm_abi) {
11 symbol(&__fixunssfdi, "__stou64");
1112 }
12 @export(&__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&__fixunssfdi, "__fixunssfdi");
1314 }
1415}
1516
lib/compiler_rt/fixunssfsi.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const intFromFloat = @import("./int_from_float.zig").intFromFloat;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_f2uiz, "__aeabi_f2uiz");
78 } else {
8 @export(&__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__fixunssfsi, "__fixunssfsi");
910 }
1011}
1112
lib/compiler_rt/fixunssfti.zig+2-2
......@@ -1,10 +1,10 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
33const intFromFloat = @import("./int_from_float.zig").intFromFloat;
44const symbol = @import("../compiler_rt.zig").symbol;
55
66comptime {
7 if (common.want_windows_v2u64_abi) {
7 if (compiler_rt.want_windows_v2u64_abi) {
88 symbol(&__fixunssfti_windows_x86_64, "__fixunssfti");
99 } else {
1010 symbol(&__fixunssfti, "__fixunssfti");
lib/compiler_rt/fixunstfdi.zig+7-6
......@@ -1,13 +1,14 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const intFromFloat = @import("./int_from_float.zig").intFromFloat;
34
45comptime {
5 if (common.want_ppc_abi) {
6 @export(&__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 @export(&_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_ppc_abi) {
7 symbol(&__fixunstfdi, "__fixunskfdi");
8 } else if (compiler_rt.want_sparc_abi) {
9 symbol(&_Qp_qtoux, "_Qp_qtoux");
910 }
10 @export(&__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__fixunstfdi, "__fixunstfdi");
1112}
1213
1314pub fn __fixunstfdi(a: f128) callconv(.c) u64 {
lib/compiler_rt/fixunstfsi.zig+7-6
......@@ -1,13 +1,14 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const intFromFloat = @import("./int_from_float.zig").intFromFloat;
34
45comptime {
5 if (common.want_ppc_abi) {
6 @export(&__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 @export(&_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_ppc_abi) {
7 symbol(&__fixunstfsi, "__fixunskfsi");
8 } else if (compiler_rt.want_sparc_abi) {
9 symbol(&_Qp_qtoui, "_Qp_qtoui");
910 }
10 @export(&__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__fixunstfsi, "__fixunstfsi");
1112}
1213
1314pub fn __fixunstfsi(a: f128) callconv(.c) u32 {
lib/compiler_rt/fixunstfti.zig+7-6
......@@ -1,14 +1,15 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const intFromFloat = @import("./int_from_float.zig").intFromFloat;
45
56comptime {
6 if (common.want_windows_v2u64_abi) {
7 @export(&__fixunstfti_windows_x86_64, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_windows_v2u64_abi) {
8 symbol(&__fixunstfti_windows_x86_64, "__fixunstfti");
89 } else {
9 if (common.want_ppc_abi)
10 @export(&__fixunstfti, .{ .name = "__fixunskfti", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fixunstfti, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });
10 if (compiler_rt.want_ppc_abi)
11 symbol(&__fixunstfti, "__fixunskfti");
12 symbol(&__fixunstfti, "__fixunstfti");
1213 }
1314}
1415
lib/compiler_rt/fixunsxfsi.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const intFromFloat = @import("./int_from_float.zig").intFromFloat;
34
45comptime {
5 @export(&__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__fixunsxfsi, "__fixunsxfsi");
67}
78
89fn __fixunsxfsi(a: f80) callconv(.c) u32 {
lib/compiler_rt/fixunsxfti.zig+5-4
......@@ -1,12 +1,13 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const intFromFloat = @import("./int_from_float.zig").intFromFloat;
45
56comptime {
6 if (common.want_windows_v2u64_abi) {
7 @export(&__fixunsxfti_windows_x86_64, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_windows_v2u64_abi) {
8 symbol(&__fixunsxfti_windows_x86_64, "__fixunsxfti");
89 } else {
9 @export(&__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });
10 symbol(&__fixunsxfti, "__fixunsxfti");
1011 }
1112}
1213
lib/compiler_rt/fixxfei.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat;
56
67comptime {
7 @export(&__fixxfei, .{ .name = "__fixxfei", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__fixxfei, "__fixxfei");
89}
910
1011pub fn __fixxfei(r: [*]u8, bits: usize, a: f80) callconv(.c) void {
lib/compiler_rt/fixxfsi.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const intFromFloat = @import("./int_from_float.zig").intFromFloat;
34
45comptime {
5 @export(&__fixxfsi, .{ .name = "__fixxfsi", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__fixxfsi, "__fixxfsi");
67}
78
89fn __fixxfsi(a: f80) callconv(.c) i32 {
lib/compiler_rt/fixxfti.zig deleted-23
......@@ -1,23 +0,0 @@
1const builtin = @import("builtin");
2
3const common = @import("./common.zig");
4const intFromFloat = @import("./int_from_float.zig").intFromFloat;
5const symbol = @import("../compiler_rt.zig").symbol;
6
7comptime {
8 if (common.want_windows_v2u64_abi) {
9 symbol(&__fixxfti_windows_x86_64, "__fixxfti");
10 } else {
11 symbol(&__fixxfti, "__fixxfti");
12 }
13}
14
15pub fn __fixxfti(a: f80) callconv(.c) i128 {
16 return intFromFloat(i128, a);
17}
18
19const v2u64 = @Vector(2, u64);
20
21fn __fixxfti_windows_x86_64(a: f80) callconv(.c) v2u64 {
22 return @bitCast(intFromFloat(i128, a));
23}
lib/compiler_rt/floatdidf.zig+7-6
......@@ -1,15 +1,16 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const floatFromInt = @import("./float_from_int.zig").floatFromInt;
45
56comptime {
6 if (common.want_aeabi) {
7 @export(&__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_aeabi) {
8 symbol(&__aeabi_l2d, "__aeabi_l2d");
89 } else {
9 if (common.want_windows_arm_abi) {
10 @export(&__floatdidf, .{ .name = "__i64tod", .linkage = common.linkage, .visibility = common.visibility });
10 if (compiler_rt.want_windows_arm_abi) {
11 symbol(&__floatdidf, "__i64tod");
1112 }
12 @export(&__floatdidf, .{ .name = "__floatdidf", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&__floatdidf, "__floatdidf");
1314 }
1415}
1516
lib/compiler_rt/floatdisf.zig+3-3
......@@ -1,12 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_l2f, "__aeabi_l2f");
88 } else {
9 if (common.want_windows_arm_abi) {
9 if (compiler_rt.want_windows_arm_abi) {
1010 symbol(&__floatdisf, "__i64tos");
1111 }
1212 symbol(&__floatdisf, "__floatdisf");
lib/compiler_rt/floatditf.zig+3-3
......@@ -1,11 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_ppc_abi) {
6 if (compiler_rt.want_ppc_abi) {
77 symbol(&__floatditf, "__floatdikf");
8 } else if (common.want_sparc_abi) {
8 } else if (compiler_rt.want_sparc_abi) {
99 symbol(&_Qp_xtoq, "_Qp_xtoq");
1010 }
1111 symbol(&__floatditf, "__floatditf");
lib/compiler_rt/floateihf.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt;
56
67comptime {
7 @export(&__floateihf, .{ .name = "__floateihf", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__floateihf, "__floateihf");
89}
910
1011pub fn __floateihf(a: [*]const u8, bits: usize) callconv(.c) f16 {
lib/compiler_rt/floateisf.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt;
56
67comptime {
7 @export(&__floateisf, .{ .name = "__floateisf", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__floateisf, "__floateisf");
89}
910
1011pub fn __floateisf(a: [*]const u8, bits: usize) callconv(.c) f32 {
lib/compiler_rt/floateitf.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt;
56
67comptime {
7 @export(&__floateitf, .{ .name = "__floateitf", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__floateitf, "__floateitf");
89}
910
1011pub fn __floateitf(a: [*]const u8, bits: usize) callconv(.c) f128 {
lib/compiler_rt/floatsidf.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const floatFromInt = @import("./float_from_int.zig").floatFromInt;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_i2d, "__aeabi_i2d");
78 } else {
8 @export(&__floatsidf, .{ .name = "__floatsidf", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__floatsidf, "__floatsidf");
910 }
1011}
1112
lib/compiler_rt/floatsihf.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const floatFromInt = @import("./float_from_int.zig").floatFromInt;
34
45comptime {
5 @export(&__floatsihf, .{ .name = "__floatsihf", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__floatsihf, "__floatsihf");
67}
78
89fn __floatsihf(a: i32) callconv(.c) f16 {
lib/compiler_rt/floatsisf.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const floatFromInt = @import("./float_from_int.zig").floatFromInt;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_i2f, "__aeabi_i2f");
78 } else {
8 @export(&__floatsisf, .{ .name = "__floatsisf", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__floatsisf, "__floatsisf");
910 }
1011}
1112
lib/compiler_rt/floatsitf.zig+7-6
......@@ -1,13 +1,14 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const floatFromInt = @import("./float_from_int.zig").floatFromInt;
34
45comptime {
5 if (common.want_ppc_abi) {
6 @export(&__floatsitf, .{ .name = "__floatsikf", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 @export(&_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_ppc_abi) {
7 symbol(&__floatsitf, "__floatsikf");
8 } else if (compiler_rt.want_sparc_abi) {
9 symbol(&_Qp_itoq, "_Qp_itoq");
910 }
10 @export(&__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__floatsitf, "__floatsitf");
1112}
1213
1314pub fn __floatsitf(a: i32) callconv(.c) f128 {
lib/compiler_rt/floatsixf.zig+1-1
......@@ -1,4 +1,4 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33const symbol = @import("../compiler_rt.zig").symbol;
44
lib/compiler_rt/floattidf.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__floattidf_windows_x86_64, "__floattidf");
88 } else {
99 symbol(&__floattidf, "__floattidf");
lib/compiler_rt/floattihf.zig+5-4
......@@ -1,12 +1,13 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const floatFromInt = @import("./float_from_int.zig").floatFromInt;
45
56comptime {
6 if (common.want_windows_v2u64_abi) {
7 @export(&__floattihf_windows_x86_64, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_windows_v2u64_abi) {
8 symbol(&__floattihf_windows_x86_64, "__floattihf");
89 } else {
9 @export(&__floattihf, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });
10 symbol(&__floattihf, "__floattihf");
1011 }
1112}
1213
lib/compiler_rt/floattisf.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__floattisf_windows_x86_64, "__floattisf");
88 } else {
99 symbol(&__floattisf, "__floattisf");
lib/compiler_rt/floattitf.zig+3-3
......@@ -1,12 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__floattitf_windows_x86_64, "__floattitf");
88 } else {
9 if (common.want_ppc_abi)
9 if (compiler_rt.want_ppc_abi)
1010 symbol(&__floattitf, "__floattikf");
1111 symbol(&__floattitf, "__floattitf");
1212 }
lib/compiler_rt/floattixf.zig+5-4
......@@ -1,12 +1,13 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const floatFromInt = @import("./float_from_int.zig").floatFromInt;
45
56comptime {
6 if (common.want_windows_v2u64_abi) {
7 @export(&__floattixf_windows_x86_64, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_windows_v2u64_abi) {
8 symbol(&__floattixf_windows_x86_64, "__floattixf");
89 } else {
9 @export(&__floattixf, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });
10 symbol(&__floattixf, "__floattixf");
1011 }
1112}
1213
lib/compiler_rt/floatundidf.zig+3-3
......@@ -1,12 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_ul2d, "__aeabi_ul2d");
88 } else {
9 if (common.want_windows_arm_abi) {
9 if (compiler_rt.want_windows_arm_abi) {
1010 symbol(&__floatundidf, "__u64tod");
1111 }
1212 symbol(&__floatundidf, "__floatundidf");
lib/compiler_rt/floatundihf.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const floatFromInt = @import("./float_from_int.zig").floatFromInt;
34
45comptime {
5 @export(&__floatundihf, .{ .name = "__floatundihf", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__floatundihf, "__floatundihf");
67}
78
89fn __floatundihf(a: u64) callconv(.c) f16 {
lib/compiler_rt/floatundisf.zig+7-6
......@@ -1,15 +1,16 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const floatFromInt = @import("./float_from_int.zig").floatFromInt;
45
56comptime {
6 if (common.want_aeabi) {
7 @export(&__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_aeabi) {
8 symbol(&__aeabi_ul2f, "__aeabi_ul2f");
89 } else {
9 if (common.want_windows_arm_abi) {
10 @export(&__floatundisf, .{ .name = "__u64tos", .linkage = common.linkage, .visibility = common.visibility });
10 if (compiler_rt.want_windows_arm_abi) {
11 symbol(&__floatundisf, "__u64tos");
1112 }
12 @export(&__floatundisf, .{ .name = "__floatundisf", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&__floatundisf, "__floatundisf");
1314 }
1415}
1516
lib/compiler_rt/floatunditf.zig+7-6
......@@ -1,13 +1,14 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const floatFromInt = @import("./float_from_int.zig").floatFromInt;
34
45comptime {
5 if (common.want_ppc_abi) {
6 @export(&__floatunditf, .{ .name = "__floatundikf", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 @export(&_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_ppc_abi) {
7 symbol(&__floatunditf, "__floatundikf");
8 } else if (compiler_rt.want_sparc_abi) {
9 symbol(&_Qp_uxtoq, "_Qp_uxtoq");
910 }
10 @export(&__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__floatunditf, "__floatunditf");
1112}
1213
1314pub fn __floatunditf(a: u64) callconv(.c) f128 {
lib/compiler_rt/floatundixf.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const floatFromInt = @import("./float_from_int.zig").floatFromInt;
34
45comptime {
5 @export(&__floatundixf, .{ .name = "__floatundixf", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__floatundixf, "__floatundixf");
67}
78
89fn __floatundixf(a: u64) callconv(.c) f80 {
lib/compiler_rt/floatuneidf.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt;
56
67comptime {
7 @export(&__floatuneidf, .{ .name = "__floatuneidf", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__floatuneidf, "__floatuneidf");
89}
910
1011pub fn __floatuneidf(a: [*]const u8, bits: usize) callconv(.c) f64 {
lib/compiler_rt/floatuneihf.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt;
56
67comptime {
7 @export(&__floatuneihf, .{ .name = "__floatuneihf", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__floatuneihf, "__floatuneihf");
89}
910
1011pub fn __floatuneihf(a: [*]const u8, bits: usize) callconv(.c) f16 {
lib/compiler_rt/floatuneisf.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt;
56
67comptime {
7 @export(&__floatuneisf, .{ .name = "__floatuneisf", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__floatuneisf, "__floatuneisf");
89}
910
1011pub fn __floatuneisf(a: [*]const u8, bits: usize) callconv(.c) f32 {
lib/compiler_rt/floatuneixf.zig+3-2
......@@ -1,10 +1,11 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt;
56
67comptime {
7 @export(&__floatuneixf, .{ .name = "__floatuneixf", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__floatuneixf, "__floatuneixf");
89}
910
1011pub fn __floatuneixf(a: [*]const u8, bits: usize) callconv(.c) f80 {
lib/compiler_rt/floatunsidf.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const floatFromInt = @import("./float_from_int.zig").floatFromInt;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_ui2d, "__aeabi_ui2d");
78 } else {
8 @export(&__floatunsidf, .{ .name = "__floatunsidf", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__floatunsidf, "__floatunsidf");
910 }
1011}
1112
lib/compiler_rt/floatunsisf.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_ui2f, "__aeabi_ui2f");
88 } else {
99 symbol(&__floatunsisf, "__floatunsisf");
lib/compiler_rt/floatunsitf.zig+3-3
......@@ -1,11 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_ppc_abi) {
6 if (compiler_rt.want_ppc_abi) {
77 symbol(&__floatunsitf, "__floatunsikf");
8 } else if (common.want_sparc_abi) {
8 } else if (compiler_rt.want_sparc_abi) {
99 symbol(&_Qp_uitoq, "_Qp_uitoq");
1010 }
1111 symbol(&__floatunsitf, "__floatunsitf");
lib/compiler_rt/floatunsixf.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const floatFromInt = @import("./float_from_int.zig").floatFromInt;
34
45comptime {
5 @export(&__floatunsixf, .{ .name = "__floatunsixf", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__floatunsixf, "__floatunsixf");
67}
78
89fn __floatunsixf(a: u32) callconv(.c) f80 {
lib/compiler_rt/floatuntidf.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__floatuntidf_windows_x86_64, "__floatuntidf");
88 } else {
99 symbol(&__floatuntidf, "__floatuntidf");
lib/compiler_rt/floatuntihf.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const floatFromInt = @import("./float_from_int.zig").floatFromInt;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__floatuntihf_windows_x86_64, "__floatuntihf");
88 } else {
99 symbol(&__floatuntihf, "__floatuntihf");
lib/compiler_rt/floatuntisf.zig+5-4
......@@ -1,12 +1,13 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const floatFromInt = @import("./float_from_int.zig").floatFromInt;
45
56comptime {
6 if (common.want_windows_v2u64_abi) {
7 @export(&__floatuntisf_windows_x86_64, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_windows_v2u64_abi) {
8 symbol(&__floatuntisf_windows_x86_64, "__floatuntisf");
89 } else {
9 @export(&__floatuntisf, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });
10 symbol(&__floatuntisf, "__floatuntisf");
1011 }
1112}
1213
lib/compiler_rt/floatuntitf.zig+3-3
......@@ -1,12 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const floatFromInt = @import("./float_from_int.zig").floatFromInt;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_windows_v2u64_abi) {
6 if (compiler_rt.want_windows_v2u64_abi) {
77 symbol(&__floatuntitf_windows_x86_64, "__floatuntitf");
88 } else {
9 if (common.want_ppc_abi)
9 if (compiler_rt.want_ppc_abi)
1010 symbol(&__floatuntitf, "__floatuntikf");
1111 symbol(&__floatuntitf, "__floatuntitf");
1212 }
lib/compiler_rt/floatuntixf.zig+5-4
......@@ -1,12 +1,13 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const floatFromInt = @import("./float_from_int.zig").floatFromInt;
45
56comptime {
6 if (common.want_windows_v2u64_abi) {
7 @export(&__floatuntixf_windows_x86_64, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });
7 if (compiler_rt.want_windows_v2u64_abi) {
8 symbol(&__floatuntixf_windows_x86_64, "__floatuntixf");
89 } else {
9 @export(&__floatuntixf, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });
10 symbol(&__floatuntixf, "__floatuntixf");
1011 }
1112}
1213
lib/compiler_rt/floor_ceil.zig+6-6
......@@ -14,7 +14,7 @@ const math = std.math;
1414const mem = std.mem;
1515const expect = std.testing.expect;
1616
17const common = @import("common.zig");
17const compiler_rt = @import("../compiler_rt.zig");
1818const symbol = @import("../compiler_rt.zig").symbol;
1919
2020comptime {
......@@ -23,7 +23,7 @@ comptime {
2323 symbol(&floorf, "floorf");
2424 symbol(&floor, "floor");
2525 symbol(&__floorx, "__floorx");
26 if (common.want_ppc_abi) {
26 if (compiler_rt.want_ppc_abi) {
2727 symbol(&floorq, "floorf128");
2828 }
2929 symbol(&floorq, "floorq");
......@@ -34,7 +34,7 @@ comptime {
3434 symbol(&ceilf, "ceilf");
3535 symbol(&ceil, "ceil");
3636 symbol(&__ceilx, "__ceilx");
37 if (common.want_ppc_abi) {
37 if (compiler_rt.want_ppc_abi) {
3838 symbol(&ceilq, "ceilf128");
3939 }
4040 symbol(&ceilq, "ceilq");
......@@ -106,11 +106,11 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T {
106106 if (e >= 0) {
107107 const m = (@as(U, 1) << @intCast(mantissa - e)) - 1;
108108 if (u & m == 0) return x;
109 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);
109 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);
110110 if (u >> bits - 1 == @intFromBool(op == .floor)) u += m;
111111 return @bitCast(u & ~m);
112112 } else {
113 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);
113 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);
114114 return switch (op) {
115115 .floor => if (u >> bits - 1 == 0) 0.0 else if (u << 1 != 0) -1.0 else x,
116116 .ceil => if (u >> bits - 1 != 0) -0.0 else if (u << 1 != 0) 1.0 else x,
......@@ -128,7 +128,7 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T {
128128 x - C + C - x;
129129
130130 if (e <= bias - 1) {
131 if (common.want_float_exceptions) mem.doNotOptimizeAway(y);
131 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(y);
132132 return switch (op) {
133133 .floor => if (positive) 0.0 else -1.0,
134134 .ceil => if (positive) 1.0 else -0.0,
lib/compiler_rt/fma.zig+10-9
......@@ -8,18 +8,19 @@
88const std = @import("std");
99const math = std.math;
1010const expect = std.testing.expect;
11const common = @import("common.zig");
11const compiler_rt = @import("../compiler_rt.zig");
12const symbol = compiler_rt.symbol;
1213
1314comptime {
14 @export(&__fmah, .{ .name = "__fmah", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&fmaf, .{ .name = "fmaf", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&fma, .{ .name = "fma", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&__fmax, .{ .name = "__fmax", .linkage = common.linkage, .visibility = common.visibility });
18 if (common.want_ppc_abi) {
19 @export(&fmaq, .{ .name = "fmaf128", .linkage = common.linkage, .visibility = common.visibility });
15 symbol(&__fmah, "__fmah");
16 symbol(&fmaf, "fmaf");
17 symbol(&fma, "fma");
18 symbol(&__fmax, "__fmax");
19 if (compiler_rt.want_ppc_abi) {
20 symbol(&fmaq, "fmaf128");
2021 }
21 @export(&fmaq, .{ .name = "fmaq", .linkage = common.linkage, .visibility = common.visibility });
22 @export(&fmal, .{ .name = "fmal", .linkage = common.linkage, .visibility = common.visibility });
22 symbol(&fmaq, "fmaq");
23 symbol(&fmal, "fmal");
2324}
2425
2526pub fn __fmah(x: f16, y: f16, z: f16) callconv(.c) f16 {
lib/compiler_rt/fmax.zig+10-9
......@@ -2,18 +2,19 @@ const std = @import("std");
22const builtin = @import("builtin");
33const math = std.math;
44const arch = builtin.cpu.arch;
5const common = @import("common.zig");
5const compiler_rt = @import("../compiler_rt.zig");
6const symbol = compiler_rt.symbol;
67
78comptime {
8 @export(&__fmaxh, .{ .name = "__fmaxh", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&fmaxf, .{ .name = "fmaxf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&fmax, .{ .name = "fmax", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage, .visibility = common.visibility });
12 if (common.want_ppc_abi) {
13 @export(&fmaxq, .{ .name = "fmaxf128", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__fmaxh, "__fmaxh");
10 symbol(&fmaxf, "fmaxf");
11 symbol(&fmax, "fmax");
12 symbol(&__fmaxx, "__fmaxx");
13 if (compiler_rt.want_ppc_abi) {
14 symbol(&fmaxq, "fmaxf128");
1415 }
15 @export(&fmaxq, .{ .name = "fmaxq", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&fmaxl, .{ .name = "fmaxl", .linkage = common.linkage, .visibility = common.visibility });
16 symbol(&fmaxq, "fmaxq");
17 symbol(&fmaxl, "fmaxl");
1718}
1819
1920pub fn __fmaxh(x: f16, y: f16) callconv(.c) f16 {
lib/compiler_rt/fmin.zig+10-9
......@@ -2,18 +2,19 @@ const std = @import("std");
22const builtin = @import("builtin");
33const math = std.math;
44const arch = builtin.cpu.arch;
5const common = @import("common.zig");
5const compiler_rt = @import("../compiler_rt.zig");
6const symbol = compiler_rt.symbol;
67
78comptime {
8 @export(&__fminh, .{ .name = "__fminh", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&fminf, .{ .name = "fminf", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&fmin, .{ .name = "fmin", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__fminx, .{ .name = "__fminx", .linkage = common.linkage, .visibility = common.visibility });
12 if (common.want_ppc_abi) {
13 @export(&fminq, .{ .name = "fminf128", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__fminh, "__fminh");
10 symbol(&fminf, "fminf");
11 symbol(&fmin, "fmin");
12 symbol(&__fminx, "__fminx");
13 if (compiler_rt.want_ppc_abi) {
14 symbol(&fminq, "fminf128");
1415 }
15 @export(&fminq, .{ .name = "fminq", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&fminl, .{ .name = "fminl", .linkage = common.linkage, .visibility = common.visibility });
16 symbol(&fminq, "fminq");
17 symbol(&fminl, "fminl");
1718}
1819
1920pub fn __fminh(x: f16, y: f16) callconv(.c) f16 {
lib/compiler_rt/fmod.zig+11-10
......@@ -3,19 +3,20 @@ const std = @import("std");
33const math = std.math;
44const assert = std.debug.assert;
55const arch = builtin.cpu.arch;
6const common = @import("common.zig");
7const normalize = common.normalize;
6const compiler_rt = @import("../compiler_rt.zig");
7const symbol = compiler_rt.symbol;
8const normalize = compiler_rt.normalize;
89
910comptime {
10 @export(&__fmodh, .{ .name = "__fmodh", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&fmodf, .{ .name = "fmodf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&fmod, .{ .name = "fmod", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__fmodx, .{ .name = "__fmodx", .linkage = common.linkage, .visibility = common.visibility });
14 if (common.want_ppc_abi) {
15 @export(&fmodq, .{ .name = "fmodf128", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__fmodh, "__fmodh");
12 symbol(&fmodf, "fmodf");
13 symbol(&fmod, "fmod");
14 symbol(&__fmodx, "__fmodx");
15 if (compiler_rt.want_ppc_abi) {
16 symbol(&fmodq, "fmodf128");
1617 }
17 @export(&fmodq, .{ .name = "fmodq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&fmodl, .{ .name = "fmodl", .linkage = common.linkage, .visibility = common.visibility });
18 symbol(&fmodq, "fmodq");
19 symbol(&fmodl, "fmodl");
1920}
2021
2122pub fn __fmodh(x: f16, y: f16) callconv(.c) f16 {
lib/compiler_rt/gedf2.zig+2-2
......@@ -1,11 +1,11 @@
11///! The quoted behavior definitions are from
22///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
3const common = @import("./common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
44const comparef = @import("./comparef.zig");
55const symbol = @import("../compiler_rt.zig").symbol;
66
77comptime {
8 if (common.want_aeabi) {
8 if (compiler_rt.want_aeabi) {
99 symbol(&__aeabi_dcmpge, "__aeabi_dcmpge");
1010 symbol(&__aeabi_dcmpgt, "__aeabi_dcmpgt");
1111 } else {
lib/compiler_rt/gesf2.zig+7-6
......@@ -1,15 +1,16 @@
11///! The quoted behavior definitions are from
22///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
3const common = @import("./common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const comparef = @import("./comparef.zig");
56
67comptime {
7 if (common.want_aeabi) {
8 @export(&__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = common.linkage, .visibility = common.visibility });
8 if (compiler_rt.want_aeabi) {
9 symbol(&__aeabi_fcmpge, "__aeabi_fcmpge");
10 symbol(&__aeabi_fcmpgt, "__aeabi_fcmpgt");
1011 } else {
11 @export(&__gesf2, .{ .name = "__gesf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__gtsf2, .{ .name = "__gtsf2", .linkage = common.linkage, .visibility = common.visibility });
12 symbol(&__gesf2, "__gesf2");
13 symbol(&__gtsf2, "__gtsf2");
1314 }
1415}
1516
lib/compiler_rt/getf2.zig+8-7
......@@ -1,18 +1,19 @@
11///! The quoted behavior definitions are from
22///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
3const common = @import("./common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const comparef = @import("./comparef.zig");
56
67comptime {
7 if (common.want_ppc_abi) {
8 @export(&__getf2, .{ .name = "__gekf2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage, .visibility = common.visibility });
10 } else if (common.want_sparc_abi) {
8 if (compiler_rt.want_ppc_abi) {
9 symbol(&__getf2, "__gekf2");
10 symbol(&__gttf2, "__gtkf2");
11 } else if (compiler_rt.want_sparc_abi) {
1112 // These exports are handled in cmptf2.zig because gt and ge on sparc
1213 // are based on calling _Qp_cmp.
1314 }
14 @export(&__getf2, .{ .name = "__getf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__gttf2, .{ .name = "__gttf2", .linkage = common.linkage, .visibility = common.visibility });
15 symbol(&__getf2, "__getf2");
16 symbol(&__gttf2, "__gttf2");
1617}
1718
1819/// "These functions return a value greater than or equal to zero if neither
lib/compiler_rt/hexagon.zig+27-25
......@@ -1,5 +1,7 @@
11const builtin = @import("builtin");
2const common = @import("./common.zig");
2
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
35
46fn __hexagon_divsi3() callconv(.naked) noreturn {
57 asm volatile (
......@@ -1759,29 +1761,29 @@ fn __hexagon_sqrtdf2() align(32) callconv(.naked) noreturn {
17591761
17601762comptime {
17611763 if (builtin.cpu.arch == .hexagon) {
1762 @export(&__hexagon_adddf3, .{ .name = "__hexagon_adddf3", .linkage = common.linkage, .visibility = common.visibility });
1763 @export(&__hexagon_adddf3, .{ .name = "__hexagon_fast_adddf3", .linkage = common.linkage, .visibility = common.visibility });
1764 @export(&__hexagon_subdf3, .{ .name = "__hexagon_subdf3", .linkage = common.linkage, .visibility = common.visibility });
1765 @export(&__hexagon_subdf3, .{ .name = "__hexagon_fast_subdf3", .linkage = common.linkage, .visibility = common.visibility });
1766 @export(&__hexagon_divdf3, .{ .name = "__hexagon_divdf3", .linkage = common.linkage, .visibility = common.visibility });
1767 @export(&__hexagon_divdf3, .{ .name = "__hexagon_fast_divdf3", .linkage = common.linkage, .visibility = common.visibility });
1768 @export(&__hexagon_muldf3, .{ .name = "__hexagon_muldf3", .linkage = common.linkage, .visibility = common.visibility });
1769 @export(&__hexagon_muldf3, .{ .name = "__hexagon_fast_muldf3", .linkage = common.linkage, .visibility = common.visibility });
1770 @export(&__hexagon_sqrtdf2, .{ .name = "__hexagon_sqrtdf2", .linkage = common.linkage, .visibility = common.visibility });
1771 @export(&__hexagon_sqrtdf2, .{ .name = "__hexagon_fast2_sqrtdf2", .linkage = common.linkage, .visibility = common.visibility });
1772 @export(&__hexagon_sqrtdf2, .{ .name = "__hexagon_sqrt", .linkage = common.linkage, .visibility = common.visibility });
1773 @export(&__hexagon_divsf3, .{ .name = "__hexagon_divsf3", .linkage = common.linkage, .visibility = common.visibility });
1774 @export(&__hexagon_divsf3, .{ .name = "__hexagon_fast_divsf3", .linkage = common.linkage, .visibility = common.visibility });
1775 @export(&__hexagon_divsi3, .{ .name = "__hexagon_divsi3", .linkage = common.linkage, .visibility = common.visibility });
1776 @export(&__hexagon_umodsi3, .{ .name = "__hexagon_umodsi3", .linkage = common.linkage, .visibility = common.visibility });
1777 @export(&__hexagon_sqrtf, .{ .name = "__hexagon_sqrtf", .linkage = common.linkage, .visibility = common.visibility });
1778 @export(&__hexagon_sqrtf, .{ .name = "__hexagon_fast2_sqrtf", .linkage = common.linkage, .visibility = common.visibility });
1779 @export(&__hexagon_moddi3, .{ .name = "__hexagon_moddi3", .linkage = common.linkage, .visibility = common.visibility });
1780 @export(&__hexagon_divdi3, .{ .name = "__hexagon_divdi3", .linkage = common.linkage, .visibility = common.visibility });
1781 @export(&__hexagon_udivdi3, .{ .name = "__hexagon_udivdi3", .linkage = common.linkage, .visibility = common.visibility });
1782 @export(&__hexagon_umoddi3, .{ .name = "__hexagon_umoddi3", .linkage = common.linkage, .visibility = common.visibility });
1783 @export(&__hexagon_modsi3, .{ .name = "__hexagon_modsi3", .linkage = common.linkage, .visibility = common.visibility });
1784 @export(&__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes, .{ .name = "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes", .linkage = common.linkage, .visibility = common.visibility });
1785 @export(&__hexagon_udivsi3, .{ .name = "__hexagon_udivsi3", .linkage = common.linkage, .visibility = common.visibility });
1764 symbol(&__hexagon_adddf3, "__hexagon_adddf3");
1765 symbol(&__hexagon_adddf3, "__hexagon_fast_adddf3");
1766 symbol(&__hexagon_subdf3, "__hexagon_subdf3");
1767 symbol(&__hexagon_subdf3, "__hexagon_fast_subdf3");
1768 symbol(&__hexagon_divdf3, "__hexagon_divdf3");
1769 symbol(&__hexagon_divdf3, "__hexagon_fast_divdf3");
1770 symbol(&__hexagon_muldf3, "__hexagon_muldf3");
1771 symbol(&__hexagon_muldf3, "__hexagon_fast_muldf3");
1772 symbol(&__hexagon_sqrtdf2, "__hexagon_sqrtdf2");
1773 symbol(&__hexagon_sqrtdf2, "__hexagon_fast2_sqrtdf2");
1774 symbol(&__hexagon_sqrtdf2, "__hexagon_sqrt");
1775 symbol(&__hexagon_divsf3, "__hexagon_divsf3");
1776 symbol(&__hexagon_divsf3, "__hexagon_fast_divsf3");
1777 symbol(&__hexagon_divsi3, "__hexagon_divsi3");
1778 symbol(&__hexagon_umodsi3, "__hexagon_umodsi3");
1779 symbol(&__hexagon_sqrtf, "__hexagon_sqrtf");
1780 symbol(&__hexagon_sqrtf, "__hexagon_fast2_sqrtf");
1781 symbol(&__hexagon_moddi3, "__hexagon_moddi3");
1782 symbol(&__hexagon_divdi3, "__hexagon_divdi3");
1783 symbol(&__hexagon_udivdi3, "__hexagon_udivdi3");
1784 symbol(&__hexagon_umoddi3, "__hexagon_umoddi3");
1785 symbol(&__hexagon_modsi3, "__hexagon_modsi3");
1786 symbol(&__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes, "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes");
1787 symbol(&__hexagon_udivsi3, "__hexagon_udivsi3");
17861788 }
17871789}
lib/compiler_rt/int.zig+4-4
......@@ -8,16 +8,16 @@ const testing = std.testing;
88const maxInt = std.math.maxInt;
99const minInt = std.math.minInt;
1010
11const common = @import("common.zig");
12const symbol = @import("../compiler_rt.zig").symbol;
11const compiler_rt = @import("../compiler_rt.zig");
12const symbol = compiler_rt.symbol;
1313const udivmod = @import("udivmod.zig").udivmod;
14const __divti3 = @import("divti3.zig").__divti3;
14const __divti3 = @import("udivmod.zig").__divti3;
1515
1616comptime {
1717 symbol(&__divmodti4, "__divmodti4");
1818 symbol(&__udivmoddi4, "__udivmoddi4");
1919 symbol(&__divmoddi4, "__divmoddi4");
20 if (common.want_aeabi) {
20 if (compiler_rt.want_aeabi) {
2121 symbol(&__aeabi_idiv, "__aeabi_idiv");
2222 symbol(&__aeabi_uidiv, "__aeabi_uidiv");
2323 } else {
lib/compiler_rt/int_from_float.zig+48-3
......@@ -1,13 +1,58 @@
11const std = @import("std");
2const Int = std.meta.Int;
32const math = std.math;
4const Log2Int = math.Log2Int;
3const Log2Int = std.math.Log2Int;
4
5const compiler_rt = @import("../compiler_rt.zig");
6const symbol = compiler_rt.symbol;
7
8comptime {
9 if (compiler_rt.want_windows_v2u64_abi) {
10 symbol(&__fixxfti_windows_x86_64, "__fixxfti");
11 } else {
12 symbol(&__fixxfti, "__fixxfti");
13 }
14
15 symbol(&__fixhfsi, "__fixhfsi");
16 symbol(&__fixhfdi, "__fixhfdi");
17
18 if (compiler_rt.want_windows_v2u64_abi) {
19 symbol(&__fixhfti_windows_x86_64, "__fixhfti");
20 } else {
21 symbol(&__fixhfti, "__fixhfti");
22 }
23}
24
25const v2u64 = @Vector(2, u64);
26
27pub fn __fixhfti(a: f16) callconv(.c) i128 {
28 return intFromFloat(i128, a);
29}
30
31fn __fixhfti_windows_x86_64(a: f16) callconv(.c) v2u64 {
32 return @bitCast(intFromFloat(i128, a));
33}
34
35fn __fixhfdi(a: f16) callconv(.c) i64 {
36 return intFromFloat(i64, a);
37}
38
39fn __fixhfsi(a: f16) callconv(.c) i32 {
40 return intFromFloat(i32, a);
41}
42
43pub fn __fixxfti(a: f80) callconv(.c) i128 {
44 return intFromFloat(i128, a);
45}
46
47fn __fixxfti_windows_x86_64(a: f80) callconv(.c) v2u64 {
48 return @bitCast(intFromFloat(i128, a));
49}
550
651pub inline fn intFromFloat(comptime I: type, a: anytype) I {
752 const F = @TypeOf(a);
853 const float_bits = @typeInfo(F).float.bits;
954 const int_bits = @typeInfo(I).int.bits;
10 const rep_t = Int(.unsigned, float_bits);
55 const rep_t = @Int(.unsigned, float_bits);
1156 const sig_bits = math.floatMantissaBits(F);
1257 const exp_bits = math.floatExponentBits(F);
1358 const fractional_bits = math.floatFractionalBits(F);
lib/compiler_rt/log.zig+6-6
......@@ -9,7 +9,7 @@ const math = std.math;
99const expect = std.testing.expect;
1010const expectEqual = std.testing.expectEqual;
1111
12const common = @import("common.zig");
12const compiler_rt = @import("../compiler_rt.zig");
1313const symbol = @import("../compiler_rt.zig").symbol;
1414
1515comptime {
......@@ -17,7 +17,7 @@ comptime {
1717 symbol(&logf, "logf");
1818 symbol(&log, "log");
1919 symbol(&__logx, "__logx");
20 if (common.want_ppc_abi) {
20 if (compiler_rt.want_ppc_abi) {
2121 symbol(&logq, "logf128");
2222 }
2323 symbol(&logq, "logq");
......@@ -45,11 +45,11 @@ pub fn logf(x_: f32) callconv(.c) f32 {
4545 if (ix < 0x00800000 or ix >> 31 != 0) {
4646 // log(+-0) = -inf
4747 if (ix << 1 == 0) {
48 return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
48 return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
4949 }
5050 // log(-#) = nan
5151 if (ix >> 31 != 0) {
52 return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
52 return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
5353 }
5454
5555 // subnormal, scale x
......@@ -398,13 +398,13 @@ pub fn log(x: f64) callconv(.c) f64 {
398398 @branchHint(.unlikely);
399399
400400 if (ix << 1 == 0)
401 return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
401 return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
402402
403403 if (ix == @as(i64, @bitCast(std.math.inf(f64))))
404404 return x;
405405
406406 if (top & 0x8000 != 0 or top & 0x7ff0 == 0x7ff0)
407 return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
407 return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
408408
409409 ix = @as(i64, @bitCast(x * 0x1p52)) - (52 << 52);
410410 }
lib/compiler_rt/log10.zig+6-6
......@@ -10,7 +10,7 @@ const expect = std.testing.expect;
1010const expectEqual = std.testing.expectEqual;
1111const maxInt = std.math.maxInt;
1212
13const common = @import("common.zig");
13const compiler_rt = @import("../compiler_rt.zig");
1414const symbol = @import("../compiler_rt.zig").symbol;
1515
1616comptime {
......@@ -18,7 +18,7 @@ comptime {
1818 symbol(&log10f, "log10f");
1919 symbol(&log10, "log10");
2020 symbol(&__log10x, "__log10x");
21 if (common.want_ppc_abi) {
21 if (compiler_rt.want_ppc_abi) {
2222 symbol(&log10q, "log10f128");
2323 }
2424 symbol(&log10q, "log10q");
......@@ -49,11 +49,11 @@ pub fn log10f(x_: f32) callconv(.c) f32 {
4949 if (ix < 0x00800000 or ix >> 31 != 0) {
5050 // log(+-0) = -inf
5151 if (ix << 1 == 0) {
52 return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
52 return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
5353 }
5454 // log(-#) = nan
5555 if (ix >> 31 != 0) {
56 return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
56 return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
5757 }
5858
5959 k -= 25;
......@@ -111,11 +111,11 @@ pub fn log10(x_: f64) callconv(.c) f64 {
111111 if (hx < 0x00100000 or hx >> 31 != 0) {
112112 // log(+-0) = -inf
113113 if (ix << 1 == 0) {
114 return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
114 return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
115115 }
116116 // log(-#) = nan
117117 if (hx >> 31 != 0) {
118 return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
118 return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
119119 }
120120
121121 // subnormal, scale x
lib/compiler_rt/log2.zig+14-13
......@@ -11,18 +11,19 @@ const expect = std.testing.expect;
1111const expectEqual = std.testing.expectEqual;
1212const maxInt = std.math.maxInt;
1313const arch = builtin.cpu.arch;
14const common = @import("common.zig");
14const compiler_rt = @import("../compiler_rt.zig");
15const symbol = compiler_rt.symbol;
1516
1617comptime {
17 @export(&__log2h, .{ .name = "__log2h", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&log2f, .{ .name = "log2f", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&log2, .{ .name = "log2", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&__log2x, .{ .name = "__log2x", .linkage = common.linkage, .visibility = common.visibility });
21 if (common.want_ppc_abi) {
22 @export(&log2q, .{ .name = "log2f128", .linkage = common.linkage, .visibility = common.visibility });
18 symbol(&__log2h, "__log2h");
19 symbol(&log2f, "log2f");
20 symbol(&log2, "log2");
21 symbol(&__log2x, "__log2x");
22 if (compiler_rt.want_ppc_abi) {
23 symbol(&log2q, "log2f128");
2324 }
24 @export(&log2q, .{ .name = "log2q", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&log2l, .{ .name = "log2l", .linkage = common.linkage, .visibility = common.visibility });
25 symbol(&log2q, "log2q");
26 symbol(&log2l, "log2l");
2627}
2728
2829pub fn __log2h(a: f16) callconv(.c) f16 {
......@@ -47,11 +48,11 @@ pub fn log2f(x_: f32) callconv(.c) f32 {
4748 if (ix < 0x00800000 or ix >> 31 != 0) {
4849 // log(+-0) = -inf
4950 if (ix << 1 == 0) {
50 return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
51 return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
5152 }
5253 // log(-#) = nan
5354 if (ix >> 31 != 0) {
54 return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
55 return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
5556 }
5657
5758 k -= 25;
......@@ -105,11 +106,11 @@ pub fn log2(x_: f64) callconv(.c) f64 {
105106 if (hx < 0x00100000 or hx >> 31 != 0) {
106107 // log(+-0) = -inf
107108 if (ix << 1 == 0) {
108 return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
109 return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64);
109110 }
110111 // log(-#) = nan
111112 if (hx >> 31 != 0) {
112 return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
113 return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
113114 }
114115
115116 // subnormal, scale x
lib/compiler_rt/memcpy.zig+4-4
......@@ -1,14 +1,14 @@
11const std = @import("std");
22const assert = std.debug.assert;
3const common = @import("./common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
44const builtin = @import("builtin");
55
66comptime {
77 if (builtin.object_format != .c) {
88 const export_options: std.builtin.ExportOptions = .{
99 .name = "memcpy",
10 .linkage = common.linkage,
11 .visibility = common.visibility,
10 .linkage = compiler_rt.linkage,
11 .visibility = compiler_rt.visibility,
1212 };
1313
1414 if (builtin.mode == .ReleaseSmall or builtin.zig_backend == .stage2_aarch64)
......@@ -18,7 +18,7 @@ comptime {
1818 }
1919}
2020
21const Element = common.PreferredLoadStoreElement;
21const Element = compiler_rt.PreferredLoadStoreElement;
2222
2323comptime {
2424 assert(std.math.isPowerOfTwo(@sizeOf(Element)));
lib/compiler_rt/memmove.zig+10-10
......@@ -1,17 +1,17 @@
11const std = @import("std");
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
33const builtin = @import("builtin");
44const assert = std.debug.assert;
55const memcpy = @import("memcpy.zig");
66
7const Element = common.PreferredLoadStoreElement;
7const Element = compiler_rt.PreferredLoadStoreElement;
88
99comptime {
1010 if (builtin.object_format != .c) {
1111 const export_options: std.builtin.ExportOptions = .{
1212 .name = "memmove",
13 .linkage = common.linkage,
14 .visibility = common.visibility,
13 .linkage = compiler_rt.linkage,
14 .visibility = compiler_rt.visibility,
1515 };
1616
1717 if (builtin.mode == .ReleaseSmall or builtin.zig_backend == .stage2_aarch64)
......@@ -39,7 +39,7 @@ fn memmoveSmall(opt_dest: ?[*]u8, opt_src: ?[*]const u8, len: usize) callconv(.c
3939}
4040
4141fn memmoveFast(dest: ?[*]u8, src: ?[*]u8, len: usize) callconv(.c) ?[*]u8 {
42 @setRuntimeSafety(common.test_safety);
42 @setRuntimeSafety(compiler_rt.test_safety);
4343 const small_limit = @max(2 * @sizeOf(Element), @sizeOf(Element));
4444
4545 if (copySmallLength(small_limit, dest.?, src.?, len)) return dest;
......@@ -79,7 +79,7 @@ inline fn copyLessThan16(
7979 src: [*]const u8,
8080 len: usize,
8181) void {
82 @setRuntimeSafety(common.test_safety);
82 @setRuntimeSafety(compiler_rt.test_safety);
8383 if (len < 4) {
8484 if (len == 0) return;
8585 const b = len / 2;
......@@ -100,7 +100,7 @@ inline fn copy16ToSmallLimit(
100100 src: [*]const u8,
101101 len: usize,
102102) bool {
103 @setRuntimeSafety(common.test_safety);
103 @setRuntimeSafety(compiler_rt.test_safety);
104104 inline for (2..(std.math.log2(small_limit) + 1) / 2 + 1) |p| {
105105 const limit = 1 << (2 * p);
106106 if (len < limit) {
......@@ -119,7 +119,7 @@ inline fn copyRange4(
119119 src: [*]const u8,
120120 len: usize,
121121) void {
122 @setRuntimeSafety(common.test_safety);
122 @setRuntimeSafety(compiler_rt.test_safety);
123123 comptime assert(std.math.isPowerOfTwo(copy_len));
124124 assert(len >= copy_len);
125125 assert(len < 4 * copy_len);
......@@ -147,7 +147,7 @@ inline fn copyForwards(
147147 src: [*]const u8,
148148 len: usize,
149149) void {
150 @setRuntimeSafety(common.test_safety);
150 @setRuntimeSafety(compiler_rt.test_safety);
151151 assert(len >= 2 * @sizeOf(Element));
152152
153153 const head = src[0..@sizeOf(Element)].*;
......@@ -181,7 +181,7 @@ inline fn copyBlocks(
181181 src: anytype,
182182 max_bytes: usize,
183183) void {
184 @setRuntimeSafety(common.test_safety);
184 @setRuntimeSafety(compiler_rt.test_safety);
185185
186186 const T = @typeInfo(@TypeOf(dest)).pointer.child;
187187 comptime assert(T == @typeInfo(@TypeOf(src)).pointer.child);
lib/compiler_rt/memset.zig deleted-33
......@@ -1,33 +0,0 @@
1const std = @import("std");
2const common = @import("./common.zig");
3const builtin = @import("builtin");
4
5comptime {
6 if (builtin.object_format != .c) {
7 @export(&memset, .{ .name = "memset", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__memset, .{ .name = "__memset", .linkage = common.linkage, .visibility = common.visibility });
9 }
10}
11
12pub fn memset(dest: ?[*]u8, c: u8, len: usize) callconv(.c) ?[*]u8 {
13 @setRuntimeSafety(false);
14
15 if (len != 0) {
16 var d = dest.?;
17 var n = len;
18 while (true) {
19 d[0] = c;
20 n -= 1;
21 if (n == 0) break;
22 d += 1;
23 }
24 }
25
26 return dest;
27}
28
29pub fn __memset(dest: ?[*]u8, c: u8, n: usize, dest_n: usize) callconv(.c) ?[*]u8 {
30 if (dest_n < n)
31 @panic("buffer overflow");
32 return memset(dest, c, n);
33}
lib/compiler_rt/modti3.zig deleted-42
......@@ -1,42 +0,0 @@
1//! Ported from:
2//!
3//! https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/modti3.c
4
5const std = @import("std");
6const builtin = @import("builtin");
7const udivmod = @import("udivmod.zig").udivmod;
8const common = @import("common.zig");
9
10comptime {
11 if (common.want_windows_v2u64_abi) {
12 @export(&__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });
13 } else {
14 @export(&__modti3, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });
15 }
16}
17
18pub fn __modti3(a: i128, b: i128) callconv(.c) i128 {
19 return mod(a, b);
20}
21
22const v2u64 = @Vector(2, u64);
23
24fn __modti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 {
25 return @bitCast(mod(@as(i128, @bitCast(a)), @as(i128, @bitCast(b))));
26}
27
28inline fn mod(a: i128, b: i128) i128 {
29 const s_a = a >> (128 - 1); // s = a < 0 ? -1 : 0
30 const s_b = b >> (128 - 1); // s = b < 0 ? -1 : 0
31
32 const an = (a ^ s_a) -% s_a; // negate if s == -1
33 const bn = (b ^ s_b) -% s_b; // negate if s == -1
34
35 var r: u128 = undefined;
36 _ = udivmod(u128, @as(u128, @bitCast(an)), @as(u128, @bitCast(bn)), &r);
37 return (@as(i128, @bitCast(r)) ^ s_a) -% s_a; // negate if s == -1
38}
39
40test {
41 _ = @import("modti3_test.zig");
42}
lib/compiler_rt/modti3_test.zig+1-1
......@@ -1,4 +1,4 @@
1const __modti3 = @import("modti3.zig").__modti3;
1const __modti3 = @import("udivmod.zig").__modti3;
22const testing = @import("std").testing;
33
44fn test__modti3(a: i128, b: i128, expected: i128) !void {
lib/compiler_rt/mulXi3.zig+11-10
......@@ -1,20 +1,21 @@
11const builtin = @import("builtin");
22const std = @import("std");
33const testing = std.testing;
4const common = @import("common.zig");
4const compiler_rt = @import("../compiler_rt.zig");
5const symbol = compiler_rt.symbol;
56const native_endian = builtin.cpu.arch.endian();
67
78comptime {
8 @export(&__mulsi3, .{ .name = "__mulsi3", .linkage = common.linkage, .visibility = common.visibility });
9 if (common.want_aeabi) {
10 @export(&__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__mulsi3, "__mulsi3");
10 if (compiler_rt.want_aeabi) {
11 symbol(&__aeabi_lmul, "__aeabi_lmul");
1112 } else {
12 @export(&__muldi3, .{ .name = "__muldi3", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&__muldi3, "__muldi3");
1314 }
14 if (common.want_windows_v2u64_abi) {
15 @export(&__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });
15 if (compiler_rt.want_windows_v2u64_abi) {
16 symbol(&__multi3_windows_x86_64, "__multi3");
1617 } else {
17 @export(&__multi3, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });
18 symbol(&__multi3, "__multi3");
1819 }
1920}
2021
......@@ -41,7 +42,7 @@ fn __aeabi_lmul(a: i64, b: i64) callconv(.{ .arm_aapcs = .{} }) i64 {
4142}
4243
4344inline fn mulX(comptime T: type, a: T, b: T) T {
44 const word_t = common.HalveInt(T, false);
45 const word_t = compiler_rt.HalveInt(T, false);
4546 const x = word_t{ .all = a };
4647 const y = word_t{ .all = b };
4748 var r = switch (T) {
......@@ -64,7 +65,7 @@ fn DoubleInt(comptime T: type) type {
6465
6566fn muldXi(comptime T: type, a: T, b: T) DoubleInt(T) {
6667 const DT = DoubleInt(T);
67 const word_t = common.HalveInt(DT, false);
68 const word_t = compiler_rt.HalveInt(DT, false);
6869 const bits_in_word_2 = @sizeOf(T) * 8 / 2;
6970 const lower_mask = (~@as(T, 0)) >> bits_in_word_2;
7071
lib/compiler_rt/muldf3.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const mulf3 = @import("./mulf3.zig").mulf3;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_dmul, "__aeabi_dmul");
88 } else {
99 symbol(&__muldf3, "__muldf3");
lib/compiler_rt/mulf3.zig+4-4
......@@ -1,12 +1,12 @@
11const std = @import("std");
22const math = std.math;
33const builtin = @import("builtin");
4const common = @import("./common.zig");
4const compiler_rt = @import("../compiler_rt.zig");
55
66/// Ported from:
77/// https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/fp_mul_impl.inc
88pub inline fn mulf3(comptime T: type, a: T, b: T) T {
9 @setRuntimeSafety(common.test_safety);
9 @setRuntimeSafety(compiler_rt.test_safety);
1010 const typeWidth = @typeInfo(T).float.bits;
1111 const significandBits = math.floatMantissaBits(T);
1212 const fractionalBits = math.floatFractionalBits(T);
......@@ -97,7 +97,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
9797 var productHi: ZSignificand = undefined;
9898 var productLo: ZSignificand = undefined;
9999 const left_align_shift = ZSignificandBits - fractionalBits - 1;
100 common.wideMultiply(ZSignificand, aSignificand, bSignificand << left_align_shift, &productHi, &productLo);
100 compiler_rt.wideMultiply(ZSignificand, aSignificand, bSignificand << left_align_shift, &productHi, &productLo);
101101
102102 var productExponent: i32 = @as(i32, @intCast(aExponent + bExponent)) - exponentBias + scale;
103103
......@@ -163,7 +163,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
163163///
164164/// This is analogous to an shr version of `@shlWithOverflow`
165165fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool {
166 @setRuntimeSafety(common.test_safety);
166 @setRuntimeSafety(compiler_rt.test_safety);
167167 const typeWidth = @typeInfo(Z).int.bits;
168168 var inexact = false;
169169 if (count < typeWidth) {
lib/compiler_rt/mulhc3.zig+3-2
......@@ -1,9 +1,10 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const mulc3 = @import("./mulc3.zig");
34
45comptime {
56 if (@import("builtin").zig_backend != .stage2_c) {
6 @export(&__mulhc3, .{ .name = "__mulhc3", .linkage = common.linkage, .visibility = common.visibility });
7 symbol(&__mulhc3, "__mulhc3");
78 }
89}
910
lib/compiler_rt/mulhf3.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const mulf3 = @import("./mulf3.zig").mulf3;
34
45comptime {
5 @export(&__mulhf3, .{ .name = "__mulhf3", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__mulhf3, "__mulhf3");
67}
78
89pub fn __mulhf3(a: f16, b: f16) callconv(.c) f16 {
lib/compiler_rt/mulo.zig+5-4
......@@ -1,12 +1,13 @@
11const std = @import("std");
22const builtin = @import("builtin");
33const math = std.math;
4const common = @import("common.zig");
4const compiler_rt = @import("../compiler_rt.zig");
5const symbol = compiler_rt.symbol;
56
67comptime {
7 @export(&__mulosi4, .{ .name = "__mulosi4", .linkage = common.linkage, .visibility = common.visibility });
8 @export(&__mulodi4, .{ .name = "__mulodi4", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__muloti4, .{ .name = "__muloti4", .linkage = common.linkage, .visibility = common.visibility });
8 symbol(&__mulosi4, "__mulosi4");
9 symbol(&__mulodi4, "__mulodi4");
10 symbol(&__muloti4, "__muloti4");
1011}
1112
1213// mulo - multiplication overflow
lib/compiler_rt/mulsf3.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const mulf3 = @import("./mulf3.zig").mulf3;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_fmul, "__aeabi_fmul");
78 } else {
8 @export(&__mulsf3, .{ .name = "__mulsf3", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__mulsf3, "__mulsf3");
910 }
1011}
1112
lib/compiler_rt/multc3.zig+2-2
......@@ -1,10 +1,10 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const mulc3 = @import("./mulc3.zig");
44
55comptime {
66 if (@import("builtin").zig_backend != .stage2_c) {
7 if (common.want_ppc_abi)
7 if (compiler_rt.want_ppc_abi)
88 symbol(&__multc3, "__mulkc3");
99 symbol(&__multc3, "__multc3");
1010 }
lib/compiler_rt/multf3.zig+7-6
......@@ -1,13 +1,14 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const mulf3 = @import("./mulf3.zig").mulf3;
34
45comptime {
5 if (common.want_ppc_abi) {
6 @export(&__multf3, .{ .name = "__mulkf3", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 @export(&_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_ppc_abi) {
7 symbol(&__multf3, "__mulkf3");
8 } else if (compiler_rt.want_sparc_abi) {
9 symbol(&_Qp_mul, "_Qp_mul");
910 }
10 @export(&__multf3, .{ .name = "__multf3", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__multf3, "__multf3");
1112}
1213
1314pub fn __multf3(a: f128, b: f128) callconv(.c) f128 {
lib/compiler_rt/mulxc3.zig+3-2
......@@ -1,9 +1,10 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const mulc3 = @import("./mulc3.zig");
34
45comptime {
56 if (@import("builtin").zig_backend != .stage2_c) {
6 @export(&__mulxc3, .{ .name = "__mulxc3", .linkage = common.linkage, .visibility = common.visibility });
7 symbol(&__mulxc3, "__mulxc3");
78 }
89}
910
lib/compiler_rt/mulxf3.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const mulf3 = @import("./mulf3.zig").mulf3;
34
45comptime {
5 @export(&__mulxf3, .{ .name = "__mulxf3", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__mulxf3, "__mulxf3");
67}
78
89pub fn __mulxf3(a: f80, b: f80) callconv(.c) f80 {
lib/compiler_rt/negXi2.zig deleted-39
......@@ -1,39 +0,0 @@
1//! neg - negate (the number)
2//! - negXi2 for unoptimized little and big endian
3//! sfffffff = 2^31-1
4//! two's complement inverting bits and add 1 would result in -INT_MIN == 0
5//! => -INT_MIN = -2^31 forbidden
6//! * size optimized builds
7//! * machines that dont support carry operations
8
9const std = @import("std");
10const builtin = @import("builtin");
11const common = @import("common.zig");
12
13comptime {
14 @export(&__negsi2, .{ .name = "__negsi2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__negdi2, .{ .name = "__negdi2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__negti2, .{ .name = "__negti2", .linkage = common.linkage, .visibility = common.visibility });
17}
18
19pub fn __negsi2(a: i32) callconv(.c) i32 {
20 return negXi2(i32, a);
21}
22
23pub fn __negdi2(a: i64) callconv(.c) i64 {
24 return negXi2(i64, a);
25}
26
27pub fn __negti2(a: i128) callconv(.c) i128 {
28 return negXi2(i128, a);
29}
30
31inline fn negXi2(comptime T: type, a: T) T {
32 return -a;
33}
34
35test {
36 _ = @import("negsi2_test.zig");
37 _ = @import("negdi2_test.zig");
38 _ = @import("negti2_test.zig");
39}
lib/compiler_rt/negdf2.zig deleted-17
......@@ -1,17 +0,0 @@
1const common = @import("./common.zig");
2
3comptime {
4 if (common.want_aeabi) {
5 @export(&__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = common.linkage, .visibility = common.visibility });
6 } else {
7 @export(&__negdf2, .{ .name = "__negdf2", .linkage = common.linkage, .visibility = common.visibility });
8 }
9}
10
11fn __negdf2(a: f64) callconv(.c) f64 {
12 return common.fneg(a);
13}
14
15fn __aeabi_dneg(a: f64) callconv(.{ .arm_aapcs = .{} }) f64 {
16 return common.fneg(a);
17}
lib/compiler_rt/negdi2_test.zig+5-3
......@@ -1,8 +1,10 @@
1const neg = @import("negXi2.zig");
2const testing = @import("std").testing;
1const std = @import("std");
2const testing = std.testing;
3
4const compiler_rt = @import("../compiler_rt.zig");
35
46fn test__negdi2(a: i64, expected: i64) !void {
5 const result = neg.__negdi2(a);
7 const result = compiler_rt.__negdi2(a);
68 try testing.expectEqual(expected, result);
79}
810
lib/compiler_rt/neghf2.zig deleted-9
......@@ -1,9 +0,0 @@
1const common = @import("./common.zig");
2
3comptime {
4 @export(&__neghf2, .{ .name = "__neghf2", .linkage = common.linkage, .visibility = common.visibility });
5}
6
7fn __neghf2(a: f16) callconv(.c) f16 {
8 return common.fneg(a);
9}
lib/compiler_rt/negsf2.zig deleted-17
......@@ -1,17 +0,0 @@
1const common = @import("./common.zig");
2
3comptime {
4 if (common.want_aeabi) {
5 @export(&__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = common.linkage, .visibility = common.visibility });
6 } else {
7 @export(&__negsf2, .{ .name = "__negsf2", .linkage = common.linkage, .visibility = common.visibility });
8 }
9}
10
11fn __negsf2(a: f32) callconv(.c) f32 {
12 return common.fneg(a);
13}
14
15fn __aeabi_fneg(a: f32) callconv(.{ .arm_aapcs = .{} }) f32 {
16 return common.fneg(a);
17}
lib/compiler_rt/negsi2_test.zig+3-2
......@@ -1,11 +1,12 @@
11const std = @import("std");
2const neg = @import("negXi2.zig");
32const testing = std.testing;
43
4const compiler_rt = @import("../compiler_rt.zig");
5
56const print = std.debug.print;
67
78fn test__negsi2(a: i32, expected: i32) !void {
8 const result = neg.__negsi2(a);
9 const result = compiler_rt.__negsi2(a);
910 try testing.expectEqual(expected, result);
1011}
1112
lib/compiler_rt/negtf2.zig deleted-12
......@@ -1,12 +0,0 @@
1const common = @import("./common.zig");
2const symbol = @import("../compiler_rt.zig").symbol;
3
4comptime {
5 if (common.want_ppc_abi)
6 symbol(&__negtf2, "__negkf2");
7 symbol(&__negtf2, "__negtf2");
8}
9
10fn __negtf2(a: f128) callconv(.c) f128 {
11 return common.fneg(a);
12}
lib/compiler_rt/negti2_test.zig+5-3
......@@ -1,8 +1,10 @@
1const neg = @import("negXi2.zig");
2const testing = @import("std").testing;
1const std = @import("std");
2const testing = std.testing;
3
4const compiler_rt = @import("../compiler_rt.zig");
35
46fn test__negti2(a: i128, expected: i128) !void {
5 const result = neg.__negti2(a);
7 const result = compiler_rt.__negti2(a);
68 try testing.expectEqual(expected, result);
79}
810
lib/compiler_rt/negv.zig+5-4
......@@ -3,12 +3,13 @@
33//! - negvXi4_generic for unoptimized version
44const std = @import("std");
55const builtin = @import("builtin");
6const common = @import("common.zig");
6const compiler_rt = @import("../compiler_rt.zig");
7const symbol = compiler_rt.symbol;
78
89comptime {
9 @export(&__negvsi2, .{ .name = "__negvsi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__negvdi2, .{ .name = "__negvdi2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&__negvti2, .{ .name = "__negvti2", .linkage = common.linkage, .visibility = common.visibility });
10 symbol(&__negvsi2, "__negvsi2");
11 symbol(&__negvdi2, "__negvdi2");
12 symbol(&__negvti2, "__negvti2");
1213}
1314
1415pub fn __negvsi2(a: i32) callconv(.c) i32 {
lib/compiler_rt/negxf2.zig deleted-9
......@@ -1,9 +0,0 @@
1const common = @import("./common.zig");
2
3comptime {
4 @export(&__negxf2, .{ .name = "__negxf2", .linkage = common.linkage, .visibility = common.visibility });
5}
6
7fn __negxf2(a: f80) callconv(.c) f80 {
8 return common.fneg(a);
9}
lib/compiler_rt/os_version_check.zig+4-3
......@@ -1,15 +1,16 @@
11const std = @import("std");
22const testing = std.testing;
33const builtin = @import("builtin");
4const common = @import("common.zig");
5const panic = @import("common.zig").panic;
4const compiler_rt = @import("../compiler_rt.zig");
5const symbol = compiler_rt.symbol;
6const panic = @import("../compiler_rt.zig").panic;
67
78const have_availability_version_check = builtin.os.tag.isDarwin() and
89 builtin.os.version_range.semver.min.order(.{ .major = 10, .minor = 15, .patch = 0 }).compare(.gte);
910
1011comptime {
1112 if (have_availability_version_check) {
12 @export(&__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&__isPlatformVersionAtLeast, "__isPlatformVersionAtLeast");
1314 }
1415}
1516
lib/compiler_rt/powiXf2.zig+2-2
......@@ -3,14 +3,14 @@
33//! Multiplication order (left-to-right or right-to-left) does not matter for
44//! error propagation and this method is optimized for performance, not accuracy.
55
6const common = @import("common.zig");
6const compiler_rt = @import("../compiler_rt.zig");
77const symbol = @import("../compiler_rt.zig").symbol;
88
99comptime {
1010 symbol(&__powihf2, "__powihf2");
1111 symbol(&__powisf2, "__powisf2");
1212 symbol(&__powidf2, "__powidf2");
13 if (common.want_ppc_abi)
13 if (compiler_rt.want_ppc_abi)
1414 symbol(&__powitf2, "__powikf2");
1515 symbol(&__powitf2, "__powitf2");
1616 symbol(&__powixf2, "__powixf2");
lib/compiler_rt/round.zig+14-13
......@@ -10,18 +10,19 @@ const math = std.math;
1010const mem = std.mem;
1111const expect = std.testing.expect;
1212const arch = builtin.cpu.arch;
13const common = @import("common.zig");
13const compiler_rt = @import("../compiler_rt.zig");
14const symbol = compiler_rt.symbol;
1415
1516comptime {
16 @export(&__roundh, .{ .name = "__roundh", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&roundf, .{ .name = "roundf", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&round, .{ .name = "round", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&__roundx, .{ .name = "__roundx", .linkage = common.linkage, .visibility = common.visibility });
20 if (common.want_ppc_abi) {
21 @export(&roundq, .{ .name = "roundf128", .linkage = common.linkage, .visibility = common.visibility });
22 }
23 @export(&roundq, .{ .name = "roundq", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&roundl, .{ .name = "roundl", .linkage = common.linkage, .visibility = common.visibility });
17 symbol(&__roundh, "__roundh");
18 symbol(&roundf, "roundf");
19 symbol(&round, "round");
20 symbol(&__roundx, "__roundx");
21 if (compiler_rt.want_ppc_abi) {
22 symbol(&roundq, "roundf128");
23 }
24 symbol(&roundq, "roundq");
25 symbol(&roundl, "roundl");
2526}
2627
2728pub fn __roundh(x: f16) callconv(.c) f16 {
......@@ -44,7 +45,7 @@ pub fn roundf(x_: f32) callconv(.c) f32 {
4445 x = -x;
4546 }
4647 if (e < 0x7F - 1) {
47 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + f32_toint);
48 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + f32_toint);
4849 return 0 * @as(f32, @bitCast(u));
4950 }
5051
......@@ -79,7 +80,7 @@ pub fn round(x_: f64) callconv(.c) f64 {
7980 x = -x;
8081 }
8182 if (e < 0x3ff - 1) {
82 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + f64_toint);
83 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + f64_toint);
8384 return 0 * @as(f64, @bitCast(u));
8485 }
8586
......@@ -119,7 +120,7 @@ pub fn roundq(x_: f128) callconv(.c) f128 {
119120 x = -x;
120121 }
121122 if (e < 0x3FFF - 1) {
122 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + f128_toint);
123 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + f128_toint);
123124 return 0 * @as(f128, @bitCast(u));
124125 }
125126
lib/compiler_rt/shift.zig+20-19
......@@ -1,33 +1,34 @@
11const std = @import("std");
22const builtin = @import("builtin");
33const Log2Int = std.math.Log2Int;
4const common = @import("common.zig");
4const compiler_rt = @import("../compiler_rt.zig");
5const symbol = compiler_rt.symbol;
56
67comptime {
78 // symbol compatibility with libgcc
8 @export(&__ashlsi3, .{ .name = "__ashlsi3", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&__ashrsi3, .{ .name = "__ashrsi3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&__lshrsi3, .{ .name = "__lshrsi3", .linkage = common.linkage, .visibility = common.visibility });
11
12 @export(&__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage, .visibility = common.visibility });
15
16 if (common.want_aeabi) {
17 @export(&__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = common.linkage, .visibility = common.visibility });
19 @export(&__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__ashlsi3, "__ashlsi3");
10 symbol(&__ashrsi3, "__ashrsi3");
11 symbol(&__lshrsi3, "__lshrsi3");
12
13 symbol(&__ashlti3, "__ashlti3");
14 symbol(&__ashrti3, "__ashrti3");
15 symbol(&__lshrti3, "__lshrti3");
16
17 if (compiler_rt.want_aeabi) {
18 symbol(&__aeabi_llsl, "__aeabi_llsl");
19 symbol(&__aeabi_lasr, "__aeabi_lasr");
20 symbol(&__aeabi_llsr, "__aeabi_llsr");
2021 } else {
21 @export(&__ashldi3, .{ .name = "__ashldi3", .linkage = common.linkage, .visibility = common.visibility });
22 @export(&__ashrdi3, .{ .name = "__ashrdi3", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&__lshrdi3, .{ .name = "__lshrdi3", .linkage = common.linkage, .visibility = common.visibility });
22 symbol(&__ashldi3, "__ashldi3");
23 symbol(&__ashrdi3, "__ashrdi3");
24 symbol(&__lshrdi3, "__lshrdi3");
2425 }
2526}
2627
2728// Arithmetic shift left: shift in 0 from right to left
2829// Precondition: 0 <= b < bits_in_dword
2930inline fn ashlXi3(comptime T: type, a: T, b: i32) T {
30 const word_t = common.HalveInt(T, false);
31 const word_t = compiler_rt.HalveInt(T, false);
3132
3233 const input = word_t{ .all = a };
3334 var output: word_t = undefined;
......@@ -49,7 +50,7 @@ inline fn ashlXi3(comptime T: type, a: T, b: i32) T {
4950// Arithmetic shift right: shift in 1 from left to right
5051// Precondition: 0 <= b < T.bit_count
5152inline fn ashrXi3(comptime T: type, a: T, b: i32) T {
52 const word_t = common.HalveInt(T, true);
53 const word_t = compiler_rt.HalveInt(T, true);
5354
5455 const input = word_t{ .all = a };
5556 var output: word_t = undefined;
......@@ -72,7 +73,7 @@ inline fn ashrXi3(comptime T: type, a: T, b: i32) T {
7273// Logical shift right: shift in 0 from left to right
7374// Precondition: 0 <= b < T.bit_count
7475inline fn lshrXi3(comptime T: type, a: T, b: i32) T {
75 const word_t = common.HalveInt(T, false);
76 const word_t = compiler_rt.HalveInt(T, false);
7677
7778 const input = word_t{ .all = a };
7879 var output: word_t = undefined;
lib/compiler_rt/sin.zig+4-4
......@@ -9,7 +9,7 @@ const math = std.math;
99const mem = std.mem;
1010const expect = std.testing.expect;
1111
12const common = @import("common.zig");
12const compiler_rt = @import("../compiler_rt.zig");
1313const symbol = @import("../compiler_rt.zig").symbol;
1414const trig = @import("trig.zig");
1515const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
......@@ -20,7 +20,7 @@ comptime {
2020 symbol(&sinf, "sinf");
2121 symbol(&sin, "sin");
2222 symbol(&__sinx, "__sinx");
23 if (common.want_ppc_abi) {
23 if (compiler_rt.want_ppc_abi) {
2424 symbol(&sinq, "sinf128");
2525 }
2626 symbol(&sinq, "sinq");
......@@ -46,7 +46,7 @@ pub fn sinf(x: f32) callconv(.c) f32 {
4646 if (ix <= 0x3f490fda) { // |x| ~<= pi/4
4747 if (ix < 0x39800000) { // |x| < 2**-12
4848 // raise inexact if x!=0 and underflow if subnormal
49 if (common.want_float_exceptions) {
49 if (compiler_rt.want_float_exceptions) {
5050 if (ix < 0x00800000) {
5151 mem.doNotOptimizeAway(x / 0x1p120);
5252 } else {
......@@ -101,7 +101,7 @@ pub fn sin(x: f64) callconv(.c) f64 {
101101 if (ix <= 0x3fe921fb) {
102102 if (ix < 0x3e500000) { // |x| < 2**-26
103103 // raise inexact if x != 0 and underflow if subnormal
104 if (common.want_float_exceptions) {
104 if (compiler_rt.want_float_exceptions) {
105105 if (ix < 0x00100000) {
106106 mem.doNotOptimizeAway(x / 0x1p120);
107107 } else {
lib/compiler_rt/sincos.zig+13-12
......@@ -6,18 +6,19 @@ const mem = std.mem;
66const trig = @import("trig.zig");
77const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
88const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
9const common = @import("common.zig");
9const compiler_rt = @import("../compiler_rt.zig");
10const symbol = compiler_rt.symbol;
1011
1112comptime {
12 @export(&__sincosh, .{ .name = "__sincosh", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&sincosf, .{ .name = "sincosf", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&sincos, .{ .name = "sincos", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&__sincosx, .{ .name = "__sincosx", .linkage = common.linkage, .visibility = common.visibility });
16 if (common.want_ppc_abi) {
17 @export(&sincosq, .{ .name = "sincosf128", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&__sincosh, "__sincosh");
14 symbol(&sincosf, "sincosf");
15 symbol(&sincos, "sincos");
16 symbol(&__sincosx, "__sincosx");
17 if (compiler_rt.want_ppc_abi) {
18 symbol(&sincosq, "sincosf128");
1819 }
19 @export(&sincosq, .{ .name = "sincosq", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&sincosl, .{ .name = "sincosl", .linkage = common.linkage, .visibility = common.visibility });
20 symbol(&sincosq, "sincosq");
21 symbol(&sincosl, "sincosl");
2122}
2223
2324pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.c) void {
......@@ -44,7 +45,7 @@ pub fn sincosf(x: f32, r_sin: *f32, r_cos: *f32) callconv(.c) void {
4445 // |x| < 2**-12
4546 if (ix < 0x39800000) {
4647 // raise inexact if x!=0 and underflow if subnormal
47 if (common.want_float_exceptions) {
48 if (compiler_rt.want_float_exceptions) {
4849 if (ix < 0x00100000) {
4950 mem.doNotOptimizeAway(x / 0x1p120);
5051 } else {
......@@ -138,7 +139,7 @@ pub fn sincos(x: f64, r_sin: *f64, r_cos: *f64) callconv(.c) void {
138139 // if |x| < 2**-27 * sqrt(2)
139140 if (ix < 0x3e46a09e) {
140141 // raise inexact if x != 0 and underflow if subnormal
141 if (common.want_float_exceptions) {
142 if (compiler_rt.want_float_exceptions) {
142143 if (ix < 0x00100000) {
143144 mem.doNotOptimizeAway(x / 0x1p120);
144145 } else {
......@@ -242,7 +243,7 @@ inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void {
242243 if (se < 0x3fff - math.floatFractionalBits(F) - 1) {
243244 // raise underflow if subnormal
244245 if (se == 0) {
245 if (common.want_float_exceptions) mem.doNotOptimizeAway(x * 0x1p-120);
246 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x * 0x1p-120);
246247 }
247248 r_sin.* = x;
248249 // raise inexact if x!=0
lib/compiler_rt/sqrt.zig+15-14
......@@ -9,20 +9,21 @@ const std = @import("std");
99const builtin = @import("builtin");
1010const arch = builtin.cpu.arch;
1111const math = std.math;
12const common = @import("common.zig");
12const compiler_rt = @import("../compiler_rt.zig");
13const symbol = compiler_rt.symbol;
1314
1415comptime {
15 @export(&__sqrth, .{ .name = "__sqrth", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&sqrtf, .{ .name = "sqrtf", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&sqrt, .{ .name = "sqrt", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage, .visibility = common.visibility });
19 if (common.want_ppc_abi) {
20 @export(&sqrtq, .{ .name = "sqrtf128", .linkage = common.linkage, .visibility = common.visibility });
21 } else if (common.want_sparc_abi) {
22 @export(&_Qp_sqrt, .{ .name = "_Qp_sqrt", .linkage = common.linkage, .visibility = common.visibility });
16 symbol(&__sqrth, "__sqrth");
17 symbol(&sqrtf, "sqrtf");
18 symbol(&sqrt, "sqrt");
19 symbol(&__sqrtx, "__sqrtx");
20 if (compiler_rt.want_ppc_abi) {
21 symbol(&sqrtq, "sqrtf128");
22 } else if (compiler_rt.want_sparc_abi) {
23 symbol(&_Qp_sqrt, "_Qp_sqrt");
2324 }
24 @export(&sqrtq, .{ .name = "sqrtq", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&sqrtl, .{ .name = "sqrtl", .linkage = common.linkage, .visibility = common.visibility });
25 symbol(&sqrtq, "sqrtq");
26 symbol(&sqrtl, "sqrtl");
2627}
2728
2829pub fn __sqrth(x: f16) callconv(.c) f16 {
......@@ -103,7 +104,7 @@ pub fn sqrtf(x: f32) callconv(.c) f32 {
103104 return x;
104105
105106 if (ix > @as(u32, @bitCast(std.math.inf(f32))))
106 return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f32);
107 return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f32);
107108
108109 ix = @as(u32, @bitCast(@as(i32, @bitCast(x * 0x1p23)) - (23 << 23)));
109110 }
......@@ -154,7 +155,7 @@ pub fn sqrt(x: f64) callconv(.c) f64 {
154155 // x < 0x1p-1022 or inf or nan.
155156 if (ix & 0x7FFF_FFFF_FFFF_FFFF == 0) return x;
156157 if (ix == 0x7FF0_0000_0000_0000) return x;
157 if (ix > 0x7FF0_0000_0000_0000) return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
158 if (ix > 0x7FF0_0000_0000_0000) return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64);
158159 // x is subnormal, normalize it.
159160 ix = @bitCast(x * 0x1p52);
160161 top = (ix >> 52) -% 52;
......@@ -291,7 +292,7 @@ pub fn __sqrtx(x: f80) callconv(.c) f80 {
291292 // x < 0x1p-16382 or inf or nan.
292293 if (ix & 0x7FFF_FFFF_FFFF_FFFF_FFFF == 0) return x;
293294 if (ix == 0x7FFF_8000_0000_0000_0000) return x;
294 if (ix > 0x7FFF_8000_0000_0000_0000) return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f80);
295 if (ix > 0x7FFF_8000_0000_0000_0000) return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f80);
295296 // x is subnormal, normalize it.
296297 ix = @bitCast(x * 0x1p63);
297298 top = (ix >> 64) -% 63;
lib/compiler_rt/ssp.zig+12-11
......@@ -13,7 +13,8 @@
1313//! - __vsprintf_chk
1414
1515const std = @import("std");
16const common = @import("./common.zig");
16const compiler_rt = @import("../compiler_rt.zig");
17const symbol = compiler_rt.symbol;
1718const builtin = @import("builtin");
1819
1920extern fn memset(dest: ?[*]u8, c: u8, n: usize) callconv(.c) ?[*]u8;
......@@ -21,16 +22,16 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call
2122extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.c) ?[*]u8;
2223
2324comptime {
24 @export(&__stack_chk_fail, .{ .name = if (builtin.os.tag == .openbsd) "__stack_smash_handler" else "__stack_chk_fail", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&__chk_fail, .{ .name = "__chk_fail", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = common.linkage, .visibility = common.visibility });
27 @export(&__strcpy_chk, .{ .name = "__strcpy_chk", .linkage = common.linkage, .visibility = common.visibility });
28 @export(&__strncpy_chk, .{ .name = "__strncpy_chk", .linkage = common.linkage, .visibility = common.visibility });
29 @export(&__strcat_chk, .{ .name = "__strcat_chk", .linkage = common.linkage, .visibility = common.visibility });
30 @export(&__strncat_chk, .{ .name = "__strncat_chk", .linkage = common.linkage, .visibility = common.visibility });
31 @export(&__memcpy_chk, .{ .name = "__memcpy_chk", .linkage = common.linkage, .visibility = common.visibility });
32 @export(&__memmove_chk, .{ .name = "__memmove_chk", .linkage = common.linkage, .visibility = common.visibility });
33 @export(&__memset_chk, .{ .name = "__memset_chk", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&__stack_chk_fail, .{ .name = if (builtin.os.tag == .openbsd) "__stack_smash_handler" else "__stack_chk_fail", .linkage = compiler_rt.linkage, .visibility = compiler_rt.visibility });
26 symbol(&__chk_fail, "__chk_fail");
27 symbol(&__stack_chk_guard, "__stack_chk_guard");
28 symbol(&__strcpy_chk, "__strcpy_chk");
29 symbol(&__strncpy_chk, "__strncpy_chk");
30 symbol(&__strcat_chk, "__strcat_chk");
31 symbol(&__strncat_chk, "__strncat_chk");
32 symbol(&__memcpy_chk, "__memcpy_chk");
33 symbol(&__memmove_chk, "__memmove_chk");
34 symbol(&__memset_chk, "__memset_chk");
3435}
3536
3637fn __stack_chk_fail() callconv(.c) noreturn {
lib/compiler_rt/stack_probe.zig+11-10
......@@ -1,6 +1,7 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const common = @import("common.zig");
3const compiler_rt = @import("../compiler_rt.zig");
4const symbol = compiler_rt.symbol;
45const os_tag = builtin.os.tag;
56const arch = builtin.cpu.arch;
67const abi = builtin.abi;
......@@ -9,16 +10,16 @@ comptime {
910 if (builtin.os.tag == .windows) {
1011 // Default stack-probe functions emitted by LLVM
1112 if (builtin.target.isMinGW()) {
12 @export(&_chkstk, .{ .name = "_alloca", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__chkstk, .{ .name = "__chkstk", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&___chkstk, .{ .name = "__alloca", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&___chkstk, .{ .name = "___chkstk", .linkage = common.linkage, .visibility = common.visibility });
16 @export(&__chkstk_ms, .{ .name = "__chkstk_ms", .linkage = common.linkage, .visibility = common.visibility });
17 @export(&___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = common.linkage, .visibility = common.visibility });
13 symbol(&_chkstk, "_alloca");
14 symbol(&__chkstk, "__chkstk");
15 symbol(&___chkstk, "__alloca");
16 symbol(&___chkstk, "___chkstk");
17 symbol(&__chkstk_ms, "__chkstk_ms");
18 symbol(&___chkstk_ms, "___chkstk_ms");
1819 } else if (!builtin.link_libc) {
1920 // This symbols are otherwise exported by MSVCRT.lib
20 @export(&_chkstk, .{ .name = "_chkstk", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__chkstk, .{ .name = "__chkstk", .linkage = common.linkage, .visibility = common.visibility });
21 symbol(&_chkstk, "_chkstk");
22 symbol(&__chkstk, "__chkstk");
2223 }
2324 }
2425
......@@ -26,7 +27,7 @@ comptime {
2627 .x86,
2728 .x86_64,
2829 => {
29 @export(&zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = common.linkage, .visibility = common.visibility });
30 symbol(&zig_probe_stack, "__zig_probe_stack");
3031 },
3132 else => {},
3233 }
lib/compiler_rt/subdf3.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const addf3 = @import("./addf3.zig").addf3;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_dsub, "__aeabi_dsub");
88 } else {
99 symbol(&__subdf3, "__subdf3");
lib/compiler_rt/subhf3.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const addf3 = @import("./addf3.zig").addf3;
34
45comptime {
5 @export(&__subhf3, .{ .name = "__subhf3", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__subhf3, "__subhf3");
67}
78
89fn __subhf3(a: f16, b: f16) callconv(.c) f16 {
lib/compiler_rt/subsf3.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const addf3 = @import("./addf3.zig").addf3;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_fsub, "__aeabi_fsub");
78 } else {
8 @export(&__subsf3, .{ .name = "__subsf3", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__subsf3, "__subsf3");
910 }
1011}
1112
lib/compiler_rt/subtf3.zig+7-6
......@@ -1,13 +1,14 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const addf3 = @import("./addf3.zig").addf3;
34
45comptime {
5 if (common.want_ppc_abi) {
6 @export(&__subtf3, .{ .name = "__subkf3", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 @export(&_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_ppc_abi) {
7 symbol(&__subtf3, "__subkf3");
8 } else if (compiler_rt.want_sparc_abi) {
9 symbol(&_Qp_sub, "_Qp_sub");
910 }
10 @export(&__subtf3, .{ .name = "__subtf3", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__subtf3, "__subtf3");
1112}
1213
1314pub fn __subtf3(a: f128, b: f128) callconv(.c) f128 {
lib/compiler_rt/subvsi3.zig+3-2
......@@ -1,8 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const testing = @import("std").testing;
34
45comptime {
5 @export(&__subvsi3, .{ .name = "__subvsi3", .linkage = common.linkage, .visibility = common.visibility });
6 symbol(&__subvsi3, "__subvsi3");
67}
78
89pub fn __subvsi3(a: i32, b: i32) callconv(.c) i32 {
lib/compiler_rt/tan.zig+4-4
......@@ -16,7 +16,7 @@ const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
1616const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
1717
1818const arch = builtin.cpu.arch;
19const common = @import("common.zig");
19const compiler_rt = @import("../compiler_rt.zig");
2020const symbol = @import("../compiler_rt.zig").symbol;
2121
2222comptime {
......@@ -24,7 +24,7 @@ comptime {
2424 symbol(&tanf, "tanf");
2525 symbol(&tan, "tan");
2626 symbol(&__tanx, "__tanx");
27 if (common.want_ppc_abi) {
27 if (compiler_rt.want_ppc_abi) {
2828 symbol(&tanq, "tanf128");
2929 }
3030 symbol(&tanq, "tanq");
......@@ -50,7 +50,7 @@ pub fn tanf(x: f32) callconv(.c) f32 {
5050 if (ix <= 0x3f490fda) { // |x| ~<= pi/4
5151 if (ix < 0x39800000) { // |x| < 2**-12
5252 // raise inexact if x!=0 and underflow if subnormal
53 if (common.want_float_exceptions) {
53 if (compiler_rt.want_float_exceptions) {
5454 if (ix < 0x00800000) {
5555 mem.doNotOptimizeAway(x / 0x1p120);
5656 } else {
......@@ -94,7 +94,7 @@ pub fn tan(x: f64) callconv(.c) f64 {
9494 if (ix <= 0x3fe921fb) {
9595 if (ix < 0x3e400000) { // |x| < 2**-27
9696 // raise inexact if x!=0 and underflow if subnormal
97 if (common.want_float_exceptions) {
97 if (compiler_rt.want_float_exceptions) {
9898 if (ix < 0x00100000) {
9999 mem.doNotOptimizeAway(x / 0x1p120);
100100 } else {
lib/compiler_rt/trunc.zig+6-9
......@@ -4,23 +4,20 @@
44//! https://git.musl-libc.org/cgit/musl/tree/src/math/truncf.c
55//! https://git.musl-libc.org/cgit/musl/tree/src/math/trunc.c
66
7const builtin = @import("builtin");
8const arch = builtin.cpu.arch;
9
107const std = @import("std");
118const math = std.math;
129const mem = std.mem;
1310const expect = std.testing.expect;
1411
15const common = @import("common.zig");
16const symbol = @import("../compiler_rt.zig").symbol;
12const compiler_rt = @import("../compiler_rt.zig");
13const symbol = compiler_rt.symbol;
1714
1815comptime {
1916 symbol(&__trunch, "__trunch");
2017 symbol(&truncf, "truncf");
2118 symbol(&trunc, "trunc");
2219 symbol(&__truncx, "__truncx");
23 if (common.want_ppc_abi) {
20 if (compiler_rt.want_ppc_abi) {
2421 symbol(&truncq, "truncf128");
2522 }
2623 symbol(&truncq, "truncq");
......@@ -48,7 +45,7 @@ pub fn truncf(x: f32) callconv(.c) f32 {
4845 if (u & m == 0) {
4946 return x;
5047 } else {
51 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
48 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
5249 return @bitCast(u & ~m);
5350 }
5451}
......@@ -69,7 +66,7 @@ pub fn trunc(x: f64) callconv(.c) f64 {
6966 if (u & m == 0) {
7067 return x;
7168 } else {
72 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
69 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
7370 return @bitCast(u & ~m);
7471 }
7572}
......@@ -95,7 +92,7 @@ pub fn truncq(x: f128) callconv(.c) f128 {
9592 if (u & m == 0) {
9693 return x;
9794 } else {
98 if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
95 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
9996 return @bitCast(u & ~m);
10097 }
10198}
lib/compiler_rt/truncdfhf2.zig+3-3
......@@ -1,15 +1,15 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const truncf = @import("./truncf.zig").truncf;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_d2h, "__aeabi_d2h");
88 }
99 symbol(&__truncdfhf2, "__truncdfhf2");
1010}
1111
12pub fn __truncdfhf2(a: f64) callconv(.c) common.F16T(f64) {
12pub fn __truncdfhf2(a: f64) callconv(.c) compiler_rt.F16T(f64) {
1313 return @bitCast(truncf(f16, f64, a));
1414}
1515
lib/compiler_rt/truncdfsf2.zig+5-4
......@@ -1,11 +1,12 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const truncf = @import("./truncf.zig").truncf;
34
45comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_aeabi) {
7 symbol(&__aeabi_d2f, "__aeabi_d2f");
78 } else {
8 @export(&__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = common.linkage, .visibility = common.visibility });
9 symbol(&__truncdfsf2, "__truncdfsf2");
910 }
1011}
1112
lib/compiler_rt/truncsfhf2.zig+9-8
......@@ -1,20 +1,21 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const truncf = @import("./truncf.zig").truncf;
34
45comptime {
5 if (common.gnu_f16_abi) {
6 @export(&__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_aeabi) {
8 @export(&__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.gnu_f16_abi) {
7 symbol(&__gnu_f2h_ieee, "__gnu_f2h_ieee");
8 } else if (compiler_rt.want_aeabi) {
9 symbol(&__aeabi_f2h, "__aeabi_f2h");
910 }
10 @export(&__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__truncsfhf2, "__truncsfhf2");
1112}
1213
13pub fn __truncsfhf2(a: f32) callconv(.c) common.F16T(f32) {
14pub fn __truncsfhf2(a: f32) callconv(.c) compiler_rt.F16T(f32) {
1415 return @bitCast(truncf(f16, f32, a));
1516}
1617
17fn __gnu_f2h_ieee(a: f32) callconv(.c) common.F16T(f32) {
18fn __gnu_f2h_ieee(a: f32) callconv(.c) compiler_rt.F16T(f32) {
1819 return @bitCast(truncf(f16, f32, a));
1920}
2021
lib/compiler_rt/trunctfdf2.zig+7-6
......@@ -1,13 +1,14 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
2const symbol = compiler_rt.symbol;
23const truncf = @import("./truncf.zig").truncf;
34
45comptime {
5 if (common.want_ppc_abi) {
6 @export(&__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 @export(&_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage, .visibility = common.visibility });
6 if (compiler_rt.want_ppc_abi) {
7 symbol(&__trunctfdf2, "__trunckfdf2");
8 } else if (compiler_rt.want_sparc_abi) {
9 symbol(&_Qp_qtod, "_Qp_qtod");
910 }
10 @export(&__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage, .visibility = common.visibility });
11 symbol(&__trunctfdf2, "__trunctfdf2");
1112}
1213
1314pub fn __trunctfdf2(a: f128) callconv(.c) f64 {
lib/compiler_rt/trunctfhf2.zig+2-2
......@@ -1,4 +1,4 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const truncf = @import("./truncf.zig").truncf;
44
......@@ -6,6 +6,6 @@ comptime {
66 symbol(&__trunctfhf2, "__trunctfhf2");
77}
88
9pub fn __trunctfhf2(a: f128) callconv(.c) common.F16T(f128) {
9pub fn __trunctfhf2(a: f128) callconv(.c) compiler_rt.F16T(f128) {
1010 return @bitCast(truncf(f16, f128, a));
1111}
lib/compiler_rt/trunctfsf2.zig+3-3
......@@ -1,11 +1,11 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const truncf = @import("./truncf.zig").truncf;
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_ppc_abi) {
6 if (compiler_rt.want_ppc_abi) {
77 symbol(&__trunctfsf2, "__trunckfsf2");
8 } else if (common.want_sparc_abi) {
8 } else if (compiler_rt.want_sparc_abi) {
99 symbol(&_Qp_qtos, "_Qp_qtos");
1010 }
1111 symbol(&__trunctfsf2, "__trunctfsf2");
lib/compiler_rt/trunctfxf2.zig+3-2
......@@ -1,9 +1,10 @@
11const math = @import("std").math;
2const common = @import("./common.zig");
2const compiler_rt = @import("../compiler_rt.zig");
3const symbol = compiler_rt.symbol;
34const trunc_f80 = @import("./truncf.zig").trunc_f80;
45
56comptime {
6 @export(&__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = common.linkage, .visibility = common.visibility });
7 symbol(&__trunctfxf2, "__trunctfxf2");
78}
89
910pub fn __trunctfxf2(a: f128) callconv(.c) f80 {
lib/compiler_rt/truncxfhf2.zig+2-2
......@@ -1,4 +1,4 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const symbol = @import("../compiler_rt.zig").symbol;
33const trunc_f80 = @import("./truncf.zig").trunc_f80;
44
......@@ -6,6 +6,6 @@ comptime {
66 symbol(&__truncxfhf2, "__truncxfhf2");
77}
88
9fn __truncxfhf2(a: f80) callconv(.c) common.F16T(f80) {
9fn __truncxfhf2(a: f80) callconv(.c) compiler_rt.F16T(f80) {
1010 return @bitCast(trunc_f80(f16, a));
1111}
lib/compiler_rt/udivmod.zig+102-6
......@@ -1,8 +1,98 @@
1const std = @import("std");
21const builtin = @import("builtin");
2
3const std = @import("std");
34const Log2Int = std.math.Log2Int;
4const common = @import("common.zig");
5const HalveInt = common.HalveInt;
5
6const compiler_rt = @import("../compiler_rt.zig");
7const symbol = compiler_rt.symbol;
8const HalveInt = compiler_rt.HalveInt;
9
10comptime {
11 if (compiler_rt.want_windows_v2u64_abi) {
12 symbol(&__umodti3_windows_x86_64, "__umodti3");
13 symbol(&__modti3_windows_x86_64, "__modti3");
14 symbol(&__udivti3_windows_x86_64, "__udivti3");
15 symbol(&__divti3_windows_x86_64, "__divti3");
16 symbol(&__udivmodti4_windows_x86_64, "__udivmodti4");
17 } else {
18 symbol(&__umodti3, "__umodti3");
19 symbol(&__modti3, "__modti3");
20 symbol(&__udivti3, "__udivti3");
21 symbol(&__divti3, "__divti3");
22 symbol(&__udivmodti4, "__udivmodti4");
23 }
24}
25
26const v128 = @Vector(2, u64);
27const v2u64 = @Vector(2, u64);
28
29pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.c) u128 {
30 return udivmod(u128, a, b, maybe_rem);
31}
32
33fn __udivmodti4_windows_x86_64(a: v2u64, b: v2u64, maybe_rem: ?*u128) callconv(.c) v2u64 {
34 return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), maybe_rem));
35}
36
37pub fn __divti3(a: i128, b: i128) callconv(.c) i128 {
38 return div(a, b);
39}
40
41fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.c) v128 {
42 return @bitCast(div(@bitCast(a), @bitCast(b)));
43}
44
45inline fn div(a: i128, b: i128) i128 {
46 const s_a = a >> (128 - 1);
47 const s_b = b >> (128 - 1);
48
49 const an = (a ^ s_a) -% s_a;
50 const bn = (b ^ s_b) -% s_b;
51
52 const r = udivmod(u128, @bitCast(an), @bitCast(bn), null);
53 const s = s_a ^ s_b;
54 return (@as(i128, @bitCast(r)) ^ s) -% s;
55}
56
57pub fn __udivti3(a: u128, b: u128) callconv(.c) u128 {
58 return udivmod(u128, a, b, null);
59}
60
61fn __udivti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 {
62 return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), null));
63}
64
65pub fn __modti3(a: i128, b: i128) callconv(.c) i128 {
66 return mod(a, b);
67}
68
69fn __modti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 {
70 return @bitCast(mod(@as(i128, @bitCast(a)), @as(i128, @bitCast(b))));
71}
72
73inline fn mod(a: i128, b: i128) i128 {
74 const s_a = a >> (128 - 1); // s = a < 0 ? -1 : 0
75 const s_b = b >> (128 - 1); // s = b < 0 ? -1 : 0
76
77 const an = (a ^ s_a) -% s_a; // negate if s == -1
78 const bn = (b ^ s_b) -% s_b; // negate if s == -1
79
80 var r: u128 = undefined;
81 _ = udivmod(u128, @as(u128, @bitCast(an)), @as(u128, @bitCast(bn)), &r);
82 return (@as(i128, @bitCast(r)) ^ s_a) -% s_a; // negate if s == -1
83}
84
85pub fn __umodti3(a: u128, b: u128) callconv(.c) u128 {
86 var r: u128 = undefined;
87 _ = udivmod(u128, a, b, &r);
88 return r;
89}
90
91fn __umodti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 {
92 var r: u128 = undefined;
93 _ = udivmod(u128, @bitCast(a), @bitCast(b), &r);
94 return @bitCast(r);
95}
696
797const lo = switch (builtin.cpu.arch.endian()) {
898 .big => 1,
......@@ -14,7 +104,7 @@ const hi = 1 - lo;
14104// Returns U / v_ and sets r = U % v_.
15105fn divwide_generic(comptime T: type, _u1: T, _u0: T, v_: T, r: *T) T {
16106 const HalfT = HalveInt(T, false).HalfT;
17 @setRuntimeSafety(common.test_safety);
107 @setRuntimeSafety(compiler_rt.test_safety);
18108 var v = v_;
19109
20110 const b = @as(T, 1) << (@bitSizeOf(T) / 2);
......@@ -70,7 +160,7 @@ fn divwide_generic(comptime T: type, _u1: T, _u0: T, v_: T, r: *T) T {
70160}
71161
72162fn divwide(comptime T: type, _u1: T, _u0: T, v: T, r: *T) T {
73 @setRuntimeSafety(common.test_safety);
163 @setRuntimeSafety(compiler_rt.test_safety);
74164 if (T == u64 and builtin.target.cpu.arch == .x86_64 and builtin.target.os.tag != .windows) {
75165 var rem: T = undefined;
76166 const quo = asm (
......@@ -90,7 +180,7 @@ fn divwide(comptime T: type, _u1: T, _u0: T, v: T, r: *T) T {
90180
91181// Returns a_ / b_ and sets maybe_rem = a_ % b.
92182pub fn udivmod(comptime T: type, a_: T, b_: T, maybe_rem: ?*T) T {
93 @setRuntimeSafety(common.test_safety);
183 @setRuntimeSafety(compiler_rt.test_safety);
94184 const HalfT = HalveInt(T, false).HalfT;
95185 const SignedT = std.meta.Int(.signed, @bitSizeOf(T));
96186
......@@ -147,3 +237,9 @@ pub fn udivmod(comptime T: type, a_: T, b_: T, maybe_rem: ?*T) T {
147237 }
148238 return @bitCast(q);
149239}
240
241test {
242 _ = @import("modti3_test.zig");
243 _ = @import("divti3_test.zig");
244 _ = @import("udivmodti4_test.zig");
245}
lib/compiler_rt/udivmodei4.zig+3-3
......@@ -5,7 +5,7 @@ const std = @import("std");
55const shr = std.math.shr;
66const shl = std.math.shl;
77
8const common = @import("common.zig");
8const compiler_rt = @import("../compiler_rt.zig");
99const symbol = @import("../compiler_rt.zig").symbol;
1010
1111const max_limbs = std.math.divCeil(usize, 65535, 32) catch unreachable; // max supported type is u65535
......@@ -115,7 +115,7 @@ pub fn divmod(q: ?[]u32, r: ?[]u32, u: []const u32, v: []const u32) !void {
115115}
116116
117117pub fn __udivei4(q_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, bits: usize) callconv(.c) void {
118 @setRuntimeSafety(common.test_safety);
118 @setRuntimeSafety(compiler_rt.test_safety);
119119 const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
120120 const q: []u32 = @ptrCast(@alignCast(q_p[0..byte_size]));
121121 const u: []const u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
......@@ -124,7 +124,7 @@ pub fn __udivei4(q_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, bits: usize) ca
124124}
125125
126126pub fn __umodei4(r_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, bits: usize) callconv(.c) void {
127 @setRuntimeSafety(common.test_safety);
127 @setRuntimeSafety(compiler_rt.test_safety);
128128 const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
129129 const r: []u32 = @ptrCast(@alignCast(r_p[0..byte_size]));
130130 const u: []const u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
lib/compiler_rt/udivmodti4.zig deleted-26
......@@ -1,26 +0,0 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const udivmod = @import("udivmod.zig").udivmod;
4const common = @import("common.zig");
5
6comptime {
7 if (common.want_windows_v2u64_abi) {
8 @export(&__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });
9 } else {
10 @export(&__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });
11 }
12}
13
14pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.c) u128 {
15 return udivmod(u128, a, b, maybe_rem);
16}
17
18const v2u64 = @Vector(2, u64);
19
20fn __udivmodti4_windows_x86_64(a: v2u64, b: v2u64, maybe_rem: ?*u128) callconv(.c) v2u64 {
21 return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), maybe_rem));
22}
23
24test {
25 _ = @import("udivmodti4_test.zig");
26}
lib/compiler_rt/udivmodti4_test.zig+1-1
......@@ -1,6 +1,6 @@
11// Disable formatting to avoid unnecessary source repository bloat.
22// zig fmt: off
3const __udivmodti4 = @import("udivmodti4.zig").__udivmodti4;
3const __udivmodti4 = @import("udivmod.zig").__udivmodti4;
44const testing = @import("std").testing;
55
66fn test__udivmodti4(a: u128, b: u128, expected_q: u128, expected_r: u128) !void {
lib/compiler_rt/udivti3.zig deleted-22
......@@ -1,22 +0,0 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const udivmod = @import("udivmod.zig").udivmod;
4const common = @import("common.zig");
5
6comptime {
7 if (common.want_windows_v2u64_abi) {
8 @export(&__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });
9 } else {
10 @export(&__udivti3, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });
11 }
12}
13
14pub fn __udivti3(a: u128, b: u128) callconv(.c) u128 {
15 return udivmod(u128, a, b, null);
16}
17
18const v2u64 = @Vector(2, u64);
19
20fn __udivti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 {
21 return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), null));
22}
lib/compiler_rt/umodti3.zig deleted-26
......@@ -1,26 +0,0 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const udivmod = @import("udivmod.zig").udivmod;
4const common = @import("common.zig");
5
6comptime {
7 if (common.want_windows_v2u64_abi) {
8 @export(&__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });
9 } else {
10 @export(&__umodti3, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });
11 }
12}
13
14pub fn __umodti3(a: u128, b: u128) callconv(.c) u128 {
15 var r: u128 = undefined;
16 _ = udivmod(u128, a, b, &r);
17 return r;
18}
19
20const v2u64 = @Vector(2, u64);
21
22fn __umodti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 {
23 var r: u128 = undefined;
24 _ = udivmod(u128, @bitCast(a), @bitCast(b), &r);
25 return @bitCast(r);
26}
lib/compiler_rt/unorddf2.zig+2-2
......@@ -1,9 +1,9 @@
1const common = @import("./common.zig");
1const compiler_rt = @import("../compiler_rt.zig");
22const comparef = @import("./comparef.zig");
33const symbol = @import("../compiler_rt.zig").symbol;
44
55comptime {
6 if (common.want_aeabi) {
6 if (compiler_rt.want_aeabi) {
77 symbol(&__aeabi_dcmpun, "__aeabi_dcmpun");
88 } else {
99 symbol(&__unorddf2, "__unorddf2");
lib/compiler_rt/unordhf2.zig deleted-10
......@@ -1,10 +0,0 @@
1const common = @import("./common.zig");
2const comparef = @import("./comparef.zig");
3
4comptime {
5 @export(&__unordhf2, .{ .name = "__unordhf2", .linkage = common.linkage, .visibility = common.visibility });
6}
7
8pub fn __unordhf2(a: f16, b: f16) callconv(.c) i32 {
9 return comparef.unordcmp(f16, a, b);
10}
lib/compiler_rt/unordsf2.zig deleted-18
......@@ -1,18 +0,0 @@
1const common = @import("./common.zig");
2const comparef = @import("./comparef.zig");
3
4comptime {
5 if (common.want_aeabi) {
6 @export(&__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = common.linkage, .visibility = common.visibility });
7 } else {
8 @export(&__unordsf2, .{ .name = "__unordsf2", .linkage = common.linkage, .visibility = common.visibility });
9 }
10}
11
12pub fn __unordsf2(a: f32, b: f32) callconv(.c) i32 {
13 return comparef.unordcmp(f32, a, b);
14}
15
16fn __aeabi_fcmpun(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
17 return comparef.unordcmp(f32, a, b);
18}
lib/compiler_rt/unordtf2.zig deleted-16
......@@ -1,16 +0,0 @@
1const common = @import("./common.zig");
2const comparef = @import("./comparef.zig");
3
4comptime {
5 if (common.want_ppc_abi) {
6 @export(&__unordtf2, .{ .name = "__unordkf2", .linkage = common.linkage, .visibility = common.visibility });
7 } else if (common.want_sparc_abi) {
8 // These exports are handled in cmptf2.zig because unordered comparisons
9 // are based on calling _Qp_cmp.
10 }
11 @export(&__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage, .visibility = common.visibility });
12}
13
14fn __unordtf2(a: f128, b: f128) callconv(.c) i32 {
15 return comparef.unordcmp(f128, a, b);
16}
lib/compiler_rt/unordxf2.zig deleted-10
......@@ -1,10 +0,0 @@
1const common = @import("./common.zig");
2const comparef = @import("./comparef.zig");
3
4comptime {
5 @export(&__unordxf2, .{ .name = "__unordxf2", .linkage = common.linkage, .visibility = common.visibility });
6}
7
8pub fn __unordxf2(a: f80, b: f80) callconv(.c) i32 {
9 return comparef.unordcmp(f80, a, b);
10}