about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/intrinsic.rs
AgeCommit message (Collapse)AuthorLines
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`
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-0/+2
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-01Add `f16` and `f128` LLVM intrinsicsTrevor Gross-0/+67
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-0/+4
Make changes necessary to support these types in the compiler.
2024-02-27Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obkMatthias Krüger-4/+4
rename 'try' intrinsic to 'catch_unwind' The intrinsic has nothing to do with `try` blocks, and corresponds to the stable `catch_unwind` function, so this makes a lot more sense IMO. Also rename Miri's special function while we are at it, to reflect the level of abstraction it works on: it's an unwinding mechanism, on which Rust implements panics.
2024-02-26rename 'try' intrinsic to 'catch_unwind'Ralf Jung-4/+4
2024-02-25Rollup merge of #121060 - clubby789:bool-newtypes, r=cjgillotMatthias Krüger-24/+31
Add newtypes for bool fields/params/return types Fixed all the cases of this found with some simple searches for `*/ bool` and `bool /*`; probably many more
2024-02-24Implement asm goto for LLVM and GCC backendGary Guo-0/+2
2024-02-23check that simd_insert/extract indices are in-boundsRalf Jung-19/+34
2024-02-21remove simd_reduce_{min,max}_nanlessRalf Jung-3/+0
2024-02-21make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all ↵Ralf Jung-2/+2
fast-math flags
2024-02-20Add "algebraic" versions of the fast-math intrinsicsBen Kimock-2/+2
2024-02-20Add newtype for signedness in LLVM SIMDclubby789-24/+31
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