╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Air.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2597 // float widening 2598 // to f128 // to f80 // to f64 // to f32 2599 __extendhftf2, __extendhfxf2, __extendhfdf2, __extendhfsf2, // from f16 2600 __extendsftf2, __extendsfxf2, __extendsfdf2, // from f32 2601 __extenddftf2, __extenddfxf2, // from f64 2602 __extendxftf2, // from f80 2603 2604 // int to float 2605 __floatsihf, __floatsisf, __floatsidf, __floatsixf, __floatsitf, // i32 to float 2606 __floatdihf, __floatdisf, __floatdidf, __floatdixf, __floatditf, // i64 to float 2607 __floattihf, __floattisf, __floattidf, __floattixf, __floattitf, // i128 to float 2608 __floateihf, __floateisf, __floateidf, __floateixf, __floateitf, // arbitrary iN to float 2609 __floatunsihf, __floatunsisf, __floatunsidf, __floatunsixf, __floatunsitf, // u32 to float 2610 __floatundihf, __floatundisf, __floatundidf, __floatundixf, __floatunditf, // u64 to float 2611 __floatuntihf, __floatuntisf, __floatuntidf, __floatuntixf, __floatuntitf, // u128 to float 2612 __floatuneihf, __floatuneisf, __floatuneidf, __floatuneixf, __floatuneitf, // arbitrary uN to float 2613 2614 // float to int 2615 __fixhfsi, __fixsfsi, __fixdfsi, __fixxfsi, __fixtfsi, // float to i32 2616 __fixhfdi, __fixsfdi, __fixdfdi, __fixxfdi, __fixtfdi, // float to i64 2617 __fixhfti, __fixsfti, __fixdfti, __fixxfti, __fixtfti, // float to i128 2618 __fixhfei, __fixsfei, __fixdfei, __fixxfei, __fixtfei, // float to arbitray iN 2619 __fixunshfsi, __fixunssfsi, __fixunsdfsi, __fixunsxfsi, __fixunstfsi, // float to u32 2620 __fixunshfdi, __fixunssfdi, __fixunsdfdi, __fixunsxfdi, __fixunstfdi, // float to u64 2621 __fixunshfti, __fixunssfti, __fixunsdfti, __fixunsxfti, __fixunstfti, // float to u128 2622 __fixunshfei, __fixunssfei, __fixunsdfei, __fixunsxfei, __fixunstfei, // float to arbitray uN 2623 2624 // zig fmt: on 2625 2626 /// Usually, the tag names of `CompilerRtFunc` match the corresponding symbol name, but not 2627 /// always; some target triples have slightly different compiler-rt ABIs for one reason or 2628 /// another. 2629 pub fn name(f: CompilerRtFunc, target: *const std.Target) []const u8 { 2630 const use_gnu_f16_abi = switch (target.cpu.arch) { 2631 .wasm32, 2632 .wasm64, 2633 .riscv64, 2634 .riscv64be, 2635 .riscv32, 2636 .riscv32be, 2637 => false, 2638 .x86, .x86_64 => true, 2639 .arm, .armeb, .thumb, .thumbeb => switch (target.abi) { 2640 .eabi, .eabihf => false, 2641 else => true, 2642 }, 2643 else => !target.os.tag.isDarwin(), 2644 }; 2645 const use_aeabi = target.cpu.arch.isArm() and switch (target.abi) { 2646 .eabi, 2647 .eabihf, 2648 .musleabi, 2649 .musleabihf, 2650 .gnueabi, 2651 .gnueabihf, 2652 .android, 2653 .androideabi, 2654 => true, 2655 else => false, 2656 }; 2657 2658 // GNU didn't like the standard names specifically for conversions between f16 2659 // and f32, so decided to make their own naming convention with blackjack and 2660 // hookers (but only use it on a few random targets of course). This overrides 2661 // the ARM EABI in some cases. I don't like GNU. 2662 if (use_gnu_f16_abi) switch (f) { 2663 .__truncsfhf2 => return "__gnu_f2h_ieee", 2664 .__extendhfsf2 => return "__gnu_h2f_ieee", 2665 else => {}, 2666 }; 2667 2668 if (use_aeabi) return switch (f) { 2669 .__addsf3 => "__aeabi_fadd", 2670 .__adddf3 => "__aeabi_dadd", 2671 .__subsf3 => "__aeabi_fsub", 2672 .__subdf3 => "__aeabi_dsub", 2673 .__mulsf3 => "__aeabi_fmul", 2674 .__muldf3 => "__aeabi_dmul", 2675 .__divsf3 => "__aeabi_fdiv", 2676 .__divdf3 => "__aeabi_ddiv", 2677 .__truncdfhf2 => "__aeabi_d2h", 2678 .__truncdfsf2 => "__aeabi_d2f", 2679 .__truncsfhf2 => "__aeabi_f2h", 2680 .__extendsfdf2 => "__aeabi_f2d", 2681 .__extendhfsf2 => "__aeabi_h2f", 2682 .__floatsisf => "__aeabi_i2f", 2683 .__floatsidf => "__aeabi_i2d", 2684 .__floatdisf => "__aeabi_l2f", 2685 .__floatdidf => "__aeabi_l2d", 2686 .__floatunsisf => "__aeabi_ui2f", 2687 .__floatunsidf => "__aeabi_ui2d", 2688 .__floatundisf => "__aeabi_ul2f", 2689 .__floatundidf => "__aeabi_ul2d", 2690 .__fixsfsi => "__aeabi_f2iz", 2691 .__fixdfsi => "__aeabi_d2iz", 2692 .__fixsfdi => "__aeabi_f2lz", 2693 .__fixdfdi => "__aeabi_d2lz", 2694 .__fixunssfsi => "__aeabi_f2uiz", 2695 .__fixunsdfsi => "__aeabi_d2uiz", 2696 .__fixunssfdi => "__aeabi_f2ulz", 2697 .__fixunsdfdi => "__aeabi_d2ulz", 2698 2699 // These functions are not available on AEABI. The AEABI equivalents are 2700 // separate fields rather than aliases because they have a different ABI. 2701 .__eqsf2, .__eqdf2 => unreachable, 2702 .__nesf2, .__nedf2 => unreachable, 2703 .__ltsf2, .__ltdf2 => unreachable, 2704 .__lesf2, .__ledf2 => unreachable, 2705 .__gtsf2, .__gtdf2 => unreachable, 2706 .__gesf2, .__gedf2 => unreachable, 2707 2708 else => @tagName(f), 2709 }; 2710 2711 return switch (f) { 2712 // These functions are only available on AEABI. 2713 .__aeabi_fcmpeq, .__aeabi_dcmpeq => unreachable, 2714 .__aeabi_fcmplt, .__aeabi_dcmplt => unreachable, 2715 .__aeabi_fcmple, .__aeabi_dcmple => unreachable, 2716 .__aeabi_fcmpgt, .__aeabi_dcmpgt => unreachable, 2717 .__aeabi_fcmpge, .__aeabi_dcmpge => unreachable, 2718 2719 else => @tagName(f), 2720 }; 2721 } 2722 2723 pub fn @"callconv"(f: CompilerRtFunc, target: *const std.Target) std.lang.CallingConvention { 2724 const use_gnu_f16_abi = switch (target.cpu.arch) { 2725 .wasm32, 2726 .wasm64, 2727 .riscv64, 2728 .riscv64be, 2729 .riscv32, 2730 .riscv32be, 2731 => false, 2732 .x86, .x86_64 => true, 2733 .arm, .armeb, .thumb, .thumbeb => switch (target.abi) { 2734 .eabi, .eabihf => false, 2735 else => true, 2736 }, 2737 else => !target.os.tag.isDarwin(), 2738 }; 2739 const use_aeabi = target.cpu.arch.isArm() and switch (target.abi) { 2740 .eabi, 2741 .eabihf, 2742 .musleabi, 2743 .musleabihf, 2744 .gnueabi, 2745 .gnueabihf, 2746 .android, 2747 .androideabi, 2748 => true, 2749 else => false, 2750 }; 2751 2752 if (use_gnu_f16_abi) switch (f) { 2753 .__truncsfhf2, 2754 .__extendhfsf2, 2755 => return target.cCallingConvention().?, 2756 else => {}, 2757 }; 2758 2759 if (use_aeabi) switch (f) { 2760 // zig fmt: off 2761 .__addsf3, .__adddf3, .__subsf3, .__subdf3, 2762 .__mulsf3, .__muldf3, .__divsf3, .__divdf3, 2763 .__truncdfhf2, .__truncdfsf2, .__truncsfhf2, 2764 .__extendsfdf2, .__extendhfsf2, 2765 .__floatsisf, .__floatsidf, .__floatdisf, .__floatdidf, 2766 .__floatunsisf, .__floatunsidf, .__floatundisf, .__floatundidf, 2767 .__fixsfsi, .__fixdfsi, .__fixsfdi, .__fixdfdi, 2768 .__fixunssfsi, .__fixunsdfsi, .__fixunssfdi, .__fixunsdfdi, 2769 => return .{ .arm_aapcs = .{} }, 2770 // zig fmt: on 2771 else => {}, 2772 }; 2773 2774 return target.cCallingConvention().?; 2775 } 2776 2777 pub fn returnType(f: CompilerRtFunc) Type { 2778 return switch (f) { 2779 .__addhf3, .__subhf3, .__mulhf3, .__divhf3 => .f16, 2780 .__addsf3, .__subsf3, .__mulsf3, .__divsf3 => .f32, 2781 .__adddf3, .__subdf3, .__muldf3, .__divdf3 => .f64, 2782 .__addxf3, .__subxf3, .__mulxf3, .__divxf3 => .f80, 2783 .__addtf3, .__subtf3, .__multf3, .__divtf3 => .f128, 2784 2785 // zig fmt: off 2786 .__fminh, .__fmaxh, 2787 .__ceilh, .__floorh, .__trunch, .__roundh, 2788 .__logh, .__log2h, .__log10h, 2789 .__exph, .__exp2h, 2790 .__sinh, .__cosh, .__tanh, 2791 .__fabsh, .__sqrth, .__fmodh, .__fmah, 2792 => .f16, 2793 .fminf, .fmaxf, 2794 .ceilf, .floorf, .truncf, .roundf, 2795 .logf, .log2f, .log10f, 2796 .expf, .exp2f, 2797 .sinf, .cosf, .tanf, 2798 .fabsf, .sqrtf, .fmodf, .fmaf, 2799 => .f32, 2800 .fmin, .fmax, 2801 .ceil, .floor, .trunc, .round, 2802 .log, .log2, .log10, 2803 .exp, .exp2, 2804 .sin, .cos, .tan, 2805 .fabs, .sqrt, .fmod, .fma, 2806 => .f64, 2807 .__fminx, .__fmaxx, 2808 .__ceilx, .__floorx, .__truncx, .__roundx, 2809 .__logx, .__log2x, .__log10x, 2810 .__expx, .__exp2x, 2811 .__sinx, .__cosx, .__tanx, 2812 .__fabsx, .__sqrtx, .__fmodx, .__fmax, 2813 => .f80, 2814 .fminq, .fmaxq, 2815 .ceilq, .floorq, .truncq, .roundq, 2816 .logq, .log2q, .log10q, 2817 .expq, .exp2q, 2818 .sinq, .cosq, .tanq, 2819 .fabsq, .sqrtq, .fmodq, .fmaq, 2820 => .f128, 2821 // zig fmt: on 2822 2823 .__eqhf2, .__eqsf2, .__eqdf2, .__eqxf2, .__eqtf2 => .i32, 2824 .__nehf2, .__nesf2, .__nedf2, .__nexf2, .__netf2 => .i32, 2825 .__lthf2, .__ltsf2, .__ltdf2, .__ltxf2, .__lttf2 => .i32, 2826 .__lehf2, .__lesf2, .__ledf2, .__lexf2, .__letf2 => .i32, 2827 .__gthf2, .__gtsf2, .__gtdf2, .__gtxf2, .__gttf2 => .i32, 2828 .__gehf2, .__gesf2, .__gedf2, .__gexf2, .__getf2 => .i32, 2829 2830 .__aeabi_fcmpeq, .__aeabi_dcmpeq => .i32, 2831 .__aeabi_fcmplt, .__aeabi_dcmplt => .i32, 2832 .__aeabi_fcmple, .__aeabi_dcmple => .i32, 2833 .__aeabi_fcmpgt, .__aeabi_dcmpgt => .i32, 2834 .__aeabi_fcmpge, .__aeabi_dcmpge => .i32, 2835 2836 .__trunctfhf2, .__truncxfhf2, .__truncdfhf2, .__truncsfhf2 => .f16, 2837 .__trunctfsf2, .__truncxfsf2, .__truncdfsf2 => .f32, 2838 .__trunctfdf2, .__truncxfdf2 => .f64, 2839 .__trunctfxf2 => .f80, 2840 2841 .__extendhftf2, .__extendsftf2, .__extenddftf2, .__extendxftf2 => .f128, 2842 .__extendhfxf2, .__extendsfxf2, .__extenddfxf2 => .f80, 2843 .__extendhfdf2, .__extendsfdf2 => .f64, 2844 .__extendhfsf2 => .f32, 2845 2846 .__floatsihf, .__floatdihf, .__floattihf, .__floateihf => .f16, 2847 .__floatsisf, .__floatdisf, .__floattisf, .__floateisf => .f32, 2848 .__floatsidf, .__floatdidf, .__floattidf, .__floateidf => .f64, 2849 .__floatsixf, .__floatdixf, .__floattixf, .__floateixf => .f80, 2850 .__floatsitf, .__floatditf, .__floattitf, .__floateitf => .f128, 2851 .__floatunsihf, .__floatundihf, .__floatuntihf, .__floatuneihf => .f16, 2852 .__floatunsisf, .__floatundisf, .__floatuntisf, .__floatuneisf => .f32, 2853 .__floatunsidf, .__floatundidf, .__floatuntidf, .__floatuneidf => .f64, 2854 .__floatunsixf, .__floatundixf, .__floatuntixf, .__floatuneixf => .f80, 2855 .__floatunsitf, .__floatunditf, .__floatuntitf, .__floatuneitf => .f128, 2856 2857 .__fixhfsi, .__fixsfsi, .__fixdfsi, .__fixxfsi, .__fixtfsi => .i32, 2858 .__fixhfdi, .__fixsfdi, .__fixdfdi, .__fixxfdi, .__fixtfdi => .i64, 2859 .__fixhfti, .__fixsfti, .__fixdfti, .__fixxfti, .__fixtfti => .i128, 2860 .__fixhfei, .__fixsfei, .__fixdfei, .__fixxfei, .__fixtfei => .void, 2861 .__fixunshfsi, .__fixunssfsi, .__fixunsdfsi, .__fixunsxfsi, .__fixunstfsi => .u32, 2862 .__fixunshfdi, .__fixunssfdi, .__fixunsdfdi, .__fixunsxfdi, .__fixunstfdi => .u64, 2863 .__fixunshfti, .__fixunssfti, .__fixunsdfti, .__fixunsxfti, .__fixunstfti => .u128, 2864 .__fixunshfei, .__fixunssfei, .__fixunsdfei, .__fixunsxfei, .__fixunstfei => .void, 2865 }; 2866 } 2867 }; 2868