Commit Graph

87 Commits

Author SHA1 Message Date
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
55b3f8b13d Enable f128 -> f16 tests on Linux
Since updating the docker images in
<https://github.com/rust-lang/compiler-builtins/pull/625>, it looks like
`__extendhftf2` and `__trunctfhf2` are available on all 64-bit Linux
platforms.
2024-06-25 23:57:08 +02:00
Trevor Gross
21690f7320 Skip f128 tests on powerpc64le
__addkf3 and __mulkf3 seem to hit a nondescript SIGILL. This is probably
likely to just be another Qemu limitation.
2024-06-22 06:05:25 -04:00
Trevor Gross
6cd17ff4d2 Add benchmarks for floating point math
This adds comparisons among the compiler-builtins function, system
functions if available, and optionally handwritten assembly.

These also help us identify inconsistencies between this crate and
system functions, which may otherwise go unnoticed if intrinsics get
lowered to inline operations rather than library calls.
2024-05-24 02:49:41 -04: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
a3b1dfb8d5 Allow a specific fallback function in apfloat_fallback
`as` casts are only allowed for primitives, doing the same operations
with `rustc_apfloat` requires using functions. Add a way to specify
these separately.
2024-05-20 20:00:46 -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
10689247bc Split Int into Int and MinInt
`MinInt` contains the basic methods that are only needed by integers
involved in widening operations, i.e. big integers. `Int` retains all
other operations and convenience methods.
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
Nicholas Bishop
524ca7ceb6 Remove unused no-lang-items feature 2022-11-12 12:09:06 -05: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
8535675a17 Add misaligned benchmarks 2021-08-21 03:03:06 +01:00
Gary Guo
d282412f70 Add test cases for memcpy, memmove and memset for different alignment 2021-08-21 03:01:39 +01:00
Aaron Kutch
fdcc30c3a3 Add public-test-deps feature for better visibility control 2021-06-02 14:13:54 -05: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
5221cef1fc Remove rand dependency, update rand_xoshiro 2021-04-02 09:35:01 -05: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
Aaron Kutch
ec4fc5dab5 refactor float conversion 2021-04-02 08:58:50 -05:00
Amanieu d'Antras
bffd24076b
Merge pull request #406 from bjorn3/less_rust_intrinsics
Remove unused __rust_* shift intrinsics
2021-04-02 12:59:26 +01:00
Amanieu d'Antras
880ec8bb83 Disable AArch64 FP-to-int tests
This is a temporary workaround for https://github.com/rust-lang/rust/issues/83467
2021-04-02 12:36:57 +01:00
bjorn3
c75621f12c Remove unused __rust_* shift intrinsics
They are rust specific and used by neither cg_llvm nor cg_clif
2021-02-21 11:36:47 +01:00
Aaron Kutch
69a3c571f7 Completely overhaul fuzz testing
adds testing for almost every numerical intrinsic
2020-12-08 11:42:28 -06:00
Aaron Kutch
f61c411e2b fix some clippy warnings 2020-12-07 23:26:26 -06:00
Aaron Kutch
26681724f3 replace some transmutes 2020-12-07 23:26:25 -06:00