about summary refs log tree commit diff
path: root/compiler/stable_mir/src/compiler_interface.rs
AgeCommit message (Collapse)AuthorLines
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.