Commit Graph

2531 Commits

Author SHA1 Message Date
Ralf Jung
ba6a38495f remove 'platform-intrinsic' ABI leftovers 2024-11-07 17:42:49 +01:00
bors
12677fd3d0 Auto merge of #132526 - bjorn3:sync_cg_clif-2024-11-02, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The highlight this time is an update to Cranelift 0.113,

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-11-03 05:03:52 +00:00
Noratrieb
541c33ec41 Rename target triple to target tuple in many places in the compiler
This changes the naming to the new naming, used by `--print
target-tuple`.
It does not change all locations, but many.
2024-11-02 21:29:59 +01:00
bjorn3
e2a5108657 Merge commit '5b1246bb4bed72fd0bb8fa497d8e5ed2c7f3515c' into sync_cg_clif-2024-11-02 2024-11-02 14:53:30 +00:00
Mads Marquart
322d392d90 Move versioned LLVM target creation to rustc_codegen_ssa
The OS version depends on the deployment target environment variables,
the access of which we want to move to later in the compilation pipeline
that has access to more information, for example `env_depinfo`.
2024-11-01 17:07:18 +01:00
Jubilee Young
e3c154705c cg_clif: rustc_abi::Abi => BackendRepr 2024-10-29 15:01:01 -07:00
Jubilee Young
988f49d04f cg_clif: Rename LayoutS to LayoutData 2024-10-27 22:32:40 -07:00
Matthias Krüger
a29a8f523e Rollup merge of #132168 - fee1-dead-contrib:fxclean, r=compiler-errors
Effects cleanup

- removed extra bits from predicates queries that are no longer needed in the new system
- removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers

r? compiler-errors
2024-10-26 06:29:48 +02:00
Deadbeef
83f1121ebd Effects cleanup
- removed extra bits from predicates queries that are no longer needed in the new system
- removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
2024-10-26 10:19:07 +08:00
Ralf Jung
6ca276df2e Re-do recursive const stability checks
Fundamentally, we have *three* disjoint categories of functions:
1. const-stable functions
2. private/unstable functions that are meant to be callable from const-stable functions
3. functions that can make use of unstable const features

This PR implements the following system:
- `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions.
- `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category.
- `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls.

Also, several holes in recursive const stability checking are being closed.
There's still one potential hole that is hard to avoid, which is when MIR
building automatically inserts calls to a particular function in stable
functions -- which happens in the panic machinery. Those need to *not* be
`rustc_const_unstable` (or manually get a `rustc_const_stable_indirect`) to be
sure they follow recursive const stability. But that's a fairly rare and special
case so IMO it's fine.

The net effect of this is that a `#[unstable]` or unmarked function can be
constified simply by marking it as `const fn`, and it will then be
const-callable from stable `const fn` and subject to recursive const stability
requirements. If it is publicly reachable (which implies it cannot be unmarked),
it will be const-unstable under the same feature gate. Only if the function ever
becomes `#[stable]` does it need a `#[rustc_const_unstable]` or
`#[rustc_const_stable]` marker to decide if this should also imply
const-stability.

Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to
use unstable const lang features (including intrinsics), or (b) `#[stable]`
functions that are not yet intended to be const-stable. Adding
`#[rustc_const_stable]` is only needed for functions that are actually meant to
be directly callable from stable const code. `#[rustc_const_stable_indirect]` is
used to mark intrinsics as const-callable and for `#[rustc_const_unstable]`
functions that are actually called from other, exposed-on-stable `const fn`. No
other attributes are required.
2024-10-25 20:31:40 +02:00
Adrian Taylor
c5a5e86baa Rename Receiver -> LegacyReceiver
As part of the "arbitrary self types v2" project, we are going to
replace the current `Receiver` trait with a new mechanism based on a
new, different `Receiver` trait.

This PR renames the old trait to get it out the way. Naming is hard.
Options considered included:
* HardCodedReceiver (because it should only be used for things in the
  standard library, and hence is sort-of hard coded)
* LegacyReceiver
* TargetLessReceiver
* OldReceiver

These are all bad names, but fortunately this will be temporary.
Assuming the new mechanism proceeds to stabilization as intended, the
legacy trait will be removed altogether.

Although we expect this trait to be used only in the standard library,
we suspect it may be in use elsehwere, so we're landing this change
separately to identify any surprising breakages.

It's known that this trait is used within the Rust for Linux project; a
patch is in progress to remove their dependency.

This is a part of the arbitrary self types v2 project,
https://github.com/rust-lang/rfcs/pull/3519
https://github.com/rust-lang/rust/issues/44874

