Commit Graph

66 Commits

Author SHA1 Message Date
Trevor Gross
b47d3cc2f8 Shorten prefixes for float constants
Change `SIGNIFICAND_*` to `SIG_*` and `EXPONENT_*` to `EXP_*`. This
makes things more consistent with `libm`, and terseness is convenient
here since there isn't anything to confuse.
2025-01-03 02:54:56 +00:00
Trevor Gross
fbd6907358 Add integer to f128 conversions 2024-10-30 12:25:24 -05:00
Trevor Gross
51dd4da053 Refactor integer to float conversion
Extract some common routines to separate functions in order to
deduplicate code and remove some of the magic.
2024-10-30 12:25:22 -05:00
Trevor Gross
1dc50415cd Add an apfloat fallback for int to float tests 2024-10-30 12:22:57 -05:00
Trevor Gross
606d971958 Add support for f128 integer exponentiation
Create the symbol `__powitf2`.
2024-09-28 11:06:33 -04:00
Trevor Gross
2a32f80cdc Move float_pow tests to their own file 2024-09-28 11:06:33 -04:00
Trevor Gross
18b42ebb78 Remove unneeded features
A few of the features that we enable have been stabilized, others may
have been needed at some point but are no longer required. Clean this
up.
2024-09-28 10:56:30 -04:00
Trevor Gross
764a177497 Add f128 division
Use the new generic division algorithm to expose `__divtf3` and
`__divkf3`.
2024-09-24 18:32:58 +02:00
Trevor Gross
4f8afbabdc Make float division generic
Float division currently has a separate `div32` and `div64` for `f32`
and `f64`, respectively. Combine these to make use of generics. This
will make it easier to support `f128` division, and reduces a lot of
redundant code.

