about summary refs log tree commit diff
path: root/compiler/rustc_abi/src
AgeCommit message (Collapse)AuthorLines
2025-03-08Remove most manual LayoutData creations and move them to `rustc_abi`Moulins-94/+171
...either as: - methods on LayoutCalculator, for faillible operations; - constructors on LayoutData, for infaillible ones.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-06Rollup merge of #137805 - RalfJung:layout-debug-print, r=NoratriebMichael Goulet-1/+1
adjust Layout debug printing to match the internal field name The field got renamed a while ago, but the debug printing was not updated to match.
2025-03-04compiler: add `ExternAbi::is_rustic_abi`Jubilee Young-0/+11
2025-02-28rename BackendRepr::Vector → SimdVectorRalf Jung-20/+24
2025-02-28adjust Layout debug printing to match the internal field namesRalf Jung-1/+1
2025-02-23Rollup merge of #137334 - compiler-errors:edition-2024-fresh-2, ↵Jacob Pratt-1/+1
r=saethlin,traviscross Greatly simplify lifetime captures in edition 2024 Remove most of the `+ Captures` and `+ '_` from the compiler, since they are now unnecessary with the new edition 2021 lifetime capture rules. Use some `+ 'tcx` and `+ 'static` rather than being overly verbose with precise capturing syntax.
2025-02-23Rollup merge of #137256 - workingjubilee:untangle-vector-abi-assumptions, ↵Matthias Krüger-59/+73
r=bjorn3,RalfJung compiler: untangle SIMD alignment assumptions There were a number of puzzling assumptions being made about SIMD types and their layout that I have corrected in this diff. These are mostly no-op edits in actual fact, but they do subtly alter a pair of checks in our invariant-checking and union layout computation that rested on those peculiar assumptions. Those unfortunately stand in the way of any further actual fixes. I submit this for review, even though it's not clearly motivated without its followups, because it should still be possible to independently conclude whether this is correct.
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-1/+1
2025-02-22Fix binding mode problemsMichael Goulet-9/+9
2025-02-20compiler: split vector_align into cabi and llvmlikeJubilee Young-10/+15
Introduce a pair of functions that actually describe what they do, because it wasn't clear the alignment is sometimes a forgery.
2025-02-20compiler: `BackendRepr::inherent_{size,align} -> scalar_{size,align}`Jubilee Young-40/+50
This pair of fn was introduced to perform invariant checks for scalars. Their current behavior doesn't mesh as well with checking SIMD types, so change the name of the fn to reflect their actual use-case and refactor the corresponding checks. Also simplify the returns from Option<AbiAndPrefAlign> to Option<Align>, because every site was mapping away the "preferred" alignment anyways.
2025-02-20compiler: Align::max_for_offset -> Align::max_aligned_factorJubilee Young-9/+8
No functional changes.
2025-02-20Adjust LayoutData::uninhabited doc comment.zachs18-2/+2
Co-authored-by: Jubilee <workingjubilee@gmail.com>
2025-02-20Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: bool` ↵Zachary S-32/+28
field in `LayoutData`. Also update comments that refered to BackendRepr::Uninhabited.
2025-02-19Add a .bss-like scheme for encoded const allocsBen Kimock-2/+2
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-2/+2
with rust-analyzer
2025-02-15Replace some u64 hashes with Hash64Ben Kimock-7/+9
2025-02-12Split out the `extern_system_varargs` featureJubilee Young-2/+0
After the stabilization PR was opened, `extern "system"` functions were added to `extended_varargs_abi_support`. This has a number of questions regarding it that were not discussed and were somewhat surprising. It deserves to be considered as its own feature, separate from `extended_varargs_abi_support`.
2025-02-11compiler: remove rustc_abi::lookup and AbiUnsupportedJubilee Young-17/+14
These can be entirely replaced by the FromStr implementation.
2025-02-11compiler: remove AbiDatasJubilee Young-131/+9
These were a way to ensure hashes were stable over time for ExternAbi, but simply hashing the strings is more stable in the face of changes. As a result, we can do away with them.
2025-02-11compiler: compare and hash ExternAbi like its stringJubilee Young-12/+137
Directly map each ExternAbi variant to its string and back again. This has a few advantages: - By making the ABIs compare equal to their strings, we can easily lexicographically sort them and use that sorted slice at runtime. - We no longer need a workaround to make sure the hashes remain stable, as they already naturally are (by being the hashes of unique strings). - The compiler can carry around less &str wide pointers
2025-02-11compiler: narrow scope of nightly cfg in rustc_abiJubilee Young-6/+3
2025-02-09compiler: remove `abi`-specific `extern "{abi}"` suggestionsJubilee Young-20/+7
These are either residue of a long-term migration away from something, or are simply trying too hard to be specifically useful: nearest-match suggestions for ABI strings should handle this.
2025-02-09compiler: gate `extern "{abi}"` in ast_loweringJubilee Young-107/+5
By moving this stability check into AST lowering, we effectively make it impossible to accidentally miss, as it must happen to generate HIR. Also, we put the ABI-stability code next to code that actually uses it! This allows code that wants to reason about backend ABI implementations to stop worrying about high-level concerns like syntax stability, while still leaving it as the authority on what ABIs actually exist. It also makes it easy to refactor things to have more consistent errors. For now, we only apply this to generalize the existing messages a bit.
2025-02-08Rustfmtbjorn3-4/+7
2025-02-06compiler: reorganize rustc_abi to be more internally uniformJubilee Young-74/+78
General housekeeping: - Use less reexports from its rustc_target era - Unify some imports as a result - Split the Reg(ister) types into their own files Generally moving stuff around because it makes the crate more consistent.
2025-01-17Auto merge of #135047 - Flakebi:amdgpu-kernel-cc, r=workingjubileebors-13/+22
Add gpu-kernel calling convention The amdgpu-kernel calling convention was reverted in commit f6b21e90d1ec01081bc2619efb68af6788a63d65 (#120495 and https://github.com/rust-lang/rust-analyzer/pull/16463) due to inactivity in the amdgpu target. Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for. Tracking issue: #135467 amdgpu target tracking issue: #135024
2025-01-16Add gpu-kernel calling conventionFlakebi-13/+22
The amdgpu-kernel calling convention was reverted in commit f6b21e90d1ec01081bc2619efb68af6788a63d65 due to inactivity in the amdgpu target. Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for.
2025-01-10fix ZST handling for Windows ABIs on MSVC targetRalf Jung-0/+4
2025-01-10exclude unsizable tail from randomization seed calculationThe 8472-13/+9
2025-01-10Foo<T> != Foo<U> under layout randomizationThe 8472-2/+74
previously field ordering was using the same seed for all instances of Foo, now we pass seed values through the layout tree so that not only the struct itself affects layout but also its fields
2024-12-30compiler: Add a statement-of-intent to `rustc_abi`Jubilee Young-0/+32
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-14/+17
2024-12-18Variants::Single: do not use invalid VariantIdx for uninhabited enumsRalf Jung-11/+11
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+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-01fix safe-transmute handling of enumsRalf Jung-1/+5
2024-11-30improve TagEncoding::Niche docs and sanity checkRalf Jung-5/+19
2024-11-22Auto merge of #130867 - michirakara:steps_between, r=dtolnaybors-1/+1
distinguish overflow and unimplemented in Step::steps_between
2024-11-21distinguish overflow and unimplemented in Step::steps_betweenmichirakara-1/+1
2024-11-14Support s390x z13 vector ABITaiki Endo-0/+18
2024-11-08pointee_info_at: fix logic for recursing into enumsRalf Jung-4/+12
2024-10-30compiler: Lift `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`Jubilee Young-0/+372
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-111/+133
The initial naming of "Abi" was an awful mistake, conveying wrong ideas about how psABIs worked and even more about what the enum meant. It was only meant to represent the way the value would be described to a codegen backend as it was lowered to that intermediate representation. It was never meant to mean anything about the actual psABI handling! The conflation is because LLVM typically will associate a certain form with a certain ABI, but even that does not hold when the special cases that actually exist arise, plus the IR annotations that modify the ABI. Reframe `rustc_abi::Abi` as the `BackendRepr` of the type, and rename `BackendRepr::Aggregate` as `BackendRepr::Memory`. Unfortunately, due to the persistent misunderstandings, this too is now incorrect: - Scattered ABI-relevant code is entangled with BackendRepr - We do not always pre-compute a correct BackendRepr that reflects how we "actually" want this value to be handled, so we leave the backend interface to also inject various special-cases here - In some cases `BackendRepr::Memory` is a "real" aggregate, but in others it is in fact using memory, and in some cases it is a scalar! Our rustc-to-backend lowering code handles this sort of thing right now. That will eventually be addressed by lifting duplicated lowering code to either rustc_codegen_ssa or rustc_target as appropriate.
2024-10-28Rollup merge of #132255 - workingjubilee:layout-is-🏚️, r=compiler-errorsJubilee-2/+7
Add `LayoutS::is_uninhabited` and use it Use accessors for the things that accessors are good at: reducing everyone's need to be nosy and peek at the internals of every data structure.
2024-10-28compiler: Add `is_uninhabited` and use LayoutS accessorsJubilee Young-2/+7
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-27compiler: Rename LayoutS to LayoutDataJubilee Young-33/+33
The last {UninternedType}S is in captivity. The galaxy is at peace.
2024-10-21Make rustc_abi compile on stable againLukas Wirth-15/+23
2024-10-20compiler: Reject impossible reprs during enum layoutJubilee Young-0/+9
2024-10-19compiler: Adopt rust-analyzer impls for `LayoutCalculatorError`Jubilee Young-1/+26