Commit Graph

237 Commits

Author SHA1 Message Date
Alex Rønne Petersen 9a1e754a58 compiler-rt: Implement __clear_cache() for mips-netbsd 2025-07-07 09:05:07 +02:00
Alex Rønne Petersen 5209e7e458 compiler-rt: Export __emutls_get_address for OpenHarmony 2025-07-07 07:23:24 +02:00
Ali Cheraghi 1df79ab895 remove spirv cpu arch 2025-06-23 06:03:03 +02:00
Koki Ueha 9e340b3005 This commit enables fmax and fmin to differentiate between 0.0 and
-0.0, making it compatible with musl.
2025-06-20 10:17:24 +02:00
Jacob Young 1f98c98fff x86_64: increase passing test coverage on windows
Now that codegen has no references to linker state this is much easier.

Closes #24153
2025-06-19 18:41:12 -04:00
Jacob Young ed37a1a33c coff: add hack to build a compiler-rt dynamic library
This is not meant to be a long-term solution, but it's the easiest thing
to get working quickly at the moment. The main intention of this hack is
to allow more tests to be enabled. By the time the coff linker is far
enough along to be enabled by default, this will no longer be required.
2025-06-19 18:41:12 -04:00
Jacob Young 917640810e Target: pass and use locals by pointer instead of by value
This struct is larger than 256 bytes and code that copies it
consistently shows up in profiles of the compiler.
2025-06-19 11:45:06 -04:00
Koki Ueha 878b7b80c1 libc: Prevent FCSEL instruction from being used to avoid raising an unintended exception
If you write an if expression in mem.doNotOptimizeAway like
doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120);,
FCSEL instruction is used on AArch64.
FCSEL instruction selects one of the two registers according to
the condition and copies its value.
In this example, `x / 0x1p120` and `x + 0x1p120` are expressions
that raise different floating-point exceptions.
However, since both are actually evaluated before the FCSEL
instruction, the exception not intended by the programmer may
also be raised.

To prevent FCSEL instruction from being used here, this commit
splits doNotOptimizeAway in two.
2025-06-15 04:01:43 -04:00
Alex Rønne Petersen 9d534790eb std.Target: Introduce Cpu convenience functions for feature tests.
Before:

* std.Target.arm.featureSetHas(target.cpu.features, .has_v7)
* std.Target.x86.featureSetHasAny(target.cpu.features, .{ .sse, .avx, .cmov })
* std.Target.wasm.featureSetHasAll(target.cpu.features, .{ .atomics, .bulk_memory })

After:

* target.cpu.has(.arm, .has_v7)
* target.cpu.hasAny(.x86, &.{ .sse, .avx, .cmov })
* target.cpu.hasAll(.wasm, &.{ .atomics, .bulk_memory })
2025-06-05 06:12:00 +02:00
Alex Rønne Petersen bc8ace2a6d compiler-rt: Issue VALGRIND_DISCARD_TRANSLATIONS request in __clear_cache().
Closes #24030.
2025-06-04 13:25:21 +02:00
Andrew Kelley 826e1c30ba Merge pull request #24013 from alexrp/test-matrix
More target coverage in the module test matrix
2025-06-03 17:05:15 -04:00
Hilger Baumstark 0386730777 compiler-rt: add __addvsi3, __subvsi3, __mulvsi3, and __subvdi3 2025-06-01 20:17:25 +02:00
Alex Rønne Petersen 358ee859ba compiler-rt: Fix some exports for *-windows-none. 2025-05-29 15:35:35 +02:00
Alex Rønne Petersen 07c93cb103 compiler-rt: Add a comment explaining why we currently need weak linkage. 2025-05-19 00:22:03 +02:00
Alex Rønne Petersen 90fb2d9754 compiler-rt: Fix some exports to respect the common linkage and visibility. 2025-05-19 00:22:03 +02:00
Alex Rønne Petersen 092352ec63 compiler-rt, zigc: Use hidden visibility except when testing.
This prevents symbols from these libraries from polluting the dynamic symbol
tables of binaries built with Zig. The downside is that we no longer deduplicate
the symbols at run time due to weak linkage.

Closes #7935.
Closes #13303.
Closes #19342.
2025-05-19 00:22:03 +02:00
Alex Rønne Petersen 2c5f54c898 compiler-rt: Add missing _Qp_sqrt export for sparc64.
https://github.com/ziglang/zig/issues/23716
2025-04-28 12:05:19 +02:00
Jacob Young b31a91bbef compiler-rt: compute correct integer sizes from bits at runtime
Also, accepting `align(1)` pointers ensures that the alignment is safety
checked rather than assumed.
2025-04-11 07:06:01 -04:00
Alex Rønne Petersen 82b9d9c0f6 compiler-rt: Fix names of some float/int conversion routines for hexagon. 2025-04-04 06:08:10 +02:00
Alex Rønne Petersen 858305385d llvm: Update the list of targets that use native f16/f128.
Closes #22003.
Closes #22013.
2025-04-04 06:08:10 +02:00
Jacob Young a5900e310e compiler-rt: fix signed min int from float 2025-03-08 14:21:22 -05:00
Linus Groh 79460d4a3e Remove uses of deprecated callconv aliases 2025-03-05 03:01:43 +00:00
Alex Rønne Petersen ad5515bed8 compiler-rt: Add tests from llvm/llvm-project#119449. 2025-02-25 19:31:00 +01:00
Andrew Kelley eb3c7f5706 zig build fmt 2025-02-22 17:09:20 -08:00
Andrew Kelley 61ee9f9415 Merge pull request #22606 from dweiller/memmove-opt
compiler-rt: memmove optimisation
2025-02-22 17:14:06 -05:00
Alex Rønne Petersen 481b7bf3f0 std.Target: Remove functions that just wrap component functions.
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look
at multiple components of the target. But functions like isWasm(), isDarwin(),
isGnu(), etc only exist to save 4-8 characters. I don't think this is a good
enough reason to keep them, especially given that:

