about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/intrinsic.rs
AgeCommit message (Collapse)AuthorLines
2024-02-12Teach llvm backend how to fall back to default bodiesOli Scherer-9/+14
2024-02-05old solver: improve normalization of `Pointee::Metadata`Lukas Markeffsky-4/+2
2024-01-29Avoid ICE when is_val_statically_known is not of a supported typeAlex Huang-4/+12
2024-01-19Add new intrinsic `is_constant` and optimize `pow`Catherine Flores-0/+4
Fix overflow check Make MIRI choose the path randomly and rename the intrinsic Add back test Add miri test and make it operate on `ptr` Define `llvm.is.constant` for primitives Update MIRI comment and fix test in stage2 Add const eval test Clarify that both branches must have the same side effects guaranteed non guarantee use immediate type instead Co-Authored-By: Ralf Jung <post@ralfj.de>
2024-01-05Auto merge of #118991 - nikic:scalar-pair, r=nagisabors-1/+4
Separate immediate and in-memory ScalarPair representation Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirements. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-15/+19
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-15Separate immediate and in-memory ScalarPair representationNikita Popov-1/+4
Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirement. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.
2023-12-12Fix alignment passed down to LLVM for simd_masked_loadJakub Okoński-1/+1
2023-12-11Auto merge of #117116 - calebzulawski:repr-simd-packed, r=workingjubileebors-1/+8
Implement repr(packed) for repr(simd) This allows creating vectors with non-power-of-2 lengths that do not have padding. See rust-lang/portable-simd#319
2023-12-09Add simd_masked_{load,store} platform-intrinsicsJakub Okoński-0/+192
This maps to the LLVM intrinsics: llvm.masked.load and llvm.masked.store
2023-12-02Implement repr(packed) for repr(simd)Caleb Zulawski-1/+8
2023-10-31Merge simd size and type extraction into checking whether a type is simd, as ↵Oli Scherer-48/+26
these always go together.
2023-10-31Simplify all `require_simd` invocations by moving all of the shared ↵Oli Scherer-37/+19
invocation arguments into the macro
2023-10-31don't use the moral equivalent of `assert!(false, "foo")`Oli Scherer-33/+22
2023-09-18Prototype using const generic for simd_shuffle IDX arrayOli Scherer-2/+55
2023-09-15explain PassMode::CastRalf Jung-2/+2
2023-08-06Apply suggestions from code reviewscottmcm-0/+1
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-08-06Add a new `compare_bytes` intrinsic instead of calling `memcmp` directlyScott McMurray-0/+9
2023-08-03Forbid old-style `simd_shuffleN` intrinsicsOli Scherer-21/+13
2023-08-01Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3bors-152/+75
cleanup: remove pointee types This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after #114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.) I initially hoped this would provide some minor perf win, but in https://github.com/rust-lang/rust/pull/105412#issuecomment-1341224450 it had very little impact, so this is only valuable as a cleanup. As a followup, this will enable #96242 to be resolved. r? `@ghost` `@rustbot` label S-blocked
2023-07-31Auto merge of #114266 - calebzulawski:simd-bswap, r=compiler-errorsbors-11/+10
Fix simd_bswap for i8/u8 #114156 missed this test case ☹️ cc `@workingjubilee`
2023-07-30Fix simd_bswap for i8/u8Caleb Zulawski-11/+10
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-9/+9
2023-07-29cg_llvm: simplify llvm.masked.gather/scatter naming with opaque pointersErik Desjardins-105/+47
With opaque pointers, there's no longer a need to generate a chain of pointer types in the intrinsic name when arguments are pointers to pointers.
2023-07-29cg_llvm: remove pointee types and pointercast/bitcast-of-ptrErik Desjardins-50/+31
2023-07-28Use i1 instead of boolCaleb Zulawski-2/+9
2023-07-27Add SIMD bitreverse, ctlz, cttz intrinsicsCaleb Zulawski-7/+25
2023-07-27Add simd_bswap intrinsicCaleb Zulawski-0/+22
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-3/+3
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-15/+21
2023-06-07fix comment (review change)Jan-Mirko Otter-1/+1
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2023-06-07wasm exception handlingJan-Mirko Otter-1/+77
2023-05-09CFI: Fix SIGILL reached via trait objectsRamon de C Valle-1/+1
Fix #106547 by transforming the concrete self into a reference to a trait object before emitting type metadata identifiers for trait methods.
2023-05-03Add cross-language LLVM CFI support to the Rust compilerRamon de C Valle-12/+16
This commit adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395). It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653. Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto).
2023-03-22Add `CastKind::Transmute` to MIRScott McMurray-1/+1
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-07Auto merge of #95317 - Jules-Bertholet:round_ties_to_even, ↵bors-0/+2
r=pnkfelix,m-ou-se,scottmcm Add `round_ties_even` to `f32` and `f64` Tracking issue: #96710 Redux of #82273. See also #55107 Adds a new method, `round_ties_even`, to `f32` and `f64`, that rounds the float to the nearest integer , rounding halfway cases to the number with an even least significant bit. Uses the `roundeven` LLVM intrinsic to do this. Of the five IEEE 754 rounding modes, this is the only one that doesn't already have a round-to-integer function exposed by Rust (others are `round`, `floor`, `ceil`, and `trunc`). Ties-to-even is also the rounding mode used for int-to-float and float-to-float `as` casts, as well as float arithmentic operations. So not having an explicit rounding method for it seems like an oversight. Bikeshed: this PR currently uses `round_ties_even` for the name of the method. But maybe `round_ties_to_even` is better, or `round_even`, or `round_to_even`?
2023-02-17Use `IntoIterator` for `mk_fn_sig`.Nicholas Nethercote-4/+3
This makes a lot of call sites nicer.
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-5/+5
2023-01-22abi: add `AddressSpace` field to `Primitive::Pointer`Erik Desjardins-1/+1
...and remove it from `PointeeInfo`, which isn't meant for this. There are still various places (marked with FIXMEs) that assume all pointers have the same size and alignment. Fixing this requires parsing non-default address spaces in the data layout string, which will be done in a followup.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-2/+2
2022-12-27DELETE - fn span_invalid_monomorphization_error and localize intrinsics macrosJhonny Bill Mena-247/+282
2022-12-27UPDATE - migrate fn simd_simple_float_intrinsic error messagesJhonny Bill Mena-28/+13
2022-12-27[WIP] UPDATE - migrate intrinsic.rs to new diagnostic infrastructureJhonny Bill Mena-8/+5
WIP - replacing span_invalid_monomorphization_error function. Still in progress due to its use in codegen_llvm inside macros
2022-12-22Allow building std with craneliftJoshua Nelson-1/+1
- Don't pass llvm-specific args when using cranelift - Don't use `asm` in compiler_builtins when using cranelift
2022-12-11Add `round_ties_even` to `f32` and `f64`Jules Bertholet-0/+2
2022-12-03Directly return loaded value from type_checked_loadbjorn3-1/+3
2022-11-23Add `Mutability::{is_mut,is_not}`Maybe Waffle-1/+1
2022-11-08prevent uninitialized access in black_box for zero-sized-typesKrasimir Georgiev-3/+12
2022-10-01Merge apply_attrs_callsite into call and invokebjorn3-18/+34
Some codegen backends are not able to apply callsite attrs after the fact.
2022-09-17Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obkDylan DPC-0/+91
Implement simd_as for pointers Expands `simd_as` (and `simd_cast`) to handle pointer-to-pointer, pointer-to-integer, and integer-to-pointer conversions. cc ``@programmerjake`` ``@thomcc``