This includes a simplification of division tests.
2024-09-24 18:32:56 +02:00
Trevor Gross
44840a12bc Add Shr to u256
Float division requires some shift operations on big integers; implement
right shift here.
2024-09-24 18:21:57 +02:00
Sbstn Bcht
69406c118a
Remove unsupported *vfp functions (#678)
Remove all *vfp functions and related tests since LLVM no longer emits them.

Link: https://github.com/rust-lang/compiler-builtins/pull/626

[ Reword commit message - Trevor ]
2024-09-03 22:55:44 -04:00
Kleis Auke Wolthuizen
13cc7daf05 Fix CI for targets that conditionally disable f16 or f128 support 2024-08-12 14:56:59 +02:00
Trevor Gross
e0e6243b21 Update float conversion tests
Since there are more platforms that do not have symbols present, we need
to use `rustc_apfloat` for more conversion tests. Make use of the
fallback like other tests, and refactor so each test gets its own
function.

Previously we were testing both apfloat and system conversion methods
when possible. This changes to only test one or the other, depending on
whether or not the system version is available. This seems reasonable
because it is consistent with all other tests, but we should consider
updating all tests to check both at some point.

This also includes an adjustment of PowerPC configuration to account for
the linking errors at [1].

[1]: https://github.com/rust-lang/compiler-builtins/issues/655
2024-08-03 02:07:06 -04:00
Andrey Turkin
adabbe73d9 Implement __ctz*i2 intrinsics 2024-07-25 19:26:02 +03:00
Andrey Turkin
a5c7a17d55 Implement remaining __clz*i2 intrinsics 2024-07-24 12:50:04 +01:00
Andrey Turkin
45465cc488 Implement __bswap[sdt]i2 intrinsics
These can be emitted by gcc, at least if requested specifically via __builtin_bswap{32,64,128}.
2024-07-06 11:51:52 +02:00
beetrees
c6bf88ab1c
Ignore broken nightly/system builtins 2024-07-01 07:42:22 +01:00
beetrees
ffb31aee13
Fix incorrect rounding with subnormal/zero results of float multiplication 2024-06-30 22:03:33 +01:00
Trevor Gross
c7bd2a5655 Add ppc_alias to the intrinsics! macro
PowerPC platforms use `kf` rather than `tf` for `f128`. Add a way to
alias this in the macro to make the code cleaner.

This also fixes the names of `fixunstf*` and `fixtf*` on Power PC
(`fixunskf*` and `fixkf*` are correct).
2024-05-21 03:55:37 -04:00
Trevor Gross
ccd179b231 Add f128 float to integer conversion functions
Add the following:

- `__fixtfsi`
- `__fixtfdi`
- `__fixtfti`
- `__fixunstfsi`
- `__fixunstfdi`
- `__fixunstfti`
2024-05-20 20:01:33 -04:00
Trevor Gross
aaaf62bd6b Add an apfloat fallback for float to integer tests 2024-05-20 20:01:19 -04:00
Trevor Gross
f82e1f14fc Rework the test crate to separate individual tests
Currently, tests of the same kind are grouped together across all types
into a single function. This makes it difficult to understand exactly
what failed in CI.

Change test macros to create separate functions for separate types so
failures are more fine grained.
2024-05-18 04:37:55 -04:00
Trevor Gross
a82491ed54 Correct f128 extend and truncate symbol names on powerpc
PowerPC uses `kf` instead of `tf`:
<https://gcc.gnu.org/wiki/Ieee128PowerPC>
2024-05-15 07:19:17 -05:00
Trevor Gross
aaa5260748 Implement f128 comparison 2024-05-15 07:19:17 -05:00
Trevor Gross
191c1b88cd Implement f128 multiplication 2024-05-15 07:19:17 -05:00
Trevor Gross
2755f457f8 Implement f128 addition and subtraction 2024-05-15 07:19:17 -05:00
Trevor Gross
1be6626307 Refactor float test macros to have a fallback
Change float test macros to fall back to testing against `rustc_apfloat`
when system implementations are not available, rather than just skipping
tests.

This allows for easier debugging where operations may not be supported.
2024-05-15 07:19:17 -05:00
Trevor Gross
23b91f2b58 Add i256 and u256 bigint types 2024-05-15 07:19:17 -05:00
Trevor Gross
54d96150b5 Update cfg to fix warnings 2024-05-11 09:56:55 +02:00
beetrees
229babb1d0 Add builtins for f16/f128 float conversions 2024-05-02 13:49:24 +02:00
Trevor Gross
47f2241db9 Change aarch64_linux module and lse tests to have the same gating
Trying to run testcrate on non-linux aarch64 currently hits a
compilation error. Make this test linux-only, to be consistent with the
`aarch64_linux` module that it depends on.

Additionally, enable the `aarch64_linux` module for `target_arch =
"arm64ec"` to be the same as these tests.
2024-04-16 14:04:47 -04:00
Daniel Paoliello
30182128c9 Add support for arm64ec 2024-03-28 09:20:13 -07:00
jyn
c4e9f479ad Only compile outlined-atomics intrinsics on linux 2023-07-02 21:55:02 -05:00
Amanieu d'Antras
bb0d107feb
Merge pull request #532 from jyn514/lse.rs 2023-06-28 23:41:39 +01:00
kirk
379445f9a5 port updated version of llvm float div 2023-06-27 01:17:31 +00:00
Joshua Nelson
6242fd629e address review comments and fix CI
- implement CAS 16
- remove useless commented out symbol name
- support `feature("no-asm")`
- fix warnings when `feature("c")` is enabled
- rustfmt
2023-06-26 15:09:37 +00:00
Joshua Nelson
21c821c6c9 Port outline-atomics to rust
This has a very long history, summarized in
https://github.com/rust-lang/rust/issues/109064. This port is a very
minimal subset of `aarch64/lse.S` from LLVM's compiler-rt. In
particular, it is missing the following:

1. Any form of runtime dispatch between LL/SC and LSE.

Determining which version of the intrinsics to use
requires one of the following:

  i) `getauxval` from glibc. It's unclear whether `compiler_builtins` is
allowed to depend on libc at all, and musl doesn't even support
getauxval. Don't enshrine the requirement "de-facto" by making it
required for outline-atomics.

  ii) kernel support. Linux and FreeBSD have limited support, but it
requires an extremely recent kernel version and doesn't work at all under QEMU (https://github.com/rust-lang/rust/issues/109064#issuecomment-1494939904).

