about summary refs log tree commit diff
path: root/compiler/rustc_target/src/abi/mod.rs
AgeCommit message (Collapse)AuthorLines
2023-02-15Rollup merge of #107163 - mikebenfield:parameters-pr, r=TaKO8KiDylan DPC-46/+2
Remove some superfluous type parameters from layout.rs. Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
2023-01-22rustc_abi: remove Primitive::{is_float,is_int}Erik Desjardins-1/+1
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
2023-01-21Remove some superfluous type parameters from layout.rs.Michael Benfield-46/+2
Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
2022-12-18A few small cleanups for `newtype_index`Nilstrieb-2/+1
Remove the `..` from the body, only a few invocations used it and it's inconsistent with rust syntax. Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18Use `#[derive]` instead of custom syntax in all `newtype_index`Nilstrieb-1/+1
2022-11-24move things from rustc_target::abi to rustc_abihkalbasi-1518/+4
2022-11-24move some layout logic to rustc_target::abi::layouthkalbasi-7/+144
2022-11-24make rustc_target usable outside of rustchkalbasi-34/+93
2022-11-13add is_sized method on Abi and Layout, and use itRalf Jung-0/+10
2022-10-05change might_permit_raw_init to fully detect LLVM UB, but not more than thatRalf Jung-69/+1
2022-09-08translations(rustc_session): migrate TargetDataLayout::parseLuis Cardoso-26/+37
2022-09-07Change name of "dataful" variant to "untagged"Michael Benfield-2/+2
This is in anticipation of a new enum layout, in which the niche optimization may be applied even when multiple variants have data.
2022-08-02Auto merge of #92268 - jswrenn:transmute, r=oli-obkbors-1/+2
Initial implementation of transmutability trait. *T'was the night before Christmas and all through the codebase, not a miri was stirring — no hint of `unsafe`!* This PR provides an initial, **incomplete** implementation of *[MCP 411: Lang Item for Transmutability](https://github.com/rust-lang/compiler-team/issues/411)*. The `core::mem::BikeshedIntrinsicFrom` trait provided by this PR is implemented on-the-fly by the compiler for types `Src` and `Dst` when the bits of all possible values of type `Src` are safely reinterpretable as a value of type `Dst`. What this PR provides is: - [x] [support for transmutations involving primitives](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/primitives) - [x] [support for transmutations involving arrays](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/arrays) - [x] [support for transmutations involving structs](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/structs) - [x] [support for transmutations involving enums](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/enums) - [x] [support for transmutations involving unions](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/unions) - [x] [support for weaker validity checks](https://github.com/jswrenn/rust/blob/transmute/src/test/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs) (i.e., `Assume::VALIDITY`) - [x] visibility checking What isn't yet implemented: - [ ] transmutability options passed using the `Assume` struct - [ ] [support for references](https://github.com/jswrenn/rust/blob/transmute/src/test/ui/transmutability/references.rs) - [ ] smarter error messages These features will be implemented in future PRs.
2022-07-31reorder fields in Laout debug outputRalf Jung-6/+7
2022-07-27Initial (incomplete) implementation of transmutability trait.Jack Wrenn-1/+2
This initial implementation handles transmutations between types with specified layouts, except when references are involved. Co-authored-by: Igor null <m1el.2027@gmail.com>
2022-07-22do not mark interior mutable shared refs as dereferenceableRalf Jung-3/+7
2022-07-22rename PointerKind::Shared → SharedMutable to indicate this is NOT the ↵Ralf Jung-1/+1
usual shared reference
2022-07-14Use constant eval to do strict validity checks5225225-23/+15
2022-06-06Auto merge of #97684 - RalfJung:better-provenance-control, r=oli-obkbors-0/+5
interpret: better control over whether we read data with provenance The resolution in https://github.com/rust-lang/unsafe-code-guidelines/issues/286 seems to be that when we load data at integer type, we implicitly strip provenance. So let's implement that in Miri at least for scalar loads. This makes use of the fact that `Scalar` layouts distinguish pointer-sized integers and pointers -- so I was expecting some wild bugs where layouts set this incorrectly, but so far that does not seem to happen. This does not entirely implement the solution to https://github.com/rust-lang/unsafe-code-guidelines/issues/286; we still do the wrong thing for integers in larger types: we will `copy_op` them and then do validation, and validation will complain about the provenance. To fix that we need mutating validation; validation needs to strip the provenance rather than complaining about it. This is a larger undertaking (but will also help resolve https://github.com/rust-lang/miri/issues/845 since we can reset padding to `Uninit`). The reason this is useful is that we can now implement `addr` as a `transmute` from a pointer to an integer, and actually get the desired behavior of stripping provenance without exposing it!
2022-06-05interpret: better control over whether we read data with provenance, and ↵Ralf Jung-0/+5
implicit provenance stripping where possible
2022-06-03Use serde_json for target spec jsonbjorn3-2/+3
2022-06-03Remove a couple of unused Encodable and Decodable derivesbjorn3-1/+1
2022-05-24Add flag for stricter checks on uninit/zeroed5225225-12/+47
2022-05-06make Size and Align debug-printing a bit more compactRalf Jung-2/+16
2022-04-26Rollup merge of #94703 - kjetilkjeka:nvptx-kernel-args-abi2, r=nagisaGuillaume Gomez-0/+32
Fix codegen bug in "ptx-kernel" abi related to arg passing I found a codegen bug in the nvptx abi related to that args are passed as ptrs ([see comment](https://github.com/rust-lang/rust/issues/38788#issuecomment-1048999928)), this is not as specified in the [ptx-interoperability doc](https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/) or how C/C++ does it. It will also almost always fail in practice since device/host uses different memory spaces for most hardware. This PR fixes the bug and add tests for passing structs to ptx kernels. I observed that all nvptx assembly tests had been marked as [ignore a long time ago](https://github.com/rust-lang/rust/pull/59752#issuecomment-501713428). I'm not sure if the new one should be marked as ignore, it passed on my computer but it might fail if ptx-linker is missing on the server? I guess this is outside scope for this PR and should be looked at in a different issue/PR. I only fixed the nvptx64-nvidia-cuda target and not the potential code paths for the non-existing 32bit target. Even though 32bit nvptx is not a supported target there are still some code under the hood supporting codegen for 32 bit ptx. I was advised to create an MCP to find out if this code should be removed or updated. Perhaps ``@RDambrosio016`` would have interest in taking a quick look at this.
2022-04-19Fix a bug in the ptx-kernel calling convention where structs was passed ↵Kjetil Kjeka-0/+32
indirectly Structs being passed indirectly is suprpising and have a high chance not to work as the device and host usually do not share memory.
2022-04-05trivial cfg(bootstrap) changesPietro Albini-1/+1
2022-04-05Mark scalar layout unions so that backends that do not support partially ↵Oli Scherer-20/+80
initialized scalars can special case them.
2022-03-29allow large Size againRalf Jung-16/+7
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-07Clarify `Layout` interning.Nicholas Nethercote-11/+65
`Layout` is another type that is sometimes interned, sometimes not, and we always use references to refer to it so we can't take any advantage of the uniqueness properties for hashing or equality checks. This commit renames `Layout` as `LayoutS`, and then introduces a new `Layout` that is a newtype around an `Interned<LayoutS>`. It also interns more layouts than before. Previously layouts within layouts (via the `variants` field) were never interned, but now they are. Hence the lifetime on the new `Layout` type. Unlike other interned types, these ones are in `rustc_target` instead of `rustc_middle`. This reflects the existing structure of the code, which does layout-specific stuff in `rustc_target` while `TyAndLayout` is generic over the `Ty`, allowing the type-specific stuff to occur in `rustc_middle`. The commit also adds a `HashStable` impl for `Interned`, which was needed. It hashes the contents, unlike the `Hash` impl which hashes the pointer.
2022-02-19Adopt let else in more placesest31-6/+3
2021-12-17Eliminate duplicate codes of is_single_fp_elementlzh-0/+18
2021-10-19Fix issue 90038Gary Guo-1/+1
2021-09-13enum niche allocation grows toward zero if possibleAndreas Liljeqvist-9/+43
2021-09-09bugfixAndreas Liljeqvist-1/+1
2021-09-09WrapAndreas Liljeqvist-1/+1
2021-09-09rename `is_valid_for` to `is_valid`Andreas Liljeqvist-2/+2
2021-09-09Rename `(un)signed` to `(un)signed_int`Andreas Liljeqvist-6/+6
2021-09-09Move `unsigned_max` etc into `Size` againAndreas Liljeqvist-7/+22
2021-09-09Make `abi::Abi` `Copy` and remove a *lot* of refsAndreas Liljeqvist-7/+7
fix fix Remove more refs and clones fix more fix
2021-09-09Fix docstringAndreas Liljeqvist-2/+1
2021-09-09Use special `Debug` format when `start` > `end`Andreas Liljeqvist-1/+5
2021-09-09Remove `contains_zero`, respect the compilerAndreas Liljeqvist-8/+1
2021-09-09derive Copy for WrappingRange and ScalarAndreas Liljeqvist-5/+5
2021-09-09fix matchAndreas Liljeqvist-2/+4
2021-09-09Add methods for checking for full ranges to `Scalar` and `WrappingRange`Andreas Liljeqvist-21/+15
Move *_max methods back to util change to inline instead of inline(always) Remove valid_range_exclusive from scalar Use WrappingRange instead implement always_valid_for in a safer way Fix accidental edit
2021-09-02rustc_target: move `LayoutOf` to `ty::layout`.Eduard-Mihai Burtescu-41/+0
2021-08-30rustc_target: remove `LayoutOf` bound from `TyAbiInterface`.Eduard-Mihai Burtescu-5/+2
2021-08-30rustc_target: `TyAndLayout::field` should never error.Eduard-Mihai Burtescu-9/+8