summaryrefslogtreecommitdiff
path: root/compiler/rustc_abi
Commit message (Collapse)AuthorAgeFilesLines
* Reorder to keep duplicate checks in sync.Luqman Aden2023-05-051-7/+12
|
* Review feedbackLuqman Aden2023-05-052-14/+23
|
* Don't discard preferred alignment in scalar pair.Luqman Aden2023-05-051-4/+2
|
* Factor out checks in layout check and add helper inherent_size.Luqman Aden2023-05-051-1/+22
|
* Incorporate review feedback from 103926.Luqman Aden2023-05-051-38/+33
|
* Add helper methods inherent_align and to_union on Abi.Luqman Aden2023-05-051-1/+26
|
* Do not use scalar layout if there are ZSTs with alignment > 1Oli Scherer2023-05-051-20/+42
|
* layout-alignment-promotion logic should depend on the niche-biasThe 84722023-04-281-7/+22
| | | | | | | For start-biased layout we want to avoid overpromoting so that the niche doesn't get pushed back. For end-biased layout we want to avoid promoting fields that may contain one of the niches of interest.
* [review] add comments, turn flag into enumThe 84722023-04-281-23/+44
|
* add tracing for layout optimizationsThe 84722023-04-271-0/+44
|
* don't promote large fields to higher alignments if that would affect niche ↵The 84722023-04-271-13/+24
| | | | placement
* try two different niche-placement strategies when layouting univariant structsThe 84722023-04-271-6/+70
|
* refactor: extract functionThe 84722023-04-271-214/+220
|
* Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle2023-04-241-1/+1
|
* Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock2023-04-182-4/+6
|
* Rollup merge of #110394 - scottmcm:less-idx-new, r=WaffleLapkinMatthias Krüger2023-04-172-5/+4
|\ | | | | | | | | | | | | | | | | Various minor Idx-related tweaks Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify. cc https://github.com/rust-lang/compiler-team/issues/606 r? `@WaffleLapkin`
| * Various minor Idx-related tweaksScott McMurray2023-04-162-5/+4
| | | | | | | | Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.
* | Remove the loop in `Align::from_bytes`Scott McMurray2023-04-161-7/+4
|/ | | | Perf is almost certainly irrelevant, but might as well simplify it, since `trailing_zeros` does exactly what's needed.
* Fix some clippy::complexityNilstrieb2023-04-091-1/+1
|
* Enforce that PointerLike requires a pointer-like ABIMichael Goulet2023-04-081-0/+10
|
* Use `FieldIdx` in `FieldsShape`Scott McMurray2023-04-042-52/+46
| | | | Finally got to the main motivating example from the MCP :)
* Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray2023-04-022-3/+3
| | | | All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
* Move `mir::Field` → `abi::FieldIdx`Scott McMurray2023-03-281-0/+26
| | | | | | The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
* Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray2023-03-252-11/+24
| | | | | | Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
* Unify validity checks into a single queryNilstrieb2023-02-231-8/+0
| | | | | | | | | Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
* Rollup merge of #107592 - workingjubilee:use-16-bit-enum-on-16-bit-targets, ↵Matthias Krüger2023-02-171-1/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r=WaffleLapkin Default `repr(C)` enums to `c_int` size This is what ISO C strongly implies this is correct, and many processor-specific ABIs imply or mandate this size, so "everyone" (LLVM, gcc...) defaults to emitting enums this way. However, this is by no means guaranteed by ISO C, and the bare-metal Arm targets show it can be overridden, which rustc supports via `c-enum-min-bits` in a target.json. The override is a flag named `-fshort-enums` in clang and gcc, but introducing a CLI flag is probably unnecessary for rustc. This flag can be used by non-Arm microcontroller targets, like AVR and MSP430, but it is not enabled for them by default. Rust programmers who know the size of a target's enums can use explicit reprs, which also lets them match C23 code. This change is most relevant to 16-bit targets: AVR and MSP430. Most of rustc's targets use 32-bit ints, but ILP64 does exist. Regardless, rustc should now correctly handle enums for both very small and very large targets. Thanks to William for confirming MSP430 behavior, and to Waffle for better style and no-core `size_of` asserts. Fixes rust-lang/rust#107361 Fixes rust-lang/rust#77806
| * Default repr(C) enums to c_int sizeJubilee Young2023-02-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is what ISO C strongly implies this is correct, and many processor-specific ABIs imply or mandate this size, so "everyone" (LLVM, gcc...) defaults to emitting enums this way. However, this is by no means guaranteed by ISO C, and the bare-metal Arm targets show it can be overridden, which rustc supports via `c-enum-min-bits` in a target.json. The override is a flag named `-fshort-enums` in clang and gcc, but introducing a CLI flag is probably unnecessary for rustc. This flag can be used by non-Arm microcontroller targets, like AVR and MSP430, but it is not enabled for them by default. Rust programmers who know the size of a target's enums can use explicit reprs, which also lets them match C23 code. This change is most relevant to 16-bit targets: AVR and MSP430. Most of rustc's targets use 32-bit ints, but ILP64 does exist. Regardless, rustc should now correctly handle enums for both very small and very large targets. Thanks to William for confirming MSP430 behavior, and to Waffle for better style and no-core size_of asserts. Co-authored-by: William D. Jones <thor0505@comcast.net> Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
* | Rollup merge of #107163 - mikebenfield:parameters-pr, r=TaKO8KiDylan DPC2023-02-152-87/+130
|\ \ | | | | | | | | | | | | | | | Remove some superfluous type parameters from layout.rs. Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
| * | Remove some superfluous type parameters from layout.rs.Michael Benfield2023-01-212-87/+130
| | | | | | | | | | | | | | | Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
* | | also do not add noalias on not-Unpin BoxRalf Jung2023-02-061-2/+2
| | |
* | | make PointerKind directly reflect pointer typesRalf Jung2023-02-061-15/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code that consumes PointerKind (`adjust_for_rust_scalar` in rustc_ty_utils) ended up using PointerKind variants to talk about Rust reference types (& and &mut) anyway, making the old code structure quite confusing: one always had to keep in mind which PointerKind corresponds to which type. So this changes PointerKind to directly reflect the type. This does not change behavior.
* | | PointeeInfo is advisory onlyRalf Jung2023-01-311-0/+2
| | |
* | | abi: add `AddressSpace` field to `Primitive::Pointer`Erik Desjardins2023-01-221-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | ...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.
* | | rustc_abi: remove Primitive::{is_float,is_int}Erik Desjardins2023-01-221-12/+0
|/ / | | | | | | | | | | | | | | there were fixmes for this already i am about to remove is_ptr (since callers need to properly distinguish between pointers in different address spaces), so might as well do this at the same time
* | Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726Matthias Krüger2023-01-171-2/+2
|\ \ | |/ |/| | | | | | | Remove double spaces after dots in comments Most of the comments do not have double spaces, so I assume these are typos.
| * Remove double spaces after dots in commentsMaybe Waffle2023-01-171-2/+2
| |
* | Removed various double spaces in compiler source comments.André Vennberg2023-01-141-1/+1
|/
* Auto merge of #105446 - erikdesjardins:vt-size, r=nikicbors2022-12-181-0/+12
|\ | | | | | | | | | | | | | | | | | | | | Add 0..=isize::MAX range metadata to size loads from vtables This is the (much belated) size counterpart to #91569. Inspired by https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Range.20metadata.20for.20.60size_of_val.60.20and.20other.20isize.3A.3AMAX.20limits. This could help optimize layout computations based on the size of a dyn trait. Though, admittedly, adding this to vtables wouldn't be as beneficial as adding it to slice len, which is used much more often. Miri detects this UB already: https://github.com/rust-lang/rust/blob/b7cc99142ad0cfe47e2fe9f7a82eaf5b672c0573/compiler/rustc_const_eval/src/interpret/traits.rs#L119-L121 (In fact Miri goes further, [assuming a 48-bit address space on 64-bit platforms](https://github.com/rust-lang/rust/blob/9db224fc908059986c179fc6ec433944e9cfce50/compiler/rustc_abi/src/lib.rs#L312-L331), but I don't think we can assume that in an optimization.)
| * Add 0..=isize::MAX range metadata to size loads from vtablesErik Desjardins2022-12-081-0/+12
| |
* | minor code cleanupsMatthias Krüger2022-12-121-6/+3
| |
* | compiler: remove unnecessary imports and qualified pathsKaDiWa2022-12-101-1/+0
|/
* Auto merge of #105175 - michaelwoerister:add-stable-ord-trait, r=nagisabors2022-12-061-0/+7
|\ | | | | | | | | | | | | | | Add StableOrd trait as proposed in MCP 533. The `StableOrd` trait can be used to mark types as having a stable sort order across compilation sessions. Collections that sort their items in a stable way can safely implement HashStable by hashing items in sort order. See https://github.com/rust-lang/compiler-team/issues/533 for more information.
| * Add StableOrd trait as proposed in MCP 533.Michael Woerister2022-12-021-0/+7
| | | | | | | | | | | | | | The StableOrd trait can be used to mark types as having a stable sort order across compilation sessions. Collections that sort their items in a stable way can safely implement HashStable by hashing items in sort order.
* | Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514Matthias Krüger2022-12-031-5/+5
|\ \ | |/ |/| | | | | | | | | Remove useless borrows and derefs They are nothing more than noise. <sub>These are not all of them, but my clippy started crashing (stack overflow), so rip :(</sub>
| * Remove useless borrows and derefsMaybe Waffle2022-12-011-5/+5
| |
* | Extract llvm datalayout parsing out of spec modulehkalbasi2022-11-301-0/+96
|/
* Simplify and document range layout computationOli Scherer2022-11-251-13/+11
|
* move things from rustc_target::abi to rustc_abihkalbasi2022-11-243-0/+2370