diff --git a/CMakeLists.txt b/CMakeLists.txt index 38dbd6ca6a..8317566b44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,181 +205,6 @@ set(ZIG_CPP_SOURCES set(ZIG_STAGE2_SOURCES "${ZIG_CONFIG_ZIG_OUT}" lib/compiler_rt.zig - lib/compiler_rt/absv.zig - lib/compiler_rt/absvdi2.zig - lib/compiler_rt/absvsi2.zig - lib/compiler_rt/absvti2.zig - lib/compiler_rt/adddf3.zig - lib/compiler_rt/addf3.zig - lib/compiler_rt/addsf3.zig - lib/compiler_rt/addtf3.zig - lib/compiler_rt/addvsi3.zig - lib/compiler_rt/addvdi3.zig - lib/compiler_rt/addxf3.zig - lib/compiler_rt/arm.zig - lib/compiler_rt/atomics.zig - lib/compiler_rt/aulldiv.zig - lib/compiler_rt/aullrem.zig - lib/compiler_rt/bswap.zig - lib/compiler_rt/clear_cache.zig - lib/compiler_rt/cmp.zig - lib/compiler_rt/cmpdf2.zig - lib/compiler_rt/cmpsf2.zig - lib/compiler_rt/cmptf2.zig - lib/compiler_rt/cmpxf2.zig - lib/compiler_rt/common.zig - lib/compiler_rt/comparef.zig - lib/compiler_rt/cos.zig - lib/compiler_rt/count0bits.zig - lib/compiler_rt/divdf3.zig - lib/compiler_rt/divsf3.zig - lib/compiler_rt/divtf3.zig - lib/compiler_rt/divti3.zig - lib/compiler_rt/divxf3.zig - lib/compiler_rt/emutls.zig - lib/compiler_rt/exp.zig - lib/compiler_rt/exp2.zig - lib/compiler_rt/extenddftf2.zig - lib/compiler_rt/extenddfxf2.zig - lib/compiler_rt/extendf.zig - lib/compiler_rt/extendhfsf2.zig - lib/compiler_rt/extendhftf2.zig - lib/compiler_rt/extendhfxf2.zig - lib/compiler_rt/extendsfdf2.zig - lib/compiler_rt/extendsftf2.zig - lib/compiler_rt/extendsfxf2.zig - lib/compiler_rt/extendxftf2.zig - lib/compiler_rt/fabs.zig - lib/compiler_rt/fixdfdi.zig - lib/compiler_rt/fixdfsi.zig - lib/compiler_rt/fixdfti.zig - lib/compiler_rt/fixhfdi.zig - lib/compiler_rt/fixhfsi.zig - lib/compiler_rt/fixhfti.zig - lib/compiler_rt/fixsfdi.zig - lib/compiler_rt/fixsfsi.zig - lib/compiler_rt/fixsfti.zig - lib/compiler_rt/fixtfdi.zig - lib/compiler_rt/fixtfsi.zig - lib/compiler_rt/fixtfti.zig - lib/compiler_rt/fixunsdfdi.zig - lib/compiler_rt/fixunsdfsi.zig - lib/compiler_rt/fixunsdfti.zig - lib/compiler_rt/fixunshfdi.zig - lib/compiler_rt/fixunshfsi.zig - lib/compiler_rt/fixunshfti.zig - lib/compiler_rt/fixunssfdi.zig - lib/compiler_rt/fixunssfsi.zig - lib/compiler_rt/fixunssfti.zig - lib/compiler_rt/fixunstfdi.zig - lib/compiler_rt/fixunstfsi.zig - lib/compiler_rt/fixunstfti.zig - lib/compiler_rt/fixunsxfdi.zig - lib/compiler_rt/fixunsxfsi.zig - lib/compiler_rt/fixunsxfti.zig - lib/compiler_rt/fixxfdi.zig - lib/compiler_rt/fixxfsi.zig - lib/compiler_rt/fixxfti.zig - lib/compiler_rt/float_from_int.zig - lib/compiler_rt/floatdidf.zig - lib/compiler_rt/floatdihf.zig - lib/compiler_rt/floatdisf.zig - lib/compiler_rt/floatditf.zig - lib/compiler_rt/floatdixf.zig - lib/compiler_rt/floatsidf.zig - lib/compiler_rt/floatsihf.zig - lib/compiler_rt/floatsisf.zig - lib/compiler_rt/floatsitf.zig - lib/compiler_rt/floatsixf.zig - lib/compiler_rt/floattidf.zig - lib/compiler_rt/floattihf.zig - lib/compiler_rt/floattisf.zig - lib/compiler_rt/floattitf.zig - lib/compiler_rt/floattixf.zig - lib/compiler_rt/floatundidf.zig - lib/compiler_rt/floatundihf.zig - lib/compiler_rt/floatundisf.zig - lib/compiler_rt/floatunditf.zig - lib/compiler_rt/floatundixf.zig - lib/compiler_rt/floatunsidf.zig - lib/compiler_rt/floatunsihf.zig - lib/compiler_rt/floatunsisf.zig - lib/compiler_rt/floatunsitf.zig - lib/compiler_rt/floatunsixf.zig - lib/compiler_rt/floatuntidf.zig - lib/compiler_rt/floatuntihf.zig - lib/compiler_rt/floatuntisf.zig - lib/compiler_rt/floatuntitf.zig - lib/compiler_rt/floatuntixf.zig - lib/compiler_rt/floor_ceil.zig - lib/compiler_rt/fma.zig - lib/compiler_rt/fmax.zig - lib/compiler_rt/fmin.zig - lib/compiler_rt/fmod.zig - lib/compiler_rt/gedf2.zig - lib/compiler_rt/gesf2.zig - lib/compiler_rt/getf2.zig - lib/compiler_rt/gexf2.zig - lib/compiler_rt/int.zig - lib/compiler_rt/int_from_float.zig - lib/compiler_rt/log.zig - lib/compiler_rt/log10.zig - lib/compiler_rt/log2.zig - lib/compiler_rt/modti3.zig - lib/compiler_rt/mulXi3.zig - lib/compiler_rt/muldf3.zig - lib/compiler_rt/mulf3.zig - lib/compiler_rt/mulo.zig - lib/compiler_rt/mulsf3.zig - lib/compiler_rt/multf3.zig - lib/compiler_rt/mulvsi3.zig - lib/compiler_rt/mulxf3.zig - lib/compiler_rt/negXi2.zig - lib/compiler_rt/negdf2.zig - lib/compiler_rt/negsf2.zig - lib/compiler_rt/negtf2.zig - lib/compiler_rt/negv.zig - lib/compiler_rt/negxf2.zig - lib/compiler_rt/os_version_check.zig - lib/compiler_rt/parity.zig - lib/compiler_rt/popcount.zig - lib/compiler_rt/rem_pio2.zig - lib/compiler_rt/rem_pio2_large.zig - lib/compiler_rt/rem_pio2f.zig - lib/compiler_rt/round.zig - lib/compiler_rt/shift.zig - lib/compiler_rt/sin.zig - lib/compiler_rt/sincos.zig - lib/compiler_rt/sqrt.zig - lib/compiler_rt/stack_probe.zig - lib/compiler_rt/subdf3.zig - lib/compiler_rt/subsf3.zig - lib/compiler_rt/subtf3.zig - lib/compiler_rt/subvdi3.zig - lib/compiler_rt/subvsi3.zig - lib/compiler_rt/subxf3.zig - lib/compiler_rt/tan.zig - lib/compiler_rt/trig.zig - lib/compiler_rt/trunc.zig - lib/compiler_rt/truncdfhf2.zig - lib/compiler_rt/truncdfsf2.zig - lib/compiler_rt/truncf.zig - lib/compiler_rt/truncsfhf2.zig - lib/compiler_rt/trunctfdf2.zig - lib/compiler_rt/trunctfhf2.zig - lib/compiler_rt/trunctfsf2.zig - lib/compiler_rt/trunctfxf2.zig - lib/compiler_rt/truncxfdf2.zig - lib/compiler_rt/truncxfhf2.zig - lib/compiler_rt/truncxfsf2.zig - lib/compiler_rt/udivmod.zig - lib/compiler_rt/udivmodei4.zig - lib/compiler_rt/udivmodti4.zig - lib/compiler_rt/udivti3.zig - lib/compiler_rt/umodti3.zig - lib/compiler_rt/unorddf2.zig - lib/compiler_rt/unordsf2.zig - lib/compiler_rt/unordtf2.zig lib/std/BitStack.zig lib/std/Build.zig lib/std/Build/Cache.zig diff --git a/lib/compiler_rt.zig b/lib/compiler_rt.zig index 343363188f..5c9c7a59af 100644 --- a/lib/compiler_rt.zig +++ b/lib/compiler_rt.zig @@ -1,5 +1,6 @@ const builtin = @import("builtin"); const ofmt_c = builtin.object_format == .c; +const native_endian = builtin.cpu.arch.endian(); const std = @import("std"); @@ -57,13 +58,12 @@ comptime { _ = @import("compiler_rt/cmp.zig"); _ = @import("compiler_rt/shift.zig"); - _ = @import("compiler_rt/negXi2.zig"); + symbol(&__negsi2, "__negsi2"); + symbol(&__negdi2, "__negdi2"); + symbol(&__negti2, "__negti2"); _ = @import("compiler_rt/int.zig"); _ = @import("compiler_rt/mulXi3.zig"); - _ = @import("compiler_rt/divti3.zig"); - _ = @import("compiler_rt/udivti3.zig"); - _ = @import("compiler_rt/modti3.zig"); - _ = @import("compiler_rt/umodti3.zig"); + _ = @import("compiler_rt/udivmod.zig"); _ = @import("compiler_rt/absv.zig"); _ = @import("compiler_rt/absvsi2.zig"); @@ -108,9 +108,6 @@ comptime { _ = @import("compiler_rt/trunctfxf2.zig"); _ = @import("compiler_rt/int_from_float.zig"); - _ = @import("compiler_rt/fixhfsi.zig"); - _ = @import("compiler_rt/fixhfdi.zig"); - _ = @import("compiler_rt/fixhfti.zig"); _ = @import("compiler_rt/fixhfei.zig"); _ = @import("compiler_rt/fixsfsi.zig"); _ = @import("compiler_rt/fixsfdi.zig"); @@ -126,8 +123,8 @@ comptime { _ = @import("compiler_rt/fixtfei.zig"); _ = @import("compiler_rt/fixxfsi.zig"); _ = @import("compiler_rt/fixxfdi.zig"); - _ = @import("compiler_rt/fixxfti.zig"); _ = @import("compiler_rt/fixxfei.zig"); + _ = @import("compiler_rt/fixunshfsi.zig"); _ = @import("compiler_rt/fixunshfdi.zig"); _ = @import("compiler_rt/fixunshfti.zig"); @@ -193,16 +190,10 @@ comptime { // comparison _ = @import("compiler_rt/comparef.zig"); - _ = @import("compiler_rt/cmphf2.zig"); - _ = @import("compiler_rt/cmpsf2.zig"); _ = @import("compiler_rt/cmpdf2.zig"); _ = @import("compiler_rt/cmptf2.zig"); _ = @import("compiler_rt/cmpxf2.zig"); - _ = @import("compiler_rt/unordhf2.zig"); - _ = @import("compiler_rt/unordsf2.zig"); _ = @import("compiler_rt/unorddf2.zig"); - _ = @import("compiler_rt/unordxf2.zig"); - _ = @import("compiler_rt/unordtf2.zig"); _ = @import("compiler_rt/gehf2.zig"); _ = @import("compiler_rt/gesf2.zig"); _ = @import("compiler_rt/gedf2.zig"); @@ -236,11 +227,17 @@ comptime { _ = @import("compiler_rt/divxf3.zig"); _ = @import("compiler_rt/divtf3.zig"); - _ = @import("compiler_rt/neghf2.zig"); - _ = @import("compiler_rt/negsf2.zig"); - _ = @import("compiler_rt/negdf2.zig"); - _ = @import("compiler_rt/negtf2.zig"); - _ = @import("compiler_rt/negxf2.zig"); + symbol(&__neghf2, "__neghf2"); + if (want_aeabi) { + symbol(&__aeabi_fneg, "__aeabi_fneg"); + symbol(&__aeabi_dneg, "__aeabi_dneg"); + } else { + symbol(&__negsf2, "__negsf2"); + symbol(&__negdf2, "__negdf2"); + } + if (want_ppc_abi) symbol(&__negtf2, "__negkf2"); + symbol(&__negtf2, "__negtf2"); + symbol(&__negxf2, "__negxf2"); // other _ = @import("compiler_rt/powiXf2.zig"); @@ -281,7 +278,6 @@ comptime { // BigInt. Alphabetically sorted. _ = @import("compiler_rt/divmodei4.zig"); _ = @import("compiler_rt/udivmodei4.zig"); - _ = @import("compiler_rt/udivmodti4.zig"); // extra _ = @import("compiler_rt/os_version_check.zig"); @@ -302,10 +298,13 @@ comptime { } _ = @import("compiler_rt/memcpy.zig"); - _ = @import("compiler_rt/memset.zig"); + if (!ofmt_c) { + symbol(&memset, "memset"); + symbol(&__memset, "__memset"); + } _ = @import("compiler_rt/memmove.zig"); symbol(&memcmp, "memcmp"); - _ = @import("compiler_rt/bcmp.zig"); + symbol(&bcmp, "bcmp"); _ = @import("compiler_rt/ssp.zig"); symbol(&strlen, "strlen"); } @@ -345,3 +344,383 @@ test "memcmp" { try std.testing.expect(memcmp(arr0, arr4, 3) < 0); try std.testing.expect(memcmp(arr4, arr0, 3) > 0); } + +pub const PreferredLoadStoreElement = element: { + if (std.simd.suggestVectorLength(u8)) |vec_size| { + const Vec = @Vector(vec_size, u8); + + if (@sizeOf(Vec) == vec_size and std.math.isPowerOfTwo(vec_size)) { + break :element Vec; + } + } + break :element usize; +}; + +pub const want_aeabi = switch (builtin.abi) { + .eabi, + .eabihf, + .musleabi, + .musleabihf, + .gnueabi, + .gnueabihf, + .android, + .androideabi, + => switch (builtin.cpu.arch) { + .arm, .armeb, .thumb, .thumbeb => true, + else => false, + }, + else => false, +}; + +/// These functions are required on Windows on ARM. They are provided by MSVC libc, but in libc-less +/// builds or when linking MinGW libc they are our responsibility. +/// Temporarily used for thumb-uefi until https://github.com/ziglang/zig/issues/21630 is addressed. +pub const want_windows_arm_abi = e: { + if (!builtin.cpu.arch.isArm()) break :e false; + switch (builtin.os.tag) { + .windows, .uefi => {}, + else => break :e false, + } + // The ABI is needed, but it's only our reponsibility if libc won't provide it. + break :e builtin.abi.isGnu() or !builtin.link_libc; +}; + +/// These functions are required by on Windows on x86 on some ABIs. They are provided by MSVC libc, +/// but in libc-less builds they are our responsibility. +pub const want_windows_x86_msvc_abi = e: { + if (builtin.cpu.arch != .x86) break :e false; + if (builtin.os.tag != .windows) break :e false; + switch (builtin.abi) { + .none, .msvc, .itanium => {}, + else => break :e false, + } + // The ABI is needed, but it's only our responsibility if libc won't provide it. + break :e !builtin.link_libc; +}; + +pub const want_ppc_abi = builtin.cpu.arch.isPowerPC(); + +pub const want_float_exceptions = !builtin.cpu.arch.isWasm(); + +// Libcalls that involve u128 on Windows x86-64 are expected by LLVM to use the +// calling convention of @Vector(2, u64), rather than what's standard. +pub const want_windows_v2u64_abi = builtin.os.tag == .windows and builtin.cpu.arch == .x86_64 and !ofmt_c; + +/// This governs whether to use these symbol names for f16/f32 conversions +/// rather than the standard names: +/// * __gnu_f2h_ieee +/// * __gnu_h2f_ieee +/// Known correct configurations: +/// x86_64-freestanding-none => true +/// x86_64-linux-none => true +/// x86_64-linux-gnu => true +/// x86_64-linux-musl => true +/// x86_64-linux-eabi => true +/// arm-linux-musleabihf => true +/// arm-linux-gnueabihf => true +/// arm-linux-eabihf => false +/// wasm32-wasi-musl => false +/// wasm32-freestanding-none => false +/// x86_64-windows-gnu => true +/// x86_64-windows-msvc => true +/// any-macos-any => false +pub const gnu_f16_abi = switch (builtin.cpu.arch) { + .wasm32, + .wasm64, + .riscv64, + .riscv64be, + .riscv32, + .riscv32be, + => false, + + .x86, .x86_64 => true, + + .arm, .armeb, .thumb, .thumbeb => switch (builtin.abi) { + .eabi, .eabihf => false, + else => true, + }, + + else => !builtin.os.tag.isDarwin(), +}; + +pub const want_sparc_abi = builtin.cpu.arch.isSPARC(); + +/// This seems to mostly correspond to `clang::TargetInfo::HasFloat16`. +pub fn F16T(comptime OtherType: type) type { + return switch (builtin.cpu.arch) { + .amdgcn, + .arm, + .armeb, + .thumb, + .thumbeb, + .aarch64, + .aarch64_be, + .hexagon, + .loongarch32, + .loongarch64, + .nvptx, + .nvptx64, + .riscv32, + .riscv32be, + .riscv64, + .riscv64be, + .s390x, + .spirv32, + .spirv64, + => f16, + .x86, .x86_64 => if (builtin.target.os.tag.isDarwin()) switch (OtherType) { + // Starting with LLVM 16, Darwin uses different abi for f16 + // depending on the type of the other return/argument..??? + f32, f64 => u16, + f80, f128 => f16, + else => unreachable, + } else f16, + else => u16, + }; +} + +pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { + switch (Z) { + u16 => { + // 16x16 --> 32 bit multiply + const product = @as(u32, a) * @as(u32, b); + hi.* = @intCast(product >> 16); + lo.* = @truncate(product); + }, + u32 => { + // 32x32 --> 64 bit multiply + const product = @as(u64, a) * @as(u64, b); + hi.* = @truncate(product >> 32); + lo.* = @truncate(product); + }, + u64 => { + const S = struct { + fn loWord(x: u64) u64 { + return @as(u32, @truncate(x)); + } + fn hiWord(x: u64) u64 { + return @as(u32, @truncate(x >> 32)); + } + }; + // 64x64 -> 128 wide multiply for platforms that don't have such an operation; + // many 64-bit platforms have this operation, but they tend to have hardware + // floating-point, so we don't bother with a special case for them here. + // Each of the component 32x32 -> 64 products + const plolo: u64 = S.loWord(a) * S.loWord(b); + const plohi: u64 = S.loWord(a) * S.hiWord(b); + const philo: u64 = S.hiWord(a) * S.loWord(b); + const phihi: u64 = S.hiWord(a) * S.hiWord(b); + // Sum terms that contribute to lo in a way that allows us to get the carry + const r0: u64 = S.loWord(plolo); + const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo); + lo.* = r0 +% (r1 << 32); + // Sum terms contributing to hi with the carry from lo + hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi; + }, + u128 => { + const Word_LoMask: u64 = 0x00000000ffffffff; + const Word_HiMask: u64 = 0xffffffff00000000; + const Word_FullMask: u64 = 0xffffffffffffffff; + const S = struct { + fn Word_1(x: u128) u64 { + return @as(u32, @truncate(x >> 96)); + } + fn Word_2(x: u128) u64 { + return @as(u32, @truncate(x >> 64)); + } + fn Word_3(x: u128) u64 { + return @as(u32, @truncate(x >> 32)); + } + fn Word_4(x: u128) u64 { + return @as(u32, @truncate(x)); + } + }; + // 128x128 -> 256 wide multiply for platforms that don't have such an operation; + // many 64-bit platforms have this operation, but they tend to have hardware + // floating-point, so we don't bother with a special case for them here. + + const product11: u64 = S.Word_1(a) * S.Word_1(b); + const product12: u64 = S.Word_1(a) * S.Word_2(b); + const product13: u64 = S.Word_1(a) * S.Word_3(b); + const product14: u64 = S.Word_1(a) * S.Word_4(b); + const product21: u64 = S.Word_2(a) * S.Word_1(b); + const product22: u64 = S.Word_2(a) * S.Word_2(b); + const product23: u64 = S.Word_2(a) * S.Word_3(b); + const product24: u64 = S.Word_2(a) * S.Word_4(b); + const product31: u64 = S.Word_3(a) * S.Word_1(b); + const product32: u64 = S.Word_3(a) * S.Word_2(b); + const product33: u64 = S.Word_3(a) * S.Word_3(b); + const product34: u64 = S.Word_3(a) * S.Word_4(b); + const product41: u64 = S.Word_4(a) * S.Word_1(b); + const product42: u64 = S.Word_4(a) * S.Word_2(b); + const product43: u64 = S.Word_4(a) * S.Word_3(b); + const product44: u64 = S.Word_4(a) * S.Word_4(b); + + const sum0: u128 = @as(u128, product44); + const sum1: u128 = @as(u128, product34) +% + @as(u128, product43); + const sum2: u128 = @as(u128, product24) +% + @as(u128, product33) +% + @as(u128, product42); + const sum3: u128 = @as(u128, product14) +% + @as(u128, product23) +% + @as(u128, product32) +% + @as(u128, product41); + const sum4: u128 = @as(u128, product13) +% + @as(u128, product22) +% + @as(u128, product31); + const sum5: u128 = @as(u128, product12) +% + @as(u128, product21); + const sum6: u128 = @as(u128, product11); + + const r0: u128 = (sum0 & Word_FullMask) +% + ((sum1 & Word_LoMask) << 32); + const r1: u128 = (sum0 >> 64) +% + ((sum1 >> 32) & Word_FullMask) +% + (sum2 & Word_FullMask) +% + ((sum3 << 32) & Word_HiMask); + + lo.* = r0 +% (r1 << 64); + hi.* = (r1 >> 64) +% + (sum1 >> 96) +% + (sum2 >> 64) +% + (sum3 >> 32) +% + sum4 +% + (sum5 << 32) +% + (sum6 << 64); + }, + else => @compileError("unsupported"), + } +} + +pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).float.bits)) i32 { + const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits); + const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T); + + const shift = @clz(significand.*) - @clz(integerBit); + significand.* <<= @as(std.math.Log2Int(Z), @intCast(shift)); + return @as(i32, 1) - shift; +} + +pub inline fn fneg(a: anytype) @TypeOf(a) { + const F = @TypeOf(a); + const bits = @typeInfo(F).float.bits; + const U = @Int(.unsigned, bits); + const sign_bit_mask = @as(U, 1) << (bits - 1); + const negated = @as(U, @bitCast(a)) ^ sign_bit_mask; + return @bitCast(negated); +} + +fn __negxf2(a: f80) callconv(.c) f80 { + return fneg(a); +} + +fn __neghf2(a: f16) callconv(.c) f16 { + return fneg(a); +} + +fn __negdf2(a: f64) callconv(.c) f64 { + return fneg(a); +} + +fn __aeabi_dneg(a: f64) callconv(.{ .arm_aapcs = .{} }) f64 { + return fneg(a); +} + +fn __negtf2(a: f128) callconv(.c) f128 { + return fneg(a); +} + +fn __negsf2(a: f32) callconv(.c) f32 { + return fneg(a); +} + +fn __aeabi_fneg(a: f32) callconv(.{ .arm_aapcs = .{} }) f32 { + return fneg(a); +} + +/// Allows to access underlying bits as two equally sized lower and higher +/// signed or unsigned integers. +pub fn HalveInt(comptime T: type, comptime signed_half: bool) type { + return extern union { + pub const bits = @divExact(@typeInfo(T).int.bits, 2); + pub const HalfTU = std.meta.Int(.unsigned, bits); + pub const HalfTS = std.meta.Int(.signed, bits); + pub const HalfT = if (signed_half) HalfTS else HalfTU; + + all: T, + s: if (native_endian == .little) + extern struct { low: HalfT, high: HalfT } + else + extern struct { high: HalfT, low: HalfT }, + }; +} + +pub fn __negsi2(a: i32) callconv(.c) i32 { + return negXi2(i32, a); +} + +pub fn __negdi2(a: i64) callconv(.c) i64 { + return negXi2(i64, a); +} + +pub fn __negti2(a: i128) callconv(.c) i128 { + return negXi2(i128, a); +} + +inline fn negXi2(comptime T: type, a: T) T { + return -a; +} + +pub fn memset(dest: ?[*]u8, c: u8, len: usize) callconv(.c) ?[*]u8 { + @setRuntimeSafety(false); + + if (len != 0) { + var d = dest.?; + var n = len; + while (true) { + d[0] = c; + n -= 1; + if (n == 0) break; + d += 1; + } + } + + return dest; +} + +pub fn __memset(dest: ?[*]u8, c: u8, n: usize, dest_n: usize) callconv(.c) ?[*]u8 { + if (dest_n < n) + @panic("buffer overflow"); + return memset(dest, c, n); +} + +pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.c) c_int { + @setRuntimeSafety(false); + + var index: usize = 0; + while (index != n) : (index += 1) { + if (vl[index] != vr[index]) { + return 1; + } + } + + return 0; +} + +test "bcmp" { + const base_arr = &[_]u8{ 1, 1, 1 }; + const arr1 = &[_]u8{ 1, 1, 1 }; + const arr2 = &[_]u8{ 1, 0, 1 }; + const arr3 = &[_]u8{ 1, 2, 1 }; + + try std.testing.expect(bcmp(base_arr[0..], arr1[0..], base_arr.len) == 0); + try std.testing.expect(bcmp(base_arr[0..], arr2[0..], base_arr.len) != 0); + try std.testing.expect(bcmp(base_arr[0..], arr3[0..], base_arr.len) != 0); +} + +test { + _ = @import("compiler_rt/negsi2_test.zig"); + _ = @import("compiler_rt/negdi2_test.zig"); + _ = @import("compiler_rt/negti2_test.zig"); +} diff --git a/lib/compiler_rt/aarch64_outline_atomics.zig b/lib/compiler_rt/aarch64_outline_atomics.zig index 817800eb21..c03306cd1a 100644 --- a/lib/compiler_rt/aarch64_outline_atomics.zig +++ b/lib/compiler_rt/aarch64_outline_atomics.zig @@ -1,7 +1,8 @@ //! This file is generated by tools/gen_outline_atomics.zig. const builtin = @import("builtin"); const std = @import("std"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const always_has_lse = builtin.cpu.has(.aarch64, .lse); /// This default is overridden at runtime after inspecting CPU properties. @@ -2024,104 +2025,104 @@ fn __aarch64_cas16_acq_rel() align(16) callconv(.naked) void { } comptime { - @export(&__aarch64_cas1_relax, .{ .name = "__aarch64_cas1_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp1_relax, .{ .name = "__aarch64_swp1_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd1_relax, .{ .name = "__aarch64_ldadd1_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr1_relax, .{ .name = "__aarch64_ldclr1_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor1_relax, .{ .name = "__aarch64_ldeor1_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset1_relax, .{ .name = "__aarch64_ldset1_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas1_acq, .{ .name = "__aarch64_cas1_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp1_acq, .{ .name = "__aarch64_swp1_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd1_acq, .{ .name = "__aarch64_ldadd1_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr1_acq, .{ .name = "__aarch64_ldclr1_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor1_acq, .{ .name = "__aarch64_ldeor1_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset1_acq, .{ .name = "__aarch64_ldset1_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas1_rel, .{ .name = "__aarch64_cas1_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp1_rel, .{ .name = "__aarch64_swp1_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd1_rel, .{ .name = "__aarch64_ldadd1_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr1_rel, .{ .name = "__aarch64_ldclr1_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor1_rel, .{ .name = "__aarch64_ldeor1_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset1_rel, .{ .name = "__aarch64_ldset1_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas1_acq_rel, .{ .name = "__aarch64_cas1_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp1_acq_rel, .{ .name = "__aarch64_swp1_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd1_acq_rel, .{ .name = "__aarch64_ldadd1_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr1_acq_rel, .{ .name = "__aarch64_ldclr1_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor1_acq_rel, .{ .name = "__aarch64_ldeor1_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset1_acq_rel, .{ .name = "__aarch64_ldset1_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas2_relax, .{ .name = "__aarch64_cas2_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp2_relax, .{ .name = "__aarch64_swp2_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd2_relax, .{ .name = "__aarch64_ldadd2_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr2_relax, .{ .name = "__aarch64_ldclr2_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor2_relax, .{ .name = "__aarch64_ldeor2_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset2_relax, .{ .name = "__aarch64_ldset2_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas2_acq, .{ .name = "__aarch64_cas2_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp2_acq, .{ .name = "__aarch64_swp2_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd2_acq, .{ .name = "__aarch64_ldadd2_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr2_acq, .{ .name = "__aarch64_ldclr2_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor2_acq, .{ .name = "__aarch64_ldeor2_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset2_acq, .{ .name = "__aarch64_ldset2_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas2_rel, .{ .name = "__aarch64_cas2_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp2_rel, .{ .name = "__aarch64_swp2_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd2_rel, .{ .name = "__aarch64_ldadd2_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr2_rel, .{ .name = "__aarch64_ldclr2_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor2_rel, .{ .name = "__aarch64_ldeor2_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset2_rel, .{ .name = "__aarch64_ldset2_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas2_acq_rel, .{ .name = "__aarch64_cas2_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp2_acq_rel, .{ .name = "__aarch64_swp2_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd2_acq_rel, .{ .name = "__aarch64_ldadd2_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr2_acq_rel, .{ .name = "__aarch64_ldclr2_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor2_acq_rel, .{ .name = "__aarch64_ldeor2_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset2_acq_rel, .{ .name = "__aarch64_ldset2_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas4_relax, .{ .name = "__aarch64_cas4_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp4_relax, .{ .name = "__aarch64_swp4_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd4_relax, .{ .name = "__aarch64_ldadd4_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr4_relax, .{ .name = "__aarch64_ldclr4_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor4_relax, .{ .name = "__aarch64_ldeor4_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset4_relax, .{ .name = "__aarch64_ldset4_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas4_acq, .{ .name = "__aarch64_cas4_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp4_acq, .{ .name = "__aarch64_swp4_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd4_acq, .{ .name = "__aarch64_ldadd4_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr4_acq, .{ .name = "__aarch64_ldclr4_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor4_acq, .{ .name = "__aarch64_ldeor4_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset4_acq, .{ .name = "__aarch64_ldset4_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas4_rel, .{ .name = "__aarch64_cas4_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp4_rel, .{ .name = "__aarch64_swp4_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd4_rel, .{ .name = "__aarch64_ldadd4_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr4_rel, .{ .name = "__aarch64_ldclr4_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor4_rel, .{ .name = "__aarch64_ldeor4_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset4_rel, .{ .name = "__aarch64_ldset4_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas4_acq_rel, .{ .name = "__aarch64_cas4_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp4_acq_rel, .{ .name = "__aarch64_swp4_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd4_acq_rel, .{ .name = "__aarch64_ldadd4_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr4_acq_rel, .{ .name = "__aarch64_ldclr4_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor4_acq_rel, .{ .name = "__aarch64_ldeor4_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset4_acq_rel, .{ .name = "__aarch64_ldset4_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas8_relax, .{ .name = "__aarch64_cas8_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp8_relax, .{ .name = "__aarch64_swp8_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd8_relax, .{ .name = "__aarch64_ldadd8_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr8_relax, .{ .name = "__aarch64_ldclr8_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor8_relax, .{ .name = "__aarch64_ldeor8_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset8_relax, .{ .name = "__aarch64_ldset8_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas8_acq, .{ .name = "__aarch64_cas8_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp8_acq, .{ .name = "__aarch64_swp8_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd8_acq, .{ .name = "__aarch64_ldadd8_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr8_acq, .{ .name = "__aarch64_ldclr8_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor8_acq, .{ .name = "__aarch64_ldeor8_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset8_acq, .{ .name = "__aarch64_ldset8_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas8_rel, .{ .name = "__aarch64_cas8_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp8_rel, .{ .name = "__aarch64_swp8_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd8_rel, .{ .name = "__aarch64_ldadd8_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr8_rel, .{ .name = "__aarch64_ldclr8_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor8_rel, .{ .name = "__aarch64_ldeor8_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset8_rel, .{ .name = "__aarch64_ldset8_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas8_acq_rel, .{ .name = "__aarch64_cas8_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_swp8_acq_rel, .{ .name = "__aarch64_swp8_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldadd8_acq_rel, .{ .name = "__aarch64_ldadd8_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldclr8_acq_rel, .{ .name = "__aarch64_ldclr8_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldeor8_acq_rel, .{ .name = "__aarch64_ldeor8_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_ldset8_acq_rel, .{ .name = "__aarch64_ldset8_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas16_relax, .{ .name = "__aarch64_cas16_relax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas16_acq, .{ .name = "__aarch64_cas16_acq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas16_rel, .{ .name = "__aarch64_cas16_rel", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aarch64_cas16_acq_rel, .{ .name = "__aarch64_cas16_acq_rel", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__aarch64_cas1_relax, "__aarch64_cas1_relax"); + symbol(&__aarch64_swp1_relax, "__aarch64_swp1_relax"); + symbol(&__aarch64_ldadd1_relax, "__aarch64_ldadd1_relax"); + symbol(&__aarch64_ldclr1_relax, "__aarch64_ldclr1_relax"); + symbol(&__aarch64_ldeor1_relax, "__aarch64_ldeor1_relax"); + symbol(&__aarch64_ldset1_relax, "__aarch64_ldset1_relax"); + symbol(&__aarch64_cas1_acq, "__aarch64_cas1_acq"); + symbol(&__aarch64_swp1_acq, "__aarch64_swp1_acq"); + symbol(&__aarch64_ldadd1_acq, "__aarch64_ldadd1_acq"); + symbol(&__aarch64_ldclr1_acq, "__aarch64_ldclr1_acq"); + symbol(&__aarch64_ldeor1_acq, "__aarch64_ldeor1_acq"); + symbol(&__aarch64_ldset1_acq, "__aarch64_ldset1_acq"); + symbol(&__aarch64_cas1_rel, "__aarch64_cas1_rel"); + symbol(&__aarch64_swp1_rel, "__aarch64_swp1_rel"); + symbol(&__aarch64_ldadd1_rel, "__aarch64_ldadd1_rel"); + symbol(&__aarch64_ldclr1_rel, "__aarch64_ldclr1_rel"); + symbol(&__aarch64_ldeor1_rel, "__aarch64_ldeor1_rel"); + symbol(&__aarch64_ldset1_rel, "__aarch64_ldset1_rel"); + symbol(&__aarch64_cas1_acq_rel, "__aarch64_cas1_acq_rel"); + symbol(&__aarch64_swp1_acq_rel, "__aarch64_swp1_acq_rel"); + symbol(&__aarch64_ldadd1_acq_rel, "__aarch64_ldadd1_acq_rel"); + symbol(&__aarch64_ldclr1_acq_rel, "__aarch64_ldclr1_acq_rel"); + symbol(&__aarch64_ldeor1_acq_rel, "__aarch64_ldeor1_acq_rel"); + symbol(&__aarch64_ldset1_acq_rel, "__aarch64_ldset1_acq_rel"); + symbol(&__aarch64_cas2_relax, "__aarch64_cas2_relax"); + symbol(&__aarch64_swp2_relax, "__aarch64_swp2_relax"); + symbol(&__aarch64_ldadd2_relax, "__aarch64_ldadd2_relax"); + symbol(&__aarch64_ldclr2_relax, "__aarch64_ldclr2_relax"); + symbol(&__aarch64_ldeor2_relax, "__aarch64_ldeor2_relax"); + symbol(&__aarch64_ldset2_relax, "__aarch64_ldset2_relax"); + symbol(&__aarch64_cas2_acq, "__aarch64_cas2_acq"); + symbol(&__aarch64_swp2_acq, "__aarch64_swp2_acq"); + symbol(&__aarch64_ldadd2_acq, "__aarch64_ldadd2_acq"); + symbol(&__aarch64_ldclr2_acq, "__aarch64_ldclr2_acq"); + symbol(&__aarch64_ldeor2_acq, "__aarch64_ldeor2_acq"); + symbol(&__aarch64_ldset2_acq, "__aarch64_ldset2_acq"); + symbol(&__aarch64_cas2_rel, "__aarch64_cas2_rel"); + symbol(&__aarch64_swp2_rel, "__aarch64_swp2_rel"); + symbol(&__aarch64_ldadd2_rel, "__aarch64_ldadd2_rel"); + symbol(&__aarch64_ldclr2_rel, "__aarch64_ldclr2_rel"); + symbol(&__aarch64_ldeor2_rel, "__aarch64_ldeor2_rel"); + symbol(&__aarch64_ldset2_rel, "__aarch64_ldset2_rel"); + symbol(&__aarch64_cas2_acq_rel, "__aarch64_cas2_acq_rel"); + symbol(&__aarch64_swp2_acq_rel, "__aarch64_swp2_acq_rel"); + symbol(&__aarch64_ldadd2_acq_rel, "__aarch64_ldadd2_acq_rel"); + symbol(&__aarch64_ldclr2_acq_rel, "__aarch64_ldclr2_acq_rel"); + symbol(&__aarch64_ldeor2_acq_rel, "__aarch64_ldeor2_acq_rel"); + symbol(&__aarch64_ldset2_acq_rel, "__aarch64_ldset2_acq_rel"); + symbol(&__aarch64_cas4_relax, "__aarch64_cas4_relax"); + symbol(&__aarch64_swp4_relax, "__aarch64_swp4_relax"); + symbol(&__aarch64_ldadd4_relax, "__aarch64_ldadd4_relax"); + symbol(&__aarch64_ldclr4_relax, "__aarch64_ldclr4_relax"); + symbol(&__aarch64_ldeor4_relax, "__aarch64_ldeor4_relax"); + symbol(&__aarch64_ldset4_relax, "__aarch64_ldset4_relax"); + symbol(&__aarch64_cas4_acq, "__aarch64_cas4_acq"); + symbol(&__aarch64_swp4_acq, "__aarch64_swp4_acq"); + symbol(&__aarch64_ldadd4_acq, "__aarch64_ldadd4_acq"); + symbol(&__aarch64_ldclr4_acq, "__aarch64_ldclr4_acq"); + symbol(&__aarch64_ldeor4_acq, "__aarch64_ldeor4_acq"); + symbol(&__aarch64_ldset4_acq, "__aarch64_ldset4_acq"); + symbol(&__aarch64_cas4_rel, "__aarch64_cas4_rel"); + symbol(&__aarch64_swp4_rel, "__aarch64_swp4_rel"); + symbol(&__aarch64_ldadd4_rel, "__aarch64_ldadd4_rel"); + symbol(&__aarch64_ldclr4_rel, "__aarch64_ldclr4_rel"); + symbol(&__aarch64_ldeor4_rel, "__aarch64_ldeor4_rel"); + symbol(&__aarch64_ldset4_rel, "__aarch64_ldset4_rel"); + symbol(&__aarch64_cas4_acq_rel, "__aarch64_cas4_acq_rel"); + symbol(&__aarch64_swp4_acq_rel, "__aarch64_swp4_acq_rel"); + symbol(&__aarch64_ldadd4_acq_rel, "__aarch64_ldadd4_acq_rel"); + symbol(&__aarch64_ldclr4_acq_rel, "__aarch64_ldclr4_acq_rel"); + symbol(&__aarch64_ldeor4_acq_rel, "__aarch64_ldeor4_acq_rel"); + symbol(&__aarch64_ldset4_acq_rel, "__aarch64_ldset4_acq_rel"); + symbol(&__aarch64_cas8_relax, "__aarch64_cas8_relax"); + symbol(&__aarch64_swp8_relax, "__aarch64_swp8_relax"); + symbol(&__aarch64_ldadd8_relax, "__aarch64_ldadd8_relax"); + symbol(&__aarch64_ldclr8_relax, "__aarch64_ldclr8_relax"); + symbol(&__aarch64_ldeor8_relax, "__aarch64_ldeor8_relax"); + symbol(&__aarch64_ldset8_relax, "__aarch64_ldset8_relax"); + symbol(&__aarch64_cas8_acq, "__aarch64_cas8_acq"); + symbol(&__aarch64_swp8_acq, "__aarch64_swp8_acq"); + symbol(&__aarch64_ldadd8_acq, "__aarch64_ldadd8_acq"); + symbol(&__aarch64_ldclr8_acq, "__aarch64_ldclr8_acq"); + symbol(&__aarch64_ldeor8_acq, "__aarch64_ldeor8_acq"); + symbol(&__aarch64_ldset8_acq, "__aarch64_ldset8_acq"); + symbol(&__aarch64_cas8_rel, "__aarch64_cas8_rel"); + symbol(&__aarch64_swp8_rel, "__aarch64_swp8_rel"); + symbol(&__aarch64_ldadd8_rel, "__aarch64_ldadd8_rel"); + symbol(&__aarch64_ldclr8_rel, "__aarch64_ldclr8_rel"); + symbol(&__aarch64_ldeor8_rel, "__aarch64_ldeor8_rel"); + symbol(&__aarch64_ldset8_rel, "__aarch64_ldset8_rel"); + symbol(&__aarch64_cas8_acq_rel, "__aarch64_cas8_acq_rel"); + symbol(&__aarch64_swp8_acq_rel, "__aarch64_swp8_acq_rel"); + symbol(&__aarch64_ldadd8_acq_rel, "__aarch64_ldadd8_acq_rel"); + symbol(&__aarch64_ldclr8_acq_rel, "__aarch64_ldclr8_acq_rel"); + symbol(&__aarch64_ldeor8_acq_rel, "__aarch64_ldeor8_acq_rel"); + symbol(&__aarch64_ldset8_acq_rel, "__aarch64_ldset8_acq_rel"); + symbol(&__aarch64_cas16_relax, "__aarch64_cas16_relax"); + symbol(&__aarch64_cas16_acq, "__aarch64_cas16_acq"); + symbol(&__aarch64_cas16_rel, "__aarch64_cas16_rel"); + symbol(&__aarch64_cas16_acq_rel, "__aarch64_cas16_acq_rel"); } diff --git a/lib/compiler_rt/absvsi2.zig b/lib/compiler_rt/absvsi2.zig index fb527cd997..538d7f7f01 100644 --- a/lib/compiler_rt/absvsi2.zig +++ b/lib/compiler_rt/absvsi2.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const absv = @import("./absv.zig").absv; comptime { - @export(&__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__absvsi2, "__absvsi2"); } pub fn __absvsi2(a: i32) callconv(.c) i32 { diff --git a/lib/compiler_rt/adddf3.zig b/lib/compiler_rt/adddf3.zig index 7a49b0d782..7b6f252da2 100644 --- a/lib/compiler_rt/adddf3.zig +++ b/lib/compiler_rt/adddf3.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const addf3 = @import("./addf3.zig").addf3; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_dadd, "__aeabi_dadd"); } else { symbol(&__adddf3, "__adddf3"); diff --git a/lib/compiler_rt/addf3.zig b/lib/compiler_rt/addf3.zig index 60ae0165a8..91152735f4 100644 --- a/lib/compiler_rt/addf3.zig +++ b/lib/compiler_rt/addf3.zig @@ -1,7 +1,7 @@ const std = @import("std"); const math = std.math; -const common = @import("./common.zig"); -const normalize = common.normalize; +const compiler_rt = @import("../compiler_rt.zig"); +const normalize = compiler_rt.normalize; /// Ported from: /// diff --git a/lib/compiler_rt/addhf3.zig b/lib/compiler_rt/addhf3.zig index 842c88f5d4..bd13f48cac 100644 --- a/lib/compiler_rt/addhf3.zig +++ b/lib/compiler_rt/addhf3.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const addf3 = @import("./addf3.zig").addf3; comptime { - @export(&__addhf3, .{ .name = "__addhf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__addhf3, "__addhf3"); } fn __addhf3(a: f16, b: f16) callconv(.c) f16 { diff --git a/lib/compiler_rt/addsf3.zig b/lib/compiler_rt/addsf3.zig index fb65bec624..4878fb704d 100644 --- a/lib/compiler_rt/addsf3.zig +++ b/lib/compiler_rt/addsf3.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const addf3 = @import("./addf3.zig").addf3; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_fadd, "__aeabi_fadd"); } else { symbol(&__addsf3, "__addsf3"); diff --git a/lib/compiler_rt/addtf3.zig b/lib/compiler_rt/addtf3.zig index d4011f9238..50e699415a 100644 --- a/lib/compiler_rt/addtf3.zig +++ b/lib/compiler_rt/addtf3.zig @@ -1,13 +1,14 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const addf3 = @import("./addf3.zig").addf3; comptime { - if (common.want_ppc_abi) { - @export(&__addtf3, .{ .name = "__addkf3", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__addtf3, "__addkf3"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_add, "_Qp_add"); } - @export(&__addtf3, .{ .name = "__addtf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__addtf3, "__addtf3"); } pub fn __addtf3(a: f128, b: f128) callconv(.c) f128 { diff --git a/lib/compiler_rt/addvsi3.zig b/lib/compiler_rt/addvsi3.zig index 468047eda1..c35b22e8df 100644 --- a/lib/compiler_rt/addvsi3.zig +++ b/lib/compiler_rt/addvsi3.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const testing = @import("std").testing; comptime { - @export(&__addvsi3, .{ .name = "__addvsi3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__addvsi3, "__addvsi3"); } pub fn __addvsi3(a: i32, b: i32) callconv(.c) i32 { diff --git a/lib/compiler_rt/addxf3.zig b/lib/compiler_rt/addxf3.zig index e1509f04f5..f57708c985 100644 --- a/lib/compiler_rt/addxf3.zig +++ b/lib/compiler_rt/addxf3.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const addf3 = @import("./addf3.zig").addf3; comptime { - @export(&__addxf3, .{ .name = "__addxf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__addxf3, "__addxf3"); } pub fn __addxf3(a: f80, b: f80) callconv(.c) f80 { diff --git a/lib/compiler_rt/arm.zig b/lib/compiler_rt/arm.zig index aa31e855dc..eecb0e5d03 100644 --- a/lib/compiler_rt/arm.zig +++ b/lib/compiler_rt/arm.zig @@ -4,49 +4,50 @@ const std = @import("std"); const builtin = @import("builtin"); const target = builtin.target; const arch = builtin.cpu.arch; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { if (!builtin.is_test) { if (arch.isArm()) { - @export(&__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__aeabi_unwind_cpp_pr0, "__aeabi_unwind_cpp_pr0"); + symbol(&__aeabi_unwind_cpp_pr1, "__aeabi_unwind_cpp_pr1"); + symbol(&__aeabi_unwind_cpp_pr2, "__aeabi_unwind_cpp_pr2"); - if (common.want_windows_arm_abi) { - @export(&__aeabi_ldivmod, .{ .name = "__rt_sdiv64", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_uldivmod, .{ .name = "__rt_udiv64", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_idivmod, .{ .name = "__rt_sdiv", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_uidivmod, .{ .name = "__rt_udiv", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_arm_abi) { + symbol(&__aeabi_ldivmod, "__rt_sdiv64"); + symbol(&__aeabi_uldivmod, "__rt_udiv64"); + symbol(&__aeabi_idivmod, "__rt_sdiv"); + symbol(&__aeabi_uidivmod, "__rt_udiv"); } - @export(&__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__aeabi_ldivmod, "__aeabi_ldivmod"); + symbol(&__aeabi_uldivmod, "__aeabi_uldivmod"); + symbol(&__aeabi_idivmod, "__aeabi_idivmod"); + symbol(&__aeabi_uidivmod, "__aeabi_uidivmod"); - @export(&__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__aeabi_memcpy, "__aeabi_memcpy"); + symbol(&__aeabi_memcpy4, "__aeabi_memcpy4"); + symbol(&__aeabi_memcpy8, "__aeabi_memcpy8"); - @export(&__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__aeabi_memmove, "__aeabi_memmove"); + symbol(&__aeabi_memmove4, "__aeabi_memmove4"); + symbol(&__aeabi_memmove8, "__aeabi_memmove8"); - @export(&__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__aeabi_memset, "__aeabi_memset"); + symbol(&__aeabi_memset4, "__aeabi_memset4"); + symbol(&__aeabi_memset8, "__aeabi_memset8"); - @export(&__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__aeabi_memclr, "__aeabi_memclr"); + symbol(&__aeabi_memclr4, "__aeabi_memclr4"); + symbol(&__aeabi_memclr8, "__aeabi_memclr8"); if (builtin.os.tag == .linux or builtin.os.tag == .freebsd) { - @export(&__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__aeabi_read_tp, "__aeabi_read_tp"); } // floating-point helper functions (single+double-precision reverse subtraction, y – x), see subdf3.zig - @export(&__aeabi_frsub, .{ .name = "__aeabi_frsub", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_drsub, .{ .name = "__aeabi_drsub", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__aeabi_frsub, "__aeabi_frsub"); + symbol(&__aeabi_drsub, "__aeabi_drsub"); } } } diff --git a/lib/compiler_rt/atomics.zig b/lib/compiler_rt/atomics.zig index 31c87f4b1b..d6eaf4d671 100644 --- a/lib/compiler_rt/atomics.zig +++ b/lib/compiler_rt/atomics.zig @@ -4,7 +4,7 @@ const arch = cpu.arch; const std = @import("std"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; // This parameter is true iff the target architecture supports the bare minimum diff --git a/lib/compiler_rt/aulldiv.zig b/lib/compiler_rt/aulldiv.zig index fb0d6126a8..4ed92f39ee 100644 --- a/lib/compiler_rt/aulldiv.zig +++ b/lib/compiler_rt/aulldiv.zig @@ -1,10 +1,10 @@ const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_windows_x86_msvc_abi) { + if (compiler_rt.want_windows_x86_msvc_abi) { // Don't let LLVM apply the stdcall name mangling on those MSVC builtins symbol(&_alldiv, "\x01__alldiv"); symbol(&_aulldiv, "\x01__aulldiv"); diff --git a/lib/compiler_rt/aullrem.zig b/lib/compiler_rt/aullrem.zig index ea12c16a06..efb8f15b73 100644 --- a/lib/compiler_rt/aullrem.zig +++ b/lib/compiler_rt/aullrem.zig @@ -3,13 +3,14 @@ const builtin = @import("builtin"); const arch = builtin.cpu.arch; const os = builtin.os.tag; const abi = builtin.abi; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - if (common.want_windows_x86_msvc_abi) { + if (compiler_rt.want_windows_x86_msvc_abi) { // Don't let LLVM apply the stdcall name mangling on those MSVC builtins - @export(&_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility }); - @export(&_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&_allrem, "\x01__allrem"); + symbol(&_aullrem, "\x01__aullrem"); } } diff --git a/lib/compiler_rt/bcmp.zig b/lib/compiler_rt/bcmp.zig deleted file mode 100644 index eb1fca21f0..0000000000 --- a/lib/compiler_rt/bcmp.zig +++ /dev/null @@ -1,30 +0,0 @@ -const std = @import("std"); -const common = @import("./common.zig"); - -comptime { - @export(&bcmp, .{ .name = "bcmp", .linkage = common.linkage, .visibility = common.visibility }); -} - -pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.c) c_int { - @setRuntimeSafety(false); - - var index: usize = 0; - while (index != n) : (index += 1) { - if (vl[index] != vr[index]) { - return 1; - } - } - - return 0; -} - -test "bcmp" { - const base_arr = &[_]u8{ 1, 1, 1 }; - const arr1 = &[_]u8{ 1, 1, 1 }; - const arr2 = &[_]u8{ 1, 0, 1 }; - const arr3 = &[_]u8{ 1, 2, 1 }; - - try std.testing.expect(bcmp(base_arr[0..], arr1[0..], base_arr.len) == 0); - try std.testing.expect(bcmp(base_arr[0..], arr2[0..], base_arr.len) != 0); - try std.testing.expect(bcmp(base_arr[0..], arr3[0..], base_arr.len) != 0); -} diff --git a/lib/compiler_rt/bitreverse.zig b/lib/compiler_rt/bitreverse.zig index 6dbeac77d9..dda620152d 100644 --- a/lib/compiler_rt/bitreverse.zig +++ b/lib/compiler_rt/bitreverse.zig @@ -1,11 +1,12 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__bitreversesi2, .{ .name = "__bitreversesi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__bitreversedi2, .{ .name = "__bitreversedi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__bitreverseti2, .{ .name = "__bitreverseti2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__bitreversesi2, "__bitreversesi2"); + symbol(&__bitreversedi2, "__bitreversedi2"); + symbol(&__bitreverseti2, "__bitreverseti2"); } inline fn bitreverseXi2(comptime T: type, a: T) T { diff --git a/lib/compiler_rt/bswap.zig b/lib/compiler_rt/bswap.zig index e6f634c66f..94c3294eaf 100644 --- a/lib/compiler_rt/bswap.zig +++ b/lib/compiler_rt/bswap.zig @@ -1,11 +1,12 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__bswapsi2, "__bswapsi2"); + symbol(&__bswapdi2, "__bswapdi2"); + symbol(&__bswapti2, "__bswapti2"); } // bswap - byteswap diff --git a/lib/compiler_rt/clear_cache.zig b/lib/compiler_rt/clear_cache.zig index 0e3b5d371f..2a8226c130 100644 --- a/lib/compiler_rt/clear_cache.zig +++ b/lib/compiler_rt/clear_cache.zig @@ -2,7 +2,8 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; const os = builtin.os.tag; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; // Ported from llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28 @@ -188,7 +189,7 @@ fn clear_cache(start: usize, end: usize) callconv(.c) void { } fn exportIt() void { - @export(&clear_cache, .{ .name = "__clear_cache", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&clear_cache, "__clear_cache"); } // MIPS-only diff --git a/lib/compiler_rt/cmp.zig b/lib/compiler_rt/cmp.zig index cac23a7508..9b123f5007 100644 --- a/lib/compiler_rt/cmp.zig +++ b/lib/compiler_rt/cmp.zig @@ -1,14 +1,15 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__cmpsi2, "__cmpsi2"); + symbol(&__cmpdi2, "__cmpdi2"); + symbol(&__cmpti2, "__cmpti2"); + symbol(&__ucmpsi2, "__ucmpsi2"); + symbol(&__ucmpdi2, "__ucmpdi2"); + symbol(&__ucmpti2, "__ucmpti2"); } // cmp - signed compare diff --git a/lib/compiler_rt/cmpdf2.zig b/lib/compiler_rt/cmpdf2.zig index 691827ac4b..7a9295bcdb 100644 --- a/lib/compiler_rt/cmpdf2.zig +++ b/lib/compiler_rt/cmpdf2.zig @@ -1,11 +1,11 @@ ///! The quoted behavior definitions are from ///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const comparef = @import("./comparef.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_dcmpeq, "__aeabi_dcmpeq"); symbol(&__aeabi_dcmplt, "__aeabi_dcmplt"); symbol(&__aeabi_dcmple, "__aeabi_dcmple"); diff --git a/lib/compiler_rt/cmphf2.zig b/lib/compiler_rt/cmphf2.zig deleted file mode 100644 index ea70e71e16..0000000000 --- a/lib/compiler_rt/cmphf2.zig +++ /dev/null @@ -1,48 +0,0 @@ -///! The quoted behavior definitions are from -///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines -const common = @import("./common.zig"); -const comparef = @import("./comparef.zig"); - -comptime { - @export(&__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__nehf2, .{ .name = "__nehf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__lehf2, .{ .name = "__lehf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__lthf2, .{ .name = "__lthf2", .linkage = common.linkage, .visibility = common.visibility }); -} - -/// "These functions calculate a <=> b. That is, if a is less than b, they return -1; -/// if a is greater than b, they return 1; and if a and b are equal they return 0. -/// If either argument is NaN they return 1..." -/// -/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`, -/// and `__lthf2`. -fn __cmphf2(a: f16, b: f16) callconv(.c) i32 { - return @intFromEnum(comparef.cmpf2(f16, comparef.LE, a, b)); -} - -/// "These functions return a value less than or equal to zero if neither argument is NaN, -/// and a is less than or equal to b." -pub fn __lehf2(a: f16, b: f16) callconv(.c) i32 { - return __cmphf2(a, b); -} - -/// "These functions return zero if neither argument is NaN, and a and b are equal." -/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined -/// to have the same return value. -pub fn __eqhf2(a: f16, b: f16) callconv(.c) i32 { - return __cmphf2(a, b); -} - -/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal." -/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined -/// to have the same return value. -pub fn __nehf2(a: f16, b: f16) callconv(.c) i32 { - return __cmphf2(a, b); -} - -/// "These functions return a value less than zero if neither argument is NaN, and a -/// is strictly less than b." -pub fn __lthf2(a: f16, b: f16) callconv(.c) i32 { - return __cmphf2(a, b); -} diff --git a/lib/compiler_rt/cmpsf2.zig b/lib/compiler_rt/cmpsf2.zig deleted file mode 100644 index 4b200198e6..0000000000 --- a/lib/compiler_rt/cmpsf2.zig +++ /dev/null @@ -1,66 +0,0 @@ -///! The quoted behavior definitions are from -///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines -const common = @import("./common.zig"); -const comparef = @import("./comparef.zig"); - -comptime { - if (common.want_aeabi) { - @export(&__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__nesf2, .{ .name = "__nesf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__lesf2, .{ .name = "__lesf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -/// "These functions calculate a <=> b. That is, if a is less than b, they return -1; -/// if a is greater than b, they return 1; and if a and b are equal they return 0. -/// If either argument is NaN they return 1..." -/// -/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`, -/// and `__ltsf2`. -fn __cmpsf2(a: f32, b: f32) callconv(.c) i32 { - return @intFromEnum(comparef.cmpf2(f32, comparef.LE, a, b)); -} - -/// "These functions return a value less than or equal to zero if neither argument is NaN, -/// and a is less than or equal to b." -pub fn __lesf2(a: f32, b: f32) callconv(.c) i32 { - return __cmpsf2(a, b); -} - -/// "These functions return zero if neither argument is NaN, and a and b are equal." -/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined -/// to have the same return value. -pub fn __eqsf2(a: f32, b: f32) callconv(.c) i32 { - return __cmpsf2(a, b); -} - -/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal." -/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined -/// to have the same return value. -pub fn __nesf2(a: f32, b: f32) callconv(.c) i32 { - return __cmpsf2(a, b); -} - -/// "These functions return a value less than zero if neither argument is NaN, and a -/// is strictly less than b." -pub fn __ltsf2(a: f32, b: f32) callconv(.c) i32 { - return __cmpsf2(a, b); -} - -fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 { - return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal); -} - -fn __aeabi_fcmplt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 { - return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) == .Less); -} - -fn __aeabi_fcmple(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 { - return @intFromBool(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater); -} diff --git a/lib/compiler_rt/cmptf2.zig b/lib/compiler_rt/cmptf2.zig index 846e62935c..bdffc97f86 100644 --- a/lib/compiler_rt/cmptf2.zig +++ b/lib/compiler_rt/cmptf2.zig @@ -1,16 +1,16 @@ ///! The quoted behavior definitions are from ///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const comparef = @import("./comparef.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&__eqtf2, "__eqkf2"); symbol(&__netf2, "__nekf2"); symbol(&__lttf2, "__ltkf2"); symbol(&__letf2, "__lekf2"); - } else if (common.want_sparc_abi) { + } else if (compiler_rt.want_sparc_abi) { symbol(&_Qp_cmp, "_Qp_cmp"); symbol(&_Qp_feq, "_Qp_feq"); symbol(&_Qp_fne, "_Qp_fne"); diff --git a/lib/compiler_rt/cmpxf2.zig b/lib/compiler_rt/cmpxf2.zig index f70de9c0b6..c6e2e375a1 100644 --- a/lib/compiler_rt/cmpxf2.zig +++ b/lib/compiler_rt/cmpxf2.zig @@ -1,14 +1,15 @@ ///! The quoted behavior definitions are from ///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const comparef = @import("./comparef.zig"); comptime { - @export(&__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__nexf2, .{ .name = "__nexf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__lexf2, .{ .name = "__lexf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__eqxf2, "__eqxf2"); + symbol(&__nexf2, "__nexf2"); + symbol(&__lexf2, "__lexf2"); + symbol(&__cmpxf2, "__cmpxf2"); + symbol(&__ltxf2, "__ltxf2"); } /// "These functions calculate a <=> b. That is, if a is less than b, they return -1; diff --git a/lib/compiler_rt/common.zig b/lib/compiler_rt/common.zig deleted file mode 100644 index 0839d78b1b..0000000000 --- a/lib/compiler_rt/common.zig +++ /dev/null @@ -1,296 +0,0 @@ -const std = @import("std"); -const builtin = @import("builtin"); -const native_endian = builtin.cpu.arch.endian(); -const ofmt_c = builtin.object_format == .c; - -/// Deprecated, everything in common should move to compiler_rt.zig -pub const linkage = @import("../compiler_rt.zig").linkage; - -/// Deprecated, everything in common should move to compiler_rt.zig -pub const visibility = @import("../compiler_rt.zig").visibility; - -pub const PreferredLoadStoreElement = element: { - if (std.simd.suggestVectorLength(u8)) |vec_size| { - const Vec = @Vector(vec_size, u8); - - if (@sizeOf(Vec) == vec_size and std.math.isPowerOfTwo(vec_size)) { - break :element Vec; - } - } - break :element usize; -}; - -pub const want_aeabi = switch (builtin.abi) { - .eabi, - .eabihf, - .musleabi, - .musleabihf, - .gnueabi, - .gnueabihf, - .android, - .androideabi, - => switch (builtin.cpu.arch) { - .arm, .armeb, .thumb, .thumbeb => true, - else => false, - }, - else => false, -}; - -/// These functions are required on Windows on ARM. They are provided by MSVC libc, but in libc-less -/// builds or when linking MinGW libc they are our responsibility. -/// Temporarily used for thumb-uefi until https://github.com/ziglang/zig/issues/21630 is addressed. -pub const want_windows_arm_abi = e: { - if (!builtin.cpu.arch.isArm()) break :e false; - switch (builtin.os.tag) { - .windows, .uefi => {}, - else => break :e false, - } - // The ABI is needed, but it's only our reponsibility if libc won't provide it. - break :e builtin.abi.isGnu() or !builtin.link_libc; -}; - -/// These functions are required by on Windows on x86 on some ABIs. They are provided by MSVC libc, -/// but in libc-less builds they are our responsibility. -pub const want_windows_x86_msvc_abi = e: { - if (builtin.cpu.arch != .x86) break :e false; - if (builtin.os.tag != .windows) break :e false; - switch (builtin.abi) { - .none, .msvc, .itanium => {}, - else => break :e false, - } - // The ABI is needed, but it's only our responsibility if libc won't provide it. - break :e !builtin.link_libc; -}; - -pub const want_ppc_abi = builtin.cpu.arch.isPowerPC(); - -pub const want_float_exceptions = !builtin.cpu.arch.isWasm(); - -// Libcalls that involve u128 on Windows x86-64 are expected by LLVM to use the -// calling convention of @Vector(2, u64), rather than what's standard. -pub const want_windows_v2u64_abi = builtin.os.tag == .windows and builtin.cpu.arch == .x86_64 and !ofmt_c; - -/// This governs whether to use these symbol names for f16/f32 conversions -/// rather than the standard names: -/// * __gnu_f2h_ieee -/// * __gnu_h2f_ieee -/// Known correct configurations: -/// x86_64-freestanding-none => true -/// x86_64-linux-none => true -/// x86_64-linux-gnu => true -/// x86_64-linux-musl => true -/// x86_64-linux-eabi => true -/// arm-linux-musleabihf => true -/// arm-linux-gnueabihf => true -/// arm-linux-eabihf => false -/// wasm32-wasi-musl => false -/// wasm32-freestanding-none => false -/// x86_64-windows-gnu => true -/// x86_64-windows-msvc => true -/// any-macos-any => false -pub const gnu_f16_abi = switch (builtin.cpu.arch) { - .wasm32, - .wasm64, - .riscv64, - .riscv64be, - .riscv32, - .riscv32be, - => false, - - .x86, .x86_64 => true, - - .arm, .armeb, .thumb, .thumbeb => switch (builtin.abi) { - .eabi, .eabihf => false, - else => true, - }, - - else => !builtin.os.tag.isDarwin(), -}; - -pub const want_sparc_abi = builtin.cpu.arch.isSPARC(); - -/// Deprecated, everything in common should move to compiler_rt.zig -pub const test_safety = @import("../compiler_rt.zig").test_safety; - -/// This seems to mostly correspond to `clang::TargetInfo::HasFloat16`. -pub fn F16T(comptime OtherType: type) type { - return switch (builtin.cpu.arch) { - .amdgcn, - .arm, - .armeb, - .thumb, - .thumbeb, - .aarch64, - .aarch64_be, - .hexagon, - .loongarch32, - .loongarch64, - .nvptx, - .nvptx64, - .riscv32, - .riscv32be, - .riscv64, - .riscv64be, - .s390x, - .spirv32, - .spirv64, - => f16, - .x86, .x86_64 => if (builtin.target.os.tag.isDarwin()) switch (OtherType) { - // Starting with LLVM 16, Darwin uses different abi for f16 - // depending on the type of the other return/argument..??? - f32, f64 => u16, - f80, f128 => f16, - else => unreachable, - } else f16, - else => u16, - }; -} - -pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { - switch (Z) { - u16 => { - // 16x16 --> 32 bit multiply - const product = @as(u32, a) * @as(u32, b); - hi.* = @intCast(product >> 16); - lo.* = @truncate(product); - }, - u32 => { - // 32x32 --> 64 bit multiply - const product = @as(u64, a) * @as(u64, b); - hi.* = @truncate(product >> 32); - lo.* = @truncate(product); - }, - u64 => { - const S = struct { - fn loWord(x: u64) u64 { - return @as(u32, @truncate(x)); - } - fn hiWord(x: u64) u64 { - return @as(u32, @truncate(x >> 32)); - } - }; - // 64x64 -> 128 wide multiply for platforms that don't have such an operation; - // many 64-bit platforms have this operation, but they tend to have hardware - // floating-point, so we don't bother with a special case for them here. - // Each of the component 32x32 -> 64 products - const plolo: u64 = S.loWord(a) * S.loWord(b); - const plohi: u64 = S.loWord(a) * S.hiWord(b); - const philo: u64 = S.hiWord(a) * S.loWord(b); - const phihi: u64 = S.hiWord(a) * S.hiWord(b); - // Sum terms that contribute to lo in a way that allows us to get the carry - const r0: u64 = S.loWord(plolo); - const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo); - lo.* = r0 +% (r1 << 32); - // Sum terms contributing to hi with the carry from lo - hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi; - }, - u128 => { - const Word_LoMask: u64 = 0x00000000ffffffff; - const Word_HiMask: u64 = 0xffffffff00000000; - const Word_FullMask: u64 = 0xffffffffffffffff; - const S = struct { - fn Word_1(x: u128) u64 { - return @as(u32, @truncate(x >> 96)); - } - fn Word_2(x: u128) u64 { - return @as(u32, @truncate(x >> 64)); - } - fn Word_3(x: u128) u64 { - return @as(u32, @truncate(x >> 32)); - } - fn Word_4(x: u128) u64 { - return @as(u32, @truncate(x)); - } - }; - // 128x128 -> 256 wide multiply for platforms that don't have such an operation; - // many 64-bit platforms have this operation, but they tend to have hardware - // floating-point, so we don't bother with a special case for them here. - - const product11: u64 = S.Word_1(a) * S.Word_1(b); - const product12: u64 = S.Word_1(a) * S.Word_2(b); - const product13: u64 = S.Word_1(a) * S.Word_3(b); - const product14: u64 = S.Word_1(a) * S.Word_4(b); - const product21: u64 = S.Word_2(a) * S.Word_1(b); - const product22: u64 = S.Word_2(a) * S.Word_2(b); - const product23: u64 = S.Word_2(a) * S.Word_3(b); - const product24: u64 = S.Word_2(a) * S.Word_4(b); - const product31: u64 = S.Word_3(a) * S.Word_1(b); - const product32: u64 = S.Word_3(a) * S.Word_2(b); - const product33: u64 = S.Word_3(a) * S.Word_3(b); - const product34: u64 = S.Word_3(a) * S.Word_4(b); - const product41: u64 = S.Word_4(a) * S.Word_1(b); - const product42: u64 = S.Word_4(a) * S.Word_2(b); - const product43: u64 = S.Word_4(a) * S.Word_3(b); - const product44: u64 = S.Word_4(a) * S.Word_4(b); - - const sum0: u128 = @as(u128, product44); - const sum1: u128 = @as(u128, product34) +% - @as(u128, product43); - const sum2: u128 = @as(u128, product24) +% - @as(u128, product33) +% - @as(u128, product42); - const sum3: u128 = @as(u128, product14) +% - @as(u128, product23) +% - @as(u128, product32) +% - @as(u128, product41); - const sum4: u128 = @as(u128, product13) +% - @as(u128, product22) +% - @as(u128, product31); - const sum5: u128 = @as(u128, product12) +% - @as(u128, product21); - const sum6: u128 = @as(u128, product11); - - const r0: u128 = (sum0 & Word_FullMask) +% - ((sum1 & Word_LoMask) << 32); - const r1: u128 = (sum0 >> 64) +% - ((sum1 >> 32) & Word_FullMask) +% - (sum2 & Word_FullMask) +% - ((sum3 << 32) & Word_HiMask); - - lo.* = r0 +% (r1 << 64); - hi.* = (r1 >> 64) +% - (sum1 >> 96) +% - (sum2 >> 64) +% - (sum3 >> 32) +% - sum4 +% - (sum5 << 32) +% - (sum6 << 64); - }, - else => @compileError("unsupported"), - } -} - -pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).float.bits)) i32 { - const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits); - const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T); - - const shift = @clz(significand.*) - @clz(integerBit); - significand.* <<= @as(std.math.Log2Int(Z), @intCast(shift)); - return @as(i32, 1) - shift; -} - -pub inline fn fneg(a: anytype) @TypeOf(a) { - const F = @TypeOf(a); - const bits = @typeInfo(F).float.bits; - const U = @Int(.unsigned, bits); - const sign_bit_mask = @as(U, 1) << (bits - 1); - const negated = @as(U, @bitCast(a)) ^ sign_bit_mask; - return @bitCast(negated); -} - -/// Allows to access underlying bits as two equally sized lower and higher -/// signed or unsigned integers. -pub fn HalveInt(comptime T: type, comptime signed_half: bool) type { - return extern union { - pub const bits = @divExact(@typeInfo(T).int.bits, 2); - pub const HalfTU = std.meta.Int(.unsigned, bits); - pub const HalfTS = std.meta.Int(.signed, bits); - pub const HalfT = if (signed_half) HalfTS else HalfTU; - - all: T, - s: if (native_endian == .little) - extern struct { low: HalfT, high: HalfT } - else - extern struct { high: HalfT, low: HalfT }, - }; -} diff --git a/lib/compiler_rt/comparef.zig b/lib/compiler_rt/comparef.zig index 76f04f430a..3e97477589 100644 --- a/lib/compiler_rt/comparef.zig +++ b/lib/compiler_rt/comparef.zig @@ -1,5 +1,149 @@ const std = @import("std"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; + +comptime { + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_fcmpun, "__aeabi_fcmpun"); + } else { + symbol(&__unordsf2, "__unordsf2"); + } + + symbol(&__unordxf2, "__unordxf2"); + + symbol(&__eqhf2, "__eqhf2"); + symbol(&__nehf2, "__nehf2"); + symbol(&__lehf2, "__lehf2"); + symbol(&__cmphf2, "__cmphf2"); + symbol(&__lthf2, "__lthf2"); + + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_fcmpeq, "__aeabi_fcmpeq"); + symbol(&__aeabi_fcmplt, "__aeabi_fcmplt"); + symbol(&__aeabi_fcmple, "__aeabi_fcmple"); + } else { + symbol(&__eqsf2, "__eqsf2"); + symbol(&__nesf2, "__nesf2"); + symbol(&__lesf2, "__lesf2"); + symbol(&__cmpsf2, "__cmpsf2"); + symbol(&__ltsf2, "__ltsf2"); + } + + if (compiler_rt.want_ppc_abi) { + symbol(&__unordtf2, "__unordkf2"); + } else if (compiler_rt.want_sparc_abi) { + // These exports are handled in cmptf2.zig because unordered comparisons + // are based on calling _Qp_cmp. + } + symbol(&__unordtf2, "__unordtf2"); + symbol(&__unordhf2, "__unordhf2"); +} + +pub fn __unordhf2(a: f16, b: f16) callconv(.c) i32 { + return unordcmp(f16, a, b); +} + +pub fn __unordtf2(a: f128, b: f128) callconv(.c) i32 { + return unordcmp(f128, a, b); +} + +/// "These functions calculate a <=> b. That is, if a is less than b, they return -1; +/// if a is greater than b, they return 1; and if a and b are equal they return 0. +/// If either argument is NaN they return 1..." +/// +/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`, +/// and `__ltsf2`. +fn __cmpsf2(a: f32, b: f32) callconv(.c) i32 { + return @intFromEnum(cmpf2(f32, LE, a, b)); +} + +/// "These functions return a value less than or equal to zero if neither argument is NaN, +/// and a is less than or equal to b." +pub fn __lesf2(a: f32, b: f32) callconv(.c) i32 { + return __cmpsf2(a, b); +} + +/// "These functions return zero if neither argument is NaN, and a and b are equal." +/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined +/// to have the same return value. +pub fn __eqsf2(a: f32, b: f32) callconv(.c) i32 { + return __cmpsf2(a, b); +} + +/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal." +/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined +/// to have the same return value. +pub fn __nesf2(a: f32, b: f32) callconv(.c) i32 { + return __cmpsf2(a, b); +} + +/// "These functions return a value less than zero if neither argument is NaN, and a +/// is strictly less than b." +pub fn __ltsf2(a: f32, b: f32) callconv(.c) i32 { + return __cmpsf2(a, b); +} + +fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 { + return @intFromBool(cmpf2(f32, LE, a, b) == .Equal); +} + +fn __aeabi_fcmplt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 { + return @intFromBool(cmpf2(f32, LE, a, b) == .Less); +} + +fn __aeabi_fcmple(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 { + return @intFromBool(cmpf2(f32, LE, a, b) != .Greater); +} + +/// "These functions calculate a <=> b. That is, if a is less than b, they return -1; +/// if a is greater than b, they return 1; and if a and b are equal they return 0. +/// If either argument is NaN they return 1..." +/// +/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`, +/// and `__lthf2`. +fn __cmphf2(a: f16, b: f16) callconv(.c) i32 { + return @intFromEnum(cmpf2(f16, LE, a, b)); +} + +/// "These functions return a value less than or equal to zero if neither argument is NaN, +/// and a is less than or equal to b." +fn __lehf2(a: f16, b: f16) callconv(.c) i32 { + return __cmphf2(a, b); +} + +/// "These functions return zero if neither argument is NaN, and a and b are equal." +/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined +/// to have the same return value. +fn __eqhf2(a: f16, b: f16) callconv(.c) i32 { + return __cmphf2(a, b); +} + +/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal." +/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined +/// to have the same return value. +fn __nehf2(a: f16, b: f16) callconv(.c) i32 { + return __cmphf2(a, b); +} + +/// "These functions return a value less than zero if neither argument is NaN, and a +/// is strictly less than b." +fn __lthf2(a: f16, b: f16) callconv(.c) i32 { + return __cmphf2(a, b); +} + +fn __unordxf2(a: f80, b: f80) callconv(.c) i32 { + return unordcmp(f80, a, b); +} + +pub fn __unordsf2(a: f32, b: f32) callconv(.c) i32 { + return unordcmp(f32, a, b); +} + +fn __aeabi_fcmpun(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 { + return unordcmp(f32, a, b); +} + pub const LE = enum(i32) { Less = -1, Equal = 0, diff --git a/lib/compiler_rt/comparesf2_test.zig b/lib/compiler_rt/comparesf2_test.zig index 65e78da99e..d42e1ca6db 100644 --- a/lib/compiler_rt/comparesf2_test.zig +++ b/lib/compiler_rt/comparesf2_test.zig @@ -5,15 +5,15 @@ const std = @import("std"); const builtin = @import("builtin"); -const __eqsf2 = @import("./cmpsf2.zig").__eqsf2; -const __lesf2 = @import("./cmpsf2.zig").__lesf2; -const __ltsf2 = @import("./cmpsf2.zig").__ltsf2; -const __nesf2 = @import("./cmpsf2.zig").__nesf2; +const __eqsf2 = @import("./comparef.zig").__eqsf2; +const __lesf2 = @import("./comparef.zig").__lesf2; +const __ltsf2 = @import("./comparef.zig").__ltsf2; +const __nesf2 = @import("./comparef.zig").__nesf2; const __gesf2 = @import("./gesf2.zig").__gesf2; const __gtsf2 = @import("./gesf2.zig").__gtsf2; -const __unordsf2 = @import("./unordsf2.zig").__unordsf2; +const __unordsf2 = @import("./comparef.zig").__unordsf2; const TestVector = struct { a: f32, diff --git a/lib/compiler_rt/cos.zig b/lib/compiler_rt/cos.zig index 406098d56b..3534e7837c 100644 --- a/lib/compiler_rt/cos.zig +++ b/lib/compiler_rt/cos.zig @@ -3,7 +3,7 @@ const math = std.math; const mem = std.mem; const expect = std.testing.expect; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const trig = @import("trig.zig"); const rem_pio2 = @import("rem_pio2.zig").rem_pio2; @@ -14,7 +14,7 @@ comptime { symbol(&cosf, "cosf"); symbol(&cos, "cos"); symbol(&__cosx, "__cosx"); - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&cosq, "cosf128"); } symbol(&cosq, "cosq"); @@ -40,7 +40,7 @@ pub fn cosf(x: f32) callconv(.c) f32 { if (ix <= 0x3f490fda) { // |x| ~<= pi/4 if (ix < 0x39800000) { // |x| < 2**-12 // raise inexact if x != 0 - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); return 1.0; } return trig.__cosdf(x); @@ -91,7 +91,7 @@ pub fn cos(x: f64) callconv(.c) f64 { if (ix <= 0x3fe921fb) { if (ix < 0x3e46a09e) { // |x| < 2**-27 * sqrt(2) // raise inexact if x!=0 - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); return 1.0; } return trig.__cos(x, 0); diff --git a/lib/compiler_rt/divdf3.zig b/lib/compiler_rt/divdf3.zig index c57b432832..b8a9c1914e 100644 --- a/lib/compiler_rt/divdf3.zig +++ b/lib/compiler_rt/divdf3.zig @@ -3,14 +3,14 @@ //! https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/divdf3.c const std = @import("std"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; -const normalize = common.normalize; -const wideMultiply = common.wideMultiply; +const normalize = compiler_rt.normalize; +const wideMultiply = compiler_rt.wideMultiply; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_ddiv, "__aeabi_ddiv"); } else { symbol(&__divdf3, "__divdf3"); diff --git a/lib/compiler_rt/divhc3.zig b/lib/compiler_rt/divhc3.zig index 8243c545b1..c9668f4ca8 100644 --- a/lib/compiler_rt/divhc3.zig +++ b/lib/compiler_rt/divhc3.zig @@ -1,10 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const divc3 = @import("./divc3.zig"); const Complex = @import("./mulc3.zig").Complex; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(&__divhc3, .{ .name = "__divhc3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__divhc3, "__divhc3"); } } diff --git a/lib/compiler_rt/divmodei4.zig b/lib/compiler_rt/divmodei4.zig index d96be7dec5..4fa168a675 100644 --- a/lib/compiler_rt/divmodei4.zig +++ b/lib/compiler_rt/divmodei4.zig @@ -3,7 +3,7 @@ const endian = builtin.cpu.arch.endian(); const std = @import("std"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const udivmod = @import("udivmodei4.zig").divmod; const symbol = @import("../compiler_rt.zig").symbol; @@ -36,7 +36,7 @@ fn divmod(q: ?[]u32, r: ?[]u32, u: []u32, v: []u32) !void { } pub fn __divei4(q_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) void { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits)); const q: []u32 = @ptrCast(@alignCast(q_p[0..byte_size])); const u: []u32 = @ptrCast(@alignCast(u_p[0..byte_size])); @@ -45,7 +45,7 @@ pub fn __divei4(q_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) vo } pub fn __modei4(r_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) void { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits)); const r: []u32 = @ptrCast(@alignCast(r_p[0..byte_size])); const u: []u32 = @ptrCast(@alignCast(u_p[0..byte_size])); diff --git a/lib/compiler_rt/divsf3.zig b/lib/compiler_rt/divsf3.zig index 67e24de80d..5406dc8ccf 100644 --- a/lib/compiler_rt/divsf3.zig +++ b/lib/compiler_rt/divsf3.zig @@ -4,12 +4,12 @@ const std = @import("std"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; -const normalize = common.normalize; +const normalize = compiler_rt.normalize; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_fdiv, "__aeabi_fdiv"); } else { symbol(&__divsf3, "__divsf3"); diff --git a/lib/compiler_rt/divtc3.zig b/lib/compiler_rt/divtc3.zig index d686958621..b0e0f35f54 100644 --- a/lib/compiler_rt/divtc3.zig +++ b/lib/compiler_rt/divtc3.zig @@ -1,11 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const divc3 = @import("./divc3.zig"); const Complex = @import("./mulc3.zig").Complex; const symbol = @import("../compiler_rt.zig").symbol; comptime { if (@import("builtin").zig_backend != .stage2_c) { - if (common.want_ppc_abi) + if (compiler_rt.want_ppc_abi) symbol(&__divtc3, "__divkc3"); symbol(&__divtc3, "__divtc3"); } diff --git a/lib/compiler_rt/divtf3.zig b/lib/compiler_rt/divtf3.zig index 6606d0de38..db495ee0a4 100644 --- a/lib/compiler_rt/divtf3.zig +++ b/lib/compiler_rt/divtf3.zig @@ -1,17 +1,18 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); -const normalize = common.normalize; -const wideMultiply = common.wideMultiply; +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; +const normalize = compiler_rt.normalize; +const wideMultiply = compiler_rt.wideMultiply; comptime { - if (common.want_ppc_abi) { - @export(&__divtf3, .{ .name = "__divkf3", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__divtf3, "__divkf3"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_div, "_Qp_div"); } - @export(&__divtf3, .{ .name = "__divtf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__divtf3, "__divtf3"); } pub fn __divtf3(a: f128, b: f128) callconv(.c) f128 { diff --git a/lib/compiler_rt/divti3.zig b/lib/compiler_rt/divti3.zig deleted file mode 100644 index 9eb8dda187..0000000000 --- a/lib/compiler_rt/divti3.zig +++ /dev/null @@ -1,39 +0,0 @@ -const std = @import("std"); -const builtin = @import("builtin"); -const udivmod = @import("udivmod.zig").udivmod; -const arch = builtin.cpu.arch; -const common = @import("common.zig"); - -comptime { - if (common.want_windows_v2u64_abi) { - @export(&__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -pub fn __divti3(a: i128, b: i128) callconv(.c) i128 { - return div(a, b); -} - -const v128 = @Vector(2, u64); - -fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.c) v128 { - return @bitCast(div(@bitCast(a), @bitCast(b))); -} - -inline fn div(a: i128, b: i128) i128 { - const s_a = a >> (128 - 1); - const s_b = b >> (128 - 1); - - const an = (a ^ s_a) -% s_a; - const bn = (b ^ s_b) -% s_b; - - const r = udivmod(u128, @bitCast(an), @bitCast(bn), null); - const s = s_a ^ s_b; - return (@as(i128, @bitCast(r)) ^ s) -% s; -} - -test { - _ = @import("divti3_test.zig"); -} diff --git a/lib/compiler_rt/divti3_test.zig b/lib/compiler_rt/divti3_test.zig index bcf45da3f2..34431d12af 100644 --- a/lib/compiler_rt/divti3_test.zig +++ b/lib/compiler_rt/divti3_test.zig @@ -1,4 +1,4 @@ -const __divti3 = @import("divti3.zig").__divti3; +const __divti3 = @import("udivmod.zig").__divti3; const testing = @import("std").testing; fn test__divti3(a: i128, b: i128, expected: i128) !void { diff --git a/lib/compiler_rt/divxf3.zig b/lib/compiler_rt/divxf3.zig index 069510a2b6..46210a500f 100644 --- a/lib/compiler_rt/divxf3.zig +++ b/lib/compiler_rt/divxf3.zig @@ -2,12 +2,13 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; -const common = @import("common.zig"); -const normalize = common.normalize; -const wideMultiply = common.wideMultiply; +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; +const normalize = compiler_rt.normalize; +const wideMultiply = compiler_rt.wideMultiply; comptime { - @export(&__divxf3, .{ .name = "__divxf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__divxf3, "__divxf3"); } pub fn __divxf3(a: f80, b: f80) callconv(.c) f80 { diff --git a/lib/compiler_rt/emutls.zig b/lib/compiler_rt/emutls.zig index d702597cd2..ee80d75d9f 100644 --- a/lib/compiler_rt/emutls.zig +++ b/lib/compiler_rt/emutls.zig @@ -5,7 +5,8 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const abort = std.process.abort; const assert = std.debug.assert; @@ -17,7 +18,7 @@ const gcc_word = usize; comptime { if (builtin.link_libc and (builtin.abi.isAndroid() or builtin.abi.isOpenHarmony() or builtin.os.tag == .openbsd)) { - @export(&__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__emutls_get_address, "__emutls_get_address"); } } diff --git a/lib/compiler_rt/exp.zig b/lib/compiler_rt/exp.zig index 3f18188fa0..c5a980ac72 100644 --- a/lib/compiler_rt/exp.zig +++ b/lib/compiler_rt/exp.zig @@ -13,7 +13,7 @@ const mem = std.mem; const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { @@ -21,7 +21,7 @@ comptime { symbol(&expf, "expf"); symbol(&exp, "exp"); symbol(&__expx, "__expx"); - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&expq, "expf128"); } symbol(&expq, "expq"); @@ -61,7 +61,7 @@ pub fn expf(x_: f32) callconv(.c) f32 { return x * 0x1.0p127; } if (sign != 0) { - if (common.want_float_exceptions) mem.doNotOptimizeAway(-0x1.0p-149 / x); // overflow + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(-0x1.0p-149 / x); // overflow // x <= -103.972084 if (hx >= 0x42CFF1B5) { return 0; @@ -93,7 +93,7 @@ pub fn expf(x_: f32) callconv(.c) f32 { hi = x; lo = 0; } else { - if (common.want_float_exceptions) mem.doNotOptimizeAway(0x1.0p127 + x); // inexact + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(0x1.0p127 + x); // inexact return 1 + x; } @@ -137,11 +137,11 @@ pub fn exp(x_: f64) callconv(.c) f64 { } if (x > 709.782712893383973096) { // overflow if x != inf - return if (common.want_float_exceptions) x * 0x1p1023 else std.math.inf(f64); + return if (compiler_rt.want_float_exceptions) x * 0x1p1023 else std.math.inf(f64); } if (x < -708.39641853226410622) { // underflow if x != -inf - if (common.want_float_exceptions) mem.doNotOptimizeAway(-0x0.0000000000001p-1022 / x); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(-0x0.0000000000001p-1022 / x); if (x < -745.13321910194110842) { return 0; } @@ -174,7 +174,7 @@ pub fn exp(x_: f64) callconv(.c) f64 { lo = 0; } else { // inexact if x != 0 - if (common.want_float_exceptions) mem.doNotOptimizeAway(0x1.0p1023 + x); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(0x1.0p1023 + x); return 1 + x; } diff --git a/lib/compiler_rt/exp2.zig b/lib/compiler_rt/exp2.zig index f59e98620e..4e41db2f2d 100644 --- a/lib/compiler_rt/exp2.zig +++ b/lib/compiler_rt/exp2.zig @@ -11,18 +11,19 @@ const math = std.math; const mem = std.mem; const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__exp2h, .{ .name = "__exp2h", .linkage = common.linkage, .visibility = common.visibility }); - @export(&exp2f, .{ .name = "exp2f", .linkage = common.linkage, .visibility = common.visibility }); - @export(&exp2, .{ .name = "exp2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__exp2x, .{ .name = "__exp2x", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&exp2q, .{ .name = "exp2f128", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__exp2h, "__exp2h"); + symbol(&exp2f, "exp2f"); + symbol(&exp2, "exp2"); + symbol(&__exp2x, "__exp2x"); + if (compiler_rt.want_ppc_abi) { + symbol(&exp2q, "exp2f128"); } - @export(&exp2q, .{ .name = "exp2q", .linkage = common.linkage, .visibility = common.visibility }); - @export(&exp2l, .{ .name = "exp2l", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&exp2q, "exp2q"); + symbol(&exp2l, "exp2l"); } pub fn __exp2h(x: f16) callconv(.c) f16 { @@ -54,7 +55,7 @@ pub fn exp2f(x: f32) callconv(.c) f32 { // x < -126 if (u >= 0x80000000) { if (u >= 0xC3160000 or u & 0x000FFFF != 0) { - if (common.want_float_exceptions) mem.doNotOptimizeAway(-0x1.0p-149 / x); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(-0x1.0p-149 / x); } // x <= -150 if (u >= 0xC3160000) { @@ -108,7 +109,7 @@ pub fn exp2(x: f64) callconv(.c) f64 { if (ix >= 0x408FF000) { // x >= 1024 or nan if (ix >= 0x40900000 and ux >> 63 == 0) { - return if (common.want_float_exceptions) x * 0x1p1023 else std.math.inf(f64); + return if (compiler_rt.want_float_exceptions) x * 0x1p1023 else std.math.inf(f64); } // -inf or -nan if (ix >= 0x7FF00000) { @@ -118,7 +119,7 @@ pub fn exp2(x: f64) callconv(.c) f64 { if (ux >> 63 != 0) { // underflow if (x <= -1075 or x - 0x1.0p52 + 0x1.0p52 != x) { - if (common.want_float_exceptions) mem.doNotOptimizeAway(@as(f32, @floatCast(-0x1.0p-149 / x))); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(@as(f32, @floatCast(-0x1.0p-149 / x))); } if (x <= -1075) { return 0; diff --git a/lib/compiler_rt/extenddftf2.zig b/lib/compiler_rt/extenddftf2.zig index 0204de48ed..4ccd402b24 100644 --- a/lib/compiler_rt/extenddftf2.zig +++ b/lib/compiler_rt/extenddftf2.zig @@ -1,11 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const extendf = @import("./extendf.zig").extendf; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&__extenddftf2, "__extenddfkf2"); - } else if (common.want_sparc_abi) { + } else if (compiler_rt.want_sparc_abi) { symbol(&_Qp_dtoq, "_Qp_dtoq"); } symbol(&__extenddftf2, "__extenddftf2"); diff --git a/lib/compiler_rt/extenddfxf2.zig b/lib/compiler_rt/extenddfxf2.zig index 1d7bc998d7..d18195aea3 100644 --- a/lib/compiler_rt/extenddfxf2.zig +++ b/lib/compiler_rt/extenddfxf2.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const extend_f80 = @import("./extendf.zig").extend_f80; comptime { - @export(&__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__extenddfxf2, "__extenddfxf2"); } pub fn __extenddfxf2(a: f64) callconv(.c) f80 { diff --git a/lib/compiler_rt/extendf_test.zig b/lib/compiler_rt/extendf_test.zig index 20273507d1..f572495b66 100644 --- a/lib/compiler_rt/extendf_test.zig +++ b/lib/compiler_rt/extendf_test.zig @@ -1,12 +1,14 @@ +const builtin = @import("builtin"); + const std = @import("std"); const math = std.math; -const builtin = @import("builtin"); + const __extendhfsf2 = @import("extendhfsf2.zig").__extendhfsf2; const __extendhftf2 = @import("extendhftf2.zig").__extendhftf2; const __extendsftf2 = @import("extendsftf2.zig").__extendsftf2; const __extenddftf2 = @import("extenddftf2.zig").__extenddftf2; const __extenddfxf2 = @import("extenddfxf2.zig").__extenddfxf2; -const F16T = @import("./common.zig").F16T; +const F16T = @import("../compiler_rt.zig").F16T; fn test__extenddfxf2(a: f64, expected: u80) !void { const x = __extenddfxf2(a); diff --git a/lib/compiler_rt/extendhfdf2.zig b/lib/compiler_rt/extendhfdf2.zig index 2191bafe13..8cadc7139e 100644 --- a/lib/compiler_rt/extendhfdf2.zig +++ b/lib/compiler_rt/extendhfdf2.zig @@ -1,4 +1,4 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const extendf = @import("./extendf.zig").extendf; @@ -6,6 +6,6 @@ comptime { symbol(&__extendhfdf2, "__extendhfdf2"); } -pub fn __extendhfdf2(a: common.F16T(f64)) callconv(.c) f64 { +pub fn __extendhfdf2(a: compiler_rt.F16T(f64)) callconv(.c) f64 { return extendf(f64, f16, @as(u16, @bitCast(a))); } diff --git a/lib/compiler_rt/extendhfsf2.zig b/lib/compiler_rt/extendhfsf2.zig index 2c734f0147..b638192c47 100644 --- a/lib/compiler_rt/extendhfsf2.zig +++ b/lib/compiler_rt/extendhfsf2.zig @@ -1,21 +1,21 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const extendf = @import("./extendf.zig").extendf; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.gnu_f16_abi) { + if (compiler_rt.gnu_f16_abi) { symbol(&__gnu_h2f_ieee, "__gnu_h2f_ieee"); - } else if (common.want_aeabi) { + } else if (compiler_rt.want_aeabi) { symbol(&__aeabi_h2f, "__aeabi_h2f"); } symbol(&__extendhfsf2, "__extendhfsf2"); } -pub fn __extendhfsf2(a: common.F16T(f32)) callconv(.c) f32 { +pub fn __extendhfsf2(a: compiler_rt.F16T(f32)) callconv(.c) f32 { return extendf(f32, f16, @as(u16, @bitCast(a))); } -fn __gnu_h2f_ieee(a: common.F16T(f32)) callconv(.c) f32 { +fn __gnu_h2f_ieee(a: compiler_rt.F16T(f32)) callconv(.c) f32 { return extendf(f32, f16, @as(u16, @bitCast(a))); } diff --git a/lib/compiler_rt/extendhftf2.zig b/lib/compiler_rt/extendhftf2.zig index a94b849a5a..29e7866b66 100644 --- a/lib/compiler_rt/extendhftf2.zig +++ b/lib/compiler_rt/extendhftf2.zig @@ -1,10 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const extendf = @import("./extendf.zig").extendf; comptime { - @export(&__extendhftf2, .{ .name = "__extendhftf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__extendhftf2, "__extendhftf2"); } -pub fn __extendhftf2(a: common.F16T(f128)) callconv(.c) f128 { +pub fn __extendhftf2(a: compiler_rt.F16T(f128)) callconv(.c) f128 { return extendf(f128, f16, @as(u16, @bitCast(a))); } diff --git a/lib/compiler_rt/extendhfxf2.zig b/lib/compiler_rt/extendhfxf2.zig index 5e205b1f88..e76daf4f55 100644 --- a/lib/compiler_rt/extendhfxf2.zig +++ b/lib/compiler_rt/extendhfxf2.zig @@ -1,10 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const extend_f80 = @import("./extendf.zig").extend_f80; comptime { - @export(&__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__extendhfxf2, "__extendhfxf2"); } -fn __extendhfxf2(a: common.F16T(f80)) callconv(.c) f80 { +fn __extendhfxf2(a: compiler_rt.F16T(f80)) callconv(.c) f80 { return extend_f80(f16, @as(u16, @bitCast(a))); } diff --git a/lib/compiler_rt/extendsfdf2.zig b/lib/compiler_rt/extendsfdf2.zig index 9cc0a43663..4f34b05242 100644 --- a/lib/compiler_rt/extendsfdf2.zig +++ b/lib/compiler_rt/extendsfdf2.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const extendf = @import("./extendf.zig").extendf; comptime { - if (common.want_aeabi) { - @export(&__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_f2d, "__aeabi_f2d"); } else { - @export(&__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__extendsfdf2, "__extendsfdf2"); } } diff --git a/lib/compiler_rt/extendsftf2.zig b/lib/compiler_rt/extendsftf2.zig index 3690a0733c..e260eec7fe 100644 --- a/lib/compiler_rt/extendsftf2.zig +++ b/lib/compiler_rt/extendsftf2.zig @@ -1,13 +1,14 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const extendf = @import("./extendf.zig").extendf; comptime { - if (common.want_ppc_abi) { - @export(&__extendsftf2, .{ .name = "__extendsfkf2", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__extendsftf2, "__extendsfkf2"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_stoq, "_Qp_stoq"); } - @export(&__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__extendsftf2, "__extendsftf2"); } pub fn __extendsftf2(a: f32) callconv(.c) f128 { diff --git a/lib/compiler_rt/fabs.zig b/lib/compiler_rt/fabs.zig index 9a10f4ce61..8fcf36262a 100644 --- a/lib/compiler_rt/fabs.zig +++ b/lib/compiler_rt/fabs.zig @@ -1,18 +1,19 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__fabsh, .{ .name = "__fabsh", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fabsf, .{ .name = "fabsf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fabs, .{ .name = "fabs", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__fabsx, .{ .name = "__fabsx", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&fabsq, .{ .name = "fabsf128", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fabsh, "__fabsh"); + symbol(&fabsf, "fabsf"); + symbol(&fabs, "fabs"); + symbol(&__fabsx, "__fabsx"); + if (compiler_rt.want_ppc_abi) { + symbol(&fabsq, "fabsf128"); } - @export(&fabsq, .{ .name = "fabsq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fabsl, .{ .name = "fabsl", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&fabsq, "fabsq"); + symbol(&fabsl, "fabsl"); } pub fn __fabsh(a: f16) callconv(.c) f16 { diff --git a/lib/compiler_rt/fixdfdi.zig b/lib/compiler_rt/fixdfdi.zig index 97f3be044e..5a66cc124f 100644 --- a/lib/compiler_rt/fixdfdi.zig +++ b/lib/compiler_rt/fixdfdi.zig @@ -1,15 +1,16 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_aeabi) { - @export(&__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_d2lz, "__aeabi_d2lz"); } else { - if (common.want_windows_arm_abi) { - @export(&__fixdfdi, .{ .name = "__dtoi64", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_arm_abi) { + symbol(&__fixdfdi, "__dtoi64"); } - @export(&__fixdfdi, .{ .name = "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixdfdi, "__fixdfdi"); } } diff --git a/lib/compiler_rt/fixdfei.zig b/lib/compiler_rt/fixdfei.zig index 3565cb45ba..170b4a1603 100644 --- a/lib/compiler_rt/fixdfei.zig +++ b/lib/compiler_rt/fixdfei.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat; comptime { - @export(&__fixdfei, .{ .name = "__fixdfei", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixdfei, "__fixdfei"); } pub fn __fixdfei(r: [*]u8, bits: usize, a: f64) callconv(.c) void { diff --git a/lib/compiler_rt/fixdfsi.zig b/lib/compiler_rt/fixdfsi.zig index 7707f89830..1d42337ea5 100644 --- a/lib/compiler_rt/fixdfsi.zig +++ b/lib/compiler_rt/fixdfsi.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const intFromFloat = @import("./int_from_float.zig").intFromFloat; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_d2iz, "__aeabi_d2iz"); } else { symbol(&__fixdfsi, "__fixdfsi"); diff --git a/lib/compiler_rt/fixdfti.zig b/lib/compiler_rt/fixdfti.zig index 64c5a080f9..4717fd7b59 100644 --- a/lib/compiler_rt/fixdfti.zig +++ b/lib/compiler_rt/fixdfti.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const intFromFloat = @import("./int_from_float.zig").intFromFloat; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__fixdfti_windows_x86_64, "__fixdfti"); } else { symbol(&__fixdfti, "__fixdfti"); diff --git a/lib/compiler_rt/fixhfdi.zig b/lib/compiler_rt/fixhfdi.zig deleted file mode 100644 index 3bcb848972..0000000000 --- a/lib/compiler_rt/fixhfdi.zig +++ /dev/null @@ -1,10 +0,0 @@ -const common = @import("./common.zig"); -const intFromFloat = @import("./int_from_float.zig").intFromFloat; - -comptime { - @export(&__fixhfdi, .{ .name = "__fixhfdi", .linkage = common.linkage, .visibility = common.visibility }); -} - -fn __fixhfdi(a: f16) callconv(.c) i64 { - return intFromFloat(i64, a); -} diff --git a/lib/compiler_rt/fixhfei.zig b/lib/compiler_rt/fixhfei.zig index 1eef56073f..5b759c3fc6 100644 --- a/lib/compiler_rt/fixhfei.zig +++ b/lib/compiler_rt/fixhfei.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat; comptime { - @export(&__fixhfei, .{ .name = "__fixhfei", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixhfei, "__fixhfei"); } pub fn __fixhfei(r: [*]u8, bits: usize, a: f16) callconv(.c) void { diff --git a/lib/compiler_rt/fixhfsi.zig b/lib/compiler_rt/fixhfsi.zig deleted file mode 100644 index 658f13bb71..0000000000 --- a/lib/compiler_rt/fixhfsi.zig +++ /dev/null @@ -1,10 +0,0 @@ -const common = @import("./common.zig"); -const intFromFloat = @import("./int_from_float.zig").intFromFloat; - -comptime { - @export(&__fixhfsi, .{ .name = "__fixhfsi", .linkage = common.linkage, .visibility = common.visibility }); -} - -fn __fixhfsi(a: f16) callconv(.c) i32 { - return intFromFloat(i32, a); -} diff --git a/lib/compiler_rt/fixhfti.zig b/lib/compiler_rt/fixhfti.zig deleted file mode 100644 index 1c51ebc056..0000000000 --- a/lib/compiler_rt/fixhfti.zig +++ /dev/null @@ -1,21 +0,0 @@ -const builtin = @import("builtin"); -const common = @import("./common.zig"); -const intFromFloat = @import("./int_from_float.zig").intFromFloat; - -comptime { - if (common.want_windows_v2u64_abi) { - @export(&__fixhfti_windows_x86_64, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__fixhfti, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -pub fn __fixhfti(a: f16) callconv(.c) i128 { - return intFromFloat(i128, a); -} - -const v2u64 = @Vector(2, u64); - -fn __fixhfti_windows_x86_64(a: f16) callconv(.c) v2u64 { - return @bitCast(intFromFloat(i128, a)); -} diff --git a/lib/compiler_rt/fixsfdi.zig b/lib/compiler_rt/fixsfdi.zig index b2880aefc2..0a3731877e 100644 --- a/lib/compiler_rt/fixsfdi.zig +++ b/lib/compiler_rt/fixsfdi.zig @@ -1,13 +1,13 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const intFromFloat = @import("./int_from_float.zig").intFromFloat; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_f2lz, "__aeabi_f2lz"); } else { - if (common.want_windows_arm_abi) { + if (compiler_rt.want_windows_arm_abi) { symbol(&__fixsfdi, "__stoi64"); } symbol(&__fixsfdi, "__fixsfdi"); diff --git a/lib/compiler_rt/fixsfei.zig b/lib/compiler_rt/fixsfei.zig index efbccfa299..4324325405 100644 --- a/lib/compiler_rt/fixsfei.zig +++ b/lib/compiler_rt/fixsfei.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat; comptime { - @export(&__fixsfei, .{ .name = "__fixsfei", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixsfei, "__fixsfei"); } pub fn __fixsfei(r: [*]u8, bits: usize, a: f32) callconv(.c) void { diff --git a/lib/compiler_rt/fixsfsi.zig b/lib/compiler_rt/fixsfsi.zig index abb8564369..9c07c5824a 100644 --- a/lib/compiler_rt/fixsfsi.zig +++ b/lib/compiler_rt/fixsfsi.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_aeabi) { - @export(&__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_f2iz, "__aeabi_f2iz"); } else { - @export(&__fixsfsi, .{ .name = "__fixsfsi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixsfsi, "__fixsfsi"); } } diff --git a/lib/compiler_rt/fixsfti.zig b/lib/compiler_rt/fixsfti.zig index 82b1db70dc..0980012a45 100644 --- a/lib/compiler_rt/fixsfti.zig +++ b/lib/compiler_rt/fixsfti.zig @@ -1,12 +1,13 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_windows_v2u64_abi) { - @export(&__fixsfti_windows_x86_64, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__fixsfti_windows_x86_64, "__fixsfti"); } else { - @export(&__fixsfti, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixsfti, "__fixsfti"); } } diff --git a/lib/compiler_rt/fixtfdi.zig b/lib/compiler_rt/fixtfdi.zig index bc1c8e56eb..f3cb7bc1cf 100644 --- a/lib/compiler_rt/fixtfdi.zig +++ b/lib/compiler_rt/fixtfdi.zig @@ -1,11 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const intFromFloat = @import("./int_from_float.zig").intFromFloat; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&__fixtfdi, "__fixkfdi"); - } else if (common.want_sparc_abi) { + } else if (compiler_rt.want_sparc_abi) { symbol(&_Qp_qtox, "_Qp_qtox"); } symbol(&__fixtfdi, "__fixtfdi"); diff --git a/lib/compiler_rt/fixtfei.zig b/lib/compiler_rt/fixtfei.zig index 980db4c614..6443a0cb3b 100644 --- a/lib/compiler_rt/fixtfei.zig +++ b/lib/compiler_rt/fixtfei.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat; comptime { - @export(&__fixtfei, .{ .name = "__fixtfei", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixtfei, "__fixtfei"); } pub fn __fixtfei(r: [*]u8, bits: usize, a: f128) callconv(.c) void { diff --git a/lib/compiler_rt/fixtfsi.zig b/lib/compiler_rt/fixtfsi.zig index 0919566a80..10cddec0da 100644 --- a/lib/compiler_rt/fixtfsi.zig +++ b/lib/compiler_rt/fixtfsi.zig @@ -1,11 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&__fixtfsi, "__fixkfsi"); - } else if (common.want_sparc_abi) { + } else if (compiler_rt.want_sparc_abi) { symbol(&_Qp_qtoi, "_Qp_qtoi"); } symbol(&__fixtfsi, "__fixtfsi"); diff --git a/lib/compiler_rt/fixtfti.zig b/lib/compiler_rt/fixtfti.zig index 2a1a928256..cb642d6166 100644 --- a/lib/compiler_rt/fixtfti.zig +++ b/lib/compiler_rt/fixtfti.zig @@ -1,12 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const intFromFloat = @import("./int_from_float.zig").intFromFloat; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__fixtfti_windows_x86_64, "__fixtfti"); } else { - if (common.want_ppc_abi) + if (compiler_rt.want_ppc_abi) symbol(&__fixtfti, "__fixkfti"); symbol(&__fixtfti, "__fixtfti"); } diff --git a/lib/compiler_rt/fixunsdfdi.zig b/lib/compiler_rt/fixunsdfdi.zig index 211963bf3e..340bb8f6b1 100644 --- a/lib/compiler_rt/fixunsdfdi.zig +++ b/lib/compiler_rt/fixunsdfdi.zig @@ -1,15 +1,16 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_aeabi) { - @export(&__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_d2ulz, "__aeabi_d2ulz"); } else { - if (common.want_windows_arm_abi) { - @export(&__fixunsdfdi, .{ .name = "__dtou64", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_arm_abi) { + symbol(&__fixunsdfdi, "__dtou64"); } - @export(&__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixunsdfdi, "__fixunsdfdi"); } } diff --git a/lib/compiler_rt/fixunsdfsi.zig b/lib/compiler_rt/fixunsdfsi.zig index a8e9197361..e8b976d03d 100644 --- a/lib/compiler_rt/fixunsdfsi.zig +++ b/lib/compiler_rt/fixunsdfsi.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_aeabi) { - @export(&__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_d2uiz, "__aeabi_d2uiz"); } else { - @export(&__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixunsdfsi, "__fixunsdfsi"); } } diff --git a/lib/compiler_rt/fixunsdfti.zig b/lib/compiler_rt/fixunsdfti.zig index a90b3d67fb..95d15ac313 100644 --- a/lib/compiler_rt/fixunsdfti.zig +++ b/lib/compiler_rt/fixunsdfti.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__fixunsdfti_windows_x86_64, "__fixunsdfti"); } else { symbol(&__fixunsdfti, "__fixunsdfti"); diff --git a/lib/compiler_rt/fixunshfsi.zig b/lib/compiler_rt/fixunshfsi.zig index fca40d1b0a..438767c7a8 100644 --- a/lib/compiler_rt/fixunshfsi.zig +++ b/lib/compiler_rt/fixunshfsi.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - @export(&__fixunshfsi, .{ .name = "__fixunshfsi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixunshfsi, "__fixunshfsi"); } fn __fixunshfsi(a: f16) callconv(.c) u32 { diff --git a/lib/compiler_rt/fixunshfti.zig b/lib/compiler_rt/fixunshfti.zig index 454aa9d575..a090027196 100644 --- a/lib/compiler_rt/fixunshfti.zig +++ b/lib/compiler_rt/fixunshfti.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const intFromFloat = @import("./int_from_float.zig").intFromFloat; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__fixunshfti_windows_x86_64, "__fixunshfti"); } else { symbol(&__fixunshfti, "__fixunshfti"); diff --git a/lib/compiler_rt/fixunssfdi.zig b/lib/compiler_rt/fixunssfdi.zig index f12ec1cd5a..ffc238a53f 100644 --- a/lib/compiler_rt/fixunssfdi.zig +++ b/lib/compiler_rt/fixunssfdi.zig @@ -1,15 +1,16 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_aeabi) { - @export(&__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_f2ulz, "__aeabi_f2ulz"); } else { - if (common.want_windows_arm_abi) { - @export(&__fixunssfdi, .{ .name = "__stou64", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_arm_abi) { + symbol(&__fixunssfdi, "__stou64"); } - @export(&__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixunssfdi, "__fixunssfdi"); } } diff --git a/lib/compiler_rt/fixunssfsi.zig b/lib/compiler_rt/fixunssfsi.zig index 4def4b867f..f9c09b3f3d 100644 --- a/lib/compiler_rt/fixunssfsi.zig +++ b/lib/compiler_rt/fixunssfsi.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_aeabi) { - @export(&__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_f2uiz, "__aeabi_f2uiz"); } else { - @export(&__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixunssfsi, "__fixunssfsi"); } } diff --git a/lib/compiler_rt/fixunssfti.zig b/lib/compiler_rt/fixunssfti.zig index 73e2d2a3f6..da46f43d5b 100644 --- a/lib/compiler_rt/fixunssfti.zig +++ b/lib/compiler_rt/fixunssfti.zig @@ -1,10 +1,10 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const intFromFloat = @import("./int_from_float.zig").intFromFloat; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__fixunssfti_windows_x86_64, "__fixunssfti"); } else { symbol(&__fixunssfti, "__fixunssfti"); diff --git a/lib/compiler_rt/fixunstfdi.zig b/lib/compiler_rt/fixunstfdi.zig index f1e1822a31..809fe6eb80 100644 --- a/lib/compiler_rt/fixunstfdi.zig +++ b/lib/compiler_rt/fixunstfdi.zig @@ -1,13 +1,14 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_ppc_abi) { - @export(&__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__fixunstfdi, "__fixunskfdi"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_qtoux, "_Qp_qtoux"); } - @export(&__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixunstfdi, "__fixunstfdi"); } pub fn __fixunstfdi(a: f128) callconv(.c) u64 { diff --git a/lib/compiler_rt/fixunstfsi.zig b/lib/compiler_rt/fixunstfsi.zig index d3a9bfbed8..e8ec0aea93 100644 --- a/lib/compiler_rt/fixunstfsi.zig +++ b/lib/compiler_rt/fixunstfsi.zig @@ -1,13 +1,14 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_ppc_abi) { - @export(&__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__fixunstfsi, "__fixunskfsi"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_qtoui, "_Qp_qtoui"); } - @export(&__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixunstfsi, "__fixunstfsi"); } pub fn __fixunstfsi(a: f128) callconv(.c) u32 { diff --git a/lib/compiler_rt/fixunstfti.zig b/lib/compiler_rt/fixunstfti.zig index 92fcd569dc..81c2a16095 100644 --- a/lib/compiler_rt/fixunstfti.zig +++ b/lib/compiler_rt/fixunstfti.zig @@ -1,14 +1,15 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_windows_v2u64_abi) { - @export(&__fixunstfti_windows_x86_64, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__fixunstfti_windows_x86_64, "__fixunstfti"); } else { - if (common.want_ppc_abi) - @export(&__fixunstfti, .{ .name = "__fixunskfti", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__fixunstfti, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) + symbol(&__fixunstfti, "__fixunskfti"); + symbol(&__fixunstfti, "__fixunstfti"); } } diff --git a/lib/compiler_rt/fixunsxfsi.zig b/lib/compiler_rt/fixunsxfsi.zig index 8f900076c7..7309fbf5a6 100644 --- a/lib/compiler_rt/fixunsxfsi.zig +++ b/lib/compiler_rt/fixunsxfsi.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - @export(&__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixunsxfsi, "__fixunsxfsi"); } fn __fixunsxfsi(a: f80) callconv(.c) u32 { diff --git a/lib/compiler_rt/fixunsxfti.zig b/lib/compiler_rt/fixunsxfti.zig index 39dde2ca12..24296dd416 100644 --- a/lib/compiler_rt/fixunsxfti.zig +++ b/lib/compiler_rt/fixunsxfti.zig @@ -1,12 +1,13 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - if (common.want_windows_v2u64_abi) { - @export(&__fixunsxfti_windows_x86_64, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__fixunsxfti_windows_x86_64, "__fixunsxfti"); } else { - @export(&__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixunsxfti, "__fixunsxfti"); } } diff --git a/lib/compiler_rt/fixxfei.zig b/lib/compiler_rt/fixxfei.zig index 75edfad035..82cd67648d 100644 --- a/lib/compiler_rt/fixxfei.zig +++ b/lib/compiler_rt/fixxfei.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const bigIntFromFloat = @import("int_from_float.zig").bigIntFromFloat; comptime { - @export(&__fixxfei, .{ .name = "__fixxfei", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixxfei, "__fixxfei"); } pub fn __fixxfei(r: [*]u8, bits: usize, a: f80) callconv(.c) void { diff --git a/lib/compiler_rt/fixxfsi.zig b/lib/compiler_rt/fixxfsi.zig index 8a645bdae1..363492168c 100644 --- a/lib/compiler_rt/fixxfsi.zig +++ b/lib/compiler_rt/fixxfsi.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const intFromFloat = @import("./int_from_float.zig").intFromFloat; comptime { - @export(&__fixxfsi, .{ .name = "__fixxfsi", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fixxfsi, "__fixxfsi"); } fn __fixxfsi(a: f80) callconv(.c) i32 { diff --git a/lib/compiler_rt/fixxfti.zig b/lib/compiler_rt/fixxfti.zig deleted file mode 100644 index 2f43814eac..0000000000 --- a/lib/compiler_rt/fixxfti.zig +++ /dev/null @@ -1,23 +0,0 @@ -const builtin = @import("builtin"); - -const common = @import("./common.zig"); -const intFromFloat = @import("./int_from_float.zig").intFromFloat; -const symbol = @import("../compiler_rt.zig").symbol; - -comptime { - if (common.want_windows_v2u64_abi) { - symbol(&__fixxfti_windows_x86_64, "__fixxfti"); - } else { - symbol(&__fixxfti, "__fixxfti"); - } -} - -pub fn __fixxfti(a: f80) callconv(.c) i128 { - return intFromFloat(i128, a); -} - -const v2u64 = @Vector(2, u64); - -fn __fixxfti_windows_x86_64(a: f80) callconv(.c) v2u64 { - return @bitCast(intFromFloat(i128, a)); -} diff --git a/lib/compiler_rt/floatdidf.zig b/lib/compiler_rt/floatdidf.zig index f614521478..f8d5153d5b 100644 --- a/lib/compiler_rt/floatdidf.zig +++ b/lib/compiler_rt/floatdidf.zig @@ -1,15 +1,16 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_aeabi) { - @export(&__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_l2d, "__aeabi_l2d"); } else { - if (common.want_windows_arm_abi) { - @export(&__floatdidf, .{ .name = "__i64tod", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_arm_abi) { + symbol(&__floatdidf, "__i64tod"); } - @export(&__floatdidf, .{ .name = "__floatdidf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatdidf, "__floatdidf"); } } diff --git a/lib/compiler_rt/floatdisf.zig b/lib/compiler_rt/floatdisf.zig index 691ba91f26..3da1faba36 100644 --- a/lib/compiler_rt/floatdisf.zig +++ b/lib/compiler_rt/floatdisf.zig @@ -1,12 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_l2f, "__aeabi_l2f"); } else { - if (common.want_windows_arm_abi) { + if (compiler_rt.want_windows_arm_abi) { symbol(&__floatdisf, "__i64tos"); } symbol(&__floatdisf, "__floatdisf"); diff --git a/lib/compiler_rt/floatditf.zig b/lib/compiler_rt/floatditf.zig index 03182aab0b..544c059f1b 100644 --- a/lib/compiler_rt/floatditf.zig +++ b/lib/compiler_rt/floatditf.zig @@ -1,11 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const floatFromInt = @import("./float_from_int.zig").floatFromInt; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&__floatditf, "__floatdikf"); - } else if (common.want_sparc_abi) { + } else if (compiler_rt.want_sparc_abi) { symbol(&_Qp_xtoq, "_Qp_xtoq"); } symbol(&__floatditf, "__floatditf"); diff --git a/lib/compiler_rt/floateihf.zig b/lib/compiler_rt/floateihf.zig index 013e6d2d79..c1ec290fb1 100644 --- a/lib/compiler_rt/floateihf.zig +++ b/lib/compiler_rt/floateihf.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt; comptime { - @export(&__floateihf, .{ .name = "__floateihf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floateihf, "__floateihf"); } pub fn __floateihf(a: [*]const u8, bits: usize) callconv(.c) f16 { diff --git a/lib/compiler_rt/floateisf.zig b/lib/compiler_rt/floateisf.zig index eb24b6aa43..dd5933b7df 100644 --- a/lib/compiler_rt/floateisf.zig +++ b/lib/compiler_rt/floateisf.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt; comptime { - @export(&__floateisf, .{ .name = "__floateisf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floateisf, "__floateisf"); } pub fn __floateisf(a: [*]const u8, bits: usize) callconv(.c) f32 { diff --git a/lib/compiler_rt/floateitf.zig b/lib/compiler_rt/floateitf.zig index e5b50ab7a6..0df893bd18 100644 --- a/lib/compiler_rt/floateitf.zig +++ b/lib/compiler_rt/floateitf.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt; comptime { - @export(&__floateitf, .{ .name = "__floateitf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floateitf, "__floateitf"); } pub fn __floateitf(a: [*]const u8, bits: usize) callconv(.c) f128 { diff --git a/lib/compiler_rt/floatsidf.zig b/lib/compiler_rt/floatsidf.zig index 435c8db9a4..dc5a261a08 100644 --- a/lib/compiler_rt/floatsidf.zig +++ b/lib/compiler_rt/floatsidf.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_aeabi) { - @export(&__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_i2d, "__aeabi_i2d"); } else { - @export(&__floatsidf, .{ .name = "__floatsidf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatsidf, "__floatsidf"); } } diff --git a/lib/compiler_rt/floatsihf.zig b/lib/compiler_rt/floatsihf.zig index 5f2db12585..e1d588cfb0 100644 --- a/lib/compiler_rt/floatsihf.zig +++ b/lib/compiler_rt/floatsihf.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - @export(&__floatsihf, .{ .name = "__floatsihf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatsihf, "__floatsihf"); } fn __floatsihf(a: i32) callconv(.c) f16 { diff --git a/lib/compiler_rt/floatsisf.zig b/lib/compiler_rt/floatsisf.zig index 9c36387c66..0dac860ebf 100644 --- a/lib/compiler_rt/floatsisf.zig +++ b/lib/compiler_rt/floatsisf.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_aeabi) { - @export(&__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_i2f, "__aeabi_i2f"); } else { - @export(&__floatsisf, .{ .name = "__floatsisf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatsisf, "__floatsisf"); } } diff --git a/lib/compiler_rt/floatsitf.zig b/lib/compiler_rt/floatsitf.zig index 750633052d..b004d53989 100644 --- a/lib/compiler_rt/floatsitf.zig +++ b/lib/compiler_rt/floatsitf.zig @@ -1,13 +1,14 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_ppc_abi) { - @export(&__floatsitf, .{ .name = "__floatsikf", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__floatsitf, "__floatsikf"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_itoq, "_Qp_itoq"); } - @export(&__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatsitf, "__floatsitf"); } pub fn __floatsitf(a: i32) callconv(.c) f128 { diff --git a/lib/compiler_rt/floatsixf.zig b/lib/compiler_rt/floatsixf.zig index 0d5fcb340d..bd28eaf1fa 100644 --- a/lib/compiler_rt/floatsixf.zig +++ b/lib/compiler_rt/floatsixf.zig @@ -1,4 +1,4 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const floatFromInt = @import("./float_from_int.zig").floatFromInt; const symbol = @import("../compiler_rt.zig").symbol; diff --git a/lib/compiler_rt/floattidf.zig b/lib/compiler_rt/floattidf.zig index db48fe8af3..5fd6b4c0f6 100644 --- a/lib/compiler_rt/floattidf.zig +++ b/lib/compiler_rt/floattidf.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__floattidf_windows_x86_64, "__floattidf"); } else { symbol(&__floattidf, "__floattidf"); diff --git a/lib/compiler_rt/floattihf.zig b/lib/compiler_rt/floattihf.zig index 9ad705870e..643849f48e 100644 --- a/lib/compiler_rt/floattihf.zig +++ b/lib/compiler_rt/floattihf.zig @@ -1,12 +1,13 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_windows_v2u64_abi) { - @export(&__floattihf_windows_x86_64, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__floattihf_windows_x86_64, "__floattihf"); } else { - @export(&__floattihf, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floattihf, "__floattihf"); } } diff --git a/lib/compiler_rt/floattisf.zig b/lib/compiler_rt/floattisf.zig index 3e5fffcfd8..8926105d2d 100644 --- a/lib/compiler_rt/floattisf.zig +++ b/lib/compiler_rt/floattisf.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const floatFromInt = @import("./float_from_int.zig").floatFromInt; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__floattisf_windows_x86_64, "__floattisf"); } else { symbol(&__floattisf, "__floattisf"); diff --git a/lib/compiler_rt/floattitf.zig b/lib/compiler_rt/floattitf.zig index e8e301c42d..f8e6ca80e6 100644 --- a/lib/compiler_rt/floattitf.zig +++ b/lib/compiler_rt/floattitf.zig @@ -1,12 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__floattitf_windows_x86_64, "__floattitf"); } else { - if (common.want_ppc_abi) + if (compiler_rt.want_ppc_abi) symbol(&__floattitf, "__floattikf"); symbol(&__floattitf, "__floattitf"); } diff --git a/lib/compiler_rt/floattixf.zig b/lib/compiler_rt/floattixf.zig index ac1df5ba32..b69b8f9845 100644 --- a/lib/compiler_rt/floattixf.zig +++ b/lib/compiler_rt/floattixf.zig @@ -1,12 +1,13 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_windows_v2u64_abi) { - @export(&__floattixf_windows_x86_64, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__floattixf_windows_x86_64, "__floattixf"); } else { - @export(&__floattixf, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floattixf, "__floattixf"); } } diff --git a/lib/compiler_rt/floatundidf.zig b/lib/compiler_rt/floatundidf.zig index 6530f76ee7..8526753705 100644 --- a/lib/compiler_rt/floatundidf.zig +++ b/lib/compiler_rt/floatundidf.zig @@ -1,12 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const floatFromInt = @import("./float_from_int.zig").floatFromInt; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_ul2d, "__aeabi_ul2d"); } else { - if (common.want_windows_arm_abi) { + if (compiler_rt.want_windows_arm_abi) { symbol(&__floatundidf, "__u64tod"); } symbol(&__floatundidf, "__floatundidf"); diff --git a/lib/compiler_rt/floatundihf.zig b/lib/compiler_rt/floatundihf.zig index e7a3f865f8..064d565d2d 100644 --- a/lib/compiler_rt/floatundihf.zig +++ b/lib/compiler_rt/floatundihf.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - @export(&__floatundihf, .{ .name = "__floatundihf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatundihf, "__floatundihf"); } fn __floatundihf(a: u64) callconv(.c) f16 { diff --git a/lib/compiler_rt/floatundisf.zig b/lib/compiler_rt/floatundisf.zig index 89e7fa1f4b..827a419fd5 100644 --- a/lib/compiler_rt/floatundisf.zig +++ b/lib/compiler_rt/floatundisf.zig @@ -1,15 +1,16 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_aeabi) { - @export(&__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_ul2f, "__aeabi_ul2f"); } else { - if (common.want_windows_arm_abi) { - @export(&__floatundisf, .{ .name = "__u64tos", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_arm_abi) { + symbol(&__floatundisf, "__u64tos"); } - @export(&__floatundisf, .{ .name = "__floatundisf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatundisf, "__floatundisf"); } } diff --git a/lib/compiler_rt/floatunditf.zig b/lib/compiler_rt/floatunditf.zig index d313ff3d12..257a5779bb 100644 --- a/lib/compiler_rt/floatunditf.zig +++ b/lib/compiler_rt/floatunditf.zig @@ -1,13 +1,14 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_ppc_abi) { - @export(&__floatunditf, .{ .name = "__floatundikf", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__floatunditf, "__floatundikf"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_uxtoq, "_Qp_uxtoq"); } - @export(&__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatunditf, "__floatunditf"); } pub fn __floatunditf(a: u64) callconv(.c) f128 { diff --git a/lib/compiler_rt/floatundixf.zig b/lib/compiler_rt/floatundixf.zig index b9691e9144..ce36d47a4e 100644 --- a/lib/compiler_rt/floatundixf.zig +++ b/lib/compiler_rt/floatundixf.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - @export(&__floatundixf, .{ .name = "__floatundixf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatundixf, "__floatundixf"); } fn __floatundixf(a: u64) callconv(.c) f80 { diff --git a/lib/compiler_rt/floatuneidf.zig b/lib/compiler_rt/floatuneidf.zig index bb8a6579ce..6e391b7cf1 100644 --- a/lib/compiler_rt/floatuneidf.zig +++ b/lib/compiler_rt/floatuneidf.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt; comptime { - @export(&__floatuneidf, .{ .name = "__floatuneidf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatuneidf, "__floatuneidf"); } pub fn __floatuneidf(a: [*]const u8, bits: usize) callconv(.c) f64 { diff --git a/lib/compiler_rt/floatuneihf.zig b/lib/compiler_rt/floatuneihf.zig index 17b1e1d290..0df0cf155b 100644 --- a/lib/compiler_rt/floatuneihf.zig +++ b/lib/compiler_rt/floatuneihf.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt; comptime { - @export(&__floatuneihf, .{ .name = "__floatuneihf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatuneihf, "__floatuneihf"); } pub fn __floatuneihf(a: [*]const u8, bits: usize) callconv(.c) f16 { diff --git a/lib/compiler_rt/floatuneisf.zig b/lib/compiler_rt/floatuneisf.zig index bb43b6ee65..e2dadd9ffd 100644 --- a/lib/compiler_rt/floatuneisf.zig +++ b/lib/compiler_rt/floatuneisf.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt; comptime { - @export(&__floatuneisf, .{ .name = "__floatuneisf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatuneisf, "__floatuneisf"); } pub fn __floatuneisf(a: [*]const u8, bits: usize) callconv(.c) f32 { diff --git a/lib/compiler_rt/floatuneixf.zig b/lib/compiler_rt/floatuneixf.zig index ad0b8f24de..75dd565daf 100644 --- a/lib/compiler_rt/floatuneixf.zig +++ b/lib/compiler_rt/floatuneixf.zig @@ -1,10 +1,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromBigInt = @import("float_from_int.zig").floatFromBigInt; comptime { - @export(&__floatuneixf, .{ .name = "__floatuneixf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatuneixf, "__floatuneixf"); } pub fn __floatuneixf(a: [*]const u8, bits: usize) callconv(.c) f80 { diff --git a/lib/compiler_rt/floatunsidf.zig b/lib/compiler_rt/floatunsidf.zig index fc50a5ad37..94949c7bff 100644 --- a/lib/compiler_rt/floatunsidf.zig +++ b/lib/compiler_rt/floatunsidf.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_aeabi) { - @export(&__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_ui2d, "__aeabi_ui2d"); } else { - @export(&__floatunsidf, .{ .name = "__floatunsidf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatunsidf, "__floatunsidf"); } } diff --git a/lib/compiler_rt/floatunsisf.zig b/lib/compiler_rt/floatunsisf.zig index 72ac1a5901..04da1aa5c0 100644 --- a/lib/compiler_rt/floatunsisf.zig +++ b/lib/compiler_rt/floatunsisf.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const floatFromInt = @import("./float_from_int.zig").floatFromInt; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_ui2f, "__aeabi_ui2f"); } else { symbol(&__floatunsisf, "__floatunsisf"); diff --git a/lib/compiler_rt/floatunsitf.zig b/lib/compiler_rt/floatunsitf.zig index 6ad2ca5c56..6a5607c147 100644 --- a/lib/compiler_rt/floatunsitf.zig +++ b/lib/compiler_rt/floatunsitf.zig @@ -1,11 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const floatFromInt = @import("./float_from_int.zig").floatFromInt; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&__floatunsitf, "__floatunsikf"); - } else if (common.want_sparc_abi) { + } else if (compiler_rt.want_sparc_abi) { symbol(&_Qp_uitoq, "_Qp_uitoq"); } symbol(&__floatunsitf, "__floatunsitf"); diff --git a/lib/compiler_rt/floatunsixf.zig b/lib/compiler_rt/floatunsixf.zig index 875d3476fa..906f0270f5 100644 --- a/lib/compiler_rt/floatunsixf.zig +++ b/lib/compiler_rt/floatunsixf.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - @export(&__floatunsixf, .{ .name = "__floatunsixf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatunsixf, "__floatunsixf"); } fn __floatunsixf(a: u32) callconv(.c) f80 { diff --git a/lib/compiler_rt/floatuntidf.zig b/lib/compiler_rt/floatuntidf.zig index d2d34f5754..7e08a66b97 100644 --- a/lib/compiler_rt/floatuntidf.zig +++ b/lib/compiler_rt/floatuntidf.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const floatFromInt = @import("./float_from_int.zig").floatFromInt; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__floatuntidf_windows_x86_64, "__floatuntidf"); } else { symbol(&__floatuntidf, "__floatuntidf"); diff --git a/lib/compiler_rt/floatuntihf.zig b/lib/compiler_rt/floatuntihf.zig index 629e8088eb..5c50f39eaa 100644 --- a/lib/compiler_rt/floatuntihf.zig +++ b/lib/compiler_rt/floatuntihf.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__floatuntihf_windows_x86_64, "__floatuntihf"); } else { symbol(&__floatuntihf, "__floatuntihf"); diff --git a/lib/compiler_rt/floatuntisf.zig b/lib/compiler_rt/floatuntisf.zig index f79d2e5fed..5a15f7c19d 100644 --- a/lib/compiler_rt/floatuntisf.zig +++ b/lib/compiler_rt/floatuntisf.zig @@ -1,12 +1,13 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_windows_v2u64_abi) { - @export(&__floatuntisf_windows_x86_64, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__floatuntisf_windows_x86_64, "__floatuntisf"); } else { - @export(&__floatuntisf, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatuntisf, "__floatuntisf"); } } diff --git a/lib/compiler_rt/floatuntitf.zig b/lib/compiler_rt/floatuntitf.zig index 64063495b8..6df02c5bef 100644 --- a/lib/compiler_rt/floatuntitf.zig +++ b/lib/compiler_rt/floatuntitf.zig @@ -1,12 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const floatFromInt = @import("./float_from_int.zig").floatFromInt; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_windows_v2u64_abi) { + if (compiler_rt.want_windows_v2u64_abi) { symbol(&__floatuntitf_windows_x86_64, "__floatuntitf"); } else { - if (common.want_ppc_abi) + if (compiler_rt.want_ppc_abi) symbol(&__floatuntitf, "__floatuntikf"); symbol(&__floatuntitf, "__floatuntitf"); } diff --git a/lib/compiler_rt/floatuntixf.zig b/lib/compiler_rt/floatuntixf.zig index 12a561b573..27e668109f 100644 --- a/lib/compiler_rt/floatuntixf.zig +++ b/lib/compiler_rt/floatuntixf.zig @@ -1,12 +1,13 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const floatFromInt = @import("./float_from_int.zig").floatFromInt; comptime { - if (common.want_windows_v2u64_abi) { - @export(&__floatuntixf_windows_x86_64, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__floatuntixf_windows_x86_64, "__floatuntixf"); } else { - @export(&__floatuntixf, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__floatuntixf, "__floatuntixf"); } } diff --git a/lib/compiler_rt/floor_ceil.zig b/lib/compiler_rt/floor_ceil.zig index c44e9c2e57..f81d2e0011 100644 --- a/lib/compiler_rt/floor_ceil.zig +++ b/lib/compiler_rt/floor_ceil.zig @@ -14,7 +14,7 @@ const math = std.math; const mem = std.mem; const expect = std.testing.expect; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { @@ -23,7 +23,7 @@ comptime { symbol(&floorf, "floorf"); symbol(&floor, "floor"); symbol(&__floorx, "__floorx"); - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&floorq, "floorf128"); } symbol(&floorq, "floorq"); @@ -34,7 +34,7 @@ comptime { symbol(&ceilf, "ceilf"); symbol(&ceil, "ceil"); symbol(&__ceilx, "__ceilx"); - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&ceilq, "ceilf128"); } symbol(&ceilq, "ceilq"); @@ -106,11 +106,11 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T { if (e >= 0) { const m = (@as(U, 1) << @intCast(mantissa - e)) - 1; if (u & m == 0) return x; - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120); if (u >> bits - 1 == @intFromBool(op == .floor)) u += m; return @bitCast(u & ~m); } else { - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120); return switch (op) { .floor => if (u >> bits - 1 == 0) 0.0 else if (u << 1 != 0) -1.0 else x, .ceil => if (u >> bits - 1 != 0) -0.0 else if (u << 1 != 0) 1.0 else x, @@ -128,7 +128,7 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T { x - C + C - x; if (e <= bias - 1) { - if (common.want_float_exceptions) mem.doNotOptimizeAway(y); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(y); return switch (op) { .floor => if (positive) 0.0 else -1.0, .ceil => if (positive) 1.0 else -0.0, diff --git a/lib/compiler_rt/fma.zig b/lib/compiler_rt/fma.zig index cce9215f88..10926e9bde 100644 --- a/lib/compiler_rt/fma.zig +++ b/lib/compiler_rt/fma.zig @@ -8,18 +8,19 @@ const std = @import("std"); const math = std.math; const expect = std.testing.expect; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__fmah, .{ .name = "__fmah", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fmaf, .{ .name = "fmaf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fma, .{ .name = "fma", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__fmax, .{ .name = "__fmax", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&fmaq, .{ .name = "fmaf128", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fmah, "__fmah"); + symbol(&fmaf, "fmaf"); + symbol(&fma, "fma"); + symbol(&__fmax, "__fmax"); + if (compiler_rt.want_ppc_abi) { + symbol(&fmaq, "fmaf128"); } - @export(&fmaq, .{ .name = "fmaq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fmal, .{ .name = "fmal", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&fmaq, "fmaq"); + symbol(&fmal, "fmal"); } pub fn __fmah(x: f16, y: f16, z: f16) callconv(.c) f16 { diff --git a/lib/compiler_rt/fmax.zig b/lib/compiler_rt/fmax.zig index 19a7c3f6f7..606888d2d4 100644 --- a/lib/compiler_rt/fmax.zig +++ b/lib/compiler_rt/fmax.zig @@ -2,18 +2,19 @@ const std = @import("std"); const builtin = @import("builtin"); const math = std.math; const arch = builtin.cpu.arch; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__fmaxh, .{ .name = "__fmaxh", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fmaxf, .{ .name = "fmaxf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fmax, .{ .name = "fmax", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&fmaxq, .{ .name = "fmaxf128", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fmaxh, "__fmaxh"); + symbol(&fmaxf, "fmaxf"); + symbol(&fmax, "fmax"); + symbol(&__fmaxx, "__fmaxx"); + if (compiler_rt.want_ppc_abi) { + symbol(&fmaxq, "fmaxf128"); } - @export(&fmaxq, .{ .name = "fmaxq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fmaxl, .{ .name = "fmaxl", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&fmaxq, "fmaxq"); + symbol(&fmaxl, "fmaxl"); } pub fn __fmaxh(x: f16, y: f16) callconv(.c) f16 { diff --git a/lib/compiler_rt/fmin.zig b/lib/compiler_rt/fmin.zig index aa54ba6e0b..bea1779476 100644 --- a/lib/compiler_rt/fmin.zig +++ b/lib/compiler_rt/fmin.zig @@ -2,18 +2,19 @@ const std = @import("std"); const builtin = @import("builtin"); const math = std.math; const arch = builtin.cpu.arch; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__fminh, .{ .name = "__fminh", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fminf, .{ .name = "fminf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fmin, .{ .name = "fmin", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__fminx, .{ .name = "__fminx", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&fminq, .{ .name = "fminf128", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fminh, "__fminh"); + symbol(&fminf, "fminf"); + symbol(&fmin, "fmin"); + symbol(&__fminx, "__fminx"); + if (compiler_rt.want_ppc_abi) { + symbol(&fminq, "fminf128"); } - @export(&fminq, .{ .name = "fminq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fminl, .{ .name = "fminl", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&fminq, "fminq"); + symbol(&fminl, "fminl"); } pub fn __fminh(x: f16, y: f16) callconv(.c) f16 { diff --git a/lib/compiler_rt/fmod.zig b/lib/compiler_rt/fmod.zig index ae5abaae65..c2108abf33 100644 --- a/lib/compiler_rt/fmod.zig +++ b/lib/compiler_rt/fmod.zig @@ -3,19 +3,20 @@ const std = @import("std"); const math = std.math; const assert = std.debug.assert; const arch = builtin.cpu.arch; -const common = @import("common.zig"); -const normalize = common.normalize; +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; +const normalize = compiler_rt.normalize; comptime { - @export(&__fmodh, .{ .name = "__fmodh", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fmodf, .{ .name = "fmodf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fmod, .{ .name = "fmod", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__fmodx, .{ .name = "__fmodx", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&fmodq, .{ .name = "fmodf128", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__fmodh, "__fmodh"); + symbol(&fmodf, "fmodf"); + symbol(&fmod, "fmod"); + symbol(&__fmodx, "__fmodx"); + if (compiler_rt.want_ppc_abi) { + symbol(&fmodq, "fmodf128"); } - @export(&fmodq, .{ .name = "fmodq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&fmodl, .{ .name = "fmodl", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&fmodq, "fmodq"); + symbol(&fmodl, "fmodl"); } pub fn __fmodh(x: f16, y: f16) callconv(.c) f16 { diff --git a/lib/compiler_rt/gedf2.zig b/lib/compiler_rt/gedf2.zig index bd16de17f8..a37fb27bd3 100644 --- a/lib/compiler_rt/gedf2.zig +++ b/lib/compiler_rt/gedf2.zig @@ -1,11 +1,11 @@ ///! The quoted behavior definitions are from ///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const comparef = @import("./comparef.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_dcmpge, "__aeabi_dcmpge"); symbol(&__aeabi_dcmpgt, "__aeabi_dcmpgt"); } else { diff --git a/lib/compiler_rt/gesf2.zig b/lib/compiler_rt/gesf2.zig index d4b6a23c66..49454c4694 100644 --- a/lib/compiler_rt/gesf2.zig +++ b/lib/compiler_rt/gesf2.zig @@ -1,15 +1,16 @@ ///! The quoted behavior definitions are from ///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const comparef = @import("./comparef.zig"); comptime { - if (common.want_aeabi) { - @export(&__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_fcmpge, "__aeabi_fcmpge"); + symbol(&__aeabi_fcmpgt, "__aeabi_fcmpgt"); } else { - @export(&__gesf2, .{ .name = "__gesf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__gtsf2, .{ .name = "__gtsf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__gesf2, "__gesf2"); + symbol(&__gtsf2, "__gtsf2"); } } diff --git a/lib/compiler_rt/getf2.zig b/lib/compiler_rt/getf2.zig index a6014b365e..4476ab636c 100644 --- a/lib/compiler_rt/getf2.zig +++ b/lib/compiler_rt/getf2.zig @@ -1,18 +1,19 @@ ///! The quoted behavior definitions are from ///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const comparef = @import("./comparef.zig"); comptime { - if (common.want_ppc_abi) { - @export(&__getf2, .{ .name = "__gekf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { + if (compiler_rt.want_ppc_abi) { + symbol(&__getf2, "__gekf2"); + symbol(&__gttf2, "__gtkf2"); + } else if (compiler_rt.want_sparc_abi) { // These exports are handled in cmptf2.zig because gt and ge on sparc // are based on calling _Qp_cmp. } - @export(&__getf2, .{ .name = "__getf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__gttf2, .{ .name = "__gttf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__getf2, "__getf2"); + symbol(&__gttf2, "__gttf2"); } /// "These functions return a value greater than or equal to zero if neither diff --git a/lib/compiler_rt/hexagon.zig b/lib/compiler_rt/hexagon.zig index de7fd96491..2a4b8b75f7 100644 --- a/lib/compiler_rt/hexagon.zig +++ b/lib/compiler_rt/hexagon.zig @@ -1,5 +1,7 @@ const builtin = @import("builtin"); -const common = @import("./common.zig"); + +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; fn __hexagon_divsi3() callconv(.naked) noreturn { asm volatile ( @@ -1759,29 +1761,29 @@ fn __hexagon_sqrtdf2() align(32) callconv(.naked) noreturn { comptime { if (builtin.cpu.arch == .hexagon) { - @export(&__hexagon_adddf3, .{ .name = "__hexagon_adddf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_adddf3, .{ .name = "__hexagon_fast_adddf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_subdf3, .{ .name = "__hexagon_subdf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_subdf3, .{ .name = "__hexagon_fast_subdf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_divdf3, .{ .name = "__hexagon_divdf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_divdf3, .{ .name = "__hexagon_fast_divdf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_muldf3, .{ .name = "__hexagon_muldf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_muldf3, .{ .name = "__hexagon_fast_muldf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_sqrtdf2, .{ .name = "__hexagon_sqrtdf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_sqrtdf2, .{ .name = "__hexagon_fast2_sqrtdf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_sqrtdf2, .{ .name = "__hexagon_sqrt", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_divsf3, .{ .name = "__hexagon_divsf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_divsf3, .{ .name = "__hexagon_fast_divsf3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_divsi3, .{ .name = "__hexagon_divsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_umodsi3, .{ .name = "__hexagon_umodsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_sqrtf, .{ .name = "__hexagon_sqrtf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_sqrtf, .{ .name = "__hexagon_fast2_sqrtf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_moddi3, .{ .name = "__hexagon_moddi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_divdi3, .{ .name = "__hexagon_divdi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_udivdi3, .{ .name = "__hexagon_udivdi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_umoddi3, .{ .name = "__hexagon_umoddi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_modsi3, .{ .name = "__hexagon_modsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes, .{ .name = "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__hexagon_udivsi3, .{ .name = "__hexagon_udivsi3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__hexagon_adddf3, "__hexagon_adddf3"); + symbol(&__hexagon_adddf3, "__hexagon_fast_adddf3"); + symbol(&__hexagon_subdf3, "__hexagon_subdf3"); + symbol(&__hexagon_subdf3, "__hexagon_fast_subdf3"); + symbol(&__hexagon_divdf3, "__hexagon_divdf3"); + symbol(&__hexagon_divdf3, "__hexagon_fast_divdf3"); + symbol(&__hexagon_muldf3, "__hexagon_muldf3"); + symbol(&__hexagon_muldf3, "__hexagon_fast_muldf3"); + symbol(&__hexagon_sqrtdf2, "__hexagon_sqrtdf2"); + symbol(&__hexagon_sqrtdf2, "__hexagon_fast2_sqrtdf2"); + symbol(&__hexagon_sqrtdf2, "__hexagon_sqrt"); + symbol(&__hexagon_divsf3, "__hexagon_divsf3"); + symbol(&__hexagon_divsf3, "__hexagon_fast_divsf3"); + symbol(&__hexagon_divsi3, "__hexagon_divsi3"); + symbol(&__hexagon_umodsi3, "__hexagon_umodsi3"); + symbol(&__hexagon_sqrtf, "__hexagon_sqrtf"); + symbol(&__hexagon_sqrtf, "__hexagon_fast2_sqrtf"); + symbol(&__hexagon_moddi3, "__hexagon_moddi3"); + symbol(&__hexagon_divdi3, "__hexagon_divdi3"); + symbol(&__hexagon_udivdi3, "__hexagon_udivdi3"); + symbol(&__hexagon_umoddi3, "__hexagon_umoddi3"); + symbol(&__hexagon_modsi3, "__hexagon_modsi3"); + symbol(&__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes, "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes"); + symbol(&__hexagon_udivsi3, "__hexagon_udivsi3"); } } diff --git a/lib/compiler_rt/int.zig b/lib/compiler_rt/int.zig index 01827cf640..48c900207b 100644 --- a/lib/compiler_rt/int.zig +++ b/lib/compiler_rt/int.zig @@ -8,16 +8,16 @@ const testing = std.testing; const maxInt = std.math.maxInt; const minInt = std.math.minInt; -const common = @import("common.zig"); -const symbol = @import("../compiler_rt.zig").symbol; +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const udivmod = @import("udivmod.zig").udivmod; -const __divti3 = @import("divti3.zig").__divti3; +const __divti3 = @import("udivmod.zig").__divti3; comptime { symbol(&__divmodti4, "__divmodti4"); symbol(&__udivmoddi4, "__udivmoddi4"); symbol(&__divmoddi4, "__divmoddi4"); - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_idiv, "__aeabi_idiv"); symbol(&__aeabi_uidiv, "__aeabi_uidiv"); } else { diff --git a/lib/compiler_rt/int_from_float.zig b/lib/compiler_rt/int_from_float.zig index 1f1cdb215f..146456fd11 100644 --- a/lib/compiler_rt/int_from_float.zig +++ b/lib/compiler_rt/int_from_float.zig @@ -1,13 +1,58 @@ const std = @import("std"); -const Int = std.meta.Int; const math = std.math; -const Log2Int = math.Log2Int; +const Log2Int = std.math.Log2Int; + +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; + +comptime { + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__fixxfti_windows_x86_64, "__fixxfti"); + } else { + symbol(&__fixxfti, "__fixxfti"); + } + + symbol(&__fixhfsi, "__fixhfsi"); + symbol(&__fixhfdi, "__fixhfdi"); + + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__fixhfti_windows_x86_64, "__fixhfti"); + } else { + symbol(&__fixhfti, "__fixhfti"); + } +} + +const v2u64 = @Vector(2, u64); + +pub fn __fixhfti(a: f16) callconv(.c) i128 { + return intFromFloat(i128, a); +} + +fn __fixhfti_windows_x86_64(a: f16) callconv(.c) v2u64 { + return @bitCast(intFromFloat(i128, a)); +} + +fn __fixhfdi(a: f16) callconv(.c) i64 { + return intFromFloat(i64, a); +} + +fn __fixhfsi(a: f16) callconv(.c) i32 { + return intFromFloat(i32, a); +} + +pub fn __fixxfti(a: f80) callconv(.c) i128 { + return intFromFloat(i128, a); +} + +fn __fixxfti_windows_x86_64(a: f80) callconv(.c) v2u64 { + return @bitCast(intFromFloat(i128, a)); +} pub inline fn intFromFloat(comptime I: type, a: anytype) I { const F = @TypeOf(a); const float_bits = @typeInfo(F).float.bits; const int_bits = @typeInfo(I).int.bits; - const rep_t = Int(.unsigned, float_bits); + const rep_t = @Int(.unsigned, float_bits); const sig_bits = math.floatMantissaBits(F); const exp_bits = math.floatExponentBits(F); const fractional_bits = math.floatFractionalBits(F); diff --git a/lib/compiler_rt/log.zig b/lib/compiler_rt/log.zig index 96dd319f72..0cd2a00ddb 100644 --- a/lib/compiler_rt/log.zig +++ b/lib/compiler_rt/log.zig @@ -9,7 +9,7 @@ const math = std.math; const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { @@ -17,7 +17,7 @@ comptime { symbol(&logf, "logf"); symbol(&log, "log"); symbol(&__logx, "__logx"); - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&logq, "logf128"); } symbol(&logq, "logq"); @@ -45,11 +45,11 @@ pub fn logf(x_: f32) callconv(.c) f32 { if (ix < 0x00800000 or ix >> 31 != 0) { // log(+-0) = -inf if (ix << 1 == 0) { - return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); + return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); } // log(-#) = nan if (ix >> 31 != 0) { - return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); + return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); } // subnormal, scale x @@ -398,13 +398,13 @@ pub fn log(x: f64) callconv(.c) f64 { @branchHint(.unlikely); if (ix << 1 == 0) - return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); + return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); if (ix == @as(i64, @bitCast(std.math.inf(f64)))) return x; if (top & 0x8000 != 0 or top & 0x7ff0 == 0x7ff0) - return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); + return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); ix = @as(i64, @bitCast(x * 0x1p52)) - (52 << 52); } diff --git a/lib/compiler_rt/log10.zig b/lib/compiler_rt/log10.zig index d2741e3b23..ec4edac618 100644 --- a/lib/compiler_rt/log10.zig +++ b/lib/compiler_rt/log10.zig @@ -10,7 +10,7 @@ const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const maxInt = std.math.maxInt; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { @@ -18,7 +18,7 @@ comptime { symbol(&log10f, "log10f"); symbol(&log10, "log10"); symbol(&__log10x, "__log10x"); - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&log10q, "log10f128"); } symbol(&log10q, "log10q"); @@ -49,11 +49,11 @@ pub fn log10f(x_: f32) callconv(.c) f32 { if (ix < 0x00800000 or ix >> 31 != 0) { // log(+-0) = -inf if (ix << 1 == 0) { - return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); + return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); } // log(-#) = nan if (ix >> 31 != 0) { - return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); + return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); } k -= 25; @@ -111,11 +111,11 @@ pub fn log10(x_: f64) callconv(.c) f64 { if (hx < 0x00100000 or hx >> 31 != 0) { // log(+-0) = -inf if (ix << 1 == 0) { - return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); + return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); } // log(-#) = nan if (hx >> 31 != 0) { - return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); + return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); } // subnormal, scale x diff --git a/lib/compiler_rt/log2.zig b/lib/compiler_rt/log2.zig index 48ff6135d8..ad17df7f65 100644 --- a/lib/compiler_rt/log2.zig +++ b/lib/compiler_rt/log2.zig @@ -11,18 +11,19 @@ const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const maxInt = std.math.maxInt; const arch = builtin.cpu.arch; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__log2h, .{ .name = "__log2h", .linkage = common.linkage, .visibility = common.visibility }); - @export(&log2f, .{ .name = "log2f", .linkage = common.linkage, .visibility = common.visibility }); - @export(&log2, .{ .name = "log2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__log2x, .{ .name = "__log2x", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&log2q, .{ .name = "log2f128", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__log2h, "__log2h"); + symbol(&log2f, "log2f"); + symbol(&log2, "log2"); + symbol(&__log2x, "__log2x"); + if (compiler_rt.want_ppc_abi) { + symbol(&log2q, "log2f128"); } - @export(&log2q, .{ .name = "log2q", .linkage = common.linkage, .visibility = common.visibility }); - @export(&log2l, .{ .name = "log2l", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&log2q, "log2q"); + symbol(&log2l, "log2l"); } pub fn __log2h(a: f16) callconv(.c) f16 { @@ -47,11 +48,11 @@ pub fn log2f(x_: f32) callconv(.c) f32 { if (ix < 0x00800000 or ix >> 31 != 0) { // log(+-0) = -inf if (ix << 1 == 0) { - return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); + return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); } // log(-#) = nan if (ix >> 31 != 0) { - return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); + return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); } k -= 25; @@ -105,11 +106,11 @@ pub fn log2(x_: f64) callconv(.c) f64 { if (hx < 0x00100000 or hx >> 31 != 0) { // log(+-0) = -inf if (ix << 1 == 0) { - return if (common.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); + return if (compiler_rt.want_float_exceptions) -1 / (x * x) else -std.math.inf(f64); } // log(-#) = nan if (hx >> 31 != 0) { - return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); + return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); } // subnormal, scale x diff --git a/lib/compiler_rt/memcpy.zig b/lib/compiler_rt/memcpy.zig index 4dcd184d29..bb3c91eea8 100644 --- a/lib/compiler_rt/memcpy.zig +++ b/lib/compiler_rt/memcpy.zig @@ -1,14 +1,14 @@ const std = @import("std"); const assert = std.debug.assert; -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const builtin = @import("builtin"); comptime { if (builtin.object_format != .c) { const export_options: std.builtin.ExportOptions = .{ .name = "memcpy", - .linkage = common.linkage, - .visibility = common.visibility, + .linkage = compiler_rt.linkage, + .visibility = compiler_rt.visibility, }; if (builtin.mode == .ReleaseSmall or builtin.zig_backend == .stage2_aarch64) @@ -18,7 +18,7 @@ comptime { } } -const Element = common.PreferredLoadStoreElement; +const Element = compiler_rt.PreferredLoadStoreElement; comptime { assert(std.math.isPowerOfTwo(@sizeOf(Element))); diff --git a/lib/compiler_rt/memmove.zig b/lib/compiler_rt/memmove.zig index c57ba9c3cc..ad501e758a 100644 --- a/lib/compiler_rt/memmove.zig +++ b/lib/compiler_rt/memmove.zig @@ -1,17 +1,17 @@ const std = @import("std"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const builtin = @import("builtin"); const assert = std.debug.assert; const memcpy = @import("memcpy.zig"); -const Element = common.PreferredLoadStoreElement; +const Element = compiler_rt.PreferredLoadStoreElement; comptime { if (builtin.object_format != .c) { const export_options: std.builtin.ExportOptions = .{ .name = "memmove", - .linkage = common.linkage, - .visibility = common.visibility, + .linkage = compiler_rt.linkage, + .visibility = compiler_rt.visibility, }; if (builtin.mode == .ReleaseSmall or builtin.zig_backend == .stage2_aarch64) @@ -39,7 +39,7 @@ fn memmoveSmall(opt_dest: ?[*]u8, opt_src: ?[*]const u8, len: usize) callconv(.c } fn memmoveFast(dest: ?[*]u8, src: ?[*]u8, len: usize) callconv(.c) ?[*]u8 { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); const small_limit = @max(2 * @sizeOf(Element), @sizeOf(Element)); if (copySmallLength(small_limit, dest.?, src.?, len)) return dest; @@ -79,7 +79,7 @@ inline fn copyLessThan16( src: [*]const u8, len: usize, ) void { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); if (len < 4) { if (len == 0) return; const b = len / 2; @@ -100,7 +100,7 @@ inline fn copy16ToSmallLimit( src: [*]const u8, len: usize, ) bool { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); inline for (2..(std.math.log2(small_limit) + 1) / 2 + 1) |p| { const limit = 1 << (2 * p); if (len < limit) { @@ -119,7 +119,7 @@ inline fn copyRange4( src: [*]const u8, len: usize, ) void { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); comptime assert(std.math.isPowerOfTwo(copy_len)); assert(len >= copy_len); assert(len < 4 * copy_len); @@ -147,7 +147,7 @@ inline fn copyForwards( src: [*]const u8, len: usize, ) void { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); assert(len >= 2 * @sizeOf(Element)); const head = src[0..@sizeOf(Element)].*; @@ -181,7 +181,7 @@ inline fn copyBlocks( src: anytype, max_bytes: usize, ) void { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); const T = @typeInfo(@TypeOf(dest)).pointer.child; comptime assert(T == @typeInfo(@TypeOf(src)).pointer.child); diff --git a/lib/compiler_rt/memset.zig b/lib/compiler_rt/memset.zig deleted file mode 100644 index 6b51037b57..0000000000 --- a/lib/compiler_rt/memset.zig +++ /dev/null @@ -1,33 +0,0 @@ -const std = @import("std"); -const common = @import("./common.zig"); -const builtin = @import("builtin"); - -comptime { - if (builtin.object_format != .c) { - @export(&memset, .{ .name = "memset", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__memset, .{ .name = "__memset", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -pub fn memset(dest: ?[*]u8, c: u8, len: usize) callconv(.c) ?[*]u8 { - @setRuntimeSafety(false); - - if (len != 0) { - var d = dest.?; - var n = len; - while (true) { - d[0] = c; - n -= 1; - if (n == 0) break; - d += 1; - } - } - - return dest; -} - -pub fn __memset(dest: ?[*]u8, c: u8, n: usize, dest_n: usize) callconv(.c) ?[*]u8 { - if (dest_n < n) - @panic("buffer overflow"); - return memset(dest, c, n); -} diff --git a/lib/compiler_rt/modti3.zig b/lib/compiler_rt/modti3.zig deleted file mode 100644 index 74e431a061..0000000000 --- a/lib/compiler_rt/modti3.zig +++ /dev/null @@ -1,42 +0,0 @@ -//! Ported from: -//! -//! https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/modti3.c - -const std = @import("std"); -const builtin = @import("builtin"); -const udivmod = @import("udivmod.zig").udivmod; -const common = @import("common.zig"); - -comptime { - if (common.want_windows_v2u64_abi) { - @export(&__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__modti3, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -pub fn __modti3(a: i128, b: i128) callconv(.c) i128 { - return mod(a, b); -} - -const v2u64 = @Vector(2, u64); - -fn __modti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 { - return @bitCast(mod(@as(i128, @bitCast(a)), @as(i128, @bitCast(b)))); -} - -inline fn mod(a: i128, b: i128) i128 { - const s_a = a >> (128 - 1); // s = a < 0 ? -1 : 0 - const s_b = b >> (128 - 1); // s = b < 0 ? -1 : 0 - - const an = (a ^ s_a) -% s_a; // negate if s == -1 - const bn = (b ^ s_b) -% s_b; // negate if s == -1 - - var r: u128 = undefined; - _ = udivmod(u128, @as(u128, @bitCast(an)), @as(u128, @bitCast(bn)), &r); - return (@as(i128, @bitCast(r)) ^ s_a) -% s_a; // negate if s == -1 -} - -test { - _ = @import("modti3_test.zig"); -} diff --git a/lib/compiler_rt/modti3_test.zig b/lib/compiler_rt/modti3_test.zig index 800547b48b..6959e09dcc 100644 --- a/lib/compiler_rt/modti3_test.zig +++ b/lib/compiler_rt/modti3_test.zig @@ -1,4 +1,4 @@ -const __modti3 = @import("modti3.zig").__modti3; +const __modti3 = @import("udivmod.zig").__modti3; const testing = @import("std").testing; fn test__modti3(a: i128, b: i128, expected: i128) !void { diff --git a/lib/compiler_rt/mulXi3.zig b/lib/compiler_rt/mulXi3.zig index 198d51c888..41df7283ea 100644 --- a/lib/compiler_rt/mulXi3.zig +++ b/lib/compiler_rt/mulXi3.zig @@ -1,20 +1,21 @@ const builtin = @import("builtin"); const std = @import("std"); const testing = std.testing; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const native_endian = builtin.cpu.arch.endian(); comptime { - @export(&__mulsi3, .{ .name = "__mulsi3", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_aeabi) { - @export(&__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__mulsi3, "__mulsi3"); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_lmul, "__aeabi_lmul"); } else { - @export(&__muldi3, .{ .name = "__muldi3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__muldi3, "__muldi3"); } - if (common.want_windows_v2u64_abi) { - @export(&__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__multi3_windows_x86_64, "__multi3"); } else { - @export(&__multi3, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__multi3, "__multi3"); } } @@ -41,7 +42,7 @@ fn __aeabi_lmul(a: i64, b: i64) callconv(.{ .arm_aapcs = .{} }) i64 { } inline fn mulX(comptime T: type, a: T, b: T) T { - const word_t = common.HalveInt(T, false); + const word_t = compiler_rt.HalveInt(T, false); const x = word_t{ .all = a }; const y = word_t{ .all = b }; var r = switch (T) { @@ -64,7 +65,7 @@ fn DoubleInt(comptime T: type) type { fn muldXi(comptime T: type, a: T, b: T) DoubleInt(T) { const DT = DoubleInt(T); - const word_t = common.HalveInt(DT, false); + const word_t = compiler_rt.HalveInt(DT, false); const bits_in_word_2 = @sizeOf(T) * 8 / 2; const lower_mask = (~@as(T, 0)) >> bits_in_word_2; diff --git a/lib/compiler_rt/muldf3.zig b/lib/compiler_rt/muldf3.zig index e9c978430e..b8809e76da 100644 --- a/lib/compiler_rt/muldf3.zig +++ b/lib/compiler_rt/muldf3.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const mulf3 = @import("./mulf3.zig").mulf3; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_dmul, "__aeabi_dmul"); } else { symbol(&__muldf3, "__muldf3"); diff --git a/lib/compiler_rt/mulf3.zig b/lib/compiler_rt/mulf3.zig index 34d39fb9b7..d85b0bf8d5 100644 --- a/lib/compiler_rt/mulf3.zig +++ b/lib/compiler_rt/mulf3.zig @@ -1,12 +1,12 @@ const std = @import("std"); const math = std.math; const builtin = @import("builtin"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); /// Ported from: /// https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/fp_mul_impl.inc pub inline fn mulf3(comptime T: type, a: T, b: T) T { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); const typeWidth = @typeInfo(T).float.bits; const significandBits = math.floatMantissaBits(T); const fractionalBits = math.floatFractionalBits(T); @@ -97,7 +97,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T { var productHi: ZSignificand = undefined; var productLo: ZSignificand = undefined; const left_align_shift = ZSignificandBits - fractionalBits - 1; - common.wideMultiply(ZSignificand, aSignificand, bSignificand << left_align_shift, &productHi, &productLo); + compiler_rt.wideMultiply(ZSignificand, aSignificand, bSignificand << left_align_shift, &productHi, &productLo); var productExponent: i32 = @as(i32, @intCast(aExponent + bExponent)) - exponentBias + scale; @@ -163,7 +163,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T { /// /// This is analogous to an shr version of `@shlWithOverflow` fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); const typeWidth = @typeInfo(Z).int.bits; var inexact = false; if (count < typeWidth) { diff --git a/lib/compiler_rt/mulhc3.zig b/lib/compiler_rt/mulhc3.zig index 09bca03a05..4e0d3f8753 100644 --- a/lib/compiler_rt/mulhc3.zig +++ b/lib/compiler_rt/mulhc3.zig @@ -1,9 +1,10 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const mulc3 = @import("./mulc3.zig"); comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(&__mulhc3, .{ .name = "__mulhc3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__mulhc3, "__mulhc3"); } } diff --git a/lib/compiler_rt/mulhf3.zig b/lib/compiler_rt/mulhf3.zig index 22f7a95627..46ce7a6b99 100644 --- a/lib/compiler_rt/mulhf3.zig +++ b/lib/compiler_rt/mulhf3.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const mulf3 = @import("./mulf3.zig").mulf3; comptime { - @export(&__mulhf3, .{ .name = "__mulhf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__mulhf3, "__mulhf3"); } pub fn __mulhf3(a: f16, b: f16) callconv(.c) f16 { diff --git a/lib/compiler_rt/mulo.zig b/lib/compiler_rt/mulo.zig index b85623eb7e..979a5452a5 100644 --- a/lib/compiler_rt/mulo.zig +++ b/lib/compiler_rt/mulo.zig @@ -1,12 +1,13 @@ const std = @import("std"); const builtin = @import("builtin"); const math = std.math; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__mulosi4, .{ .name = "__mulosi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__mulodi4, .{ .name = "__mulodi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__muloti4, .{ .name = "__muloti4", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__mulosi4, "__mulosi4"); + symbol(&__mulodi4, "__mulodi4"); + symbol(&__muloti4, "__muloti4"); } // mulo - multiplication overflow diff --git a/lib/compiler_rt/mulsf3.zig b/lib/compiler_rt/mulsf3.zig index a603652262..81f9eafae2 100644 --- a/lib/compiler_rt/mulsf3.zig +++ b/lib/compiler_rt/mulsf3.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const mulf3 = @import("./mulf3.zig").mulf3; comptime { - if (common.want_aeabi) { - @export(&__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_fmul, "__aeabi_fmul"); } else { - @export(&__mulsf3, .{ .name = "__mulsf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__mulsf3, "__mulsf3"); } } diff --git a/lib/compiler_rt/multc3.zig b/lib/compiler_rt/multc3.zig index 13870c6465..4914735b10 100644 --- a/lib/compiler_rt/multc3.zig +++ b/lib/compiler_rt/multc3.zig @@ -1,10 +1,10 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const mulc3 = @import("./mulc3.zig"); comptime { if (@import("builtin").zig_backend != .stage2_c) { - if (common.want_ppc_abi) + if (compiler_rt.want_ppc_abi) symbol(&__multc3, "__mulkc3"); symbol(&__multc3, "__multc3"); } diff --git a/lib/compiler_rt/multf3.zig b/lib/compiler_rt/multf3.zig index 6ef9cc2c25..3befe34da0 100644 --- a/lib/compiler_rt/multf3.zig +++ b/lib/compiler_rt/multf3.zig @@ -1,13 +1,14 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const mulf3 = @import("./mulf3.zig").mulf3; comptime { - if (common.want_ppc_abi) { - @export(&__multf3, .{ .name = "__mulkf3", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__multf3, "__mulkf3"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_mul, "_Qp_mul"); } - @export(&__multf3, .{ .name = "__multf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__multf3, "__multf3"); } pub fn __multf3(a: f128, b: f128) callconv(.c) f128 { diff --git a/lib/compiler_rt/mulxc3.zig b/lib/compiler_rt/mulxc3.zig index cbf9c64083..ac0e189f63 100644 --- a/lib/compiler_rt/mulxc3.zig +++ b/lib/compiler_rt/mulxc3.zig @@ -1,9 +1,10 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const mulc3 = @import("./mulc3.zig"); comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(&__mulxc3, .{ .name = "__mulxc3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__mulxc3, "__mulxc3"); } } diff --git a/lib/compiler_rt/mulxf3.zig b/lib/compiler_rt/mulxf3.zig index 1d9f465ebd..dcf783a4a6 100644 --- a/lib/compiler_rt/mulxf3.zig +++ b/lib/compiler_rt/mulxf3.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const mulf3 = @import("./mulf3.zig").mulf3; comptime { - @export(&__mulxf3, .{ .name = "__mulxf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__mulxf3, "__mulxf3"); } pub fn __mulxf3(a: f80, b: f80) callconv(.c) f80 { diff --git a/lib/compiler_rt/negXi2.zig b/lib/compiler_rt/negXi2.zig deleted file mode 100644 index 7a57e988c6..0000000000 --- a/lib/compiler_rt/negXi2.zig +++ /dev/null @@ -1,39 +0,0 @@ -//! neg - negate (the number) -//! - negXi2 for unoptimized little and big endian -//! sfffffff = 2^31-1 -//! two's complement inverting bits and add 1 would result in -INT_MIN == 0 -//! => -INT_MIN = -2^31 forbidden -//! * size optimized builds -//! * machines that dont support carry operations - -const std = @import("std"); -const builtin = @import("builtin"); -const common = @import("common.zig"); - -comptime { - @export(&__negsi2, .{ .name = "__negsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__negdi2, .{ .name = "__negdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__negti2, .{ .name = "__negti2", .linkage = common.linkage, .visibility = common.visibility }); -} - -pub fn __negsi2(a: i32) callconv(.c) i32 { - return negXi2(i32, a); -} - -pub fn __negdi2(a: i64) callconv(.c) i64 { - return negXi2(i64, a); -} - -pub fn __negti2(a: i128) callconv(.c) i128 { - return negXi2(i128, a); -} - -inline fn negXi2(comptime T: type, a: T) T { - return -a; -} - -test { - _ = @import("negsi2_test.zig"); - _ = @import("negdi2_test.zig"); - _ = @import("negti2_test.zig"); -} diff --git a/lib/compiler_rt/negdf2.zig b/lib/compiler_rt/negdf2.zig deleted file mode 100644 index b0ac26e6c0..0000000000 --- a/lib/compiler_rt/negdf2.zig +++ /dev/null @@ -1,17 +0,0 @@ -const common = @import("./common.zig"); - -comptime { - if (common.want_aeabi) { - @export(&__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__negdf2, .{ .name = "__negdf2", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -fn __negdf2(a: f64) callconv(.c) f64 { - return common.fneg(a); -} - -fn __aeabi_dneg(a: f64) callconv(.{ .arm_aapcs = .{} }) f64 { - return common.fneg(a); -} diff --git a/lib/compiler_rt/negdi2_test.zig b/lib/compiler_rt/negdi2_test.zig index a4bb0217ad..2a3a966193 100644 --- a/lib/compiler_rt/negdi2_test.zig +++ b/lib/compiler_rt/negdi2_test.zig @@ -1,8 +1,10 @@ -const neg = @import("negXi2.zig"); -const testing = @import("std").testing; +const std = @import("std"); +const testing = std.testing; + +const compiler_rt = @import("../compiler_rt.zig"); fn test__negdi2(a: i64, expected: i64) !void { - const result = neg.__negdi2(a); + const result = compiler_rt.__negdi2(a); try testing.expectEqual(expected, result); } diff --git a/lib/compiler_rt/neghf2.zig b/lib/compiler_rt/neghf2.zig deleted file mode 100644 index 59c7e155b7..0000000000 --- a/lib/compiler_rt/neghf2.zig +++ /dev/null @@ -1,9 +0,0 @@ -const common = @import("./common.zig"); - -comptime { - @export(&__neghf2, .{ .name = "__neghf2", .linkage = common.linkage, .visibility = common.visibility }); -} - -fn __neghf2(a: f16) callconv(.c) f16 { - return common.fneg(a); -} diff --git a/lib/compiler_rt/negsf2.zig b/lib/compiler_rt/negsf2.zig deleted file mode 100644 index 065dc3acd1..0000000000 --- a/lib/compiler_rt/negsf2.zig +++ /dev/null @@ -1,17 +0,0 @@ -const common = @import("./common.zig"); - -comptime { - if (common.want_aeabi) { - @export(&__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__negsf2, .{ .name = "__negsf2", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -fn __negsf2(a: f32) callconv(.c) f32 { - return common.fneg(a); -} - -fn __aeabi_fneg(a: f32) callconv(.{ .arm_aapcs = .{} }) f32 { - return common.fneg(a); -} diff --git a/lib/compiler_rt/negsi2_test.zig b/lib/compiler_rt/negsi2_test.zig index 2584de2136..0eecd6a728 100644 --- a/lib/compiler_rt/negsi2_test.zig +++ b/lib/compiler_rt/negsi2_test.zig @@ -1,11 +1,12 @@ const std = @import("std"); -const neg = @import("negXi2.zig"); const testing = std.testing; +const compiler_rt = @import("../compiler_rt.zig"); + const print = std.debug.print; fn test__negsi2(a: i32, expected: i32) !void { - const result = neg.__negsi2(a); + const result = compiler_rt.__negsi2(a); try testing.expectEqual(expected, result); } diff --git a/lib/compiler_rt/negtf2.zig b/lib/compiler_rt/negtf2.zig deleted file mode 100644 index 9d981ce2ff..0000000000 --- a/lib/compiler_rt/negtf2.zig +++ /dev/null @@ -1,12 +0,0 @@ -const common = @import("./common.zig"); -const symbol = @import("../compiler_rt.zig").symbol; - -comptime { - if (common.want_ppc_abi) - symbol(&__negtf2, "__negkf2"); - symbol(&__negtf2, "__negtf2"); -} - -fn __negtf2(a: f128) callconv(.c) f128 { - return common.fneg(a); -} diff --git a/lib/compiler_rt/negti2_test.zig b/lib/compiler_rt/negti2_test.zig index d58f9c8f27..ea9e917312 100644 --- a/lib/compiler_rt/negti2_test.zig +++ b/lib/compiler_rt/negti2_test.zig @@ -1,8 +1,10 @@ -const neg = @import("negXi2.zig"); -const testing = @import("std").testing; +const std = @import("std"); +const testing = std.testing; + +const compiler_rt = @import("../compiler_rt.zig"); fn test__negti2(a: i128, expected: i128) !void { - const result = neg.__negti2(a); + const result = compiler_rt.__negti2(a); try testing.expectEqual(expected, result); } diff --git a/lib/compiler_rt/negv.zig b/lib/compiler_rt/negv.zig index 98934b78f4..7c67a51c34 100644 --- a/lib/compiler_rt/negv.zig +++ b/lib/compiler_rt/negv.zig @@ -3,12 +3,13 @@ //! - negvXi4_generic for unoptimized version const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__negvsi2, .{ .name = "__negvsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__negvdi2, .{ .name = "__negvdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__negvti2, .{ .name = "__negvti2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__negvsi2, "__negvsi2"); + symbol(&__negvdi2, "__negvdi2"); + symbol(&__negvti2, "__negvti2"); } pub fn __negvsi2(a: i32) callconv(.c) i32 { diff --git a/lib/compiler_rt/negxf2.zig b/lib/compiler_rt/negxf2.zig deleted file mode 100644 index ea16c8fef2..0000000000 --- a/lib/compiler_rt/negxf2.zig +++ /dev/null @@ -1,9 +0,0 @@ -const common = @import("./common.zig"); - -comptime { - @export(&__negxf2, .{ .name = "__negxf2", .linkage = common.linkage, .visibility = common.visibility }); -} - -fn __negxf2(a: f80) callconv(.c) f80 { - return common.fneg(a); -} diff --git a/lib/compiler_rt/os_version_check.zig b/lib/compiler_rt/os_version_check.zig index a2dc7f221e..e575fef9ce 100644 --- a/lib/compiler_rt/os_version_check.zig +++ b/lib/compiler_rt/os_version_check.zig @@ -1,15 +1,16 @@ const std = @import("std"); const testing = std.testing; const builtin = @import("builtin"); -const common = @import("common.zig"); -const panic = @import("common.zig").panic; +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; +const panic = @import("../compiler_rt.zig").panic; const have_availability_version_check = builtin.os.tag.isDarwin() and builtin.os.version_range.semver.min.order(.{ .major = 10, .minor = 15, .patch = 0 }).compare(.gte); comptime { if (have_availability_version_check) { - @export(&__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__isPlatformVersionAtLeast, "__isPlatformVersionAtLeast"); } } diff --git a/lib/compiler_rt/powiXf2.zig b/lib/compiler_rt/powiXf2.zig index 91767818bd..b2a1e3e698 100644 --- a/lib/compiler_rt/powiXf2.zig +++ b/lib/compiler_rt/powiXf2.zig @@ -3,14 +3,14 @@ //! Multiplication order (left-to-right or right-to-left) does not matter for //! error propagation and this method is optimized for performance, not accuracy. -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { symbol(&__powihf2, "__powihf2"); symbol(&__powisf2, "__powisf2"); symbol(&__powidf2, "__powidf2"); - if (common.want_ppc_abi) + if (compiler_rt.want_ppc_abi) symbol(&__powitf2, "__powikf2"); symbol(&__powitf2, "__powitf2"); symbol(&__powixf2, "__powixf2"); diff --git a/lib/compiler_rt/round.zig b/lib/compiler_rt/round.zig index b643bfd89f..8087fd6e15 100644 --- a/lib/compiler_rt/round.zig +++ b/lib/compiler_rt/round.zig @@ -10,18 +10,19 @@ const math = std.math; const mem = std.mem; const expect = std.testing.expect; const arch = builtin.cpu.arch; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__roundh, .{ .name = "__roundh", .linkage = common.linkage, .visibility = common.visibility }); - @export(&roundf, .{ .name = "roundf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&round, .{ .name = "round", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__roundx, .{ .name = "__roundx", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&roundq, .{ .name = "roundf128", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__roundh, "__roundh"); + symbol(&roundf, "roundf"); + symbol(&round, "round"); + symbol(&__roundx, "__roundx"); + if (compiler_rt.want_ppc_abi) { + symbol(&roundq, "roundf128"); } - @export(&roundq, .{ .name = "roundq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&roundl, .{ .name = "roundl", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&roundq, "roundq"); + symbol(&roundl, "roundl"); } pub fn __roundh(x: f16) callconv(.c) f16 { @@ -44,7 +45,7 @@ pub fn roundf(x_: f32) callconv(.c) f32 { x = -x; } if (e < 0x7F - 1) { - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + f32_toint); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + f32_toint); return 0 * @as(f32, @bitCast(u)); } @@ -79,7 +80,7 @@ pub fn round(x_: f64) callconv(.c) f64 { x = -x; } if (e < 0x3ff - 1) { - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + f64_toint); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + f64_toint); return 0 * @as(f64, @bitCast(u)); } @@ -119,7 +120,7 @@ pub fn roundq(x_: f128) callconv(.c) f128 { x = -x; } if (e < 0x3FFF - 1) { - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + f128_toint); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + f128_toint); return 0 * @as(f128, @bitCast(u)); } diff --git a/lib/compiler_rt/shift.zig b/lib/compiler_rt/shift.zig index 9c75bd3475..425ca2c69c 100644 --- a/lib/compiler_rt/shift.zig +++ b/lib/compiler_rt/shift.zig @@ -1,33 +1,34 @@ const std = @import("std"); const builtin = @import("builtin"); const Log2Int = std.math.Log2Int; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { // symbol compatibility with libgcc - @export(&__ashlsi3, .{ .name = "__ashlsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__ashrsi3, .{ .name = "__ashrsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__lshrsi3, .{ .name = "__lshrsi3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__ashlsi3, "__ashlsi3"); + symbol(&__ashrsi3, "__ashrsi3"); + symbol(&__lshrsi3, "__lshrsi3"); - @export(&__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__ashlti3, "__ashlti3"); + symbol(&__ashrti3, "__ashrti3"); + symbol(&__lshrti3, "__lshrti3"); - if (common.want_aeabi) { - @export(&__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_llsl, "__aeabi_llsl"); + symbol(&__aeabi_lasr, "__aeabi_lasr"); + symbol(&__aeabi_llsr, "__aeabi_llsr"); } else { - @export(&__ashldi3, .{ .name = "__ashldi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__ashrdi3, .{ .name = "__ashrdi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__lshrdi3, .{ .name = "__lshrdi3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__ashldi3, "__ashldi3"); + symbol(&__ashrdi3, "__ashrdi3"); + symbol(&__lshrdi3, "__lshrdi3"); } } // Arithmetic shift left: shift in 0 from right to left // Precondition: 0 <= b < bits_in_dword inline fn ashlXi3(comptime T: type, a: T, b: i32) T { - const word_t = common.HalveInt(T, false); + const word_t = compiler_rt.HalveInt(T, false); const input = word_t{ .all = a }; var output: word_t = undefined; @@ -49,7 +50,7 @@ inline fn ashlXi3(comptime T: type, a: T, b: i32) T { // Arithmetic shift right: shift in 1 from left to right // Precondition: 0 <= b < T.bit_count inline fn ashrXi3(comptime T: type, a: T, b: i32) T { - const word_t = common.HalveInt(T, true); + const word_t = compiler_rt.HalveInt(T, true); const input = word_t{ .all = a }; var output: word_t = undefined; @@ -72,7 +73,7 @@ inline fn ashrXi3(comptime T: type, a: T, b: i32) T { // Logical shift right: shift in 0 from left to right // Precondition: 0 <= b < T.bit_count inline fn lshrXi3(comptime T: type, a: T, b: i32) T { - const word_t = common.HalveInt(T, false); + const word_t = compiler_rt.HalveInt(T, false); const input = word_t{ .all = a }; var output: word_t = undefined; diff --git a/lib/compiler_rt/sin.zig b/lib/compiler_rt/sin.zig index ab1775d7ce..ef3709bc18 100644 --- a/lib/compiler_rt/sin.zig +++ b/lib/compiler_rt/sin.zig @@ -9,7 +9,7 @@ const math = std.math; const mem = std.mem; const expect = std.testing.expect; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const trig = @import("trig.zig"); const rem_pio2 = @import("rem_pio2.zig").rem_pio2; @@ -20,7 +20,7 @@ comptime { symbol(&sinf, "sinf"); symbol(&sin, "sin"); symbol(&__sinx, "__sinx"); - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&sinq, "sinf128"); } symbol(&sinq, "sinq"); @@ -46,7 +46,7 @@ pub fn sinf(x: f32) callconv(.c) f32 { if (ix <= 0x3f490fda) { // |x| ~<= pi/4 if (ix < 0x39800000) { // |x| < 2**-12 // raise inexact if x!=0 and underflow if subnormal - if (common.want_float_exceptions) { + if (compiler_rt.want_float_exceptions) { if (ix < 0x00800000) { mem.doNotOptimizeAway(x / 0x1p120); } else { @@ -101,7 +101,7 @@ pub fn sin(x: f64) callconv(.c) f64 { if (ix <= 0x3fe921fb) { if (ix < 0x3e500000) { // |x| < 2**-26 // raise inexact if x != 0 and underflow if subnormal - if (common.want_float_exceptions) { + if (compiler_rt.want_float_exceptions) { if (ix < 0x00100000) { mem.doNotOptimizeAway(x / 0x1p120); } else { diff --git a/lib/compiler_rt/sincos.zig b/lib/compiler_rt/sincos.zig index 46fec8ff64..6aeb1105e5 100644 --- a/lib/compiler_rt/sincos.zig +++ b/lib/compiler_rt/sincos.zig @@ -6,18 +6,19 @@ const mem = std.mem; const trig = @import("trig.zig"); const rem_pio2 = @import("rem_pio2.zig").rem_pio2; const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__sincosh, .{ .name = "__sincosh", .linkage = common.linkage, .visibility = common.visibility }); - @export(&sincosf, .{ .name = "sincosf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&sincos, .{ .name = "sincos", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__sincosx, .{ .name = "__sincosx", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&sincosq, .{ .name = "sincosf128", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__sincosh, "__sincosh"); + symbol(&sincosf, "sincosf"); + symbol(&sincos, "sincos"); + symbol(&__sincosx, "__sincosx"); + if (compiler_rt.want_ppc_abi) { + symbol(&sincosq, "sincosf128"); } - @export(&sincosq, .{ .name = "sincosq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&sincosl, .{ .name = "sincosl", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&sincosq, "sincosq"); + symbol(&sincosl, "sincosl"); } pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.c) void { @@ -44,7 +45,7 @@ pub fn sincosf(x: f32, r_sin: *f32, r_cos: *f32) callconv(.c) void { // |x| < 2**-12 if (ix < 0x39800000) { // raise inexact if x!=0 and underflow if subnormal - if (common.want_float_exceptions) { + if (compiler_rt.want_float_exceptions) { if (ix < 0x00100000) { mem.doNotOptimizeAway(x / 0x1p120); } else { @@ -138,7 +139,7 @@ pub fn sincos(x: f64, r_sin: *f64, r_cos: *f64) callconv(.c) void { // if |x| < 2**-27 * sqrt(2) if (ix < 0x3e46a09e) { // raise inexact if x != 0 and underflow if subnormal - if (common.want_float_exceptions) { + if (compiler_rt.want_float_exceptions) { if (ix < 0x00100000) { mem.doNotOptimizeAway(x / 0x1p120); } else { @@ -242,7 +243,7 @@ inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void { if (se < 0x3fff - math.floatFractionalBits(F) - 1) { // raise underflow if subnormal if (se == 0) { - if (common.want_float_exceptions) mem.doNotOptimizeAway(x * 0x1p-120); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x * 0x1p-120); } r_sin.* = x; // raise inexact if x!=0 diff --git a/lib/compiler_rt/sqrt.zig b/lib/compiler_rt/sqrt.zig index 870b1ee560..e765414fb0 100644 --- a/lib/compiler_rt/sqrt.zig +++ b/lib/compiler_rt/sqrt.zig @@ -9,20 +9,21 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; const math = std.math; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { - @export(&__sqrth, .{ .name = "__sqrth", .linkage = common.linkage, .visibility = common.visibility }); - @export(&sqrtf, .{ .name = "sqrtf", .linkage = common.linkage, .visibility = common.visibility }); - @export(&sqrt, .{ .name = "sqrt", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage, .visibility = common.visibility }); - if (common.want_ppc_abi) { - @export(&sqrtq, .{ .name = "sqrtf128", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_sqrt, .{ .name = "_Qp_sqrt", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__sqrth, "__sqrth"); + symbol(&sqrtf, "sqrtf"); + symbol(&sqrt, "sqrt"); + symbol(&__sqrtx, "__sqrtx"); + if (compiler_rt.want_ppc_abi) { + symbol(&sqrtq, "sqrtf128"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_sqrt, "_Qp_sqrt"); } - @export(&sqrtq, .{ .name = "sqrtq", .linkage = common.linkage, .visibility = common.visibility }); - @export(&sqrtl, .{ .name = "sqrtl", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&sqrtq, "sqrtq"); + symbol(&sqrtl, "sqrtl"); } pub fn __sqrth(x: f16) callconv(.c) f16 { @@ -103,7 +104,7 @@ pub fn sqrtf(x: f32) callconv(.c) f32 { return x; if (ix > @as(u32, @bitCast(std.math.inf(f32)))) - return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f32); + return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f32); ix = @as(u32, @bitCast(@as(i32, @bitCast(x * 0x1p23)) - (23 << 23))); } @@ -154,7 +155,7 @@ pub fn sqrt(x: f64) callconv(.c) f64 { // x < 0x1p-1022 or inf or nan. if (ix & 0x7FFF_FFFF_FFFF_FFFF == 0) return x; if (ix == 0x7FF0_0000_0000_0000) return x; - if (ix > 0x7FF0_0000_0000_0000) return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); + if (ix > 0x7FF0_0000_0000_0000) return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f64); // x is subnormal, normalize it. ix = @bitCast(x * 0x1p52); top = (ix >> 52) -% 52; @@ -291,7 +292,7 @@ pub fn __sqrtx(x: f80) callconv(.c) f80 { // x < 0x1p-16382 or inf or nan. if (ix & 0x7FFF_FFFF_FFFF_FFFF_FFFF == 0) return x; if (ix == 0x7FFF_8000_0000_0000_0000) return x; - if (ix > 0x7FFF_8000_0000_0000_0000) return if (common.want_float_exceptions) (x - x) / 0.0 else math.nan(f80); + if (ix > 0x7FFF_8000_0000_0000_0000) return if (compiler_rt.want_float_exceptions) (x - x) / 0.0 else math.nan(f80); // x is subnormal, normalize it. ix = @bitCast(x * 0x1p63); top = (ix >> 64) -% 63; diff --git a/lib/compiler_rt/ssp.zig b/lib/compiler_rt/ssp.zig index 0a138735ba..403652ea1b 100644 --- a/lib/compiler_rt/ssp.zig +++ b/lib/compiler_rt/ssp.zig @@ -13,7 +13,8 @@ //! - __vsprintf_chk const std = @import("std"); -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const builtin = @import("builtin"); extern fn memset(dest: ?[*]u8, c: u8, n: usize) callconv(.c) ?[*]u8; @@ -21,16 +22,16 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.c) ?[*]u8; comptime { - @export(&__stack_chk_fail, .{ .name = if (builtin.os.tag == .openbsd) "__stack_smash_handler" else "__stack_chk_fail", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__chk_fail, .{ .name = "__chk_fail", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__strcpy_chk, .{ .name = "__strcpy_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__strncpy_chk, .{ .name = "__strncpy_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__strcat_chk, .{ .name = "__strcat_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__strncat_chk, .{ .name = "__strncat_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__memcpy_chk, .{ .name = "__memcpy_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__memmove_chk, .{ .name = "__memmove_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__memset_chk, .{ .name = "__memset_chk", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__stack_chk_fail, .{ .name = if (builtin.os.tag == .openbsd) "__stack_smash_handler" else "__stack_chk_fail", .linkage = compiler_rt.linkage, .visibility = compiler_rt.visibility }); + symbol(&__chk_fail, "__chk_fail"); + symbol(&__stack_chk_guard, "__stack_chk_guard"); + symbol(&__strcpy_chk, "__strcpy_chk"); + symbol(&__strncpy_chk, "__strncpy_chk"); + symbol(&__strcat_chk, "__strcat_chk"); + symbol(&__strncat_chk, "__strncat_chk"); + symbol(&__memcpy_chk, "__memcpy_chk"); + symbol(&__memmove_chk, "__memmove_chk"); + symbol(&__memset_chk, "__memset_chk"); } fn __stack_chk_fail() callconv(.c) noreturn { diff --git a/lib/compiler_rt/stack_probe.zig b/lib/compiler_rt/stack_probe.zig index 83e08be015..5d63c9a422 100644 --- a/lib/compiler_rt/stack_probe.zig +++ b/lib/compiler_rt/stack_probe.zig @@ -1,6 +1,7 @@ const std = @import("std"); const builtin = @import("builtin"); -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const os_tag = builtin.os.tag; const arch = builtin.cpu.arch; const abi = builtin.abi; @@ -9,16 +10,16 @@ comptime { if (builtin.os.tag == .windows) { // Default stack-probe functions emitted by LLVM if (builtin.target.isMinGW()) { - @export(&_chkstk, .{ .name = "_alloca", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__chkstk, .{ .name = "__chkstk", .linkage = common.linkage, .visibility = common.visibility }); - @export(&___chkstk, .{ .name = "__alloca", .linkage = common.linkage, .visibility = common.visibility }); - @export(&___chkstk, .{ .name = "___chkstk", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__chkstk_ms, .{ .name = "__chkstk_ms", .linkage = common.linkage, .visibility = common.visibility }); - @export(&___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&_chkstk, "_alloca"); + symbol(&__chkstk, "__chkstk"); + symbol(&___chkstk, "__alloca"); + symbol(&___chkstk, "___chkstk"); + symbol(&__chkstk_ms, "__chkstk_ms"); + symbol(&___chkstk_ms, "___chkstk_ms"); } else if (!builtin.link_libc) { // This symbols are otherwise exported by MSVCRT.lib - @export(&_chkstk, .{ .name = "_chkstk", .linkage = common.linkage, .visibility = common.visibility }); - @export(&__chkstk, .{ .name = "__chkstk", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&_chkstk, "_chkstk"); + symbol(&__chkstk, "__chkstk"); } } @@ -26,7 +27,7 @@ comptime { .x86, .x86_64, => { - @export(&zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&zig_probe_stack, "__zig_probe_stack"); }, else => {}, } diff --git a/lib/compiler_rt/subdf3.zig b/lib/compiler_rt/subdf3.zig index 3e7dcc3dd2..4d00a7f03a 100644 --- a/lib/compiler_rt/subdf3.zig +++ b/lib/compiler_rt/subdf3.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const addf3 = @import("./addf3.zig").addf3; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_dsub, "__aeabi_dsub"); } else { symbol(&__subdf3, "__subdf3"); diff --git a/lib/compiler_rt/subhf3.zig b/lib/compiler_rt/subhf3.zig index e019005ae4..258401d295 100644 --- a/lib/compiler_rt/subhf3.zig +++ b/lib/compiler_rt/subhf3.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const addf3 = @import("./addf3.zig").addf3; comptime { - @export(&__subhf3, .{ .name = "__subhf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__subhf3, "__subhf3"); } fn __subhf3(a: f16, b: f16) callconv(.c) f16 { diff --git a/lib/compiler_rt/subsf3.zig b/lib/compiler_rt/subsf3.zig index 9a1cb559b2..94d4722016 100644 --- a/lib/compiler_rt/subsf3.zig +++ b/lib/compiler_rt/subsf3.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const addf3 = @import("./addf3.zig").addf3; comptime { - if (common.want_aeabi) { - @export(&__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_fsub, "__aeabi_fsub"); } else { - @export(&__subsf3, .{ .name = "__subsf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__subsf3, "__subsf3"); } } diff --git a/lib/compiler_rt/subtf3.zig b/lib/compiler_rt/subtf3.zig index b187eaf579..617e0e7016 100644 --- a/lib/compiler_rt/subtf3.zig +++ b/lib/compiler_rt/subtf3.zig @@ -1,13 +1,14 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const addf3 = @import("./addf3.zig").addf3; comptime { - if (common.want_ppc_abi) { - @export(&__subtf3, .{ .name = "__subkf3", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__subtf3, "__subkf3"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_sub, "_Qp_sub"); } - @export(&__subtf3, .{ .name = "__subtf3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__subtf3, "__subtf3"); } pub fn __subtf3(a: f128, b: f128) callconv(.c) f128 { diff --git a/lib/compiler_rt/subvsi3.zig b/lib/compiler_rt/subvsi3.zig index 68f551071c..0744585770 100644 --- a/lib/compiler_rt/subvsi3.zig +++ b/lib/compiler_rt/subvsi3.zig @@ -1,8 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const testing = @import("std").testing; comptime { - @export(&__subvsi3, .{ .name = "__subvsi3", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__subvsi3, "__subvsi3"); } pub fn __subvsi3(a: i32, b: i32) callconv(.c) i32 { diff --git a/lib/compiler_rt/tan.zig b/lib/compiler_rt/tan.zig index 17b7f1f1e7..822ffd4dec 100644 --- a/lib/compiler_rt/tan.zig +++ b/lib/compiler_rt/tan.zig @@ -16,7 +16,7 @@ const rem_pio2 = @import("rem_pio2.zig").rem_pio2; const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; const arch = builtin.cpu.arch; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { @@ -24,7 +24,7 @@ comptime { symbol(&tanf, "tanf"); symbol(&tan, "tan"); symbol(&__tanx, "__tanx"); - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&tanq, "tanf128"); } symbol(&tanq, "tanq"); @@ -50,7 +50,7 @@ pub fn tanf(x: f32) callconv(.c) f32 { if (ix <= 0x3f490fda) { // |x| ~<= pi/4 if (ix < 0x39800000) { // |x| < 2**-12 // raise inexact if x!=0 and underflow if subnormal - if (common.want_float_exceptions) { + if (compiler_rt.want_float_exceptions) { if (ix < 0x00800000) { mem.doNotOptimizeAway(x / 0x1p120); } else { @@ -94,7 +94,7 @@ pub fn tan(x: f64) callconv(.c) f64 { if (ix <= 0x3fe921fb) { if (ix < 0x3e400000) { // |x| < 2**-27 // raise inexact if x!=0 and underflow if subnormal - if (common.want_float_exceptions) { + if (compiler_rt.want_float_exceptions) { if (ix < 0x00100000) { mem.doNotOptimizeAway(x / 0x1p120); } else { diff --git a/lib/compiler_rt/trunc.zig b/lib/compiler_rt/trunc.zig index 799fbc9fbb..b784630703 100644 --- a/lib/compiler_rt/trunc.zig +++ b/lib/compiler_rt/trunc.zig @@ -4,23 +4,20 @@ //! https://git.musl-libc.org/cgit/musl/tree/src/math/truncf.c //! https://git.musl-libc.org/cgit/musl/tree/src/math/trunc.c -const builtin = @import("builtin"); -const arch = builtin.cpu.arch; - const std = @import("std"); const math = std.math; const mem = std.mem; const expect = std.testing.expect; -const common = @import("common.zig"); -const symbol = @import("../compiler_rt.zig").symbol; +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; comptime { symbol(&__trunch, "__trunch"); symbol(&truncf, "truncf"); symbol(&trunc, "trunc"); symbol(&__truncx, "__truncx"); - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&truncq, "truncf128"); } symbol(&truncq, "truncq"); @@ -48,7 +45,7 @@ pub fn truncf(x: f32) callconv(.c) f32 { if (u & m == 0) { return x; } else { - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); return @bitCast(u & ~m); } } @@ -69,7 +66,7 @@ pub fn trunc(x: f64) callconv(.c) f64 { if (u & m == 0) { return x; } else { - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); return @bitCast(u & ~m); } } @@ -95,7 +92,7 @@ pub fn truncq(x: f128) callconv(.c) f128 { if (u & m == 0) { return x; } else { - if (common.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); + if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); return @bitCast(u & ~m); } } diff --git a/lib/compiler_rt/truncdfhf2.zig b/lib/compiler_rt/truncdfhf2.zig index 43ad7fb20d..e01e187763 100644 --- a/lib/compiler_rt/truncdfhf2.zig +++ b/lib/compiler_rt/truncdfhf2.zig @@ -1,15 +1,15 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const truncf = @import("./truncf.zig").truncf; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_d2h, "__aeabi_d2h"); } symbol(&__truncdfhf2, "__truncdfhf2"); } -pub fn __truncdfhf2(a: f64) callconv(.c) common.F16T(f64) { +pub fn __truncdfhf2(a: f64) callconv(.c) compiler_rt.F16T(f64) { return @bitCast(truncf(f16, f64, a)); } diff --git a/lib/compiler_rt/truncdfsf2.zig b/lib/compiler_rt/truncdfsf2.zig index 8d6ed5c320..f1bada1844 100644 --- a/lib/compiler_rt/truncdfsf2.zig +++ b/lib/compiler_rt/truncdfsf2.zig @@ -1,11 +1,12 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const truncf = @import("./truncf.zig").truncf; comptime { - if (common.want_aeabi) { - @export(&__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_aeabi) { + symbol(&__aeabi_d2f, "__aeabi_d2f"); } else { - @export(&__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__truncdfsf2, "__truncdfsf2"); } } diff --git a/lib/compiler_rt/truncsfhf2.zig b/lib/compiler_rt/truncsfhf2.zig index acd5631da8..e0b2b1e4bf 100644 --- a/lib/compiler_rt/truncsfhf2.zig +++ b/lib/compiler_rt/truncsfhf2.zig @@ -1,20 +1,21 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const truncf = @import("./truncf.zig").truncf; comptime { - if (common.gnu_f16_abi) { - @export(&__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_aeabi) { - @export(&__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.gnu_f16_abi) { + symbol(&__gnu_f2h_ieee, "__gnu_f2h_ieee"); + } else if (compiler_rt.want_aeabi) { + symbol(&__aeabi_f2h, "__aeabi_f2h"); } - @export(&__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__truncsfhf2, "__truncsfhf2"); } -pub fn __truncsfhf2(a: f32) callconv(.c) common.F16T(f32) { +pub fn __truncsfhf2(a: f32) callconv(.c) compiler_rt.F16T(f32) { return @bitCast(truncf(f16, f32, a)); } -fn __gnu_f2h_ieee(a: f32) callconv(.c) common.F16T(f32) { +fn __gnu_f2h_ieee(a: f32) callconv(.c) compiler_rt.F16T(f32) { return @bitCast(truncf(f16, f32, a)); } diff --git a/lib/compiler_rt/trunctfdf2.zig b/lib/compiler_rt/trunctfdf2.zig index 4f569dae67..5396e87151 100644 --- a/lib/compiler_rt/trunctfdf2.zig +++ b/lib/compiler_rt/trunctfdf2.zig @@ -1,13 +1,14 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const truncf = @import("./truncf.zig").truncf; comptime { - if (common.want_ppc_abi) { - @export(&__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - @export(&_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage, .visibility = common.visibility }); + if (compiler_rt.want_ppc_abi) { + symbol(&__trunctfdf2, "__trunckfdf2"); + } else if (compiler_rt.want_sparc_abi) { + symbol(&_Qp_qtod, "_Qp_qtod"); } - @export(&__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__trunctfdf2, "__trunctfdf2"); } pub fn __trunctfdf2(a: f128) callconv(.c) f64 { diff --git a/lib/compiler_rt/trunctfhf2.zig b/lib/compiler_rt/trunctfhf2.zig index bd0e7a5dc2..46c6e34ec9 100644 --- a/lib/compiler_rt/trunctfhf2.zig +++ b/lib/compiler_rt/trunctfhf2.zig @@ -1,4 +1,4 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const truncf = @import("./truncf.zig").truncf; @@ -6,6 +6,6 @@ comptime { symbol(&__trunctfhf2, "__trunctfhf2"); } -pub fn __trunctfhf2(a: f128) callconv(.c) common.F16T(f128) { +pub fn __trunctfhf2(a: f128) callconv(.c) compiler_rt.F16T(f128) { return @bitCast(truncf(f16, f128, a)); } diff --git a/lib/compiler_rt/trunctfsf2.zig b/lib/compiler_rt/trunctfsf2.zig index bab5534bfe..94dbff6ef9 100644 --- a/lib/compiler_rt/trunctfsf2.zig +++ b/lib/compiler_rt/trunctfsf2.zig @@ -1,11 +1,11 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const truncf = @import("./truncf.zig").truncf; const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_ppc_abi) { + if (compiler_rt.want_ppc_abi) { symbol(&__trunctfsf2, "__trunckfsf2"); - } else if (common.want_sparc_abi) { + } else if (compiler_rt.want_sparc_abi) { symbol(&_Qp_qtos, "_Qp_qtos"); } symbol(&__trunctfsf2, "__trunctfsf2"); diff --git a/lib/compiler_rt/trunctfxf2.zig b/lib/compiler_rt/trunctfxf2.zig index df0db2393a..dfb9ef8040 100644 --- a/lib/compiler_rt/trunctfxf2.zig +++ b/lib/compiler_rt/trunctfxf2.zig @@ -1,9 +1,10 @@ const math = @import("std").math; -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; const trunc_f80 = @import("./truncf.zig").trunc_f80; comptime { - @export(&__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = common.linkage, .visibility = common.visibility }); + symbol(&__trunctfxf2, "__trunctfxf2"); } pub fn __trunctfxf2(a: f128) callconv(.c) f80 { diff --git a/lib/compiler_rt/truncxfhf2.zig b/lib/compiler_rt/truncxfhf2.zig index b6abce58d5..4c3e951bfe 100644 --- a/lib/compiler_rt/truncxfhf2.zig +++ b/lib/compiler_rt/truncxfhf2.zig @@ -1,4 +1,4 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const trunc_f80 = @import("./truncf.zig").trunc_f80; @@ -6,6 +6,6 @@ comptime { symbol(&__truncxfhf2, "__truncxfhf2"); } -fn __truncxfhf2(a: f80) callconv(.c) common.F16T(f80) { +fn __truncxfhf2(a: f80) callconv(.c) compiler_rt.F16T(f80) { return @bitCast(trunc_f80(f16, a)); } diff --git a/lib/compiler_rt/udivmod.zig b/lib/compiler_rt/udivmod.zig index bf6aaadeae..44165c0a62 100644 --- a/lib/compiler_rt/udivmod.zig +++ b/lib/compiler_rt/udivmod.zig @@ -1,8 +1,98 @@ -const std = @import("std"); const builtin = @import("builtin"); + +const std = @import("std"); const Log2Int = std.math.Log2Int; -const common = @import("common.zig"); -const HalveInt = common.HalveInt; + +const compiler_rt = @import("../compiler_rt.zig"); +const symbol = compiler_rt.symbol; +const HalveInt = compiler_rt.HalveInt; + +comptime { + if (compiler_rt.want_windows_v2u64_abi) { + symbol(&__umodti3_windows_x86_64, "__umodti3"); + symbol(&__modti3_windows_x86_64, "__modti3"); + symbol(&__udivti3_windows_x86_64, "__udivti3"); + symbol(&__divti3_windows_x86_64, "__divti3"); + symbol(&__udivmodti4_windows_x86_64, "__udivmodti4"); + } else { + symbol(&__umodti3, "__umodti3"); + symbol(&__modti3, "__modti3"); + symbol(&__udivti3, "__udivti3"); + symbol(&__divti3, "__divti3"); + symbol(&__udivmodti4, "__udivmodti4"); + } +} + +const v128 = @Vector(2, u64); +const v2u64 = @Vector(2, u64); + +pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.c) u128 { + return udivmod(u128, a, b, maybe_rem); +} + +fn __udivmodti4_windows_x86_64(a: v2u64, b: v2u64, maybe_rem: ?*u128) callconv(.c) v2u64 { + return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), maybe_rem)); +} + +pub fn __divti3(a: i128, b: i128) callconv(.c) i128 { + return div(a, b); +} + +fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.c) v128 { + return @bitCast(div(@bitCast(a), @bitCast(b))); +} + +inline fn div(a: i128, b: i128) i128 { + const s_a = a >> (128 - 1); + const s_b = b >> (128 - 1); + + const an = (a ^ s_a) -% s_a; + const bn = (b ^ s_b) -% s_b; + + const r = udivmod(u128, @bitCast(an), @bitCast(bn), null); + const s = s_a ^ s_b; + return (@as(i128, @bitCast(r)) ^ s) -% s; +} + +pub fn __udivti3(a: u128, b: u128) callconv(.c) u128 { + return udivmod(u128, a, b, null); +} + +fn __udivti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 { + return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), null)); +} + +pub fn __modti3(a: i128, b: i128) callconv(.c) i128 { + return mod(a, b); +} + +fn __modti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 { + return @bitCast(mod(@as(i128, @bitCast(a)), @as(i128, @bitCast(b)))); +} + +inline fn mod(a: i128, b: i128) i128 { + const s_a = a >> (128 - 1); // s = a < 0 ? -1 : 0 + const s_b = b >> (128 - 1); // s = b < 0 ? -1 : 0 + + const an = (a ^ s_a) -% s_a; // negate if s == -1 + const bn = (b ^ s_b) -% s_b; // negate if s == -1 + + var r: u128 = undefined; + _ = udivmod(u128, @as(u128, @bitCast(an)), @as(u128, @bitCast(bn)), &r); + return (@as(i128, @bitCast(r)) ^ s_a) -% s_a; // negate if s == -1 +} + +pub fn __umodti3(a: u128, b: u128) callconv(.c) u128 { + var r: u128 = undefined; + _ = udivmod(u128, a, b, &r); + return r; +} + +fn __umodti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 { + var r: u128 = undefined; + _ = udivmod(u128, @bitCast(a), @bitCast(b), &r); + return @bitCast(r); +} const lo = switch (builtin.cpu.arch.endian()) { .big => 1, @@ -14,7 +104,7 @@ const hi = 1 - lo; // Returns U / v_ and sets r = U % v_. fn divwide_generic(comptime T: type, _u1: T, _u0: T, v_: T, r: *T) T { const HalfT = HalveInt(T, false).HalfT; - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); var v = v_; const b = @as(T, 1) << (@bitSizeOf(T) / 2); @@ -70,7 +160,7 @@ fn divwide_generic(comptime T: type, _u1: T, _u0: T, v_: T, r: *T) T { } fn divwide(comptime T: type, _u1: T, _u0: T, v: T, r: *T) T { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); if (T == u64 and builtin.target.cpu.arch == .x86_64 and builtin.target.os.tag != .windows) { var rem: T = undefined; const quo = asm ( @@ -90,7 +180,7 @@ fn divwide(comptime T: type, _u1: T, _u0: T, v: T, r: *T) T { // Returns a_ / b_ and sets maybe_rem = a_ % b. pub fn udivmod(comptime T: type, a_: T, b_: T, maybe_rem: ?*T) T { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); const HalfT = HalveInt(T, false).HalfT; const SignedT = std.meta.Int(.signed, @bitSizeOf(T)); @@ -147,3 +237,9 @@ pub fn udivmod(comptime T: type, a_: T, b_: T, maybe_rem: ?*T) T { } return @bitCast(q); } + +test { + _ = @import("modti3_test.zig"); + _ = @import("divti3_test.zig"); + _ = @import("udivmodti4_test.zig"); +} diff --git a/lib/compiler_rt/udivmodei4.zig b/lib/compiler_rt/udivmodei4.zig index fd8cc6717e..f037639c72 100644 --- a/lib/compiler_rt/udivmodei4.zig +++ b/lib/compiler_rt/udivmodei4.zig @@ -5,7 +5,7 @@ const std = @import("std"); const shr = std.math.shr; const shl = std.math.shl; -const common = @import("common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const symbol = @import("../compiler_rt.zig").symbol; const max_limbs = std.math.divCeil(usize, 65535, 32) catch unreachable; // max supported type is u65535 @@ -115,7 +115,7 @@ pub fn divmod(q: ?[]u32, r: ?[]u32, u: []const u32, v: []const u32) !void { } pub fn __udivei4(q_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, bits: usize) callconv(.c) void { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits)); const q: []u32 = @ptrCast(@alignCast(q_p[0..byte_size])); const u: []const u32 = @ptrCast(@alignCast(u_p[0..byte_size])); @@ -124,7 +124,7 @@ pub fn __udivei4(q_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, bits: usize) ca } pub fn __umodei4(r_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, bits: usize) callconv(.c) void { - @setRuntimeSafety(common.test_safety); + @setRuntimeSafety(compiler_rt.test_safety); const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits)); const r: []u32 = @ptrCast(@alignCast(r_p[0..byte_size])); const u: []const u32 = @ptrCast(@alignCast(u_p[0..byte_size])); diff --git a/lib/compiler_rt/udivmodti4.zig b/lib/compiler_rt/udivmodti4.zig deleted file mode 100644 index a1b89bb962..0000000000 --- a/lib/compiler_rt/udivmodti4.zig +++ /dev/null @@ -1,26 +0,0 @@ -const std = @import("std"); -const builtin = @import("builtin"); -const udivmod = @import("udivmod.zig").udivmod; -const common = @import("common.zig"); - -comptime { - if (common.want_windows_v2u64_abi) { - @export(&__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.c) u128 { - return udivmod(u128, a, b, maybe_rem); -} - -const v2u64 = @Vector(2, u64); - -fn __udivmodti4_windows_x86_64(a: v2u64, b: v2u64, maybe_rem: ?*u128) callconv(.c) v2u64 { - return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), maybe_rem)); -} - -test { - _ = @import("udivmodti4_test.zig"); -} diff --git a/lib/compiler_rt/udivmodti4_test.zig b/lib/compiler_rt/udivmodti4_test.zig index 5e172c29f8..fc457990e6 100644 --- a/lib/compiler_rt/udivmodti4_test.zig +++ b/lib/compiler_rt/udivmodti4_test.zig @@ -1,6 +1,6 @@ // Disable formatting to avoid unnecessary source repository bloat. // zig fmt: off -const __udivmodti4 = @import("udivmodti4.zig").__udivmodti4; +const __udivmodti4 = @import("udivmod.zig").__udivmodti4; const testing = @import("std").testing; fn test__udivmodti4(a: u128, b: u128, expected_q: u128, expected_r: u128) !void { diff --git a/lib/compiler_rt/udivti3.zig b/lib/compiler_rt/udivti3.zig deleted file mode 100644 index a579d81e47..0000000000 --- a/lib/compiler_rt/udivti3.zig +++ /dev/null @@ -1,22 +0,0 @@ -const std = @import("std"); -const builtin = @import("builtin"); -const udivmod = @import("udivmod.zig").udivmod; -const common = @import("common.zig"); - -comptime { - if (common.want_windows_v2u64_abi) { - @export(&__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__udivti3, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -pub fn __udivti3(a: u128, b: u128) callconv(.c) u128 { - return udivmod(u128, a, b, null); -} - -const v2u64 = @Vector(2, u64); - -fn __udivti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 { - return @bitCast(udivmod(u128, @bitCast(a), @bitCast(b), null)); -} diff --git a/lib/compiler_rt/umodti3.zig b/lib/compiler_rt/umodti3.zig deleted file mode 100644 index 63cfcc2c25..0000000000 --- a/lib/compiler_rt/umodti3.zig +++ /dev/null @@ -1,26 +0,0 @@ -const std = @import("std"); -const builtin = @import("builtin"); -const udivmod = @import("udivmod.zig").udivmod; -const common = @import("common.zig"); - -comptime { - if (common.want_windows_v2u64_abi) { - @export(&__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__umodti3, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -pub fn __umodti3(a: u128, b: u128) callconv(.c) u128 { - var r: u128 = undefined; - _ = udivmod(u128, a, b, &r); - return r; -} - -const v2u64 = @Vector(2, u64); - -fn __umodti3_windows_x86_64(a: v2u64, b: v2u64) callconv(.c) v2u64 { - var r: u128 = undefined; - _ = udivmod(u128, @bitCast(a), @bitCast(b), &r); - return @bitCast(r); -} diff --git a/lib/compiler_rt/unorddf2.zig b/lib/compiler_rt/unorddf2.zig index 634f14398d..90da745199 100644 --- a/lib/compiler_rt/unorddf2.zig +++ b/lib/compiler_rt/unorddf2.zig @@ -1,9 +1,9 @@ -const common = @import("./common.zig"); +const compiler_rt = @import("../compiler_rt.zig"); const comparef = @import("./comparef.zig"); const symbol = @import("../compiler_rt.zig").symbol; comptime { - if (common.want_aeabi) { + if (compiler_rt.want_aeabi) { symbol(&__aeabi_dcmpun, "__aeabi_dcmpun"); } else { symbol(&__unorddf2, "__unorddf2"); diff --git a/lib/compiler_rt/unordhf2.zig b/lib/compiler_rt/unordhf2.zig deleted file mode 100644 index 4fcffd1a1d..0000000000 --- a/lib/compiler_rt/unordhf2.zig +++ /dev/null @@ -1,10 +0,0 @@ -const common = @import("./common.zig"); -const comparef = @import("./comparef.zig"); - -comptime { - @export(&__unordhf2, .{ .name = "__unordhf2", .linkage = common.linkage, .visibility = common.visibility }); -} - -pub fn __unordhf2(a: f16, b: f16) callconv(.c) i32 { - return comparef.unordcmp(f16, a, b); -} diff --git a/lib/compiler_rt/unordsf2.zig b/lib/compiler_rt/unordsf2.zig deleted file mode 100644 index 56bfb94028..0000000000 --- a/lib/compiler_rt/unordsf2.zig +++ /dev/null @@ -1,18 +0,0 @@ -const common = @import("./common.zig"); -const comparef = @import("./comparef.zig"); - -comptime { - if (common.want_aeabi) { - @export(&__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__unordsf2, .{ .name = "__unordsf2", .linkage = common.linkage, .visibility = common.visibility }); - } -} - -pub fn __unordsf2(a: f32, b: f32) callconv(.c) i32 { - return comparef.unordcmp(f32, a, b); -} - -fn __aeabi_fcmpun(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 { - return comparef.unordcmp(f32, a, b); -} diff --git a/lib/compiler_rt/unordtf2.zig b/lib/compiler_rt/unordtf2.zig deleted file mode 100644 index 22e90acaae..0000000000 --- a/lib/compiler_rt/unordtf2.zig +++ /dev/null @@ -1,16 +0,0 @@ -const common = @import("./common.zig"); -const comparef = @import("./comparef.zig"); - -comptime { - if (common.want_ppc_abi) { - @export(&__unordtf2, .{ .name = "__unordkf2", .linkage = common.linkage, .visibility = common.visibility }); - } else if (common.want_sparc_abi) { - // These exports are handled in cmptf2.zig because unordered comparisons - // are based on calling _Qp_cmp. - } - @export(&__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage, .visibility = common.visibility }); -} - -fn __unordtf2(a: f128, b: f128) callconv(.c) i32 { - return comparef.unordcmp(f128, a, b); -} diff --git a/lib/compiler_rt/unordxf2.zig b/lib/compiler_rt/unordxf2.zig deleted file mode 100644 index 2ebf5f413c..0000000000 --- a/lib/compiler_rt/unordxf2.zig +++ /dev/null @@ -1,10 +0,0 @@ -const common = @import("./common.zig"); -const comparef = @import("./comparef.zig"); - -comptime { - @export(&__unordxf2, .{ .name = "__unordxf2", .linkage = common.linkage, .visibility = common.visibility }); -} - -pub fn __unordxf2(a: f80, b: f80) callconv(.c) i32 { - return comparef.unordcmp(f80, a, b); -}