mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +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)
|
||||
} else if place.layout.is_gcc_immediate() {
|
||||
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);
|
||||
}
|
||||
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 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 => {
|
||||
use rustc_target::abi::Abi::*;
|
||||
use rustc_abi::BackendRepr::*;
|
||||
let tp_ty = fn_args.type_at(0);
|
||||
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,
|
||||
Uninhabited | Vector { .. } => false,
|
||||
Aggregate { .. } => {
|
||||
Memory { .. } => {
|
||||
// For rusty ABIs, small aggregates are actually passed
|
||||
// as `RegKind::Integer` (see `FnAbi::adjust_for_abi`),
|
||||
// so we re-use that same threshold here.
|
||||
|
@ -3,7 +3,7 @@ use std::fmt::Write;
|
||||
use gccjit::{Struct, Type};
|
||||
use rustc_abi as abi;
|
||||
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::{
|
||||
BaseTypeCodegenMethods, DerivedTypeCodegenMethods, LayoutTypeCodegenMethods,
|
||||
};
|
||||
@ -60,9 +60,9 @@ fn uncached_gcc_type<'gcc, 'tcx>(
|
||||
layout: TyAndLayout<'tcx>,
|
||||
defer: &mut Option<(Struct<'gcc>, TyAndLayout<'tcx>)>,
|
||||
) -> Type<'gcc> {
|
||||
match layout.abi {
|
||||
Abi::Scalar(_) => bug!("handled elsewhere"),
|
||||
Abi::Vector { ref element, count } => {
|
||||
match layout.backend_repr {
|
||||
BackendRepr::Scalar(_) => bug!("handled elsewhere"),
|
||||
BackendRepr::Vector { ref element, count } => {
|
||||
let element = layout.scalar_gcc_type_at(cx, element, Size::ZERO);
|
||||
let element =
|
||||
// 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);
|
||||
}
|
||||
Abi::ScalarPair(..) => {
|
||||
BackendRepr::ScalarPair(..) => {
|
||||
return cx.type_struct(
|
||||
&[
|
||||
layout.scalar_pair_element_gcc_type(cx, 0),
|
||||
@ -83,7 +83,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(
|
||||
false,
|
||||
);
|
||||
}
|
||||
Abi::Uninhabited | Abi::Aggregate { .. } => {}
|
||||
BackendRepr::Uninhabited | BackendRepr::Memory { .. } => {}
|
||||
}
|
||||
|
||||
let name = match *layout.ty.kind() {
|
||||
@ -176,16 +176,21 @@ pub trait LayoutGccExt<'tcx> {
|
||||
|
||||
impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
|
||||
fn is_gcc_immediate(&self) -> bool {
|
||||
match self.abi {
|
||||
Abi::Scalar(_) | Abi::Vector { .. } => true,
|
||||
Abi::ScalarPair(..) | Abi::Uninhabited | Abi::Aggregate { .. } => false,
|
||||
match self.backend_repr {
|
||||
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true,
|
||||
BackendRepr::ScalarPair(..) | BackendRepr::Uninhabited | BackendRepr::Memory { .. } => {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_gcc_scalar_pair(&self) -> bool {
|
||||
match self.abi {
|
||||
Abi::ScalarPair(..) => true,
|
||||
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } | Abi::Aggregate { .. } => false,
|
||||
match self.backend_repr {
|
||||
BackendRepr::ScalarPair(..) => true,
|
||||
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!
|
||||
// In other words, this should generally not look at the type at all, but only at the
|
||||
// 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
|
||||
// can be either wide or thin (data pointers of wide pointers).
|
||||
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> {
|
||||
if let Abi::Scalar(ref scalar) = self.abi {
|
||||
if let BackendRepr::Scalar(ref scalar) = self.backend_repr {
|
||||
if scalar.is_bool() {
|
||||
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!
|
||||
// In other words, this should generally not look at the type at all, but only at the
|
||||
// layout.
|
||||
let (a, b) = match self.abi {
|
||||
Abi::ScalarPair(ref a, ref b) => (a, b),
|
||||
let (a, b) = match self.backend_repr {
|
||||
BackendRepr::ScalarPair(ref a, ref b) => (a, b),
|
||||
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
||||
};
|
||||
let scalar = [a, b][index];
|
||||
|
Loading…
Reference in New Issue
Block a user