r? @wesleywiser
2024-10-22 12:55:16 +00:00
Michael Goulet
65201c20a6 Fix tests 2024-10-19 18:07:35 +00:00
Michael Goulet
2f1b15f145 Allow dropping dyn principal 2024-10-17 20:43:31 +02:00
Jed Brown
270fb2130c intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semantics
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-11 15:32:56 -06:00
Jubilee Young
48504415cf cg_clif: Factor out rustc_target::abi 2024-10-08 18:24:56 -07:00
Folkert de Vries
2811ce715d various fixes for naked_asm! implementation
- fix for divergence
- fix error message
- fix another cranelift test
- fix some cranelift things
- don't set the NORETURN option for naked asm
- fix use of naked_asm! in doc comment
- fix use of naked_asm! in run-make test
- use `span_bug` in unreachable branch
2024-10-06 19:00:09 +02:00
Urgau
0bd0b99729 Use wide pointers consistenly across the compiler 2024-10-04 14:06:48 +02:00
Michael Goulet
d10a16ae40 Relax a debug assertion in codegen 2024-09-30 12:18:02 -04:00
Ralf Jung
9b31c68c0e fix cranelift CI 2024-09-29 07:32:08 +02:00
Michael Goulet
6fdc133daa Add a debug assertion in codegen that unsize casts of the same principal trait def id are truly NOPs 2024-09-25 11:13:59 -04:00
Lukas Markeffsky
25b66d8091 be even more precise about "cast" vs "coercion" 2024-09-24 23:12:02 +02:00
Lukas Markeffsky
1efad22339 unify dyn* coercions with other pointer coercions 2024-09-24 22:17:55 +02:00
Michael Goulet
631ab21ff0 Check vtable projections for validity in miri 2024-09-23 19:38:26 -04:00
bjorn3
9d8572d33b Rustfmt 2024-09-23 11:28:15 +00:00
bjorn3
f3ae4237ab Revert change to apply_patches to fix panic 2024-09-23 11:20:56 +00:00
bjorn3
32b608a439 Merge commit '6d35b4c9a04580366fd800692a5b5db79d766530' into sync_cg_clif-2024-09-22 2024-09-23 11:20:46 +00:00
Michael Goulet
02b0f3b5ab Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Folkert de Vries
90300ef40b add C-cmse-nonsecure-entry ABI 2024-09-21 13:04:14 +02:00
Michael Goulet
460abead20 Do not unnecessarily eval consts in codegen 2024-09-20 20:38:11 -04:00
Nicholas Nethercote
37204ee563 Use associative type defaults in {Layout,FnAbi}OfHelpers.
This avoids some repetitive boilerplate code.
2024-09-17 10:25:06 +10:00
Ralf Jung
15848f3f08 simd_shuffle: require index argument to be a vector 2024-09-14 14:43:24 +02:00
Scott McMurray
fe5183e627 Fix the examples in cg_clif 2024-09-09 19:39:43 -07:00
bors
cf7c0554f1 Auto merge of #128939 - bjorn3:windows_cg_clif_component, r=albertlarsan68
Distribute rustc_codegen_cranelift for Windows

With support for raw-dylib recently added to cg_clif, and inline assembly support working on Windows for quite a while now, all blockers for distributing cg_clif on Windows that I mentioned in https://github.com/rust-lang/rust/pull/81746#issuecomment-1774099637 are fixed now.
2024-09-09 16:09:06 +00:00
Rémy Rakic
0fba9b4dbb introduce PrettyPrintMirOptions for cosmetic MIR dump options
initially starting with `-Z mir-include-spans` because we want them in
the NLL mir dump pass
2024-08-30 07:07:28 +00:00
Trevor Gross
8a26d21ce2 Rollup merge of #128731 - RalfJung:simd-shuffle-vector, r=workingjubilee
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](6c0b89dfac/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-27 01:46:50 -05:00
Ralf Jung
8e7b3b5c2b rename AddressOf -> RawBorrow inside the compiler 2024-08-18 19:46:53 +02:00
Ralf Jung
f1fadb8ba2 stabilize raw_ref_op 2024-08-18 19:46:53 +02:00
Chris Denton
d7198a541d Always use ar_archive_writer for import libs 2024-08-17 19:10:46 +00:00
bors
e2acda7447 Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errors
Shrink `TyKind::FnPtr`.

By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.

r? `@compiler-errors`
2024-08-14 00:56:53 +00:00
Ralf Jung
6906793db8 simd_shuffle intrinsic: allow argument to be passed as vector (not just as array) 2024-08-13 07:51:17 +02:00
Guillaume Gomez
ef74616e44 Rollup merge of #128149 - RalfJung:nontemporal_store, r=jieyouxu,Amanieu,Jubilee
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`
2024-08-12 17:09:14 +02:00
bjorn3
060811a602 Distribute rustc_codegen_cranelift for Windows 2024-08-10 21:16:44 +00:00
Nadrieril
3de829e4e5 Fixes in various places 2024-08-10 12:08:46 +02:00
bjorn3
0174cb1932 Use ar_archive_writer from sysroot for cg_clif 2024-08-09 17:23:50 +00:00
bjorn3
3ea9313de3 Merge commit '69b3f5a426a5c1c05236a45b36f6679d95fbe01b' into sync_cg_clif-2024-08-09 2024-08-09 17:18:46 +00:00
Nicholas Nethercote
b8b3a9328f Shrink TyKind::FnPtr.
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and
`FnHeader`, which can be packed more efficiently. This reduces the size
of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms.
This reduces peak memory usage by a few percent on some benchmarks. It
also reduces cache misses and page faults similarly, though this doesn't
translate to clear cycles or wall-time improvements on CI.
2024-08-09 14:33:25 +10:00
Michael Goulet
e96ece7c0b Rename struct_tail_erasing_lifetimes to struct_tail_for_codegen 2024-08-08 12:15:16 -04:00
Ralf Jung
80a7d5f61d nontemporal_store: make sure that the intrinsic is truly just a hint 2024-08-05 10:57:14 +02:00
bjorn3
37da264107 Move computation of decorated names out of the create_dll_import_lib method 2024-07-30 10:32:32 +00:00
bjorn3
161d2476d5 Move temp file name generation out of the create_dll_import_lib method 2024-07-30 10:10:41 +00:00