Commit Graph

116 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
9818afad7c Remove the unneeded isqrt feature gate
[1] has been stabilized so we no longer need to enable it.

[1]: https://github.com/rust-lang/rust/issues/116226
2024-10-30 12:27:59 -05: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
2f7fafd182 Rename Float::repr and Float::from_repr
`to_bits` and `from_bits` are builtin methods on float types. Rename
`repr` to `to_bits` and `from_repr` to `from_bits` so this is consistent
with usage that doesn't go through the trait.
2024-10-25 14:18:53 -05:00
Trevor Gross
e226c0dce5 Ungate tests that were skipped due to a broken implementation
The upstream issue [1] has been resolved so we can enable these tests
again.

[1]: https://github.com/rust-lang/compiler-builtins/issues/616
2024-09-28 18:13:34 -04:00
Trevor Gross
4ae984cbce Resolve FIXMEs related to f16 assembly
We have a couple FIXMEs from before aarch64 `f16` assembly support
existed. We have this available now, so resolve the notes here.
2024-09-28 17:57:06 -04:00
Trevor Gross
b2db9e8e89 Add a benchmark for __powitf2 2024-09-28 11:06:33 -04: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
4842bd6ab1 Add benchmarks for f128 division 2024-09-24 18:32:58 +02: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
Trevor Gross
db9debf096 Apply fixes to build.rs files
Make the following changes:

- Add `rerun-if-changed` to the new `configure.rs`, it seems this was
  causing incorrect caching.
- Change from matching `i686` to `x86`. The target triple starts with
  `i686` so that is what we were checking before, but the architecture
  is `x86`. This change should have been made when we added `struct
  Target`, update it now instead.
2024-08-19 07:04:07 -05:00
Kleis Auke Wolthuizen
13cc7daf05 Fix CI for targets that conditionally disable f16 or f128 support 2024-08-12 14:56:59 +02:00
Kleis Auke Wolthuizen
5dad727bdc Configure f16 and f128 support for WebAssembly 2024-08-11 17:25:55 +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
Trevor Gross
b6c2b6ebf7 Update to the latest rustc_apfloat
The latest version has a convenient `.unwrap()`. Increase the version so
we can use this.
2024-08-03 02:02:44 -04:00
Trevor Gross
1cdeaed9f9 Correct sys_avialable for f64 -> f16 truncation
The `sys_available` gate was incorrect. Update it.
2024-08-03 02:02:44 -04:00
Trevor Gross
db8daebd5b Update which platforms have no f16 symbols
Previously we were building the C versions of these symbols. Since we
added the Rust version and updated compiler builtins, these are no
longer available by default. This is unintentional, but it gives a
better indicator of which symbol versions are not actually provided by
the system.

Use the list of build failures to correct the list of platforms that do
not have `f16` symbols.
2024-08-03 02:02:44 -04:00
Trevor Gross
364dd5fd5b Add release-plz for automatic releases.
This is what `cc-rs` is using and should create a release PR whenever a
change to `master` is made. If the branch is merged, it should publish
the new version.

Includes configuration to disable semver checks and not keep a changelog
since this is an implementation detail.
2024-07-26 23:45:35 -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
Trevor Gross
32b12b647b Remove unnecessary benchmark files 2024-07-05 22:17:50 +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
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