about summary refs log tree commit diff
path: root/compiler/stable_mir/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-07-14rename `stable_mir` to `rustc_public`, and `rustc_smir` to `rustc_public_bridge`Makai-300/+0
2025-07-06move `stable_mir` back to its own crate and move `rustc_internal` to ↵Makai-6/+295
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-30Change rustc_driver dependency on stable_mir crateCelina G. Val-0/+4
This fixes issues with RustAnalyzer not finding stable_mir crate. It is also part of the long term architecture plan for these crates, since we are moving towards having stable_mir depend on rustc_smir and not the other way around. I believe this is an utility function that will come handy eventually for stable_mir users, but I'm keeping it as part of rustc_internal since it initializes the StableMir context and requires `TyCtxt`. Finally, I added the rustc_internal crate under a feature since the APIs from this module shall not be stabilized.
2025-04-05let `rustc_smir` host `stable_mir` for refactoringMakai-229/+5
2025-04-01Implement `associated_items` api.makai410-2/+5
2025-03-04Make CrateItem::body() function return an optionCelina G. Val-5/+16
When we initially created `CrateItem`, it would only represent items that contain a body. That is no longer the case, for now, make this explicit by expanding the APIs to retrieve the item body. This is related to https://github.com/rust-lang/project-stable-mir/issues/34
2025-03-02Replace usages of `Context.def_name`NotLebedev-4/+1
Use `DefId.name` and `DefId.trimmed_name` instead
2024-11-07[StableMIR] API to retrieve definitions from cratesCelina G. Val-1/+12
Add functions to retrieve function definitions and static items from all crates (local and external). For external crates, add a query to retrieve the number of defs in a foreign crate.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-5/+4
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-26add serde derive Serialize to stable_mirStephen Skeirik-4/+6
2024-06-12Add a new trait to retrieve StableMir definition TyCelina G. Val-3/+5
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-04-30Remove `extern crate scoped_tls` from `stable_mir`.Nicholas Nethercote-2/+0
2024-03-20Improve emit stable mir bodyCelina G. Val-4/+2
2024-02-12Add APIs for fetching foreign items including foreign modules, their ABIs, ↵Mohammad Omidvar-1/+6
and their items
2024-01-25Remove unused featuresclubby789-1/+0
2024-01-09Fix all_trait* methods to return all trait availableCelina G. Val-9/+13
Also provide a mechanism to retrieve traits and implementations for a given crate.
2023-12-20Add `ItemKind::Ctor` to stable mirCelina G. Val-0/+7
2023-12-18Add function ABI and type layout to StableMIRCelina G. Val-0/+1
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-07Add instance evaluation and methods to read allocCelina G. Val-0/+1
The instance evaluation is needed to handle intrinsics such as `type_id` and `type_name`. Since we now use Allocation to represent all evaluated constants, provide a few methods to help process the data inside an allocation.
2023-12-06Fix `is_foreign_item` for StableMIR instanceCelina G. Val-1/+1
Change the implementation of `Instance::is_foreign_item` to directly query the compiler for the instance `def_id` instead of incorrectly relying on the conversion to `CrateItem`. Background: - In pull https://github.com/rust-lang/rust/pull/118524, I fixed the conversion from Instance to CrateItem to avoid the conversion if the instance didn't have a body available. This broke the `is_foreign_item`.
2023-11-26add successors and their formatterouz-a-1/+1
2023-11-25add pretty_terminatorouz-a-1/+1
2023-11-24Reorder imports and remove re-exportCelina G. Val-9/+10
2023-11-24Move the compiler interface defs to its own moduleCelina G. Val-160/+9
Separate items that are exposed in the `stable_mir` crate to be used by the compiler from items that we expect to be used by tool developers.
2023-11-22Add CrateDef trait and methods to get def namesCelina G. Val-14/+13
2023-11-21Add support to get virtual table allocationCelina G. Val-0/+3
2023-11-21Add support to global allocation to stable-mirCelina G. Val-15/+15
2023-11-21remove quotation from filenameouz-a-1/+1
2023-11-20Add place.ty() and Ty build from a kind to smirCelina G. Val-2/+18
2023-11-17use new apis and add new functionouz-a-3/+6
2023-11-17move pretty into stable_mirOğuz Ağcayazı-1/+8
2023-11-16Fix has_body() and change resolve_drop_in_place() sigCelina G. Val-1/+1
Fixed the `has_body()` function operator. Before that, this function was returning false for all shims. Change resolve_drop_in_place() to also return an instance for empty shims, since they may still be required for vtable construction.
2023-11-16Add more APIs and fix `Instance::body`Celina G. Val-5/+36
Add more APIs to retrieve information about types, and add more instance resolution options. Make `Instance::body()` return an Option<Body>, since not every instance might have an available body. For example, foreign instances, virtual instances, dependencies.
2023-11-16Add more SMIR internal impl and callback return valueCelina G. Val-8/+12
In cases like Kani, we will invoke the rustc_internal run command directly for now. It would be handly to be able to have a callback that can return a value. We also need extra methods to convert stable constructs into internal ones, so we can break down the transition into finer grain commits.
2023-10-30Add a stable MIR visitorCelina G. Val-3/+4
Add a few utility functions as well and extend most `mir` and `ty` ADTs to implement `PartialEq` and `Eq`.
2023-10-24Remove fold code and add Const::internal()Celina G. Val-4/+0
We are not planning to support user generated constant in the foreseeable future, so we are removing the Fold logic for now in favor of the Instance::resolve logic. The Instance::resolve was however incomplete, since we weren't handling internalizing constants yet. Thus, I added that. I decided to keep the Const fields private in case we decide to translate them lazily.
2023-10-23Remove unsafe and `Rc`Celina G. Val-8/+5
2023-10-23Add method to convert internal to stable constructsCelina G. Val-26/+26
2023-10-19Add stable Instance::body() and RustcInternal traitCelina G. Val-0/+4
The `Instance::body()` returns a monomorphized body. For that, we had to implement visitor that monomorphize types and constants. We are also introducing the RustcInternal trait that will allow us to convert back from Stable to Internal. Note that this trait is not yet visible for our users as it depends on Tables. We should probably add a new trait that can be exposed.
2023-10-16Add MonoItems and Instance to stable_mirCelina G. Val-15/+28
Also add a few methods to instantiate instances and get an instance definition. We're still missing support to actually monomorphize the instance body.
2023-10-13change fn name, return loc info, local nameOğuz Ağcayazı-2/+2
2023-10-11implement get_filename/lines for spanOğuz Ağcayazı-5/+12
2023-10-10Rollup merge of #116560 - ouz-a:efficient_ids, r=oli-obkGuillaume Gomez-3/+23
In smir use `FxIndexMap` to store indexed ids Previously we used `vec` for storing indexed types, which is fine for small cases but will lead to huge performance issues when we use `smir` for real world cases. Addresses https://github.com/rust-lang/project-stable-mir/issues/35 r? ``@oli-obk``
2023-10-10add new wrapper for FxIndexMapOğuz Ağcayazı-3/+23
2023-10-09return crates instead of a crateOğuz Ağcayazı-4/+4
2023-09-25Split out the stable part of smir into its own crate to prevent accidental ↵Oli Scherer-0/+242
usage of forever unstable things