diff options
| author | bors <bors@rust-lang.org> | 2019-05-05 18:25:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-05-05 18:25:13 +0000 |
| commit | d628c2e642c6f8f85f24dd5d7f49de89b95bf682 (patch) | |
| tree | def3c31e34937115a64751b9120d9d18b3a8446c /src/librustc_target | |
| parent | c6b16987645dd8980f40efe7c72d4f3fd4b399d3 (diff) | |
| parent | 968eb7ff5a5db0d842527cba15be6dba741103a2 (diff) | |
| download | rust-d628c2e642c6f8f85f24dd5d7f49de89b95bf682.tar.gz rust-d628c2e642c6f8f85f24dd5d7f49de89b95bf682.zip | |
Auto merge of #60237 - saleemjaffer:issue-56166-miri-fntype-arg-passing, r=eddyb
Move pointee_info_at from rustc_codegen_llvm to rustc_target. Makes progress towards #56166. This is a continuation of https://github.com/rust-lang/rust/pull/57150. @oli-obk Should I close the older PR?
Diffstat (limited to 'src/librustc_target')
| -rw-r--r-- | src/librustc_target/abi/mod.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 59eda97a2f9..4b61057e5cf 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -910,6 +910,28 @@ pub trait LayoutOf { fn layout_of(&self, ty: Self::Ty) -> Self::TyLayout; } +#[derive(Copy, Clone, PartialEq, Eq)] +pub enum PointerKind { + /// Most general case, we know no restrictions to tell LLVM. + Shared, + + /// `&T` where `T` contains no `UnsafeCell`, is `noalias` and `readonly`. + Frozen, + + /// `&mut T`, when we know `noalias` is safe for LLVM. + UniqueBorrowed, + + /// `Box<T>`, unlike `UniqueBorrowed`, it also has `noalias` on returns. + UniqueOwned +} + +#[derive(Copy, Clone)] +pub struct PointeeInfo { + pub size: Size, + pub align: Align, + pub safe: Option<PointerKind>, +} + pub trait TyLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized { fn for_variant( this: TyLayout<'a, Self>, @@ -917,6 +939,11 @@ pub trait TyLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized { variant_index: VariantIdx, ) -> TyLayout<'a, Self>; fn field(this: TyLayout<'a, Self>, cx: &C, i: usize) -> C::TyLayout; + fn pointee_info_at( + this: TyLayout<'a, Self>, + cx: &C, + offset: Size, + ) -> Option<PointeeInfo>; } impl<'a, Ty> TyLayout<'a, Ty> { @@ -928,6 +955,10 @@ impl<'a, Ty> TyLayout<'a, Ty> { where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> { Ty::field(self, cx, i) } + pub fn pointee_info_at<C>(self, cx: &C, offset: Size) -> Option<PointeeInfo> + where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> { + Ty::pointee_info_at(self, cx, offset) + } } impl<'a, Ty> TyLayout<'a, Ty> { |
