mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Auto merge of #164333 - tgross35:update-builtins, r=tgross35
compiler-builtins subtree update
Subtree update of `compiler-builtins` to c8f734e1a0.
Created using https://github.com/rust-lang/josh-sync.
r? @ghost
This commit is contained in:
@@ -12,3 +12,6 @@ indent_size = 4
|
||||
|
||||
[*.{yaml,yml}]
|
||||
indent_size = 2
|
||||
|
||||
[*.json*]
|
||||
indent_size = 2
|
||||
|
||||
31
library/compiler-builtins/.github/renovate.json5
vendored
31
library/compiler-builtins/.github/renovate.json5
vendored
@@ -5,26 +5,37 @@
|
||||
":maintainLockFilesMonthly",
|
||||
"helpers:pinGitHubActionDigestsToSemver"
|
||||
],
|
||||
commitMessagePrefix: "deps:",
|
||||
customManagers: [
|
||||
{
|
||||
customType: "regex",
|
||||
managerFilePatterns: [".github/workflows/main.yaml"],
|
||||
matchStrings: ["BENCHMARK_RUSTC:\\s*(?<currentValue>\\S+)"],
|
||||
autoReplaceStringTemplate: "BENCHMARK_RUSTC: {{{newValue}}}",
|
||||
depNameTemplate: "nightly",
|
||||
datasourceTemplate: "rust-version",
|
||||
versioningTemplate: "rust-release-channel",
|
||||
},
|
||||
],
|
||||
packageRules: [
|
||||
{
|
||||
matchCategories: [
|
||||
"rust"
|
||||
],
|
||||
matchJsonata: [
|
||||
"isBreaking != true"
|
||||
],
|
||||
matchCategories: ["rust"],
|
||||
matchJsonata: ["isBreaking != true"],
|
||||
// Disable non-breaking change updates because they
|
||||
// are updated periodically with lockfile maintainance.
|
||||
enabled: false,
|
||||
},
|
||||
{
|
||||
matchManagers: [
|
||||
"github-actions"
|
||||
],
|
||||
matchManagers: ["github-actions"],
|
||||
// Every month
|
||||
schedule: "* 0 1 * *",
|
||||
commitMessagePrefix: "ci:",
|
||||
groupName: "Github Actions",
|
||||
}
|
||||
},
|
||||
{
|
||||
matchManagers: ["custom.regex"],
|
||||
commitMessage: "bench: Update pinned toolchain to {{{newVersion}}}",
|
||||
},
|
||||
],
|
||||
// Receive any update that fixes security vulnerabilities.
|
||||
// We need this because we disabled "patch" updates for Rust.
|
||||
|
||||
@@ -16,7 +16,7 @@ env:
|
||||
RUSTDOCFLAGS: -Dwarnings
|
||||
RUSTFLAGS: -Dwarnings -Dlinker_messages
|
||||
RUST_BACKTRACE: full
|
||||
BENCHMARK_RUSTC: nightly-2026-08-19 # Pin the toolchain for reproducable results
|
||||
BENCHMARK_RUSTC: nightly-2026-09-26 # Pin the toolchain for reproducable results
|
||||
|
||||
defaults:
|
||||
run:
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
|
||||
test:
|
||||
name: Build and test
|
||||
timeout-minutes: 60
|
||||
timeout-minutes: 90
|
||||
# NOTE: self-hosted riscv64 runners are experimental and may be flaky.
|
||||
# Do not block CI on failures from this platform for now.
|
||||
continue-on-error: ${{ contains(matrix.os, 'self-hosted') }}
|
||||
@@ -71,6 +71,8 @@ jobs:
|
||||
os: ubuntu-26.04
|
||||
- target: armv7-unknown-linux-gnueabihf
|
||||
os: ubuntu-26.04
|
||||
- target: armv7-unknown-linux-gnueabihf
|
||||
os: self-hosted-linux-armhf-noble-large-rust
|
||||
- target: thumbv7neon-unknown-linux-gnueabihf
|
||||
os: ubuntu-26.04
|
||||
- target: i586-unknown-linux-gnu
|
||||
@@ -94,8 +96,8 @@ jobs:
|
||||
# os: ["self-hosted", "linux", "riscv64"]
|
||||
- target: riscv64gc-unknown-linux-gnu
|
||||
os: ubuntu-26.04
|
||||
- target: s390x-unknown-linux-gnu
|
||||
os: self-hosted-linux-s390x-resolute-large-rust # resolute == ubuntu-26.04
|
||||
# - target: s390x-unknown-linux-gnu
|
||||
# os: self-hosted-linux-s390x-resolute-large-rust # resolute == ubuntu-26.04
|
||||
- target: s390x-unknown-linux-gnu
|
||||
os: ubuntu-24.04-s390x
|
||||
- target: thumbv6m-none-eabi
|
||||
@@ -149,7 +151,7 @@ jobs:
|
||||
- name: Set up dependencies and Rust
|
||||
run: ./ci/install-test-deps.sh "$JOB_TARGET" "$JOB_HOST_TOOLCHAIN"
|
||||
|
||||
- uses: taiki-e/install-action@7f4eb899022d8fe70b20c4f3de697aa85c309026 # v2.85.11
|
||||
- uses: taiki-e/install-action@f7e5d7c961414b23f5b25b2da9294395d08513ad # v2.87.26
|
||||
continue-on-error: true
|
||||
with:
|
||||
tool: nextest@0.9.131
|
||||
@@ -169,7 +171,7 @@ jobs:
|
||||
key: ${{ matrix.target }}-buildx-${{ github.sha }}
|
||||
restore-keys: ${{ matrix.target }}-buildx-
|
||||
# Configure buildx to use Docker layer caching
|
||||
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
|
||||
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
if: ${{ env.RUN_IN_DOCKER == 'true' }}
|
||||
|
||||
- name: Cache compiler-rt
|
||||
@@ -243,7 +245,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with: { persist-credentials: false }
|
||||
- uses: zizmorcore/zizmor-action@3dc1ecc9bcb9e94e9b2c709687979e1298497054 # v0.6.2
|
||||
- uses: zizmorcore/zizmor-action@cc914d7f3750a2d13d75c7f184a1060aa0e9d482 # v0.6.4
|
||||
|
||||
build-custom:
|
||||
name: Build custom target
|
||||
@@ -305,7 +307,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with: { persist-credentials: false }
|
||||
- uses: taiki-e/install-action@7f4eb899022d8fe70b20c4f3de697aa85c309026 # v2.85.11
|
||||
- uses: taiki-e/install-action@f7e5d7c961414b23f5b25b2da9294395d08513ad # v2.87.26
|
||||
with:
|
||||
tool: cargo-binstall@1.17.7
|
||||
|
||||
@@ -324,7 +326,7 @@ jobs:
|
||||
run: ./ci/bench-icount.sh "$JOB_TARGET"
|
||||
|
||||
- name: Upload the benchmark baseline
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: ${{ env.BASELINE_NAME }}
|
||||
path: ${{ env.BASELINE_NAME }}.tar.xz
|
||||
|
||||
@@ -3,6 +3,7 @@ name: Release-plz
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
id-token: write
|
||||
|
||||
on:
|
||||
push: { branches: [main] }
|
||||
@@ -10,7 +11,7 @@ on:
|
||||
jobs:
|
||||
release-plz:
|
||||
name: Release-plz
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-26.04
|
||||
environment: publish
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
@@ -20,6 +21,6 @@ jobs:
|
||||
- name: Install Rust (rustup)
|
||||
run: rustup update nightly --no-self-update && rustup default nightly
|
||||
- name: Run release-plz
|
||||
uses: release-plz/action@2eb1d8bcb770b4c48ccfaad919734b38b51958c9 # v0.5
|
||||
uses: release-plz/action@18641b6c63063cc5ff8786ebf69cd57e8541bae1 # v0.5.140
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -13,7 +13,8 @@ env:
|
||||
jobs:
|
||||
pull:
|
||||
if: github.repository == 'rust-lang/compiler-builtins'
|
||||
uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@00d007cf377c524bc2968b40a61ef1d2ce20e283 # main
|
||||
# zizmor: ignore[unpinned-uses] We explicitly want to track the main branch.
|
||||
uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@b1da651cd99a7325cc242548db6d711639b0c30c # main
|
||||
with:
|
||||
github-app-id: ${{ vars.APP_CLIENT_ID }}
|
||||
pr-author: "workflows-compiler-builtins[bot]"
|
||||
|
||||
@@ -133,9 +133,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.13.1"
|
||||
version = "2.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
|
||||
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
@@ -174,9 +174,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.4.4"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ad534f4357a5264cce5019c989cf66a4f0dc4e0d1b1d15f8aacec0ff7360273"
|
||||
checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
@@ -184,9 +184,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
||||
|
||||
[[package]]
|
||||
name = "chacha20"
|
||||
@@ -228,9 +228,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.6.6"
|
||||
version = "4.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca"
|
||||
checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -238,9 +238,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.6.6"
|
||||
version = "4.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889"
|
||||
checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -250,21 +250,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.6.4"
|
||||
version = "4.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d012d2b9d65aca7f18f4d9878a045bc17899bba951561ba5ec3c2ba1eed9a061"
|
||||
checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.4",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
|
||||
checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
@@ -281,9 +281,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.16.4"
|
||||
version = "0.16.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fe5f465a4f6fee88fad41b85d990f84c835335e85b5d9e6e63e0d06d28cba7c"
|
||||
checksum = "e96a4956774c13c126a8b5af4daa79384f4d826534c95a02d76afb39e2ab64e3"
|
||||
dependencies = [
|
||||
"encode_unicode",
|
||||
"libc",
|
||||
@@ -301,9 +301,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.5.1"
|
||||
version = "1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8498c871161e1742aaa9d52551b2d6ebdd4c3d45a3be423e3728f33b955be550"
|
||||
checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
@@ -344,9 +344,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.7"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5181e0de7b61eb03a81e347d6dd8797bae9da5146707b51077e2d71a54ec0ceb"
|
||||
checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
@@ -354,18 +354,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.20"
|
||||
version = "0.9.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f"
|
||||
checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.22"
|
||||
version = "0.8.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17"
|
||||
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
@@ -408,9 +408,9 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.18.0"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
|
||||
checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
||||
|
||||
[[package]]
|
||||
name = "either-or-both"
|
||||
@@ -446,9 +446,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "escape8259"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6"
|
||||
checksum = "9f1f0d310082fd5de539d4f41601182241147498444a7695c520288a0cdbead6"
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
@@ -458,9 +458,9 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.11"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d45db016d36b838f563236e9193d0ee6ce38f3f68b6c94e914b4929c96bbb890"
|
||||
checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
@@ -538,21 +538,28 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gungraun"
|
||||
version = "0.19.4"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9300d38d30facf6870c15bc9e243edcc47e5ddc270c9d2c1ae824a00b1faea79"
|
||||
checksum = "c041375e48b8ef7cd2d0e70715598154af627c1a551e41c35fdb4a2b3910831a"
|
||||
dependencies = [
|
||||
"bincode-next",
|
||||
"derive_more",
|
||||
"gungraun-common",
|
||||
"gungraun-macros",
|
||||
"gungraun-runner",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gungraun-macros"
|
||||
version = "0.9.1"
|
||||
name = "gungraun-common"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7f3214bae6cfd6739f4f29edb262bae439c6393a7b7b12c4eeb96417c2e50df"
|
||||
checksum = "bc270ba55639babb5806b62d4bfbc35e15ca15791e3ec00c7b92b39c62a9d8eb"
|
||||
|
||||
[[package]]
|
||||
name = "gungraun-macros"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08472a9e996a98a5b4274dd342fb32ebe1a5cfeb2662b6578d0c7bf1dd203129"
|
||||
dependencies = [
|
||||
"derive_more",
|
||||
"proc-macro-error3",
|
||||
@@ -561,14 +568,14 @@ dependencies = [
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn 2.0.119",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gungraun-runner"
|
||||
version = "0.19.4"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47c68c92812da579a2510a2cc702d5aa3251992b9662d4a98502ca46e0cbe16e"
|
||||
checksum = "1e1460377fe936c3efbe8e27c422b745fa54ebaea81ffe4a53a6f17c7a478683"
|
||||
dependencies = [
|
||||
"either-or-both",
|
||||
"serde",
|
||||
@@ -599,9 +606,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.14.1"
|
||||
version = "2.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07aa2048142242915a31d35844fb311e0e53fcca590c3a0a40dcf1b841fa09eb"
|
||||
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
@@ -642,9 +649,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.104"
|
||||
version = "0.3.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a"
|
||||
checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-util",
|
||||
@@ -653,9 +660,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.189"
|
||||
version = "0.2.190"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
||||
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
@@ -678,7 +685,7 @@ dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.4",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -754,7 +761,7 @@ checksum = "fc80370b4544f28ffa317e3c3474ee3ecbfe269196c01ae657d9f837a7d944a1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.4",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -927,7 +934,7 @@ dependencies = [
|
||||
"proc-macro-error-attr3",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.4",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -956,9 +963,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.10.2"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"
|
||||
checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
|
||||
dependencies = [
|
||||
"chacha20",
|
||||
"getrandom",
|
||||
@@ -1081,9 +1088,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.1.4"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
|
||||
checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
@@ -1149,7 +1156,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.4",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1185,9 +1192,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.2"
|
||||
version = "1.16.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
|
||||
checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
@@ -1221,15 +1228,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.4"
|
||||
version = "3.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6275cddf4610d1775e6d1fe9469b2e77d0f39fd98fb7450901b821e0c53649f"
|
||||
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sysbench"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.27.0"
|
||||
@@ -1261,15 +1272,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "twox-hash"
|
||||
version = "2.1.4"
|
||||
version = "2.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5283634e518fe9e82c7b20520bb4bc209009fd16c82077c802f8111ecbb0117a"
|
||||
checksum = "86a801b3cea342a06d468c8710662aa29e5e05e4f5c0d62f00bbb7f2ad7941c2"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.24"
|
||||
version = "1.0.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
@@ -1338,9 +1349,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.127"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70"
|
||||
checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
@@ -1351,9 +1362,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.127"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1"
|
||||
checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -1361,22 +1372,22 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.127"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284"
|
||||
checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
"syn 3.0.6",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.127"
|
||||
version = "0.2.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf"
|
||||
checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -1392,9 +1403,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.104"
|
||||
version = "0.3.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c435338968042f4f59a557f690a253676d47ce13ceb55d70100e7facf6620a30"
|
||||
checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
@@ -1464,18 +1475,18 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.56"
|
||||
version = "0.8.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "556764e583adb45a9f8d413c2a147fa7e8d821e48e12b14fd560b607998b75eb"
|
||||
checksum = "86502bf56ac7c77571a32e2647bb2a15894565e981fb2a48d7bde2d91c965a9d"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.56"
|
||||
version = "0.8.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2ab42fc20575779bd240faa45f94a74256f755c0fa9e89f0ede20d91d0cdfc1"
|
||||
checksum = "5457206954b06561e2608c7e19cf58b1926586d999c246eebe4502f7e2039d1a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1484,9 +1495,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zlib-rs"
|
||||
version = "0.6.7"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34b31d188d9d685a4f9c7b46d6e36631b07058d2cfe190267adce54dc230bf12"
|
||||
checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
|
||||
@@ -8,6 +8,7 @@ members = [
|
||||
"crates/musl-math-sys",
|
||||
"crates/panic-handler",
|
||||
"crates/symcheck",
|
||||
"crates/sysbench",
|
||||
"crates/update-api-list",
|
||||
"crates/util",
|
||||
"libm",
|
||||
@@ -45,7 +46,7 @@ getopts = "0.2.24"
|
||||
getrandom = "0.4.1"
|
||||
glob = "0.3.3"
|
||||
gmp-mpfr-sys = { version = "1.6.8", default-features = false }
|
||||
gungraun = "0.19.0"
|
||||
gungraun = "0.20.0"
|
||||
heck = "0.5.0"
|
||||
indicatif = { version = "0.18.3", default-features = false }
|
||||
libm = { path = "libm", default-features = false }
|
||||
|
||||
@@ -15,9 +15,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.4.4"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ad534f4357a5264cce5019c989cf66a4f0dc4e0d1b1d15f8aacec0ff7360273"
|
||||
checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
@@ -32,9 +32,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.11"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d45db016d36b838f563236e9193d0ee6ce38f3f68b6c94e914b4929c96bbb890"
|
||||
checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
|
||||
|
||||
[[package]]
|
||||
name = "panic-handler"
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#![feature(f128)]
|
||||
#![feature(f16)]
|
||||
#![feature(lang_items)]
|
||||
#![feature(optimize_attribute)]
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
|
||||
@@ -22,9 +22,7 @@ float_bench! {
|
||||
asm: [],
|
||||
}
|
||||
|
||||
// FIXME(f16_f128): can be changed to only `f128_enabled` once `__multf3` and `__divtf3` are
|
||||
// distributed by nightly.
|
||||
#[cfg(all(f128_enabled, not(no_sys_f128)))]
|
||||
#[cfg(f128_enabled)]
|
||||
float_bench! {
|
||||
name: powi_f128,
|
||||
sig: (a: f128, b: i32) -> f128,
|
||||
@@ -42,7 +40,7 @@ pub fn float_pow() {
|
||||
powi_f32(&mut criterion);
|
||||
powi_f64(&mut criterion);
|
||||
|
||||
#[cfg(all(f128_enabled, not(no_sys_f128)))]
|
||||
#[cfg(f128_enabled)]
|
||||
powi_f128(&mut criterion);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,13 +41,37 @@ mod i_to_f {
|
||||
);
|
||||
let f1: $f_ty = $fn(x);
|
||||
|
||||
if f1.is_nan() {
|
||||
panic!("int->float cannot result in a NaN: {}({x})", stringify!($fn));
|
||||
}
|
||||
|
||||
#[cfg($sys_available)] {
|
||||
// If `f1` is infinite, calculate the integer that is 1 ULP after/before
|
||||
// $f_ty::MAX/$f_ty::MIN, saturating as needed. There's no need to
|
||||
// handle NaN as the result of a conversion can never be NaN.
|
||||
let as_int = |f: $f_ty| {
|
||||
if f.is_infinite() {
|
||||
// For infinity, calculate the float that is half of the desired
|
||||
// 1-ulp-after-max/-before-min (and therefore representable as
|
||||
// $f_ty), then multiply by two after converting to an integer.
|
||||
let bits = <$f_ty>::EXP_MASK - <$f_ty>::IMPLICIT_BIT;
|
||||
let bits = if f.is_sign_negative() {
|
||||
bits | <$f_ty as Float>::SIGN_MASK
|
||||
} else {
|
||||
bits
|
||||
};
|
||||
// float->int casts saturate, so saturate the multiply to match.
|
||||
(<$f_ty>::from_bits(bits) as $i_ty).saturating_mul(2)
|
||||
} else {
|
||||
f as $i_ty
|
||||
}
|
||||
};
|
||||
// This makes sure that the conversion produced the best rounding possible, and does
|
||||
// this independent of `x as $into` rounding correctly.
|
||||
// This assumes that float to integer conversion is correct.
|
||||
let y_minus_ulp = <$f_ty>::from_bits(f1.to_bits().wrapping_sub(1)) as $i_ty;
|
||||
let y = f1 as $i_ty;
|
||||
let y_plus_ulp = <$f_ty>::from_bits(f1.to_bits().wrapping_add(1)) as $i_ty;
|
||||
let y_minus_ulp = as_int(f1.next_down());
|
||||
let y = as_int(f1);
|
||||
let y_plus_ulp = as_int(f1.next_up());
|
||||
let error_minus = <$i_ty as Int>::abs_diff(y_minus_ulp, x);
|
||||
let error = <$i_ty as Int>::abs_diff(y, x);
|
||||
let error_plus = <$i_ty as Int>::abs_diff(y_plus_ulp, x);
|
||||
|
||||
@@ -58,7 +58,7 @@ mod cas {
|
||||
crate::run_fuzz_tests_with_lse_variants(10000, |expected: super::int_ty!($bytes), new| {
|
||||
let mut target = expected.wrapping_add(10);
|
||||
let ret: super::int_ty!($bytes) = unsafe {
|
||||
compiler_builtins::aarch64_outline_atomics::$name::$name(
|
||||
compiler_builtins::aarch64_outline_atomics::$name(
|
||||
expected,
|
||||
new,
|
||||
&mut target,
|
||||
@@ -77,7 +77,7 @@ mod cas {
|
||||
|
||||
target = expected;
|
||||
let ret: super::int_ty!($bytes) = unsafe {
|
||||
compiler_builtins::aarch64_outline_atomics::$name::$name(
|
||||
compiler_builtins::aarch64_outline_atomics::$name(
|
||||
expected,
|
||||
new,
|
||||
&mut target,
|
||||
@@ -108,9 +108,7 @@ mod swap {
|
||||
let orig_right = right;
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
compiler_builtins::aarch64_outline_atomics::$name::$name(
|
||||
left, &mut right,
|
||||
)
|
||||
compiler_builtins::aarch64_outline_atomics::$name(left, &mut right)
|
||||
},
|
||||
orig_right
|
||||
);
|
||||
@@ -132,7 +130,13 @@ macro_rules! test_op {
|
||||
let mut target = old;
|
||||
let op: fn(super::int_ty!($bytes), super::int_ty!($bytes)) -> _ = $($op)*;
|
||||
let expected = op(old, val);
|
||||
assert_eq!(old, unsafe { compiler_builtins::aarch64_outline_atomics::$name::$name(val, &mut target) }, "{} should return original value", stringify!($name));
|
||||
assert_eq!(
|
||||
old,
|
||||
unsafe {
|
||||
compiler_builtins::aarch64_outline_atomics::$name(val, &mut target)
|
||||
},
|
||||
"{} should return original value", stringify!($name)
|
||||
);
|
||||
assert_eq!(expected, target, "{} should store to target", stringify!($name));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![feature(optimize_attribute)]
|
||||
|
||||
use compiler_builtins::mem::{memcmp, memcpy, memmove, memset, strlen, wchar_t};
|
||||
|
||||
const WORD_SIZE: usize = core::mem::size_of::<usize>();
|
||||
|
||||
@@ -21,12 +21,34 @@ fi
|
||||
to_install=()
|
||||
|
||||
if [ "$RUN_IN_DOCKER" != "0" ]; then
|
||||
! command -v rustup && to_install+=(rustup)
|
||||
! command -v m4 && to_install+=(m4)
|
||||
command -v libtool || to_install+=(libtool)
|
||||
command -v m4 || to_install+=(m4)
|
||||
command -v make || to_install+=(make)
|
||||
command -v rustup || to_install+=(rustup)
|
||||
fi
|
||||
|
||||
if [ "$target" = "i686-pc-windows-gnu" ]; then
|
||||
! command -v i686-w64-mingw32-gcc && to_install+=(mingw-w64-i686-gcc)
|
||||
command -v i686-w64-mingw32-gcc || to_install+=(mingw-w64-i686-gcc)
|
||||
fi
|
||||
|
||||
# specific check for armv7-unknown-linux-gnueabihf on canonical runners
|
||||
# which are 32-bit armhf-native but have VMs running over an arm64 kernel with AArch32/EL0 support
|
||||
if [ "$target" = "armv7-unknown-linux-gnueabihf" ] && [ "${RUN_IN_DOCKER:-}" != "true" ] &&
|
||||
[ "$(dpkg --print-architecture 2>/dev/null)" = "arm64" ]; then
|
||||
|
||||
# expose these variables so we can keep the arm64 host toolchain, cross-link with
|
||||
# the armhf gcc, and run the test binaries natively in AArch32 mode
|
||||
{
|
||||
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc"
|
||||
echo "CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc"
|
||||
echo "AR_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar"
|
||||
} >> "$GITHUB_ENV"
|
||||
|
||||
# install required tooling to enable cross-compilation
|
||||
sudo dpkg --add-architecture armhf
|
||||
to_install+=(gcc-arm-linux-gnueabihf) # cross-compiler
|
||||
to_install+=(libc6-dev-armhf-cross) # target libc
|
||||
to_install+=(libc6:armhf libgcc-s1:armhf) # loaded at runtime
|
||||
fi
|
||||
|
||||
if [ ${#to_install[@]} -ne 0 ]; then
|
||||
@@ -43,6 +65,7 @@ if [ ${#to_install[@]} -ne 0 ]; then
|
||||
fi
|
||||
|
||||
# Install the correct Rust version
|
||||
rustup set profile minimal
|
||||
rustup update "$channel" --no-self-update
|
||||
rustup default "$channel"
|
||||
rustup target add "$target"
|
||||
|
||||
@@ -6,11 +6,11 @@ export RUST_BACKTRACE="${RUST_BACKTRACE:-full}"
|
||||
export NEXTEST_STATUS_LEVEL=all
|
||||
|
||||
target="${1:-}"
|
||||
host_tuple="$(rustc --print host-tuple)"
|
||||
|
||||
if [ -z "$target" ]; then
|
||||
host_target=$(rustc -vV | awk '/^host/ { print $2 }')
|
||||
echo "Defaulted to host target $host_target"
|
||||
target="$host_target"
|
||||
echo "Defaulted to host target $host_tuple"
|
||||
target="$host_tuple"
|
||||
fi
|
||||
|
||||
# Print machine information
|
||||
@@ -58,6 +58,9 @@ fi
|
||||
if [ "${BUILD_ONLY:-}" = "1" ]; then
|
||||
echo "no tests to run for build-only targets"
|
||||
else
|
||||
# Get a quick performance score
|
||||
cargo run -p sysbench --target "$target" --release
|
||||
|
||||
test_builtins=(
|
||||
"${test_runner[@]}"
|
||||
--package builtins-test
|
||||
@@ -138,7 +141,7 @@ echo "::endgroup"
|
||||
# Test libm
|
||||
|
||||
# Make sure a simple build works
|
||||
cargo check -p libm --no-default-features --target "$target"
|
||||
asgroup cargo check -p libm --no-default-features --target "$target"
|
||||
|
||||
if [ "${MAY_SKIP_LIBM_CI:-}" = "true" ]; then
|
||||
echo "skipping libm PR CI"
|
||||
@@ -171,19 +174,21 @@ case "$target" in
|
||||
*) mflags+=(--features libm-test/build-musl) ;;
|
||||
esac
|
||||
|
||||
|
||||
# Configure which targets test against MPFR
|
||||
case "$target" in
|
||||
# MSVC cannot link MPFR
|
||||
# Excluded in gmp-mpfr-sys with "Windows MSVC target is not supported (linking
|
||||
# would fail)". MPFR isn't really built for non-gcc-like compilers anyway.
|
||||
*windows-msvc*) ;;
|
||||
# FIXME: MinGW should be able to build MPFR, but setup in CI is nontrivial.
|
||||
*windows-gnu*) ;;
|
||||
# Targets that aren't cross compiled in CI work fine
|
||||
# Ensure enabled on targets that we expect to be native in CI
|
||||
aarch64*apple*) mflags+=(--features libm-test/build-mpfr) ;;
|
||||
aarch64*linux*) mflags+=(--features libm-test/build-mpfr) ;;
|
||||
i586*) mflags+=(--features libm-test/build-mpfr --features gmp-mpfr-sys/force-cross) ;;
|
||||
i686*) mflags+=(--features libm-test/build-mpfr) ;;
|
||||
x86_64*) mflags+=(--features libm-test/build-mpfr) ;;
|
||||
# Fallback to enabled on native targets, disabled otherwise
|
||||
*) [ "$target" = "$host_tuple" ] && mflags+=(--features libm-test/build-mpfr) ;;
|
||||
esac
|
||||
|
||||
# FIXME: `STATUS_DLL_NOT_FOUND` testing macros on CI.
|
||||
|
||||
@@ -148,77 +148,6 @@ macro_rules! stxp {
|
||||
};
|
||||
}
|
||||
|
||||
// The AArch64 assembly syntax for relocation specifiers
|
||||
// when accessing symbols changes depending on the target executable format.
|
||||
// In ELF (used in Linux), we have a prefix notation surrounded by colons (:specifier:sym),
|
||||
// while in Mach-O object files (used in MacOS), a postfix notation is used (sym@specifier).
|
||||
|
||||
/// AArch64 ELF position-independent addressing:
|
||||
///
|
||||
/// adrp xN, symbol
|
||||
/// add xN, xN, :lo12:symbol
|
||||
///
|
||||
/// The :lo12: modifier selects the low 12 bits of the symbol address
|
||||
/// and emits an ELF relocation such as R_AARCH64_ADD_ABS_LO12_NC.
|
||||
///
|
||||
/// Defined by the AArch64 ELF psABI.
|
||||
/// See: <https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#static-miscellaneous-relocations>.
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
macro_rules! sym {
|
||||
($sym:literal) => {
|
||||
$sym
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
macro_rules! sym_off {
|
||||
($sym:literal) => {
|
||||
concat!(":lo12:", $sym)
|
||||
};
|
||||
}
|
||||
|
||||
/// Mach-O ARM64 relocation types:
|
||||
/// ARM64_RELOC_PAGE21
|
||||
/// ARM64_RELOC_PAGEOFF12
|
||||
///
|
||||
/// These relocations implement the @PAGE / @PAGEOFF split used by
|
||||
/// adrp + add sequences on Apple platforms.
|
||||
///
|
||||
/// adrp xN, symbol@PAGE -> ARM64_RELOC_PAGE21
|
||||
/// add xN, xN, symbol@PAGEOFF -> ARM64_RELOC_PAGEOFF12
|
||||
///
|
||||
/// Relocation types defined by Apple in XNU: <mach-o/arm64/reloc.h>.
|
||||
/// See: <https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/EXTERNAL_HEADERS/mach-o/arm64/reloc.h>.
|
||||
#[cfg(target_vendor = "apple")]
|
||||
macro_rules! sym {
|
||||
($sym:literal) => {
|
||||
concat!($sym, "@PAGE")
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(target_vendor = "apple")]
|
||||
macro_rules! sym_off {
|
||||
($sym:literal) => {
|
||||
concat!($sym, "@PAGEOFF")
|
||||
};
|
||||
}
|
||||
|
||||
// If supported, perform the requested LSE op and return, or fallthrough.
|
||||
macro_rules! try_lse_op {
|
||||
($op: literal, $ordering:ident, $bytes:tt, $($reg:literal,)* [ $mem:ident ] ) => {
|
||||
concat!(
|
||||
".arch_extension lse\n",
|
||||
concat!("adrp x16, ", sym!("{have_lse}"), "\n"),
|
||||
concat!("ldrb w16, [x16, ", sym_off!("{have_lse}"), "]\n"),
|
||||
"cbz w16, 8f\n",
|
||||
// LSE_OP s(reg),* [$mem]
|
||||
concat!(lse!($op, $ordering, $bytes), $( " ", reg!($bytes, $reg), ", " ,)* "[", stringify!($mem), "]\n",),
|
||||
"ret
|
||||
8:"
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
// Translate memory ordering to the LSE suffix
|
||||
#[rustfmt::skip]
|
||||
macro_rules! lse_mem_sfx {
|
||||
@@ -238,34 +167,72 @@ macro_rules! lse {
|
||||
};
|
||||
}
|
||||
|
||||
// Ensure the register holding the pointer is zero-extended on ilp32 targets
|
||||
// before dereferencing it. This may not work, see llvm/llvm-project#225834.
|
||||
//
|
||||
// This write requires the pointer argument to be made `inout` in the asm!
|
||||
// sections. If the ilp32 targets are removed, this macro should be removed
|
||||
// and the pointer argument changed to `in`.
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
macro_rules! sanitize_ptr {
|
||||
($num:literal) => {
|
||||
concat!("mov w", $num, ", w", $num)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(target_pointer_width = "32"))]
|
||||
macro_rules! sanitize_ptr {
|
||||
($num:literal) => {
|
||||
""
|
||||
};
|
||||
}
|
||||
|
||||
/// See <https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicI8.html#method.compare_and_swap>.
|
||||
macro_rules! compare_and_swap {
|
||||
($ordering:ident, $bytes:tt, $name:ident) => {
|
||||
intrinsics! {
|
||||
#[maybe_use_optimized_c_shim]
|
||||
#[unsafe(naked)]
|
||||
pub unsafe extern "C" fn $name (
|
||||
expected: int_ty!($bytes), desired: int_ty!($bytes), ptr: *mut int_ty!($bytes)
|
||||
) -> int_ty!($bytes) {
|
||||
// We can't use `AtomicI8::compare_and_swap`; we *are* compare_and_swap.
|
||||
core::arch::naked_asm! {
|
||||
// CAS s(0), s(1), [x2]; if LSE supported.
|
||||
try_lse_op!("cas", $ordering, $bytes, 0, 1, [x2]),
|
||||
// UXT s(tmp0), s(0)
|
||||
concat!(uxt!($bytes), " ", reg!($bytes, 16), ", ", reg!($bytes, 0)),
|
||||
"0:",
|
||||
// LDXR s(0), [x2]
|
||||
concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x2]"),
|
||||
// cmp s(0), s(tmp0)
|
||||
concat!("cmp ", reg!($bytes, 0), ", ", reg!($bytes, 16)),
|
||||
"bne 1f",
|
||||
// STXR w(tmp1), s(1), [x2]
|
||||
concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 1), ", [x2]"),
|
||||
"cbnz w17, 0b",
|
||||
"1:",
|
||||
"ret",
|
||||
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
|
||||
let mut expected = expected;
|
||||
unsafe {
|
||||
if HAVE_LSE_ATOMICS.load(Ordering::Relaxed) != 0 {
|
||||
core::arch::asm!(
|
||||
".arch_extension lse",
|
||||
sanitize_ptr!(2),
|
||||
// CAS s(0), s(1), [x2]; if LSE supported.
|
||||
concat!(lse!("cas", $ordering, $bytes), " ", reg!($bytes, 0), ", ", reg!($bytes, 1),", [x2]"),
|
||||
inlateout("x0") expected,
|
||||
in("x1") desired,
|
||||
inout("x2") ptr => _,
|
||||
options(nostack, preserves_flags),
|
||||
);
|
||||
} else {
|
||||
core::arch::asm!(
|
||||
sanitize_ptr!(2),
|
||||
// UXT s(tmp0), s(0)
|
||||
concat!(uxt!($bytes), " ", reg!($bytes, 16), ", ", reg!($bytes, 0)),
|
||||
"1:",
|
||||
// LDXR s(0), [x2]
|
||||
concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x2]"),
|
||||
// cmp s(0), s(tmp0)
|
||||
concat!("cmp ", reg!($bytes, 0), ", ", reg!($bytes, 16)),
|
||||
"bne 2f",
|
||||
// STXR w(tmp1), s(1), [x2]
|
||||
concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 1), ", [x2]"),
|
||||
"cbnz w17, 1b",
|
||||
"2:",
|
||||
inlateout("x0") expected,
|
||||
in("x1") desired,
|
||||
inout("x2") ptr => _,
|
||||
out("x16") _,
|
||||
out("w17") _,
|
||||
options(nostack),
|
||||
);
|
||||
}
|
||||
}
|
||||
expected
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -276,28 +243,56 @@ macro_rules! compare_and_swap_u128 {
|
||||
($ordering:ident, $name:ident) => {
|
||||
intrinsics! {
|
||||
#[maybe_use_optimized_c_shim]
|
||||
#[unsafe(naked)]
|
||||
pub unsafe extern "C" fn $name (
|
||||
expected: u128, desired: u128, ptr: *mut u128
|
||||
) -> u128 {
|
||||
core::arch::naked_asm! {
|
||||
// CASP x0, x1, x2, x3, [x4]; if LSE supported.
|
||||
try_lse_op!("cas", $ordering, 16, 0, 1, 2, 3, [x4]),
|
||||
"mov x16, x0",
|
||||
"mov x17, x1",
|
||||
"0:",
|
||||
// LDXP x0, x1, [x4]
|
||||
concat!(ldxp!($ordering), " x0, x1, [x4]"),
|
||||
"cmp x0, x16",
|
||||
"ccmp x1, x17, #0, eq",
|
||||
"bne 1f",
|
||||
// STXP w(tmp2), x2, x3, [x4]
|
||||
concat!(stxp!($ordering), " w15, x2, x3, [x4]"),
|
||||
"cbnz w15, 0b",
|
||||
"1:",
|
||||
"ret",
|
||||
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
|
||||
let mut expected_lo = expected as u64;
|
||||
let mut expected_hi = (expected >> 64) as u64;
|
||||
let desired_lo = desired as u64;
|
||||
let desired_hi = (desired >> 64) as u64;
|
||||
|
||||
unsafe {
|
||||
if HAVE_LSE_ATOMICS.load(Ordering::Relaxed) != 0 {
|
||||
core::arch::asm!(
|
||||
".arch_extension lse",
|
||||
sanitize_ptr!(4),
|
||||
// CASP x0, x1, x2, x3, [x4]; if LSE supported.
|
||||
concat!(lse!("cas", $ordering, 16), " x0, x1, x2, x3, [x4]"),
|
||||
inlateout("x0") expected_lo,
|
||||
inlateout("x1") expected_hi,
|
||||
in("x2") desired_lo,
|
||||
in("x3") desired_hi,
|
||||
inout("x4") ptr => _,
|
||||
options(nostack, preserves_flags),
|
||||
);
|
||||
} else {
|
||||
core::arch::asm!(
|
||||
sanitize_ptr!(4),
|
||||
"mov x16, x0",
|
||||
"mov x17, x1",
|
||||
"1:",
|
||||
// LDXP x0, x1, [x4]
|
||||
concat!(ldxp!($ordering), " x0, x1, [x4]"),
|
||||
"cmp x0, x16",
|
||||
"ccmp x1, x17, #0x0, eq",
|
||||
"b.ne 2f",
|
||||
// STXP w(tmp2), x2, x3, [x4]
|
||||
concat!(stxp!($ordering), " w15, x2, x3, [x4]"),
|
||||
"cbnz w15, 1b",
|
||||
"2:",
|
||||
inlateout("x0") expected_lo,
|
||||
inlateout("x1") expected_hi,
|
||||
in("x2") desired_lo,
|
||||
in("x3") desired_hi,
|
||||
inout("x4") ptr => _,
|
||||
out("w15") _,
|
||||
out("x16") _,
|
||||
out("x17") _,
|
||||
options(nostack),
|
||||
);
|
||||
}
|
||||
}
|
||||
return ((expected_hi as u128) << 64) | expected_lo as u128;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -308,24 +303,40 @@ macro_rules! swap {
|
||||
($ordering:ident, $bytes:tt, $name:ident) => {
|
||||
intrinsics! {
|
||||
#[maybe_use_optimized_c_shim]
|
||||
#[unsafe(naked)]
|
||||
pub unsafe extern "C" fn $name (
|
||||
left: int_ty!($bytes), right_ptr: *mut int_ty!($bytes)
|
||||
) -> int_ty!($bytes) {
|
||||
core::arch::naked_asm! {
|
||||
// SWP s(0), s(0), [x1]; if LSE supported.
|
||||
try_lse_op!("swp", $ordering, $bytes, 0, 0, [x1]),
|
||||
// mov s(tmp0), s(0)
|
||||
concat!("mov ", reg!($bytes, 16), ", ", reg!($bytes, 0)),
|
||||
"0:",
|
||||
// LDXR s(0), [x1]
|
||||
concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x1]"),
|
||||
// STXR w(tmp1), s(tmp0), [x1]
|
||||
concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 16), ", [x1]"),
|
||||
"cbnz w17, 0b",
|
||||
"ret",
|
||||
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
|
||||
let mut left = left;
|
||||
unsafe {
|
||||
if HAVE_LSE_ATOMICS.load(Ordering::Relaxed) != 0 {
|
||||
core::arch::asm! {
|
||||
".arch_extension lse",
|
||||
sanitize_ptr!(1),
|
||||
// SWP s(0), s(0), [x1]; if LSE supported.
|
||||
concat!(lse!("swp", $ordering, $bytes), " ", reg!($bytes, 0), ", ", reg!($bytes, 0), ", [x1]"),
|
||||
inlateout("x0") left,
|
||||
inout("x1") right_ptr => _,
|
||||
options(nostack, preserves_flags),
|
||||
};
|
||||
} else {
|
||||
core::arch::asm! {
|
||||
sanitize_ptr!(1),
|
||||
concat!("mov ", reg!($bytes, 16), ", ", reg!($bytes, 0)),
|
||||
"1:",
|
||||
// LDXR s(0), [x1]
|
||||
concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x1]"),
|
||||
// STXR w(tmp1), s(tmp0), [x1]
|
||||
concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 16), ", [x1]"),
|
||||
"cbnz w17, 1b",
|
||||
inlateout("x0") left,
|
||||
inout("x1") right_ptr => _,
|
||||
out("x16") _,
|
||||
out("w17") _,
|
||||
options(nostack, preserves_flags),
|
||||
};
|
||||
}
|
||||
}
|
||||
left
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -336,26 +347,44 @@ macro_rules! fetch_op {
|
||||
($ordering:ident, $bytes:tt, $name:ident, $op:literal, $lse_op:literal) => {
|
||||
intrinsics! {
|
||||
#[maybe_use_optimized_c_shim]
|
||||
#[unsafe(naked)]
|
||||
pub unsafe extern "C" fn $name (
|
||||
val: int_ty!($bytes), ptr: *mut int_ty!($bytes)
|
||||
) -> int_ty!($bytes) {
|
||||
core::arch::naked_asm! {
|
||||
// LSEOP s(0), s(0), [x1]; if LSE supported.
|
||||
try_lse_op!($lse_op, $ordering, $bytes, 0, 0, [x1]),
|
||||
// mov s(tmp0), s(0)
|
||||
concat!("mov ", reg!($bytes, 16), ", ", reg!($bytes, 0)),
|
||||
"0:",
|
||||
// LDXR s(0), [x1]
|
||||
concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x1]"),
|
||||
// OP s(tmp1), s(0), s(tmp0)
|
||||
concat!($op, " ", reg!($bytes, 17), ", ", reg!($bytes, 0), ", ", reg!($bytes, 16)),
|
||||
// STXR w(tmp2), s(tmp1), [x1]
|
||||
concat!(stxr!($ordering, $bytes), " w15, ", reg!($bytes, 17), ", [x1]"),
|
||||
"cbnz w15, 0b",
|
||||
"ret",
|
||||
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
|
||||
let mut val = val;
|
||||
unsafe {
|
||||
if HAVE_LSE_ATOMICS.load(Ordering::Relaxed) != 0 {
|
||||
core::arch::asm! {
|
||||
".arch_extension lse",
|
||||
sanitize_ptr!(1),
|
||||
// LSEOP s(0), s(0), [x1]; if LSE supported.
|
||||
concat!(lse!($lse_op, $ordering, $bytes), " ", reg!($bytes, 0), ", ", reg!($bytes, 0),", [x1]"),
|
||||
inlateout("x0") val,
|
||||
inout("x1") ptr => _,
|
||||
options(nostack, preserves_flags),
|
||||
};
|
||||
} else {
|
||||
core::arch::asm! {
|
||||
sanitize_ptr!(1),
|
||||
// mov s(tmp0), s(0)
|
||||
concat!("mov ", reg!($bytes, 16), ", ", reg!($bytes, 0)),
|
||||
"1:",
|
||||
// LDXR s(0), [x1]
|
||||
concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x1]"),
|
||||
// OP s(tmp1), s(0), s(tmp0)
|
||||
concat!($op, " ", reg!($bytes, 17), ", ", reg!($bytes, 0), ", ", reg!($bytes, 16)),
|
||||
// STXR w(tmp2), s(tmp1), [x1]
|
||||
concat!(stxr!($ordering, $bytes), " w15, ", reg!($bytes, 17), ", [x1]"),
|
||||
"cbnz w15, 1b",
|
||||
inlateout("x0") val,
|
||||
inout("x1") ptr => _,
|
||||
out("w15") _,
|
||||
out("x16") _,
|
||||
out("x17") _,
|
||||
options(nostack, preserves_flags),
|
||||
}
|
||||
}
|
||||
}
|
||||
val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,6 +208,8 @@ mod int_to_float {
|
||||
|
||||
// Conversions from unsigned integers to floats.
|
||||
intrinsics! {
|
||||
/* u32 -> fN */
|
||||
|
||||
#[arm_aeabi_alias = __aeabi_ui2f]
|
||||
pub extern "C" fn __floatunsisf(i: u32) -> f32 {
|
||||
f32::from_bits(int_to_float::u32_to_f32_bits(i))
|
||||
@@ -218,6 +220,14 @@ intrinsics! {
|
||||
f64::from_bits(int_to_float::u32_to_f64_bits(i))
|
||||
}
|
||||
|
||||
#[ppc_name = __floatunsikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floatunsitf(i: u32) -> f128 {
|
||||
f128::from_bits(int_to_float::u32_to_f128_bits(i))
|
||||
}
|
||||
|
||||
/* u64 -> fN */
|
||||
|
||||
#[arm_aeabi_alias = __aeabi_ul2f]
|
||||
pub extern "C" fn __floatundisf(i: u64) -> f32 {
|
||||
f32::from_bits(int_to_float::u64_to_f32_bits(i))
|
||||
@@ -228,6 +238,14 @@ intrinsics! {
|
||||
f64::from_bits(int_to_float::u64_to_f64_bits(i))
|
||||
}
|
||||
|
||||
#[ppc_name = __floatundikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floatunditf(i: u64) -> f128 {
|
||||
f128::from_bits(int_to_float::u64_to_f128_bits(i))
|
||||
}
|
||||
|
||||
/* u128 -> fN */
|
||||
|
||||
#[cfg(not(all(target_os = "uefi", target_arch = "x86_64")))]
|
||||
pub extern "C" fn __floatuntisf(i: u128) -> f32 {
|
||||
f32::from_bits(int_to_float::u128_to_f32_bits(i))
|
||||
@@ -248,18 +266,6 @@ intrinsics! {
|
||||
f64::from_bits(int_to_float::u128_to_f64_bits((u128::from(hi) << 64) | u128::from(lo)))
|
||||
}
|
||||
|
||||
#[ppc_name = __floatunsikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floatunsitf(i: u32) -> f128 {
|
||||
f128::from_bits(int_to_float::u32_to_f128_bits(i))
|
||||
}
|
||||
|
||||
#[ppc_name = __floatundikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floatunditf(i: u64) -> f128 {
|
||||
f128::from_bits(int_to_float::u64_to_f128_bits(i))
|
||||
}
|
||||
|
||||
#[ppc_name = __floatuntikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floatuntitf(i: u128) -> f128 {
|
||||
@@ -269,6 +275,8 @@ intrinsics! {
|
||||
|
||||
// Conversions from signed integers to floats.
|
||||
intrinsics! {
|
||||
/* i32 -> fN */
|
||||
|
||||
#[arm_aeabi_alias = __aeabi_i2f]
|
||||
pub extern "C" fn __floatsisf(i: i32) -> f32 {
|
||||
int_to_float::signed(i, int_to_float::u32_to_f32_bits)
|
||||
@@ -279,6 +287,14 @@ intrinsics! {
|
||||
int_to_float::signed(i, int_to_float::u32_to_f64_bits)
|
||||
}
|
||||
|
||||
#[ppc_name = __floatsikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floatsitf(i: i32) -> f128 {
|
||||
int_to_float::signed(i, int_to_float::u32_to_f128_bits)
|
||||
}
|
||||
|
||||
/* i64 -> fN */
|
||||
|
||||
#[arm_aeabi_alias = __aeabi_l2f]
|
||||
pub extern "C" fn __floatdisf(i: i64) -> f32 {
|
||||
int_to_float::signed(i, int_to_float::u64_to_f32_bits)
|
||||
@@ -289,6 +305,14 @@ intrinsics! {
|
||||
int_to_float::signed(i, int_to_float::u64_to_f64_bits)
|
||||
}
|
||||
|
||||
#[ppc_name = __floatdikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floatditf(i: i64) -> f128 {
|
||||
int_to_float::signed(i, int_to_float::u64_to_f128_bits)
|
||||
}
|
||||
|
||||
/* i128 -> fN */
|
||||
|
||||
#[cfg(not(all(target_os = "uefi", target_arch = "x86_64")))]
|
||||
pub extern "C" fn __floattisf(i: i128) -> f32 {
|
||||
int_to_float::signed(i, int_to_float::u128_to_f32_bits)
|
||||
@@ -309,18 +333,6 @@ intrinsics! {
|
||||
int_to_float::signed((i128::from(hi) << 64) | i128::from(lo), int_to_float::u128_to_f64_bits)
|
||||
}
|
||||
|
||||
#[ppc_name = __floatsikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floatsitf(i: i32) -> f128 {
|
||||
int_to_float::signed(i, int_to_float::u32_to_f128_bits)
|
||||
}
|
||||
|
||||
#[ppc_name = __floatdikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floatditf(i: i64) -> f128 {
|
||||
int_to_float::signed(i, int_to_float::u64_to_f128_bits)
|
||||
}
|
||||
|
||||
#[ppc_name = __floattikf]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __floattitf(i: i128) -> f128 {
|
||||
@@ -411,6 +423,8 @@ where
|
||||
|
||||
// Conversions from floats to unsigned integers.
|
||||
intrinsics! {
|
||||
/* f32 -> uN */
|
||||
|
||||
#[arm_aeabi_alias = __aeabi_f2uiz]
|
||||
pub extern "C" fn __fixunssfsi(f: f32) -> u32 {
|
||||
float_to_unsigned_int(f)
|
||||
@@ -425,6 +439,8 @@ intrinsics! {
|
||||
float_to_unsigned_int(f)
|
||||
}
|
||||
|
||||
/* f64 -> uN */
|
||||
|
||||
#[arm_aeabi_alias = __aeabi_d2uiz]
|
||||
pub extern "C" fn __fixunsdfsi(f: f64) -> u32 {
|
||||
float_to_unsigned_int(f)
|
||||
@@ -439,6 +455,8 @@ intrinsics! {
|
||||
float_to_unsigned_int(f)
|
||||
}
|
||||
|
||||
/* f128 -> uN */
|
||||
|
||||
#[ppc_name = __fixunskfsi]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __fixunstfsi(f: f128) -> u32 {
|
||||
@@ -460,6 +478,8 @@ intrinsics! {
|
||||
|
||||
// Conversions from floats to signed integers.
|
||||
intrinsics! {
|
||||
/* f32 -> iN */
|
||||
|
||||
#[arm_aeabi_alias = __aeabi_f2iz]
|
||||
pub extern "C" fn __fixsfsi(f: f32) -> i32 {
|
||||
float_to_signed_int(f)
|
||||
@@ -474,6 +494,8 @@ intrinsics! {
|
||||
float_to_signed_int(f)
|
||||
}
|
||||
|
||||
/* f64 -> iN */
|
||||
|
||||
#[arm_aeabi_alias = __aeabi_d2iz]
|
||||
pub extern "C" fn __fixdfsi(f: f64) -> i32 {
|
||||
float_to_signed_int(f)
|
||||
@@ -488,6 +510,8 @@ intrinsics! {
|
||||
float_to_signed_int(f)
|
||||
}
|
||||
|
||||
/* f128 -> iN */
|
||||
|
||||
#[ppc_name = __fixkfsi]
|
||||
#[cfg(f128_enabled)]
|
||||
pub extern "C" fn __fixtfsi(f: f128) -> i32 {
|
||||
|
||||
@@ -898,6 +898,7 @@ const ALL_OPERATIONS_NESTED: &[NestedOp] = &[
|
||||
"erff",
|
||||
"exp10f",
|
||||
"exp2f",
|
||||
"exp2m1f",
|
||||
"expf",
|
||||
"expm1f",
|
||||
"fabsf",
|
||||
@@ -947,6 +948,7 @@ const ALL_OPERATIONS_NESTED: &[NestedOp] = &[
|
||||
"exp",
|
||||
"exp10",
|
||||
"exp2",
|
||||
"exp2m1",
|
||||
"expm1",
|
||||
"fabs",
|
||||
"floor",
|
||||
|
||||
7
library/compiler-builtins/crates/sysbench/Cargo.toml
Normal file
7
library/compiler-builtins/crates/sysbench/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "sysbench"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
121
library/compiler-builtins/crates/sysbench/src/main.rs
Normal file
121
library/compiler-builtins/crates/sysbench/src/main.rs
Normal file
@@ -0,0 +1,121 @@
|
||||
//! Simple check of integer and float ops, for giving us an idea of how many test cases we can
|
||||
//! expect to execute in a reasonable amount of time.
|
||||
|
||||
#![allow(clippy::type_complexity)]
|
||||
|
||||
use std::hint::black_box as bb;
|
||||
use std::io::Write;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{io, thread};
|
||||
|
||||
const ESTIMATE_ITERS: u32 = 65535;
|
||||
const ITER_MAX: u32 = u32::MAX;
|
||||
|
||||
fn main() {
|
||||
let int_mul = run_bench("integer multiplication", |i| {
|
||||
let i = i128::from(i);
|
||||
let i = i | (i << 32) | (i << 64) | (i << 96);
|
||||
bb(i).overflowing_mul(bb(i))
|
||||
});
|
||||
let float_mul = run_bench("float multiplication", |i| {
|
||||
let x = f32::from_bits(i);
|
||||
bb(x) * bb(x)
|
||||
});
|
||||
let float_fma = run_bench("float fma", |i| {
|
||||
let x = f32::from_bits(i);
|
||||
bb(x).mul_add(bb(x), bb(x))
|
||||
});
|
||||
|
||||
let oneshot = bench_oneshot();
|
||||
|
||||
let threads = thread::available_parallelism().unwrap().get();
|
||||
println!("Available parallelism: {threads}");
|
||||
|
||||
// Super simple metric to give us a rough idea of how machines compare. Int math gets a larger
|
||||
// scale since u128 requires more instructions.
|
||||
let int_score = 500.0 / int_mul;
|
||||
let float_score = 200.0 / float_mul;
|
||||
let fma_score = 200.0 / float_fma;
|
||||
let oneshot_score = 50.0 / oneshot.as_secs_f64();
|
||||
let score = int_score + float_score + fma_score + oneshot_score;
|
||||
let thread_scale = 1.0 + 0.9 * (threads as f64 - 1.0);
|
||||
|
||||
println!("Single-core performance score: {score:.0}");
|
||||
println!("Multi-core performance score: {:.0}", score * thread_scale);
|
||||
}
|
||||
|
||||
/// Benchmark `f` by running it repeatedly after a warmup. Outputs are black boxed.
|
||||
fn run_bench<T>(name: &str, mut f: impl FnMut(u32) -> T) -> f64 {
|
||||
print!("Starting {name} bench... ");
|
||||
io::stdout().flush().unwrap();
|
||||
|
||||
// Warmup
|
||||
for i in 0..1000 {
|
||||
bb(f(bb(i)));
|
||||
}
|
||||
|
||||
// Calculate how many to run
|
||||
let start = Instant::now();
|
||||
for i in 0..ESTIMATE_ITERS {
|
||||
bb(f(bb(i)));
|
||||
}
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
let ns_per_iter = elapsed.as_secs_f64() * 1e9 / ESTIMATE_ITERS as f64;
|
||||
let desired_iters = 1e9 / ns_per_iter;
|
||||
let step = ((ITER_MAX as u64 + 1) / desired_iters as u64) as usize;
|
||||
let iter = (0..=ITER_MAX).step_by(step);
|
||||
let count = iter_count(iter.clone());
|
||||
|
||||
// Run the benchmark
|
||||
let start = Instant::now();
|
||||
for i in iter {
|
||||
bb(f(bb(i)));
|
||||
}
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
let ns_per_iter = elapsed.as_secs_f64() * 1e9 / count as f64;
|
||||
println!("{count} iterations completed in {elapsed:.3?} ({ns_per_iter:.3} ns/iter)");
|
||||
ns_per_iter
|
||||
}
|
||||
|
||||
/// Qemu has a good JIT, so run something new once to try to catch it.
|
||||
fn bench_oneshot() -> Duration {
|
||||
fn fib_int(n: u32) -> u32 {
|
||||
if n == 0 {
|
||||
0
|
||||
} else if n == 1 {
|
||||
1
|
||||
} else {
|
||||
fib_int(n - 1) + fib_int(n - 2)
|
||||
}
|
||||
}
|
||||
|
||||
fn fib_float(n: f32) -> f32 {
|
||||
if n == 0.0 {
|
||||
0.0
|
||||
} else if n == 1.0 {
|
||||
1.0
|
||||
} else {
|
||||
fib_float(n - 1.0) + fib_float(n - 2.0)
|
||||
}
|
||||
}
|
||||
|
||||
print!("Starting oneshot bench... ");
|
||||
io::stdout().flush().unwrap();
|
||||
let start = Instant::now();
|
||||
bb(fib_int(bb(38)));
|
||||
bb(fib_float(bb(38.0)));
|
||||
let elapsed = start.elapsed();
|
||||
println!("completed in {elapsed:.3?}");
|
||||
elapsed
|
||||
}
|
||||
|
||||
/// `iter.count()` but allow results greater than `usize::MAX` on 32-bit.
|
||||
fn iter_count(iter: impl Iterator) -> u64 {
|
||||
let mut ret = 0u64;
|
||||
for _ in iter {
|
||||
ret = ret.strict_add(1);
|
||||
}
|
||||
ret
|
||||
}
|
||||
@@ -102,7 +102,9 @@ fn do_eval(basis: &str, op: &str, inputs: &[&str]) {
|
||||
extra: (basis, op, inputs),
|
||||
fn_extra: match MACRO_FN_NAME {
|
||||
// Not provided by musl
|
||||
fmaximum
|
||||
exp2m1
|
||||
| exp2m1f
|
||||
| fmaximum
|
||||
| fmaximum_num
|
||||
| fmaximum_numf
|
||||
| fmaximumf
|
||||
|
||||
@@ -233,6 +233,18 @@
|
||||
],
|
||||
"type": "f32"
|
||||
},
|
||||
"exp2m1": {
|
||||
"sources": [
|
||||
"libm/src/math/exp2m1.rs"
|
||||
],
|
||||
"type": "f64"
|
||||
},
|
||||
"exp2m1f": {
|
||||
"sources": [
|
||||
"libm/src/math/exp2m1f.rs"
|
||||
],
|
||||
"type": "f32"
|
||||
},
|
||||
"expf": {
|
||||
"sources": [
|
||||
"libm/src/math/expf.rs"
|
||||
|
||||
@@ -36,6 +36,8 @@ exp10
|
||||
exp10f
|
||||
exp2
|
||||
exp2f
|
||||
exp2m1
|
||||
exp2m1f
|
||||
expf
|
||||
expm1
|
||||
expm1f
|
||||
|
||||
@@ -108,6 +108,8 @@ library_benchmark_group!(
|
||||
icount_bench_exp10f,
|
||||
icount_bench_exp2,
|
||||
icount_bench_exp2f,
|
||||
icount_bench_exp2m1,
|
||||
icount_bench_exp2m1f,
|
||||
icount_bench_expf,
|
||||
icount_bench_expm1,
|
||||
icount_bench_expm1f,
|
||||
|
||||
@@ -126,7 +126,9 @@ libm_macros::for_each_function! {
|
||||
exp10 | exp10f | exp2 | exp2f => (true, Some(musl_math_sys::MACRO_FN_NAME)),
|
||||
|
||||
// Musl does not provide `f16` and `f128` functions, as well as a handful of others
|
||||
fmaximum
|
||||
exp2m1
|
||||
| exp2m1f
|
||||
| fmaximum
|
||||
| fmaximum_num
|
||||
| fmaximum_numf
|
||||
| fmaximumf
|
||||
|
||||
@@ -102,80 +102,128 @@ cb_op!(@binop f16, add, __addhf3, addf16);
|
||||
cb_op!(@binop f32, add, __addsf3, addf32);
|
||||
cb_op!(@binop f64, add, __adddf3, addf64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@binop f128, add, __addtf3, addf128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@binop f128, add, __addkf3, addf128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(@binop f16, sub, __subhf3, subf16);
|
||||
cb_op!(@binop f32, sub, __subsf3, subf32);
|
||||
cb_op!(@binop f64, sub, __subdf3, subf64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@binop f128, sub, __subtf3, subf128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@binop f128, sub, __subkf3, subf128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(@binop f16, mul, __mulhf3, mulf16);
|
||||
cb_op!(@binop f32, mul, __mulsf3, mulf32);
|
||||
cb_op!(@binop f64, mul, __muldf3, mulf64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@binop f128, mul, __multf3, mulf128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@binop f128, mul, __mulkf3, mulf128);
|
||||
|
||||
cb_op!(@binop f32, div, __divsf3, divf32);
|
||||
cb_op!(@binop f64, div, __divdf3, divf64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@binop f128, div, __divtf3, divf128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@binop f128, div, __divkf3, divf128);
|
||||
|
||||
cb_op!(pow, __powisf2, powif32, (a: f32, b: i32) -> f32);
|
||||
cb_op!(pow, __powidf2, powif64, (a: f64, b: i32) -> f64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(pow, __powitf2, powif128, (a: f128, b: i32) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(pow, __powikf2, powif128, (a: f128, b: i32) -> f128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(@cmp_eq f16, cmp, __eqhf2, eqf16);
|
||||
cb_op!(@cmp_eq f32, cmp, __eqsf2, eqf32);
|
||||
cb_op!(@cmp_eq f64, cmp, __eqdf2, eqf64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@cmp_eq f128, cmp, __eqtf2, eqf128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@cmp_eq f128, cmp, __eqkf2, eqf128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(@cmp_gt f16, cmp, __gthf2, gtf16);
|
||||
cb_op!(@cmp_gt f32, cmp, __gtsf2, gtf32);
|
||||
cb_op!(@cmp_gt f64, cmp, __gtdf2, gtf64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@cmp_gt f128, cmp, __gttf2, gtf128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@cmp_gt f128, cmp, __gtkf2, gtf128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(@cmp_ge f16, cmp, __gehf2, gef16);
|
||||
cb_op!(@cmp_ge f32, cmp, __gesf2, gef32);
|
||||
cb_op!(@cmp_ge f64, cmp, __gedf2, gef64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@cmp_ge f128, cmp, __getf2, gef128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@cmp_ge f128, cmp, __gekf2, gef128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(@cmp_lt f16, cmp, __lthf2, ltf16);
|
||||
cb_op!(@cmp_lt f32, cmp, __ltsf2, ltf32);
|
||||
cb_op!(@cmp_lt f64, cmp, __ltdf2, ltf64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@cmp_lt f128, cmp, __lttf2, ltf128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@cmp_lt f128, cmp, __ltkf2, ltf128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(@cmp_le f16, cmp, __lehf2, lef16);
|
||||
cb_op!(@cmp_le f32, cmp, __lesf2, lef32);
|
||||
cb_op!(@cmp_le f64, cmp, __ledf2, lef64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@cmp_le f128, cmp, __letf2, lef128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@cmp_le f128, cmp, __lekf2, lef128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(@cmp_ne f16, cmp, __nehf2, nef16);
|
||||
cb_op!(@cmp_ne f32, cmp, __nesf2, nef32);
|
||||
cb_op!(@cmp_ne f64, cmp, __nedf2, nef64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@cmp_ne f128, cmp, __netf2, nef128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@cmp_ne f128, cmp, __nekf2, nef128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(@cmp_unord f16, cmp, __unordhf2, unordf16);
|
||||
cb_op!(@cmp_unord f32, cmp, __unordsf2, unordf32);
|
||||
cb_op!(@cmp_unord f64, cmp, __unorddf2, unordf64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(@cmp_unord f128, cmp, __unordtf2, unordf128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(@cmp_unord f128, cmp, __unordkf2, unordf128);
|
||||
|
||||
#[cfg(f16_enabled)]
|
||||
cb_op!(extend, __extendhfsf2, extend_f16_f32, (a: f16) -> f32);
|
||||
@@ -183,12 +231,25 @@ cb_op!(extend, __extendhfsf2, extend_f16_f32, (a: f16) -> f32);
|
||||
cb_op!(extend, __extendhfdf2, extend_f16_f64, (a: f16) -> f64);
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(extend, __extendhftf2, extend_f16_f128, (a: f16) -> f128);
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(extend, __extendhfkf2, extend_f16_f128, (a: f16) -> f128);
|
||||
cb_op!(extend, __extendsfdf2, extend_f32_f64, (a: f32) -> f64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(extend, __extendsftf2, extend_f32_f128, (a: f32) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(extend, __extendsfkf2, extend_f32_f128, (a: f32) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(extend, __extenddftf2, extend_f64_f128, (a: f64) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(extend, __extenddfkf2, extend_f64_f128, (a: f64) -> f128);
|
||||
|
||||
// Note that these are renamed from trunc to narrow to avoid collision with libm `trunc`.
|
||||
#[cfg(f16_enabled)]
|
||||
@@ -198,11 +259,23 @@ cb_op!(trunc, __truncdfhf2, narrow_f64_f16, (a: f64) -> f16);
|
||||
cb_op!(trunc, __truncdfsf2, narrow_f64_f32, (a: f64) -> f32);
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(trunc, __trunctfhf2, narrow_f128_f16, (a: f128) -> f16);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(trunc, __trunckfhf2, narrow_f128_f16, (a: f128) -> f16);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(trunc, __trunctfsf2, narrow_f128_f32, (a: f128) -> f32);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(trunc, __trunckfsf2, narrow_f128_f32, (a: f128) -> f32);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(trunc, __trunctfdf2, narrow_f128_f64, (a: f128) -> f64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(trunc, __trunckfdf2, narrow_f128_f64, (a: f128) -> f64);
|
||||
|
||||
cb_op!(conv, __fixsfsi, ftoi_f32_i32, (a: f32) -> i32);
|
||||
cb_op!(conv, __fixsfdi, ftoi_f32_i64, (a: f32) -> i64);
|
||||
@@ -211,11 +284,23 @@ cb_op!(conv, __fixdfsi, ftoi_f64_i32, (a: f64) -> i32);
|
||||
cb_op!(conv, __fixdfdi, ftoi_f64_i64, (a: f64) -> i64);
|
||||
cb_op!(conv, __fixdfti, ftoi_f64_i128, (a: f64) -> i128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __fixtfsi, ftoi_f128_i32, (a: f128) -> i32);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __fixkfsi, ftoi_f128_i32, (a: f128) -> i32);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __fixtfdi, ftoi_f128_i64, (a: f128) -> i64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __fixkfdi, ftoi_f128_i64, (a: f128) -> i64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __fixtfti, ftoi_f128_i128, (a: f128) -> i128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __fixkfti, ftoi_f128_i128, (a: f128) -> i128);
|
||||
cb_op!(conv, __fixunssfsi, ftoi_f32_u32, (a: f32) -> u32);
|
||||
cb_op!(conv, __fixunssfdi, ftoi_f32_u64, (a: f32) -> u64);
|
||||
cb_op!(conv, __fixunssfti, ftoi_f32_u128, (a: f32) -> u128);
|
||||
@@ -223,11 +308,23 @@ cb_op!(conv, __fixunsdfsi, ftoi_f64_u32, (a: f64) -> u32);
|
||||
cb_op!(conv, __fixunsdfdi, ftoi_f64_u64, (a: f64) -> u64);
|
||||
cb_op!(conv, __fixunsdfti, ftoi_f64_u128, (a: f64) -> u128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __fixunstfsi, ftoi_f128_u32, (a: f128) -> u32);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __fixunskfsi, ftoi_f128_u32, (a: f128) -> u32);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __fixunstfdi, ftoi_f128_u64, (a: f128) -> u64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __fixunskfdi, ftoi_f128_u64, (a: f128) -> u64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __fixunstfti, ftoi_f128_u128, (a: f128) -> u128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __fixunskfti, ftoi_f128_u128, (a: f128) -> u128);
|
||||
|
||||
cb_op!(conv, __floatsisf, itof_i32_f32, (a: i32) -> f32);
|
||||
cb_op!(conv, __floatdisf, itof_i64_f32, (a: i64) -> f32);
|
||||
@@ -236,11 +333,23 @@ cb_op!(conv, __floatsidf, itof_i32_f64, (a: i32) -> f64);
|
||||
cb_op!(conv, __floatdidf, itof_i64_f64, (a: i64) -> f64);
|
||||
cb_op!(conv, __floattidf, itof_i128_f64, (a: i128) -> f64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __floatsitf, itof_i32_f128, (a: i32) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __floatsikf, itof_i32_f128, (a: i32) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __floatditf, itof_i64_f128, (a: i64) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __floatdikf, itof_i64_f128, (a: i64) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __floattitf, itof_i128_f128, (a: i128) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __floattikf, itof_i128_f128, (a: i128) -> f128);
|
||||
cb_op!(conv, __floatunsisf, itof_u32_f32, (a: u32) -> f32);
|
||||
cb_op!(conv, __floatundisf, itof_u64_f32, (a: u64) -> f32);
|
||||
cb_op!(conv, __floatuntisf, itof_u128_f32, (a: u128) -> f32);
|
||||
@@ -248,11 +357,23 @@ cb_op!(conv, __floatunsidf, itof_u32_f64, (a: u32) -> f64);
|
||||
cb_op!(conv, __floatundidf, itof_u64_f64, (a: u64) -> f64);
|
||||
cb_op!(conv, __floatuntidf, itof_u128_f64, (a: u128) -> f64);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __floatunsitf, itof_u32_f128, (a: u32) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __floatunsikf, itof_u32_f128, (a: u32) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __floatunditf, itof_u64_f128, (a: u64) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __floatundikf, itof_u64_f128, (a: u64) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
|
||||
cb_op!(conv, __floatuntitf, itof_u128_f128, (a: u128) -> f128);
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
|
||||
cb_op!(conv, __floatuntikf, itof_u128_f128, (a: u128) -> f128);
|
||||
|
||||
/* int ops */
|
||||
|
||||
|
||||
@@ -283,6 +283,7 @@ pub fn get_domain<F: Float, I: Int>(
|
||||
BaseName::Expm1 => &EitherPrim::UNBOUNDED1[..],
|
||||
BaseName::Exp10 => &EitherPrim::UNBOUNDED1[..],
|
||||
BaseName::Exp2 => &EitherPrim::UNBOUNDED1[..],
|
||||
BaseName::Exp2m1 => &EitherPrim::UNBOUNDED1[..],
|
||||
BaseName::Frexp => &EitherPrim::UNBOUNDED1[..],
|
||||
BaseName::Fabs => &EitherPrim::UNBOUNDED1[..],
|
||||
BaseName::Fdim => &EitherPrim::UNBOUNDED2[..],
|
||||
|
||||
@@ -97,6 +97,14 @@ impl Float for f8 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn floor(self) -> Self {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn roundeven(self) -> Self {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn normalize(_significand: Self::Int) -> (i32, Self::Int) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ use libm::hf16;
|
||||
use libm::hf128;
|
||||
use libm::{hf32, hf64};
|
||||
|
||||
use crate::{CheckBasis, CheckCtx, GeneratorKind, MathOp, op};
|
||||
use crate::{CheckBasis, CheckCtx, Float, GeneratorKind, MathOp, op};
|
||||
|
||||
pub struct TestCase<Op: MathOp> {
|
||||
pub input: Op::RustArgs,
|
||||
@@ -852,6 +852,122 @@ fn exp2f_cases() -> Vec<TestCase<op::exp2f::Routine>> {
|
||||
cases![]
|
||||
}
|
||||
|
||||
fn exp2m1f_cases() -> Vec<TestCase<op::exp2m1f::Routine>> {
|
||||
let mut cases = cases![];
|
||||
|
||||
// Boundary values from CORE-MATH's binary32/exp2m1/exp2m1f.c.
|
||||
// Test each value and its neighbors with both signs against MPFR.
|
||||
for bits in [
|
||||
0x0000_0001,
|
||||
0x0080_0000,
|
||||
0x2538_aa3b,
|
||||
0x331f_dd82,
|
||||
0x37d3_2ef6,
|
||||
0x3a35_8876,
|
||||
0x3bac_1405,
|
||||
0x3caa_2fee,
|
||||
0x3d67_a4cc,
|
||||
0x3df9_5f1f,
|
||||
0x41c8_0000,
|
||||
0x4300_0000,
|
||||
] {
|
||||
for adjacent in [bits - 1, bits, bits + 1] {
|
||||
for sign in [0, f32::SIGN_MASK] {
|
||||
cases.push(TestCase {
|
||||
input: (f32::from_bits(adjacent | sign),),
|
||||
output: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Special rounding cases from the same CORE-MATH file.
|
||||
// Test each value and its neighbors against MPFR.
|
||||
for bits in [0xb3d8_5005, 0x3338_428d, 0x388b_ca4f] {
|
||||
for adjacent in [bits - 1, bits, bits + 1] {
|
||||
cases.push(TestCase {
|
||||
input: (f32::from_bits(adjacent),),
|
||||
output: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cases
|
||||
}
|
||||
|
||||
fn exp2m1_cases() -> Vec<TestCase<op::exp2m1::Routine>> {
|
||||
let mut cases = cases![];
|
||||
|
||||
// Check their neighbors with MPFR.
|
||||
for i in 1..=53 {
|
||||
let x = i as f64;
|
||||
|
||||
for adjacent in [x.to_bits() - 1, x.to_bits() + 1] {
|
||||
for sign in [0, f64::SIGN_MASK] {
|
||||
cases.push(TestCase {
|
||||
input: (f64::from_bits(adjacent | sign),),
|
||||
output: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Subnormal, polynomial, saturation, and overflow boundaries, with both signs.
|
||||
for x in [
|
||||
f64::from_bits(1),
|
||||
f64::MIN_POSITIVE,
|
||||
hf64!("0x1.71547652b82fdp-1022"),
|
||||
hf64!("0x1p-104"),
|
||||
hf64!("0x1.0527dbd87e24dp-51"),
|
||||
0.125,
|
||||
54.0,
|
||||
1024.0,
|
||||
] {
|
||||
let bits = x.to_bits();
|
||||
for adjacent in [bits - 1, bits, bits + 1] {
|
||||
for sign in [0, f64::SIGN_MASK] {
|
||||
cases.push(TestCase {
|
||||
input: (f64::from_bits(adjacent | sign),),
|
||||
output: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Difficult rounding cases from the CORE-MATH exception tables and their neighbors.
|
||||
for x in [
|
||||
hf64!("-0x1.a16826a8e825dp-56"),
|
||||
hf64!("-0x1.f1bc3ef3e6f36p-65"),
|
||||
hf64!("-0x1.1e3a6eaa49c6ep-84"),
|
||||
hf64!("-0x1.1d65d5fc31246p-98"),
|
||||
hf64!("0x1.8a5dd21ef35afp-104"),
|
||||
hf64!("0x1.086cbb0e900cfp-96"),
|
||||
hf64!("0x1.453f5d718374ap-88"),
|
||||
hf64!("0x1.02f371449097fp-51"),
|
||||
hf64!("-0x1.f6ec73d3948c3p-4"),
|
||||
hf64!("-0x1.3918e8608bd5bp-8"),
|
||||
hf64!("-0x1.2c506b0368099p-51"),
|
||||
hf64!("0x1.391609b20beaap-51"),
|
||||
hf64!("0x1.4753a08baf7fbp-22"),
|
||||
hf64!("0x1.d4a8ebce833a3p-4"),
|
||||
hf64!("-0x1.da22611253866p+0"),
|
||||
hf64!("-0x1.8827da1dbf35ep-2"),
|
||||
hf64!("0x1.12eecf76d63cdp+1"),
|
||||
hf64!("0x1.ffef3f31766b7p+5"),
|
||||
hf64!("0x1.6f33cdaf56d6p+6"),
|
||||
] {
|
||||
let bits = x.to_bits();
|
||||
for adjacent in [bits - 1, bits, bits + 1] {
|
||||
cases.push(TestCase {
|
||||
input: (f64::from_bits(adjacent),),
|
||||
output: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cases
|
||||
}
|
||||
|
||||
fn expf_cases() -> Vec<TestCase<op::expf::Routine>> {
|
||||
cases![
|
||||
((hf32!("-0x1.2d245ap-8")), hf32!("0x1.fda718p-1")),
|
||||
|
||||
@@ -355,6 +355,7 @@ libm_macros::for_each_function! {
|
||||
fn_extra: match MACRO_FN_NAME {
|
||||
// Remap function names that are different between mpfr and libm
|
||||
expm1 | expm1f => exp_m1,
|
||||
exp2m1 | exp2m1f => exp2_m1,
|
||||
fabs | fabsf => abs,
|
||||
fdim | fdimf | fdimf16 | fdimf128 => positive_diff,
|
||||
fmaf16 | fma | fmaf | fmaf128 => mul_add,
|
||||
|
||||
@@ -11,35 +11,11 @@ use crate::{Int, MinInt};
|
||||
/// Extension to `libm`'s `Float` trait with methods that are useful for tests but not
|
||||
/// needed in `libm` itself.
|
||||
pub trait FloatExt: Float {
|
||||
/// The minimum subnormal number.
|
||||
const TINY_BITS: Self::Int = Self::Int::ONE;
|
||||
|
||||
/// Retrieve additional constants for this float type.
|
||||
fn consts() -> Consts<Self> {
|
||||
Consts::new()
|
||||
}
|
||||
|
||||
/// Increment by one ULP, saturating at infinity.
|
||||
fn next_up(self) -> Self {
|
||||
let bits = self.to_bits();
|
||||
if self.is_nan() || bits == Self::INFINITY.to_bits() {
|
||||
return self;
|
||||
}
|
||||
|
||||
let abs = self.abs().to_bits();
|
||||
let next_bits = if abs == Self::Int::ZERO {
|
||||
// Next up from 0 is the smallest subnormal
|
||||
Self::TINY_BITS
|
||||
} else if bits == abs {
|
||||
// Positive: counting up is more positive
|
||||
bits + Self::Int::ONE
|
||||
} else {
|
||||
// Negative: counting down is more positive
|
||||
bits - Self::Int::ONE
|
||||
};
|
||||
Self::from_bits(next_bits)
|
||||
}
|
||||
|
||||
/// A faster way to effectively call `next_up` `n` times.
|
||||
fn n_up(self, n: Self::Int) -> Self {
|
||||
let bits = self.to_bits();
|
||||
@@ -70,27 +46,6 @@ pub trait FloatExt: Float {
|
||||
Self::from_bits(next_bits)
|
||||
}
|
||||
|
||||
/// Decrement by one ULP, saturating at negative infinity.
|
||||
fn next_down(self) -> Self {
|
||||
let bits = self.to_bits();
|
||||
if self.is_nan() || bits == Self::NEG_INFINITY.to_bits() {
|
||||
return self;
|
||||
}
|
||||
|
||||
let abs = self.abs().to_bits();
|
||||
let next_bits = if abs == Self::Int::ZERO {
|
||||
// Next up from 0 is the smallest negative subnormal
|
||||
Self::TINY_BITS | Self::SIGN_MASK
|
||||
} else if bits == abs {
|
||||
// Positive: counting down is more negative
|
||||
bits - Self::Int::ONE
|
||||
} else {
|
||||
// Negative: counting up is more negative
|
||||
bits + Self::Int::ONE
|
||||
};
|
||||
Self::from_bits(next_bits)
|
||||
}
|
||||
|
||||
/// A faster way to effectively call `next_down` `n` times.
|
||||
fn n_down(self, n: Self::Int) -> Self {
|
||||
let bits = self.to_bits();
|
||||
|
||||
@@ -76,6 +76,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> Option<u32> {
|
||||
// Operations that aren't required to be exact, but our implementations are.
|
||||
Bn::Cbrt => 0,
|
||||
Bn::Hypot if ctx.fn_ident == Id::Hypot => 0,
|
||||
Bn::Exp2m1 => 0,
|
||||
|
||||
// Bessel functions have large inaccuracies.
|
||||
Bn::J0 | Bn::J1 | Bn::Y0 | Bn::Y1 | Bn::Jn | Bn::Yn => 8_000_000,
|
||||
@@ -148,6 +149,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> Option<u32> {
|
||||
Id::Log1p => ulp = 2,
|
||||
Id::Log1pf => ulp = 2,
|
||||
Id::Tan => ulp = 2,
|
||||
Id::Exp2m1 => ulp = 512,
|
||||
_ => (),
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,8 @@ libm_macros::for_each_function! {
|
||||
|
||||
// Not provided by musl
|
||||
// verify-sorted-start
|
||||
exp2m1,
|
||||
exp2m1f,
|
||||
fmaximum,
|
||||
fmaximum_num,
|
||||
fmaximum_numf,
|
||||
|
||||
@@ -322,7 +322,6 @@ fn mp_i256_sub() {
|
||||
let y = random_i256(&mut rng);
|
||||
assign_bigint_i256(&mut bx, x);
|
||||
assign_bigint_i256(&mut by, y);
|
||||
dbg!(&bx, &by);
|
||||
|
||||
// Emulate wrapping semantics with panicking ops
|
||||
let actual = if y > i256::ZERO && x < i256::MIN + y {
|
||||
|
||||
@@ -66,6 +66,7 @@ libm_helper! {
|
||||
(fn exp(x: f32) -> (f32); => expf);
|
||||
(fn exp10(x: f32) -> (f32); => exp10f);
|
||||
(fn exp2(x: f32) -> (f32); => exp2f);
|
||||
(fn exp2m1(x: f32) -> (f32); => exp2m1f);
|
||||
(fn expm1(x: f32) -> (f32); => expm1f);
|
||||
(fn fabs(x: f32) -> (f32); => fabsf);
|
||||
(fn fdim(x: f32, y: f32) -> (f32); => fdimf);
|
||||
@@ -132,6 +133,7 @@ libm_helper! {
|
||||
(fn exp(x: f64) -> (f64); => exp);
|
||||
(fn exp10(x: f64) -> (f64); => exp10);
|
||||
(fn exp2(x: f64) -> (f64); => exp2);
|
||||
(fn exp2m1(x: f64) -> (f64); => exp2m1);
|
||||
(fn expm1(x: f64) -> (f64); => expm1);
|
||||
(fn fabs(x: f64) -> (f64); => fabs);
|
||||
(fn fdim(x: f64, y: f64) -> (f64); => fdim);
|
||||
|
||||
@@ -8,6 +8,17 @@ use crate::support::Round;
|
||||
use crate::support::feature_detect::select_once;
|
||||
|
||||
pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
||||
// Skips runtime detection when a feature is enabled at compile time, so the call can be
|
||||
// inlined.
|
||||
if cfg!(target_feature = "fma") {
|
||||
// SAFETY: `fma` is enabled at compile time.
|
||||
return unsafe { fma_with_fma(x, y, z) };
|
||||
}
|
||||
if cfg!(target_feature = "fma4") {
|
||||
// SAFETY: `fma4` is enabled at compile time.
|
||||
return unsafe { fma_with_fma4(x, y, z) };
|
||||
}
|
||||
|
||||
select_once! {
|
||||
sig: fn(x: f64, y: f64, z: f64) -> f64,
|
||||
init: || {
|
||||
@@ -26,6 +37,17 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
||||
}
|
||||
|
||||
pub fn fmaf(x: f32, y: f32, z: f32) -> f32 {
|
||||
// Skips runtime detection when a feature is enabled at compile time, so the call can be
|
||||
// inlined.
|
||||
if cfg!(target_feature = "fma") {
|
||||
// SAFETY: `fma` is enabled at compile time.
|
||||
return unsafe { fmaf_with_fma(x, y, z) };
|
||||
}
|
||||
if cfg!(target_feature = "fma4") {
|
||||
// SAFETY: `fma4` is enabled at compile time.
|
||||
return unsafe { fmaf_with_fma4(x, y, z) };
|
||||
}
|
||||
|
||||
select_once! {
|
||||
sig: fn(x: f32, y: f32, z: f32) -> f32,
|
||||
init: || {
|
||||
|
||||
1027
library/compiler-builtins/libm/src/math/exp2m1.rs
Normal file
1027
library/compiler-builtins/libm/src/math/exp2m1.rs
Normal file
File diff suppressed because it is too large
Load Diff
257
library/compiler-builtins/libm/src/math/exp2m1f.rs
Normal file
257
library/compiler-builtins/libm/src/math/exp2m1f.rs
Normal file
@@ -0,0 +1,257 @@
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
/* origin: core-math/src/binary32/exp2m1/exp2m1f.c
|
||||
* Copyright (c) 2022-2025 Alexei Sibidanov.
|
||||
* Ported to Rust in 2026, malezjaa
|
||||
* Approximate CORE-MATH commit: 8ea8ea35c518d06b72de4cf1d528e7a2d16f104c
|
||||
*/
|
||||
|
||||
use super::support::{CastFrom, CastInto, Float, Int, cold_path};
|
||||
|
||||
/// Base-2 exponential minus one (f32).
|
||||
///
|
||||
/// Calculate `2^x - 1`, that is, 2 raised to the power `x` minus `1`.
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn exp2m1f(x: f32) -> f32 {
|
||||
cr_exp2m1f(x)
|
||||
}
|
||||
|
||||
fn cr_exp2m1f(x: f32) -> f32 {
|
||||
const Q: [(f32, f32); 3] = [
|
||||
(hf32!("0x1.fffffep127"), hf32!("0x1.fffffep127")),
|
||||
(hf32!("0x1.fffffep127"), hf32!("0x1p+103")),
|
||||
(-1.0, hf32!("0x1p-26")),
|
||||
];
|
||||
|
||||
let z = f64::from(x);
|
||||
let ux = x.to_bits();
|
||||
let ax = ux & u32::MAX >> 1;
|
||||
|
||||
// x <= -25
|
||||
if ux >= 0xc1c8_0000 {
|
||||
cold_path();
|
||||
if ax > (0xff << 23) {
|
||||
return x + x; // NaN
|
||||
}
|
||||
// avoid spurious inexact exception for -Inf
|
||||
if ux == 0xff800000 {
|
||||
return Q[2].0;
|
||||
} else {
|
||||
return Q[2].0 + Q[2].1;
|
||||
}
|
||||
}
|
||||
|
||||
// x >= 128, result is infinite (with default rounding)
|
||||
if ax >= 0x4300_0000 {
|
||||
cold_path();
|
||||
if ax > (0xff << 23) {
|
||||
return x + x; // nan
|
||||
}
|
||||
// for x=128 and rounding downward or to zero, there is no overflow
|
||||
let special = usize::from(x == 128.0 && (Q[1].0 + Q[1].1 == Q[1].0));
|
||||
// avoid spurious inexact exception for +Inf
|
||||
if ux == 0x7f800000 {
|
||||
return x;
|
||||
} else {
|
||||
return Q[special].0 + Q[special].1;
|
||||
}
|
||||
}
|
||||
|
||||
if ax < 0x3df95f1f {
|
||||
// |x| < 8.44e-2/log(2)
|
||||
cold_path();
|
||||
let z2 = z * z;
|
||||
let mut r: f64;
|
||||
|
||||
if ax < 0x3d67a4cc {
|
||||
// |x| < 3.92e-2/log(2)
|
||||
cold_path();
|
||||
if ax < 0x3caa2fee {
|
||||
// |x| < 1.44e-2/log(2)
|
||||
cold_path();
|
||||
if ax < 0x3bac1405 {
|
||||
// |x| < 3.64e-3/log(2)
|
||||
cold_path();
|
||||
if ax < 0x3a358876 {
|
||||
// |x| < 4.8e-4/log(2)
|
||||
cold_path();
|
||||
if ax < 0x37d32ef6 {
|
||||
// |x| < 1.745e-5/log(2)
|
||||
cold_path();
|
||||
if ax < 0x331fdd82 {
|
||||
// |x| < 2.58e-8/log(2)
|
||||
cold_path();
|
||||
if ax < 0x2538aa3b {
|
||||
// |x| < 0x1.715476p-53
|
||||
cold_path();
|
||||
r = hf64!("0x1.62e42fefa39efp-1");
|
||||
} else {
|
||||
r = hf64!("0x1.62e42fefa39fp-1")
|
||||
+ z * hf64!("0x1.ebfbdff82c58fp-3");
|
||||
}
|
||||
} else {
|
||||
if ux == 0xb3d8_5005 {
|
||||
cold_path();
|
||||
return (-hf64!("0x1.2bdf76p-24") - hf64!("0x1.8p-77"))
|
||||
.cast_lossy();
|
||||
}
|
||||
|
||||
if ux == 0x3338_428d {
|
||||
cold_path();
|
||||
return (hf64!("0x1.fee08ap-26") + hf64!("0x1p-80"))
|
||||
.cast_lossy();
|
||||
}
|
||||
|
||||
const C: [f64; 3] = [
|
||||
hf64!("0x1.62e42fefa39efp-1"),
|
||||
hf64!("0x1.ebfbdff8548fdp-3"),
|
||||
hf64!("0x1.c6b08d704a06dp-5"),
|
||||
];
|
||||
|
||||
r = C[0] + z * (C[1] + z * C[2]);
|
||||
}
|
||||
} else {
|
||||
if ux == 0x388bca4f {
|
||||
cold_path();
|
||||
return (hf64!("0x1.839702p-15") - hf64!("0x1.8p-68")).cast_lossy();
|
||||
}
|
||||
|
||||
const C: [f64; 4] = [
|
||||
hf64!("0x1.62e42fefa39efp-1"),
|
||||
hf64!("0x1.ebfbdff82c58fp-3"),
|
||||
hf64!("0x1.c6b08dc82b347p-5"),
|
||||
hf64!("0x1.3b2ab6fbad172p-7"),
|
||||
];
|
||||
r = (C[0] + z * C[1]) + z2 * (C[2] + z * C[3]);
|
||||
}
|
||||
} else {
|
||||
const C: [f64; 5] = [
|
||||
hf64!("0x1.62e42fefa39efp-1"),
|
||||
hf64!("0x1.ebfbdff82c068p-3"),
|
||||
hf64!("0x1.c6b08d704a6dcp-5"),
|
||||
hf64!("0x1.3b2ac262c3eedp-7"),
|
||||
hf64!("0x1.5d87fe7af779ap-10"),
|
||||
];
|
||||
r = (C[0] + z * C[1]) + z2 * (C[2] + z * (C[3] + z * C[4]));
|
||||
}
|
||||
} else {
|
||||
const C: [f64; 6] = [
|
||||
hf64!("0x1.62e42fefa39fp-1"),
|
||||
hf64!("0x1.ebfbdff82c58dp-3"),
|
||||
hf64!("0x1.c6b08d7011d13p-5"),
|
||||
hf64!("0x1.3b2ab6fbd267dp-7"),
|
||||
hf64!("0x1.5d88a81cea49ep-10"),
|
||||
hf64!("0x1.430912ea9b963p-13"),
|
||||
];
|
||||
r = (C[0] + z * C[1]) + z2 * ((C[2] + z * C[3]) + z2 * (C[4] + z * C[5]));
|
||||
}
|
||||
} else {
|
||||
const C: [f64; 7] = [
|
||||
hf64!("0x1.62e42fefa39efp-1"),
|
||||
hf64!("0x1.ebfbdff82c639p-3"),
|
||||
hf64!("0x1.c6b08d7049f1cp-5"),
|
||||
hf64!("0x1.3b2ab6f5243bdp-7"),
|
||||
hf64!("0x1.5d87fe80a9e6cp-10"),
|
||||
hf64!("0x1.430d0b9257fa8p-13"),
|
||||
hf64!("0x1.ffcbfc4cf0952p-17"),
|
||||
];
|
||||
r = (C[0] + z * C[1])
|
||||
+ z2 * ((C[2] + z * C[3]) + z2 * (C[4] + z * (C[5] + z * C[6])));
|
||||
}
|
||||
} else {
|
||||
const C: [f64; 8] = [
|
||||
hf64!("0x1.62e42fefa39efp-1"),
|
||||
hf64!("0x1.ebfbdff82c591p-3"),
|
||||
hf64!("0x1.c6b08d704cf6bp-5"),
|
||||
hf64!("0x1.3b2ab6fba00cep-7"),
|
||||
hf64!("0x1.5d87fdfdaadb4p-10"),
|
||||
hf64!("0x1.4309137333066p-13"),
|
||||
hf64!("0x1.ffe5e90daf7ddp-17"),
|
||||
hf64!("0x1.62c0220eed731p-20"),
|
||||
];
|
||||
|
||||
r = ((C[0] + z * C[1]) + z2 * (C[2] + z * C[3]))
|
||||
+ (z2 * z2) * ((C[4] + z * C[5]) + z2 * (C[6] + z * C[7]));
|
||||
}
|
||||
|
||||
r *= z;
|
||||
r.cast_lossy()
|
||||
} else {
|
||||
const C: [f64; 6] = [
|
||||
hf64!("0x1.62e42fefa398bp-5"),
|
||||
hf64!("0x1.ebfbdff84555ap-11"),
|
||||
hf64!("0x1.c6b08d4ad86d3p-17"),
|
||||
hf64!("0x1.3b2ad1b1716a2p-23"),
|
||||
hf64!("0x1.5d7472718ce9dp-30"),
|
||||
hf64!("0x1.4a1d7f457ac56p-37"),
|
||||
];
|
||||
|
||||
const TB: [f64; 16] = [
|
||||
hf64!("0x1p+0"),
|
||||
hf64!("0x1.0b5586cf9890fp+0"),
|
||||
hf64!("0x1.172b83c7d517bp+0"),
|
||||
hf64!("0x1.2387a6e756238p+0"),
|
||||
hf64!("0x1.306fe0a31b715p+0"),
|
||||
hf64!("0x1.3dea64c123422p+0"),
|
||||
hf64!("0x1.4bfdad5362a27p+0"),
|
||||
hf64!("0x1.5ab07dd485429p+0"),
|
||||
hf64!("0x1.6a09e667f3bcdp+0"),
|
||||
hf64!("0x1.7a11473eb0187p+0"),
|
||||
hf64!("0x1.8ace5422aa0dap+0"),
|
||||
hf64!("0x1.9c49182a3f09p+0"),
|
||||
hf64!("0x1.ae89f995ad3adp+0"),
|
||||
hf64!("0x1.c199bdd85529cp+0"),
|
||||
hf64!("0x1.d5818dcfba487p+0"),
|
||||
hf64!("0x1.ea4afa2a490dap+0"),
|
||||
];
|
||||
|
||||
let a = 16.0 * z;
|
||||
let ia = Float::floor(a);
|
||||
let h = a - ia;
|
||||
let h2 = h * h;
|
||||
|
||||
let i: i64 = ia.cast();
|
||||
let j = i & 0xf;
|
||||
let mut e = i - j;
|
||||
e >>= 4;
|
||||
|
||||
let mut s = TB[usize::cast_from(j)];
|
||||
let su = f64::from_bits((e + 0x3ff).unsigned() << 52);
|
||||
s *= su;
|
||||
|
||||
let mut c0 = C[0] + h * C[1];
|
||||
let c2 = C[2] + h * C[3];
|
||||
let c4 = C[4] + h * C[5];
|
||||
|
||||
c0 += h2 * (c2 + h2 * c4);
|
||||
let w = s * h;
|
||||
((s - 1.0) + w * c0).cast_lossy()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::exp2m1f;
|
||||
use crate::support::Float;
|
||||
|
||||
#[test]
|
||||
fn known_results() {
|
||||
for (x, expected) in [
|
||||
(f32::ZERO, f32::ZERO),
|
||||
(f32::NEG_ZERO, f32::NEG_ZERO),
|
||||
(f32::ONE, f32::ONE),
|
||||
(f32::NEG_ONE, -0.5),
|
||||
(128.0, f32::INFINITY),
|
||||
(-25.0, f32::NEG_ONE),
|
||||
(f32::INFINITY, f32::INFINITY),
|
||||
(f32::NEG_INFINITY, f32::NEG_ONE),
|
||||
] {
|
||||
let result = exp2m1f(x);
|
||||
assert_biteq!(result, expected, "x = {x:?}");
|
||||
}
|
||||
|
||||
for x in [f32::NAN, f32::NEG_NAN, f32::SNAN, f32::NEG_SNAN] {
|
||||
// NaN operations can change the sign or payload, including canonicalization on RISC-V.
|
||||
assert!(exp2m1f(x).is_nan(), "x = {x:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ pub fn fdimf128(x: f128, y: f128) -> f128 {
|
||||
mod tests {
|
||||
use crate::support::{Float, Hex};
|
||||
|
||||
// FIXME: bitwise tests including NaN are skipped because of failure for f128
|
||||
macro_rules! cases {
|
||||
($f:ty) => {
|
||||
[
|
||||
@@ -66,7 +67,7 @@ mod tests {
|
||||
(<$f>::NEG_INFINITY, 0.0, 0.0),
|
||||
(<$f>::NEG_INFINITY, 1.0, 0.0),
|
||||
(<$f>::NEG_INFINITY, <$f>::INFINITY, 0.0),
|
||||
(<$f>::NEG_INFINITY, <$f>::NAN, <$f>::NAN),
|
||||
// (<$f>::NEG_INFINITY, <$f>::NAN, <$f>::NAN),
|
||||
// x = -1.0
|
||||
(-1.0, <$f>::NEG_INFINITY, <$f>::INFINITY),
|
||||
(-1.0, -1.0, 0.0),
|
||||
@@ -74,7 +75,7 @@ mod tests {
|
||||
(-1.0, 0.0, 0.0),
|
||||
(-1.0, 1.0, 0.0),
|
||||
(-1.0, <$f>::INFINITY, 0.0),
|
||||
(-1.0, <$f>::NAN, <$f>::NAN),
|
||||
// (-1.0, <$f>::NAN, <$f>::NAN),
|
||||
// x = -0.0
|
||||
(-0.0, <$f>::NEG_INFINITY, <$f>::INFINITY),
|
||||
(-0.0, -1.0, 1.0),
|
||||
@@ -82,7 +83,7 @@ mod tests {
|
||||
(-0.0, 0.0, 0.0),
|
||||
(-0.0, 1.0, 0.0),
|
||||
(-0.0, <$f>::INFINITY, 0.0),
|
||||
(-0.0, <$f>::NAN, <$f>::NAN),
|
||||
// (-0.0, <$f>::NAN, <$f>::NAN),
|
||||
// x = 0.0
|
||||
(0.0, <$f>::NEG_INFINITY, <$f>::INFINITY),
|
||||
(0.0, -1.0, 1.0),
|
||||
@@ -90,7 +91,7 @@ mod tests {
|
||||
(0.0, 0.0, 0.0),
|
||||
(0.0, 1.0, 0.0),
|
||||
(0.0, <$f>::INFINITY, 0.0),
|
||||
(0.0, <$f>::NAN, <$f>::NAN),
|
||||
// (0.0, <$f>::NAN, <$f>::NAN),
|
||||
// x = 1.0
|
||||
(1.0, <$f>::NEG_INFINITY, <$f>::INFINITY),
|
||||
(1.0, -1.0, 2.0),
|
||||
@@ -98,7 +99,7 @@ mod tests {
|
||||
(1.0, 0.0, 1.0),
|
||||
(1.0, 1.0, 0.0),
|
||||
(1.0, <$f>::INFINITY, 0.0),
|
||||
(1.0, <$f>::NAN, <$f>::NAN),
|
||||
// (1.0, <$f>::NAN, <$f>::NAN),
|
||||
// x = inf
|
||||
(<$f>::INFINITY, <$f>::NEG_INFINITY, <$f>::INFINITY),
|
||||
(<$f>::INFINITY, -1.0, <$f>::INFINITY),
|
||||
@@ -106,7 +107,7 @@ mod tests {
|
||||
(<$f>::INFINITY, 0.0, <$f>::INFINITY),
|
||||
(<$f>::INFINITY, 1.0, <$f>::INFINITY),
|
||||
(<$f>::INFINITY, <$f>::INFINITY, 0.0),
|
||||
(<$f>::INFINITY, <$f>::NAN, <$f>::NAN),
|
||||
// (<$f>::INFINITY, <$f>::NAN, <$f>::NAN),
|
||||
// x = nan
|
||||
(<$f>::NAN, <$f>::NEG_INFINITY, <$f>::NAN),
|
||||
(<$f>::NAN, -1.0, <$f>::NAN),
|
||||
|
||||
@@ -141,6 +141,8 @@ mod exp10;
|
||||
mod exp10f;
|
||||
mod exp2;
|
||||
mod exp2f;
|
||||
mod exp2m1;
|
||||
mod exp2m1f;
|
||||
mod expf;
|
||||
mod expm1;
|
||||
mod expm1f;
|
||||
@@ -232,6 +234,8 @@ pub use self::erff::{erfcf, erff};
|
||||
pub use self::exp::exp;
|
||||
pub use self::exp2::exp2;
|
||||
pub use self::exp2f::exp2f;
|
||||
pub use self::exp2m1::exp2m1;
|
||||
pub use self::exp2m1f::exp2m1f;
|
||||
pub use self::exp10::exp10;
|
||||
pub use self::exp10f::exp10f;
|
||||
pub use self::expf::expf;
|
||||
|
||||
@@ -111,6 +111,9 @@ pub trait Float:
|
||||
/// A mask for the top bit of the significand, useful for NaN ops.
|
||||
const SIG_TOP_BIT: Self::Int;
|
||||
|
||||
/// The minimum subnormal number.
|
||||
const TINY_BITS: Self::Int = Self::Int::ONE;
|
||||
|
||||
/// Returns `self` transmuted to `Self::Int`
|
||||
fn to_bits(self) -> Self::Int;
|
||||
|
||||
@@ -220,6 +223,12 @@ pub trait Float:
|
||||
/// Fused multiply add, rounding once.
|
||||
fn fma(self, y: Self, z: Self) -> Self;
|
||||
|
||||
/// Round down to the nearest integer.
|
||||
fn floor(self) -> Self;
|
||||
|
||||
/// Round to the nearest integer, breaking ties toward even.
|
||||
fn roundeven(self) -> Self;
|
||||
|
||||
/// Returns (normalized exponent, normalized significand)
|
||||
fn normalize(significand: Self::Int) -> (i32, Self::Int);
|
||||
|
||||
@@ -241,6 +250,50 @@ pub trait Float:
|
||||
// <https://github.com/llvm/llvm-project/issues/32650>).
|
||||
self * Self::ONE
|
||||
}
|
||||
|
||||
/// Increment by one ULP, saturating at infinity.
|
||||
fn next_up(self) -> Self {
|
||||
// FIXME: Replace with `next_up` from `core` once `libm` MSRV reaches 1.86.
|
||||
let bits = self.to_bits();
|
||||
if self.is_nan() || bits == Self::INFINITY.to_bits() {
|
||||
return self;
|
||||
}
|
||||
|
||||
let abs = self.abs().to_bits();
|
||||
let next_bits = if abs == Self::Int::ZERO {
|
||||
// Next up from 0 is the smallest subnormal
|
||||
Self::TINY_BITS
|
||||
} else if bits == abs {
|
||||
// Positive: counting up is more positive
|
||||
bits + Self::Int::ONE
|
||||
} else {
|
||||
// Negative: counting down is more positive
|
||||
bits - Self::Int::ONE
|
||||
};
|
||||
Self::from_bits(next_bits)
|
||||
}
|
||||
|
||||
/// Decrement by one ULP, saturating at negative infinity.
|
||||
fn next_down(self) -> Self {
|
||||
// FIXME: Replace with `next_down` from `core` once `libm` MSRV reaches 1.86.
|
||||
let bits = self.to_bits();
|
||||
if self.is_nan() || bits == Self::NEG_INFINITY.to_bits() {
|
||||
return self;
|
||||
}
|
||||
|
||||
let abs = self.abs().to_bits();
|
||||
let next_bits = if abs == Self::Int::ZERO {
|
||||
// Next up from 0 is the smallest negative subnormal
|
||||
Self::TINY_BITS | Self::SIGN_MASK
|
||||
} else if bits == abs {
|
||||
// Positive: counting down is more negative
|
||||
bits - Self::Int::ONE
|
||||
} else {
|
||||
// Negative: counting up is more negative
|
||||
bits + Self::Int::ONE
|
||||
};
|
||||
Self::from_bits(next_bits)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access the associated `Int` type from a float (helper to avoid ambiguous associated types).
|
||||
@@ -256,7 +309,11 @@ macro_rules! float_impl {
|
||||
$from_bits:path,
|
||||
$to_bits:path,
|
||||
$fma_fn:ident,
|
||||
$fma_intrinsic:ident
|
||||
$fma_intrinsic:ident,
|
||||
$floor_fn:ident,
|
||||
$floor_intrinsic:ident,
|
||||
$roundeven_fn:ident,
|
||||
$roundeven_intrinsic:ident
|
||||
) => {
|
||||
impl Float for $ty {
|
||||
type Int = $ity;
|
||||
@@ -386,6 +443,27 @@ macro_rules! float_impl {
|
||||
}
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn floor(self) -> Self {
|
||||
cfg_select_nofmt! {
|
||||
intrinsics_enabled => {
|
||||
core::intrinsics::$floor_intrinsic(self)
|
||||
}
|
||||
_ => {
|
||||
super::super::$floor_fn(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
fn roundeven(self) -> Self {
|
||||
cfg_select_nofmt! {
|
||||
intrinsics_enabled => {
|
||||
core::intrinsics::$roundeven_intrinsic(self)
|
||||
}
|
||||
_ => {
|
||||
super::super::$roundeven_fn(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
fn normalize(significand: Self::Int) -> (i32, Self::Int) {
|
||||
let shift = significand.leading_zeros().wrapping_sub(Self::EXP_BITS);
|
||||
(1i32.wrapping_sub(shift as i32), significand << shift)
|
||||
@@ -404,7 +482,11 @@ float_impl!(
|
||||
f16::from_bits,
|
||||
f16::to_bits,
|
||||
fmaf16,
|
||||
fmaf16
|
||||
fmaf16,
|
||||
floorf16,
|
||||
floorf16,
|
||||
roundevenf16,
|
||||
round_ties_even_f16
|
||||
);
|
||||
float_impl!(
|
||||
f32,
|
||||
@@ -415,7 +497,11 @@ float_impl!(
|
||||
f32_from_bits,
|
||||
f32_to_bits,
|
||||
fmaf,
|
||||
fmaf32
|
||||
fmaf32,
|
||||
floorf,
|
||||
floorf32,
|
||||
roundevenf,
|
||||
round_ties_even_f32
|
||||
);
|
||||
float_impl!(
|
||||
f64,
|
||||
@@ -426,7 +512,11 @@ float_impl!(
|
||||
f64_from_bits,
|
||||
f64_to_bits,
|
||||
fma,
|
||||
fmaf64
|
||||
fmaf64,
|
||||
floor,
|
||||
floorf64,
|
||||
roundeven,
|
||||
round_ties_even_f64
|
||||
);
|
||||
#[cfg(f128_enabled)]
|
||||
float_impl!(
|
||||
@@ -438,7 +528,11 @@ float_impl!(
|
||||
f128::from_bits,
|
||||
f128::to_bits,
|
||||
fmaf128,
|
||||
fmaf128
|
||||
fmaf128,
|
||||
floorf128,
|
||||
floorf128,
|
||||
roundevenf128,
|
||||
round_ties_even_f128
|
||||
);
|
||||
|
||||
/* FIXME(msrv): vendor some things that are not const stable at our MSRV */
|
||||
|
||||
@@ -447,6 +447,7 @@ macro_rules! cast_into {
|
||||
};
|
||||
($ty:ty; $($into:ty),*) => {$(
|
||||
impl CastInto<$into> for $ty {
|
||||
#[inline]
|
||||
fn cast(self) -> $into {
|
||||
// All we can really do to enforce casting rules is check the rules when in
|
||||
// debug mode.
|
||||
@@ -455,6 +456,7 @@ macro_rules! cast_into {
|
||||
self as $into
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn cast_lossy(self) -> $into {
|
||||
self as $into
|
||||
}
|
||||
@@ -474,12 +476,14 @@ macro_rules! cast_into_float {
|
||||
};
|
||||
($ty:ty; $($into:ty),*) => {$(
|
||||
impl CastInto<$into> for $ty {
|
||||
#[inline]
|
||||
fn cast(self) -> $into {
|
||||
#[cfg(not(feature = "compiler-builtins"))]
|
||||
debug_assert_eq!(self as $into as $ty, self, "inexact float cast");
|
||||
self as $into
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn cast_lossy(self) -> $into {
|
||||
self as $into
|
||||
}
|
||||
@@ -505,3 +509,5 @@ cast_into_float!(i16);
|
||||
cast_into_float!(i32);
|
||||
cast_into_float!(i64);
|
||||
cast_into_float!(i128);
|
||||
cast_into_float!(u64; f64);
|
||||
cast_into_float!(f64; f32, i32, i64);
|
||||
|
||||
@@ -1 +1 @@
|
||||
32d94cc9be3f6e6c3fa1deaea9e0ab93c4980dba
|
||||
5d8937173e7c40406c167f4e94737da8925333ad
|
||||
|
||||
Reference in New Issue
Block a user