Commit Graph

50 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
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
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
Joseph Richey
34e35d74b6
Use REP MOVSQ/STOSQ on x86_64 (#365)
* mem: Move mem* functions to separate directory

Signed-off-by: Joe Richey <joerichey@google.com>

* memcpy: Create separate memcpy.rs file

Signed-off-by: Joe Richey <joerichey@google.com>

* benches: Add benchmarks for mem* functions

This allows comparing the "normal" implementations to the
implementations provided by this crate.

Signed-off-by: Joe Richey <joerichey@google.com>

* mem: Add REP MOVSB/STOSB implementations

The assembly generated seems correct:
    https://rust.godbolt.org/z/GGnec8

Signed-off-by: Joe Richey <joerichey@google.com>

* mem: Add documentations for REP string insturctions

Signed-off-by: Joe Richey <joerichey@google.com>

* Use quad-word rep string instructions

Signed-off-by: Joe Richey <joerichey@google.com>

* Prevent panic when compiled in debug mode

Signed-off-by: Joe Richey <joerichey@google.com>

* Add tests for mem* functions

Signed-off-by: Joe Richey <joerichey@google.com>

* Add build/test with the "asm" feature

Signed-off-by: Joe Richey <joerichey@google.com>

* Add byte length to Bencher

Signed-off-by: Joe Richey <joerichey@google.com>
2020-10-24 10:58:04 -05:00
Aaron Kutch
92f0680743 Add __divmodti4 2020-08-29 18:02:57 -05:00
Aaron Kutch
d1c8673332 Use specialized-div-rem 1.0.0 for division algorithms 2020-08-14 15:31:36 -05:00
Aaron Kutch
7652f288d3
Improve __clzsi2 performance (#366) 2020-07-28 13:09:18 -05:00
Runji Wang
304028b2ed Fix compile error on x86_64-unknown-uefi target (#331)
* fix compile error on x86_64-unknown-uefi target

* Fix tests on nightly
2019-12-10 09:02:14 -08:00
Alex Crichton
3f473cd3f3
Allow FFI-unsafe warnings for u128/i128 (#323)
* Allow FFI-unsafe warnings for u128/i128

Handle new warnings on nightly, and we shouldn't need to worry about
these with compiler-builtins since this is tied to a particular compiler.

* Clean up crate attributes

* No need for stability marker
* Rustdoc docs not used for this crate
* Remove old build-system related cruft from rustc itself.

* Run `cargo fmt`
2019-11-11 12:19:10 -06:00
Alex Crichton
b2cfc3a4f1 Run rustfmt over everything 2019-05-14 14:40:38 -07:00
Lokathor
a68950646f Move the test to be a standard test. 2019-01-02 18:50:11 -07:00
Alex Crichton
99d7dde58d Attempt to fix tests on latest nightly 2018-05-11 16:45:30 -07:00
Paolo Teti
64ea229988 Fix CI for thumb* targets
Main fix is inside 'utest' all the rest are minor fixes due to the
new 'testcrate'.

Still allow failures on TravisCI for a while.
2018-02-18 18:15:57 +01:00
Alex Crichton
41290fe728 Simplify how testing is done
All tests are moved to a separate crate in this repository to enable features by
default. Additionally the test generation is moved to a seprate build script and
simplified to reduce the amount of boilerplate needed per test.

Overall this should still be testing everything, just in a different location!
2018-01-31 11:32:20 -08:00