mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
cg_gcc: rustc_abi::Abi
=> BackendRepr
This commit is contained in:
parent
6d5d8b5071
commit
0349209901
@ -1016,11 +1016,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||||||
OperandValue::Ref(place.val)
|
OperandValue::Ref(place.val)
|
||||||
} else if place.layout.is_gcc_immediate() {
|
} else if place.layout.is_gcc_immediate() {
|
||||||
let load = self.load(place.layout.gcc_type(self), place.val.llval, place.val.align);
|
let load = self.load(place.layout.gcc_type(self), place.val.llval, place.val.align);
|
||||||
if let abi::Abi::Scalar(ref scalar) = place.layout.abi {
|
if let abi::BackendRepr::Scalar(ref scalar) = place.layout.backend_repr {
|
||||||
scalar_load_metadata(self, load, scalar);
|
scalar_load_metadata(self, load, scalar);
|
||||||
}
|
}
|
||||||
OperandValue::Immediate(self.to_immediate(load, place.layout))
|
OperandValue::Immediate(self.to_immediate(load, place.layout))
|
||||||
} else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
|
} else if let abi::BackendRepr::ScalarPair(ref a, ref b) = place.layout.backend_repr {
|
||||||
let b_offset = a.size(self).align_to(b.align(self).abi);
|
let b_offset = a.size(self).align_to(b.align(self).abi);
|
||||||
|
|
||||||
let mut load = |i, scalar: &abi::Scalar, align| {
|
let mut load = |i, scalar: &abi::Scalar, align| {
|
||||||
|
@ -294,13 +294,13 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
|
|||||||
}
|
}
|
||||||
|
|
||||||
sym::raw_eq => {
|
sym::raw_eq => {
|
||||||
use rustc_target::abi::Abi::*;
|
use rustc_abi::BackendRepr::*;
|
||||||
let tp_ty = fn_args.type_at(0);
|
let tp_ty = fn_args.type_at(0);
|
||||||
let layout = self.layout_of(tp_ty).layout;
|
let layout = self.layout_of(tp_ty).layout;
|
||||||
let _use_integer_compare = match layout.abi() {
|
let _use_integer_compare = match layout.backend_repr() {
|
||||||
Scalar(_) | ScalarPair(_, _) => true,
|
Scalar(_) | ScalarPair(_, _) => true,
|
||||||
Uninhabited | Vector { .. } => false,
|
Uninhabited | Vector { .. } => false,
|
||||||
Aggregate { .. } => {
|
Memory { .. } => {
|
||||||
// For rusty ABIs, small aggregates are actually passed
|
// For rusty ABIs, small aggregates are actually passed
|
||||||
// as `RegKind::Integer` (see `FnAbi::adjust_for_abi`),
|
// as `RegKind::Integer` (see `FnAbi::adjust_for_abi`),
|
||||||
// so we re-use that same threshold here.
|
// so we re-use that same threshold here.
|
||||||
|
@ -3,7 +3,7 @@ use std::fmt::Write;
|
|||||||
use gccjit::{Struct, Type};
|
use gccjit::{Struct, Type};
|
||||||
use rustc_abi as abi;
|
use rustc_abi as abi;
|
||||||
use rustc_abi::Primitive::*;
|
use rustc_abi::Primitive::*;
|
||||||
use rustc_abi::{Abi, FieldsShape, Integer, PointeeInfo, Size, Variants};
|
use rustc_abi::{BackendRepr, FieldsShape, Integer, PointeeInfo, Size, Variants};
|
||||||
use rustc_codegen_ssa::traits::{
|
use rustc_codegen_ssa::traits::{
|
||||||
BaseTypeCodegenMethods, DerivedTypeCodegenMethods, LayoutTypeCodegenMethods,
|
BaseTypeCodegenMethods, DerivedTypeCodegenMethods, LayoutTypeCodegenMethods,
|
||||||
};
|
};
|
||||||
@ -60,9 +60,9 @@ fn uncached_gcc_type<'gcc, 'tcx>(
|
|||||||
layout: TyAndLayout<'tcx>,
|
layout: TyAndLayout<'tcx>,
|
||||||
defer: &mut Option<(Struct<'gcc>, TyAndLayout<'tcx>)>,
|
defer: &mut Option<(Struct<'gcc>, TyAndLayout<'tcx>)>,
|
||||||
) -> Type<'gcc> {
|
) -> Type<'gcc> {
|
||||||
match layout.abi {
|
match layout.backend_repr {
|
||||||
Abi::Scalar(_) => bug!("handled elsewhere"),
|
BackendRepr::Scalar(_) => bug!("handled elsewhere"),
|
||||||
Abi::Vector { ref element, count } => {
|
BackendRepr::Vector { ref element, count } => {
|
||||||
let element = layout.scalar_gcc_type_at(cx, element, Size::ZERO);
|
let element = layout.scalar_gcc_type_at(cx, element, Size::ZERO);
|
||||||
let element =
|
let element =
|
||||||
// NOTE: gcc doesn't allow pointer types in vectors.
|
// NOTE: gcc doesn't allow pointer types in vectors.
|
||||||
@ -74,7 +74,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(
|
|||||||
};
|
};
|
||||||
return cx.context.new_vector_type(element, count);
|
return cx.context.new_vector_type(element, count);
|
||||||
}
|
}
|
||||||
Abi::ScalarPair(..) => {
|
BackendRepr::ScalarPair(..) => {
|
||||||
return cx.type_struct(
|
return cx.type_struct(
|
||||||
&[
|
&[
|
||||||
layout.scalar_pair_element_gcc_type(cx, 0),
|
layout.scalar_pair_element_gcc_type(cx, 0),
|
||||||
@ -83,7 +83,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Abi::Uninhabited | Abi::Aggregate { .. } => {}
|
BackendRepr::Uninhabited | BackendRepr::Memory { .. } => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = match *layout.ty.kind() {
|
let name = match *layout.ty.kind() {
|
||||||
@ -176,16 +176,21 @@ pub trait LayoutGccExt<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
|
impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
|
||||||
fn is_gcc_immediate(&self) -> bool {
|
fn is_gcc_immediate(&self) -> bool {
|
||||||
match self.abi {
|
match self.backend_repr {
|
||||||
Abi::Scalar(_) | Abi::Vector { .. } => true,
|
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true,
|
||||||
Abi::ScalarPair(..) | Abi::Uninhabited | Abi::Aggregate { .. } => false,
|
BackendRepr::ScalarPair(..) | BackendRepr::Uninhabited | BackendRepr::Memory { .. } => {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_gcc_scalar_pair(&self) -> bool {
|
fn is_gcc_scalar_pair(&self) -> bool {
|
||||||
match self.abi {
|
match self.backend_repr {
|
||||||
Abi::ScalarPair(..) => true,
|
BackendRepr::ScalarPair(..) => true,
|
||||||
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } | Abi::Aggregate { .. } => false,
|
BackendRepr::Uninhabited
|
||||||
|
| BackendRepr::Scalar(_)
|
||||||
|
| BackendRepr::Vector { .. }
|
||||||
|
| BackendRepr::Memory { .. } => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +210,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
|
|||||||
// This must produce the same result for `repr(transparent)` wrappers as for the inner type!
|
// This must produce the same result for `repr(transparent)` wrappers as for the inner type!
|
||||||
// In other words, this should generally not look at the type at all, but only at the
|
// In other words, this should generally not look at the type at all, but only at the
|
||||||
// layout.
|
// layout.
|
||||||
if let Abi::Scalar(ref scalar) = self.abi {
|
if let BackendRepr::Scalar(ref scalar) = self.backend_repr {
|
||||||
// Use a different cache for scalars because pointers to DSTs
|
// Use a different cache for scalars because pointers to DSTs
|
||||||
// can be either wide or thin (data pointers of wide pointers).
|
// can be either wide or thin (data pointers of wide pointers).
|
||||||
if let Some(&ty) = cx.scalar_types.borrow().get(&self.ty) {
|
if let Some(&ty) = cx.scalar_types.borrow().get(&self.ty) {
|
||||||
@ -261,7 +266,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> {
|
fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> {
|
||||||
if let Abi::Scalar(ref scalar) = self.abi {
|
if let BackendRepr::Scalar(ref scalar) = self.backend_repr {
|
||||||
if scalar.is_bool() {
|
if scalar.is_bool() {
|
||||||
return cx.type_i1();
|
return cx.type_i1();
|
||||||
}
|
}
|
||||||
@ -299,8 +304,8 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
|
|||||||
// This must produce the same result for `repr(transparent)` wrappers as for the inner type!
|
// This must produce the same result for `repr(transparent)` wrappers as for the inner type!
|
||||||
// In other words, this should generally not look at the type at all, but only at the
|
// In other words, this should generally not look at the type at all, but only at the
|
||||||
// layout.
|
// layout.
|
||||||
let (a, b) = match self.abi {
|
let (a, b) = match self.backend_repr {
|
||||||
Abi::ScalarPair(ref a, ref b) => (a, b),
|
BackendRepr::ScalarPair(ref a, ref b) => (a, b),
|
||||||
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
||||||
};
|
};
|
||||||
let scalar = [a, b][index];
|
let scalar = [a, b][index];
|
||||||
|
Loading…
Reference in New Issue
Block a user