about summary refs log tree commit diff
path: root/compiler/stable_mir/src/compiler_interface.rs
AgeCommit message (Collapse)AuthorLines
2024-09-26Use `&raw` in the compilerJosh Stone-1/+1
Like #130865 did for the standard library, we can use `&raw` in the compiler now that stage0 supports it. Also like the other issue, I did not make any doc or test changes at this time.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-06-28Add method to get all attributes on a definitionAdwin White-2/+9
2024-06-28Support fetching `Attribute` of items.Adwin White-1/+4
2024-06-21Add method to get `FnAbi` of function pointerAdwin White-0/+3
2024-06-12Unify intrinsics body handling in StableMIRCelina G. Val-4/+0
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-9/+13
2024-05-28Add an intrinsic for `ptr::metadata`Scott McMurray-1/+4
2024-05-20Add intrinsic definition and retrieval APIsMohammad Omidvar-3/+12
2024-04-30Remove `extern crate scoped_tls` from `stable_mir`.Nicholas Nethercote-1/+1
2024-04-18Fix disabling the export of noop async_drop_in_place_rawDaria Sukhonina-0/+3
2024-04-08Remove unimplemented!() from BinOp::ty() functionCelina G. Val-1/+4
To reduce redundancy, we now internalize the BinOp instead of duplicating the `ty()` function body.
2024-03-20s/place_debug/place_pretty in SMIRCelina G. Val-1/+1
2024-03-20Improve emit stable mir bodyCelina G. Val-2/+8
2024-03-14Rollup merge of #122405 - celinval:smir-new-const, r=oli-obkMatthias Krüger-4/+13
Add methods to create StableMIR constant 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. One question I have is whether we should create a global allocation instead for strings. r? ``````@oli-obk``````
2024-03-12Add `intrinsic_name` to get plain intrinsic nameAdrian Palacios-0/+1
2024-03-12Add methods to create constantsCelina G. Val-4/+13
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-02-24compiler: use `addr_of!`Pavel Grigorenko-1/+1
2024-02-15Rollup merge of #120982 - momvart:smir-61-foreign_kind, r=oli-obkMatthias Krüger-3/+10
Add APIs for fetching foreign items Closes https://github.com/rust-lang/project-stable-mir/issues/61
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-3/+10
and their items
2024-02-12Dejargnonize substShoyu Vanilla-1/+1
2024-01-09Fix all_trait* methods to return all trait availableCelina G. Val-2/+4
Also provide a mechanism to retrieve traits and implementations for a given crate.
2023-12-20Add method to get instance instantiation argumentsCelina G. Val-0/+3
2023-12-18Add function ABI and type layout to StableMIRCelina G. Val-0/+10
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/+3
2023-12-11Fix BinOp ty assertion and `fn_sig` for closuresCelina G. Val-0/+6
Also added a few more util methods to TyKind to check for specific types.
2023-12-07Fix conversion to StaticDef and add testCelina G. Val-1/+1
2023-12-07Add instance evaluation and methods to read allocCelina G. Val-0/+7
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-07Rollup merge of #118688 - celinval:smir-rvalue-ty, r=compiler-errorsMatthias Krüger-1/+7
Add method to get type of an Rvalue in StableMIR Provide a method to StableMIR users to retrieve the type of an Rvalue operation. There were two possible implementation: 1. Create the logic inside stable_mir to process the type according to the Rvalue semantics, which duplicates the logic of `rustc_middle::mir::Rvalue::ty()`. 2. Implement the Rvalue translation from StableMIR back to internal representation, invoke the `rustc_middle::mir::Rvalue::ty()`, and translate the return value to StableMIR. I chose the first one for now since the duplication was fairly small, and the option 2 would require way more work to translate everything back to rustc internal representation. If we eventually add those translations, we could easily swap to the option 2. ```@compiler-errors``` / ```@ouz-a``` Please let me know if you have any strong opinion here. r? ```@compiler-errors```
2023-12-06Simplify StaticDef to Instance conversionCelina G. Val-1/+1
2023-12-06Add method to get type of an Rvalue in StableMIRCelina G. Val-0/+6
2023-12-06Rollup merge of #118681 - celinval:fix-foreign-item, r=ouz-aMatthias Krüger-1/+1
Fix is_foreign_item for StableMIR instance 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`. I also added a method to check if the instance has body, since the function already existed and it just wasn't exposed via public APIs. This makes it much cheaper for the user to check if the instance has body. ## 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`. r? `@ouz-a`
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-12-05Change ty_with_args to return Ty instead of ResultCelina G. Val-1/+1
Although, we would like to avoid crashes whenever possible, and that's why I wanted to make this API fallible. It's looking pretty hard to do proper validation. I think many of our APIs will unfortunately depend on the user doing the correct thing since at the MIR level we are working on, we expect types to have been checked already.
2023-12-04Add FieldDef to StableMIR and methods to get typeCelina G. Val-1/+5
2023-12-04Add Variant and a few more APIs to stable_mirCelina G. Val-1/+7
2023-12-01Add more information to stable InstanceCelina G. Val-4/+13
- Retrieve `FnSig`. - Implement CrateDef for InstanceDef. - Add VTable index for Virtual instances.
2023-11-24Reorder imports and remove re-exportCelina G. Val-1/+2
2023-11-24Move the compiler interface defs to its own moduleCelina G. Val-0/+163
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.