Trait rustc_codegen_llvm::type_of::LayoutLlvmExt
source · pub trait LayoutLlvmExt<'tcx> {
fn is_llvm_immediate(&self) -> bool;
fn is_llvm_scalar_pair(&self) -> bool;
fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type;
fn immediate_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type;
fn scalar_llvm_type_at<'a>(
&self,
cx: &CodegenCx<'a, 'tcx>,
scalar: Scalar,
offset: Size
) -> &'a Type;
fn scalar_pair_element_llvm_type<'a>(
&self,
cx: &CodegenCx<'a, 'tcx>,
index: usize,
immediate: bool
) -> &'a Type;
fn llvm_field_index<'a>(&self, cx: &CodegenCx<'a, 'tcx>, index: usize) -> u64;
fn pointee_info_at<'a>(
&self,
cx: &CodegenCx<'a, 'tcx>,
offset: Size
) -> Option<PointeeInfo>;
}
Required Methods
source
fn is_llvm_immediate(&self) -> bool
source
fn is_llvm_scalar_pair(&self) -> bool
source
fn immediate_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type
sourcefn scalar_llvm_type_at<'a>(
fn scalar_llvm_type_at<'a>(
&self,
cx: &CodegenCx<'a, 'tcx>,
scalar: Scalar,
offset: Size
) -> &'a Type
sourcefn scalar_pair_element_llvm_type<'a>(
fn scalar_pair_element_llvm_type<'a>(
&self,
cx: &CodegenCx<'a, 'tcx>,
index: usize,
immediate: bool
) -> &'a Type
source
fn llvm_field_index<'a>(&self, cx: &CodegenCx<'a, 'tcx>, index: usize) -> u64
sourcefn pointee_info_at<'a>(
fn pointee_info_at<'a>(
&self,
cx: &CodegenCx<'a, 'tcx>,
offset: Size
) -> Option<PointeeInfo>
Implementations on Foreign Types
sourceimpl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx>
impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx>
sourcefn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type
fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type
Gets the LLVM type corresponding to a Rust type, i.e., rustc_middle::ty::Ty
.
The pointee type of the pointer in PlaceRef
is always this type.
For sized types, it is also the right LLVM type for an alloca
containing a value of that type, and most immediates (except bool
).
Unsized types, however, are represented by a “minimal unit”, e.g.
[T]
becomes T
, while str
and Trait
turn into i8
- this
is useful for indexing slices, as &[T]
’s data pointer is T*
.
If the type is an unsized struct, the regular layout is generated,
with the inner-most trailing unsized field using the “minimal unit”
of that field’s type - this is useful for taking the address of
that field and ensuring the struct has the right alignment.