summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/intrinsic.rs
AgeCommit message (Collapse)AuthorLines
2024-10-11intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semanticsJed Brown-0/+5
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-10-04Use wide pointers consistenly across the compilerUrgau-2/+2
2024-09-24Auto merge of #130389 - Luv-Ray:LLVMMDNodeInContext2, r=nikicbors-3/+5
llvm: replace some deprecated functions `LLVMMDStringInContext` and `LLVMMDNodeInContext` are deprecated, replace them with `LLVMMDStringInContext2` and `LLVMMDNodeInContext2`. Also replace `Value` with `Metadata` in some function signatures for better consistency.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-213/+207
2024-09-19Reformat some comments.Nicholas Nethercote-4/+6
So they are less than 100 chars.
2024-09-19replace some deprecated functionsLuv-Ray-3/+5
2024-09-18Rollup merge of #130457 - nnethercote:cleanup-codegen-traits, r=bjorn3Matthias Krüger-1/+1
Cleanup codegen traits The traits governing codegen are quite complicated and hard to follow. This PR cleans them up a bit. r? `@bjorn3`
2024-09-17Rename `{ArgAbi,IntrinsicCall}Methods`.Nicholas Nethercote-1/+1
They both are part of `BuilderMethods`, and so should have `Builder` in their name like all the other traits in `BuilderMethods`.
2024-09-15Rollup merge of #130325 - workingjubilee:plus-minus-zero-redux, ↵Jubilee-2/+2
r=RalfJung,jieyouxu Use -0.0 in `intrinsics::simd::reduce_add_unordered` -0.0 is the actual neutral additive float, not +0.0, and this matters to codegen. try-job: aarch64-gnu
2024-09-15Use -0.0 in `intrinsics::simd::reduce_add_unordered`Jubilee Young-2/+2
-0.0 is the actual neutral additive float, not +0.0, and this matters to codegen.
2024-09-14simd_shuffle: require index argument to be a vectorRalf Jung-52/+28
2024-09-04Don't codegen `expect` in opt-level=0clubby789-7/+10
2024-08-27Rollup merge of #128731 - RalfJung:simd-shuffle-vector, r=workingjubileeTrevor Gross-7/+12
simd_shuffle intrinsic: allow argument to be passed as vector See https://github.com/rust-lang/rust/issues/128738 for context. I'd like to get rid of [this hack](https://github.com/rust-lang/rust/blob/6c0b89dfac65be9a5be12f938f23098ebc36c635/compiler/rustc_codegen_ssa/src/mir/block.rs#L922-L935). https://github.com/rust-lang/rust/pull/128537 almost lets us do that since constant SIMD vectors will then be passed as immediate arguments. However, simd_shuffle for some reason actually takes an *array* as argument, not a vector, so the hack is still required to ensure that the array becomes an immediate (which then later stages of codegen convert into a vector, as that's what LLVM needs). This PR prepares simd_shuffle to also support a vector as the `idx` argument. Once this lands, stdarch can hopefully be updated to pass `idx` as a vector, and then support for arrays can be removed, which finally lets us get rid of that hack.
2024-08-17Fix `is_val_statically_known` for floatsbeetrees-7/+15
2024-08-13simd_shuffle intrinsic: allow argument to be passed as vector (not just as ↵Ralf Jung-7/+12
array)
2024-08-11Use assert_matches around the compilerMichael Goulet-1/+2
2024-08-01Specify the integer type of the `powi` LLVM intrinsicTrevor Gross-4/+4
Since LLVM <https://reviews.llvm.org/D99439> (4c7f820b2b20, "Update @llvm.powi to handle different int sizes for the exponent"), the size of the integer can be specified for the `powi` intrinsic. Make use of this so it is more obvious that integer size is consistent across all float types. This feature is available since LLVM 13 (October 2021). Based on bootstrap we currently support >= 17.0, so there should be no support problems.
2024-07-30Auto merge of #128250 - Amanieu:select_unpredictable, r=nikicbors-1/+30
Add `select_unpredictable` to force LLVM to use CMOV Since https://reviews.llvm.org/D118118, LLVM will no longer turn CMOVs into branches if it comes from a `select` marked with an `unpredictable` metadata attribute. This PR introduces `core::intrinsics::select_unpredictable` which emits such a `select` and uses it in the implementation of `binary_search_by`.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-9/+9
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28Force LLVM to use CMOV for binary searchAmanieu d'Antras-1/+30
Since https://reviews.llvm.org/D118118, LLVM will no longer turn CMOVs into branches if it comes from a `select` marked with an `unpredictable` metadata attribute. This PR introduces `core::intrinsics::select_unpredictable` which emits such a `select` and uses it in the implementation of `binary_search_by`.
2024-07-08Add `f16` and `f128` as SIMD types in LLVMTrevor Gross-0/+2
2024-07-01fix simd_bitmask return type for non-power-of-two inputs, and add testsRalf Jung-8/+8
2024-06-10Rollup merge of #126159 - RalfJung:scalarint-size-mismatch, r=oli-obkMatthias Krüger-1/+1
ScalarInt: size mismatches are a bug, do not delay the panic Cc [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Why.20are.20ScalarInt.20to.20iN.2FuN.20methods.20fallible.3F) r? ``@oli-obk``
2024-06-10ScalarInt: size mismatches are a bug, do not delay the panicRalf Jung-1/+1
2024-06-08simd packed types: update outdated check, extend codegen testRalf Jung-4/+6
2024-06-05Add `Ty` to `ConstKind::Value`Boxy-0/+1
2024-06-02Rollup merge of #125311 - calebzulawski:repr-packed-simd-intrinsics, ↵Jubilee-1/+53
r=workingjubilee Make repr(packed) vectors work with SIMD intrinsics In #117116 I fixed `#[repr(packed, simd)]` by doing the expected thing and removing padding from the layout. This should be the last step in providing a solution to rust-lang/portable-simd#319
2024-06-01Improve documentationCaleb Zulawski-1/+6
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_codegen_llvm`.Nicholas Nethercote-0/+1
2024-05-22Stop using `to_hir_binop` in codegenScott McMurray-6/+7
2024-05-20Make repr(packed) vectors work with SIMD intrinsicsCaleb Zulawski-1/+48
2024-05-19clarify the second arg to llvm.ctlz and cttzJubilee Young-3/+3
2024-05-18compiler: add simd_ctpop intrinsicJubilee Young-19/+29
2024-05-17Rename Unsafe to SafetySantiago Pastorino-3/+3
2024-05-10Rollup merge of #124957 - compiler-errors:builtin-deref, r=michaelwoeristerMatthias Krüger-1/+1
Make `Ty::builtin_deref` just return a `Ty` Nowhere in the compiler are we using the mutability part of the `TyAndMut` that we used to return.
2024-05-09Make builtin_deref just return a TyMichael Goulet-1/+1
2024-05-06Refactor float `Primitive`s to a separate `Float` typebeetrees-5/+9
2024-05-02Inline & delete `Ty::new_unit`, since it's just a field accessWaffle Lapkin-2/+2
2024-04-24Auto merge of #122053 - erikdesjardins:alloca, r=nikicbors-10/+10
Stop using LLVM struct types for alloca The alloca type has no semantic meaning, only the size (and alignment, but we specify it explicitly) matter. Using `[N x i8]` is a more direct way to specify that we want `N` bytes, and avoids relying on LLVM's struct layout. It is likely that a future LLVM version will change to an untyped alloca representation. Split out from #121577. r? `@ghost`
2024-04-16Change intrinsic types to use `u32` instead of `T` to match stable reexportsMaybe Waffle-8/+19
2024-04-11use [N x i8] for alloca typesErik Desjardins-10/+10
2024-04-11Add load/store helpers that take `PlaceValue`Scott McMurray-1/+1
2024-04-11Make `PlaceRef` hold a `PlaceValue` for the non-layout fields (like ↵Scott McMurray-4/+4
`OperandRef` does)
2024-04-03rename `expose_addr` to `expose_provenance`joboet-1/+1
2024-04-02Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=AmanieuJacob Pratt-1/+1
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066). The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".) The new name nicely matches `ptr::without_provenance`.
2024-03-23also rename the SIMD intrinsicRalf Jung-1/+1
2024-03-23CFI: Use Instance at callsitesMatthew Maurer-16/+23
We already use `Instance` at declaration sites when available to glean additional information about possible abstractions of the type in use. This does the same when possible at callsites as well. The primary purpose of this change is to allow CFI to alter how it generates type information for indirect calls through `Virtual` instances.
2024-03-22Make RawPtr take Ty and Mutbl separatelyMichael Goulet-13/+13
2024-03-22Programmatically convert some of the pat ctorsMichael Goulet-4/+4
2024-03-18Avoid various uses of `Option<Span>` in favor of using `DUMMY_SP` in the few ↵Oli Scherer-1/+1
cases that used `None`