about summary refs log tree commit diff
path: root/compiler/rustc_target/src/target_features.rs
AgeCommit message (Collapse)AuthorLines
2025-01-29Auto merge of #136227 - fmease:rollup-ewpvznh, r=fmeasebors-0/+5
Rollup of 9 pull requests Successful merges: - #136121 (Deduplicate operand creation between scalars, non-scalars and string patterns) - #136134 (Fix SIMD codegen tests on LLVM 20) - #136153 (Locate asan-odr-win with other sanitizer tests) - #136161 (rustdoc: add nobuild typescript checking to our JS) - #136166 (interpret: is_alloc_live: check global allocs last) - #136168 (GCI: Don't try to eval / collect mono items inside overly generic free const items) - #136170 (Reject unsound toggling of Arm atomics-32 target feature) - #136176 (Render pattern types nicely in mir dumps) - #136186 (uefi: process: Fix args) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-28Reject unsound toggling of Arm atomics-32 target featureTaiki Endo-0/+5
2025-01-28update commentsRalf Jung-13/+11
2025-01-07arm: add unstable soft-float target featureRalf Jung-0/+8
2025-01-05add dedicated type for ABI target feature constraintsRalf Jung-10/+18
2024-12-31arm: use target.llvm_floatabi over soft-float target featureRalf Jung-9/+20
2024-12-31add ABI target features *before* -Ctarget-featuresRalf Jung-0/+3
2024-12-31x86-64 hardfloat actually requires sse2Ralf Jung-1/+10
2024-12-31clean up target feature system; most of the toggleability is now handled by ↵Ralf Jung-431/+343
the ABI target feature check
2024-12-31explicitly model that certain ABIs require/forbid certain target featuresRalf Jung-113/+95
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-1/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-16Rollup merge of #134337 - RalfJung:riscv-target-features, r=workingjubileeMatthias Krüger-4/+71
reject unsound toggling of RISCV target features ~~Stacked on top of https://github.com/rust-lang/rust/pull/133417, only the last commit is new.~~ Works towards https://github.com/rust-lang/rust/issues/132618 (but more [remains to be done](https://github.com/rust-lang/rust/pull/134337#issuecomment-2544228958)) Part of https://github.com/rust-lang/rust/issues/116344 Cc ``@beetrees`` I hope I got everything. I didn't do anything about "The f and zfinx features are incompatible" and that's not an ABI thing (right?) and I am not sure how to handle it with these ABI checks. r? ``@workingjubilee`` Ideally we'd also reject target specs that disable the `f` feature but set an ABI that requires `f`... but I don't want to duplicate this logic. I have some ideas for how maybe the entire float ABI check logic should be different, now that we have some examples of what these ABI checks look like, but that will be a future PR.
2024-12-16tweak commentsRalf Jung-3/+7
2024-12-15reject unsound toggling of RISCV target featuresRalf Jung-3/+66
2024-12-15Auto merge of #134349 - jieyouxu:rollup-zqn0jox, r=jieyouxubors-1/+17
Rollup of 4 pull requests Successful merges: - #134111 (Fix `--nocapture` for run-make tests) - #134329 (Add m68k_target_feature) - #134331 (bootstrap: make ./x test error-index work) - #134339 (Pass `TyCtxt` to early diagostics decoration) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-15apply review feedbackRalf Jung-12/+12
2024-12-15Add m68k_target_featureTaiki Endo-1/+17
2024-12-14reject aarch64 target feature toggling that would change the float ABIRalf Jung-1/+23
2024-12-14target_features: control separately whether enabling and disabling a target ↵Ralf Jung-22/+55
feature is allowed
2024-12-13Auto merge of #133099 - RalfJung:forbidden-hardfloat-features, r=workingjubileebors-337/+441
forbid toggling x87 and fpregs on hard-float targets Part of https://github.com/rust-lang/rust/issues/116344, follow-up to https://github.com/rust-lang/rust/pull/129884: The `x87` target feature on x86 and the `fpregs` target feature on ARM must not be disabled on a hardfloat target, as that would change the float ABI. However, *enabling* `fpregs` on ARM is [explicitly requested](https://github.com/rust-lang/rust/issues/130988) as it seems to be useful. Therefore, we need to refine the distinction of "forbidden" target features and "allowed" target features: all (un)stable target features can determine on a per-target basis whether they should be allowed to be toggled or not. `fpregs` then checks whether the current target has the `soft-float` feature, and if yes, `fpregs` is permitted -- otherwise, it is not. (Same for `x87` on x86). Also fixes https://github.com/rust-lang/rust/issues/132351. Since `fpregs` and `x87` can be enabled on some builds and disabled on others, it would make sense that one can query it via `cfg`. Therefore, I made them behave in `cfg` like any other unstable target feature. The first commit prepares the infrastructure, but does not change behavior. The second commit then wires up `fpregs` and `x87` with that new infrastructure. r? `@workingjubilee`
2024-12-11apply review feedbackRalf Jung-12/+22
2024-12-11forbid toggling x87 and fpregs on hard-float targetsRalf Jung-2/+34
2024-12-11generalize 'forbidden feature' concept so that even (un)stable feature can ↵Ralf Jung-335/+397
be invalid to toggle Also rename some things for extra clarity
2024-12-11ABI checks: add support for loongarchWANG Rui-1/+3
LoongArch psABI[^1] specifies that LSX vector types are passed via general-purpose registers, while LASX vector types are passed indirectly through the stack. This patch addresses the following warnings: ``` warning: this function call uses a SIMD vector type that is not currently supported with the chosen ABI --> .../library/core/src/../../stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs:3695:5 | 3695 | __lsx_vreplgr2vr_b(a) | ^^^^^^^^^^^^^^^^^^^^^ function called here | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = note: `#[warn(abi_unsupported_vector_types)]` on by default ``` [^1]: https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc
2024-12-09Add the `power8-crypto` target featureSayantan Chakraborty-0/+1
2024-11-26Fix handling of x18 in AArch64 inline assembly on ohos/trusty or with ↵Taiki Endo-0/+6
-Zfixed-x18
2024-11-14ABI checks: add support for some tier3 arches, warn on others.Luca Versari-14/+23
2024-11-12ABI checks: add support for tier2 archesLuca Versari-3/+21
See #131800 for the data collection behind this change. Also adds a test that exercise the "empty list of features" path.
2024-11-11Auto merge of #132880 - RalfJung:implied-features, r=workingjubileebors-0/+5
target_features: explain what exacty 'implied' means here
2024-11-11target_features: explain what exacty 'implied' means hereRalf Jung-0/+5
2024-11-10Stabilize WebAssembly `multivalue`, `reference-types`, and `tail-call` ↵Alex Crichton-2/+3
target features For the `multivalue` and `reference-types` features this commit is similar to #117457 in that it's stabilizing target features specific to WebAssembly targets. The previous PR left out these two features because they weren't expected to change much about compiled code so it was unclear what the rationale was. It has [since been discovered][blog] that `reference-types` can be useful as it changes the binary format of the `call_indirect` instruction. Additionally [on Zulip][zulip] there's a use case of detecting these features at compile time and generating a compile error to better warn users about features not supported on engines. This PR then additionally adds the `tail-call` feature which corresponds to the [tail-call] proposal to WebAssembly. This feature advanced to "phase 4" in the WebAssembly CG awhile back and has been supported in LLVM for quite some time now. Engines are finishing up implementations or have already shipped implementations, so while this is a bit of a late addition to Rust itself it reflects the current status of WebAssembly's state of the feature. A test has been added here not only for these features but other WebAssembly features as well to showcase that they're usable without feature gates in stable Rust. [blog]: https://blog.rust-lang.org/2024/09/24/webassembly-targets-change-in-default-target-features.html [zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/wasm32.20reference-types.20.2F.20multivalue.20in.201.2E82-beta.20not.20enabled/near/473893987 [tail-call]: https://github.com/webassembly/tail-call
2024-11-10Auto merge of #132173 - veluca93:abi_checks, r=RalfJung,compiler-errorsbors-0/+17
Emit warning when calling/declaring functions with unavailable vectors. On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.) As discussed in rust-lang/lang-team#235, this turns out to very easily lead to unsound code. This commit makes it a post-monomorphization future-incompat warning to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI. See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187) for more discussion. Part of #116558 r? RalfJung
2024-11-09Add v8plus target feature to sparc and use it in create_object_fileTaiki Endo-0/+1
2024-11-09Add v9 and leoncasa target feature to sparcTaiki Endo-0/+9
2024-11-05Rollup merge of #132077 - alexcrichton:wide-arithmetic, r=jieyouxuMatthias Krüger-0/+1
Add a new `wide-arithmetic` feature for WebAssembly This commit adds a new rustc target feature named `wide-arithmetic` for WebAssembly targets. This corresponds to the [wide-arithmetic] proposal for WebAssembly which adds new instructions catered towards accelerating integer arithmetic larger than 64-bits. This proposal to WebAssembly is not standard yet so this new feature is flagged as an unstable target feature. Additionally Rust's LLVM version doesn't support this new feature yet since support will first be added in LLVM 20, so the feature filtering logic for LLVM is updated to handle this. I'll also note that I'm not currently planning to add wasm-specific intrinsics to `std::arch::wasm32` at this time. The currently proposed instructions are all accessible through `i128` or `u128`-based operations which Rust already supports, so intrinsic shouldn't be necessary to get access to these new instructions. [wide-arithmetic]: https://github.com/WebAssembly/wide-arithmetic
2024-11-04mark some target features as 'forbidden' so they cannot be (un)setRalf Jung-51/+91
For now, this is just a warning, but should become a hard error in the future
2024-11-01Emit warning when calling/declaring functions with unavailable vectors.Luca Versari-0/+17
On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.) As discussed in rust-lang/lang-team#235, this turns out to very easily lead to unsound code. This commit makes it a post-monomorphization future-incompat warning to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI. See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187) for more discussion. Part of #116558
2024-10-28Add a new `wide-arithmetic` feature for WebAssemblyAlex Crichton-0/+1
This commit adds a new rustc target feature named `wide-arithmetic` for WebAssembly targets. This corresponds to the [wide-arithmetic] proposal for WebAssembly which adds new instructions catered towards accelerating integer arithmetic larger than 64-bits. This proposal to WebAssembly is not standard yet so this new feature is flagged as an unstable target feature. Additionally Rust's LLVM version doesn't support this new feature yet since support will first be added in LLVM 20, so the feature filtering logic for LLVM is updated to handle this. I'll also note that I'm not currently planning to add wasm-specific intrinsics to `std::arch::wasm32` at this time. The currently proposed instructions are all accessible through `i128` or `u128`-based operations which Rust already supports, so intrinsic shouldn't be necessary to get access to these new instructions. [wide-arithmetic]: https://github.com/WebAssembly/wide-arithmetic
2024-10-27Auto merge of #131900 - mrkajetanp:target-feature-pauth-lr, r=Amanieubors-0/+2
rustc_target: Add pauth-lr aarch64 target feature Add the pauth-lr target feature, corresponding to aarch64 FEAT_PAuth_LR. This feature has been added in LLVM 19. It is currently not supported by the Linux hwcap and so we cannot add runtime feature detection for it at this time. r? `@Amanieu`
2024-10-26x86 target features: make pclmulqdq imply sse2Ralf Jung-1/+1
2024-10-25Revert "Emit error when calling/declaring functions with unavailable vectors."Rémy Rakic-17/+0
This reverts commit 5af56cac38fa48e4228e5e123d060e85eb1acbf7.
2024-10-25Emit error when calling/declaring functions with unavailable vectors.Luca Versari-0/+17
On some architectures, vector types may have a different ABI when relevant target features are enabled. As discussed in https://github.com/rust-lang/lang-team/issues/235, this turns out to very easily lead to unsound code. This commit makes it an error to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant.
2024-10-16rustc_target: Add pauth-lr aarch64 target featureKajetan Puchalski-0/+2
Add the pauth-lr target feature, corresponding to aarch64 FEAT_PAuth_LR. This feature has been added in LLVM 19. It is currently not supported by the Linux hwcap and so we cannot add runtime feature detection for it at this time.
2024-10-10rustc_target: Add sme-b16b16 as an explicit aarch64 target featureKajetan Puchalski-1/+3
LLVM 20 split out what used to be called b16b16 and correspond to aarch64 FEAT_SVE_B16B16 into sve-b16b16 and sme-b16b16. Add sme-b16b16 as an explicit feature and update the codegen accordingly.
2024-09-28rustc_target: Add RISC-V atomic-related featuresTaiki Endo-1/+4
2024-09-26rustc_target: Add powerpc64 atomic-related featuresTaiki Endo-0/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-11/+7
2024-08-27rustc_target: Remove fpmr target featureKajetan Puchalski-2/+0
FEAT_FPMR has been removed from upstream LLVM as of LLVM 19. Remove the feature from the target features list and temporarily hack the LLVM codegen to always enable it until the minimum LLVM version is bumped to 19.
2024-08-27rustc_target: Add SME aarch64 featuresKajetan Puchalski-0/+26
Add SME aarch64 features already supported by LLVM and Linux. This commit adds compiler support for the following features: - FEAT_SME - FEAT_SME_F16F16 - FEAT_SME_F64F64 - FEAT_SME_F8F16 - FEAT_SME_F8F32 - FEAT_SME_FA64 - FEAT_SME_I16I64 - FEAT_SME_LUTv2 - FEAT_SME2 - FEAT_SME2p1 - FEAT_SSVE_FP8DOT2 - FEAT_SSVE_FP8DOT4 - FEAT_SSVE_FP8FMA
2024-08-27rustc_target: Add various aarch64 featuresKajetan Puchalski-5/+49
Add various aarch64 features already supported by LLVM and Linux. The features are marked as unstable using a newly added symbol, i.e. aarch64_unstable_target_feature. Additionally include some comment fixes to ensure consistency of feature names with the Arm ARM and support for architecture version target features up to v9.5a. This commit adds compiler support for the following features: - FEAT_CSSC - FEAT_ECV - FEAT_FAMINMAX - FEAT_FLAGM2 - FEAT_FP8 - FEAT_FP8DOT2 - FEAT_FP8DOT4 - FEAT_FP8FMA - FEAT_FPMR - FEAT_HBC - FEAT_LSE128 - FEAT_LSE2 - FEAT_LUT - FEAT_MOPS - FEAT_LRCPC3 - FEAT_SVE_B16B16 - FEAT_SVE2p1 - FEAT_WFxT