1
Fork 0

Add function ABI and type layout to StableMIR

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.
This commit is contained in:
Celina G. Val 2023-12-18 19:52:25 +00:00
parent 2a7634047a
commit 1a83c5b55b
14 changed files with 760 additions and 25 deletions

View file

@ -5,6 +5,7 @@
use std::cell::Cell;
use crate::abi::{FnAbi, Layout, LayoutShape};
use crate::mir::alloc::{AllocId, GlobalAlloc};
use crate::mir::mono::{Instance, InstanceDef, StaticDef};
use crate::mir::Body;
@ -173,6 +174,15 @@ pub trait Context {
/// Return information about the target machine.
fn target_info(&self) -> MachineInfo;
/// Get an instance ABI.
fn instance_abi(&self, def: InstanceDef) -> Result<FnAbi, Error>;
/// Get the layout of a type.
fn ty_layout(&self, ty: Ty) -> Result<Layout, Error>;
/// Get the layout shape.
fn layout_shape(&self, id: Layout) -> LayoutShape;
}
// A thread local variable that stores a pointer to the tables mapping between TyCtxt