about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src/intrinsics
AgeCommit message (Collapse)AuthorLines
2025-07-23atomicrmw on pointers: move integer-pointer cast hacks into backendRalf Jung-12/+12
2025-06-30Stop backends from needing to support nullary intrinsicsOli Scherer-15/+0
2025-06-29Rollup merge of #142078 - sayantn:more-intrinsics, r=workingjubileeGuillaume Gomez-1/+4
Add SIMD funnel shift and round-to-even intrinsics This PR adds 3 new SIMD intrinsics - `simd_funnel_shl` - funnel shift left - `simd_funnel_shr` - funnel shift right - `simd_round_ties_even` (vector version of `round_ties_even_fN`) TODO (future PR): implement `simd_fsh{l,r}` in miri, cg_gcc and cg_clif (it is surprisingly hard to implement without branches, the common tricks that rotate uses doesn't work because we have 2 elements now. e.g, the `-n&31` trick used by cg_gcc to implement rotate doesn't work with this because then `fshl(a, b, 0)` will be `a | b`) [#t-compiler > More SIMD intrinsics](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/More.20SIMD.20intrinsics/with/522130286) `@rustbot` label T-compiler T-libs A-intrinsics F-core_intrinsics r? `@workingjubilee`
2025-06-24Merge commit '8c848e0604b5d26fad120914f822f564fe05c52a' into ↵bjorn3-6/+8
sync_cg_clif-2025-06-24
2025-06-15Implement `simd_round_ties_even` for miri, cg_clif and cg_gccsayantn-1/+4
2025-06-12intrinsics: rename min_align_of to align_ofRalf Jung-2/+2
2025-06-08Remove rustc's notion of "preferred" alignment AKA `__alignof`Jubilee Young-5/+1
In PR 90877 T-lang decided not to remove `intrinsics::pref_align_of`. However, the intrinsic and its supporting code 1. is a nightly feature, so can be removed at compiler/libs discretion 2. requires considerable effort in the compiler to support, as it necessarily complicates every single site reasoning about alignment 3. has been justified based on relevance to codegen, but it is only a requirement for C++ (not C, not Rust) stack frame layout for AIX, in ways Rust would not consider even with increased C++ interop 4. is only used by rustc to overalign some globals, not correctness 5. can be adequately replaced by other rules for globals, as it mostly affects alignments for a few types under 16 bytes of alignment 6. has only one clear benefactor: automating C -> Rust translation for GNU extensions like `__alignof` 7. such code was likely intended to be `alignof` or `_Alignof`, because the GNU extension is a "false friend" of the C keyword, which makes the choice to support such a mapping very questionable 8. makes it easy to do incorrect codegen in the compiler by its mere presence as usual Rust rules of alignment (e.g. `size == align * N`) do not hold with preferred alignment The implementation is clearly damaging the code quality of the compiler. Thus it is within the compiler team's purview to simply rip it out. If T-lang wishes to have this intrinsic restored for c2rust's benefit, it would have to use a radically different implementation that somehow does not cause internal incorrectness. Until then, remove the intrinsic and its supporting code, as one tool and an ill-considered GCC extension cannot justify risking correctness. Because we touch a fair amount of the compiler to change this at all, and unfortunately the duplication of AbiAndPrefAlign is deep-rooted, we keep an "AbiAlign" type which we can wean code off later.
2025-06-07intrinsics: use const generic to set atomic orderingRalf Jung-15/+13
2025-06-07Auto merge of #141964 - sayantn:update-stdarch, r=Amanieubors-8/+8
Update stdarch submodule Updates the stdarch submodule. ## Merged PRs - rust-lang/stdarch#1797 - rust-lang/stdarch#1758 - rust-lang/stdarch#1798 - rust-lang/stdarch#1811 - rust-lang/stdarch#1810 - rust-lang/stdarch#1807 - rust-lang/stdarch#1806 - rust-lang/stdarch#1812 - rust-lang/stdarch#1795 - rust-lang/stdarch#1796 - rust-lang/stdarch#1813 - rust-lang/stdarch#1816 - rust-lang/stdarch#1818 - rust-lang/stdarch#1820 - rust-lang/stdarch#1819 r? `@Amanieu` `@rustbot` label T-libs-api Closes rust-lang/rust#111137
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-6/+6
2025-06-03Add impl for `llvm.roundeven` in cg_clifsayantn-8/+8
- remove unused `llvm.aarch64.neon.frintn` from cg_clif
2025-05-28atomic_load intrinsic: use const generic parameter for orderingRalf Jung-1/+2
2025-05-25Merge commit '979dcf8e2f213e4f4b645cb62e7fe9f4f2c0c785' into ↵bjorn3-15/+231
sync_cg_clif-2025-05-25
2025-05-09Use intrinsics for `{f16,f32,f64,f128}::{minimum,maximum}` operationsUrgau-0/+37
2025-05-05Rename Instance::new to Instance::new_raw and add a note that it is rawMichael Goulet-1/+1
2025-04-06update docsBennet Bleßmann-2/+1
- src\doc\nomicon\src\ffi.md should also have its ABI list updated
2025-03-30Merge commit 'ba315abda789c9f59f2100102232bddb30b0d3d3' into ↵bjorn3-2/+129
sync_cg_clif-2025-03-30
2025-03-13atomic intrinsics: clarify which types are supported and (if applicable) ↵Ralf Jung-4/+4
what happens with provenance
2025-02-28rename BackendRepr::Vector → SimdVectorRalf Jung-1/+1
2025-02-25Rollup merge of #137595 - folkertdev:remove-simd-pow-powi, r=RalfJungLeón Orell Valerian Liehr-58/+0
remove `simd_fpow` and `simd_fpowi` Discussed in https://github.com/rust-lang/rust/issues/137555 These functions are not exposed from `std::intrinsics::simd`, and not used anywhere outside of the compiler. They also don't lower to particularly good code at least on the major ISAs (I checked x86_64, aarch64, s390x, powerpc), where the vector is just spilled to the stack and scalar functions are used for the actual logic. r? `@RalfJung`
2025-02-25remove `simd_fpow` and `simd_fpowi`Folkert de Vries-58/+0
2025-02-24rename simd_shuffle_generic → simd_shuffle_const_genericRalf Jung-2/+2
2025-02-23Rollup merge of #136543 - RalfJung:round-ties-even, r=tgross35Trevor Gross-9/+7
intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic LLVM has three intrinsics here that all do the same thing (when used in the default FP environment). There's no reason Rust needs to copy that historically-grown mess -- let's just have one intrinsic and leave it up to the LLVM backend to decide how to lower that. Suggested by `@hanna-kruppe` in https://github.com/rust-lang/rust/issues/136459; Cc `@tgross35` try-job: test-various
2025-02-08Rustfmtbjorn3-3/+6
2025-02-07Merge commit '8332329f83d4ef34479fec67cc21b21246dca6b5' into ↵bjorn3-0/+24
sync_cg_clif-2025-02-07
2025-02-04intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even ↵Ralf Jung-9/+7
intrinsic
2025-01-30introduce `ty::Value`Lukas Markeffsky-6/+1
Co-authored-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
2025-01-20Updated several files to use rust intrinsic macros instead of the legacy ↵vayunbiyani-0/+1
extern "rust-intrinsic" blocks
2025-01-05Merge commit '918acafef682d0d0ca30b47de4768210417ff362' into ↵bjorn3-1/+1
sync_cg_clif-2025-01-05
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-06Merge commit '57845a397ec15e4e6a561ed2c4bfa3dcf49144fb' into ↵bjorn3-2/+1
sync_cg_clif-2024-12-06
2024-11-23Add simd_relaxed_fma intrinsicCaleb Zulawski-1/+2
2024-11-19`InterpCx` store `TypingEnv` instead of a `ParamEnv`lcnr-1/+5
2024-11-18Auto merge of #132460 - lcnr:questionable-uwu, r=compiler-errorsbors-3/+6
Use `TypingMode` throughout the compiler instead of `ParamEnv` Hopefully the biggest single PR as part of https://github.com/rust-lang/types-team/issues/128. ## `infcx.typing_env` while defining opaque types I don't know how'll be able to correctly handle opaque types when using something taking a `TypingEnv` while defining opaque types. To correctly handle the opaques we need to be able to pass in the current `opaque_type_storage` and return constraints, i.e. we need to use a proper canonical query. We should migrate all the queries used during HIR typeck and borrowck where this matters to proper canonical queries. This is ## `layout_of` and `Reveal::All` We convert the `ParamEnv` to `Reveal::All` right at the start of the `layout_of` query, so I've changed callers of `layout_of` to already use a post analysis `TypingEnv` when encountering it. https://github.com/rust-lang/rust/blob/ca87b535a05097df6abbe2a031b057de2cefac5b/compiler/rustc_ty_utils/src/layout.rs#L51 ## `Ty::is_[unpin|sized|whatever]` I haven't migrated `fn is_item_raw` to use `TypingEnv`, will do so in a followup PR, this should significantly reduce the amount of `typing_env.param_env`. At some point there will probably be zero such uses as using the type system while ignoring the `typing_mode` is incorrect. ## `MirPhase` and phase-transitions When inside of a MIR-body, we can mostly use its `MirPhase` to figure out the right `typing_mode`. This does not work during phase transitions, most notably when transitioning from `Analysis` to `Runtime`: https://github.com/rust-lang/rust/blob/dae7ac133b9eda152784c075facb31a6688c92b1/compiler/rustc_mir_transform/src/lib.rs#L606-L625 All these passes still run with `MirPhase::Analysis`, but we should only use `Reveal::All` once we're run the `RevealAll` pass. This required me to manually construct the right `TypingEnv` in all these passes. Given that it feels somewhat easy to accidentally miss this going forward, I would maybe like to change `Body::phase` to an `Option` and replace it at the start of phase transitions. This then makes it clear that the MIR is currently in a weird state. r? `@ghost`
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-3/+6
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-18remove pointless cold_path impl in interpreterRalf Jung-0/+1
2024-11-17Likely unlikely fixJiri Bobek-5/+4
2024-11-09Merge commit '1fa693ca4462fc1f790693464cf765ad693616af' into ↵bjorn3-1/+1
sync_cg_clif-2024-11-09
2024-11-07 remove 'platform-intrinsic' ABI leftoversRalf Jung-2/+2
2024-11-02Merge commit '5b1246bb4bed72fd0bb8fa497d8e5ed2c7f3515c' into ↵bjorn3-5/+6
sync_cg_clif-2024-11-02
2024-10-29cg_clif: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-5/+5
2024-10-19Fix testsMichael Goulet-4/+9
2024-10-11intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semanticsJed Brown-1/+4
Add intrinsics `fmuladd{f16,f32,f64,f128}`. This computes `(a * b) + c`, to be fused if the code generator determines that (i) the target instruction set has support for a fused operation, and (ii) that the fused operation is more efficient than the equivalent, separate pair of `mul` and `add` instructions. https://llvm.org/docs/LangRef.html#llvm-fmuladd-intrinsic MIRI support is included for f32 and f64. The codegen_cranelift uses the `fma` function from libc, which is a correct implementation, but without the desired performance semantic. I think this requires an update to cranelift to expose a suitable instruction in its IR. I have not tested with codegen_gcc, but it should behave the same way (using `fma` from libc).
2024-09-23Rustfmtbjorn3-6/+3
2024-09-23Merge commit '6d35b4c9a04580366fd800692a5b5db79d766530' into ↵bjorn3-27/+57
sync_cg_clif-2024-09-22
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-9/+6
2024-09-20Do not unnecessarily eval consts in codegenMichael Goulet-3/+2
2024-09-14simd_shuffle: require index argument to be a vectorRalf Jung-27/+13
2024-08-13simd_shuffle intrinsic: allow argument to be passed as vector (not just as ↵Ralf Jung-0/+10
array)
2024-08-12Rollup merge of #128149 - RalfJung:nontemporal_store, r=jieyouxu,Amanieu,JubileeGuillaume Gomez-1/+2
nontemporal_store: make sure that the intrinsic is truly just a hint The `!nontemporal` flag for stores in LLVM *sounds* like it is just a hint, but actually, it is not -- at least on x86, non-temporal stores need very special treatment by the programmer or else the Rust memory model breaks down. LLVM still treats these stores as-if they were normal stores for optimizations, which is [highly dubious](https://github.com/llvm/llvm-project/issues/64521). Let's avoid all that dubiousness by making our own non-temporal stores be truly just a hint, which is possible on some targets (e.g. ARM). On all other targets, non-temporal stores become regular stores. ~~Blocked on https://github.com/rust-lang/stdarch/pull/1541 propagating to the rustc repo, to make sure the `_mm_stream` intrinsics are unaffected by this change.~~ Fixes https://github.com/rust-lang/rust/issues/114582 Cc `@Amanieu` `@workingjubilee`