* It's not immediately obvious to a reader whether target.isDarwin() means the
  same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar
  functions *do* look at multiple components.
* It's not clear where we would draw the line. The logical conclusion before
  this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(),
  Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand.
* It's nice to just have a single correct way of doing something.
2025-02-17 19:18:19 +01:00
Alex Rønne Petersen ddff1fa4c6 compiler-rt: Use Windows Arm ABI routines for UEFI for now.
Until #21630 is addressed.

Closes #22893.
2025-02-16 01:15:29 +01:00
Jacob Young 8c48376d64 x86_64: rewrite scalar and vector int @divTrunc 2025-02-15 03:45:21 -05:00
dweiller 6dc1a4db7f compiler-rt: fix memcpy generating recursive calls
When using the LLVM backend, array copies were lowered as calls to
`llvm.memcpy.*` builtin which could cause recursive calls to memcpy to
be generated (observed with `-target x86_64-linux -mcpu x86_64+avx512vl
--debug-rt`).

By instead performing these small fixed-size copies with integers or
vectors the LLVM backend does not generate calls to the `llvm.memcpy`
builtin, and so (with `-fno-builtin`) recursive calls to memcpy will
not be generated by LLVM.

The assertions and (test build) runtime safety have been removed as they
may cause (mutually) recursive calls to memcpy in debug builds since the
panic handler generates calls to llvm.memcpy.
2025-02-11 17:40:20 -08:00
Andrew Kelley 8d914ea734 compiler_rt memcpy: avoid infinite recursion
when compiled in debug mode (--debug-rt)
2025-02-10 22:58:49 -08:00
Jacob Young 4e4775d6bd x86_64: implement conversions between scalar floats and ints
Closes #22797
2025-02-09 00:42:55 -08:00
dweiller 3294ef792f compiler-rt: only check dest/src start address in memmove 2025-01-30 19:56:57 +11:00
dweiller 7e7c36fb57 compiler-rt: remove manual unroll code from memmove 2025-01-30 19:56:57 +11:00
dweiller 63f5a80b71 compiler-rt: workaround miscompilation in memmove 2025-01-30 19:56:57 +11:00
dweiller 4db01eb130 compiler-rt: optimize memmove 2025-01-30 19:56:57 +11:00
Andrew Kelley eed3b9567d Merge pull request #22610 from jacobly0/x86_64-rewrite
x86_64: rewrite `@min`/`@max` for scalar floats
2025-01-27 11:47:52 -08:00
dweiller df1cd62720 compiler-rt: ensure memcpy Element has no unused bytes 2025-01-26 07:00:24 -08:00
Jacob Young 0c890bb9a4 x86_64: rewrite @min/@max for scalar floats 2025-01-26 06:58:37 -05:00
Alex Rønne Petersen 673544b783 compiler-rt: Pass called functions into inline asm so the compiler sees the usage. 2025-01-25 14:54:02 +01:00
Alex Rønne Petersen 35da1e1e8f compiler-rt: Don't export __a(u)ll(div,rem) if linking libc.
libc provides these when targeting MSVC.
2025-01-25 13:49:21 +01:00
Alex Rønne Petersen 05a877a9a1 compiler-rt: More accurately export Windows Arm functions. 2025-01-25 13:49:21 +01:00
mlugg 38b47034f7 compiler_rt: upgrade to new panic interface 2025-01-24 22:33:23 +00:00
dweiller b7a887f0fb compiler-rt: optimize memcpy
The new memcpy function aims to be more generic than the previous
implementation which was adapted from an implementation optimized for
x86_64 avx2 machines. Even on x86_64 avx2 machines this implementation
should be generally be faster due to fewer branches in the small length
cases and generating less machine code.

Note that the new memcpy function no longer acts as a memmove.
2025-01-20 18:29:15 +11:00
dweiller d6e1166f1a compiler-rt: reduce memmove and memcpy size for ReleaseSmall 2025-01-20 18:29:15 +11:00
dweiller bf89482f23 compiler-rt: move memmove back to memmove.zig 2025-01-20 17:16:24 +11:00
Alex Rønne Petersen 515c97065a Revert "work around llvm failing to lower memcpy"
This reverts commit acf7043955.

Fixed as of ec768b7fa2f9c7dea6b92651bef59a7eea3299f2.
2025-01-18 12:59:41 +01:00
Andrew Kelley acf7043955 work around llvm failing to lower memcpy
triggers an assertion in LegalizeDAG otherwise
2025-01-17 13:21:30 -08:00
Andrew Kelley 59acfb1263 compiler_rt: don't rely on weak aliases 2025-01-17 12:53:25 -08:00
David Rubin f278038923 replace compiler_rt memcpy with a better version 2025-01-17 12:34:15 -08:00
GalaxyShard e6879e99e2 compiler_rt: fix incorrect __clzsi2_thumb1 lookup table usage 2025-01-02 01:01:06 +01:00