about summary refs log tree commit diff
path: root/compiler/stable_mir/src/ty.rs
AgeCommit message (Collapse)AuthorLines
2025-07-14rename `stable_mir` to `rustc_public`, and `rustc_smir` to `rustc_public_bridge`Makai-1655/+0
2025-07-06move `stable_mir` back to its own crate and move `rustc_internal` to ↵Makai-0/+1655
the`stable_mir` crate As part of this reorganization, some traits need to be moved from `rustc_smir::context::traits` to `stable_mir::unstable::internal_cx`. These traits are specifically designed for `InternalCx` to clarify the behavior of different functions that share the same name. This move is necessary to avoid orphan rule violations.
2025-04-05let `rustc_smir` host `stable_mir` for refactoringMakai-1622/+0
2025-04-01Implement `associated_items` api.makai410-1/+66
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-1/+1
2025-02-10Extend the renaming to coerce_unsafe_ptrBastian Kersting-1/+1
2025-01-16Add gpu-kernel calling conventionFlakebi-0/+1
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.
2024-12-14Encode coroutine-closures in SMIRMichael Goulet-0/+11
2024-11-07[StableMIR] A few fixes to pretty printingCelina G. Val-0/+8
Improve identation, and a few other rvalue printing
2024-10-24Remove associated type based effects logicMichael Goulet-1/+0
2024-09-25Compiler: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-21add `C-cmse-nonsecure-entry` ABIFolkert de Vries-0/+1
2024-09-02chore: Fix typos in 'compiler' (batch 3)Alexander Cyon-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-7/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-25Auto merge of #126963 - runtimeverification:smir_serde_derive, r=celinvalbors-68/+85
Add basic Serde serialization capabilities to Stable MIR This PR adds basic Serde serialization capabilities to Stable MIR. It is intentionally minimal (just wrapping all stable MIR types with a Serde `derive`), so that any important design decisions can be discussed before going further. A simple test is included with this PR to validate that JSON can actually be emitted. ## Notes When I wrapped the Stable MIR error types in `compiler/stable_mir/src/error.rs`, it caused test failures (though I'm not sure why) so I backed those out. ## Future Work So, this PR will support serializing basic stable MIR, but it _does not_ support serializing interned values beneath `Ty`s and `AllocId`s, etc... My current thinking about how to handle this is as follows: 1. Add new `visited_X` fields to the `Tables` struct for each interned category of interest. 2. As serialization is occuring, serialize interned values as usual _and_ also record the interned value we referenced in `visited_X`. (Possibly) In addition, if an interned value recursively references other interned values, record those interned values as well. 3. Teach the stable MIR `Context` how to access the `visited_X` values and expose them with wrappers in `stable_mir/src/lib.rs` to users (e.g. to serialize and/or further analyze them). ### Pros This approach does not commit to any specific serialization format regarding interned values or other more complex cases, which avoids us locking into any behaviors that may not be desired long-term. ### Cons The user will need to manually handle serializing interned values. ### Alternatives 1. We can directly provide access to the underlying `Tables` maps for interned values; the disadvantage of this approach is that it either requires extra processing for users to filter out to only use the values that they need _or_ users may serialize extra values that they don't need. The advantage is that the implementation is even simpler. The other pros/cons are similar to the above. 2. We can directly serialize interned values by expanding them in-place. The pro is that this may make some basic inputs easier to consume. However, the cons are that there will need to be special provisions for dealing with cyclical values on both the producer and consumer _and_ global values will possibly need to be de-duplicated on the consumer side.
2024-07-11Remove extern "wasm" ABINikita Popov-1/+0
Remove the unstable `extern "wasm"` ABI (`wasm_abi` feature tracked in #83788). As discussed in https://github.com/rust-lang/rust/pull/127513#issuecomment-2220410679 and following, this ABI is a failed experiment that did not end up being used for anything. Keeping support for this ABI in LLVM 19 would require us to switch wasm targets to the `experimental-mv` ABI, which we do not want to do. It should be noted that `Abi::Wasm` was internally used for two things: The `-Z wasm-c-abi=legacy` ABI that is still used by default on some wasm targets, and the `extern "wasm"` ABI. Despite both being `Abi::Wasm` internally, they were not the same. An explicit `extern "wasm"` additionally enabled the `+multivalue` feature. I've opted to remove `Abi::Wasm` in this patch entirely, instead of keeping it as an ABI with only internal usage. Both `-Z wasm-c-abi` variants are now treated as part of the normal C ABI, just with different different treatment in adjust_for_foreign_abi.
2024-06-26add serde derive Serialize to stable_mirStephen Skeirik-68/+85
2024-06-26Remove `f16` and `f128` ICE paths from smirTrevor Gross-0/+2
2024-06-21Add method to get `FnAbi` of function pointerAdwin White-1/+11
2024-06-15Rollup merge of #126361 - celinval:issue-0079-intrinsic, r=oli-obkMatthias Krüger-1/+6
Unify intrinsics body handling in StableMIR rust-lang/rust#120675 introduced a new mechanism to declare intrinsics which will potentially replace the rust-intrinsic ABI. The new mechanism introduces a placeholder body and mark the intrinsic with `#[rustc_intrinsic_must_be_overridden]`. In practice, this means that a backend should not generate code for the placeholder, and shim the intrinsic. The new annotation is an internal compiler implementation, and it doesn't need to be exposed to StableMIR users. In this PR, we unify the interface for intrinsics marked with `rustc_intrinsic_must_be_overridden` and intrinsics that do not have a body. Fixes https://github.com/rust-lang/project-stable-mir/issues/79 r? ``@oli-obk`` cc: ``@momvart``
2024-06-13Rollup merge of #126366 - celinval:issue-0080-def-ty, r=oli-obkLeón Orell Valerian Liehr-6/+22
Add a new trait to retrieve StableMir definition Ty We implement the trait only for definitions that should have a type. It's possible that I missed a few definitions, but we can add them later if needed. Fixes https://github.com/rust-lang/project-stable-mir/issues/80
2024-06-12Add a new trait to retrieve StableMir definition TyCelina G. Val-6/+22
We implement the trait only for definitions that should have a type. It's possible that I missed a few definitions, but we can add them later if needed.
2024-06-12Make `try_from_target_usize` method publicArtem Agvanian-1/+1
There is now no way to create a TyConst from an integer, so I propose making this method public unless there was a reason for keeping it otherwise.
2024-06-12Unify intrinsics body handling in StableMIRCelina G. Val-1/+6
rust-lang/rust#120675 introduced a new mechanism to declare intrinsics which will potentially replace the rust-intrinsic ABI. The new mechanism introduces a placeholder body and mark the intrinsic with #[rustc_intrinsic_must_be_overridden]. In practice, this means that backends should not generate code for the placeholder, and shim the intrinsic. The new annotation is an internal compiler implementation, and it doesn't need to be exposed to StableMIR users. In this PR, intrinsics marked with `rustc_intrinsic_must_be_overridden` are handled the same way as intrinsics that do not have a body.
2024-06-04Split smir `Const` into `TyConst` and `MirConst`Boxy-28/+67
2024-05-30Apply x clippy --fix and x fmtr0cky-3/+3
2024-05-24Remove `DefId` from `EarlyParamRegion` (clippy/smir)Boxy-1/+0
2024-05-23Rollup merge of #125336 - momvart:smir-77-intrinsic, r=celinvalLeón Orell Valerian Liehr-0/+35
Add dedicated definition for intrinsics Closes rust-lang/project-stable-mir#77
2024-05-23Add conversion from IntrinsicDef to FnDefMohammad Omidvar-0/+6
2024-05-20Implement BOXED_SLICE_INTO_ITERMichael Goulet-0/+1
2024-05-20Add intrinsic definition and retrieval APIsMohammad Omidvar-0/+29
2024-05-17Rename Unsafe to SafetySantiago Pastorino-4/+3
2024-05-13split out AliasTy -> AliasTermMichael Goulet-1/+7
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+7
2024-03-28Normalize the result of Fields::ty_with_argsCelina G. Val-2/+2
We were only instantiating before, which would leak an AliasTy. I added a test case that reproduce the issue seen here: https://github.com/model-checking/kani/issues/3113
2024-03-22Split out ImplPolarity and PredicatePolarityMichael Goulet-1/+7
2024-03-12Add methods to create constantsCelina G. Val-1/+26
I've been experimenting with transforming the StableMIR to instrument the code with potential UB checks. The modified body will only be used by our analysis tool, however, constants in StableMIR must be backed by rustc constants. Thus, I'm adding a few functions to build constants, such as building string and other primitives.
2024-03-01Implement missing ABI structures in StableMIRCelina G. Val-1/+6
2024-02-25remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsicsRalf Jung-1/+0
2024-02-14Rewrite foreign item kind query using `DefKind`Mohammad Omidvar-1/+1
2024-02-12Add APIs for fetching foreign items including foreign modules, their ABIs, ↵Mohammad Omidvar-1/+35
and their items
2024-01-30Remove the `abi_amdgpu_kernel` featureclubby789-1/+0
2024-01-19Make the remaining "private" fields actually privateOli Scherer-2/+2
2024-01-09Fix all_trait* methods to return all trait availableCelina G. Val-0/+15
Also provide a mechanism to retrieve traits and implementations for a given crate.
2023-12-28Restore movability to SMIRMichael Goulet-3/+4
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-3/+3
2023-12-18Add function ABI and type layout to StableMIRCelina G. Val-0/+6
This change introduces a new module to StableMIR named `abi` with information from `rustc_target::abi` and `rustc_abi`, that allow users to retrieve more low level information required to perform bit-precise analysis. The layout of a type can be retrieved via `Ty::layout`, and the instance ABI can be retrieved via `Instance::fn_abi()`. To properly handle errors while retrieve layout information, we had to implement a few layout related traits.
2023-12-15Add a method to check if type is a CStrCelina G. Val-0/+6
2023-12-14Address PR commentsCelina G. Val-4/+8
- Remove `fn_sig()` from Instance. - Change return value of `AssertMessage::description` to `Cow<>`. - Add assert to instance `ty()`. - Generalize uint / int type creation.