Commit Graph

1197 Commits

Author SHA1 Message Date
Trevor Gross
7065cd0420 Rename EXP_MAX to EXP_SAT
"Maximum" is technically correct here with regards to what the
bitpattern can represent, but it is not the numeric maximum value of the
exponent which has a relationship with the bias. So, replace the maximum
terminology with "saturated" to indicate it only means the full
bitpattern.

This change is more relevant to `libm` than `compiler-builtins`.
2025-01-03 02:56:34 +00:00
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
github-actions[bot]
a078f5a0c5 chore: release v0.1.140 2024-12-26 00:16:33 -05:00
Sebastian Neubauer
e8eb76a45a
Disable f128 for amdgpu (#737)
`compiler_builtins` fails to compile to amdgpu if f128 is enabled.
The reason seems to be that compiler_builtins uses libcalls in the
implementation. I’m not really familiar with what libcalls are, but the
LLVM amdgpu backend explicitly does not support them.

Error message:
```
LLVM ERROR: unsupported libcall legalization
```
2024-12-26 00:01:14 -05:00
Trevor Gross
a4d9b4a6a2 Fix a bug in abs_diff
These implementations of `abs_diff` were added in c2ff1b3119
("Completely overhaul fuzz testing"), but the signed implementation is
wrong when |x| + |y| exceeds the integer's limits (e.g.
`(-128).abs_diff(1)` should be 128 but currently these return 127.

Resolve this by just using `std`'s implementation since that is stable
now. This isn't used anywhere critical, we probably just weren't hitting
the edge case.
2024-12-22 22:08:31 +00:00
Trevor Gross
04ccb683d9 Disable f16 on platforms that have recursion problems
CI in [1] seems to indicate that there are cases where the `f16`
infinite recursion bug ([2], [3]) can make its way into what gets called
during tests, even though this doesn't seem to be the usual case. In
order to make sure that we avoid these completely, just unset
`f16_enabled` on any platforms that have the recursion problem.

This also refactors the `match` statement to be more in line with
`library/std/build.rs`.

[1]: https://github.com/rust-lang/compiler-builtins/pull/729
[2]: https://github.com/llvm/llvm-project/issues/97981
[3]: https://github.com/rust-lang/compiler-builtins/issues/651
2024-11-05 02:57:34 -06:00
github-actions[bot]
c33f521bb5
chore: release v0.1.139 2024-11-03 23:08:41 +00:00
beetrees
10bdf3b6c1
Remove incorrect sparcv9 match pattern from configure_f16_f128 2024-11-03 22:54:01 +00:00
github-actions[bot]
4c7450d10c
chore: release v0.1.138 2024-11-01 11:00:27 +00:00
Trevor Gross
28fb4bc868 Enable the changelog for release-plz
This crate isn't meant for direct use, but having an easy way to see
what changed between versions would still be helpful when this crate is
updated in rust-lang/rust.
2024-11-01 05:59:57 -05:00
WANG Rui
ec673535f7 ci: add support for loongarch64-unknown-linux-gnu 2024-11-01 05:48:47 -05:00
hev
ca996df5c1
Use f16_enabled/f128_enabled in examples/intrinsics.rs (#724)
Enable conditional compilation for intrinsics with `f16_enabled` and `f128_enabled`
2024-11-01 10:34:51 +00:00
hev
53b3e71bbc
Disable f16 for LoongArch64 (#722)
Disable `f161` for LoongArch64 due to incorrect code generation on LLVM 19,
which causes failures in `testcrate/tests/conv.rs`. This workaround will
remain in place until llvm/llvm-project#109093 is merged or we upgrade to
LLVM 20.
2024-11-01 10:00:00 +00:00
github-actions[bot]
94e6ed373a chore: release v0.1.137 2024-10-31 19:13:38 -05: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
github-actions[bot]
f9914e98b3
chore: release v0.1.136 2024-10-26 23:29:14 +00:00
Trevor Gross
01a2a13a01 Update the libm submodule 2024-10-26 18:22:14 -05:00
Trevor Gross
6399bed36c Update licensing to MIT AND Apache-2.0 WITH LLVM-exception
Currently, Cargo.toml specifies Apache-2.0 OR MIT, but LICENSE.txt
describes MIT OR NCSA. compiler-builtins is derived from LLVM's
compiler-rt. LICENSE.txt correctly reflects the state of compiler-rt
prior to relicensing on 2019-01-19, during which time software was
available for use under either MIT or the University of Illinois NCSA
license. After relicensing, however, compiler-rt is available for use
only under Apache-2.0 with the LLVM exception; this is not reflected
anywhere in the repository.

Update the SPDX license identifier to `MIT AND Apache-2.0 WITH
LLVM-exception AND (MIT OR Apache-2.0)`. Each AND portion covers
something specific:

* Apache-2.0 WITH LLVM-exception: this covers work that is derived from
  the LLVM repository since after the LLVM relicensing.
* MIT: This covers work that is derived from LLVM before the LLVM
  relicensing (under MIT OR NCSA), as well as the vendored `libm`
  components.
* MIT AND Apache-2.0: This ensures that any contributions to this
  repository, in addition to meeting the above required licenses, is
  also released for use under the Rust-standard Apache-2.0 with no LLVM
  exception.

See also the parallel license update in rust-lang/libm [1].

Fixes: https://github.com/rust-lang/compiler-builtins/issues/307
Closes: https://github.com/rust-lang/compiler-builtins/pull/511
Link: https://rust-lang.zulipchat.com/#narrow/channel/335408-foundation/topic/Request.20for.20legal.20team.20input.20on.20crate.20licensing
Link: https://github.com/rust-lang/libm/pull/317 [1]
2024-10-26 17:35:26 -05:00
Trevor Gross
394fb9f2bc Add an abs function to the Float trait
There is no in-crate use for this yet, but we will make use of it in
`libm`.
2024-10-25 14:30:03 -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
github-actions[bot]
ce89a70ae4
chore: release v0.1.135 2024-10-23 09:57:03 +00:00
Niklas Sombert
68b820187b Re-enable math module on i686-unknown-uefi
In 9ba77d1583e6de5ab9cf7c9b82827ba8fcb9062f, this was disabled for x86
without sse2. It should be fine to re-enable it for UEFI, as explained at
<https://github.com/rust-lang/rust/issues/128533#issuecomment-2408699671>.
2024-10-23 11:39:33 +02:00
github-actions[bot]
3e922da156
chore: release v0.1.134 2024-10-17 23:55:25 +00:00
Ben Kimock
2a738c50ab Use wrapping pointer arithmetic in mem/impls.rs
Add a comment (and fix a typo)
2024-10-16 22:37:42 -04:00
github-actions[bot]
fedfc6aaab
chore: release 2024-10-06 02:08:00 +00:00
Trevor Gross
996799a896 Add a note about avoiding default implemenations in some places
Link: https://github.com/rust-lang/compiler-builtins/pull/707
2024-10-05 20:55:47 -05:00
Enzo "raskyld" Nocera
8153729f91 fix(int): avoid infinite recursion on left shift
Please, see this discussion for the full
context: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.5Bwasm32.5D.20Infinite.20recursion.20.60compiler-builtins.60.20.60__multi3.60

Signed-off-by: Enzo "raskyld" Nocera <enzo@nocera.eu>

We determined that some recursion problems on SPARC and WASM were due to
infinite recusion. This was introduced at 9c6fcb56e8 ("Split Int into
Int and MinInt") when moving the implementation of `widen_hi` from
something on each `impl` block to a default on the trait. The reasoning
is not fully understood, but undoing this portion of the change seems to
resolve the issue.

[ add the above context - Trevor ]

Signed-off-by: Trevor Gross <tmgross@umich.edu>
2024-10-05 20:49:45 -05:00
github-actions[bot]
3edc27ef56
chore: release 2024-10-04 17:17:03 +00:00
Alan Wu
3f70601e3c Allow implicit function decl on A64
Testing in <https://github.com/rust-lang/rust/pull/131221>, we found
that <https://github.com/rust-lang/compiler-builtins/pull/627> is
unusable with the current LLVM version.
2024-10-04 12:33:16 -04:00
Trevor Gross
76580a96a7 Upgrade CI LLVM version to 19.1
19.1 is the latest stable release from 2024-09-17. This will match what
is currently being used in rust-lang/rust.
2024-10-03 11:49:45 -04:00
github-actions[bot]
859e22b4ae
chore: release 2024-10-03 15:37:33 +00:00
Alan Wu
edc6f80dcc Build with -Werror=implicit-function-declaration
To prevent fail-fast in situations like
https://github.com/rust-lang/rust/issues/125619, where an upstream
source compiles but creates a link error way downstream.
2024-10-03 11:24:49 -04:00
Trevor Gross
0c97b10dc0 Add riscv64gc to CI
There is a proposal to promote `riscv64gc-unknown-linux-gnu` to tier 1
[1]. We do not currently test RISC-V in CI; add it here.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Imminent.20RFC.20PR.3A.20riscv64gc-unknown-linux-gnu.20to.20Tier-1
2024-10-02 16:35:28 -04:00
Trevor Gross
85cd4c0660 Fix some warnings from shellcheck 2024-09-28 21:24:44 -04:00
Trevor Gross
c6b434e5a3 Revert "Temporarily use define_rust_probestack;"
<https://github.com/rust-lang/rust/issues/126984> has been resolved.
Remove the workaround that was introduced to suppress it.

This reverts commit 254edbcad4cfd6a8af32e3297c1037d7984c3c49.
2024-09-28 18:22:22 -04: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
github-actions[bot]
8a13ab7dfc
chore: release 2024-09-28 15:13:17 +00: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
github-actions[bot]
c48926906a
chore: release 2024-09-27 11:08:02 +00:00
Trevor Gross
1649f72ea6
Revert "Bump cc dependency" 2024-09-27 07:00:19 -04:00
Davide Mor
8c31ec9e7d Fixed __divtf3 having wrong cfg for f128 2024-09-26 15:25:48 +02:00
github-actions[bot]
1e5bf9e166
chore: release 2024-09-25 14:37:03 +00:00
Artyom Tetyukhin
70d74bb7a4
Bump cc dependency 2024-09-25 18:21:36 +04:00