fix gcc, cranelift build

This commit is contained in:
Ralf Jung 2023-09-09 09:23:56 +02:00
parent 89139d4c46
commit 29a4b7b971
4 changed files with 14 additions and 14 deletions

View File

@ -100,7 +100,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
} }
_ => unreachable!("{:?}", self.layout.abi), _ => unreachable!("{:?}", self.layout.abi),
}, },
PassMode::Cast(ref cast, pad_i32) => { PassMode::Cast { ref cast, pad_i32 } => {
assert!(!pad_i32, "padding support not yet implemented"); assert!(!pad_i32, "padding support not yet implemented");
cast_target_to_abi_params(cast) cast_target_to_abi_params(cast)
} }
@ -148,7 +148,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
} }
_ => unreachable!("{:?}", self.layout.abi), _ => unreachable!("{:?}", self.layout.abi),
}, },
PassMode::Cast(ref cast, _) => { PassMode::Cast { ref cast, .. } => {
(None, cast_target_to_abi_params(cast).into_iter().collect()) (None, cast_target_to_abi_params(cast).into_iter().collect())
} }
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack } => { PassMode::Indirect { attrs: _, meta_attrs: None, on_stack } => {
@ -229,7 +229,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>(
let (a, b) = arg.load_scalar_pair(fx); let (a, b) = arg.load_scalar_pair(fx);
smallvec![a, b] smallvec![a, b]
} }
PassMode::Cast(ref cast, _) => to_casted_value(fx, arg, cast), PassMode::Cast { ref cast, .. } => to_casted_value(fx, arg, cast),
PassMode::Indirect { .. } => { PassMode::Indirect { .. } => {
if is_owned { if is_owned {
match arg.force_stack(fx) { match arg.force_stack(fx) {
@ -287,7 +287,7 @@ pub(super) fn cvalue_for_param<'tcx>(
assert_eq!(block_params.len(), 2, "{:?}", block_params); assert_eq!(block_params.len(), 2, "{:?}", block_params);
Some(CValue::by_val_pair(block_params[0], block_params[1], arg_abi.layout)) Some(CValue::by_val_pair(block_params[0], block_params[1], arg_abi.layout))
} }
PassMode::Cast(ref cast, _) => { PassMode::Cast { ref cast, .. } => {
Some(from_casted_value(fx, &block_params, arg_abi.layout, cast)) Some(from_casted_value(fx, &block_params, arg_abi.layout, cast))
} }
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => { PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {

View File

@ -13,7 +13,7 @@ pub(super) fn codegen_return_param<'tcx>(
block_params_iter: &mut impl Iterator<Item = Value>, block_params_iter: &mut impl Iterator<Item = Value>,
) -> CPlace<'tcx> { ) -> CPlace<'tcx> {
let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.as_ref().unwrap().ret.mode { let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.as_ref().unwrap().ret.mode {
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast(..) => { PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast { .. } => {
let is_ssa = let is_ssa =
ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.as_ref().unwrap().ret.layout.ty); ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.as_ref().unwrap().ret.layout.ty);
( (
@ -76,7 +76,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => { PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
unreachable!("unsized return value") unreachable!("unsized return value")
} }
PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast(..) => (None, None), PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast { .. } => (None, None),
}; };
let call_inst = f(fx, return_ptr); let call_inst = f(fx, return_ptr);
@ -93,7 +93,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
ret_place ret_place
.write_cvalue(fx, CValue::by_val_pair(ret_val_a, ret_val_b, ret_arg_abi.layout)); .write_cvalue(fx, CValue::by_val_pair(ret_val_a, ret_val_b, ret_arg_abi.layout));
} }
PassMode::Cast(ref cast, _) => { PassMode::Cast { ref cast, .. } => {
let results = let results =
fx.bcx.inst_results(call_inst).iter().copied().collect::<SmallVec<[Value; 2]>>(); fx.bcx.inst_results(call_inst).iter().copied().collect::<SmallVec<[Value; 2]>>();
let result = let result =
@ -132,7 +132,7 @@ pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, '_>) {
let (ret_val_a, ret_val_b) = place.to_cvalue(fx).load_scalar_pair(fx); let (ret_val_a, ret_val_b) = place.to_cvalue(fx).load_scalar_pair(fx);
fx.bcx.ins().return_(&[ret_val_a, ret_val_b]); fx.bcx.ins().return_(&[ret_val_a, ret_val_b]);
} }
PassMode::Cast(ref cast, _) => { PassMode::Cast { ref cast, .. } => {
let place = fx.get_local_place(RETURN_PLACE); let place = fx.get_local_place(RETURN_PLACE);
let ret_val = place.to_cvalue(fx); let ret_val = place.to_cvalue(fx);
let ret_vals = super::pass_mode::to_casted_value(fx, ret_val, cast); let ret_vals = super::pass_mode::to_casted_value(fx, ret_val, cast);

View File

@ -113,7 +113,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
match self.ret.mode { match self.ret.mode {
PassMode::Ignore => cx.type_void(), PassMode::Ignore => cx.type_void(),
PassMode::Direct(_) | PassMode::Pair(..) => self.ret.layout.immediate_gcc_type(cx), PassMode::Direct(_) | PassMode::Pair(..) => self.ret.layout.immediate_gcc_type(cx),
PassMode::Cast(ref cast, _) => cast.gcc_type(cx), PassMode::Cast { ref cast, .. } => cast.gcc_type(cx),
PassMode::Indirect { .. } => { PassMode::Indirect { .. } => {
argument_tys.push(cx.type_ptr_to(self.ret.memory_ty(cx))); argument_tys.push(cx.type_ptr_to(self.ret.memory_ty(cx)));
cx.type_void() cx.type_void()
@ -132,7 +132,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
PassMode::Indirect { meta_attrs: Some(_), .. } => { PassMode::Indirect { meta_attrs: Some(_), .. } => {
unimplemented!(); unimplemented!();
} }
PassMode::Cast(ref cast, pad_i32) => { PassMode::Cast { ref cast, pad_i32 } => {
// add padding // add padding
if pad_i32 { if pad_i32 {
argument_tys.push(Reg::i32().gcc_type(cx)); argument_tys.push(Reg::i32().gcc_type(cx));

View File

@ -144,7 +144,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
sym::volatile_load | sym::unaligned_volatile_load => { sym::volatile_load | sym::unaligned_volatile_load => {
let tp_ty = fn_args.type_at(0); let tp_ty = fn_args.type_at(0);
let mut ptr = args[0].immediate(); let mut ptr = args[0].immediate();
if let PassMode::Cast(ty, _) = &fn_abi.ret.mode { if let PassMode::Cast { cast: ty, .. } = &fn_abi.ret.mode {
ptr = self.pointercast(ptr, self.type_ptr_to(ty.gcc_type(self))); ptr = self.pointercast(ptr, self.type_ptr_to(ty.gcc_type(self)));
} }
let load = self.volatile_load(ptr.get_type(), ptr); let load = self.volatile_load(ptr.get_type(), ptr);
@ -353,7 +353,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
}; };
if !fn_abi.ret.is_ignore() { if !fn_abi.ret.is_ignore() {
if let PassMode::Cast(ty, _) = &fn_abi.ret.mode { if let PassMode::Cast { cast: ty, .. } = &fn_abi.ret.mode {
let ptr_llty = self.type_ptr_to(ty.gcc_type(self)); let ptr_llty = self.type_ptr_to(ty.gcc_type(self));
let ptr = self.pointercast(result.llval, ptr_llty); let ptr = self.pointercast(result.llval, ptr_llty);
self.store(llval, ptr, result.align); self.store(llval, ptr, result.align);
@ -449,7 +449,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
else if self.is_unsized_indirect() { else if self.is_unsized_indirect() {
bug!("unsized `ArgAbi` must be handled through `store_fn_arg`"); bug!("unsized `ArgAbi` must be handled through `store_fn_arg`");
} }
else if let PassMode::Cast(ref cast, _) = self.mode { else if let PassMode::Cast { ref cast, .. } = self.mode {
// FIXME(eddyb): Figure out when the simpler Store is safe, clang // FIXME(eddyb): Figure out when the simpler Store is safe, clang
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}. // uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
let can_store_through_cast_ptr = false; let can_store_through_cast_ptr = false;
@ -514,7 +514,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
PassMode::Indirect { meta_attrs: Some(_), .. } => { PassMode::Indirect { meta_attrs: Some(_), .. } => {
OperandValue::Ref(next(), Some(next()), self.layout.align.abi).store(bx, dst); OperandValue::Ref(next(), Some(next()), self.layout.align.abi).store(bx, dst);
}, },
PassMode::Direct(_) | PassMode::Indirect { meta_attrs: None, .. } | PassMode::Cast(..) => { PassMode::Direct(_) | PassMode::Indirect { meta_attrs: None, .. } | PassMode::Cast { .. } => {
let next_arg = next(); let next_arg = next();
self.store(bx, next_arg, dst); self.store(bx, next_arg, dst);
}, },