Instead, we hard-code LL/SC intrinsics. Users who want LSE support
should use the LLVM compiler-rt (if you're building from source in
rust-lang/rust, make sure you have `src/llvm-project` checked out
locally. the goal is to soon add a new `optimized-compiler-builtins`
option so this is easier to discover).

2. The global `___aarch64_have_lse_atomics` CTOR, required to do runtime
   dispatch. Thom Chiviolani has this to say about global CTORs:

> static ctors are problems because we are pretty eager about dead code elim
> in general if you have a module that isnt directly reference we will probably not have its static ctors
> also, while llvm has a super robust way to have a static ctor (theres s special "appending global" to use for c++), we dont use that and just have people make a #[used] static in a special section
> 1. the robust way kinda requires rust knowing that the argument is a static ctor (maybe a #[rustc_static_ctor] attribute). it also would be... finnicky, since on windows we actually care beyond being a static ctor, that we run as part in a specific group of ctors, which means a very specific section (one for TLS and the other for, uh, i dont remember)
> 2. we still actually have to codegen the cgu that isn't referenced. but maybe we could remember that it has that attribute and use that

So while this is possible in theory, it's decidedly non-trivial, and
needs invasive changes to rust itself. In any case, it doesn't matter
until we decide the story around libc.

3. The 16-byte (i128) version of compare_and_swap. This wouldn't be
   *too* hard to add, but it would be hard to test. The way I tested the
existing code was not just with unit tests but also by loading it as a
path dependency and running `x test core` - the latter caught several
bugs the unit tests didn't catch (because I originally wrote the tests
wrong). So I am slightly nervous about adding a 16-byte version that is
much more poorly tested than the other intrinsics.
2023-06-26 05:56:08 +00:00
Amanieu d'Antras
7db8c0581d Disable another test on powerpc 2023-03-29 21:49:08 +01:00
Amanieu d'Antras
6b6db5cc84 Disable some PPC64 tests which are failing due to an LLVM(?) bug
See https://github.com/rust-lang/rust/issues/99853
2022-07-28 16:02:04 +01:00
David Hoppenbrouwers
e7a8932e3b
Fix CI, better memcmp tests 2022-05-28 00:10:55 +02:00
David Hoppenbrouwers
d6650678de
Fix formatting 2022-05-27 22:37:54 +02:00
David Hoppenbrouwers
4dbd8387f9
Implement faster memcmp for x86_64
x86_64 can load unaligned words in a single cache line as fast as
aligned words. Even when crossing cache or page boundaries it is just as
fast to do an unaligned word read instead of multiple byte reads.

Also add a couple more tests & benchmarks.
2022-05-27 21:58:39 +02:00
Ayrton
9124cdc7ec Remove truncdfsf2.c from sources in build.rs and add test for __truncdfsf2vfp
Also fixed the calling convention for truncdfsf2 on ARM
2021-12-12 21:12:42 -05:00
Ayrton
9e65060184 Add __truncdfsf2 intrinsic
This adds the truncdfsf2 intrinsic and a corresponding fuzz test case. The
implementation of trunc is generic to make it easy to add truncdfhs2 and
truncsfhf2 if rust ever gets `f16` support.
2021-12-12 15:01:34 -05:00
Amanieu d'Antras
a71b0e4493 Disable broken powerpc64 test due to https://github.com/rust-lang/rust/issues/88520 2021-10-15 02:11:12 +02:00
Gary Guo
d282412f70 Add test cases for memcpy, memmove and memset for different alignment 2021-08-21 03:01:39 +01:00
Amanieu d'Antras
189b987a25 Revert "Disable AArch64 FP-to-int tests"
This reverts commit 9e76b9115fa9571501d378b6329ce557266908b7.
2021-04-23 18:54:12 +01:00
Aaron Kutch
94af8a8268 Delete redundant tests
The old tests were hacky and did not cover nearly as many cases as the new tests do.
2021-04-02 08:58:50 -05:00
Aaron Kutch
3871282eee fix powi 2021-04-02 08:58:50 -05:00
Aaron Kutch
96a6110d69 add remaining floating point tests 2021-04-02 08:58:50 -05:00