| author | |
| committer | |
| log | 80790be3094f65877231209532c04f7fdb4441a7 |
| tree | 10c677f0bc95053c7fde3fb64d11c41f455faa90 |
| parent | 33cf6ef621114daad63d14067b6ff374e664d410 |
70 files changed, 2003 insertions(+), 1133 deletions(-)
lib/compiler_rt.zig+61-872| ... | @@ -1,542 +1,69 @@ | ... | @@ -1,542 +1,69 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 2 | pub const panic = @import("compiler_rt/common.zig").panic; |
| 4 | const os_tag = builtin.os.tag; | ||
| 5 | const arch = builtin.cpu.arch; | ||
| 6 | const abi = builtin.abi; | ||
| 7 | |||
| 8 | const is_gnu = abi.isGnu(); | ||
| 9 | const is_mingw = os_tag == .windows and is_gnu; | ||
| 10 | const is_darwin = std.Target.Os.Tag.isDarwin(os_tag); | ||
| 11 | const is_ppc = arch.isPPC() or arch.isPPC64(); | ||
| 12 | |||
| 13 | const linkage = if (is_test) | ||
| 14 | std.builtin.GlobalLinkage.Internal | ||
| 15 | else | ||
| 16 | std.builtin.GlobalLinkage.Weak; | ||
| 17 | |||
| 18 | const strong_linkage = if (is_test) | ||
| 19 | std.builtin.GlobalLinkage.Internal | ||
| 20 | else | ||
| 21 | std.builtin.GlobalLinkage.Strong; | ||
| 22 | 3 | ||
| 23 | comptime { | 4 | comptime { |
| 24 | // These files do their own comptime exporting logic. | 5 | // These files do their own comptime exporting logic. |
| 25 | _ = @import("compiler_rt/atomics.zig"); | 6 | _ = @import("compiler_rt/atomics.zig"); |
| 26 | if (builtin.zig_backend != .stage2_llvm) { // TODO | 7 | _ = @import("compiler_rt/sin.zig"); |
| 27 | _ = @import("compiler_rt/clear_cache.zig").clear_cache; | 8 | _ = @import("compiler_rt/cos.zig"); |
| 28 | } | 9 | _ = @import("compiler_rt/sincos.zig"); |
| 29 | 10 | _ = @import("compiler_rt/ceil.zig"); | |
| 30 | const __extenddftf2 = @import("compiler_rt/extendXfYf2.zig").__extenddftf2; | 11 | _ = @import("compiler_rt/exp.zig"); |
| 31 | @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage }); | 12 | _ = @import("compiler_rt/exp2.zig"); |
| 32 | const __extendsftf2 = @import("compiler_rt/extendXfYf2.zig").__extendsftf2; | 13 | _ = @import("compiler_rt/fabs.zig"); |
| 33 | @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = linkage }); | 14 | _ = @import("compiler_rt/floor.zig"); |
| 34 | const __extendhfsf2 = @import("compiler_rt/extendXfYf2.zig").__extendhfsf2; | 15 | _ = @import("compiler_rt/fma.zig"); |
| 35 | @export(__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = linkage }); | 16 | _ = @import("compiler_rt/fmax.zig"); |
| 36 | const __extendhftf2 = @import("compiler_rt/extendXfYf2.zig").__extendhftf2; | 17 | _ = @import("compiler_rt/fmin.zig"); |
| 37 | @export(__extendhftf2, .{ .name = "__extendhftf2", .linkage = linkage }); | 18 | _ = @import("compiler_rt/fmod.zig"); |
| 38 | 19 | _ = @import("compiler_rt/log.zig"); | |
| 39 | const __extendhfxf2 = @import("compiler_rt/extend_f80.zig").__extendhfxf2; | 20 | _ = @import("compiler_rt/log10.zig"); |
| 40 | @export(__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = linkage }); | 21 | _ = @import("compiler_rt/log2.zig"); |
| 41 | const __extendsfxf2 = @import("compiler_rt/extend_f80.zig").__extendsfxf2; | 22 | _ = @import("compiler_rt/round.zig"); |
| 42 | @export(__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = linkage }); | 23 | _ = @import("compiler_rt/sqrt.zig"); |
| 43 | const __extenddfxf2 = @import("compiler_rt/extend_f80.zig").__extenddfxf2; | 24 | _ = @import("compiler_rt/tan.zig"); |
| 44 | @export(__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = linkage }); | 25 | _ = @import("compiler_rt/trunc.zig"); |
| 45 | const __extendxftf2 = @import("compiler_rt/extend_f80.zig").__extendxftf2; | 26 | _ = @import("compiler_rt/extendXfYf2.zig"); |
| 46 | @export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = linkage }); | 27 | _ = @import("compiler_rt/extend_f80.zig"); |
| 47 | 28 | _ = @import("compiler_rt/compareXf2.zig"); | |
| 48 | const __lesf2 = @import("compiler_rt/compareXf2.zig").__lesf2; | 29 | _ = @import("compiler_rt/stack_probe.zig"); |
| 49 | @export(__lesf2, .{ .name = "__lesf2", .linkage = linkage }); | 30 | _ = @import("compiler_rt/divti3.zig"); |
| 50 | const __ledf2 = @import("compiler_rt/compareXf2.zig").__ledf2; | 31 | _ = @import("compiler_rt/modti3.zig"); |
| 51 | @export(__ledf2, .{ .name = "__ledf2", .linkage = linkage }); | 32 | _ = @import("compiler_rt/multi3.zig"); |
| 52 | const __letf2 = @import("compiler_rt/compareXf2.zig").__letf2; | 33 | _ = @import("compiler_rt/udivti3.zig"); |
| 53 | @export(__letf2, .{ .name = "__letf2", .linkage = linkage }); | 34 | _ = @import("compiler_rt/udivmodti4.zig"); |
| 54 | const __lexf2 = @import("compiler_rt/compareXf2.zig").__lexf2; | 35 | _ = @import("compiler_rt/umodti3.zig"); |
| 55 | @export(__lexf2, .{ .name = "__lexf2", .linkage = linkage }); | 36 | _ = @import("compiler_rt/truncXfYf2.zig"); |
| 56 | 37 | _ = @import("compiler_rt/trunc_f80.zig"); | |
| 57 | const __gesf2 = @import("compiler_rt/compareXf2.zig").__gesf2; | 38 | _ = @import("compiler_rt/addXf3.zig"); |
| 58 | @export(__gesf2, .{ .name = "__gesf2", .linkage = linkage }); | 39 | _ = @import("compiler_rt/mulXf3.zig"); |
| 59 | const __gedf2 = @import("compiler_rt/compareXf2.zig").__gedf2; | 40 | _ = @import("compiler_rt/divsf3.zig"); |
| 60 | @export(__gedf2, .{ .name = "__gedf2", .linkage = linkage }); | 41 | _ = @import("compiler_rt/divdf3.zig"); |
| 61 | const __getf2 = @import("compiler_rt/compareXf2.zig").__getf2; | 42 | _ = @import("compiler_rt/divxf3.zig"); |
| 62 | @export(__getf2, .{ .name = "__getf2", .linkage = linkage }); | 43 | _ = @import("compiler_rt/divtf3.zig"); |
| 63 | const __gexf2 = @import("compiler_rt/compareXf2.zig").__gexf2; | 44 | _ = @import("compiler_rt/floatXiYf.zig"); |
| 64 | @export(__gexf2, .{ .name = "__gexf2", .linkage = linkage }); | 45 | _ = @import("compiler_rt/fixXfYi.zig"); |
| 65 | 46 | _ = @import("compiler_rt/count0bits.zig"); | |
| 66 | const __eqsf2 = @import("compiler_rt/compareXf2.zig").__eqsf2; | 47 | _ = @import("compiler_rt/parity.zig"); |
| 67 | @export(__eqsf2, .{ .name = "__eqsf2", .linkage = linkage }); | 48 | _ = @import("compiler_rt/popcount.zig"); |
| 68 | const __eqdf2 = @import("compiler_rt/compareXf2.zig").__eqdf2; | 49 | _ = @import("compiler_rt/bswap.zig"); |
| 69 | @export(__eqdf2, .{ .name = "__eqdf2", .linkage = linkage }); | 50 | _ = @import("compiler_rt/int.zig"); |
| 70 | const __eqxf2 = @import("compiler_rt/compareXf2.zig").__eqxf2; | 51 | _ = @import("compiler_rt/shift.zig"); |
| 71 | @export(__eqxf2, .{ .name = "__eqxf2", .linkage = linkage }); | 52 | _ = @import("compiler_rt/negXi2.zig"); |
| 72 | 53 | _ = @import("compiler_rt/muldi3.zig"); | |
| 73 | const __ltsf2 = @import("compiler_rt/compareXf2.zig").__ltsf2; | 54 | _ = @import("compiler_rt/absv.zig"); |
| 74 | @export(__ltsf2, .{ .name = "__ltsf2", .linkage = linkage }); | 55 | _ = @import("compiler_rt/negv.zig"); |
| 75 | const __ltdf2 = @import("compiler_rt/compareXf2.zig").__ltdf2; | 56 | _ = @import("compiler_rt/addo.zig"); |
| 76 | @export(__ltdf2, .{ .name = "__ltdf2", .linkage = linkage }); | 57 | _ = @import("compiler_rt/subo.zig"); |
| 77 | const __ltxf2 = @import("compiler_rt/compareXf2.zig").__ltxf2; | 58 | _ = @import("compiler_rt/mulo.zig"); |
| 78 | @export(__ltxf2, .{ .name = "__ltxf2", .linkage = linkage }); | 59 | _ = @import("compiler_rt/cmp.zig"); |
| 79 | 60 | _ = @import("compiler_rt/negXf2.zig"); | |
| 80 | const __nesf2 = @import("compiler_rt/compareXf2.zig").__nesf2; | 61 | _ = @import("compiler_rt/os_version_check.zig"); |
| 81 | @export(__nesf2, .{ .name = "__nesf2", .linkage = linkage }); | 62 | _ = @import("compiler_rt/emutls.zig"); |
| 82 | const __nedf2 = @import("compiler_rt/compareXf2.zig").__nedf2; | 63 | _ = @import("compiler_rt/arm.zig"); |
| 83 | @export(__nedf2, .{ .name = "__nedf2", .linkage = linkage }); | 64 | _ = @import("compiler_rt/aulldiv.zig"); |
| 84 | const __nexf2 = @import("compiler_rt/compareXf2.zig").__nexf2; | 65 | _ = @import("compiler_rt/sparc.zig"); |
| 85 | @export(__nexf2, .{ .name = "__nexf2", .linkage = linkage }); | 66 | _ = @import("compiler_rt/clear_cache.zig"); |
| 86 | |||
| 87 | const __gtsf2 = @import("compiler_rt/compareXf2.zig").__gtsf2; | ||
| 88 | @export(__gtsf2, .{ .name = "__gtsf2", .linkage = linkage }); | ||
| 89 | const __gtdf2 = @import("compiler_rt/compareXf2.zig").__gtdf2; | ||
| 90 | @export(__gtdf2, .{ .name = "__gtdf2", .linkage = linkage }); | ||
| 91 | const __gtxf2 = @import("compiler_rt/compareXf2.zig").__gtxf2; | ||
| 92 | @export(__gtxf2, .{ .name = "__gtxf2", .linkage = linkage }); | ||
| 93 | |||
| 94 | if (!is_test) { | ||
| 95 | @export(__lesf2, .{ .name = "__cmpsf2", .linkage = linkage }); | ||
| 96 | @export(__ledf2, .{ .name = "__cmpdf2", .linkage = linkage }); | ||
| 97 | @export(__letf2, .{ .name = "__cmptf2", .linkage = linkage }); | ||
| 98 | @export(__letf2, .{ .name = "__eqtf2", .linkage = linkage }); | ||
| 99 | @export(__letf2, .{ .name = "__lttf2", .linkage = linkage }); | ||
| 100 | @export(__getf2, .{ .name = "__gttf2", .linkage = linkage }); | ||
| 101 | @export(__letf2, .{ .name = "__netf2", .linkage = linkage }); | ||
| 102 | @export(__extendhfsf2, .{ .name = "__gnu_h2f_ieee", .linkage = linkage }); | ||
| 103 | } | ||
| 104 | |||
| 105 | if (builtin.os.tag == .windows) { | ||
| 106 | // Default stack-probe functions emitted by LLVM | ||
| 107 | if (is_mingw) { | ||
| 108 | const _chkstk = @import("compiler_rt/stack_probe.zig")._chkstk; | ||
| 109 | @export(_chkstk, .{ .name = "_alloca", .linkage = strong_linkage }); | ||
| 110 | const ___chkstk_ms = @import("compiler_rt/stack_probe.zig").___chkstk_ms; | ||
| 111 | @export(___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = strong_linkage }); | ||
| 112 | } else if (!builtin.link_libc) { | ||
| 113 | // This symbols are otherwise exported by MSVCRT.lib | ||
| 114 | const _chkstk = @import("compiler_rt/stack_probe.zig")._chkstk; | ||
| 115 | @export(_chkstk, .{ .name = "_chkstk", .linkage = strong_linkage }); | ||
| 116 | const __chkstk = @import("compiler_rt/stack_probe.zig").__chkstk; | ||
| 117 | @export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage }); | ||
| 118 | } | ||
| 119 | |||
| 120 | switch (arch) { | ||
| 121 | .i386 => { | ||
| 122 | const __divti3 = @import("compiler_rt/divti3.zig").__divti3; | ||
| 123 | @export(__divti3, .{ .name = "__divti3", .linkage = linkage }); | ||
| 124 | const __modti3 = @import("compiler_rt/modti3.zig").__modti3; | ||
| 125 | @export(__modti3, .{ .name = "__modti3", .linkage = linkage }); | ||
| 126 | const __multi3 = @import("compiler_rt/multi3.zig").__multi3; | ||
| 127 | @export(__multi3, .{ .name = "__multi3", .linkage = linkage }); | ||
| 128 | const __udivti3 = @import("compiler_rt/udivti3.zig").__udivti3; | ||
| 129 | @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage }); | ||
| 130 | const __udivmodti4 = @import("compiler_rt/udivmodti4.zig").__udivmodti4; | ||
| 131 | @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage }); | ||
| 132 | const __umodti3 = @import("compiler_rt/umodti3.zig").__umodti3; | ||
| 133 | @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage }); | ||
| 134 | }, | ||
| 135 | .x86_64 => { | ||
| 136 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | ||
| 137 | // that LLVM expects compiler-rt to have. | ||
| 138 | const __divti3_windows_x86_64 = @import("compiler_rt/divti3.zig").__divti3_windows_x86_64; | ||
| 139 | @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = linkage }); | ||
| 140 | const __modti3_windows_x86_64 = @import("compiler_rt/modti3.zig").__modti3_windows_x86_64; | ||
| 141 | @export(__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = linkage }); | ||
| 142 | const __multi3_windows_x86_64 = @import("compiler_rt/multi3.zig").__multi3_windows_x86_64; | ||
| 143 | @export(__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = linkage }); | ||
| 144 | const __udivti3_windows_x86_64 = @import("compiler_rt/udivti3.zig").__udivti3_windows_x86_64; | ||
| 145 | @export(__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = linkage }); | ||
| 146 | const __udivmodti4_windows_x86_64 = @import("compiler_rt/udivmodti4.zig").__udivmodti4_windows_x86_64; | ||
| 147 | @export(__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = linkage }); | ||
| 148 | const __umodti3_windows_x86_64 = @import("compiler_rt/umodti3.zig").__umodti3_windows_x86_64; | ||
| 149 | @export(__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = linkage }); | ||
| 150 | }, | ||
| 151 | else => {}, | ||
| 152 | } | ||
| 153 | if (arch.isAARCH64()) { | ||
| 154 | const __chkstk = @import("compiler_rt/stack_probe.zig").__chkstk; | ||
| 155 | @export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage }); | ||
| 156 | const __divti3_windows = @import("compiler_rt/divti3.zig").__divti3; | ||
| 157 | @export(__divti3_windows, .{ .name = "__divti3", .linkage = linkage }); | ||
| 158 | const __modti3 = @import("compiler_rt/modti3.zig").__modti3; | ||
| 159 | @export(__modti3, .{ .name = "__modti3", .linkage = linkage }); | ||
| 160 | const __udivti3_windows = @import("compiler_rt/udivti3.zig").__udivti3; | ||
| 161 | @export(__udivti3_windows, .{ .name = "__udivti3", .linkage = linkage }); | ||
| 162 | const __umodti3 = @import("compiler_rt/umodti3.zig").__umodti3; | ||
| 163 | @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage }); | ||
| 164 | } | ||
| 165 | } else { | ||
| 166 | const __divti3 = @import("compiler_rt/divti3.zig").__divti3; | ||
| 167 | @export(__divti3, .{ .name = "__divti3", .linkage = linkage }); | ||
| 168 | const __modti3 = @import("compiler_rt/modti3.zig").__modti3; | ||
| 169 | @export(__modti3, .{ .name = "__modti3", .linkage = linkage }); | ||
| 170 | const __multi3 = @import("compiler_rt/multi3.zig").__multi3; | ||
| 171 | @export(__multi3, .{ .name = "__multi3", .linkage = linkage }); | ||
| 172 | const __udivti3 = @import("compiler_rt/udivti3.zig").__udivti3; | ||
| 173 | @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage }); | ||
| 174 | const __udivmodti4 = @import("compiler_rt/udivmodti4.zig").__udivmodti4; | ||
| 175 | @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage }); | ||
| 176 | const __umodti3 = @import("compiler_rt/umodti3.zig").__umodti3; | ||
| 177 | @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage }); | ||
| 178 | } | ||
| 179 | |||
| 180 | const __truncdfhf2 = @import("compiler_rt/truncXfYf2.zig").__truncdfhf2; | ||
| 181 | @export(__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = linkage }); | ||
| 182 | const __trunctfhf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfhf2; | ||
| 183 | @export(__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = linkage }); | ||
| 184 | const __trunctfdf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfdf2; | ||
| 185 | @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = linkage }); | ||
| 186 | const __trunctfsf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfsf2; | ||
| 187 | @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = linkage }); | ||
| 188 | |||
| 189 | const __truncdfsf2 = @import("compiler_rt/truncXfYf2.zig").__truncdfsf2; | ||
| 190 | @export(__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = linkage }); | ||
| 191 | |||
| 192 | const __truncxfhf2 = @import("compiler_rt/trunc_f80.zig").__truncxfhf2; | ||
| 193 | @export(__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = linkage }); | ||
| 194 | const __truncxfsf2 = @import("compiler_rt/trunc_f80.zig").__truncxfsf2; | ||
| 195 | @export(__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = linkage }); | ||
| 196 | const __truncxfdf2 = @import("compiler_rt/trunc_f80.zig").__truncxfdf2; | ||
| 197 | @export(__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = linkage }); | ||
| 198 | const __trunctfxf2 = @import("compiler_rt/trunc_f80.zig").__trunctfxf2; | ||
| 199 | @export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage }); | ||
| 200 | |||
| 201 | switch (arch) { | ||
| 202 | .i386, | ||
| 203 | .x86_64, | ||
| 204 | => { | ||
| 205 | const zig_probe_stack = @import("compiler_rt/stack_probe.zig").zig_probe_stack; | ||
| 206 | @export(zig_probe_stack, .{ | ||
| 207 | .name = "__zig_probe_stack", | ||
| 208 | .linkage = linkage, | ||
| 209 | }); | ||
| 210 | }, | ||
| 211 | else => {}, | ||
| 212 | } | ||
| 213 | |||
| 214 | const __unordsf2 = @import("compiler_rt/compareXf2.zig").__unordsf2; | ||
| 215 | @export(__unordsf2, .{ .name = "__unordsf2", .linkage = linkage }); | ||
| 216 | const __unorddf2 = @import("compiler_rt/compareXf2.zig").__unorddf2; | ||
| 217 | @export(__unorddf2, .{ .name = "__unorddf2", .linkage = linkage }); | ||
| 218 | const __unordtf2 = @import("compiler_rt/compareXf2.zig").__unordtf2; | ||
| 219 | @export(__unordtf2, .{ .name = "__unordtf2", .linkage = linkage }); | ||
| 220 | |||
| 221 | const __addsf3 = @import("compiler_rt/addXf3.zig").__addsf3; | ||
| 222 | @export(__addsf3, .{ .name = "__addsf3", .linkage = linkage }); | ||
| 223 | const __adddf3 = @import("compiler_rt/addXf3.zig").__adddf3; | ||
| 224 | @export(__adddf3, .{ .name = "__adddf3", .linkage = linkage }); | ||
| 225 | const __addxf3 = @import("compiler_rt/addXf3.zig").__addxf3; | ||
| 226 | @export(__addxf3, .{ .name = "__addxf3", .linkage = linkage }); | ||
| 227 | const __addtf3 = @import("compiler_rt/addXf3.zig").__addtf3; | ||
| 228 | @export(__addtf3, .{ .name = "__addtf3", .linkage = linkage }); | ||
| 229 | |||
| 230 | const __subsf3 = @import("compiler_rt/addXf3.zig").__subsf3; | ||
| 231 | @export(__subsf3, .{ .name = "__subsf3", .linkage = linkage }); | ||
| 232 | const __subdf3 = @import("compiler_rt/addXf3.zig").__subdf3; | ||
| 233 | @export(__subdf3, .{ .name = "__subdf3", .linkage = linkage }); | ||
| 234 | const __subxf3 = @import("compiler_rt/addXf3.zig").__subxf3; | ||
| 235 | @export(__subxf3, .{ .name = "__subxf3", .linkage = linkage }); | ||
| 236 | const __subtf3 = @import("compiler_rt/addXf3.zig").__subtf3; | ||
| 237 | @export(__subtf3, .{ .name = "__subtf3", .linkage = linkage }); | ||
| 238 | |||
| 239 | const __mulsf3 = @import("compiler_rt/mulXf3.zig").__mulsf3; | ||
| 240 | @export(__mulsf3, .{ .name = "__mulsf3", .linkage = linkage }); | ||
| 241 | const __muldf3 = @import("compiler_rt/mulXf3.zig").__muldf3; | ||
| 242 | @export(__muldf3, .{ .name = "__muldf3", .linkage = linkage }); | ||
| 243 | const __mulxf3 = @import("compiler_rt/mulXf3.zig").__mulxf3; | ||
| 244 | @export(__mulxf3, .{ .name = "__mulxf3", .linkage = linkage }); | ||
| 245 | const __multf3 = @import("compiler_rt/mulXf3.zig").__multf3; | ||
| 246 | @export(__multf3, .{ .name = "__multf3", .linkage = linkage }); | ||
| 247 | |||
| 248 | const __divsf3 = @import("compiler_rt/divsf3.zig").__divsf3; | ||
| 249 | @export(__divsf3, .{ .name = "__divsf3", .linkage = linkage }); | ||
| 250 | const __divdf3 = @import("compiler_rt/divdf3.zig").__divdf3; | ||
| 251 | @export(__divdf3, .{ .name = "__divdf3", .linkage = linkage }); | ||
| 252 | const __divxf3 = @import("compiler_rt/divxf3.zig").__divxf3; | ||
| 253 | @export(__divxf3, .{ .name = "__divxf3", .linkage = linkage }); | ||
| 254 | const __divtf3 = @import("compiler_rt/divtf3.zig").__divtf3; | ||
| 255 | @export(__divtf3, .{ .name = "__divtf3", .linkage = linkage }); | ||
| 256 | |||
| 257 | // Integer Bit operations | ||
| 258 | const __clzsi2 = @import("compiler_rt/count0bits.zig").__clzsi2; | ||
| 259 | @export(__clzsi2, .{ .name = "__clzsi2", .linkage = linkage }); | ||
| 260 | const __clzdi2 = @import("compiler_rt/count0bits.zig").__clzdi2; | ||
| 261 | @export(__clzdi2, .{ .name = "__clzdi2", .linkage = linkage }); | ||
| 262 | const __clzti2 = @import("compiler_rt/count0bits.zig").__clzti2; | ||
| 263 | @export(__clzti2, .{ .name = "__clzti2", .linkage = linkage }); | ||
| 264 | const __ctzsi2 = @import("compiler_rt/count0bits.zig").__ctzsi2; | ||
| 265 | @export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = linkage }); | ||
| 266 | const __ctzdi2 = @import("compiler_rt/count0bits.zig").__ctzdi2; | ||
| 267 | @export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = linkage }); | ||
| 268 | const __ctzti2 = @import("compiler_rt/count0bits.zig").__ctzti2; | ||
| 269 | @export(__ctzti2, .{ .name = "__ctzti2", .linkage = linkage }); | ||
| 270 | const __ffssi2 = @import("compiler_rt/count0bits.zig").__ffssi2; | ||
| 271 | @export(__ffssi2, .{ .name = "__ffssi2", .linkage = linkage }); | ||
| 272 | const __ffsdi2 = @import("compiler_rt/count0bits.zig").__ffsdi2; | ||
| 273 | @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = linkage }); | ||
| 274 | const __ffsti2 = @import("compiler_rt/count0bits.zig").__ffsti2; | ||
| 275 | @export(__ffsti2, .{ .name = "__ffsti2", .linkage = linkage }); | ||
| 276 | const __paritysi2 = @import("compiler_rt/parity.zig").__paritysi2; | ||
| 277 | @export(__paritysi2, .{ .name = "__paritysi2", .linkage = linkage }); | ||
| 278 | const __paritydi2 = @import("compiler_rt/parity.zig").__paritydi2; | ||
| 279 | @export(__paritydi2, .{ .name = "__paritydi2", .linkage = linkage }); | ||
| 280 | const __parityti2 = @import("compiler_rt/parity.zig").__parityti2; | ||
| 281 | @export(__parityti2, .{ .name = "__parityti2", .linkage = linkage }); | ||
| 282 | const __popcountsi2 = @import("compiler_rt/popcount.zig").__popcountsi2; | ||
| 283 | @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = linkage }); | ||
| 284 | const __popcountdi2 = @import("compiler_rt/popcount.zig").__popcountdi2; | ||
| 285 | @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = linkage }); | ||
| 286 | const __popcountti2 = @import("compiler_rt/popcount.zig").__popcountti2; | ||
| 287 | @export(__popcountti2, .{ .name = "__popcountti2", .linkage = linkage }); | ||
| 288 | const __bswapsi2 = @import("compiler_rt/bswap.zig").__bswapsi2; | ||
| 289 | @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = linkage }); | ||
| 290 | const __bswapdi2 = @import("compiler_rt/bswap.zig").__bswapdi2; | ||
| 291 | @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = linkage }); | ||
| 292 | const __bswapti2 = @import("compiler_rt/bswap.zig").__bswapti2; | ||
| 293 | @export(__bswapti2, .{ .name = "__bswapti2", .linkage = linkage }); | ||
| 294 | |||
| 295 | // Integral -> Float Conversion | ||
| 296 | |||
| 297 | // Conversion to f32 | ||
| 298 | const __floatsisf = @import("compiler_rt/floatXiYf.zig").__floatsisf; | ||
| 299 | @export(__floatsisf, .{ .name = "__floatsisf", .linkage = linkage }); | ||
| 300 | const __floatunsisf = @import("compiler_rt/floatXiYf.zig").__floatunsisf; | ||
| 301 | @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage }); | ||
| 302 | |||
| 303 | const __floatundisf = @import("compiler_rt/floatXiYf.zig").__floatundisf; | ||
| 304 | @export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage }); | ||
| 305 | const __floatdisf = @import("compiler_rt/floatXiYf.zig").__floatdisf; | ||
| 306 | @export(__floatdisf, .{ .name = "__floatdisf", .linkage = linkage }); | ||
| 307 | |||
| 308 | const __floattisf = @import("compiler_rt/floatXiYf.zig").__floattisf; | ||
| 309 | @export(__floattisf, .{ .name = "__floattisf", .linkage = linkage }); | ||
| 310 | const __floatuntisf = @import("compiler_rt/floatXiYf.zig").__floatuntisf; | ||
| 311 | @export(__floatuntisf, .{ .name = "__floatuntisf", .linkage = linkage }); | ||
| 312 | |||
| 313 | // Conversion to f64 | ||
| 314 | const __floatsidf = @import("compiler_rt/floatXiYf.zig").__floatsidf; | ||
| 315 | @export(__floatsidf, .{ .name = "__floatsidf", .linkage = linkage }); | ||
| 316 | const __floatunsidf = @import("compiler_rt/floatXiYf.zig").__floatunsidf; | ||
| 317 | @export(__floatunsidf, .{ .name = "__floatunsidf", .linkage = linkage }); | ||
| 318 | |||
| 319 | const __floatdidf = @import("compiler_rt/floatXiYf.zig").__floatdidf; | ||
| 320 | @export(__floatdidf, .{ .name = "__floatdidf", .linkage = linkage }); | ||
| 321 | const __floatundidf = @import("compiler_rt/floatXiYf.zig").__floatundidf; | ||
| 322 | @export(__floatundidf, .{ .name = "__floatundidf", .linkage = linkage }); | ||
| 323 | |||
| 324 | const __floattidf = @import("compiler_rt/floatXiYf.zig").__floattidf; | ||
| 325 | @export(__floattidf, .{ .name = "__floattidf", .linkage = linkage }); | ||
| 326 | const __floatuntidf = @import("compiler_rt/floatXiYf.zig").__floatuntidf; | ||
| 327 | @export(__floatuntidf, .{ .name = "__floatuntidf", .linkage = linkage }); | ||
| 328 | |||
| 329 | // Conversion to f80 | ||
| 330 | const __floatsixf = @import("compiler_rt/floatXiYf.zig").__floatsixf; | ||
| 331 | @export(__floatsixf, .{ .name = "__floatsixf", .linkage = linkage }); | ||
| 332 | const __floatunsixf = @import("compiler_rt/floatXiYf.zig").__floatunsixf; | ||
| 333 | @export(__floatunsixf, .{ .name = "__floatunsixf", .linkage = linkage }); | ||
| 334 | |||
| 335 | const __floatdixf = @import("compiler_rt/floatXiYf.zig").__floatdixf; | ||
| 336 | @export(__floatdixf, .{ .name = "__floatdixf", .linkage = linkage }); | ||
| 337 | const __floatundixf = @import("compiler_rt/floatXiYf.zig").__floatundixf; | ||
| 338 | @export(__floatundixf, .{ .name = "__floatundixf", .linkage = linkage }); | ||
| 339 | |||
| 340 | const __floattixf = @import("compiler_rt/floatXiYf.zig").__floattixf; | ||
| 341 | @export(__floattixf, .{ .name = "__floattixf", .linkage = linkage }); | ||
| 342 | const __floatuntixf = @import("compiler_rt/floatXiYf.zig").__floatuntixf; | ||
| 343 | @export(__floatuntixf, .{ .name = "__floatuntixf", .linkage = linkage }); | ||
| 344 | |||
| 345 | // Conversion to f128 | ||
| 346 | const __floatsitf = @import("compiler_rt/floatXiYf.zig").__floatsitf; | ||
| 347 | @export(__floatsitf, .{ .name = "__floatsitf", .linkage = linkage }); | ||
| 348 | const __floatunsitf = @import("compiler_rt/floatXiYf.zig").__floatunsitf; | ||
| 349 | @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = linkage }); | ||
| 350 | |||
| 351 | const __floatditf = @import("compiler_rt/floatXiYf.zig").__floatditf; | ||
| 352 | @export(__floatditf, .{ .name = "__floatditf", .linkage = linkage }); | ||
| 353 | const __floatunditf = @import("compiler_rt/floatXiYf.zig").__floatunditf; | ||
| 354 | @export(__floatunditf, .{ .name = "__floatunditf", .linkage = linkage }); | ||
| 355 | |||
| 356 | const __floattitf = @import("compiler_rt/floatXiYf.zig").__floattitf; | ||
| 357 | @export(__floattitf, .{ .name = "__floattitf", .linkage = linkage }); | ||
| 358 | const __floatuntitf = @import("compiler_rt/floatXiYf.zig").__floatuntitf; | ||
| 359 | @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = linkage }); | ||
| 360 | |||
| 361 | // Float -> Integral Conversion | ||
| 362 | |||
| 363 | // Conversion from f32 | ||
| 364 | const __fixsfsi = @import("compiler_rt/fixXfYi.zig").__fixsfsi; | ||
| 365 | @export(__fixsfsi, .{ .name = "__fixsfsi", .linkage = linkage }); | ||
| 366 | const __fixunssfsi = @import("compiler_rt/fixXfYi.zig").__fixunssfsi; | ||
| 367 | @export(__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = linkage }); | ||
| 368 | |||
| 369 | const __fixsfdi = @import("compiler_rt/fixXfYi.zig").__fixsfdi; | ||
| 370 | @export(__fixsfdi, .{ .name = "__fixsfdi", .linkage = linkage }); | ||
| 371 | const __fixunssfdi = @import("compiler_rt/fixXfYi.zig").__fixunssfdi; | ||
| 372 | @export(__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = linkage }); | ||
| 373 | |||
| 374 | const __fixsfti = @import("compiler_rt/fixXfYi.zig").__fixsfti; | ||
| 375 | @export(__fixsfti, .{ .name = "__fixsfti", .linkage = linkage }); | ||
| 376 | const __fixunssfti = @import("compiler_rt/fixXfYi.zig").__fixunssfti; | ||
| 377 | @export(__fixunssfti, .{ .name = "__fixunssfti", .linkage = linkage }); | ||
| 378 | |||
| 379 | // Conversion from f64 | ||
| 380 | const __fixdfsi = @import("compiler_rt/fixXfYi.zig").__fixdfsi; | ||
| 381 | @export(__fixdfsi, .{ .name = "__fixdfsi", .linkage = linkage }); | ||
| 382 | const __fixunsdfsi = @import("compiler_rt/fixXfYi.zig").__fixunsdfsi; | ||
| 383 | @export(__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = linkage }); | ||
| 384 | |||
| 385 | const __fixdfdi = @import("compiler_rt/fixXfYi.zig").__fixdfdi; | ||
| 386 | @export(__fixdfdi, .{ .name = "__fixdfdi", .linkage = linkage }); | ||
| 387 | const __fixunsdfdi = @import("compiler_rt/fixXfYi.zig").__fixunsdfdi; | ||
| 388 | @export(__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = linkage }); | ||
| 389 | |||
| 390 | const __fixdfti = @import("compiler_rt/fixXfYi.zig").__fixdfti; | ||
| 391 | @export(__fixdfti, .{ .name = "__fixdfti", .linkage = linkage }); | ||
| 392 | const __fixunsdfti = @import("compiler_rt/fixXfYi.zig").__fixunsdfti; | ||
| 393 | @export(__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = linkage }); | ||
| 394 | |||
| 395 | // Conversion from f80 | ||
| 396 | const __fixxfsi = @import("compiler_rt/fixXfYi.zig").__fixxfsi; | ||
| 397 | @export(__fixxfsi, .{ .name = "__fixxfsi", .linkage = linkage }); | ||
| 398 | const __fixunsxfsi = @import("compiler_rt/fixXfYi.zig").__fixunsxfsi; | ||
| 399 | @export(__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = linkage }); | ||
| 400 | |||
| 401 | const __fixxfdi = @import("compiler_rt/fixXfYi.zig").__fixxfdi; | ||
| 402 | @export(__fixxfdi, .{ .name = "__fixxfdi", .linkage = linkage }); | ||
| 403 | const __fixunsxfdi = @import("compiler_rt/fixXfYi.zig").__fixunsxfdi; | ||
| 404 | @export(__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = linkage }); | ||
| 405 | |||
| 406 | const __fixxfti = @import("compiler_rt/fixXfYi.zig").__fixxfti; | ||
| 407 | @export(__fixxfti, .{ .name = "__fixxfti", .linkage = linkage }); | ||
| 408 | const __fixunsxfti = @import("compiler_rt/fixXfYi.zig").__fixunsxfti; | ||
| 409 | @export(__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = linkage }); | ||
| 410 | |||
| 411 | // Conversion from f128 | ||
| 412 | const __fixtfsi = @import("compiler_rt/fixXfYi.zig").__fixtfsi; | ||
| 413 | @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = linkage }); | ||
| 414 | const __fixunstfsi = @import("compiler_rt/fixXfYi.zig").__fixunstfsi; | ||
| 415 | @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = linkage }); | ||
| 416 | |||
| 417 | const __fixtfdi = @import("compiler_rt/fixXfYi.zig").__fixtfdi; | ||
| 418 | @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = linkage }); | ||
| 419 | const __fixunstfdi = @import("compiler_rt/fixXfYi.zig").__fixunstfdi; | ||
| 420 | @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = linkage }); | ||
| 421 | |||
| 422 | const __fixtfti = @import("compiler_rt/fixXfYi.zig").__fixtfti; | ||
| 423 | @export(__fixtfti, .{ .name = "__fixtfti", .linkage = linkage }); | ||
| 424 | const __fixunstfti = @import("compiler_rt/fixXfYi.zig").__fixunstfti; | ||
| 425 | @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = linkage }); | ||
| 426 | |||
| 427 | const __udivmoddi4 = @import("compiler_rt/int.zig").__udivmoddi4; | ||
| 428 | @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = linkage }); | ||
| 429 | |||
| 430 | const __truncsfhf2 = @import("compiler_rt/truncXfYf2.zig").__truncsfhf2; | ||
| 431 | @export(__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = linkage }); | ||
| 432 | if (!is_test) { | ||
| 433 | @export(__truncsfhf2, .{ .name = "__gnu_f2h_ieee", .linkage = linkage }); | ||
| 434 | } | ||
| 435 | const __extendsfdf2 = @import("compiler_rt/extendXfYf2.zig").__extendsfdf2; | ||
| 436 | @export(__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = linkage }); | ||
| 437 | |||
| 438 | if (is_darwin) { | ||
| 439 | const __isPlatformVersionAtLeast = @import("compiler_rt/os_version_check.zig").__isPlatformVersionAtLeast; | ||
| 440 | @export(__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage }); | ||
| 441 | } | ||
| 442 | |||
| 443 | // Integer Arithmetic | ||
| 444 | const __ashldi3 = @import("compiler_rt/shift.zig").__ashldi3; | ||
| 445 | @export(__ashldi3, .{ .name = "__ashldi3", .linkage = linkage }); | ||
| 446 | const __ashlti3 = @import("compiler_rt/shift.zig").__ashlti3; | ||
| 447 | @export(__ashlti3, .{ .name = "__ashlti3", .linkage = linkage }); | ||
| 448 | const __ashrdi3 = @import("compiler_rt/shift.zig").__ashrdi3; | ||
| 449 | @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = linkage }); | ||
| 450 | const __ashrti3 = @import("compiler_rt/shift.zig").__ashrti3; | ||
| 451 | @export(__ashrti3, .{ .name = "__ashrti3", .linkage = linkage }); | ||
| 452 | const __lshrdi3 = @import("compiler_rt/shift.zig").__lshrdi3; | ||
| 453 | @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = linkage }); | ||
| 454 | const __lshrti3 = @import("compiler_rt/shift.zig").__lshrti3; | ||
| 455 | @export(__lshrti3, .{ .name = "__lshrti3", .linkage = linkage }); | ||
| 456 | const __negsi2 = @import("compiler_rt/negXi2.zig").__negsi2; | ||
| 457 | @export(__negsi2, .{ .name = "__negsi2", .linkage = linkage }); | ||
| 458 | const __negdi2 = @import("compiler_rt/negXi2.zig").__negdi2; | ||
| 459 | @export(__negdi2, .{ .name = "__negdi2", .linkage = linkage }); | ||
| 460 | const __negti2 = @import("compiler_rt/negXi2.zig").__negti2; | ||
| 461 | @export(__negti2, .{ .name = "__negti2", .linkage = linkage }); | ||
| 462 | |||
| 463 | const __mulsi3 = @import("compiler_rt/int.zig").__mulsi3; | ||
| 464 | @export(__mulsi3, .{ .name = "__mulsi3", .linkage = linkage }); | ||
| 465 | const __muldi3 = @import("compiler_rt/muldi3.zig").__muldi3; | ||
| 466 | @export(__muldi3, .{ .name = "__muldi3", .linkage = linkage }); | ||
| 467 | const __divmoddi4 = @import("compiler_rt/int.zig").__divmoddi4; | ||
| 468 | @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = linkage }); | ||
| 469 | const __divsi3 = @import("compiler_rt/int.zig").__divsi3; | ||
| 470 | @export(__divsi3, .{ .name = "__divsi3", .linkage = linkage }); | ||
| 471 | const __divdi3 = @import("compiler_rt/int.zig").__divdi3; | ||
| 472 | @export(__divdi3, .{ .name = "__divdi3", .linkage = linkage }); | ||
| 473 | const __udivsi3 = @import("compiler_rt/int.zig").__udivsi3; | ||
| 474 | @export(__udivsi3, .{ .name = "__udivsi3", .linkage = linkage }); | ||
| 475 | const __udivdi3 = @import("compiler_rt/int.zig").__udivdi3; | ||
| 476 | @export(__udivdi3, .{ .name = "__udivdi3", .linkage = linkage }); | ||
| 477 | const __modsi3 = @import("compiler_rt/int.zig").__modsi3; | ||
| 478 | @export(__modsi3, .{ .name = "__modsi3", .linkage = linkage }); | ||
| 479 | const __moddi3 = @import("compiler_rt/int.zig").__moddi3; | ||
| 480 | @export(__moddi3, .{ .name = "__moddi3", .linkage = linkage }); | ||
| 481 | const __umodsi3 = @import("compiler_rt/int.zig").__umodsi3; | ||
| 482 | @export(__umodsi3, .{ .name = "__umodsi3", .linkage = linkage }); | ||
| 483 | const __umoddi3 = @import("compiler_rt/int.zig").__umoddi3; | ||
| 484 | @export(__umoddi3, .{ .name = "__umoddi3", .linkage = linkage }); | ||
| 485 | const __divmodsi4 = @import("compiler_rt/int.zig").__divmodsi4; | ||
| 486 | @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = linkage }); | ||
| 487 | const __udivmodsi4 = @import("compiler_rt/int.zig").__udivmodsi4; | ||
| 488 | @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = linkage }); | ||
| 489 | |||
| 490 | // Integer Arithmetic with trapping overflow | ||
| 491 | const __absvsi2 = @import("compiler_rt/absv.zig").__absvsi2; | ||
| 492 | @export(__absvsi2, .{ .name = "__absvsi2", .linkage = linkage }); | ||
| 493 | const __absvdi2 = @import("compiler_rt/absv.zig").__absvdi2; | ||
| 494 | @export(__absvdi2, .{ .name = "__absvdi2", .linkage = linkage }); | ||
| 495 | const __absvti2 = @import("compiler_rt/absv.zig").__absvti2; | ||
| 496 | @export(__absvti2, .{ .name = "__absvti2", .linkage = linkage }); | ||
| 497 | const __negvsi2 = @import("compiler_rt/negv.zig").__negvsi2; | ||
| 498 | @export(__negvsi2, .{ .name = "__negvsi2", .linkage = linkage }); | ||
| 499 | const __negvdi2 = @import("compiler_rt/negv.zig").__negvdi2; | ||
| 500 | @export(__negvdi2, .{ .name = "__negvdi2", .linkage = linkage }); | ||
| 501 | const __negvti2 = @import("compiler_rt/negv.zig").__negvti2; | ||
| 502 | @export(__negvti2, .{ .name = "__negvti2", .linkage = linkage }); | ||
| 503 | |||
| 504 | // Integer arithmetic which returns if overflow | ||
| 505 | const __addosi4 = @import("compiler_rt/addo.zig").__addosi4; | ||
| 506 | @export(__addosi4, .{ .name = "__addosi4", .linkage = linkage }); | ||
| 507 | const __addodi4 = @import("compiler_rt/addo.zig").__addodi4; | ||
| 508 | @export(__addodi4, .{ .name = "__addodi4", .linkage = linkage }); | ||
| 509 | const __addoti4 = @import("compiler_rt/addo.zig").__addoti4; | ||
| 510 | @export(__addoti4, .{ .name = "__addoti4", .linkage = linkage }); | ||
| 511 | const __subosi4 = @import("compiler_rt/subo.zig").__subosi4; | ||
| 512 | @export(__subosi4, .{ .name = "__subosi4", .linkage = linkage }); | ||
| 513 | const __subodi4 = @import("compiler_rt/subo.zig").__subodi4; | ||
| 514 | @export(__subodi4, .{ .name = "__subodi4", .linkage = linkage }); | ||
| 515 | const __suboti4 = @import("compiler_rt/subo.zig").__suboti4; | ||
| 516 | @export(__suboti4, .{ .name = "__suboti4", .linkage = linkage }); | ||
| 517 | const __mulosi4 = @import("compiler_rt/mulo.zig").__mulosi4; | ||
| 518 | @export(__mulosi4, .{ .name = "__mulosi4", .linkage = linkage }); | ||
| 519 | const __mulodi4 = @import("compiler_rt/mulo.zig").__mulodi4; | ||
| 520 | @export(__mulodi4, .{ .name = "__mulodi4", .linkage = linkage }); | ||
| 521 | const __muloti4 = @import("compiler_rt/mulo.zig").__muloti4; | ||
| 522 | @export(__muloti4, .{ .name = "__muloti4", .linkage = linkage }); | ||
| 523 | |||
| 524 | // Integer Comparison | ||
| 525 | // (a < b) => 0 | ||
| 526 | // (a == b) => 1 | ||
| 527 | // (a > b) => 2 | ||
| 528 | const __cmpsi2 = @import("compiler_rt/cmp.zig").__cmpsi2; | ||
| 529 | @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = linkage }); | ||
| 530 | const __cmpdi2 = @import("compiler_rt/cmp.zig").__cmpdi2; | ||
| 531 | @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = linkage }); | ||
| 532 | const __cmpti2 = @import("compiler_rt/cmp.zig").__cmpti2; | ||
| 533 | @export(__cmpti2, .{ .name = "__cmpti2", .linkage = linkage }); | ||
| 534 | const __ucmpsi2 = @import("compiler_rt/cmp.zig").__ucmpsi2; | ||
| 535 | @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = linkage }); | ||
| 536 | const __ucmpdi2 = @import("compiler_rt/cmp.zig").__ucmpdi2; | ||
| 537 | @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = linkage }); | ||
| 538 | const __ucmpti2 = @import("compiler_rt/cmp.zig").__ucmpti2; | ||
| 539 | @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = linkage }); | ||
| 540 | 67 | ||
| 541 | // missing: Floating point raised to integer power | 68 | // missing: Floating point raised to integer power |
| 542 | 69 | ||
| ... | @@ -544,342 +71,4 @@ comptime { | ... | @@ -544,342 +71,4 @@ comptime { |
| 544 | // (a + ib) * (c + id) | 71 | // (a + ib) * (c + id) |
| 545 | // (a + ib) / (c + id) | 72 | // (a + ib) / (c + id) |
| 546 | 73 | ||
| 547 | const __negsf2 = @import("compiler_rt/negXf2.zig").__negsf2; | ||
| 548 | @export(__negsf2, .{ .name = "__negsf2", .linkage = linkage }); | ||
| 549 | const __negdf2 = @import("compiler_rt/negXf2.zig").__negdf2; | ||
| 550 | @export(__negdf2, .{ .name = "__negdf2", .linkage = linkage }); | ||
| 551 | |||
| 552 | if (builtin.link_libc and os_tag == .openbsd) { | ||
| 553 | const __emutls_get_address = @import("compiler_rt/emutls.zig").__emutls_get_address; | ||
| 554 | @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage }); | ||
| 555 | } | ||
| 556 | |||
| 557 | if ((arch.isARM() or arch.isThumb()) and !is_test) { | ||
| 558 | const __aeabi_unwind_cpp_pr0 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr0; | ||
| 559 | @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage }); | ||
| 560 | const __aeabi_unwind_cpp_pr1 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr1; | ||
| 561 | @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage }); | ||
| 562 | const __aeabi_unwind_cpp_pr2 = @import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr2; | ||
| 563 | @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage }); | ||
| 564 | |||
| 565 | @export(__muldi3, .{ .name = "__aeabi_lmul", .linkage = linkage }); | ||
| 566 | |||
| 567 | const __aeabi_ldivmod = @import("compiler_rt/arm.zig").__aeabi_ldivmod; | ||
| 568 | @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = linkage }); | ||
| 569 | const __aeabi_uldivmod = @import("compiler_rt/arm.zig").__aeabi_uldivmod; | ||
| 570 | @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = linkage }); | ||
| 571 | |||
| 572 | @export(__divsi3, .{ .name = "__aeabi_idiv", .linkage = linkage }); | ||
| 573 | const __aeabi_idivmod = @import("compiler_rt/arm.zig").__aeabi_idivmod; | ||
| 574 | @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = linkage }); | ||
| 575 | @export(__udivsi3, .{ .name = "__aeabi_uidiv", .linkage = linkage }); | ||
| 576 | const __aeabi_uidivmod = @import("compiler_rt/arm.zig").__aeabi_uidivmod; | ||
| 577 | @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = linkage }); | ||
| 578 | |||
| 579 | const __aeabi_memcpy = @import("compiler_rt/arm.zig").__aeabi_memcpy; | ||
| 580 | @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = linkage }); | ||
| 581 | @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy4", .linkage = linkage }); | ||
| 582 | @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy8", .linkage = linkage }); | ||
| 583 | |||
| 584 | const __aeabi_memmove = @import("compiler_rt/arm.zig").__aeabi_memmove; | ||
| 585 | @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = linkage }); | ||
| 586 | @export(__aeabi_memmove, .{ .name = "__aeabi_memmove4", .linkage = linkage }); | ||
| 587 | @export(__aeabi_memmove, .{ .name = "__aeabi_memmove8", .linkage = linkage }); | ||
| 588 | |||
| 589 | const __aeabi_memset = @import("compiler_rt/arm.zig").__aeabi_memset; | ||
| 590 | @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = linkage }); | ||
| 591 | @export(__aeabi_memset, .{ .name = "__aeabi_memset4", .linkage = linkage }); | ||
| 592 | @export(__aeabi_memset, .{ .name = "__aeabi_memset8", .linkage = linkage }); | ||
| 593 | |||
| 594 | const __aeabi_memclr = @import("compiler_rt/arm.zig").__aeabi_memclr; | ||
| 595 | @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = linkage }); | ||
| 596 | @export(__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage }); | ||
| 597 | @export(__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage }); | ||
| 598 | |||
| 599 | if (os_tag == .linux) { | ||
| 600 | const __aeabi_read_tp = @import("compiler_rt/arm.zig").__aeabi_read_tp; | ||
| 601 | @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage }); | ||
| 602 | } | ||
| 603 | |||
| 604 | const __aeabi_f2d = @import("compiler_rt/extendXfYf2.zig").__aeabi_f2d; | ||
| 605 | @export(__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage }); | ||
| 606 | const __aeabi_i2d = @import("compiler_rt/floatXiYf.zig").__aeabi_i2d; | ||
| 607 | @export(__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage }); | ||
| 608 | const __aeabi_l2d = @import("compiler_rt/floatXiYf.zig").__aeabi_l2d; | ||
| 609 | @export(__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage }); | ||
| 610 | const __aeabi_l2f = @import("compiler_rt/floatXiYf.zig").__aeabi_l2f; | ||
| 611 | @export(__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = linkage }); | ||
| 612 | const __aeabi_ui2d = @import("compiler_rt/floatXiYf.zig").__aeabi_ui2d; | ||
| 613 | @export(__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = linkage }); | ||
| 614 | const __aeabi_ul2d = @import("compiler_rt/floatXiYf.zig").__aeabi_ul2d; | ||
| 615 | @export(__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = linkage }); | ||
| 616 | const __aeabi_ui2f = @import("compiler_rt/floatXiYf.zig").__aeabi_ui2f; | ||
| 617 | @export(__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = linkage }); | ||
| 618 | const __aeabi_ul2f = @import("compiler_rt/floatXiYf.zig").__aeabi_ul2f; | ||
| 619 | @export(__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = linkage }); | ||
| 620 | |||
| 621 | const __aeabi_fneg = @import("compiler_rt/negXf2.zig").__aeabi_fneg; | ||
| 622 | @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = linkage }); | ||
| 623 | const __aeabi_dneg = @import("compiler_rt/negXf2.zig").__aeabi_dneg; | ||
| 624 | @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = linkage }); | ||
| 625 | |||
| 626 | const __aeabi_fmul = @import("compiler_rt/mulXf3.zig").__aeabi_fmul; | ||
| 627 | @export(__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = linkage }); | ||
| 628 | const __aeabi_dmul = @import("compiler_rt/mulXf3.zig").__aeabi_dmul; | ||
| 629 | @export(__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = linkage }); | ||
| 630 | |||
| 631 | const __aeabi_d2h = @import("compiler_rt/truncXfYf2.zig").__aeabi_d2h; | ||
| 632 | @export(__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = linkage }); | ||
| 633 | |||
| 634 | const __aeabi_f2ulz = @import("compiler_rt/fixXfYi.zig").__aeabi_f2ulz; | ||
| 635 | @export(__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = linkage }); | ||
| 636 | const __aeabi_d2ulz = @import("compiler_rt/fixXfYi.zig").__aeabi_d2ulz; | ||
| 637 | @export(__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = linkage }); | ||
| 638 | |||
| 639 | const __aeabi_f2lz = @import("compiler_rt/fixXfYi.zig").__aeabi_f2lz; | ||
| 640 | @export(__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = linkage }); | ||
| 641 | const __aeabi_d2lz = @import("compiler_rt/fixXfYi.zig").__aeabi_d2lz; | ||
| 642 | @export(__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = linkage }); | ||
| 643 | |||
| 644 | const __aeabi_d2uiz = @import("compiler_rt/fixXfYi.zig").__aeabi_d2uiz; | ||
| 645 | @export(__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = linkage }); | ||
| 646 | |||
| 647 | const __aeabi_h2f = @import("compiler_rt/extendXfYf2.zig").__aeabi_h2f; | ||
| 648 | @export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = linkage }); | ||
| 649 | const __aeabi_f2h = @import("compiler_rt/truncXfYf2.zig").__aeabi_f2h; | ||
| 650 | @export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = linkage }); | ||
| 651 | |||
| 652 | const __aeabi_i2f = @import("compiler_rt/floatXiYf.zig").__aeabi_i2f; | ||
| 653 | @export(__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = linkage }); | ||
| 654 | const __aeabi_d2f = @import("compiler_rt/truncXfYf2.zig").__aeabi_d2f; | ||
| 655 | @export(__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = linkage }); | ||
| 656 | |||
| 657 | const __aeabi_fadd = @import("compiler_rt/addXf3.zig").__aeabi_fadd; | ||
| 658 | @export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = linkage }); | ||
| 659 | const __aeabi_dadd = @import("compiler_rt/addXf3.zig").__aeabi_dadd; | ||
| 660 | @export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = linkage }); | ||
| 661 | const __aeabi_fsub = @import("compiler_rt/addXf3.zig").__aeabi_fsub; | ||
| 662 | @export(__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = linkage }); | ||
| 663 | const __aeabi_dsub = @import("compiler_rt/addXf3.zig").__aeabi_dsub; | ||
| 664 | @export(__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = linkage }); | ||
| 665 | |||
| 666 | const __aeabi_f2uiz = @import("compiler_rt/fixXfYi.zig").__aeabi_f2uiz; | ||
| 667 | @export(__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = linkage }); | ||
| 668 | |||
| 669 | const __aeabi_f2iz = @import("compiler_rt/fixXfYi.zig").__aeabi_f2iz; | ||
| 670 | @export(__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = linkage }); | ||
| 671 | const __aeabi_d2iz = @import("compiler_rt/fixXfYi.zig").__aeabi_d2iz; | ||
| 672 | @export(__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = linkage }); | ||
| 673 | |||
| 674 | const __aeabi_fdiv = @import("compiler_rt/divsf3.zig").__aeabi_fdiv; | ||
| 675 | @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = linkage }); | ||
| 676 | const __aeabi_ddiv = @import("compiler_rt/divdf3.zig").__aeabi_ddiv; | ||
| 677 | @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = linkage }); | ||
| 678 | |||
| 679 | const __aeabi_llsl = @import("compiler_rt/shift.zig").__aeabi_llsl; | ||
| 680 | @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = linkage }); | ||
| 681 | const __aeabi_lasr = @import("compiler_rt/shift.zig").__aeabi_lasr; | ||
| 682 | @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = linkage }); | ||
| 683 | const __aeabi_llsr = @import("compiler_rt/shift.zig").__aeabi_llsr; | ||
| 684 | @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = linkage }); | ||
| 685 | |||
| 686 | const __aeabi_fcmpeq = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpeq; | ||
| 687 | @export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = linkage }); | ||
| 688 | const __aeabi_fcmplt = @import("compiler_rt/compareXf2.zig").__aeabi_fcmplt; | ||
| 689 | @export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = linkage }); | ||
| 690 | const __aeabi_fcmple = @import("compiler_rt/compareXf2.zig").__aeabi_fcmple; | ||
| 691 | @export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = linkage }); | ||
| 692 | const __aeabi_fcmpge = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpge; | ||
| 693 | @export(__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = linkage }); | ||
| 694 | const __aeabi_fcmpgt = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpgt; | ||
| 695 | @export(__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = linkage }); | ||
| 696 | const __aeabi_fcmpun = @import("compiler_rt/compareXf2.zig").__aeabi_fcmpun; | ||
| 697 | @export(__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = linkage }); | ||
| 698 | |||
| 699 | const __aeabi_dcmpeq = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpeq; | ||
| 700 | @export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = linkage }); | ||
| 701 | const __aeabi_dcmplt = @import("compiler_rt/compareXf2.zig").__aeabi_dcmplt; | ||
| 702 | @export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = linkage }); | ||
| 703 | const __aeabi_dcmple = @import("compiler_rt/compareXf2.zig").__aeabi_dcmple; | ||
| 704 | @export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = linkage }); | ||
| 705 | const __aeabi_dcmpge = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpge; | ||
| 706 | @export(__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = linkage }); | ||
| 707 | const __aeabi_dcmpgt = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpgt; | ||
| 708 | @export(__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = linkage }); | ||
| 709 | const __aeabi_dcmpun = @import("compiler_rt/compareXf2.zig").__aeabi_dcmpun; | ||
| 710 | @export(__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage }); | ||
| 711 | } | ||
| 712 | |||
| 713 | if (arch == .i386 and abi == .msvc) { | ||
| 714 | // Don't let LLVM apply the stdcall name mangling on those MSVC builtins | ||
| 715 | const _alldiv = @import("compiler_rt/aulldiv.zig")._alldiv; | ||
| 716 | @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = strong_linkage }); | ||
| 717 | const _aulldiv = @import("compiler_rt/aulldiv.zig")._aulldiv; | ||
| 718 | @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = strong_linkage }); | ||
| 719 | const _allrem = @import("compiler_rt/aullrem.zig")._allrem; | ||
| 720 | @export(_allrem, .{ .name = "\x01__allrem", .linkage = strong_linkage }); | ||
| 721 | const _aullrem = @import("compiler_rt/aullrem.zig")._aullrem; | ||
| 722 | @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage }); | ||
| 723 | } | ||
| 724 | |||
| 725 | mathExport("ceil", @import("./compiler_rt/ceil.zig")); | ||
| 726 | mathExport("cos", @import("./compiler_rt/cos.zig")); | ||
| 727 | mathExport("exp", @import("./compiler_rt/exp.zig")); | ||
| 728 | mathExport("exp2", @import("./compiler_rt/exp2.zig")); | ||
| 729 | mathExport("fabs", @import("./compiler_rt/fabs.zig")); | ||
| 730 | mathExport("floor", @import("./compiler_rt/floor.zig")); | ||
| 731 | mathExport("fma", @import("./compiler_rt/fma.zig")); | ||
| 732 | mathExport("fmax", @import("./compiler_rt/fmax.zig")); | ||
| 733 | mathExport("fmin", @import("./compiler_rt/fmin.zig")); | ||
| 734 | mathExport("fmod", @import("./compiler_rt/fmod.zig")); | ||
| 735 | mathExport("log", @import("./compiler_rt/log.zig")); | ||
| 736 | mathExport("log10", @import("./compiler_rt/log10.zig")); | ||
| 737 | mathExport("log2", @import("./compiler_rt/log2.zig")); | ||
| 738 | mathExport("round", @import("./compiler_rt/round.zig")); | ||
| 739 | mathExport("sin", @import("./compiler_rt/sin.zig")); | ||
| 740 | mathExport("sincos", @import("./compiler_rt/sincos.zig")); | ||
| 741 | mathExport("sqrt", @import("./compiler_rt/sqrt.zig")); | ||
| 742 | mathExport("tan", @import("./compiler_rt/tan.zig")); | ||
| 743 | mathExport("trunc", @import("./compiler_rt/trunc.zig")); | ||
| 744 | |||
| 745 | if (arch.isSPARC()) { | ||
| 746 | // SPARC systems use a different naming scheme | ||
| 747 | const _Qp_add = @import("compiler_rt/sparc.zig")._Qp_add; | ||
| 748 | @export(_Qp_add, .{ .name = "_Qp_add", .linkage = linkage }); | ||
| 749 | const _Qp_div = @import("compiler_rt/sparc.zig")._Qp_div; | ||
| 750 | @export(_Qp_div, .{ .name = "_Qp_div", .linkage = linkage }); | ||
| 751 | const _Qp_mul = @import("compiler_rt/sparc.zig")._Qp_mul; | ||
| 752 | @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = linkage }); | ||
| 753 | const _Qp_sub = @import("compiler_rt/sparc.zig")._Qp_sub; | ||
| 754 | @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = linkage }); | ||
| 755 | |||
| 756 | const _Qp_cmp = @import("compiler_rt/sparc.zig")._Qp_cmp; | ||
| 757 | @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = linkage }); | ||
| 758 | const _Qp_feq = @import("compiler_rt/sparc.zig")._Qp_feq; | ||
| 759 | @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = linkage }); | ||
| 760 | const _Qp_fne = @import("compiler_rt/sparc.zig")._Qp_fne; | ||
| 761 | @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = linkage }); | ||
| 762 | const _Qp_flt = @import("compiler_rt/sparc.zig")._Qp_flt; | ||
| 763 | @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = linkage }); | ||
| 764 | const _Qp_fle = @import("compiler_rt/sparc.zig")._Qp_fle; | ||
| 765 | @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = linkage }); | ||
| 766 | const _Qp_fgt = @import("compiler_rt/sparc.zig")._Qp_fgt; | ||
| 767 | @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = linkage }); | ||
| 768 | const _Qp_fge = @import("compiler_rt/sparc.zig")._Qp_fge; | ||
| 769 | @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = linkage }); | ||
| 770 | |||
| 771 | const _Qp_itoq = @import("compiler_rt/sparc.zig")._Qp_itoq; | ||
| 772 | @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = linkage }); | ||
| 773 | const _Qp_uitoq = @import("compiler_rt/sparc.zig")._Qp_uitoq; | ||
| 774 | @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = linkage }); | ||
| 775 | const _Qp_xtoq = @import("compiler_rt/sparc.zig")._Qp_xtoq; | ||
| 776 | @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = linkage }); | ||
| 777 | const _Qp_uxtoq = @import("compiler_rt/sparc.zig")._Qp_uxtoq; | ||
| 778 | @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = linkage }); | ||
| 779 | const _Qp_stoq = @import("compiler_rt/sparc.zig")._Qp_stoq; | ||
| 780 | @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = linkage }); | ||
| 781 | const _Qp_dtoq = @import("compiler_rt/sparc.zig")._Qp_dtoq; | ||
| 782 | @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = linkage }); | ||
| 783 | const _Qp_qtoi = @import("compiler_rt/sparc.zig")._Qp_qtoi; | ||
| 784 | @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = linkage }); | ||
| 785 | const _Qp_qtoui = @import("compiler_rt/sparc.zig")._Qp_qtoui; | ||
| 786 | @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = linkage }); | ||
| 787 | const _Qp_qtox = @import("compiler_rt/sparc.zig")._Qp_qtox; | ||
| 788 | @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = linkage }); | ||
| 789 | const _Qp_qtoux = @import("compiler_rt/sparc.zig")._Qp_qtoux; | ||
| 790 | @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = linkage }); | ||
| 791 | const _Qp_qtos = @import("compiler_rt/sparc.zig")._Qp_qtos; | ||
| 792 | @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = linkage }); | ||
| 793 | const _Qp_qtod = @import("compiler_rt/sparc.zig")._Qp_qtod; | ||
| 794 | @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage }); | ||
| 795 | } | ||
| 796 | |||
| 797 | if (is_ppc and !is_test) { | ||
| 798 | @export(__addtf3, .{ .name = "__addkf3", .linkage = linkage }); | ||
| 799 | @export(__subtf3, .{ .name = "__subkf3", .linkage = linkage }); | ||
| 800 | @export(__multf3, .{ .name = "__mulkf3", .linkage = linkage }); | ||
| 801 | @export(__divtf3, .{ .name = "__divkf3", .linkage = linkage }); | ||
| 802 | @export(__extendsftf2, .{ .name = "__extendsfkf2", .linkage = linkage }); | ||
| 803 | @export(__extenddftf2, .{ .name = "__extenddfkf2", .linkage = linkage }); | ||
| 804 | @export(__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = linkage }); | ||
| 805 | @export(__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = linkage }); | ||
| 806 | @export(__fixtfdi, .{ .name = "__fixkfdi", .linkage = linkage }); | ||
| 807 | @export(__fixtfsi, .{ .name = "__fixkfsi", .linkage = linkage }); | ||
| 808 | @export(__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = linkage }); | ||
| 809 | @export(__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = linkage }); | ||
| 810 | @export(__floatsitf, .{ .name = "__floatsikf", .linkage = linkage }); | ||
| 811 | @export(__floatditf, .{ .name = "__floatdikf", .linkage = linkage }); | ||
| 812 | @export(__floatunditf, .{ .name = "__floatundikf", .linkage = linkage }); | ||
| 813 | @export(__floatunsitf, .{ .name = "__floatunsikf", .linkage = linkage }); | ||
| 814 | @export(__floatuntitf, .{ .name = "__floatuntikf", .linkage = linkage }); | ||
| 815 | |||
| 816 | @export(__letf2, .{ .name = "__eqkf2", .linkage = linkage }); | ||
| 817 | @export(__letf2, .{ .name = "__nekf2", .linkage = linkage }); | ||
| 818 | @export(__getf2, .{ .name = "__gekf2", .linkage = linkage }); | ||
| 819 | @export(__letf2, .{ .name = "__ltkf2", .linkage = linkage }); | ||
| 820 | @export(__letf2, .{ .name = "__lekf2", .linkage = linkage }); | ||
| 821 | @export(__getf2, .{ .name = "__gtkf2", .linkage = linkage }); | ||
| 822 | @export(__unordtf2, .{ .name = "__unordkf2", .linkage = linkage }); | ||
| 823 | } | ||
| 824 | } | ||
| 825 | |||
| 826 | inline fn mathExport(double_name: []const u8, comptime import: type) void { | ||
| 827 | const half_name = "__" ++ double_name ++ "h"; | ||
| 828 | const half_fn = @field(import, half_name); | ||
| 829 | const float_name = double_name ++ "f"; | ||
| 830 | const float_fn = @field(import, float_name); | ||
| 831 | const double_fn = @field(import, double_name); | ||
| 832 | const long_double_name = double_name ++ "l"; | ||
| 833 | const xf80_name = "__" ++ double_name ++ "x"; | ||
| 834 | const xf80_fn = @field(import, xf80_name); | ||
| 835 | const quad_name = double_name ++ "q"; | ||
| 836 | const quad_fn = @field(import, quad_name); | ||
| 837 | |||
| 838 | @export(half_fn, .{ .name = half_name, .linkage = linkage }); | ||
| 839 | @export(float_fn, .{ .name = float_name, .linkage = linkage }); | ||
| 840 | @export(double_fn, .{ .name = double_name, .linkage = linkage }); | ||
| 841 | @export(xf80_fn, .{ .name = xf80_name, .linkage = linkage }); | ||
| 842 | @export(quad_fn, .{ .name = quad_name, .linkage = linkage }); | ||
| 843 | |||
| 844 | if (is_test) return; | ||
| 845 | |||
| 846 | const pairs = .{ | ||
| 847 | .{ f16, half_fn }, | ||
| 848 | .{ f32, float_fn }, | ||
| 849 | .{ f64, double_fn }, | ||
| 850 | .{ f80, xf80_fn }, | ||
| 851 | .{ f128, quad_fn }, | ||
| 852 | }; | ||
| 853 | |||
| 854 | if (builtin.os.tag == .windows) { | ||
| 855 | // Weak aliases don't work on Windows, so we have to provide the 'l' variants | ||
| 856 | // as additional function definitions that jump to the real definition. | ||
| 857 | const long_double_fn = @field(import, long_double_name); | ||
| 858 | @export(long_double_fn, .{ .name = long_double_name, .linkage = linkage }); | ||
| 859 | } else { | ||
| 860 | inline for (pairs) |pair| { | ||
| 861 | const F = pair[0]; | ||
| 862 | const func = pair[1]; | ||
| 863 | if (builtin.target.longDoubleIs(F)) { | ||
| 864 | @export(func, .{ .name = long_double_name, .linkage = linkage }); | ||
| 865 | } | ||
| 866 | } | ||
| 867 | } | ||
| 868 | |||
| 869 | if (is_ppc) { | ||
| 870 | // LLVM PPC backend lowers f128 ops with the suffix `f128` instead of `l`. | ||
| 871 | @export(quad_fn, .{ .name = double_name ++ "f128", .linkage = linkage }); | ||
| 872 | } | ||
| 873 | } | ||
| 874 | |||
| 875 | // Avoid dragging in the runtime safety mechanisms into this .o file, | ||
| 876 | // unless we're trying to test this file. | ||
| 877 | pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { | ||
| 878 | _ = error_return_trace; | ||
| 879 | @setCold(true); | ||
| 880 | if (is_test) { | ||
| 881 | std.debug.panic("{s}", .{msg}); | ||
| 882 | } else { | ||
| 883 | unreachable; | ||
| 884 | } | ||
| 885 | } | 74 | } |
lib/compiler_rt/absv.zig+10| ... | @@ -1,6 +1,16 @@ | ... | @@ -1,6 +1,16 @@ |
| 1 | // absv - absolute oVerflow | 1 | // absv - absolute oVerflow |
| 2 | // * @panic, if value can not be represented | 2 | // * @panic, if value can not be represented |
| 3 | // - absvXi4_generic for unoptimized version | 3 | // - absvXi4_generic for unoptimized version |
| 4 | const std = @import("std"); | ||
| 5 | const builtin = @import("builtin"); | ||
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 8 | |||
| 9 | comptime { | ||
| 10 | @export(__absvsi2, .{ .name = "__absvsi2", .linkage = linkage }); | ||
| 11 | @export(__absvdi2, .{ .name = "__absvdi2", .linkage = linkage }); | ||
| 12 | @export(__absvti2, .{ .name = "__absvti2", .linkage = linkage }); | ||
| 13 | } | ||
| 4 | 14 | ||
| 5 | inline fn absvXi(comptime ST: type, a: ST) ST { | 15 | inline fn absvXi(comptime ST: type, a: ST) ST { |
| 6 | const UT = switch (ST) { | 16 | const UT = switch (ST) { |
lib/compiler_rt/addXf3.zig+43-16| ... | @@ -3,9 +3,41 @@ | ... | @@ -3,9 +3,41 @@ |
| 3 | // https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc | 3 | // https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc |
| 4 | 4 | ||
| 5 | const std = @import("std"); | 5 | const std = @import("std"); |
| 6 | const math = std.math; | ||
| 7 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 8 | const compiler_rt = @import("../compiler_rt.zig"); | 7 | const math = std.math; |
| 8 | const arch = builtin.cpu.arch; | ||
| 9 | const is_test = builtin.is_test; | ||
| 10 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 11 | |||
| 12 | const common = @import("common.zig"); | ||
| 13 | const normalize = common.normalize; | ||
| 14 | pub const panic = common.panic; | ||
| 15 | |||
| 16 | comptime { | ||
| 17 | @export(__addsf3, .{ .name = "__addsf3", .linkage = linkage }); | ||
| 18 | @export(__adddf3, .{ .name = "__adddf3", .linkage = linkage }); | ||
| 19 | @export(__addxf3, .{ .name = "__addxf3", .linkage = linkage }); | ||
| 20 | @export(__addtf3, .{ .name = "__addtf3", .linkage = linkage }); | ||
| 21 | |||
| 22 | @export(__subsf3, .{ .name = "__subsf3", .linkage = linkage }); | ||
| 23 | @export(__subdf3, .{ .name = "__subdf3", .linkage = linkage }); | ||
| 24 | @export(__subxf3, .{ .name = "__subxf3", .linkage = linkage }); | ||
| 25 | @export(__subtf3, .{ .name = "__subtf3", .linkage = linkage }); | ||
| 26 | |||
| 27 | if (!is_test) { | ||
| 28 | if (arch.isARM() or arch.isThumb()) { | ||
| 29 | @export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = linkage }); | ||
| 30 | @export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = linkage }); | ||
| 31 | @export(__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = linkage }); | ||
| 32 | @export(__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = linkage }); | ||
| 33 | } | ||
| 34 | |||
| 35 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 36 | @export(__addkf3, .{ .name = "__addkf3", .linkage = linkage }); | ||
| 37 | @export(__subkf3, .{ .name = "__subkf3", .linkage = linkage }); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | } | ||
| 9 | 41 | ||
| 10 | pub fn __addsf3(a: f32, b: f32) callconv(.C) f32 { | 42 | pub fn __addsf3(a: f32, b: f32) callconv(.C) f32 { |
| 11 | return addXf3(f32, a, b); | 43 | return addXf3(f32, a, b); |
| ... | @@ -29,6 +61,10 @@ pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 { | ... | @@ -29,6 +61,10 @@ pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 { |
| 29 | return addXf3(f128, a, b); | 61 | return addXf3(f128, a, b); |
| 30 | } | 62 | } |
| 31 | 63 | ||
| 64 | pub fn __addkf3(a: f128, b: f128) callconv(.C) f128 { | ||
| 65 | return @call(.{ .modifier = .always_inline }, __addtf3, .{ a, b }); | ||
| 66 | } | ||
| 67 | |||
| 32 | pub fn __subsf3(a: f32, b: f32) callconv(.C) f32 { | 68 | pub fn __subsf3(a: f32, b: f32) callconv(.C) f32 { |
| 33 | const neg_b = @bitCast(f32, @bitCast(u32, b) ^ (@as(u32, 1) << 31)); | 69 | const neg_b = @bitCast(f32, @bitCast(u32, b) ^ (@as(u32, 1) << 31)); |
| 34 | return addXf3(f32, a, neg_b); | 70 | return addXf3(f32, a, neg_b); |
| ... | @@ -44,6 +80,10 @@ pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 { | ... | @@ -44,6 +80,10 @@ pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 { |
| 44 | return addXf3(f128, a, neg_b); | 80 | return addXf3(f128, a, neg_b); |
| 45 | } | 81 | } |
| 46 | 82 | ||
| 83 | pub fn __subkf3(a: f128, b: f128) callconv(.C) f128 { | ||
| 84 | return @call(.{ .modifier = .always_inline }, __subtf3, .{ a, b }); | ||
| 85 | } | ||
| 86 | |||
| 47 | pub fn __aeabi_fadd(a: f32, b: f32) callconv(.AAPCS) f32 { | 87 | pub fn __aeabi_fadd(a: f32, b: f32) callconv(.AAPCS) f32 { |
| 48 | @setRuntimeSafety(false); | 88 | @setRuntimeSafety(false); |
| 49 | return @call(.{ .modifier = .always_inline }, __addsf3, .{ a, b }); | 89 | return @call(.{ .modifier = .always_inline }, __addsf3, .{ a, b }); |
| ... | @@ -65,20 +105,7 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 { | ... | @@ -65,20 +105,7 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 { |
| 65 | } | 105 | } |
| 66 | 106 | ||
| 67 | // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 | 107 | // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 |
| 68 | fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { | 108 | pub fn addXf3(comptime T: type, a: T, b: T) T { |
| 69 | const bits = @typeInfo(T).Float.bits; | ||
| 70 | const Z = std.meta.Int(.unsigned, bits); | ||
| 71 | const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1)); | ||
| 72 | const fractionalBits = math.floatFractionalBits(T); | ||
| 73 | const integerBit = @as(Z, 1) << fractionalBits; | ||
| 74 | |||
| 75 | const shift = @clz(std.meta.Int(.unsigned, bits), significand.*) - @clz(Z, integerBit); | ||
| 76 | significand.* <<= @intCast(S, shift); | ||
| 77 | return @as(i32, 1) - shift; | ||
| 78 | } | ||
| 79 | |||
| 80 | // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 | ||
| 81 | fn addXf3(comptime T: type, a: T, b: T) T { | ||
| 82 | const bits = @typeInfo(T).Float.bits; | 109 | const bits = @typeInfo(T).Float.bits; |
| 83 | const Z = std.meta.Int(.unsigned, bits); | 110 | const Z = std.meta.Int(.unsigned, bits); |
| 84 | const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1)); | 111 | const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1)); |
lib/compiler_rt/addo.zig+10| ... | @@ -1,4 +1,14 @@ | ... | @@ -1,4 +1,14 @@ |
| 1 | const std = @import("std"); | ||
| 1 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | ||
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__addosi4, .{ .name = "__addosi4", .linkage = linkage }); | ||
| 9 | @export(__addodi4, .{ .name = "__addodi4", .linkage = linkage }); | ||
| 10 | @export(__addoti4, .{ .name = "__addoti4", .linkage = linkage }); | ||
| 11 | } | ||
| 2 | 12 | ||
| 3 | // addo - add overflow | 13 | // addo - add overflow |
| 4 | // * return a+%b. | 14 | // * return a+%b. |
lib/compiler_rt/arm.zig+72| ... | @@ -1,5 +1,45 @@ | ... | @@ -1,5 +1,45 @@ |
| 1 | // ARM specific builtins | 1 | // ARM specific builtins |
| 2 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 4 | const arch = builtin.cpu.arch; | ||
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | if (!builtin.is_test) { | ||
| 10 | if (arch.isARM() or arch.isThumb()) { | ||
| 11 | @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage }); | ||
| 12 | @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage }); | ||
| 13 | @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage }); | ||
| 14 | |||
| 15 | @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = linkage }); | ||
| 16 | @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = linkage }); | ||
| 17 | |||
| 18 | @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = linkage }); | ||
| 19 | @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = linkage }); | ||
| 20 | |||
| 21 | @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = linkage }); | ||
| 22 | @export(__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = linkage }); | ||
| 23 | @export(__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = linkage }); | ||
| 24 | |||
| 25 | @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = linkage }); | ||
| 26 | @export(__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = linkage }); | ||
| 27 | @export(__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = linkage }); | ||
| 28 | |||
| 29 | @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = linkage }); | ||
| 30 | @export(__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = linkage }); | ||
| 31 | @export(__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = linkage }); | ||
| 32 | |||
| 33 | @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = linkage }); | ||
| 34 | @export(__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = linkage }); | ||
| 35 | @export(__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = linkage }); | ||
| 36 | |||
| 37 | if (builtin.os.tag == .linux) { | ||
| 38 | @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage }); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | } | ||
| 3 | 43 | ||
| 4 | const __divmodsi4 = @import("int.zig").__divmodsi4; | 44 | const __divmodsi4 = @import("int.zig").__divmodsi4; |
| 5 | const __udivmodsi4 = @import("int.zig").__udivmodsi4; | 45 | const __udivmodsi4 = @import("int.zig").__udivmodsi4; |
| ... | @@ -14,11 +54,27 @@ pub fn __aeabi_memcpy(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void { | ... | @@ -14,11 +54,27 @@ pub fn __aeabi_memcpy(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void { |
| 14 | @setRuntimeSafety(false); | 54 | @setRuntimeSafety(false); |
| 15 | _ = memcpy(dest, src, n); | 55 | _ = memcpy(dest, src, n); |
| 16 | } | 56 | } |
| 57 | pub fn __aeabi_memcpy4(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void { | ||
| 58 | @setRuntimeSafety(false); | ||
| 59 | _ = memcpy(dest, src, n); | ||
| 60 | } | ||
| 61 | pub fn __aeabi_memcpy8(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void { | ||
| 62 | @setRuntimeSafety(false); | ||
| 63 | _ = memcpy(dest, src, n); | ||
| 64 | } | ||
| 17 | 65 | ||
| 18 | pub fn __aeabi_memmove(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void { | 66 | pub fn __aeabi_memmove(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void { |
| 19 | @setRuntimeSafety(false); | 67 | @setRuntimeSafety(false); |
| 20 | _ = memmove(dest, src, n); | 68 | _ = memmove(dest, src, n); |
| 21 | } | 69 | } |
| 70 | pub fn __aeabi_memmove4(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void { | ||
| 71 | @setRuntimeSafety(false); | ||
| 72 | _ = memmove(dest, src, n); | ||
| 73 | } | ||
| 74 | pub fn __aeabi_memmove8(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void { | ||
| 75 | @setRuntimeSafety(false); | ||
| 76 | _ = memmove(dest, src, n); | ||
| 77 | } | ||
| 22 | 78 | ||
| 23 | pub fn __aeabi_memset(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void { | 79 | pub fn __aeabi_memset(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void { |
| 24 | @setRuntimeSafety(false); | 80 | @setRuntimeSafety(false); |
| ... | @@ -26,11 +82,27 @@ pub fn __aeabi_memset(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void { | ... | @@ -26,11 +82,27 @@ pub fn __aeabi_memset(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void { |
| 26 | // two arguments swapped | 82 | // two arguments swapped |
| 27 | _ = memset(dest, c, n); | 83 | _ = memset(dest, c, n); |
| 28 | } | 84 | } |
| 85 | pub fn __aeabi_memset4(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void { | ||
| 86 | @setRuntimeSafety(false); | ||
| 87 | _ = memset(dest, c, n); | ||
| 88 | } | ||
| 89 | pub fn __aeabi_memset8(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void { | ||
| 90 | @setRuntimeSafety(false); | ||
| 91 | _ = memset(dest, c, n); | ||
| 92 | } | ||
| 29 | 93 | ||
| 30 | pub fn __aeabi_memclr(dest: [*]u8, n: usize) callconv(.AAPCS) void { | 94 | pub fn __aeabi_memclr(dest: [*]u8, n: usize) callconv(.AAPCS) void { |
| 31 | @setRuntimeSafety(false); | 95 | @setRuntimeSafety(false); |
| 32 | _ = memset(dest, 0, n); | 96 | _ = memset(dest, 0, n); |
| 33 | } | 97 | } |
| 98 | pub fn __aeabi_memclr4(dest: [*]u8, n: usize) callconv(.AAPCS) void { | ||
| 99 | @setRuntimeSafety(false); | ||
| 100 | _ = memset(dest, 0, n); | ||
| 101 | } | ||
| 102 | pub fn __aeabi_memclr8(dest: [*]u8, n: usize) callconv(.AAPCS) void { | ||
| 103 | @setRuntimeSafety(false); | ||
| 104 | _ = memset(dest, 0, n); | ||
| 105 | } | ||
| 34 | 106 | ||
| 35 | // Dummy functions to avoid errors during the linking phase | 107 | // Dummy functions to avoid errors during the linking phase |
| 36 | pub fn __aeabi_unwind_cpp_pr0() callconv(.C) void {} | 108 | pub fn __aeabi_unwind_cpp_pr0() callconv(.C) void {} |
lib/compiler_rt/atomics.zig+1-1| ... | @@ -2,8 +2,8 @@ const std = @import("std"); | ... | @@ -2,8 +2,8 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const cpu = builtin.cpu; | 3 | const cpu = builtin.cpu; |
| 4 | const arch = cpu.arch; | 4 | const arch = cpu.arch; |
| 5 | |||
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; |
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | 7 | ||
| 8 | // This parameter is true iff the target architecture supports the bare minimum | 8 | // This parameter is true iff the target architecture supports the bare minimum |
| 9 | // to implement the atomic load/store intrinsics. | 9 | // to implement the atomic load/store intrinsics. |
lib/compiler_rt/aulldiv.zig+15| ... | @@ -1,4 +1,19 @@ | ... | @@ -1,4 +1,19 @@ |
| 1 | const std = @import("std"); | ||
| 1 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | ||
| 4 | const abi = builtin.abi; | ||
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | if (arch == .i386 and abi == .msvc) { | ||
| 10 | // Don't let LLVM apply the stdcall name mangling on those MSVC builtins | ||
| 11 | @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = linkage }); | ||
| 12 | @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = linkage }); | ||
| 13 | @export(_allrem, .{ .name = "\x01__allrem", .linkage = linkage }); | ||
| 14 | @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = linkage }); | ||
| 15 | } | ||
| 16 | } | ||
| 2 | 17 | ||
| 3 | pub fn _alldiv(a: i64, b: i64) callconv(.Stdcall) i64 { | 18 | pub fn _alldiv(a: i64, b: i64) callconv(.Stdcall) i64 { |
| 4 | @setRuntimeSafety(builtin.is_test); | 19 | @setRuntimeSafety(builtin.is_test); |
lib/compiler_rt/bswap.zig+9| ... | @@ -1,5 +1,14 @@ | ... | @@ -1,5 +1,14 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | ||
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = linkage }); | ||
| 9 | @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = linkage }); | ||
| 10 | @export(__bswapti2, .{ .name = "__bswapti2", .linkage = linkage }); | ||
| 11 | } | ||
| 3 | 12 | ||
| 4 | // bswap - byteswap | 13 | // bswap - byteswap |
| 5 | // - bswapXi2 for unoptimized big and little endian | 14 | // - bswapXi2 for unoptimized big and little endian |
lib/compiler_rt/ceil.zig+23| ... | @@ -5,8 +5,27 @@ | ... | @@ -5,8 +5,27 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ceil.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ceil.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 9 | const arch = builtin.cpu.arch; | ||
| 8 | const math = std.math; | 10 | const math = std.math; |
| 9 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | @export(__ceilh, .{ .name = "__ceilh", .linkage = linkage }); | ||
| 17 | @export(ceilf, .{ .name = "ceilf", .linkage = linkage }); | ||
| 18 | @export(ceil, .{ .name = "ceil", .linkage = linkage }); | ||
| 19 | @export(__ceilx, .{ .name = "__ceilx", .linkage = linkage }); | ||
| 20 | @export(ceilq, .{ .name = "ceilq", .linkage = linkage }); | ||
| 21 | @export(ceill, .{ .name = "ceill", .linkage = linkage }); | ||
| 22 | |||
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(ceilf128, .{ .name = "ceilf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 10 | 29 | ||
| 11 | pub fn __ceilh(x: f16) callconv(.C) f16 { | 30 | pub fn __ceilh(x: f16) callconv(.C) f16 { |
| 12 | // TODO: more efficient implementation | 31 | // TODO: more efficient implementation |
| ... | @@ -111,6 +130,10 @@ pub fn ceilq(x: f128) callconv(.C) f128 { | ... | @@ -111,6 +130,10 @@ pub fn ceilq(x: f128) callconv(.C) f128 { |
| 111 | } | 130 | } |
| 112 | } | 131 | } |
| 113 | 132 | ||
| 133 | pub fn ceilf128(x: f128) callconv(.C) f128 { | ||
| 134 | return @call(.{ .modifier = .always_inline }, ceilq, .{x}); | ||
| 135 | } | ||
| 136 | |||
| 114 | pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble { | 137 | pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble { |
| 115 | switch (@typeInfo(c_longdouble).Float.bits) { | 138 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 116 | 16 => return __ceilh(x), | 139 | 16 => return __ceilh(x), |
lib/compiler_rt/clear_cache.zig+8-1| ... | @@ -2,6 +2,7 @@ const std = @import("std"); | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const os = builtin.os.tag; | 4 | const os = builtin.os.tag; |
| 5 | pub const panic = @import("common.zig").panic; | ||
| 5 | 6 | ||
| 6 | // Ported from llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28 | 7 | // Ported from llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28 |
| 7 | 8 | ||
| ... | @@ -10,7 +11,13 @@ const os = builtin.os.tag; | ... | @@ -10,7 +11,13 @@ const os = builtin.os.tag; |
| 10 | // It is expected to invalidate the instruction cache for the | 11 | // It is expected to invalidate the instruction cache for the |
| 11 | // specified range. | 12 | // specified range. |
| 12 | 13 | ||
| 13 | pub fn clear_cache(start: usize, end: usize) callconv(.C) void { | 14 | comptime { |
| 15 | if (builtin.zig_backend != .stage2_llvm) { | ||
| 16 | _ = clear_cache; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | fn clear_cache(start: usize, end: usize) callconv(.C) void { | ||
| 14 | const x86 = switch (arch) { | 21 | const x86 = switch (arch) { |
| 15 | .i386, .x86_64 => true, | 22 | .i386, .x86_64 => true, |
| 16 | else => false, | 23 | else => false, |
lib/compiler_rt/cmp.zig+12| ... | @@ -1,5 +1,17 @@ | ... | @@ -1,5 +1,17 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | ||
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = linkage }); | ||
| 9 | @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = linkage }); | ||
| 10 | @export(__cmpti2, .{ .name = "__cmpti2", .linkage = linkage }); | ||
| 11 | @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = linkage }); | ||
| 12 | @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = linkage }); | ||
| 13 | @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = linkage }); | ||
| 14 | } | ||
| 3 | 15 | ||
| 4 | // cmp - signed compare | 16 | // cmp - signed compare |
| 5 | // - cmpXi2_generic for unoptimized little and big endian | 17 | // - cmpXi2_generic for unoptimized little and big endian |
lib/compiler_rt/common.zig created+144| ... | @@ -0,0 +1,144 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | const math = std.math; | ||
| 4 | const is_test = builtin.is_test; | ||
| 5 | |||
| 6 | // Avoid dragging in the runtime safety mechanisms into this .o file, | ||
| 7 | // unless we're trying to test this file. | ||
| 8 | pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { | ||
| 9 | _ = error_return_trace; | ||
| 10 | @setCold(true); | ||
| 11 | if (is_test) { | ||
| 12 | std.debug.panic("{s}", .{msg}); | ||
| 13 | } else { | ||
| 14 | unreachable; | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { | ||
| 19 | @setRuntimeSafety(is_test); | ||
| 20 | switch (Z) { | ||
| 21 | u16 => { | ||
| 22 | // 16x16 --> 32 bit multiply | ||
| 23 | const product = @as(u32, a) * @as(u32, b); | ||
| 24 | hi.* = @intCast(u16, product >> 16); | ||
| 25 | lo.* = @truncate(u16, product); | ||
| 26 | }, | ||
| 27 | u32 => { | ||
| 28 | // 32x32 --> 64 bit multiply | ||
| 29 | const product = @as(u64, a) * @as(u64, b); | ||
| 30 | hi.* = @truncate(u32, product >> 32); | ||
| 31 | lo.* = @truncate(u32, product); | ||
| 32 | }, | ||
| 33 | u64 => { | ||
| 34 | const S = struct { | ||
| 35 | fn loWord(x: u64) u64 { | ||
| 36 | return @truncate(u32, x); | ||
| 37 | } | ||
| 38 | fn hiWord(x: u64) u64 { | ||
| 39 | return @truncate(u32, x >> 32); | ||
| 40 | } | ||
| 41 | }; | ||
| 42 | // 64x64 -> 128 wide multiply for platforms that don't have such an operation; | ||
| 43 | // many 64-bit platforms have this operation, but they tend to have hardware | ||
| 44 | // floating-point, so we don't bother with a special case for them here. | ||
| 45 | // Each of the component 32x32 -> 64 products | ||
| 46 | const plolo: u64 = S.loWord(a) * S.loWord(b); | ||
| 47 | const plohi: u64 = S.loWord(a) * S.hiWord(b); | ||
| 48 | const philo: u64 = S.hiWord(a) * S.loWord(b); | ||
| 49 | const phihi: u64 = S.hiWord(a) * S.hiWord(b); | ||
| 50 | // Sum terms that contribute to lo in a way that allows us to get the carry | ||
| 51 | const r0: u64 = S.loWord(plolo); | ||
| 52 | const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo); | ||
| 53 | lo.* = r0 +% (r1 << 32); | ||
| 54 | // Sum terms contributing to hi with the carry from lo | ||
| 55 | hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi; | ||
| 56 | }, | ||
| 57 | u128 => { | ||
| 58 | const Word_LoMask = @as(u64, 0x00000000ffffffff); | ||
| 59 | const Word_HiMask = @as(u64, 0xffffffff00000000); | ||
| 60 | const Word_FullMask = @as(u64, 0xffffffffffffffff); | ||
| 61 | const S = struct { | ||
| 62 | fn Word_1(x: u128) u64 { | ||
| 63 | return @truncate(u32, x >> 96); | ||
| 64 | } | ||
| 65 | fn Word_2(x: u128) u64 { | ||
| 66 | return @truncate(u32, x >> 64); | ||
| 67 | } | ||
| 68 | fn Word_3(x: u128) u64 { | ||
| 69 | return @truncate(u32, x >> 32); | ||
| 70 | } | ||
| 71 | fn Word_4(x: u128) u64 { | ||
| 72 | return @truncate(u32, x); | ||
| 73 | } | ||
| 74 | }; | ||
| 75 | // 128x128 -> 256 wide multiply for platforms that don't have such an operation; | ||
| 76 | // many 64-bit platforms have this operation, but they tend to have hardware | ||
| 77 | // floating-point, so we don't bother with a special case for them here. | ||
| 78 | |||
| 79 | const product11: u64 = S.Word_1(a) * S.Word_1(b); | ||
| 80 | const product12: u64 = S.Word_1(a) * S.Word_2(b); | ||
| 81 | const product13: u64 = S.Word_1(a) * S.Word_3(b); | ||
| 82 | const product14: u64 = S.Word_1(a) * S.Word_4(b); | ||
| 83 | const product21: u64 = S.Word_2(a) * S.Word_1(b); | ||
| 84 | const product22: u64 = S.Word_2(a) * S.Word_2(b); | ||
| 85 | const product23: u64 = S.Word_2(a) * S.Word_3(b); | ||
| 86 | const product24: u64 = S.Word_2(a) * S.Word_4(b); | ||
| 87 | const product31: u64 = S.Word_3(a) * S.Word_1(b); | ||
| 88 | const product32: u64 = S.Word_3(a) * S.Word_2(b); | ||
| 89 | const product33: u64 = S.Word_3(a) * S.Word_3(b); | ||
| 90 | const product34: u64 = S.Word_3(a) * S.Word_4(b); | ||
| 91 | const product41: u64 = S.Word_4(a) * S.Word_1(b); | ||
| 92 | const product42: u64 = S.Word_4(a) * S.Word_2(b); | ||
| 93 | const product43: u64 = S.Word_4(a) * S.Word_3(b); | ||
| 94 | const product44: u64 = S.Word_4(a) * S.Word_4(b); | ||
| 95 | |||
| 96 | const sum0: u128 = @as(u128, product44); | ||
| 97 | const sum1: u128 = @as(u128, product34) +% | ||
| 98 | @as(u128, product43); | ||
| 99 | const sum2: u128 = @as(u128, product24) +% | ||
| 100 | @as(u128, product33) +% | ||
| 101 | @as(u128, product42); | ||
| 102 | const sum3: u128 = @as(u128, product14) +% | ||
| 103 | @as(u128, product23) +% | ||
| 104 | @as(u128, product32) +% | ||
| 105 | @as(u128, product41); | ||
| 106 | const sum4: u128 = @as(u128, product13) +% | ||
| 107 | @as(u128, product22) +% | ||
| 108 | @as(u128, product31); | ||
| 109 | const sum5: u128 = @as(u128, product12) +% | ||
| 110 | @as(u128, product21); | ||
| 111 | const sum6: u128 = @as(u128, product11); | ||
| 112 | |||
| 113 | const r0: u128 = (sum0 & Word_FullMask) +% | ||
| 114 | ((sum1 & Word_LoMask) << 32); | ||
| 115 | const r1: u128 = (sum0 >> 64) +% | ||
| 116 | ((sum1 >> 32) & Word_FullMask) +% | ||
| 117 | (sum2 & Word_FullMask) +% | ||
| 118 | ((sum3 << 32) & Word_HiMask); | ||
| 119 | |||
| 120 | lo.* = r0 +% (r1 << 64); | ||
| 121 | hi.* = (r1 >> 64) +% | ||
| 122 | (sum1 >> 96) +% | ||
| 123 | (sum2 >> 64) +% | ||
| 124 | (sum3 >> 32) +% | ||
| 125 | sum4 +% | ||
| 126 | (sum5 << 32) +% | ||
| 127 | (sum6 << 64); | ||
| 128 | }, | ||
| 129 | else => @compileError("unsupported"), | ||
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 | ||
| 134 | pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { | ||
| 135 | const bits = @typeInfo(T).Float.bits; | ||
| 136 | const Z = std.meta.Int(.unsigned, bits); | ||
| 137 | const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1)); | ||
| 138 | const fractionalBits = math.floatFractionalBits(T); | ||
| 139 | const integerBit = @as(Z, 1) << fractionalBits; | ||
| 140 | |||
| 141 | const shift = @clz(std.meta.Int(.unsigned, bits), significand.*) - @clz(Z, integerBit); | ||
| 142 | significand.* <<= @intCast(S, shift); | ||
| 143 | return @as(i32, 1) - shift; | ||
| 144 | } | ||
lib/compiler_rt/compareXf2.zig+128-16| ... | @@ -4,6 +4,78 @@ | ... | @@ -4,6 +4,78 @@ |
| 4 | 4 | ||
| 5 | const std = @import("std"); | 5 | const std = @import("std"); |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 7 | const is_test = builtin.is_test; | ||
| 8 | const arch = builtin.cpu.arch; | ||
| 9 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 10 | pub const panic = @import("common.zig").panic; | ||
| 11 | |||
| 12 | comptime { | ||
| 13 | @export(__lesf2, .{ .name = "__lesf2", .linkage = linkage }); | ||
| 14 | @export(__ledf2, .{ .name = "__ledf2", .linkage = linkage }); | ||
| 15 | @export(__letf2, .{ .name = "__letf2", .linkage = linkage }); | ||
| 16 | @export(__lexf2, .{ .name = "__lexf2", .linkage = linkage }); | ||
| 17 | |||
| 18 | @export(__gesf2, .{ .name = "__gesf2", .linkage = linkage }); | ||
| 19 | @export(__gedf2, .{ .name = "__gedf2", .linkage = linkage }); | ||
| 20 | @export(__getf2, .{ .name = "__getf2", .linkage = linkage }); | ||
| 21 | @export(__gexf2, .{ .name = "__gexf2", .linkage = linkage }); | ||
| 22 | |||
| 23 | @export(__eqsf2, .{ .name = "__eqsf2", .linkage = linkage }); | ||
| 24 | @export(__eqdf2, .{ .name = "__eqdf2", .linkage = linkage }); | ||
| 25 | @export(__eqxf2, .{ .name = "__eqxf2", .linkage = linkage }); | ||
| 26 | |||
| 27 | @export(__ltsf2, .{ .name = "__ltsf2", .linkage = linkage }); | ||
| 28 | @export(__ltdf2, .{ .name = "__ltdf2", .linkage = linkage }); | ||
| 29 | @export(__ltxf2, .{ .name = "__ltxf2", .linkage = linkage }); | ||
| 30 | |||
| 31 | @export(__nesf2, .{ .name = "__nesf2", .linkage = linkage }); | ||
| 32 | @export(__nedf2, .{ .name = "__nedf2", .linkage = linkage }); | ||
| 33 | @export(__nexf2, .{ .name = "__nexf2", .linkage = linkage }); | ||
| 34 | |||
| 35 | @export(__gtsf2, .{ .name = "__gtsf2", .linkage = linkage }); | ||
| 36 | @export(__gtdf2, .{ .name = "__gtdf2", .linkage = linkage }); | ||
| 37 | @export(__gtxf2, .{ .name = "__gtxf2", .linkage = linkage }); | ||
| 38 | |||
| 39 | @export(__unordsf2, .{ .name = "__unordsf2", .linkage = linkage }); | ||
| 40 | @export(__unorddf2, .{ .name = "__unorddf2", .linkage = linkage }); | ||
| 41 | @export(__unordtf2, .{ .name = "__unordtf2", .linkage = linkage }); | ||
| 42 | |||
| 43 | if (!is_test) { | ||
| 44 | @export(__cmpsf2, .{ .name = "__cmpsf2", .linkage = linkage }); | ||
| 45 | @export(__cmpdf2, .{ .name = "__cmpdf2", .linkage = linkage }); | ||
| 46 | @export(__cmptf2, .{ .name = "__cmptf2", .linkage = linkage }); | ||
| 47 | @export(__eqtf2, .{ .name = "__eqtf2", .linkage = linkage }); | ||
| 48 | @export(__lttf2, .{ .name = "__lttf2", .linkage = linkage }); | ||
| 49 | @export(__gttf2, .{ .name = "__gttf2", .linkage = linkage }); | ||
| 50 | @export(__netf2, .{ .name = "__netf2", .linkage = linkage }); | ||
| 51 | |||
| 52 | if (arch.isARM() or arch.isThumb()) { | ||
| 53 | @export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = linkage }); | ||
| 54 | @export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = linkage }); | ||
| 55 | @export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = linkage }); | ||
| 56 | @export(__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = linkage }); | ||
| 57 | @export(__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = linkage }); | ||
| 58 | @export(__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = linkage }); | ||
| 59 | |||
| 60 | @export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = linkage }); | ||
| 61 | @export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = linkage }); | ||
| 62 | @export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = linkage }); | ||
| 63 | @export(__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = linkage }); | ||
| 64 | @export(__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = linkage }); | ||
| 65 | @export(__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage }); | ||
| 66 | } | ||
| 67 | |||
| 68 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 69 | @export(__eqkf2, .{ .name = "__eqkf2", .linkage = linkage }); | ||
| 70 | @export(__nekf2, .{ .name = "__nekf2", .linkage = linkage }); | ||
| 71 | @export(__gekf2, .{ .name = "__gekf2", .linkage = linkage }); | ||
| 72 | @export(__ltkf2, .{ .name = "__ltkf2", .linkage = linkage }); | ||
| 73 | @export(__lekf2, .{ .name = "__lekf2", .linkage = linkage }); | ||
| 74 | @export(__gtkf2, .{ .name = "__gtkf2", .linkage = linkage }); | ||
| 75 | @export(__unordkf2, .{ .name = "__unordkf2", .linkage = linkage }); | ||
| 76 | } | ||
| 77 | } | ||
| 78 | } | ||
| 7 | 79 | ||
| 8 | const LE = enum(i32) { | 80 | const LE = enum(i32) { |
| 9 | Less = -1, | 81 | Less = -1, |
| ... | @@ -98,20 +170,24 @@ pub fn __gesf2(a: f32, b: f32) callconv(.C) i32 { | ... | @@ -98,20 +170,24 @@ pub fn __gesf2(a: f32, b: f32) callconv(.C) i32 { |
| 98 | return @bitCast(i32, float); | 170 | return @bitCast(i32, float); |
| 99 | } | 171 | } |
| 100 | 172 | ||
| 173 | pub fn __cmpsf2(a: f32, b: f32) callconv(.C) i32 { | ||
| 174 | return @call(.{ .modifier = .always_inline }, __lesf2, .{ a, b }); | ||
| 175 | } | ||
| 176 | |||
| 101 | pub fn __eqsf2(a: f32, b: f32) callconv(.C) i32 { | 177 | pub fn __eqsf2(a: f32, b: f32) callconv(.C) i32 { |
| 102 | return __lesf2(a, b); | 178 | return @call(.{ .modifier = .always_inline }, __lesf2, .{ a, b }); |
| 103 | } | 179 | } |
| 104 | 180 | ||
| 105 | pub fn __ltsf2(a: f32, b: f32) callconv(.C) i32 { | 181 | pub fn __ltsf2(a: f32, b: f32) callconv(.C) i32 { |
| 106 | return __lesf2(a, b); | 182 | return @call(.{ .modifier = .always_inline }, __lesf2, .{ a, b }); |
| 107 | } | 183 | } |
| 108 | 184 | ||
| 109 | pub fn __nesf2(a: f32, b: f32) callconv(.C) i32 { | 185 | pub fn __nesf2(a: f32, b: f32) callconv(.C) i32 { |
| 110 | return __lesf2(a, b); | 186 | return @call(.{ .modifier = .always_inline }, __lesf2, .{ a, b }); |
| 111 | } | 187 | } |
| 112 | 188 | ||
| 113 | pub fn __gtsf2(a: f32, b: f32) callconv(.C) i32 { | 189 | pub fn __gtsf2(a: f32, b: f32) callconv(.C) i32 { |
| 114 | return __gesf2(a, b); | 190 | return @call(.{ .modifier = .always_inline }, __gesf2, .{ a, b }); |
| 115 | } | 191 | } |
| 116 | 192 | ||
| 117 | // Comparison between f64 | 193 | // Comparison between f64 |
| ... | @@ -128,20 +204,24 @@ pub fn __gedf2(a: f64, b: f64) callconv(.C) i32 { | ... | @@ -128,20 +204,24 @@ pub fn __gedf2(a: f64, b: f64) callconv(.C) i32 { |
| 128 | return @bitCast(i32, float); | 204 | return @bitCast(i32, float); |
| 129 | } | 205 | } |
| 130 | 206 | ||
| 207 | pub fn __cmpdf2(a: f64, b: f64) callconv(.C) i32 { | ||
| 208 | return @call(.{ .modifier = .always_inline }, __ledf2, .{ a, b }); | ||
| 209 | } | ||
| 210 | |||
| 131 | pub fn __eqdf2(a: f64, b: f64) callconv(.C) i32 { | 211 | pub fn __eqdf2(a: f64, b: f64) callconv(.C) i32 { |
| 132 | return __ledf2(a, b); | 212 | return @call(.{ .modifier = .always_inline }, __ledf2, .{ a, b }); |
| 133 | } | 213 | } |
| 134 | 214 | ||
| 135 | pub fn __ltdf2(a: f64, b: f64) callconv(.C) i32 { | 215 | pub fn __ltdf2(a: f64, b: f64) callconv(.C) i32 { |
| 136 | return __ledf2(a, b); | 216 | return @call(.{ .modifier = .always_inline }, __ledf2, .{ a, b }); |
| 137 | } | 217 | } |
| 138 | 218 | ||
| 139 | pub fn __nedf2(a: f64, b: f64) callconv(.C) i32 { | 219 | pub fn __nedf2(a: f64, b: f64) callconv(.C) i32 { |
| 140 | return __ledf2(a, b); | 220 | return @call(.{ .modifier = .always_inline }, __ledf2, .{ a, b }); |
| 141 | } | 221 | } |
| 142 | 222 | ||
| 143 | pub fn __gtdf2(a: f64, b: f64) callconv(.C) i32 { | 223 | pub fn __gtdf2(a: f64, b: f64) callconv(.C) i32 { |
| 144 | return __gedf2(a, b); | 224 | return @call(.{ .modifier = .always_inline }, __gedf2, .{ a, b }); |
| 145 | } | 225 | } |
| 146 | 226 | ||
| 147 | // Comparison between f80 | 227 | // Comparison between f80 |
| ... | @@ -196,19 +276,19 @@ pub fn __gexf2(a: f80, b: f80) callconv(.C) i32 { | ... | @@ -196,19 +276,19 @@ pub fn __gexf2(a: f80, b: f80) callconv(.C) i32 { |
| 196 | } | 276 | } |
| 197 | 277 | ||
| 198 | pub fn __eqxf2(a: f80, b: f80) callconv(.C) i32 { | 278 | pub fn __eqxf2(a: f80, b: f80) callconv(.C) i32 { |
| 199 | return __lexf2(a, b); | 279 | return @call(.{ .modifier = .always_inline }, __lexf2, .{ a, b }); |
| 200 | } | 280 | } |
| 201 | 281 | ||
| 202 | pub fn __ltxf2(a: f80, b: f80) callconv(.C) i32 { | 282 | pub fn __ltxf2(a: f80, b: f80) callconv(.C) i32 { |
| 203 | return __lexf2(a, b); | 283 | return @call(.{ .modifier = .always_inline }, __lexf2, .{ a, b }); |
| 204 | } | 284 | } |
| 205 | 285 | ||
| 206 | pub fn __nexf2(a: f80, b: f80) callconv(.C) i32 { | 286 | pub fn __nexf2(a: f80, b: f80) callconv(.C) i32 { |
| 207 | return __lexf2(a, b); | 287 | return @call(.{ .modifier = .always_inline }, __lexf2, .{ a, b }); |
| 208 | } | 288 | } |
| 209 | 289 | ||
| 210 | pub fn __gtxf2(a: f80, b: f80) callconv(.C) i32 { | 290 | pub fn __gtxf2(a: f80, b: f80) callconv(.C) i32 { |
| 211 | return __gexf2(a, b); | 291 | return @call(.{ .modifier = .always_inline }, __gexf2, .{ a, b }); |
| 212 | } | 292 | } |
| 213 | 293 | ||
| 214 | // Comparison between f128 | 294 | // Comparison between f128 |
| ... | @@ -225,20 +305,48 @@ pub fn __getf2(a: f128, b: f128) callconv(.C) i32 { | ... | @@ -225,20 +305,48 @@ pub fn __getf2(a: f128, b: f128) callconv(.C) i32 { |
| 225 | return @bitCast(i32, float); | 305 | return @bitCast(i32, float); |
| 226 | } | 306 | } |
| 227 | 307 | ||
| 308 | pub fn __cmptf2(a: f128, b: f128) callconv(.C) i32 { | ||
| 309 | return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b }); | ||
| 310 | } | ||
| 311 | |||
| 228 | pub fn __eqtf2(a: f128, b: f128) callconv(.C) i32 { | 312 | pub fn __eqtf2(a: f128, b: f128) callconv(.C) i32 { |
| 229 | return __letf2(a, b); | 313 | return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b }); |
| 230 | } | 314 | } |
| 231 | 315 | ||
| 232 | pub fn __lttf2(a: f128, b: f128) callconv(.C) i32 { | 316 | pub fn __lttf2(a: f128, b: f128) callconv(.C) i32 { |
| 233 | return __letf2(a, b); | 317 | return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b }); |
| 234 | } | 318 | } |
| 235 | 319 | ||
| 236 | pub fn __netf2(a: f128, b: f128) callconv(.C) i32 { | 320 | pub fn __netf2(a: f128, b: f128) callconv(.C) i32 { |
| 237 | return __letf2(a, b); | 321 | return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b }); |
| 238 | } | 322 | } |
| 239 | 323 | ||
| 240 | pub fn __gttf2(a: f128, b: f128) callconv(.C) i32 { | 324 | pub fn __gttf2(a: f128, b: f128) callconv(.C) i32 { |
| 241 | return __getf2(a, b); | 325 | return @call(.{ .modifier = .always_inline }, __getf2, .{ a, b }); |
| 326 | } | ||
| 327 | |||
| 328 | pub fn __eqkf2(a: f128, b: f128) callconv(.C) i32 { | ||
| 329 | return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b }); | ||
| 330 | } | ||
| 331 | |||
| 332 | pub fn __nekf2(a: f128, b: f128) callconv(.C) i32 { | ||
| 333 | return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b }); | ||
| 334 | } | ||
| 335 | |||
| 336 | pub fn __gekf2(a: f128, b: f128) callconv(.C) i32 { | ||
| 337 | return @call(.{ .modifier = .always_inline }, __getf2, .{ a, b }); | ||
| 338 | } | ||
| 339 | |||
| 340 | pub fn __ltkf2(a: f128, b: f128) callconv(.C) i32 { | ||
| 341 | return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b }); | ||
| 342 | } | ||
| 343 | |||
| 344 | pub fn __lekf2(a: f128, b: f128) callconv(.C) i32 { | ||
| 345 | return @call(.{ .modifier = .always_inline }, __letf2, .{ a, b }); | ||
| 346 | } | ||
| 347 | |||
| 348 | pub fn __gtkf2(a: f128, b: f128) callconv(.C) i32 { | ||
| 349 | return @call(.{ .modifier = .always_inline }, __getf2, .{ a, b }); | ||
| 242 | } | 350 | } |
| 243 | 351 | ||
| 244 | // Unordered comparison between f32/f64/f128 | 352 | // Unordered comparison between f32/f64/f128 |
| ... | @@ -258,6 +366,10 @@ pub fn __unordtf2(a: f128, b: f128) callconv(.C) i32 { | ... | @@ -258,6 +366,10 @@ pub fn __unordtf2(a: f128, b: f128) callconv(.C) i32 { |
| 258 | return unordcmp(f128, a, b); | 366 | return unordcmp(f128, a, b); |
| 259 | } | 367 | } |
| 260 | 368 | ||
| 369 | pub fn __unordkf2(a: f128, b: f128) callconv(.C) i32 { | ||
| 370 | return @call(.{ .modifier = .always_inline }, __unordtf2, .{ a, b }); | ||
| 371 | } | ||
| 372 | |||
| 261 | // ARM EABI intrinsics | 373 | // ARM EABI intrinsics |
| 262 | 374 | ||
| 263 | pub fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 { | 375 | pub fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 { |
lib/compiler_rt/cos.zig+23| ... | @@ -1,11 +1,30 @@ | ... | @@ -1,11 +1,30 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 3 | const arch = builtin.cpu.arch; | ||
| 2 | const math = std.math; | 4 | const math = std.math; |
| 3 | const expect = std.testing.expect; | 5 | const expect = std.testing.expect; |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 4 | 8 | ||
| 5 | const trig = @import("trig.zig"); | 9 | const trig = @import("trig.zig"); |
| 6 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; | 10 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; |
| 7 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; | 11 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; |
| 8 | 12 | ||
| 13 | comptime { | ||
| 14 | @export(__cosh, .{ .name = "__cosh", .linkage = linkage }); | ||
| 15 | @export(cosf, .{ .name = "cosf", .linkage = linkage }); | ||
| 16 | @export(cos, .{ .name = "cos", .linkage = linkage }); | ||
| 17 | @export(__cosx, .{ .name = "__cosx", .linkage = linkage }); | ||
| 18 | @export(cosq, .{ .name = "cosq", .linkage = linkage }); | ||
| 19 | @export(cosl, .{ .name = "cosl", .linkage = linkage }); | ||
| 20 | |||
| 21 | if (!builtin.is_test) { | ||
| 22 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 23 | @export(cosf128, .{ .name = "cosf128", .linkage = linkage }); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 9 | pub fn __cosh(a: f16) callconv(.C) f16 { | 28 | pub fn __cosh(a: f16) callconv(.C) f16 { |
| 10 | // TODO: more efficient implementation | 29 | // TODO: more efficient implementation |
| 11 | return @floatCast(f16, cosf(a)); | 30 | return @floatCast(f16, cosf(a)); |
| ... | @@ -107,6 +126,10 @@ pub fn cosq(a: f128) callconv(.C) f128 { | ... | @@ -107,6 +126,10 @@ pub fn cosq(a: f128) callconv(.C) f128 { |
| 107 | return cos(@floatCast(f64, a)); | 126 | return cos(@floatCast(f64, a)); |
| 108 | } | 127 | } |
| 109 | 128 | ||
| 129 | pub fn cosf128(a: f128) callconv(.C) f128 { | ||
| 130 | return @call(.{ .modifier = .always_inline }, cosq, .{a}); | ||
| 131 | } | ||
| 132 | |||
| 110 | pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble { | 133 | pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble { |
| 111 | switch (@typeInfo(c_longdouble).Float.bits) { | 134 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 112 | 16 => return __cosh(x), | 135 | 16 => return __cosh(x), |
lib/compiler_rt/count0bits.zig+15| ... | @@ -1,5 +1,20 @@ | ... | @@ -1,5 +1,20 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | ||
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__clzsi2, .{ .name = "__clzsi2", .linkage = linkage }); | ||
| 9 | @export(__clzdi2, .{ .name = "__clzdi2", .linkage = linkage }); | ||
| 10 | @export(__clzti2, .{ .name = "__clzti2", .linkage = linkage }); | ||
| 11 | @export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = linkage }); | ||
| 12 | @export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = linkage }); | ||
| 13 | @export(__ctzti2, .{ .name = "__ctzti2", .linkage = linkage }); | ||
| 14 | @export(__ffssi2, .{ .name = "__ffssi2", .linkage = linkage }); | ||
| 15 | @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = linkage }); | ||
| 16 | @export(__ffsti2, .{ .name = "__ffsti2", .linkage = linkage }); | ||
| 17 | } | ||
| 3 | 18 | ||
| 4 | // clz - count leading zeroes | 19 | // clz - count leading zeroes |
| 5 | // - clzXi2 for unoptimized little and big endian | 20 | // - clzXi2 for unoptimized little and big endian |
lib/compiler_rt/divdf3.zig+18-119| ... | @@ -4,6 +4,24 @@ | ... | @@ -4,6 +4,24 @@ |
| 4 | 4 | ||
| 5 | const std = @import("std"); | 5 | const std = @import("std"); |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 7 | const arch = builtin.cpu.arch; | ||
| 8 | const is_test = builtin.is_test; | ||
| 9 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 10 | |||
| 11 | const common = @import("common.zig"); | ||
| 12 | const normalize = common.normalize; | ||
| 13 | const wideMultiply = common.wideMultiply; | ||
| 14 | pub const panic = common.panic; | ||
| 15 | |||
| 16 | comptime { | ||
| 17 | @export(__divdf3, .{ .name = "__divdf3", .linkage = linkage }); | ||
| 18 | |||
| 19 | if (!is_test) { | ||
| 20 | if (arch.isARM() or arch.isThumb()) { | ||
| 21 | @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = linkage }); | ||
| 22 | } | ||
| 23 | } | ||
| 24 | } | ||
| 7 | 25 | ||
| 8 | pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { | 26 | pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { |
| 9 | @setRuntimeSafety(builtin.is_test); | 27 | @setRuntimeSafety(builtin.is_test); |
| ... | @@ -202,125 +220,6 @@ pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { | ... | @@ -202,125 +220,6 @@ pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { |
| 202 | } | 220 | } |
| 203 | } | 221 | } |
| 204 | 222 | ||
| 205 | pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { | ||
| 206 | @setRuntimeSafety(builtin.is_test); | ||
| 207 | switch (Z) { | ||
| 208 | u32 => { | ||
| 209 | // 32x32 --> 64 bit multiply | ||
| 210 | const product = @as(u64, a) * @as(u64, b); | ||
| 211 | hi.* = @truncate(u32, product >> 32); | ||
| 212 | lo.* = @truncate(u32, product); | ||
| 213 | }, | ||
| 214 | u64 => { | ||
| 215 | const S = struct { | ||
| 216 | fn loWord(x: u64) u64 { | ||
| 217 | return @truncate(u32, x); | ||
| 218 | } | ||
| 219 | fn hiWord(x: u64) u64 { | ||
| 220 | return @truncate(u32, x >> 32); | ||
| 221 | } | ||
| 222 | }; | ||
| 223 | // 64x64 -> 128 wide multiply for platforms that don't have such an operation; | ||
| 224 | // many 64-bit platforms have this operation, but they tend to have hardware | ||
| 225 | // floating-point, so we don't bother with a special case for them here. | ||
| 226 | // Each of the component 32x32 -> 64 products | ||
| 227 | const plolo: u64 = S.loWord(a) * S.loWord(b); | ||
| 228 | const plohi: u64 = S.loWord(a) * S.hiWord(b); | ||
| 229 | const philo: u64 = S.hiWord(a) * S.loWord(b); | ||
| 230 | const phihi: u64 = S.hiWord(a) * S.hiWord(b); | ||
| 231 | // Sum terms that contribute to lo in a way that allows us to get the carry | ||
| 232 | const r0: u64 = S.loWord(plolo); | ||
| 233 | const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo); | ||
| 234 | lo.* = r0 +% (r1 << 32); | ||
| 235 | // Sum terms contributing to hi with the carry from lo | ||
| 236 | hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi; | ||
| 237 | }, | ||
| 238 | u128 => { | ||
| 239 | const Word_LoMask = @as(u64, 0x00000000ffffffff); | ||
| 240 | const Word_HiMask = @as(u64, 0xffffffff00000000); | ||
| 241 | const Word_FullMask = @as(u64, 0xffffffffffffffff); | ||
| 242 | const S = struct { | ||
| 243 | fn Word_1(x: u128) u64 { | ||
| 244 | return @truncate(u32, x >> 96); | ||
| 245 | } | ||
| 246 | fn Word_2(x: u128) u64 { | ||
| 247 | return @truncate(u32, x >> 64); | ||
| 248 | } | ||
| 249 | fn Word_3(x: u128) u64 { | ||
| 250 | return @truncate(u32, x >> 32); | ||
| 251 | } | ||
| 252 | fn Word_4(x: u128) u64 { | ||
| 253 | return @truncate(u32, x); | ||
| 254 | } | ||
| 255 | }; | ||
| 256 | // 128x128 -> 256 wide multiply for platforms that don't have such an operation; | ||
| 257 | // many 64-bit platforms have this operation, but they tend to have hardware | ||
| 258 | // floating-point, so we don't bother with a special case for them here. | ||
| 259 | |||
| 260 | const product11: u64 = S.Word_1(a) * S.Word_1(b); | ||
| 261 | const product12: u64 = S.Word_1(a) * S.Word_2(b); | ||
| 262 | const product13: u64 = S.Word_1(a) * S.Word_3(b); | ||
| 263 | const product14: u64 = S.Word_1(a) * S.Word_4(b); | ||
| 264 | const product21: u64 = S.Word_2(a) * S.Word_1(b); | ||
| 265 | const product22: u64 = S.Word_2(a) * S.Word_2(b); | ||
| 266 | const product23: u64 = S.Word_2(a) * S.Word_3(b); | ||
| 267 | const product24: u64 = S.Word_2(a) * S.Word_4(b); | ||
| 268 | const product31: u64 = S.Word_3(a) * S.Word_1(b); | ||
| 269 | const product32: u64 = S.Word_3(a) * S.Word_2(b); | ||
| 270 | const product33: u64 = S.Word_3(a) * S.Word_3(b); | ||
| 271 | const product34: u64 = S.Word_3(a) * S.Word_4(b); | ||
| 272 | const product41: u64 = S.Word_4(a) * S.Word_1(b); | ||
| 273 | const product42: u64 = S.Word_4(a) * S.Word_2(b); | ||
| 274 | const product43: u64 = S.Word_4(a) * S.Word_3(b); | ||
| 275 | const product44: u64 = S.Word_4(a) * S.Word_4(b); | ||
| 276 | |||
| 277 | const sum0: u128 = @as(u128, product44); | ||
| 278 | const sum1: u128 = @as(u128, product34) +% | ||
| 279 | @as(u128, product43); | ||
| 280 | const sum2: u128 = @as(u128, product24) +% | ||
| 281 | @as(u128, product33) +% | ||
| 282 | @as(u128, product42); | ||
| 283 | const sum3: u128 = @as(u128, product14) +% | ||
| 284 | @as(u128, product23) +% | ||
| 285 | @as(u128, product32) +% | ||
| 286 | @as(u128, product41); | ||
| 287 | const sum4: u128 = @as(u128, product13) +% | ||
| 288 | @as(u128, product22) +% | ||
| 289 | @as(u128, product31); | ||
| 290 | const sum5: u128 = @as(u128, product12) +% | ||
| 291 | @as(u128, product21); | ||
| 292 | const sum6: u128 = @as(u128, product11); | ||
| 293 | |||
| 294 | const r0: u128 = (sum0 & Word_FullMask) +% | ||
| 295 | ((sum1 & Word_LoMask) << 32); | ||
| 296 | const r1: u128 = (sum0 >> 64) +% | ||
| 297 | ((sum1 >> 32) & Word_FullMask) +% | ||
| 298 | (sum2 & Word_FullMask) +% | ||
| 299 | ((sum3 << 32) & Word_HiMask); | ||
| 300 | |||
| 301 | lo.* = r0 +% (r1 << 64); | ||
| 302 | hi.* = (r1 >> 64) +% | ||
| 303 | (sum1 >> 96) +% | ||
| 304 | (sum2 >> 64) +% | ||
| 305 | (sum3 >> 32) +% | ||
| 306 | sum4 +% | ||
| 307 | (sum5 << 32) +% | ||
| 308 | (sum6 << 64); | ||
| 309 | }, | ||
| 310 | else => @compileError("unsupported"), | ||
| 311 | } | ||
| 312 | } | ||
| 313 | |||
| 314 | pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { | ||
| 315 | @setRuntimeSafety(builtin.is_test); | ||
| 316 | const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | ||
| 317 | const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T); | ||
| 318 | |||
| 319 | const shift = @clz(Z, significand.*) - @clz(Z, integerBit); | ||
| 320 | significand.* <<= @intCast(std.math.Log2Int(Z), shift); | ||
| 321 | return @as(i32, 1) - shift; | ||
| 322 | } | ||
| 323 | |||
| 324 | pub fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 { | 223 | pub fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 { |
| 325 | @setRuntimeSafety(false); | 224 | @setRuntimeSafety(false); |
| 326 | return @call(.{ .modifier = .always_inline }, __divdf3, .{ a, b }); | 225 | return @call(.{ .modifier = .always_inline }, __divdf3, .{ a, b }); |
lib/compiler_rt/divsf3.zig+17-11| ... | @@ -4,6 +4,23 @@ | ... | @@ -4,6 +4,23 @@ |
| 4 | 4 | ||
| 5 | const std = @import("std"); | 5 | const std = @import("std"); |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 7 | const arch = builtin.cpu.arch; | ||
| 8 | const is_test = builtin.is_test; | ||
| 9 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 10 | |||
| 11 | const common = @import("common.zig"); | ||
| 12 | const normalize = common.normalize; | ||
| 13 | pub const panic = common.panic; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | @export(__divsf3, .{ .name = "__divsf3", .linkage = linkage }); | ||
| 17 | |||
| 18 | if (!is_test) { | ||
| 19 | if (arch.isARM() or arch.isThumb()) { | ||
| 20 | @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = linkage }); | ||
| 21 | } | ||
| 22 | } | ||
| 23 | } | ||
| 7 | 24 | ||
| 8 | pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { | 25 | pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { |
| 9 | @setRuntimeSafety(builtin.is_test); | 26 | @setRuntimeSafety(builtin.is_test); |
| ... | @@ -184,17 +201,6 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { | ... | @@ -184,17 +201,6 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { |
| 184 | } | 201 | } |
| 185 | } | 202 | } |
| 186 | 203 | ||
| 187 | fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { | ||
| 188 | @setRuntimeSafety(builtin.is_test); | ||
| 189 | const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | ||
| 190 | const significandBits = std.math.floatMantissaBits(T); | ||
| 191 | const implicitBit = @as(Z, 1) << significandBits; | ||
| 192 | |||
| 193 | const shift = @clz(Z, significand.*) - @clz(Z, implicitBit); | ||
| 194 | significand.* <<= @intCast(std.math.Log2Int(Z), shift); | ||
| 195 | return 1 - shift; | ||
| 196 | } | ||
| 197 | |||
| 198 | pub fn __aeabi_fdiv(a: f32, b: f32) callconv(.AAPCS) f32 { | 204 | pub fn __aeabi_fdiv(a: f32, b: f32) callconv(.AAPCS) f32 { |
| 199 | @setRuntimeSafety(false); | 205 | @setRuntimeSafety(false); |
| 200 | return @call(.{ .modifier = .always_inline }, __divsf3, .{ a, b }); | 206 | return @call(.{ .modifier = .always_inline }, __divsf3, .{ a, b }); |
lib/compiler_rt/divtf3.zig+21-2| ... | @@ -1,8 +1,27 @@ | ... | @@ -1,8 +1,27 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | ||
| 4 | const is_test = builtin.is_test; | ||
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 3 | 6 | ||
| 4 | const normalize = @import("divdf3.zig").normalize; | 7 | const common = @import("common.zig"); |
| 5 | const wideMultiply = @import("divdf3.zig").wideMultiply; | 8 | const normalize = common.normalize; |
| 9 | const wideMultiply = common.wideMultiply; | ||
| 10 | pub const panic = common.panic; | ||
| 11 | |||
| 12 | comptime { | ||
| 13 | @export(__divtf3, .{ .name = "__divtf3", .linkage = linkage }); | ||
| 14 | |||
| 15 | if (!is_test) { | ||
| 16 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 17 | @export(__divkf3, .{ .name = "__divkf3", .linkage = linkage }); | ||
| 18 | } | ||
| 19 | } | ||
| 20 | } | ||
| 21 | |||
| 22 | pub fn __divkf3(a: f128, b: f128) callconv(.C) f128 { | ||
| 23 | return @call(.{ .modifier = .always_inline }, __divtf3, .{ a, b }); | ||
| 24 | } | ||
| 6 | 25 | ||
| 7 | pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 { | 26 | pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 { |
| 8 | @setRuntimeSafety(builtin.is_test); | 27 | @setRuntimeSafety(builtin.is_test); |
lib/compiler_rt/divti3.zig+27-1| ... | @@ -1,5 +1,31 @@ | ... | @@ -1,5 +1,31 @@ |
| 1 | const udivmod = @import("udivmod.zig").udivmod; | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const udivmod = @import("udivmod.zig").udivmod; | ||
| 4 | const arch = builtin.cpu.arch; | ||
| 5 | const is_test = builtin.is_test; | ||
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 8 | |||
| 9 | comptime { | ||
| 10 | if (builtin.os.tag == .windows) { | ||
| 11 | switch (arch) { | ||
| 12 | .i386 => { | ||
| 13 | @export(__divti3, .{ .name = "__divti3", .linkage = linkage }); | ||
| 14 | }, | ||
| 15 | .x86_64 => { | ||
| 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | ||
| 17 | // that LLVM expects compiler-rt to have. | ||
| 18 | @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = linkage }); | ||
| 19 | }, | ||
| 20 | else => {}, | ||
| 21 | } | ||
| 22 | if (arch.isAARCH64()) { | ||
| 23 | @export(__divti3, .{ .name = "__divti3", .linkage = linkage }); | ||
| 24 | } | ||
| 25 | } else { | ||
| 26 | @export(__divti3, .{ .name = "__divti3", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 3 | 29 | ||
| 4 | pub fn __divti3(a: i128, b: i128) callconv(.C) i128 { | 30 | pub fn __divti3(a: i128, b: i128) callconv(.C) i128 { |
| 5 | @setRuntimeSafety(builtin.is_test); | 31 | @setRuntimeSafety(builtin.is_test); |
lib/compiler_rt/divxf3.zig+12-2| ... | @@ -1,7 +1,17 @@ | ... | @@ -1,7 +1,17 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const normalize = @import("divdf3.zig").normalize; | 3 | const arch = builtin.cpu.arch; |
| 4 | const wideMultiply = @import("divdf3.zig").wideMultiply; | 4 | const is_test = builtin.is_test; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | |||
| 7 | const common = @import("common.zig"); | ||
| 8 | const normalize = common.normalize; | ||
| 9 | const wideMultiply = common.wideMultiply; | ||
| 10 | pub const panic = common.panic; | ||
| 11 | |||
| 12 | comptime { | ||
| 13 | @export(__divxf3, .{ .name = "__divxf3", .linkage = linkage }); | ||
| 14 | } | ||
| 5 | 15 | ||
| 6 | pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 { | 16 | pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 { |
| 7 | @setRuntimeSafety(builtin.is_test); | 17 | @setRuntimeSafety(builtin.is_test); |
lib/compiler_rt/emutls.zig+13-1| ... | @@ -6,6 +6,8 @@ | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 10 | pub const panic = @import("common.zig").panic; | ||
| 9 | 11 | ||
| 10 | const abort = std.os.abort; | 12 | const abort = std.os.abort; |
| 11 | const assert = std.debug.assert; | 13 | const assert = std.debug.assert; |
| ... | @@ -16,7 +18,9 @@ const expect = std.testing.expect; | ... | @@ -16,7 +18,9 @@ const expect = std.testing.expect; |
| 16 | const gcc_word = usize; | 18 | const gcc_word = usize; |
| 17 | 19 | ||
| 18 | comptime { | 20 | comptime { |
| 19 | assert(builtin.link_libc); | 21 | if (builtin.link_libc and builtin.os.tag == .openbsd) { |
| 22 | @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage }); | ||
| 23 | } | ||
| 20 | } | 24 | } |
| 21 | 25 | ||
| 22 | /// public entrypoint for generated code using EmulatedTLS | 26 | /// public entrypoint for generated code using EmulatedTLS |
| ... | @@ -319,6 +323,8 @@ const emutls_control = extern struct { | ... | @@ -319,6 +323,8 @@ const emutls_control = extern struct { |
| 319 | }; | 323 | }; |
| 320 | 324 | ||
| 321 | test "simple_allocator" { | 325 | test "simple_allocator" { |
| 326 | if (!builtin.link_libc or builtin.os.tag != .openbsd) return error.SkipZigTest; | ||
| 327 | |||
| 322 | var data1: *[64]u8 = simple_allocator.alloc([64]u8); | 328 | var data1: *[64]u8 = simple_allocator.alloc([64]u8); |
| 323 | defer simple_allocator.free(data1); | 329 | defer simple_allocator.free(data1); |
| 324 | for (data1) |*c| { | 330 | for (data1) |*c| { |
| ... | @@ -333,6 +339,8 @@ test "simple_allocator" { | ... | @@ -333,6 +339,8 @@ test "simple_allocator" { |
| 333 | } | 339 | } |
| 334 | 340 | ||
| 335 | test "__emutls_get_address zeroed" { | 341 | test "__emutls_get_address zeroed" { |
| 342 | if (!builtin.link_libc or builtin.os.tag != .openbsd) return error.SkipZigTest; | ||
| 343 | |||
| 336 | var ctl = emutls_control.init(usize, null); | 344 | var ctl = emutls_control.init(usize, null); |
| 337 | try expect(ctl.object.index == 0); | 345 | try expect(ctl.object.index == 0); |
| 338 | 346 | ||
| ... | @@ -352,6 +360,8 @@ test "__emutls_get_address zeroed" { | ... | @@ -352,6 +360,8 @@ test "__emutls_get_address zeroed" { |
| 352 | } | 360 | } |
| 353 | 361 | ||
| 354 | test "__emutls_get_address with default_value" { | 362 | test "__emutls_get_address with default_value" { |
| 363 | if (!builtin.link_libc or builtin.os.tag != .openbsd) return error.SkipZigTest; | ||
| 364 | |||
| 355 | var value: usize = 5678; // default value | 365 | var value: usize = 5678; // default value |
| 356 | var ctl = emutls_control.init(usize, &value); | 366 | var ctl = emutls_control.init(usize, &value); |
| 357 | try expect(ctl.object.index == 0); | 367 | try expect(ctl.object.index == 0); |
| ... | @@ -370,6 +380,8 @@ test "__emutls_get_address with default_value" { | ... | @@ -370,6 +380,8 @@ test "__emutls_get_address with default_value" { |
| 370 | } | 380 | } |
| 371 | 381 | ||
| 372 | test "test default_value with differents sizes" { | 382 | test "test default_value with differents sizes" { |
| 383 | if (!builtin.link_libc or builtin.os.tag != .openbsd) return error.SkipZigTest; | ||
| 384 | |||
| 373 | const testType = struct { | 385 | const testType = struct { |
| 374 | fn _testType(comptime T: type, value: T) !void { | 386 | fn _testType(comptime T: type, value: T) !void { |
| 375 | var def: T = value; | 387 | var def: T = value; |
lib/compiler_rt/exp.zig+23| ... | @@ -5,8 +5,27 @@ | ... | @@ -5,8 +5,27 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/exp.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/exp.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 9 | const arch = builtin.cpu.arch; | ||
| 8 | const math = std.math; | 10 | const math = std.math; |
| 9 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | @export(__exph, .{ .name = "__exph", .linkage = linkage }); | ||
| 17 | @export(expf, .{ .name = "expf", .linkage = linkage }); | ||
| 18 | @export(exp, .{ .name = "exp", .linkage = linkage }); | ||
| 19 | @export(__expx, .{ .name = "__expx", .linkage = linkage }); | ||
| 20 | @export(expq, .{ .name = "expq", .linkage = linkage }); | ||
| 21 | @export(expl, .{ .name = "expl", .linkage = linkage }); | ||
| 22 | |||
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(expf128, .{ .name = "expf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 10 | 29 | ||
| 11 | pub fn __exph(a: f16) callconv(.C) f16 { | 30 | pub fn __exph(a: f16) callconv(.C) f16 { |
| 12 | // TODO: more efficient implementation | 31 | // TODO: more efficient implementation |
| ... | @@ -182,6 +201,10 @@ pub fn expq(a: f128) callconv(.C) f128 { | ... | @@ -182,6 +201,10 @@ pub fn expq(a: f128) callconv(.C) f128 { |
| 182 | return exp(@floatCast(f64, a)); | 201 | return exp(@floatCast(f64, a)); |
| 183 | } | 202 | } |
| 184 | 203 | ||
| 204 | pub fn expf128(a: f128) callconv(.C) f128 { | ||
| 205 | return @call(.{ .modifier = .always_inline }, expq, .{a}); | ||
| 206 | } | ||
| 207 | |||
| 185 | pub fn expl(x: c_longdouble) callconv(.C) c_longdouble { | 208 | pub fn expl(x: c_longdouble) callconv(.C) c_longdouble { |
| 186 | switch (@typeInfo(c_longdouble).Float.bits) { | 209 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 187 | 16 => return __exph(x), | 210 | 16 => return __exph(x), |
lib/compiler_rt/exp2.zig+23| ... | @@ -5,8 +5,27 @@ | ... | @@ -5,8 +5,27 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/exp2.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/exp2.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 9 | const arch = builtin.cpu.arch; | ||
| 8 | const math = std.math; | 10 | const math = std.math; |
| 9 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | @export(__exp2h, .{ .name = "__exp2h", .linkage = linkage }); | ||
| 17 | @export(exp2f, .{ .name = "exp2f", .linkage = linkage }); | ||
| 18 | @export(exp2, .{ .name = "exp2", .linkage = linkage }); | ||
| 19 | @export(__exp2x, .{ .name = "__exp2x", .linkage = linkage }); | ||
| 20 | @export(exp2q, .{ .name = "exp2q", .linkage = linkage }); | ||
| 21 | @export(exp2l, .{ .name = "exp2l", .linkage = linkage }); | ||
| 22 | |||
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(exp2f128, .{ .name = "exp2f128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 10 | 29 | ||
| 11 | pub fn __exp2h(x: f16) callconv(.C) f16 { | 30 | pub fn __exp2h(x: f16) callconv(.C) f16 { |
| 12 | // TODO: more efficient implementation | 31 | // TODO: more efficient implementation |
| ... | @@ -149,6 +168,10 @@ pub fn exp2q(x: f128) callconv(.C) f128 { | ... | @@ -149,6 +168,10 @@ pub fn exp2q(x: f128) callconv(.C) f128 { |
| 149 | return exp2(@floatCast(f64, x)); | 168 | return exp2(@floatCast(f64, x)); |
| 150 | } | 169 | } |
| 151 | 170 | ||
| 171 | pub fn exp2f128(x: f128) callconv(.C) f128 { | ||
| 172 | return @call(.{ .modifier = .always_inline }, exp2q, .{x}); | ||
| 173 | } | ||
| 174 | |||
| 152 | pub fn exp2l(x: c_longdouble) callconv(.C) c_longdouble { | 175 | pub fn exp2l(x: c_longdouble) callconv(.C) c_longdouble { |
| 153 | switch (@typeInfo(c_longdouble).Float.bits) { | 176 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 154 | 16 => return __exp2h(x), | 177 | 16 => return __exp2h(x), |
lib/compiler_rt/extendXfYf2.zig+38-2| ... | @@ -1,7 +1,31 @@ | ... | @@ -1,7 +1,31 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 3 | const is_test = builtin.is_test; |
| 4 | const native_arch = builtin.cpu.arch; | 4 | const arch = builtin.cpu.arch; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage }); | ||
| 10 | @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = linkage }); | ||
| 11 | @export(__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = linkage }); | ||
| 12 | @export(__extendhftf2, .{ .name = "__extendhftf2", .linkage = linkage }); | ||
| 13 | @export(__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = linkage }); | ||
| 14 | |||
| 15 | if (!is_test) { | ||
| 16 | @export(__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = linkage }); | ||
| 17 | |||
| 18 | if (arch.isARM() or arch.isThumb()) { | ||
| 19 | @export(__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = linkage }); | ||
| 20 | @export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = linkage }); | ||
| 21 | } | ||
| 22 | |||
| 23 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 24 | @export(__extendsfkf2, .{ .name = "__extendsfkf2", .linkage = linkage }); | ||
| 25 | @export(__extenddfkf2, .{ .name = "__extenddfkf2", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 5 | 29 | ||
| 6 | pub fn __extendsfdf2(a: f32) callconv(.C) f64 { | 30 | pub fn __extendsfdf2(a: f32) callconv(.C) f64 { |
| 7 | return extendXfYf2(f64, f32, @bitCast(u32, a)); | 31 | return extendXfYf2(f64, f32, @bitCast(u32, a)); |
| ... | @@ -11,18 +35,30 @@ pub fn __extenddftf2(a: f64) callconv(.C) f128 { | ... | @@ -11,18 +35,30 @@ pub fn __extenddftf2(a: f64) callconv(.C) f128 { |
| 11 | return extendXfYf2(f128, f64, @bitCast(u64, a)); | 35 | return extendXfYf2(f128, f64, @bitCast(u64, a)); |
| 12 | } | 36 | } |
| 13 | 37 | ||
| 38 | pub fn __extenddfkf2(a: f64) callconv(.C) f128 { | ||
| 39 | return @call(.{ .modifier = .always_inline }, __extenddftf2, .{a}); | ||
| 40 | } | ||
| 41 | |||
| 14 | pub fn __extendsftf2(a: f32) callconv(.C) f128 { | 42 | pub fn __extendsftf2(a: f32) callconv(.C) f128 { |
| 15 | return extendXfYf2(f128, f32, @bitCast(u32, a)); | 43 | return extendXfYf2(f128, f32, @bitCast(u32, a)); |
| 16 | } | 44 | } |
| 17 | 45 | ||
| 46 | pub fn __extendsfkf2(a: f32) callconv(.C) f128 { | ||
| 47 | return @call(.{ .modifier = .always_inline }, __extendsftf2, .{a}); | ||
| 48 | } | ||
| 49 | |||
| 18 | // AArch64 is the only ABI (at the moment) to support f16 arguments without the | 50 | // AArch64 is the only ABI (at the moment) to support f16 arguments without the |
| 19 | // need for extending them to wider fp types. | 51 | // need for extending them to wider fp types. |
| 20 | pub const F16T = if (native_arch.isAARCH64()) f16 else u16; | 52 | pub const F16T = if (arch.isAARCH64()) f16 else u16; |
| 21 | 53 | ||
| 22 | pub fn __extendhfsf2(a: F16T) callconv(.C) f32 { | 54 | pub fn __extendhfsf2(a: F16T) callconv(.C) f32 { |
| 23 | return extendXfYf2(f32, f16, @bitCast(u16, a)); | 55 | return extendXfYf2(f32, f16, @bitCast(u16, a)); |
| 24 | } | 56 | } |
| 25 | 57 | ||
| 58 | pub fn __gnu_h2f_ieee(a: F16T) callconv(.C) f32 { | ||
| 59 | return @call(.{ .modifier = .always_inline }, __extendhfsf2, .{a}); | ||
| 60 | } | ||
| 61 | |||
| 26 | pub fn __extendhftf2(a: F16T) callconv(.C) f128 { | 62 | pub fn __extendhftf2(a: F16T) callconv(.C) f128 { |
| 27 | return extendXfYf2(f128, f16, @bitCast(u16, a)); | 63 | return extendXfYf2(f128, f16, @bitCast(u16, a)); |
| 28 | } | 64 | } |
lib/compiler_rt/extend_f80.zig+15-6| ... | @@ -1,21 +1,30 @@ | ... | @@ -1,21 +1,30 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 3 | const is_test = builtin.is_test; |
| 4 | const native_arch = builtin.cpu.arch; | 4 | const arch = builtin.cpu.arch; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | @export(__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = linkage }); | ||
| 10 | @export(__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = linkage }); | ||
| 11 | @export(__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = linkage }); | ||
| 12 | @export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = linkage }); | ||
| 13 | } | ||
| 5 | 14 | ||
| 6 | // AArch64 is the only ABI (at the moment) to support f16 arguments without the | 15 | // AArch64 is the only ABI (at the moment) to support f16 arguments without the |
| 7 | // need for extending them to wider fp types. | 16 | // need for extending them to wider fp types. |
| 8 | pub const F16T = if (native_arch.isAARCH64()) f16 else u16; | 17 | const F16T = if (arch.isAARCH64()) f16 else u16; |
| 9 | 18 | ||
| 10 | pub fn __extendhfxf2(a: F16T) callconv(.C) f80 { | 19 | fn __extendhfxf2(a: F16T) callconv(.C) f80 { |
| 11 | return extendF80(f16, @bitCast(u16, a)); | 20 | return extendF80(f16, @bitCast(u16, a)); |
| 12 | } | 21 | } |
| 13 | 22 | ||
| 14 | pub fn __extendsfxf2(a: f32) callconv(.C) f80 { | 23 | fn __extendsfxf2(a: f32) callconv(.C) f80 { |
| 15 | return extendF80(f32, @bitCast(u32, a)); | 24 | return extendF80(f32, @bitCast(u32, a)); |
| 16 | } | 25 | } |
| 17 | 26 | ||
| 18 | pub fn __extenddfxf2(a: f64) callconv(.C) f80 { | 27 | fn __extenddfxf2(a: f64) callconv(.C) f80 { |
| 19 | return extendF80(f64, @bitCast(u64, a)); | 28 | return extendF80(f64, @bitCast(u64, a)); |
| 20 | } | 29 | } |
| 21 | 30 | ||
| ... | @@ -86,7 +95,7 @@ inline fn extendF80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(s | ... | @@ -86,7 +95,7 @@ inline fn extendF80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(s |
| 86 | return std.math.make_f80(dst); | 95 | return std.math.make_f80(dst); |
| 87 | } | 96 | } |
| 88 | 97 | ||
| 89 | pub fn __extendxftf2(a: f80) callconv(.C) f128 { | 98 | fn __extendxftf2(a: f80) callconv(.C) f128 { |
| 90 | @setRuntimeSafety(builtin.is_test); | 99 | @setRuntimeSafety(builtin.is_test); |
| 91 | 100 | ||
| 92 | const src_int_bit: u64 = 0x8000000000000000; | 101 | const src_int_bit: u64 = 0x8000000000000000; |
lib/compiler_rt/fabs.zig+23| ... | @@ -1,4 +1,23 @@ | ... | @@ -1,4 +1,23 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 3 | const arch = builtin.cpu.arch; | ||
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__fabsh, .{ .name = "__fabsh", .linkage = linkage }); | ||
| 9 | @export(fabsf, .{ .name = "fabsf", .linkage = linkage }); | ||
| 10 | @export(fabs, .{ .name = "fabs", .linkage = linkage }); | ||
| 11 | @export(__fabsx, .{ .name = "__fabsx", .linkage = linkage }); | ||
| 12 | @export(fabsq, .{ .name = "fabsq", .linkage = linkage }); | ||
| 13 | @export(fabsl, .{ .name = "fabsl", .linkage = linkage }); | ||
| 14 | |||
| 15 | if (!builtin.is_test) { | ||
| 16 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 17 | @export(fabsf128, .{ .name = "fabsf128", .linkage = linkage }); | ||
| 18 | } | ||
| 19 | } | ||
| 20 | } | ||
| 2 | 21 | ||
| 3 | pub fn __fabsh(a: f16) callconv(.C) f16 { | 22 | pub fn __fabsh(a: f16) callconv(.C) f16 { |
| 4 | return generic_fabs(a); | 23 | return generic_fabs(a); |
| ... | @@ -20,6 +39,10 @@ pub fn fabsq(a: f128) callconv(.C) f128 { | ... | @@ -20,6 +39,10 @@ pub fn fabsq(a: f128) callconv(.C) f128 { |
| 20 | return generic_fabs(a); | 39 | return generic_fabs(a); |
| 21 | } | 40 | } |
| 22 | 41 | ||
| 42 | pub fn fabsf128(a: f128) callconv(.C) f128 { | ||
| 43 | return @call(.{ .modifier = .always_inline }, fabsq, .{a}); | ||
| 44 | } | ||
| 45 | |||
| 23 | pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble { | 46 | pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble { |
| 24 | switch (@typeInfo(c_longdouble).Float.bits) { | 47 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 25 | 16 => return __fabsh(x), | 48 | 16 => return __fabsh(x), |
lib/compiler_rt/fixXfYi.zig+89-1| ... | @@ -1,7 +1,79 @@ | ... | @@ -1,7 +1,79 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 2 | const math = std.math; | 3 | const math = std.math; |
| 3 | const Log2Int = math.Log2Int; | 4 | const Log2Int = math.Log2Int; |
| 4 | const is_test = @import("builtin").is_test; | 5 | const arch = builtin.cpu.arch; |
| 6 | const is_test = builtin.is_test; | ||
| 7 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 8 | pub const panic = @import("common.zig").panic; | ||
| 9 | |||
| 10 | comptime { | ||
| 11 | // Float -> Integral Conversion | ||
| 12 | |||
| 13 | // Conversion from f32 | ||
| 14 | @export(__fixsfsi, .{ .name = "__fixsfsi", .linkage = linkage }); | ||
| 15 | @export(__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = linkage }); | ||
| 16 | |||
| 17 | @export(__fixsfdi, .{ .name = "__fixsfdi", .linkage = linkage }); | ||
| 18 | @export(__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = linkage }); | ||
| 19 | |||
| 20 | @export(__fixsfti, .{ .name = "__fixsfti", .linkage = linkage }); | ||
| 21 | @export(__fixunssfti, .{ .name = "__fixunssfti", .linkage = linkage }); | ||
| 22 | |||
| 23 | // Conversion from f64 | ||
| 24 | @export(__fixdfsi, .{ .name = "__fixdfsi", .linkage = linkage }); | ||
| 25 | @export(__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = linkage }); | ||
| 26 | |||
| 27 | @export(__fixdfdi, .{ .name = "__fixdfdi", .linkage = linkage }); | ||
| 28 | @export(__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = linkage }); | ||
| 29 | |||
| 30 | @export(__fixdfti, .{ .name = "__fixdfti", .linkage = linkage }); | ||
| 31 | @export(__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = linkage }); | ||
| 32 | |||
| 33 | // Conversion from f80 | ||
| 34 | @export(__fixxfsi, .{ .name = "__fixxfsi", .linkage = linkage }); | ||
| 35 | @export(__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = linkage }); | ||
| 36 | |||
| 37 | @export(__fixxfdi, .{ .name = "__fixxfdi", .linkage = linkage }); | ||
| 38 | @export(__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = linkage }); | ||
| 39 | |||
| 40 | @export(__fixxfti, .{ .name = "__fixxfti", .linkage = linkage }); | ||
| 41 | @export(__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = linkage }); | ||
| 42 | |||
| 43 | // Conversion from f128 | ||
| 44 | @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = linkage }); | ||
| 45 | @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = linkage }); | ||
| 46 | |||
| 47 | @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = linkage }); | ||
| 48 | @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = linkage }); | ||
| 49 | |||
| 50 | @export(__fixtfti, .{ .name = "__fixtfti", .linkage = linkage }); | ||
| 51 | @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = linkage }); | ||
| 52 | |||
| 53 | if (!is_test) { | ||
| 54 | if (arch.isARM() or arch.isThumb()) { | ||
| 55 | @export(__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = linkage }); | ||
| 56 | @export(__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = linkage }); | ||
| 57 | |||
| 58 | @export(__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = linkage }); | ||
| 59 | @export(__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = linkage }); | ||
| 60 | |||
| 61 | @export(__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = linkage }); | ||
| 62 | |||
| 63 | @export(__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = linkage }); | ||
| 64 | |||
| 65 | @export(__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = linkage }); | ||
| 66 | @export(__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = linkage }); | ||
| 67 | } | ||
| 68 | |||
| 69 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 70 | @export(__fixkfdi, .{ .name = "__fixkfdi", .linkage = linkage }); | ||
| 71 | @export(__fixkfsi, .{ .name = "__fixkfsi", .linkage = linkage }); | ||
| 72 | @export(__fixunskfsi, .{ .name = "__fixunskfsi", .linkage = linkage }); | ||
| 73 | @export(__fixunskfdi, .{ .name = "__fixunskfdi", .linkage = linkage }); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 5 | 77 | ||
| 6 | pub inline fn fixXfYi(comptime I: type, a: anytype) I { | 78 | pub inline fn fixXfYi(comptime I: type, a: anytype) I { |
| 7 | @setRuntimeSafety(is_test); | 79 | @setRuntimeSafety(is_test); |
| ... | @@ -163,18 +235,34 @@ pub fn __fixtfsi(a: f128) callconv(.C) i32 { | ... | @@ -163,18 +235,34 @@ pub fn __fixtfsi(a: f128) callconv(.C) i32 { |
| 163 | return fixXfYi(i32, a); | 235 | return fixXfYi(i32, a); |
| 164 | } | 236 | } |
| 165 | 237 | ||
| 238 | pub fn __fixkfsi(a: f128) callconv(.C) i32 { | ||
| 239 | return __fixtfsi(a); | ||
| 240 | } | ||
| 241 | |||
| 166 | pub fn __fixunstfsi(a: f128) callconv(.C) u32 { | 242 | pub fn __fixunstfsi(a: f128) callconv(.C) u32 { |
| 167 | return fixXfYi(u32, a); | 243 | return fixXfYi(u32, a); |
| 168 | } | 244 | } |
| 169 | 245 | ||
| 246 | pub fn __fixunskfsi(a: f128) callconv(.C) u32 { | ||
| 247 | return @call(.{ .modifier = .always_inline }, __fixunstfsi, .{a}); | ||
| 248 | } | ||
| 249 | |||
| 170 | pub fn __fixtfdi(a: f128) callconv(.C) i64 { | 250 | pub fn __fixtfdi(a: f128) callconv(.C) i64 { |
| 171 | return fixXfYi(i64, a); | 251 | return fixXfYi(i64, a); |
| 172 | } | 252 | } |
| 173 | 253 | ||
| 254 | pub fn __fixkfdi(a: f128) callconv(.C) i64 { | ||
| 255 | return @call(.{ .modifier = .always_inline }, __fixtfdi, .{a}); | ||
| 256 | } | ||
| 257 | |||
| 174 | pub fn __fixunstfdi(a: f128) callconv(.C) u64 { | 258 | pub fn __fixunstfdi(a: f128) callconv(.C) u64 { |
| 175 | return fixXfYi(u64, a); | 259 | return fixXfYi(u64, a); |
| 176 | } | 260 | } |
| 177 | 261 | ||
| 262 | pub fn __fixunskfdi(a: f128) callconv(.C) u64 { | ||
| 263 | return @call(.{ .modifier = .always_inline }, __fixunstfdi, .{a}); | ||
| 264 | } | ||
| 265 | |||
| 178 | pub fn __fixtfti(a: f128) callconv(.C) i128 { | 266 | pub fn __fixtfti(a: f128) callconv(.C) i128 { |
| 179 | return fixXfYi(i128, a); | 267 | return fixXfYi(i128, a); |
| 180 | } | 268 | } |
lib/compiler_rt/floatXiYf.zig+90-1| ... | @@ -1,8 +1,77 @@ | ... | @@ -1,8 +1,77 @@ |
| 1 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | const is_test = builtin.is_test; | ||
| 3 | const std = @import("std"); | 2 | const std = @import("std"); |
| 4 | const math = std.math; | 3 | const math = std.math; |
| 5 | const expect = std.testing.expect; | 4 | const expect = std.testing.expect; |
| 5 | const arch = builtin.cpu.arch; | ||
| 6 | const is_test = builtin.is_test; | ||
| 7 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 8 | pub const panic = @import("common.zig").panic; | ||
| 9 | |||
| 10 | comptime { | ||
| 11 | // Integral -> Float Conversion | ||
| 12 | |||
| 13 | // Conversion to f32 | ||
| 14 | @export(__floatsisf, .{ .name = "__floatsisf", .linkage = linkage }); | ||
| 15 | @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = linkage }); | ||
| 16 | |||
| 17 | @export(__floatundisf, .{ .name = "__floatundisf", .linkage = linkage }); | ||
| 18 | @export(__floatdisf, .{ .name = "__floatdisf", .linkage = linkage }); | ||
| 19 | |||
| 20 | @export(__floattisf, .{ .name = "__floattisf", .linkage = linkage }); | ||
| 21 | @export(__floatuntisf, .{ .name = "__floatuntisf", .linkage = linkage }); | ||
| 22 | |||
| 23 | // Conversion to f64 | ||
| 24 | @export(__floatsidf, .{ .name = "__floatsidf", .linkage = linkage }); | ||
| 25 | @export(__floatunsidf, .{ .name = "__floatunsidf", .linkage = linkage }); | ||
| 26 | |||
| 27 | @export(__floatdidf, .{ .name = "__floatdidf", .linkage = linkage }); | ||
| 28 | @export(__floatundidf, .{ .name = "__floatundidf", .linkage = linkage }); | ||
| 29 | |||
| 30 | @export(__floattidf, .{ .name = "__floattidf", .linkage = linkage }); | ||
| 31 | @export(__floatuntidf, .{ .name = "__floatuntidf", .linkage = linkage }); | ||
| 32 | |||
| 33 | // Conversion to f80 | ||
| 34 | @export(__floatsixf, .{ .name = "__floatsixf", .linkage = linkage }); | ||
| 35 | @export(__floatunsixf, .{ .name = "__floatunsixf", .linkage = linkage }); | ||
| 36 | |||
| 37 | @export(__floatdixf, .{ .name = "__floatdixf", .linkage = linkage }); | ||
| 38 | @export(__floatundixf, .{ .name = "__floatundixf", .linkage = linkage }); | ||
| 39 | |||
| 40 | @export(__floattixf, .{ .name = "__floattixf", .linkage = linkage }); | ||
| 41 | @export(__floatuntixf, .{ .name = "__floatuntixf", .linkage = linkage }); | ||
| 42 | |||
| 43 | // Conversion to f128 | ||
| 44 | @export(__floatsitf, .{ .name = "__floatsitf", .linkage = linkage }); | ||
| 45 | @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = linkage }); | ||
| 46 | |||
| 47 | @export(__floatditf, .{ .name = "__floatditf", .linkage = linkage }); | ||
| 48 | @export(__floatunditf, .{ .name = "__floatunditf", .linkage = linkage }); | ||
| 49 | |||
| 50 | @export(__floattitf, .{ .name = "__floattitf", .linkage = linkage }); | ||
| 51 | @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = linkage }); | ||
| 52 | |||
| 53 | if (!is_test) { | ||
| 54 | if (arch.isARM() or arch.isThumb()) { | ||
| 55 | @export(__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = linkage }); | ||
| 56 | @export(__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = linkage }); | ||
| 57 | @export(__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = linkage }); | ||
| 58 | @export(__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = linkage }); | ||
| 59 | @export(__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = linkage }); | ||
| 60 | @export(__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = linkage }); | ||
| 61 | @export(__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = linkage }); | ||
| 62 | |||
| 63 | @export(__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = linkage }); | ||
| 64 | } | ||
| 65 | |||
| 66 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 67 | @export(__floatsikf, .{ .name = "__floatsikf", .linkage = linkage }); | ||
| 68 | @export(__floatdikf, .{ .name = "__floatdikf", .linkage = linkage }); | ||
| 69 | @export(__floatundikf, .{ .name = "__floatundikf", .linkage = linkage }); | ||
| 70 | @export(__floatunsikf, .{ .name = "__floatunsikf", .linkage = linkage }); | ||
| 71 | @export(__floatuntikf, .{ .name = "__floatuntikf", .linkage = linkage }); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 6 | 75 | ||
| 7 | pub fn floatXiYf(comptime T: type, x: anytype) T { | 76 | pub fn floatXiYf(comptime T: type, x: anytype) T { |
| 8 | @setRuntimeSafety(is_test); | 77 | @setRuntimeSafety(is_test); |
| ... | @@ -163,18 +232,34 @@ pub fn __floatsitf(a: i32) callconv(.C) f128 { | ... | @@ -163,18 +232,34 @@ pub fn __floatsitf(a: i32) callconv(.C) f128 { |
| 163 | return floatXiYf(f128, a); | 232 | return floatXiYf(f128, a); |
| 164 | } | 233 | } |
| 165 | 234 | ||
| 235 | pub fn __floatsikf(a: i32) callconv(.C) f128 { | ||
| 236 | return @call(.{ .modifier = .always_inline }, __floatsitf, .{a}); | ||
| 237 | } | ||
| 238 | |||
| 166 | pub fn __floatunsitf(a: u32) callconv(.C) f128 { | 239 | pub fn __floatunsitf(a: u32) callconv(.C) f128 { |
| 167 | return floatXiYf(f128, a); | 240 | return floatXiYf(f128, a); |
| 168 | } | 241 | } |
| 169 | 242 | ||
| 243 | pub fn __floatunsikf(a: u32) callconv(.C) f128 { | ||
| 244 | return @call(.{ .modifier = .always_inline }, __floatunsitf, .{a}); | ||
| 245 | } | ||
| 246 | |||
| 170 | pub fn __floatditf(a: i64) callconv(.C) f128 { | 247 | pub fn __floatditf(a: i64) callconv(.C) f128 { |
| 171 | return floatXiYf(f128, a); | 248 | return floatXiYf(f128, a); |
| 172 | } | 249 | } |
| 173 | 250 | ||
| 251 | pub fn __floatdikf(a: i64) callconv(.C) f128 { | ||
| 252 | return @call(.{ .modifier = .always_inline }, __floatditf, .{a}); | ||
| 253 | } | ||
| 254 | |||
| 174 | pub fn __floatunditf(a: u64) callconv(.C) f128 { | 255 | pub fn __floatunditf(a: u64) callconv(.C) f128 { |
| 175 | return floatXiYf(f128, a); | 256 | return floatXiYf(f128, a); |
| 176 | } | 257 | } |
| 177 | 258 | ||
| 259 | pub fn __floatundikf(a: u64) callconv(.C) f128 { | ||
| 260 | return @call(.{ .modifier = .always_inline }, __floatunditf, .{a}); | ||
| 261 | } | ||
| 262 | |||
| 178 | pub fn __floattitf(a: i128) callconv(.C) f128 { | 263 | pub fn __floattitf(a: i128) callconv(.C) f128 { |
| 179 | return floatXiYf(f128, a); | 264 | return floatXiYf(f128, a); |
| 180 | } | 265 | } |
| ... | @@ -183,6 +268,10 @@ pub fn __floatuntitf(a: u128) callconv(.C) f128 { | ... | @@ -183,6 +268,10 @@ pub fn __floatuntitf(a: u128) callconv(.C) f128 { |
| 183 | return floatXiYf(f128, a); | 268 | return floatXiYf(f128, a); |
| 184 | } | 269 | } |
| 185 | 270 | ||
| 271 | pub fn __floatuntikf(a: u128) callconv(.C) f128 { | ||
| 272 | return @call(.{ .modifier = .always_inline }, __floatuntitf, .{a}); | ||
| 273 | } | ||
| 274 | |||
| 186 | // Conversion to f32 | 275 | // Conversion to f32 |
| 187 | pub fn __aeabi_ui2f(arg: u32) callconv(.AAPCS) f32 { | 276 | pub fn __aeabi_ui2f(arg: u32) callconv(.AAPCS) f32 { |
| 188 | return floatXiYf(f32, arg); | 277 | return floatXiYf(f32, arg); |
lib/compiler_rt/floor.zig+23| ... | @@ -5,8 +5,27 @@ | ... | @@ -5,8 +5,27 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/floor.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/floor.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 8 | const math = std.math; | 9 | const math = std.math; |
| 9 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 11 | const arch = builtin.cpu.arch; | ||
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | @export(__floorh, .{ .name = "__floorh", .linkage = linkage }); | ||
| 17 | @export(floorf, .{ .name = "floorf", .linkage = linkage }); | ||
| 18 | @export(floor, .{ .name = "floor", .linkage = linkage }); | ||
| 19 | @export(__floorx, .{ .name = "__floorx", .linkage = linkage }); | ||
| 20 | @export(floorq, .{ .name = "floorq", .linkage = linkage }); | ||
| 21 | @export(floorl, .{ .name = "floorl", .linkage = linkage }); | ||
| 22 | |||
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(floorf128, .{ .name = "floorf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 10 | 29 | ||
| 11 | pub fn __floorh(x: f16) callconv(.C) f16 { | 30 | pub fn __floorh(x: f16) callconv(.C) f16 { |
| 12 | var u = @bitCast(u16, x); | 31 | var u = @bitCast(u16, x); |
| ... | @@ -141,6 +160,10 @@ pub fn floorq(x: f128) callconv(.C) f128 { | ... | @@ -141,6 +160,10 @@ pub fn floorq(x: f128) callconv(.C) f128 { |
| 141 | } | 160 | } |
| 142 | } | 161 | } |
| 143 | 162 | ||
| 163 | pub fn floorf128(x: f128) callconv(.C) f128 { | ||
| 164 | return @call(.{ .modifier = .always_inline }, floorq, .{x}); | ||
| 165 | } | ||
| 166 | |||
| 144 | pub fn floorl(x: c_longdouble) callconv(.C) c_longdouble { | 167 | pub fn floorl(x: c_longdouble) callconv(.C) c_longdouble { |
| 145 | switch (@typeInfo(c_longdouble).Float.bits) { | 168 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 146 | 16 => return __floorh(x), | 169 | 16 => return __floorh(x), |
lib/compiler_rt/fma.zig+23| ... | @@ -6,8 +6,27 @@ | ... | @@ -6,8 +6,27 @@ |
| 6 | // https://git.musl-libc.org/cgit/musl/tree/src/math/fma.c | 6 | // https://git.musl-libc.org/cgit/musl/tree/src/math/fma.c |
| 7 | 7 | ||
| 8 | const std = @import("std"); | 8 | const std = @import("std"); |
| 9 | const builtin = @import("builtin"); | ||
| 9 | const math = std.math; | 10 | const math = std.math; |
| 10 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const arch = builtin.cpu.arch; | ||
| 13 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 14 | pub const panic = @import("common.zig").panic; | ||
| 15 | |||
| 16 | comptime { | ||
| 17 | @export(__fmah, .{ .name = "__fmah", .linkage = linkage }); | ||
| 18 | @export(fmaf, .{ .name = "fmaf", .linkage = linkage }); | ||
| 19 | @export(fma, .{ .name = "fma", .linkage = linkage }); | ||
| 20 | @export(__fmax, .{ .name = "__fmax", .linkage = linkage }); | ||
| 21 | @export(fmaq, .{ .name = "fmaq", .linkage = linkage }); | ||
| 22 | @export(fmal, .{ .name = "fmal", .linkage = linkage }); | ||
| 23 | |||
| 24 | if (!builtin.is_test) { | ||
| 25 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 26 | @export(fmaf128, .{ .name = "fmaf128", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | } | ||
| 11 | 30 | ||
| 12 | pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 { | 31 | pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 { |
| 13 | // TODO: more efficient implementation | 32 | // TODO: more efficient implementation |
| ... | @@ -135,6 +154,10 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.C) f128 { | ... | @@ -135,6 +154,10 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.C) f128 { |
| 135 | } | 154 | } |
| 136 | } | 155 | } |
| 137 | 156 | ||
| 157 | pub fn fmaf128(x: f128, y: f128, z: f128) callconv(.C) f128 { | ||
| 158 | return @call(.{ .modifier = .always_inline }, fmaq, .{ x, y, z }); | ||
| 159 | } | ||
| 160 | |||
| 138 | pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.C) c_longdouble { | 161 | pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.C) c_longdouble { |
| 139 | switch (@typeInfo(c_longdouble).Float.bits) { | 162 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 140 | 16 => return __fmah(x, y, z), | 163 | 16 => return __fmah(x, y, z), |
lib/compiler_rt/fmax.zig+23| ... | @@ -1,5 +1,24 @@ | ... | @@ -1,5 +1,24 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 2 | const math = std.math; | 3 | const math = std.math; |
| 4 | const arch = builtin.cpu.arch; | ||
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | @export(__fmaxh, .{ .name = "__fmaxh", .linkage = linkage }); | ||
| 10 | @export(fmaxf, .{ .name = "fmaxf", .linkage = linkage }); | ||
| 11 | @export(fmax, .{ .name = "fmax", .linkage = linkage }); | ||
| 12 | @export(__fmaxx, .{ .name = "__fmaxx", .linkage = linkage }); | ||
| 13 | @export(fmaxq, .{ .name = "fmaxq", .linkage = linkage }); | ||
| 14 | @export(fmaxl, .{ .name = "fmaxl", .linkage = linkage }); | ||
| 15 | |||
| 16 | if (!builtin.is_test) { | ||
| 17 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 18 | @export(fmaxf128, .{ .name = "fmaxf128", .linkage = linkage }); | ||
| 19 | } | ||
| 20 | } | ||
| 21 | } | ||
| 3 | 22 | ||
| 4 | pub fn __fmaxh(x: f16, y: f16) callconv(.C) f16 { | 23 | pub fn __fmaxh(x: f16, y: f16) callconv(.C) f16 { |
| 5 | return generic_fmax(f16, x, y); | 24 | return generic_fmax(f16, x, y); |
| ... | @@ -21,6 +40,10 @@ pub fn fmaxq(x: f128, y: f128) callconv(.C) f128 { | ... | @@ -21,6 +40,10 @@ pub fn fmaxq(x: f128, y: f128) callconv(.C) f128 { |
| 21 | return generic_fmax(f128, x, y); | 40 | return generic_fmax(f128, x, y); |
| 22 | } | 41 | } |
| 23 | 42 | ||
| 43 | pub fn fmaxf128(x: f128, y: f128) callconv(.C) f128 { | ||
| 44 | return @call(.{ .modifier = .always_inline }, fmaxq, .{ x, y }); | ||
| 45 | } | ||
| 46 | |||
| 24 | pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { | 47 | pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { |
| 25 | switch (@typeInfo(c_longdouble).Float.bits) { | 48 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 26 | 16 => return __fmaxh(x, y), | 49 | 16 => return __fmaxh(x, y), |
lib/compiler_rt/fmin.zig+23| ... | @@ -1,5 +1,24 @@ | ... | @@ -1,5 +1,24 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 2 | const math = std.math; | 3 | const math = std.math; |
| 4 | const arch = builtin.cpu.arch; | ||
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | @export(__fminh, .{ .name = "__fminh", .linkage = linkage }); | ||
| 10 | @export(fminf, .{ .name = "fminf", .linkage = linkage }); | ||
| 11 | @export(fmin, .{ .name = "fmin", .linkage = linkage }); | ||
| 12 | @export(__fminx, .{ .name = "__fminx", .linkage = linkage }); | ||
| 13 | @export(fminq, .{ .name = "fminq", .linkage = linkage }); | ||
| 14 | @export(fminl, .{ .name = "fminl", .linkage = linkage }); | ||
| 15 | |||
| 16 | if (!builtin.is_test) { | ||
| 17 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 18 | @export(fminf128, .{ .name = "fminf128", .linkage = linkage }); | ||
| 19 | } | ||
| 20 | } | ||
| 21 | } | ||
| 3 | 22 | ||
| 4 | pub fn __fminh(x: f16, y: f16) callconv(.C) f16 { | 23 | pub fn __fminh(x: f16, y: f16) callconv(.C) f16 { |
| 5 | return generic_fmin(f16, x, y); | 24 | return generic_fmin(f16, x, y); |
| ... | @@ -21,6 +40,10 @@ pub fn fminq(x: f128, y: f128) callconv(.C) f128 { | ... | @@ -21,6 +40,10 @@ pub fn fminq(x: f128, y: f128) callconv(.C) f128 { |
| 21 | return generic_fmin(f128, x, y); | 40 | return generic_fmin(f128, x, y); |
| 22 | } | 41 | } |
| 23 | 42 | ||
| 43 | pub fn fminf128(x: f128, y: f128) callconv(.C) f128 { | ||
| 44 | return @call(.{ .modifier = .always_inline }, fminq, .{ x, y }); | ||
| 45 | } | ||
| 46 | |||
| 24 | pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { | 47 | pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { |
| 25 | switch (@typeInfo(c_longdouble).Float.bits) { | 48 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 26 | 16 => return __fminh(x, y), | 49 | 16 => return __fminh(x, y), |
lib/compiler_rt/fmod.zig+25-1| ... | @@ -2,7 +2,27 @@ const builtin = @import("builtin"); | ... | @@ -2,7 +2,27 @@ const builtin = @import("builtin"); |
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | const math = std.math; | 3 | const math = std.math; |
| 4 | const assert = std.debug.assert; | 4 | const assert = std.debug.assert; |
| 5 | const normalize = @import("divdf3.zig").normalize; | 5 | const arch = builtin.cpu.arch; |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | |||
| 8 | const common = @import("common.zig"); | ||
| 9 | const normalize = common.normalize; | ||
| 10 | pub const panic = common.panic; | ||
| 11 | |||
| 12 | comptime { | ||
| 13 | @export(__fmodh, .{ .name = "__fmodh", .linkage = linkage }); | ||
| 14 | @export(fmodf, .{ .name = "fmodf", .linkage = linkage }); | ||
| 15 | @export(fmod, .{ .name = "fmod", .linkage = linkage }); | ||
| 16 | @export(__fmodx, .{ .name = "__fmodx", .linkage = linkage }); | ||
| 17 | @export(fmodq, .{ .name = "fmodq", .linkage = linkage }); | ||
| 18 | @export(fmodl, .{ .name = "fmodl", .linkage = linkage }); | ||
| 19 | |||
| 20 | if (!builtin.is_test) { | ||
| 21 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 22 | @export(fmodf128, .{ .name = "fmodf128", .linkage = linkage }); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
| 6 | 26 | ||
| 7 | pub fn __fmodh(x: f16, y: f16) callconv(.C) f16 { | 27 | pub fn __fmodh(x: f16, y: f16) callconv(.C) f16 { |
| 8 | // TODO: more efficient implementation | 28 | // TODO: more efficient implementation |
| ... | @@ -237,6 +257,10 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 { | ... | @@ -237,6 +257,10 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 { |
| 237 | return amod; | 257 | return amod; |
| 238 | } | 258 | } |
| 239 | 259 | ||
| 260 | pub fn fmodf128(a: f128, b: f128) callconv(.C) f128 { | ||
| 261 | return @call(.{ .modifier = .always_inline }, fmodq, .{ a, b }); | ||
| 262 | } | ||
| 263 | |||
| 240 | pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { | 264 | pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { |
| 241 | switch (@typeInfo(c_longdouble).Float.bits) { | 265 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 242 | 16 => return __fmodh(a, b), | 266 | 16 => return __fmodh(a, b), |
lib/compiler_rt/int.zig+35| ... | @@ -4,9 +4,36 @@ const std = @import("std"); | ... | @@ -4,9 +4,36 @@ const std = @import("std"); |
| 4 | const testing = std.testing; | 4 | const testing = std.testing; |
| 5 | const maxInt = std.math.maxInt; | 5 | const maxInt = std.math.maxInt; |
| 6 | const minInt = std.math.minInt; | 6 | const minInt = std.math.minInt; |
| 7 | const arch = builtin.cpu.arch; | ||
| 8 | const is_test = builtin.is_test; | ||
| 9 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 10 | pub const panic = @import("common.zig").panic; | ||
| 7 | 11 | ||
| 8 | const udivmod = @import("udivmod.zig").udivmod; | 12 | const udivmod = @import("udivmod.zig").udivmod; |
| 9 | 13 | ||
| 14 | comptime { | ||
| 15 | @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = linkage }); | ||
| 16 | @export(__mulsi3, .{ .name = "__mulsi3", .linkage = linkage }); | ||
| 17 | @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = linkage }); | ||
| 18 | @export(__divsi3, .{ .name = "__divsi3", .linkage = linkage }); | ||
| 19 | @export(__divdi3, .{ .name = "__divdi3", .linkage = linkage }); | ||
| 20 | @export(__udivsi3, .{ .name = "__udivsi3", .linkage = linkage }); | ||
| 21 | @export(__udivdi3, .{ .name = "__udivdi3", .linkage = linkage }); | ||
| 22 | @export(__modsi3, .{ .name = "__modsi3", .linkage = linkage }); | ||
| 23 | @export(__moddi3, .{ .name = "__moddi3", .linkage = linkage }); | ||
| 24 | @export(__umodsi3, .{ .name = "__umodsi3", .linkage = linkage }); | ||
| 25 | @export(__umoddi3, .{ .name = "__umoddi3", .linkage = linkage }); | ||
| 26 | @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = linkage }); | ||
| 27 | @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = linkage }); | ||
| 28 | |||
| 29 | if (!is_test) { | ||
| 30 | if (arch.isARM() or arch.isThumb()) { | ||
| 31 | @export(__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = linkage }); | ||
| 32 | @export(__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = linkage }); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 10 | pub fn __divmoddi4(a: i64, b: i64, rem: *i64) callconv(.C) i64 { | 37 | pub fn __divmoddi4(a: i64, b: i64, rem: *i64) callconv(.C) i64 { |
| 11 | @setRuntimeSafety(builtin.is_test); | 38 | @setRuntimeSafety(builtin.is_test); |
| 12 | 39 | ||
| ... | @@ -187,6 +214,10 @@ pub fn __divsi3(n: i32, d: i32) callconv(.C) i32 { | ... | @@ -187,6 +214,10 @@ pub fn __divsi3(n: i32, d: i32) callconv(.C) i32 { |
| 187 | return @bitCast(i32, (res ^ sign) -% sign); | 214 | return @bitCast(i32, (res ^ sign) -% sign); |
| 188 | } | 215 | } |
| 189 | 216 | ||
| 217 | pub fn __aeabi_idiv(n: i32, d: i32) callconv(.C) i32 { | ||
| 218 | return @call(.{ .modifier = .always_inline }, __divsi3, .{ n, d }); | ||
| 219 | } | ||
| 220 | |||
| 190 | test "test_divsi3" { | 221 | test "test_divsi3" { |
| 191 | const cases = [_][3]i32{ | 222 | const cases = [_][3]i32{ |
| 192 | [_]i32{ 0, 1, 0 }, | 223 | [_]i32{ 0, 1, 0 }, |
| ... | @@ -253,6 +284,10 @@ pub fn __udivsi3(n: u32, d: u32) callconv(.C) u32 { | ... | @@ -253,6 +284,10 @@ pub fn __udivsi3(n: u32, d: u32) callconv(.C) u32 { |
| 253 | return q; | 284 | return q; |
| 254 | } | 285 | } |
| 255 | 286 | ||
| 287 | pub fn __aeabi_uidiv(n: u32, d: u32) callconv(.C) u32 { | ||
| 288 | return @call(.{ .modifier = .always_inline }, __udivsi3, .{ n, d }); | ||
| 289 | } | ||
| 290 | |||
| 256 | test "test_udivsi3" { | 291 | test "test_udivsi3" { |
| 257 | const cases = [_][3]u32{ | 292 | const cases = [_][3]u32{ |
| 258 | [_]u32{ 0x00000000, 0x00000001, 0x00000000 }, | 293 | [_]u32{ 0x00000000, 0x00000001, 0x00000000 }, |
lib/compiler_rt/log.zig+23| ... | @@ -5,8 +5,27 @@ | ... | @@ -5,8 +5,27 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ln.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ln.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 8 | const math = std.math; | 9 | const math = std.math; |
| 9 | const testing = std.testing; | 10 | const testing = std.testing; |
| 11 | const arch = builtin.cpu.arch; | ||
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | @export(__logh, .{ .name = "__logh", .linkage = linkage }); | ||
| 17 | @export(logf, .{ .name = "logf", .linkage = linkage }); | ||
| 18 | @export(log, .{ .name = "log", .linkage = linkage }); | ||
| 19 | @export(__logx, .{ .name = "__logx", .linkage = linkage }); | ||
| 20 | @export(logq, .{ .name = "logq", .linkage = linkage }); | ||
| 21 | @export(logl, .{ .name = "logl", .linkage = linkage }); | ||
| 22 | |||
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(logf128, .{ .name = "logf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 10 | 29 | ||
| 11 | pub fn __logh(a: f16) callconv(.C) f16 { | 30 | pub fn __logh(a: f16) callconv(.C) f16 { |
| 12 | // TODO: more efficient implementation | 31 | // TODO: more efficient implementation |
| ... | @@ -131,6 +150,10 @@ pub fn logq(a: f128) callconv(.C) f128 { | ... | @@ -131,6 +150,10 @@ pub fn logq(a: f128) callconv(.C) f128 { |
| 131 | return log(@floatCast(f64, a)); | 150 | return log(@floatCast(f64, a)); |
| 132 | } | 151 | } |
| 133 | 152 | ||
| 153 | pub fn logf128(a: f128) callconv(.C) f128 { | ||
| 154 | return @call(.{ .modifier = .always_inline }, logq, .{a}); | ||
| 155 | } | ||
| 156 | |||
| 134 | pub fn logl(x: c_longdouble) callconv(.C) c_longdouble { | 157 | pub fn logl(x: c_longdouble) callconv(.C) c_longdouble { |
| 135 | switch (@typeInfo(c_longdouble).Float.bits) { | 158 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 136 | 16 => return __logh(x), | 159 | 16 => return __logh(x), |
lib/compiler_rt/log10.zig+23| ... | @@ -5,9 +5,28 @@ | ... | @@ -5,9 +5,28 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log10.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log10.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 8 | const math = std.math; | 9 | const math = std.math; |
| 9 | const testing = std.testing; | 10 | const testing = std.testing; |
| 10 | const maxInt = std.math.maxInt; | 11 | const maxInt = std.math.maxInt; |
| 12 | const arch = builtin.cpu.arch; | ||
| 13 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 14 | pub const panic = @import("common.zig").panic; | ||
| 15 | |||
| 16 | comptime { | ||
| 17 | @export(__log10h, .{ .name = "__log10h", .linkage = linkage }); | ||
| 18 | @export(log10f, .{ .name = "log10f", .linkage = linkage }); | ||
| 19 | @export(log10, .{ .name = "log10", .linkage = linkage }); | ||
| 20 | @export(__log10x, .{ .name = "__log10x", .linkage = linkage }); | ||
| 21 | @export(log10q, .{ .name = "log10q", .linkage = linkage }); | ||
| 22 | @export(log10l, .{ .name = "log10l", .linkage = linkage }); | ||
| 23 | |||
| 24 | if (!builtin.is_test) { | ||
| 25 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 26 | @export(log10f128, .{ .name = "log10f128", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | } | ||
| 11 | 30 | ||
| 12 | pub fn __log10h(a: f16) callconv(.C) f16 { | 31 | pub fn __log10h(a: f16) callconv(.C) f16 { |
| 13 | // TODO: more efficient implementation | 32 | // TODO: more efficient implementation |
| ... | @@ -159,6 +178,10 @@ pub fn log10q(a: f128) callconv(.C) f128 { | ... | @@ -159,6 +178,10 @@ pub fn log10q(a: f128) callconv(.C) f128 { |
| 159 | return log10(@floatCast(f64, a)); | 178 | return log10(@floatCast(f64, a)); |
| 160 | } | 179 | } |
| 161 | 180 | ||
| 181 | pub fn log10f128(a: f128) callconv(.C) f128 { | ||
| 182 | return @call(.{ .modifier = .always_inline }, log10q, .{a}); | ||
| 183 | } | ||
| 184 | |||
| 162 | pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble { | 185 | pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble { |
| 163 | switch (@typeInfo(c_longdouble).Float.bits) { | 186 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 164 | 16 => return __log10h(x), | 187 | 16 => return __log10h(x), |
lib/compiler_rt/log2.zig+23| ... | @@ -5,9 +5,28 @@ | ... | @@ -5,9 +5,28 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log2.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log2.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 8 | const math = std.math; | 9 | const math = std.math; |
| 9 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 10 | const maxInt = std.math.maxInt; | 11 | const maxInt = std.math.maxInt; |
| 12 | const arch = builtin.cpu.arch; | ||
| 13 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 14 | pub const panic = @import("common.zig").panic; | ||
| 15 | |||
| 16 | comptime { | ||
| 17 | @export(__log2h, .{ .name = "__log2h", .linkage = linkage }); | ||
| 18 | @export(log2f, .{ .name = "log2f", .linkage = linkage }); | ||
| 19 | @export(log2, .{ .name = "log2", .linkage = linkage }); | ||
| 20 | @export(__log2x, .{ .name = "__log2x", .linkage = linkage }); | ||
| 21 | @export(log2q, .{ .name = "log2q", .linkage = linkage }); | ||
| 22 | @export(log2l, .{ .name = "log2l", .linkage = linkage }); | ||
| 23 | |||
| 24 | if (!builtin.is_test) { | ||
| 25 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 26 | @export(log2f128, .{ .name = "log2f128", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | } | ||
| 11 | 30 | ||
| 12 | pub fn __log2h(a: f16) callconv(.C) f16 { | 31 | pub fn __log2h(a: f16) callconv(.C) f16 { |
| 13 | // TODO: more efficient implementation | 32 | // TODO: more efficient implementation |
| ... | @@ -151,6 +170,10 @@ pub fn log2q(a: f128) callconv(.C) f128 { | ... | @@ -151,6 +170,10 @@ pub fn log2q(a: f128) callconv(.C) f128 { |
| 151 | return log2(@floatCast(f64, a)); | 170 | return log2(@floatCast(f64, a)); |
| 152 | } | 171 | } |
| 153 | 172 | ||
| 173 | pub fn log2f128(a: f128) callconv(.C) f128 { | ||
| 174 | return @call(.{ .modifier = .always_inline }, log2q, .{a}); | ||
| 175 | } | ||
| 176 | |||
| 154 | pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble { | 177 | pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble { |
| 155 | switch (@typeInfo(c_longdouble).Float.bits) { | 178 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 156 | 16 => return __log2h(x), | 179 | 16 => return __log2h(x), |
lib/compiler_rt/modti3.zig+27-2| ... | @@ -2,9 +2,34 @@ | ... | @@ -2,9 +2,34 @@ |
| 2 | // | 2 | // |
| 3 | // https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/modti3.c | 3 | // https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/modti3.c |
| 4 | 4 | ||
| 5 | const udivmod = @import("udivmod.zig").udivmod; | 5 | const std = @import("std"); |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 7 | const compiler_rt = @import("../compiler_rt.zig"); | 7 | const udivmod = @import("udivmod.zig").udivmod; |
| 8 | const arch = builtin.cpu.arch; | ||
| 9 | const is_test = builtin.is_test; | ||
| 10 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 11 | pub const panic = @import("common.zig").panic; | ||
| 12 | |||
| 13 | comptime { | ||
| 14 | if (builtin.os.tag == .windows) { | ||
| 15 | switch (arch) { | ||
| 16 | .i386 => { | ||
| 17 | @export(__modti3, .{ .name = "__modti3", .linkage = linkage }); | ||
| 18 | }, | ||
| 19 | .x86_64 => { | ||
| 20 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | ||
| 21 | // that LLVM expects compiler-rt to have. | ||
| 22 | @export(__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = linkage }); | ||
| 23 | }, | ||
| 24 | else => {}, | ||
| 25 | } | ||
| 26 | if (arch.isAARCH64()) { | ||
| 27 | @export(__modti3, .{ .name = "__modti3", .linkage = linkage }); | ||
| 28 | } | ||
| 29 | } else { | ||
| 30 | @export(__modti3, .{ .name = "__modti3", .linkage = linkage }); | ||
| 31 | } | ||
| 32 | } | ||
| 8 | 33 | ||
| 9 | pub fn __modti3(a: i128, b: i128) callconv(.C) i128 { | 34 | pub fn __modti3(a: i128, b: i128) callconv(.C) i128 { |
| 10 | @setRuntimeSafety(builtin.is_test); | 35 | @setRuntimeSafety(builtin.is_test); |
lib/compiler_rt/mulXf3.zig+26-2| ... | @@ -5,8 +5,32 @@ | ... | @@ -5,8 +5,32 @@ |
| 5 | const std = @import("std"); | 5 | const std = @import("std"); |
| 6 | const math = std.math; | 6 | const math = std.math; |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = @import("builtin"); |
| 8 | const compiler_rt = @import("../compiler_rt.zig"); | 8 | const arch = builtin.cpu.arch; |
| 9 | const is_test = builtin.is_test; | ||
| 10 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 11 | pub const panic = @import("common.zig").panic; | ||
| 12 | |||
| 13 | comptime { | ||
| 14 | @export(__mulsf3, .{ .name = "__mulsf3", .linkage = linkage }); | ||
| 15 | @export(__muldf3, .{ .name = "__muldf3", .linkage = linkage }); | ||
| 16 | @export(__mulxf3, .{ .name = "__mulxf3", .linkage = linkage }); | ||
| 17 | @export(__multf3, .{ .name = "__multf3", .linkage = linkage }); | ||
| 18 | |||
| 19 | if (!is_test) { | ||
| 20 | if (arch.isARM() or arch.isThumb()) { | ||
| 21 | @export(__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = linkage }); | ||
| 22 | @export(__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = linkage }); | ||
| 23 | } | ||
| 24 | |||
| 25 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 26 | @export(__mulkf3, .{ .name = "__mulkf3", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | } | ||
| 9 | 30 | ||
| 31 | pub fn __mulkf3(a: f128, b: f128) callconv(.C) f128 { | ||
| 32 | return @call(.{ .modifier = .always_inline }, __multf3, .{ a, b }); | ||
| 33 | } | ||
| 10 | pub fn __multf3(a: f128, b: f128) callconv(.C) f128 { | 34 | pub fn __multf3(a: f128, b: f128) callconv(.C) f128 { |
| 11 | return mulXf3(f128, a, b); | 35 | return mulXf3(f128, a, b); |
| 12 | } | 36 | } |
| ... | @@ -30,7 +54,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 { | ... | @@ -30,7 +54,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 { |
| 30 | return @call(.{ .modifier = .always_inline }, __muldf3, .{ a, b }); | 54 | return @call(.{ .modifier = .always_inline }, __muldf3, .{ a, b }); |
| 31 | } | 55 | } |
| 32 | 56 | ||
| 33 | fn mulXf3(comptime T: type, a: T, b: T) T { | 57 | pub fn mulXf3(comptime T: type, a: T, b: T) T { |
| 34 | @setRuntimeSafety(builtin.is_test); | 58 | @setRuntimeSafety(builtin.is_test); |
| 35 | const typeWidth = @typeInfo(T).Float.bits; | 59 | const typeWidth = @typeInfo(T).Float.bits; |
| 36 | const significandBits = math.floatMantissaBits(T); | 60 | const significandBits = math.floatMantissaBits(T); |
lib/compiler_rt/muldi3.zig+19-2| ... | @@ -1,7 +1,20 @@ | ... | @@ -1,7 +1,20 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | ||
| 4 | const native_endian = builtin.cpu.arch.endian(); | 3 | const native_endian = builtin.cpu.arch.endian(); |
| 4 | const arch = builtin.cpu.arch; | ||
| 5 | const is_test = builtin.is_test; | ||
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 8 | |||
| 9 | comptime { | ||
| 10 | @export(__muldi3, .{ .name = "__muldi3", .linkage = linkage }); | ||
| 11 | |||
| 12 | if (!is_test) { | ||
| 13 | if (arch.isARM() or arch.isThumb()) { | ||
| 14 | @export(__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = linkage }); | ||
| 15 | } | ||
| 16 | } | ||
| 17 | } | ||
| 5 | 18 | ||
| 6 | // Ported from | 19 | // Ported from |
| 7 | // https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0/compiler-rt/lib/builtins/muldi3.c | 20 | // https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0/compiler-rt/lib/builtins/muldi3.c |
| ... | @@ -20,7 +33,11 @@ const dwords = extern union { | ... | @@ -20,7 +33,11 @@ const dwords = extern union { |
| 20 | }, | 33 | }, |
| 21 | }; | 34 | }; |
| 22 | 35 | ||
| 23 | fn __muldsi3(a: u32, b: u32) i64 { | 36 | pub fn __aeabi_lmul(a: i64, b: i64) callconv(.C) i64 { |
| 37 | return @call(.{ .modifier = .always_inline }, __muldi3, .{ a, b }); | ||
| 38 | } | ||
| 39 | |||
| 40 | pub fn __muldsi3(a: u32, b: u32) i64 { | ||
| 24 | @setRuntimeSafety(is_test); | 41 | @setRuntimeSafety(is_test); |
| 25 | 42 | ||
| 26 | const bits_in_word_2 = @sizeOf(i32) * 8 / 2; | 43 | const bits_in_word_2 = @sizeOf(i32) * 8 / 2; |
lib/compiler_rt/mulo.zig+10-1| ... | @@ -1,6 +1,15 @@ | ... | @@ -1,6 +1,15 @@ |
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 3 | const math = std.math; | 3 | const math = std.math; |
| 4 | const is_test = builtin.is_test; | ||
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | @export(__mulosi4, .{ .name = "__mulosi4", .linkage = linkage }); | ||
| 10 | @export(__mulodi4, .{ .name = "__mulodi4", .linkage = linkage }); | ||
| 11 | @export(__muloti4, .{ .name = "__muloti4", .linkage = linkage }); | ||
| 12 | } | ||
| 4 | 13 | ||
| 5 | // mulo - multiplication overflow | 14 | // mulo - multiplication overflow |
| 6 | // * return a*%b. | 15 | // * return a*%b. |
lib/compiler_rt/multi3.zig+22-2| ... | @@ -1,13 +1,33 @@ | ... | @@ -1,13 +1,33 @@ |
| 1 | const compiler_rt = @import("../compiler_rt.zig"); | ||
| 2 | const std = @import("std"); | 1 | const std = @import("std"); |
| 3 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | ||
| 4 | const is_test = builtin.is_test; | 4 | const is_test = builtin.is_test; |
| 5 | const native_endian = builtin.cpu.arch.endian(); | 5 | const native_endian = builtin.cpu.arch.endian(); |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 6 | 8 | ||
| 7 | // Ported from git@github.com:llvm-project/llvm-project-20170507.git | 9 | // Ported from git@github.com:llvm-project/llvm-project-20170507.git |
| 8 | // ae684fad6d34858c014c94da69c15e7774a633c3 | 10 | // ae684fad6d34858c014c94da69c15e7774a633c3 |
| 9 | // 2018-08-13 | 11 | // 2018-08-13 |
| 10 | 12 | ||
| 13 | comptime { | ||
| 14 | if (builtin.os.tag == .windows) { | ||
| 15 | switch (arch) { | ||
| 16 | .i386 => { | ||
| 17 | @export(__multi3, .{ .name = "__multi3", .linkage = linkage }); | ||
| 18 | }, | ||
| 19 | .x86_64 => { | ||
| 20 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | ||
| 21 | // that LLVM expects compiler-rt to have. | ||
| 22 | @export(__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = linkage }); | ||
| 23 | }, | ||
| 24 | else => {}, | ||
| 25 | } | ||
| 26 | } else { | ||
| 27 | @export(__multi3, .{ .name = "__multi3", .linkage = linkage }); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 11 | pub fn __multi3(a: i128, b: i128) callconv(.C) i128 { | 31 | pub fn __multi3(a: i128, b: i128) callconv(.C) i128 { |
| 12 | @setRuntimeSafety(is_test); | 32 | @setRuntimeSafety(is_test); |
| 13 | const x = twords{ .all = a }; | 33 | const x = twords{ .all = a }; |
| ... | @@ -25,7 +45,7 @@ pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | ... | @@ -25,7 +45,7 @@ pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { |
| 25 | })); | 45 | })); |
| 26 | } | 46 | } |
| 27 | 47 | ||
| 28 | fn __mulddi3(a: u64, b: u64) i128 { | 48 | pub fn __mulddi3(a: u64, b: u64) i128 { |
| 29 | const bits_in_dword_2 = (@sizeOf(i64) * 8) / 2; | 49 | const bits_in_dword_2 = (@sizeOf(i64) * 8) / 2; |
| 30 | const lower_mask = ~@as(u64, 0) >> bits_in_dword_2; | 50 | const lower_mask = ~@as(u64, 0) >> bits_in_dword_2; |
| 31 | var r: twords = undefined; | 51 | var r: twords = undefined; |
lib/compiler_rt/negXf2.zig+17| ... | @@ -1,4 +1,21 @@ | ... | @@ -1,4 +1,21 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 3 | const arch = builtin.cpu.arch; | ||
| 4 | const is_test = builtin.is_test; | ||
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | @export(__negsf2, .{ .name = "__negsf2", .linkage = linkage }); | ||
| 10 | @export(__negdf2, .{ .name = "__negdf2", .linkage = linkage }); | ||
| 11 | |||
| 12 | if (!is_test) { | ||
| 13 | if (arch.isARM() or arch.isThumb()) { | ||
| 14 | @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = linkage }); | ||
| 15 | @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = linkage }); | ||
| 16 | } | ||
| 17 | } | ||
| 18 | } | ||
| 2 | 19 | ||
| 3 | pub fn __negsf2(a: f32) callconv(.C) f32 { | 20 | pub fn __negsf2(a: f32) callconv(.C) f32 { |
| 4 | return negXf2(f32, a); | 21 | return negXf2(f32, a); |
lib/compiler_rt/negXi2.zig+9| ... | @@ -1,5 +1,14 @@ | ... | @@ -1,5 +1,14 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | ||
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__negsi2, .{ .name = "__negsi2", .linkage = linkage }); | ||
| 9 | @export(__negdi2, .{ .name = "__negdi2", .linkage = linkage }); | ||
| 10 | @export(__negti2, .{ .name = "__negti2", .linkage = linkage }); | ||
| 11 | } | ||
| 3 | 12 | ||
| 4 | // neg - negate (the number) | 13 | // neg - negate (the number) |
| 5 | // - negXi2 for unoptimized little and big endian | 14 | // - negXi2 for unoptimized little and big endian |
lib/compiler_rt/negv.zig+11| ... | @@ -1,6 +1,17 @@ | ... | @@ -1,6 +1,17 @@ |
| 1 | // negv - negate oVerflow | 1 | // negv - negate oVerflow |
| 2 | // * @panic, if result can not be represented | 2 | // * @panic, if result can not be represented |
| 3 | // - negvXi4_generic for unoptimized version | 3 | // - negvXi4_generic for unoptimized version |
| 4 | const std = @import("std"); | ||
| 5 | const builtin = @import("builtin"); | ||
| 6 | const is_test = builtin.is_test; | ||
| 7 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 8 | pub const panic = @import("common.zig").panic; | ||
| 9 | |||
| 10 | comptime { | ||
| 11 | @export(__negvsi2, .{ .name = "__negvsi2", .linkage = linkage }); | ||
| 12 | @export(__negvdi2, .{ .name = "__negvdi2", .linkage = linkage }); | ||
| 13 | @export(__negvti2, .{ .name = "__negvti2", .linkage = linkage }); | ||
| 14 | } | ||
| 4 | 15 | ||
| 5 | // assume -0 == 0 is gracefully handled by the hardware | 16 | // assume -0 == 0 is gracefully handled by the hardware |
| 6 | inline fn negvXi(comptime ST: type, a: ST) ST { | 17 | inline fn negvXi(comptime ST: type, a: ST) ST { |
lib/compiler_rt/os_version_check.zig+36-22| ... | @@ -1,5 +1,17 @@ | ... | @@ -1,5 +1,17 @@ |
| 1 | const testing = @import("std").testing; | 1 | const std = @import("std"); |
| 2 | const testing = std.testing; | ||
| 2 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | if (builtin.os.tag.isDarwin()) { | ||
| 9 | @export(IsPlatformVersionAtLeast.__isPlatformVersionAtLeast, .{ | ||
| 10 | .name = "__isPlatformVersionAtLeast", | ||
| 11 | .linkage = linkage, | ||
| 12 | }); | ||
| 13 | } | ||
| 14 | } | ||
| 3 | 15 | ||
| 4 | // Ported from llvm-project 13.0.0 d7b669b3a30345cfcdb2fde2af6f48aa4b94845d | 16 | // Ported from llvm-project 13.0.0 d7b669b3a30345cfcdb2fde2af6f48aa4b94845d |
| 5 | // | 17 | // |
| ... | @@ -16,34 +28,36 @@ const builtin = @import("builtin"); | ... | @@ -16,34 +28,36 @@ const builtin = @import("builtin"); |
| 16 | // the newer codepath, which merely calls out to the Darwin _availability_version_check API which is | 28 | // the newer codepath, which merely calls out to the Darwin _availability_version_check API which is |
| 17 | // available on macOS 10.15+, iOS 13+, tvOS 13+ and watchOS 6+. | 29 | // available on macOS 10.15+, iOS 13+, tvOS 13+ and watchOS 6+. |
| 18 | 30 | ||
| 19 | inline fn constructVersion(major: u32, minor: u32, subminor: u32) u32 { | 31 | const IsPlatformVersionAtLeast = struct { |
| 20 | return ((major & 0xffff) << 16) | ((minor & 0xff) << 8) | (subminor & 0xff); | 32 | inline fn constructVersion(major: u32, minor: u32, subminor: u32) u32 { |
| 21 | } | 33 | return ((major & 0xffff) << 16) | ((minor & 0xff) << 8) | (subminor & 0xff); |
| 34 | } | ||
| 22 | 35 | ||
| 23 | // Darwin-only | 36 | // Darwin-only |
| 24 | pub fn __isPlatformVersionAtLeast(platform: u32, major: u32, minor: u32, subminor: u32) callconv(.C) i32 { | 37 | fn __isPlatformVersionAtLeast(platform: u32, major: u32, minor: u32, subminor: u32) callconv(.C) i32 { |
| 25 | const build_version = dyld_build_version_t{ | 38 | const build_version = dyld_build_version_t{ |
| 26 | .platform = platform, | 39 | .platform = platform, |
| 27 | .version = constructVersion(major, minor, subminor), | 40 | .version = constructVersion(major, minor, subminor), |
| 28 | }; | 41 | }; |
| 29 | return @boolToInt(_availability_version_check(1, &[_]dyld_build_version_t{build_version})); | 42 | return @boolToInt(_availability_version_check(1, &[_]dyld_build_version_t{build_version})); |
| 30 | } | 43 | } |
| 31 | 44 | ||
| 32 | // _availability_version_check darwin API support. | 45 | // _availability_version_check darwin API support. |
| 33 | const dyld_platform_t = u32; | 46 | const dyld_platform_t = u32; |
| 34 | const dyld_build_version_t = extern struct { | 47 | const dyld_build_version_t = extern struct { |
| 35 | platform: dyld_platform_t, | 48 | platform: dyld_platform_t, |
| 36 | version: u32, | 49 | version: u32, |
| 50 | }; | ||
| 51 | // Darwin-only | ||
| 52 | extern "c" fn _availability_version_check(count: u32, versions: [*c]const dyld_build_version_t) bool; | ||
| 37 | }; | 53 | }; |
| 38 | // Darwin-only | ||
| 39 | extern "c" fn _availability_version_check(count: u32, versions: [*c]const dyld_build_version_t) bool; | ||
| 40 | 54 | ||
| 41 | test "isPlatformVersionAtLeast" { | 55 | test "isPlatformVersionAtLeast" { |
| 42 | if (!builtin.os.tag.isDarwin()) return error.SkipZigTest; | 56 | if (!comptime builtin.os.tag.isDarwin()) return error.SkipZigTest; |
| 43 | 57 | ||
| 44 | // Note: this test depends on the actual host OS version since it is merely calling into the | 58 | // Note: this test depends on the actual host OS version since it is merely calling into the |
| 45 | // native Darwin API. | 59 | // native Darwin API. |
| 46 | const macos_platform_constant = 1; | 60 | const macos_platform_constant = 1; |
| 47 | try testing.expect(__isPlatformVersionAtLeast(macos_platform_constant, 10, 0, 15) == 1); | 61 | try testing.expect(IsPlatformVersionAtLeast.__isPlatformVersionAtLeast(macos_platform_constant, 10, 0, 15) == 1); |
| 48 | try testing.expect(__isPlatformVersionAtLeast(macos_platform_constant, 99, 0, 0) == 0); | 62 | try testing.expect(IsPlatformVersionAtLeast.__isPlatformVersionAtLeast(macos_platform_constant, 99, 0, 0) == 0); |
| 49 | } | 63 | } |
lib/compiler_rt/parity.zig+9| ... | @@ -1,5 +1,14 @@ | ... | @@ -1,5 +1,14 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | ||
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__paritysi2, .{ .name = "__paritysi2", .linkage = linkage }); | ||
| 9 | @export(__paritydi2, .{ .name = "__paritydi2", .linkage = linkage }); | ||
| 10 | @export(__parityti2, .{ .name = "__parityti2", .linkage = linkage }); | ||
| 11 | } | ||
| 3 | 12 | ||
| 4 | // parity - if number of bits set is even => 0, else => 1 | 13 | // parity - if number of bits set is even => 0, else => 1 |
| 5 | // - pariytXi2_generic for big and little endian | 14 | // - pariytXi2_generic for big and little endian |
lib/compiler_rt/popcount.zig+9| ... | @@ -1,5 +1,14 @@ | ... | @@ -1,5 +1,14 @@ |
| 1 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | const is_test = builtin.is_test; | ||
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = linkage }); | ||
| 9 | @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = linkage }); | ||
| 10 | @export(__popcountti2, .{ .name = "__popcountti2", .linkage = linkage }); | ||
| 11 | } | ||
| 3 | 12 | ||
| 4 | // popcount - population count | 13 | // popcount - population count |
| 5 | // counts the number of 1 bits | 14 | // counts the number of 1 bits |
lib/compiler_rt/round.zig+23| ... | @@ -5,8 +5,27 @@ | ... | @@ -5,8 +5,27 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/round.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/round.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 8 | const math = std.math; | 9 | const math = std.math; |
| 9 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 11 | const arch = builtin.cpu.arch; | ||
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | @export(__roundh, .{ .name = "__roundh", .linkage = linkage }); | ||
| 17 | @export(roundf, .{ .name = "roundf", .linkage = linkage }); | ||
| 18 | @export(round, .{ .name = "round", .linkage = linkage }); | ||
| 19 | @export(__roundx, .{ .name = "__roundx", .linkage = linkage }); | ||
| 20 | @export(roundq, .{ .name = "roundq", .linkage = linkage }); | ||
| 21 | @export(roundl, .{ .name = "roundl", .linkage = linkage }); | ||
| 22 | |||
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(roundf128, .{ .name = "roundf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 10 | 29 | ||
| 11 | pub fn __roundh(x: f16) callconv(.C) f16 { | 30 | pub fn __roundh(x: f16) callconv(.C) f16 { |
| 12 | // TODO: more efficient implementation | 31 | // TODO: more efficient implementation |
| ... | @@ -123,6 +142,10 @@ pub fn roundq(x_: f128) callconv(.C) f128 { | ... | @@ -123,6 +142,10 @@ pub fn roundq(x_: f128) callconv(.C) f128 { |
| 123 | } | 142 | } |
| 124 | } | 143 | } |
| 125 | 144 | ||
| 145 | pub fn roundf128(x_: f128) callconv(.C) f128 { | ||
| 146 | return @call(.{ .modifier = .always_inline }, roundq, .{x_}); | ||
| 147 | } | ||
| 148 | |||
| 126 | pub fn roundl(x: c_longdouble) callconv(.C) c_longdouble { | 149 | pub fn roundl(x: c_longdouble) callconv(.C) c_longdouble { |
| 127 | switch (@typeInfo(c_longdouble).Float.bits) { | 150 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 128 | 16 => return __roundh(x), | 151 | 16 => return __roundh(x), |
lib/compiler_rt/shift.zig+30-8| ... | @@ -1,13 +1,35 @@ | ... | @@ -1,13 +1,35 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 2 | const Log2Int = std.math.Log2Int; | 3 | const Log2Int = std.math.Log2Int; |
| 3 | const native_endian = @import("builtin").cpu.arch.endian(); | 4 | const native_endian = builtin.cpu.arch.endian(); |
| 5 | const arch = builtin.cpu.arch; | ||
| 6 | const is_test = builtin.is_test; | ||
| 7 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 8 | pub const panic = @import("common.zig").panic; | ||
| 9 | |||
| 10 | comptime { | ||
| 11 | @export(__ashldi3, .{ .name = "__ashldi3", .linkage = linkage }); | ||
| 12 | @export(__ashlti3, .{ .name = "__ashlti3", .linkage = linkage }); | ||
| 13 | @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = linkage }); | ||
| 14 | @export(__ashrti3, .{ .name = "__ashrti3", .linkage = linkage }); | ||
| 15 | @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = linkage }); | ||
| 16 | @export(__lshrti3, .{ .name = "__lshrti3", .linkage = linkage }); | ||
| 17 | |||
| 18 | if (!is_test) { | ||
| 19 | if (arch.isARM() or arch.isThumb()) { | ||
| 20 | @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = linkage }); | ||
| 21 | @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = linkage }); | ||
| 22 | @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = linkage }); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
| 4 | 26 | ||
| 5 | fn Dwords(comptime T: type, comptime signed_half: bool) type { | 27 | fn Dwords(comptime T: type, comptime signed_half: bool) type { |
| 6 | return extern union { | 28 | return extern union { |
| 7 | pub const bits = @divExact(@typeInfo(T).Int.bits, 2); | 29 | const bits = @divExact(@typeInfo(T).Int.bits, 2); |
| 8 | pub const HalfTU = std.meta.Int(.unsigned, bits); | 30 | const HalfTU = std.meta.Int(.unsigned, bits); |
| 9 | pub const HalfTS = std.meta.Int(.signed, bits); | 31 | const HalfTS = std.meta.Int(.signed, bits); |
| 10 | pub const HalfT = if (signed_half) HalfTS else HalfTU; | 32 | const HalfT = if (signed_half) HalfTS else HalfTU; |
| 11 | 33 | ||
| 12 | all: T, | 34 | all: T, |
| 13 | s: if (native_endian == .Little) | 35 | s: if (native_endian == .Little) |
| ... | @@ -19,7 +41,7 @@ fn Dwords(comptime T: type, comptime signed_half: bool) type { | ... | @@ -19,7 +41,7 @@ fn Dwords(comptime T: type, comptime signed_half: bool) type { |
| 19 | 41 | ||
| 20 | // Arithmetic shift left | 42 | // Arithmetic shift left |
| 21 | // Precondition: 0 <= b < bits_in_dword | 43 | // Precondition: 0 <= b < bits_in_dword |
| 22 | pub inline fn ashlXi3(comptime T: type, a: T, b: i32) T { | 44 | inline fn ashlXi3(comptime T: type, a: T, b: i32) T { |
| 23 | const dwords = Dwords(T, false); | 45 | const dwords = Dwords(T, false); |
| 24 | const S = Log2Int(dwords.HalfT); | 46 | const S = Log2Int(dwords.HalfT); |
| 25 | 47 | ||
| ... | @@ -42,7 +64,7 @@ pub inline fn ashlXi3(comptime T: type, a: T, b: i32) T { | ... | @@ -42,7 +64,7 @@ pub inline fn ashlXi3(comptime T: type, a: T, b: i32) T { |
| 42 | 64 | ||
| 43 | // Arithmetic shift right | 65 | // Arithmetic shift right |
| 44 | // Precondition: 0 <= b < T.bit_count | 66 | // Precondition: 0 <= b < T.bit_count |
| 45 | pub inline fn ashrXi3(comptime T: type, a: T, b: i32) T { | 67 | inline fn ashrXi3(comptime T: type, a: T, b: i32) T { |
| 46 | const dwords = Dwords(T, true); | 68 | const dwords = Dwords(T, true); |
| 47 | const S = Log2Int(dwords.HalfT); | 69 | const S = Log2Int(dwords.HalfT); |
| 48 | 70 | ||
| ... | @@ -69,7 +91,7 @@ pub inline fn ashrXi3(comptime T: type, a: T, b: i32) T { | ... | @@ -69,7 +91,7 @@ pub inline fn ashrXi3(comptime T: type, a: T, b: i32) T { |
| 69 | 91 | ||
| 70 | // Logical shift right | 92 | // Logical shift right |
| 71 | // Precondition: 0 <= b < T.bit_count | 93 | // Precondition: 0 <= b < T.bit_count |
| 72 | pub inline fn lshrXi3(comptime T: type, a: T, b: i32) T { | 94 | inline fn lshrXi3(comptime T: type, a: T, b: i32) T { |
| 73 | const dwords = Dwords(T, false); | 95 | const dwords = Dwords(T, false); |
| 74 | const S = Log2Int(dwords.HalfT); | 96 | const S = Log2Int(dwords.HalfT); |
| 75 | 97 |
lib/compiler_rt/sin.zig+23| ... | @@ -5,13 +5,32 @@ | ... | @@ -5,13 +5,32 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/sin.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/sin.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 9 | const arch = builtin.cpu.arch; | ||
| 8 | const math = std.math; | 10 | const math = std.math; |
| 9 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 13 | pub const panic = @import("common.zig").panic; | ||
| 10 | 14 | ||
| 11 | const trig = @import("trig.zig"); | 15 | const trig = @import("trig.zig"); |
| 12 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; | 16 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; |
| 13 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; | 17 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; |
| 14 | 18 | ||
| 19 | comptime { | ||
| 20 | @export(__sinh, .{ .name = "__sinh", .linkage = linkage }); | ||
| 21 | @export(sinf, .{ .name = "sinf", .linkage = linkage }); | ||
| 22 | @export(sin, .{ .name = "sin", .linkage = linkage }); | ||
| 23 | @export(__sinx, .{ .name = "__sinx", .linkage = linkage }); | ||
| 24 | @export(sinq, .{ .name = "sinq", .linkage = linkage }); | ||
| 25 | @export(sinl, .{ .name = "sinl", .linkage = linkage }); | ||
| 26 | |||
| 27 | if (!builtin.is_test) { | ||
| 28 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 29 | @export(sinf128, .{ .name = "sinf128", .linkage = linkage }); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 15 | pub fn __sinh(x: f16) callconv(.C) f16 { | 34 | pub fn __sinh(x: f16) callconv(.C) f16 { |
| 16 | // TODO: more efficient implementation | 35 | // TODO: more efficient implementation |
| 17 | return @floatCast(f16, sinf(x)); | 36 | return @floatCast(f16, sinf(x)); |
| ... | @@ -111,6 +130,10 @@ pub fn sinq(x: f128) callconv(.C) f128 { | ... | @@ -111,6 +130,10 @@ pub fn sinq(x: f128) callconv(.C) f128 { |
| 111 | return sin(@floatCast(f64, x)); | 130 | return sin(@floatCast(f64, x)); |
| 112 | } | 131 | } |
| 113 | 132 | ||
| 133 | pub fn sinf128(x: f128) callconv(.C) f128 { | ||
| 134 | return @call(.{ .modifier = .always_inline }, sinq, .{x}); | ||
| 135 | } | ||
| 136 | |||
| 114 | pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble { | 137 | pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble { |
| 115 | switch (@typeInfo(c_longdouble).Float.bits) { | 138 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 116 | 16 => return __sinh(x), | 139 | 16 => return __sinh(x), |
lib/compiler_rt/sincos.zig+24-3| ... | @@ -1,10 +1,27 @@ | ... | @@ -1,10 +1,27 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 3 | const arch = builtin.cpu.arch; | ||
| 2 | const math = std.math; | 4 | const math = std.math; |
| 3 | const sin = @import("sin.zig"); | ||
| 4 | const cos = @import("cos.zig"); | ||
| 5 | const trig = @import("trig.zig"); | 5 | const trig = @import("trig.zig"); |
| 6 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; | 6 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; |
| 7 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; | 7 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; |
| 8 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 9 | pub const panic = @import("common.zig").panic; | ||
| 10 | |||
| 11 | comptime { | ||
| 12 | @export(__sincosh, .{ .name = "__sincosh", .linkage = linkage }); | ||
| 13 | @export(sincosf, .{ .name = "sincosf", .linkage = linkage }); | ||
| 14 | @export(sincos, .{ .name = "sincos", .linkage = linkage }); | ||
| 15 | @export(__sincosx, .{ .name = "__sincosx", .linkage = linkage }); | ||
| 16 | @export(sincosq, .{ .name = "sincosq", .linkage = linkage }); | ||
| 17 | @export(sincosl, .{ .name = "sincosl", .linkage = linkage }); | ||
| 18 | |||
| 19 | if (!builtin.is_test) { | ||
| 20 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 21 | @export(sincosf128, .{ .name = "sincosf128", .linkage = linkage }); | ||
| 22 | } | ||
| 23 | } | ||
| 24 | } | ||
| 8 | 25 | ||
| 9 | pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.C) void { | 26 | pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.C) void { |
| 10 | // TODO: more efficient implementation | 27 | // TODO: more efficient implementation |
| ... | @@ -181,6 +198,10 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void { | ... | @@ -181,6 +198,10 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void { |
| 181 | r_cos.* = small_cos; | 198 | r_cos.* = small_cos; |
| 182 | } | 199 | } |
| 183 | 200 | ||
| 201 | pub fn sincosf128(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void { | ||
| 202 | return @call(.{ .modifier = .always_inline }, sincosq, .{ x, r_sin, r_cos }); | ||
| 203 | } | ||
| 204 | |||
| 184 | pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.C) void { | 205 | pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.C) void { |
| 185 | switch (@typeInfo(c_longdouble).Float.bits) { | 206 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 186 | 16 => return __sincosh(x, r_sin, r_cos), | 207 | 16 => return __sincosh(x, r_sin, r_cos), |
| ... | @@ -192,7 +213,7 @@ pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) call | ... | @@ -192,7 +213,7 @@ pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) call |
| 192 | } | 213 | } |
| 193 | } | 214 | } |
| 194 | 215 | ||
| 195 | const rem_pio2_generic = @compileError("TODO"); | 216 | pub const rem_pio2_generic = @compileError("TODO"); |
| 196 | 217 | ||
| 197 | /// Ported from musl sincosl.c. Needs the following dependencies to be complete: | 218 | /// Ported from musl sincosl.c. Needs the following dependencies to be complete: |
| 198 | /// * rem_pio2_generic ported from __rem_pio2l.c | 219 | /// * rem_pio2_generic ported from __rem_pio2l.c |
lib/compiler_rt/sparc.zig+34| ... | @@ -3,6 +3,40 @@ | ... | @@ -3,6 +3,40 @@ |
| 3 | 3 | ||
| 4 | const std = @import("std"); | 4 | const std = @import("std"); |
| 5 | const builtin = @import("builtin"); | 5 | const builtin = @import("builtin"); |
| 6 | const arch = builtin.cpu.arch; | ||
| 7 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 8 | pub const panic = @import("common.zig").panic; | ||
| 9 | |||
| 10 | comptime { | ||
| 11 | if (arch.isSPARC()) { | ||
| 12 | // SPARC systems use a different naming scheme | ||
| 13 | @export(_Qp_add, .{ .name = "_Qp_add", .linkage = linkage }); | ||
| 14 | @export(_Qp_div, .{ .name = "_Qp_div", .linkage = linkage }); | ||
| 15 | @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = linkage }); | ||
| 16 | @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = linkage }); | ||
| 17 | |||
| 18 | @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = linkage }); | ||
| 19 | @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = linkage }); | ||
| 20 | @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = linkage }); | ||
| 21 | @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = linkage }); | ||
| 22 | @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = linkage }); | ||
| 23 | @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = linkage }); | ||
| 24 | @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = linkage }); | ||
| 25 | |||
| 26 | @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = linkage }); | ||
| 27 | @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = linkage }); | ||
| 28 | @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = linkage }); | ||
| 29 | @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = linkage }); | ||
| 30 | @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = linkage }); | ||
| 31 | @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = linkage }); | ||
| 32 | @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = linkage }); | ||
| 33 | @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = linkage }); | ||
| 34 | @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = linkage }); | ||
| 35 | @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = linkage }); | ||
| 36 | @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = linkage }); | ||
| 37 | @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage }); | ||
| 38 | } | ||
| 39 | } | ||
| 6 | 40 | ||
| 7 | // The SPARC Architecture Manual, Version 9: | 41 | // The SPARC Architecture Manual, Version 9: |
| 8 | // A.13 Floating-Point Compare | 42 | // A.13 Floating-Point Compare |
lib/compiler_rt/sqrt.zig+23| ... | @@ -1,5 +1,24 @@ | ... | @@ -1,5 +1,24 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 3 | const arch = builtin.cpu.arch; | ||
| 2 | const math = std.math; | 4 | const math = std.math; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | @export(__sqrth, .{ .name = "__sqrth", .linkage = linkage }); | ||
| 10 | @export(sqrtf, .{ .name = "sqrtf", .linkage = linkage }); | ||
| 11 | @export(sqrt, .{ .name = "sqrt", .linkage = linkage }); | ||
| 12 | @export(__sqrtx, .{ .name = "__sqrtx", .linkage = linkage }); | ||
| 13 | @export(sqrtq, .{ .name = "sqrtq", .linkage = linkage }); | ||
| 14 | @export(sqrtl, .{ .name = "sqrtl", .linkage = linkage }); | ||
| 15 | |||
| 16 | if (!builtin.is_test) { | ||
| 17 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 18 | @export(sqrtf128, .{ .name = "sqrtf128", .linkage = linkage }); | ||
| 19 | } | ||
| 20 | } | ||
| 21 | } | ||
| 3 | 22 | ||
| 4 | pub fn __sqrth(x: f16) callconv(.C) f16 { | 23 | pub fn __sqrth(x: f16) callconv(.C) f16 { |
| 5 | // TODO: more efficient implementation | 24 | // TODO: more efficient implementation |
| ... | @@ -236,6 +255,10 @@ pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble { | ... | @@ -236,6 +255,10 @@ pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble { |
| 236 | } | 255 | } |
| 237 | } | 256 | } |
| 238 | 257 | ||
| 258 | pub fn sqrtf128(x: f128) callconv(.C) f128 { | ||
| 259 | return @call(.{ .modifier = .always_inline }, sqrtq, .{x}); | ||
| 260 | } | ||
| 261 | |||
| 239 | test "sqrtf" { | 262 | test "sqrtf" { |
| 240 | const V = [_]f32{ | 263 | const V = [_]f32{ |
| 241 | 0.0, | 264 | 0.0, |
lib/compiler_rt/stack_probe.zig+46-7| ... | @@ -1,4 +1,43 @@ | ... | @@ -1,4 +1,43 @@ |
| 1 | const native_arch = @import("builtin").cpu.arch; | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 3 | const os_tag = builtin.os.tag; | ||
| 4 | const arch = builtin.cpu.arch; | ||
| 5 | const abi = builtin.abi; | ||
| 6 | const is_test = builtin.is_test; | ||
| 7 | |||
| 8 | const is_gnu = abi.isGnu(); | ||
| 9 | const is_mingw = os_tag == .windows and is_gnu; | ||
| 10 | |||
| 11 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 12 | const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong; | ||
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | if (builtin.os.tag == .windows) { | ||
| 17 | // Default stack-probe functions emitted by LLVM | ||
| 18 | if (is_mingw) { | ||
| 19 | @export(_chkstk, .{ .name = "_alloca", .linkage = strong_linkage }); | ||
| 20 | @export(___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = strong_linkage }); | ||
| 21 | } else if (!builtin.link_libc) { | ||
| 22 | // This symbols are otherwise exported by MSVCRT.lib | ||
| 23 | @export(_chkstk, .{ .name = "_chkstk", .linkage = strong_linkage }); | ||
| 24 | @export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage }); | ||
| 25 | } | ||
| 26 | |||
| 27 | if (arch.isAARCH64()) { | ||
| 28 | @export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage }); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | switch (arch) { | ||
| 33 | .i386, | ||
| 34 | .x86_64, | ||
| 35 | => { | ||
| 36 | @export(zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage }); | ||
| 37 | }, | ||
| 38 | else => {}, | ||
| 39 | } | ||
| 40 | } | ||
| 2 | 41 | ||
| 3 | // Zig's own stack-probe routine (available only on x86 and x86_64) | 42 | // Zig's own stack-probe routine (available only on x86 and x86_64) |
| 4 | pub fn zig_probe_stack() callconv(.Naked) void { | 43 | pub fn zig_probe_stack() callconv(.Naked) void { |
| ... | @@ -8,7 +47,7 @@ pub fn zig_probe_stack() callconv(.Naked) void { | ... | @@ -8,7 +47,7 @@ pub fn zig_probe_stack() callconv(.Naked) void { |
| 8 | // invalid so let's update it on the go, otherwise we'll get a segfault | 47 | // invalid so let's update it on the go, otherwise we'll get a segfault |
| 9 | // instead of triggering the stack growth. | 48 | // instead of triggering the stack growth. |
| 10 | 49 | ||
| 11 | switch (native_arch) { | 50 | switch (arch) { |
| 12 | .x86_64 => { | 51 | .x86_64 => { |
| 13 | // %rax = probe length, %rsp = stack pointer | 52 | // %rax = probe length, %rsp = stack pointer |
| 14 | asm volatile ( | 53 | asm volatile ( |
| ... | @@ -60,7 +99,7 @@ pub fn zig_probe_stack() callconv(.Naked) void { | ... | @@ -60,7 +99,7 @@ pub fn zig_probe_stack() callconv(.Naked) void { |
| 60 | fn win_probe_stack_only() void { | 99 | fn win_probe_stack_only() void { |
| 61 | @setRuntimeSafety(false); | 100 | @setRuntimeSafety(false); |
| 62 | 101 | ||
| 63 | switch (native_arch) { | 102 | switch (arch) { |
| 64 | .x86_64 => { | 103 | .x86_64 => { |
| 65 | asm volatile ( | 104 | asm volatile ( |
| 66 | \\ push %%rcx | 105 | \\ push %%rcx |
| ... | @@ -105,7 +144,7 @@ fn win_probe_stack_only() void { | ... | @@ -105,7 +144,7 @@ fn win_probe_stack_only() void { |
| 105 | }, | 144 | }, |
| 106 | else => {}, | 145 | else => {}, |
| 107 | } | 146 | } |
| 108 | if (comptime native_arch.isAARCH64()) { | 147 | if (comptime arch.isAARCH64()) { |
| 109 | // NOTE: page size hardcoded to 4096 for now | 148 | // NOTE: page size hardcoded to 4096 for now |
| 110 | asm volatile ( | 149 | asm volatile ( |
| 111 | \\ lsl x16, x15, #4 | 150 | \\ lsl x16, x15, #4 |
| ... | @@ -127,7 +166,7 @@ fn win_probe_stack_only() void { | ... | @@ -127,7 +166,7 @@ fn win_probe_stack_only() void { |
| 127 | fn win_probe_stack_adjust_sp() void { | 166 | fn win_probe_stack_adjust_sp() void { |
| 128 | @setRuntimeSafety(false); | 167 | @setRuntimeSafety(false); |
| 129 | 168 | ||
| 130 | switch (native_arch) { | 169 | switch (arch) { |
| 131 | .x86_64 => { | 170 | .x86_64 => { |
| 132 | asm volatile ( | 171 | asm volatile ( |
| 133 | \\ push %%rcx | 172 | \\ push %%rcx |
| ... | @@ -201,9 +240,9 @@ pub fn _chkstk() callconv(.Naked) void { | ... | @@ -201,9 +240,9 @@ pub fn _chkstk() callconv(.Naked) void { |
| 201 | } | 240 | } |
| 202 | pub fn __chkstk() callconv(.Naked) void { | 241 | pub fn __chkstk() callconv(.Naked) void { |
| 203 | @setRuntimeSafety(false); | 242 | @setRuntimeSafety(false); |
| 204 | if (comptime native_arch.isAARCH64()) { | 243 | if (comptime arch.isAARCH64()) { |
| 205 | @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{}); | 244 | @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{}); |
| 206 | } else switch (native_arch) { | 245 | } else switch (arch) { |
| 207 | .i386 => @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{}), | 246 | .i386 => @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{}), |
| 208 | .x86_64 => @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{}), | 247 | .x86_64 => @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{}), |
| 209 | else => unreachable, | 248 | else => unreachable, |
lib/compiler_rt/subo.zig+10| ... | @@ -1,4 +1,14 @@ | ... | @@ -1,4 +1,14 @@ |
| 1 | const std = @import("std"); | ||
| 1 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | ||
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__subosi4, .{ .name = "__subosi4", .linkage = linkage }); | ||
| 9 | @export(__subodi4, .{ .name = "__subodi4", .linkage = linkage }); | ||
| 10 | @export(__suboti4, .{ .name = "__suboti4", .linkage = linkage }); | ||
| 11 | } | ||
| 2 | 12 | ||
| 3 | // subo - subtract overflow | 13 | // subo - subtract overflow |
| 4 | // * return a-%b. | 14 | // * return a-%b. |
lib/compiler_rt/tan.zig+24| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | // https://golang.org/src/math/tan.go | 6 | // https://golang.org/src/math/tan.go |
| 7 | 7 | ||
| 8 | const std = @import("std"); | 8 | const std = @import("std"); |
| 9 | const builtin = @import("builtin"); | ||
| 9 | const math = std.math; | 10 | const math = std.math; |
| 10 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 11 | 12 | ||
| ... | @@ -13,6 +14,25 @@ const kernel = @import("trig.zig"); | ... | @@ -13,6 +14,25 @@ const kernel = @import("trig.zig"); |
| 13 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; | 14 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; |
| 14 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; | 15 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; |
| 15 | 16 | ||
| 17 | const arch = builtin.cpu.arch; | ||
| 18 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 19 | pub const panic = @import("common.zig").panic; | ||
| 20 | |||
| 21 | comptime { | ||
| 22 | @export(__tanh, .{ .name = "__tanh", .linkage = linkage }); | ||
| 23 | @export(tanf, .{ .name = "tanf", .linkage = linkage }); | ||
| 24 | @export(tan, .{ .name = "tan", .linkage = linkage }); | ||
| 25 | @export(__tanx, .{ .name = "__tanx", .linkage = linkage }); | ||
| 26 | @export(tanq, .{ .name = "tanq", .linkage = linkage }); | ||
| 27 | @export(tanl, .{ .name = "tanl", .linkage = linkage }); | ||
| 28 | |||
| 29 | if (!builtin.is_test) { | ||
| 30 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 31 | @export(tanf128, .{ .name = "tanf128", .linkage = linkage }); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 16 | pub fn __tanh(x: f16) callconv(.C) f16 { | 36 | pub fn __tanh(x: f16) callconv(.C) f16 { |
| 17 | // TODO: more efficient implementation | 37 | // TODO: more efficient implementation |
| 18 | return @floatCast(f16, tanf(x)); | 38 | return @floatCast(f16, tanf(x)); |
| ... | @@ -96,6 +116,10 @@ pub fn tanq(x: f128) callconv(.C) f128 { | ... | @@ -96,6 +116,10 @@ pub fn tanq(x: f128) callconv(.C) f128 { |
| 96 | return tan(@floatCast(f64, x)); | 116 | return tan(@floatCast(f64, x)); |
| 97 | } | 117 | } |
| 98 | 118 | ||
| 119 | pub fn tanf128(x: f128) callconv(.C) f128 { | ||
| 120 | return @call(.{ .modifier = .always_inline }, tanq, .{x}); | ||
| 121 | } | ||
| 122 | |||
| 99 | pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble { | 123 | pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble { |
| 100 | switch (@typeInfo(c_longdouble).Float.bits) { | 124 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 101 | 16 => return __tanh(x), | 125 | 16 => return __tanh(x), |
lib/compiler_rt/trunc.zig+23| ... | @@ -5,8 +5,27 @@ | ... | @@ -5,8 +5,27 @@ |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/trunc.c | 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/trunc.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | ||
| 8 | const math = std.math; | 9 | const math = std.math; |
| 9 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 11 | const arch = builtin.cpu.arch; | ||
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | |||
| 15 | comptime { | ||
| 16 | @export(__trunch, .{ .name = "__trunch", .linkage = linkage }); | ||
| 17 | @export(truncf, .{ .name = "truncf", .linkage = linkage }); | ||
| 18 | @export(trunc, .{ .name = "trunc", .linkage = linkage }); | ||
| 19 | @export(__truncx, .{ .name = "__truncx", .linkage = linkage }); | ||
| 20 | @export(truncq, .{ .name = "truncq", .linkage = linkage }); | ||
| 21 | @export(truncl, .{ .name = "truncl", .linkage = linkage }); | ||
| 22 | |||
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(truncf128, .{ .name = "truncf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 10 | 29 | ||
| 11 | pub fn __trunch(x: f16) callconv(.C) f16 { | 30 | pub fn __trunch(x: f16) callconv(.C) f16 { |
| 12 | // TODO: more efficient implementation | 31 | // TODO: more efficient implementation |
| ... | @@ -81,6 +100,10 @@ pub fn truncq(x: f128) callconv(.C) f128 { | ... | @@ -81,6 +100,10 @@ pub fn truncq(x: f128) callconv(.C) f128 { |
| 81 | } | 100 | } |
| 82 | } | 101 | } |
| 83 | 102 | ||
| 103 | pub fn truncf128(x: f128) callconv(.C) f128 { | ||
| 104 | return @call(.{ .modifier = .always_inline }, truncq, .{x}); | ||
| 105 | } | ||
| 106 | |||
| 84 | pub fn truncl(x: c_longdouble) callconv(.C) c_longdouble { | 107 | pub fn truncl(x: c_longdouble) callconv(.C) c_longdouble { |
| 85 | switch (@typeInfo(c_longdouble).Float.bits) { | 108 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 86 | 16 => return __trunch(x), | 109 | 16 => return __trunch(x), |
lib/compiler_rt/truncXfYf2.zig+42-2| ... | @@ -1,17 +1,49 @@ | ... | @@ -1,17 +1,49 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const native_arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const is_test = builtin.is_test; | ||
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | |||
| 8 | comptime { | ||
| 9 | @export(__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = linkage }); | ||
| 10 | @export(__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = linkage }); | ||
| 11 | @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = linkage }); | ||
| 12 | @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = linkage }); | ||
| 13 | |||
| 14 | @export(__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = linkage }); | ||
| 15 | @export(__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = linkage }); | ||
| 16 | |||
| 17 | if (!is_test) { | ||
| 18 | @export(__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = linkage }); | ||
| 19 | |||
| 20 | if (arch.isARM() or arch.isThumb()) { | ||
| 21 | @export(__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = linkage }); | ||
| 22 | @export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = linkage }); | ||
| 23 | @export(__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = linkage }); | ||
| 24 | } | ||
| 25 | |||
| 26 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 27 | @export(__trunckfsf2, .{ .name = "__trunckfsf2", .linkage = linkage }); | ||
| 28 | @export(__trunckfdf2, .{ .name = "__trunckfdf2", .linkage = linkage }); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 4 | 32 | ||
| 5 | // AArch64 is the only ABI (at the moment) to support f16 arguments without the | 33 | // AArch64 is the only ABI (at the moment) to support f16 arguments without the |
| 6 | // need for extending them to wider fp types. | 34 | // need for extending them to wider fp types. |
| 7 | // TODO remove this; do this type selection in the language rather than | 35 | // TODO remove this; do this type selection in the language rather than |
| 8 | // here in compiler-rt. | 36 | // here in compiler-rt. |
| 9 | pub const F16T = if (native_arch.isAARCH64()) f16 else u16; | 37 | const F16T = if (arch.isAARCH64()) f16 else u16; |
| 10 | 38 | ||
| 11 | pub fn __truncsfhf2(a: f32) callconv(.C) F16T { | 39 | pub fn __truncsfhf2(a: f32) callconv(.C) F16T { |
| 12 | return @bitCast(F16T, truncXfYf2(f16, f32, a)); | 40 | return @bitCast(F16T, truncXfYf2(f16, f32, a)); |
| 13 | } | 41 | } |
| 14 | 42 | ||
| 43 | pub fn __gnu_f2h_ieee(a: f32) callconv(.C) F16T { | ||
| 44 | return @call(.{ .modifier = .always_inline }, __truncsfhf2, .{a}); | ||
| 45 | } | ||
| 46 | |||
| 15 | pub fn __truncdfhf2(a: f64) callconv(.C) F16T { | 47 | pub fn __truncdfhf2(a: f64) callconv(.C) F16T { |
| 16 | return @bitCast(F16T, truncXfYf2(f16, f64, a)); | 48 | return @bitCast(F16T, truncXfYf2(f16, f64, a)); |
| 17 | } | 49 | } |
| ... | @@ -24,10 +56,18 @@ pub fn __trunctfsf2(a: f128) callconv(.C) f32 { | ... | @@ -24,10 +56,18 @@ pub fn __trunctfsf2(a: f128) callconv(.C) f32 { |
| 24 | return truncXfYf2(f32, f128, a); | 56 | return truncXfYf2(f32, f128, a); |
| 25 | } | 57 | } |
| 26 | 58 | ||
| 59 | pub fn __trunckfsf2(a: f128) callconv(.C) f32 { | ||
| 60 | return truncXfYf2(f32, f128, a); | ||
| 61 | } | ||
| 62 | |||
| 27 | pub fn __trunctfdf2(a: f128) callconv(.C) f64 { | 63 | pub fn __trunctfdf2(a: f128) callconv(.C) f64 { |
| 28 | return truncXfYf2(f64, f128, a); | 64 | return truncXfYf2(f64, f128, a); |
| 29 | } | 65 | } |
| 30 | 66 | ||
| 67 | pub fn __trunckfdf2(a: f128) callconv(.C) f64 { | ||
| 68 | return truncXfYf2(f64, f128, a); | ||
| 69 | } | ||
| 70 | |||
| 31 | pub fn __truncdfsf2(a: f64) callconv(.C) f32 { | 71 | pub fn __truncdfsf2(a: f64) callconv(.C) f32 { |
| 32 | return truncXfYf2(f32, f64, a); | 72 | return truncXfYf2(f32, f64, a); |
| 33 | } | 73 | } |
lib/compiler_rt/trunc_f80.zig+12-2| ... | @@ -1,11 +1,21 @@ | ... | @@ -1,11 +1,21 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const native_arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const testing = std.testing; | 4 | const testing = std.testing; |
| 5 | const is_test = builtin.is_test; | ||
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 8 | |||
| 9 | comptime { | ||
| 10 | @export(__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = linkage }); | ||
| 11 | @export(__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = linkage }); | ||
| 12 | @export(__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = linkage }); | ||
| 13 | @export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage }); | ||
| 14 | } | ||
| 5 | 15 | ||
| 6 | // AArch64 is the only ABI (at the moment) to support f16 arguments without the | 16 | // AArch64 is the only ABI (at the moment) to support f16 arguments without the |
| 7 | // need for extending them to wider fp types. | 17 | // need for extending them to wider fp types. |
| 8 | pub const F16T = if (native_arch.isAARCH64()) f16 else u16; | 18 | const F16T = if (arch.isAARCH64()) f16 else u16; |
| 9 | 19 | ||
| 10 | pub fn __truncxfhf2(a: f80) callconv(.C) F16T { | 20 | pub fn __truncxfhf2(a: f80) callconv(.C) F16T { |
| 11 | return @bitCast(F16T, trunc(f16, a)); | 21 | return @bitCast(F16T, trunc(f16, a)); |
lib/compiler_rt/udivmodti4.zig+25-3| ... | @@ -1,13 +1,35 @@ | ... | @@ -1,13 +1,35 @@ |
| 1 | const udivmod = @import("udivmod.zig").udivmod; | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const compiler_rt = @import("../compiler_rt.zig"); | 3 | const udivmod = @import("udivmod.zig").udivmod; |
| 4 | const arch = builtin.cpu.arch; | ||
| 5 | const is_test = builtin.is_test; | ||
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 8 | |||
| 9 | comptime { | ||
| 10 | if (builtin.os.tag == .windows) { | ||
| 11 | switch (arch) { | ||
| 12 | .i386 => { | ||
| 13 | @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage }); | ||
| 14 | }, | ||
| 15 | .x86_64 => { | ||
| 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | ||
| 17 | // that LLVM expects compiler-rt to have. | ||
| 18 | @export(__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = linkage }); | ||
| 19 | }, | ||
| 20 | else => {}, | ||
| 21 | } | ||
| 22 | } else { | ||
| 23 | @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage }); | ||
| 24 | } | ||
| 25 | } | ||
| 4 | 26 | ||
| 5 | pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.C) u128 { | 27 | pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.C) u128 { |
| 6 | @setRuntimeSafety(builtin.is_test); | 28 | @setRuntimeSafety(builtin.is_test); |
| 7 | return udivmod(u128, a, b, maybe_rem); | 29 | return udivmod(u128, a, b, maybe_rem); |
| 8 | } | 30 | } |
| 9 | 31 | ||
| 10 | const v128 = @import("std").meta.Vector(2, u64); | 32 | const v128 = std.meta.Vector(2, u64); |
| 11 | pub fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) callconv(.C) v128 { | 33 | pub fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) callconv(.C) v128 { |
| 12 | @setRuntimeSafety(builtin.is_test); | 34 | @setRuntimeSafety(builtin.is_test); |
| 13 | return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem)); | 35 | return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem)); |
lib/compiler_rt/udivti3.zig+30-4| ... | @@ -1,13 +1,39 @@ | ... | @@ -1,13 +1,39 @@ |
| 1 | const udivmodti4 = @import("udivmodti4.zig"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const udivmod = @import("udivmod.zig").udivmod; | ||
| 4 | const arch = builtin.cpu.arch; | ||
| 5 | const is_test = builtin.is_test; | ||
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 8 | |||
| 9 | comptime { | ||
| 10 | if (builtin.os.tag == .windows) { | ||
| 11 | switch (arch) { | ||
| 12 | .i386 => { | ||
| 13 | @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage }); | ||
| 14 | }, | ||
| 15 | .x86_64 => { | ||
| 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | ||
| 17 | // that LLVM expects compiler-rt to have. | ||
| 18 | @export(__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = linkage }); | ||
| 19 | }, | ||
| 20 | else => {}, | ||
| 21 | } | ||
| 22 | if (arch.isAARCH64()) { | ||
| 23 | @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage }); | ||
| 24 | } | ||
| 25 | } else { | ||
| 26 | @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 3 | 29 | ||
| 4 | pub fn __udivti3(a: u128, b: u128) callconv(.C) u128 { | 30 | pub fn __udivti3(a: u128, b: u128) callconv(.C) u128 { |
| 5 | @setRuntimeSafety(builtin.is_test); | 31 | @setRuntimeSafety(builtin.is_test); |
| 6 | return udivmodti4.__udivmodti4(a, b, null); | 32 | return udivmod(u128, a, b, null); |
| 7 | } | 33 | } |
| 8 | 34 | ||
| 9 | const v128 = @import("std").meta.Vector(2, u64); | 35 | const v128 = std.meta.Vector(2, u64); |
| 10 | pub fn __udivti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | 36 | pub fn __udivti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { |
| 11 | @setRuntimeSafety(builtin.is_test); | 37 | @setRuntimeSafety(builtin.is_test); |
| 12 | return udivmodti4.__udivmodti4_windows_x86_64(a, b, null); | 38 | return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), null)); |
| 13 | } | 39 | } |
lib/compiler_rt/umodti3.zig+29-4| ... | @@ -1,15 +1,40 @@ | ... | @@ -1,15 +1,40 @@ |
| 1 | const udivmodti4 = @import("udivmodti4.zig"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const compiler_rt = @import("../compiler_rt.zig"); | 3 | const udivmod = @import("udivmod.zig").udivmod; |
| 4 | const arch = builtin.cpu.arch; | ||
| 5 | const is_test = builtin.is_test; | ||
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 8 | |||
| 9 | comptime { | ||
| 10 | if (builtin.os.tag == .windows) { | ||
| 11 | switch (arch) { | ||
| 12 | .i386 => { | ||
| 13 | @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage }); | ||
| 14 | }, | ||
| 15 | .x86_64 => { | ||
| 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | ||
| 17 | // that LLVM expects compiler-rt to have. | ||
| 18 | @export(__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = linkage }); | ||
| 19 | }, | ||
| 20 | else => {}, | ||
| 21 | } | ||
| 22 | if (arch.isAARCH64()) { | ||
| 23 | @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage }); | ||
| 24 | } | ||
| 25 | } else { | ||
| 26 | @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 4 | 29 | ||
| 5 | pub fn __umodti3(a: u128, b: u128) callconv(.C) u128 { | 30 | pub fn __umodti3(a: u128, b: u128) callconv(.C) u128 { |
| 6 | @setRuntimeSafety(builtin.is_test); | 31 | @setRuntimeSafety(builtin.is_test); |
| 7 | var r: u128 = undefined; | 32 | var r: u128 = undefined; |
| 8 | _ = udivmodti4.__udivmodti4(a, b, &r); | 33 | _ = udivmod(u128, a, b, &r); |
| 9 | return r; | 34 | return r; |
| 10 | } | 35 | } |
| 11 | 36 | ||
| 12 | const v128 = @import("std").meta.Vector(2, u64); | 37 | const v128 = std.meta.Vector(2, u64); |
| 13 | pub fn __umodti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | 38 | pub fn __umodti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { |
| 14 | return @bitCast(v128, @call(.{ .modifier = .always_inline }, __umodti3, .{ | 39 | return @bitCast(v128, @call(.{ .modifier = .always_inline }, __umodti3, .{ |
| 15 | @bitCast(u128, a), | 40 | @bitCast(u128, a), |
src/Compilation.zig+16-11| ... | @@ -23,6 +23,7 @@ const mingw = @import("mingw.zig"); | ... | @@ -23,6 +23,7 @@ const mingw = @import("mingw.zig"); |
| 23 | const libunwind = @import("libunwind.zig"); | 23 | const libunwind = @import("libunwind.zig"); |
| 24 | const libcxx = @import("libcxx.zig"); | 24 | const libcxx = @import("libcxx.zig"); |
| 25 | const wasi_libc = @import("wasi_libc.zig"); | 25 | const wasi_libc = @import("wasi_libc.zig"); |
| 26 | const compiler_rt = @import("compiler_rt.zig"); | ||
| 26 | const fatal = @import("main.zig").fatal; | 27 | const fatal = @import("main.zig").fatal; |
| 27 | const clangMain = @import("main.zig").clangMain; | 28 | const clangMain = @import("main.zig").clangMain; |
| 28 | const Module = @import("Module.zig"); | 29 | const Module = @import("Module.zig"); |
| ... | @@ -131,7 +132,7 @@ libssp_static_lib: ?CRTFile = null, | ... | @@ -131,7 +132,7 @@ libssp_static_lib: ?CRTFile = null, |
| 131 | libc_static_lib: ?CRTFile = null, | 132 | libc_static_lib: ?CRTFile = null, |
| 132 | /// Populated when we build the libcompiler_rt static library. A Job to build this is placed in the queue | 133 | /// Populated when we build the libcompiler_rt static library. A Job to build this is placed in the queue |
| 133 | /// and resolved before calling linker.flush(). | 134 | /// and resolved before calling linker.flush(). |
| 134 | compiler_rt_static_lib: ?CRTFile = null, | 135 | compiler_rt_static_lib: compiler_rt.CompilerRtLib = .{}, |
| 135 | /// Populated when we build the compiler_rt_obj object. A Job to build this is placed in the queue | 136 | /// Populated when we build the compiler_rt_obj object. A Job to build this is placed in the queue |
| 136 | /// and resolved before calling linker.flush(). | 137 | /// and resolved before calling linker.flush(). |
| 137 | compiler_rt_obj: ?CRTFile = null, | 138 | compiler_rt_obj: ?CRTFile = null, |
| ... | @@ -175,7 +176,7 @@ pub const CRTFile = struct { | ... | @@ -175,7 +176,7 @@ pub const CRTFile = struct { |
| 175 | lock: Cache.Lock, | 176 | lock: Cache.Lock, |
| 176 | full_object_path: []const u8, | 177 | full_object_path: []const u8, |
| 177 | 178 | ||
| 178 | fn deinit(self: *CRTFile, gpa: Allocator) void { | 179 | pub fn deinit(self: *CRTFile, gpa: Allocator) void { |
| 179 | self.lock.release(); | 180 | self.lock.release(); |
| 180 | gpa.free(self.full_object_path); | 181 | gpa.free(self.full_object_path); |
| 181 | self.* = undefined; | 182 | self.* = undefined; |
| ... | @@ -1978,9 +1979,7 @@ pub fn destroy(self: *Compilation) void { | ... | @@ -1978,9 +1979,7 @@ pub fn destroy(self: *Compilation) void { |
| 1978 | if (self.libcxxabi_static_lib) |*crt_file| { | 1979 | if (self.libcxxabi_static_lib) |*crt_file| { |
| 1979 | crt_file.deinit(gpa); | 1980 | crt_file.deinit(gpa); |
| 1980 | } | 1981 | } |
| 1981 | if (self.compiler_rt_static_lib) |*crt_file| { | 1982 | self.compiler_rt_static_lib.deinit(gpa); |
| 1982 | crt_file.deinit(gpa); | ||
| 1983 | } | ||
| 1984 | if (self.compiler_rt_obj) |*crt_file| { | 1983 | if (self.compiler_rt_obj) |*crt_file| { |
| 1985 | crt_file.deinit(gpa); | 1984 | crt_file.deinit(gpa); |
| 1986 | } | 1985 | } |
| ... | @@ -3138,11 +3137,9 @@ fn processOneJob(comp: *Compilation, job: Job) !void { | ... | @@ -3138,11 +3137,9 @@ fn processOneJob(comp: *Compilation, job: Job) !void { |
| 3138 | const named_frame = tracy.namedFrame("compiler_rt_lib"); | 3137 | const named_frame = tracy.namedFrame("compiler_rt_lib"); |
| 3139 | defer named_frame.end(); | 3138 | defer named_frame.end(); |
| 3140 | 3139 | ||
| 3141 | comp.buildOutputFromZig( | 3140 | compiler_rt.buildCompilerRtLib( |
| 3142 | "compiler_rt.zig", | 3141 | comp, |
| 3143 | .Lib, | ||
| 3144 | &comp.compiler_rt_static_lib, | 3142 | &comp.compiler_rt_static_lib, |
| 3145 | .compiler_rt, | ||
| 3146 | ) catch |err| switch (err) { | 3143 | ) catch |err| switch (err) { |
| 3147 | error.OutOfMemory => return error.OutOfMemory, | 3144 | error.OutOfMemory => return error.OutOfMemory, |
| 3148 | error.SubCompilationFailed => return, // error reported already | 3145 | error.SubCompilationFailed => return, // error reported already |
| ... | @@ -4897,7 +4894,7 @@ pub fn updateSubCompilation(sub_compilation: *Compilation) !void { | ... | @@ -4897,7 +4894,7 @@ pub fn updateSubCompilation(sub_compilation: *Compilation) !void { |
| 4897 | } | 4894 | } |
| 4898 | } | 4895 | } |
| 4899 | 4896 | ||
| 4900 | fn buildOutputFromZig( | 4897 | pub fn buildOutputFromZig( |
| 4901 | comp: *Compilation, | 4898 | comp: *Compilation, |
| 4902 | src_basename: []const u8, | 4899 | src_basename: []const u8, |
| 4903 | output_mode: std.builtin.OutputMode, | 4900 | output_mode: std.builtin.OutputMode, |
| ... | @@ -4914,7 +4911,15 @@ fn buildOutputFromZig( | ... | @@ -4914,7 +4911,15 @@ fn buildOutputFromZig( |
| 4914 | .root_src_path = src_basename, | 4911 | .root_src_path = src_basename, |
| 4915 | }; | 4912 | }; |
| 4916 | defer main_pkg.deinitTable(comp.gpa); | 4913 | defer main_pkg.deinitTable(comp.gpa); |
| 4917 | const root_name = src_basename[0 .. src_basename.len - std.fs.path.extension(src_basename).len]; | 4914 | |
| 4915 | const root_name = root_name: { | ||
| 4916 | const basename = if (std.fs.path.dirname(src_basename)) |dirname| | ||
| 4917 | src_basename[dirname.len + 1 ..] | ||
| 4918 | else | ||
| 4919 | src_basename; | ||
| 4920 | const root_name = basename[0 .. basename.len - std.fs.path.extension(basename).len]; | ||
| 4921 | break :root_name root_name; | ||
| 4922 | }; | ||
| 4918 | const target = comp.getTarget(); | 4923 | const target = comp.getTarget(); |
| 4919 | const bin_basename = try std.zig.binNameAlloc(comp.gpa, .{ | 4924 | const bin_basename = try std.zig.binNameAlloc(comp.gpa, .{ |
| 4920 | .root_name = root_name, | 4925 | .root_name = root_name, |
src/compiler_rt.zig created+186| ... | @@ -0,0 +1,186 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | const Allocator = std.mem.Allocator; | ||
| 4 | const mem = std.mem; | ||
| 5 | const tracy = @import("tracy.zig"); | ||
| 6 | const trace = tracy.trace; | ||
| 7 | |||
| 8 | const Compilation = @import("Compilation.zig"); | ||
| 9 | const CRTFile = Compilation.CRTFile; | ||
| 10 | const LinkObject = Compilation.LinkObject; | ||
| 11 | const Package = @import("Package.zig"); | ||
| 12 | |||
| 13 | pub const CompilerRtLib = struct { | ||
| 14 | crt_object_files: [sources.len]?CRTFile = undefined, | ||
| 15 | crt_lib_file: ?CRTFile = null, | ||
| 16 | |||
| 17 | pub fn deinit(crt_lib: *CompilerRtLib, gpa: Allocator) void { | ||
| 18 | for (crt_lib.crt_object_files) |*crt_file| { | ||
| 19 | if (crt_file.*) |*cf| { | ||
| 20 | cf.deinit(gpa); | ||
| 21 | } | ||
| 22 | } | ||
| 23 | if (crt_lib.crt_lib_file) |*crt_file| { | ||
| 24 | crt_file.deinit(gpa); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | }; | ||
| 28 | |||
| 29 | pub fn buildCompilerRtLib(comp: *Compilation, compiler_rt_lib: *CompilerRtLib) !void { | ||
| 30 | const tracy_trace = trace(@src()); | ||
| 31 | defer tracy_trace.end(); | ||
| 32 | |||
| 33 | var progress: std.Progress = .{ .dont_print_on_dumb = true }; | ||
| 34 | var progress_node = progress.start("Compile Compiler-RT", sources.len + 1); | ||
| 35 | defer progress_node.end(); | ||
| 36 | if (comp.color == .off) progress.terminal = null; | ||
| 37 | |||
| 38 | progress_node.activate(); | ||
| 39 | |||
| 40 | var link_objects: [sources.len]LinkObject = undefined; | ||
| 41 | for (sources) |source, i| { | ||
| 42 | var obj_progress_node = progress_node.start(source, 0); | ||
| 43 | obj_progress_node.activate(); | ||
| 44 | defer obj_progress_node.end(); | ||
| 45 | |||
| 46 | try comp.buildOutputFromZig(source, .Obj, &compiler_rt_lib.crt_object_files[i], .compiler_rt); | ||
| 47 | link_objects[i] = .{ | ||
| 48 | .path = compiler_rt_lib.crt_object_files[i].?.full_object_path, | ||
| 49 | .must_link = true, | ||
| 50 | }; | ||
| 51 | } | ||
| 52 | |||
| 53 | const root_name = "compiler_rt"; | ||
| 54 | |||
| 55 | var lib_progress_node = progress_node.start(root_name, 0); | ||
| 56 | lib_progress_node.activate(); | ||
| 57 | defer lib_progress_node.end(); | ||
| 58 | |||
| 59 | const target = comp.getTarget(); | ||
| 60 | const basename = try std.zig.binNameAlloc(comp.gpa, .{ | ||
| 61 | .root_name = root_name, | ||
| 62 | .target = target, | ||
| 63 | .output_mode = .Lib, | ||
| 64 | }); | ||
| 65 | errdefer comp.gpa.free(basename); | ||
| 66 | |||
| 67 | // TODO: This is extracted into a local variable to work around a stage1 miscompilation. | ||
| 68 | const emit_bin = Compilation.EmitLoc{ | ||
| 69 | .directory = null, // Put it in the cache directory. | ||
| 70 | .basename = basename, | ||
| 71 | }; | ||
| 72 | const sub_compilation = try Compilation.create(comp.gpa, .{ | ||
| 73 | .local_cache_directory = comp.global_cache_directory, | ||
| 74 | .global_cache_directory = comp.global_cache_directory, | ||
| 75 | .zig_lib_directory = comp.zig_lib_directory, | ||
| 76 | .cache_mode = .whole, | ||
| 77 | .target = target, | ||
| 78 | .root_name = root_name, | ||
| 79 | .main_pkg = null, | ||
| 80 | .output_mode = .Lib, | ||
| 81 | .link_mode = .Static, | ||
| 82 | .function_sections = true, | ||
| 83 | .thread_pool = comp.thread_pool, | ||
| 84 | .libc_installation = comp.bin_file.options.libc_installation, | ||
| 85 | .emit_bin = emit_bin, | ||
| 86 | .optimize_mode = comp.compilerRtOptMode(), | ||
| 87 | .want_sanitize_c = false, | ||
| 88 | .want_stack_check = false, | ||
| 89 | .want_red_zone = comp.bin_file.options.red_zone, | ||
| 90 | .omit_frame_pointer = comp.bin_file.options.omit_frame_pointer, | ||
| 91 | .want_valgrind = false, | ||
| 92 | .want_tsan = false, | ||
| 93 | .want_pic = comp.bin_file.options.pic, | ||
| 94 | .want_pie = comp.bin_file.options.pie, | ||
| 95 | .want_lto = comp.bin_file.options.lto, | ||
| 96 | .emit_h = null, | ||
| 97 | .strip = comp.compilerRtStrip(), | ||
| 98 | .is_native_os = comp.bin_file.options.is_native_os, | ||
| 99 | .is_native_abi = comp.bin_file.options.is_native_abi, | ||
| 100 | .self_exe_path = comp.self_exe_path, | ||
| 101 | .link_objects = &link_objects, | ||
| 102 | .verbose_cc = comp.verbose_cc, | ||
| 103 | .verbose_link = comp.bin_file.options.verbose_link, | ||
| 104 | .verbose_air = comp.verbose_air, | ||
| 105 | .verbose_llvm_ir = comp.verbose_llvm_ir, | ||
| 106 | .verbose_cimport = comp.verbose_cimport, | ||
| 107 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, | ||
| 108 | .clang_passthrough_mode = comp.clang_passthrough_mode, | ||
| 109 | .skip_linker_dependencies = true, | ||
| 110 | .parent_compilation_link_libc = comp.bin_file.options.link_libc, | ||
| 111 | }); | ||
| 112 | defer sub_compilation.destroy(); | ||
| 113 | |||
| 114 | try sub_compilation.updateSubCompilation(); | ||
| 115 | |||
| 116 | compiler_rt_lib.crt_lib_file = .{ | ||
| 117 | .full_object_path = try sub_compilation.bin_file.options.emit.?.directory.join(comp.gpa, &[_][]const u8{ | ||
| 118 | sub_compilation.bin_file.options.emit.?.sub_path, | ||
| 119 | }), | ||
| 120 | .lock = sub_compilation.bin_file.toOwnedLock(), | ||
| 121 | }; | ||
| 122 | } | ||
| 123 | |||
| 124 | const sources = &[_][]const u8{ | ||
| 125 | "compiler_rt/atomics.zig", | ||
| 126 | "compiler_rt/sin.zig", | ||
| 127 | "compiler_rt/cos.zig", | ||
| 128 | "compiler_rt/sincos.zig", | ||
| 129 | "compiler_rt/ceil.zig", | ||
| 130 | "compiler_rt/exp.zig", | ||
| 131 | "compiler_rt/exp2.zig", | ||
| 132 | "compiler_rt/fabs.zig", | ||
| 133 | "compiler_rt/floor.zig", | ||
| 134 | "compiler_rt/fma.zig", | ||
| 135 | "compiler_rt/fmax.zig", | ||
| 136 | "compiler_rt/fmin.zig", | ||
| 137 | "compiler_rt/fmod.zig", | ||
| 138 | "compiler_rt/log.zig", | ||
| 139 | "compiler_rt/log10.zig", | ||
| 140 | "compiler_rt/log2.zig", | ||
| 141 | "compiler_rt/round.zig", | ||
| 142 | "compiler_rt/sqrt.zig", | ||
| 143 | "compiler_rt/tan.zig", | ||
| 144 | "compiler_rt/trunc.zig", | ||
| 145 | "compiler_rt/extendXfYf2.zig", | ||
| 146 | "compiler_rt/extend_f80.zig", | ||
| 147 | "compiler_rt/compareXf2.zig", | ||
| 148 | "compiler_rt/stack_probe.zig", | ||
| 149 | "compiler_rt/divti3.zig", | ||
| 150 | "compiler_rt/modti3.zig", | ||
| 151 | "compiler_rt/multi3.zig", | ||
| 152 | "compiler_rt/udivti3.zig", | ||
| 153 | "compiler_rt/udivmodti4.zig", | ||
| 154 | "compiler_rt/umodti3.zig", | ||
| 155 | "compiler_rt/truncXfYf2.zig", | ||
| 156 | "compiler_rt/trunc_f80.zig", | ||
| 157 | "compiler_rt/addXf3.zig", | ||
| 158 | "compiler_rt/mulXf3.zig", | ||
| 159 | "compiler_rt/divsf3.zig", | ||
| 160 | "compiler_rt/divdf3.zig", | ||
| 161 | "compiler_rt/divxf3.zig", | ||
| 162 | "compiler_rt/divtf3.zig", | ||
| 163 | "compiler_rt/floatXiYf.zig", | ||
| 164 | "compiler_rt/fixXfYi.zig", | ||
| 165 | "compiler_rt/count0bits.zig", | ||
| 166 | "compiler_rt/parity.zig", | ||
| 167 | "compiler_rt/popcount.zig", | ||
| 168 | "compiler_rt/bswap.zig", | ||
| 169 | "compiler_rt/int.zig", | ||
| 170 | "compiler_rt/shift.zig", | ||
| 171 | "compiler_rt/negXi2.zig", | ||
| 172 | "compiler_rt/muldi3.zig", | ||
| 173 | "compiler_rt/absv.zig", | ||
| 174 | "compiler_rt/negv.zig", | ||
| 175 | "compiler_rt/addo.zig", | ||
| 176 | "compiler_rt/subo.zig", | ||
| 177 | "compiler_rt/mulo.zig", | ||
| 178 | "compiler_rt/cmp.zig", | ||
| 179 | "compiler_rt/negXf2.zig", | ||
| 180 | "compiler_rt/os_version_check.zig", | ||
| 181 | "compiler_rt/emutls.zig", | ||
| 182 | "compiler_rt/arm.zig", | ||
| 183 | "compiler_rt/aulldiv.zig", | ||
| 184 | "compiler_rt/sparc.zig", | ||
| 185 | "compiler_rt/clear_cache.zig", | ||
| 186 | }; | ||
src/link/Coff.zig+1-1| ... | @@ -1354,7 +1354,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Node) ! | ... | @@ -1354,7 +1354,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Node) ! |
| 1354 | } | 1354 | } |
| 1355 | // MSVC compiler_rt is missing some stuff, so we build it unconditionally but | 1355 | // MSVC compiler_rt is missing some stuff, so we build it unconditionally but |
| 1356 | // and rely on weak linkage to allow MSVC compiler_rt functions to override ours. | 1356 | // and rely on weak linkage to allow MSVC compiler_rt functions to override ours. |
| 1357 | if (comp.compiler_rt_static_lib) |lib| { | 1357 | if (comp.compiler_rt_static_lib.crt_lib_file) |lib| { |
| 1358 | try argv.append(lib.full_object_path); | 1358 | try argv.append(lib.full_object_path); |
| 1359 | } | 1359 | } |
| 1360 | } | 1360 | } |
src/link/Elf.zig+1-1| ... | @@ -1272,7 +1272,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v | ... | @@ -1272,7 +1272,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v |
| 1272 | const stack_size = self.base.options.stack_size_override orelse 16777216; | 1272 | const stack_size = self.base.options.stack_size_override orelse 16777216; |
| 1273 | const allow_shlib_undefined = self.base.options.allow_shlib_undefined orelse !self.base.options.is_native_os; | 1273 | const allow_shlib_undefined = self.base.options.allow_shlib_undefined orelse !self.base.options.is_native_os; |
| 1274 | const compiler_rt_path: ?[]const u8 = blk: { | 1274 | const compiler_rt_path: ?[]const u8 = blk: { |
| 1275 | if (comp.compiler_rt_static_lib) |x| break :blk x.full_object_path; | 1275 | if (comp.compiler_rt_static_lib.crt_lib_file) |x| break :blk x.full_object_path; |
| 1276 | if (comp.compiler_rt_obj) |x| break :blk x.full_object_path; | 1276 | if (comp.compiler_rt_obj) |x| break :blk x.full_object_path; |
| 1277 | break :blk null; | 1277 | break :blk null; |
| 1278 | }; | 1278 | }; |
src/link/MachO.zig+1-1| ... | @@ -738,7 +738,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No | ... | @@ -738,7 +738,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 738 | try positionals.append(p); | 738 | try positionals.append(p); |
| 739 | } | 739 | } |
| 740 | 740 | ||
| 741 | if (comp.compiler_rt_static_lib) |lib| { | 741 | if (comp.compiler_rt_static_lib.crt_lib_file) |lib| { |
| 742 | try positionals.append(lib.full_object_path); | 742 | try positionals.append(lib.full_object_path); |
| 743 | } | 743 | } |
| 744 | 744 |
src/link/Wasm.zig+1-1| ... | @@ -2255,7 +2255,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! | ... | @@ -2255,7 +2255,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! |
| 2255 | const is_obj = self.base.options.output_mode == .Obj; | 2255 | const is_obj = self.base.options.output_mode == .Obj; |
| 2256 | 2256 | ||
| 2257 | const compiler_rt_path: ?[]const u8 = if (self.base.options.include_compiler_rt and !is_obj) | 2257 | const compiler_rt_path: ?[]const u8 = if (self.base.options.include_compiler_rt and !is_obj) |
| 2258 | comp.compiler_rt_static_lib.?.full_object_path | 2258 | comp.compiler_rt_static_lib.crt_lib_file.?.full_object_path |
| 2259 | else | 2259 | else |
| 2260 | null; | 2260 | null; |
| 2261 | 2261 |
src/musl.zig-1| ... | @@ -4,7 +4,6 @@ const mem = std.mem; | ... | @@ -4,7 +4,6 @@ const mem = std.mem; |
| 4 | const path = std.fs.path; | 4 | const path = std.fs.path; |
| 5 | const assert = std.debug.assert; | 5 | const assert = std.debug.assert; |
| 6 | 6 | ||
| 7 | const target_util = @import("target.zig"); | ||
| 8 | const Compilation = @import("Compilation.zig"); | 7 | const Compilation = @import("Compilation.zig"); |
| 9 | const build_options = @import("build_options"); | 8 | const build_options = @import("build_options"); |
| 10 | 9 |