clarify PassMode::Indirect as well
This commit is contained in:
parent
90d894e122
commit
89f0d18bc8
@ -104,7 +104,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs, extra_attrs: None, on_stack } => {
|
PassMode::Indirect { attrs, meta_attrs: None, on_stack } => {
|
||||||
if on_stack {
|
if on_stack {
|
||||||
// Abi requires aligning struct size to pointer size
|
// Abi requires aligning struct size to pointer size
|
||||||
let size = self.layout.size.align_to(tcx.data_layout.pointer_align.abi);
|
let size = self.layout.size.align_to(tcx.data_layout.pointer_align.abi);
|
||||||
@ -117,11 +117,11 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
|
|||||||
smallvec![apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs)]
|
smallvec![apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs, extra_attrs: Some(extra_attrs), on_stack } => {
|
PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), on_stack } => {
|
||||||
assert!(!on_stack);
|
assert!(!on_stack);
|
||||||
smallvec![
|
smallvec![
|
||||||
apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs),
|
apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs),
|
||||||
apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), extra_attrs),
|
apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), meta_attrs),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,11 +151,11 @@ fn get_abi_return(&self, tcx: TyCtxt<'tcx>) -> (Option<AbiParam>, Vec<AbiParam>)
|
|||||||
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: _, extra_attrs: None, on_stack } => {
|
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack } => {
|
||||||
assert!(!on_stack);
|
assert!(!on_stack);
|
||||||
(Some(AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructReturn)), vec![])
|
(Some(AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructReturn)), vec![])
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ } => {
|
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
|
||||||
unreachable!("unsized return value")
|
unreachable!("unsized return value")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,11 +290,11 @@ pub(super) fn cvalue_for_param<'tcx>(
|
|||||||
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: _, extra_attrs: None, on_stack: _ } => {
|
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
|
||||||
assert_eq!(block_params.len(), 1, "{:?}", block_params);
|
assert_eq!(block_params.len(), 1, "{:?}", block_params);
|
||||||
Some(CValue::by_ref(Pointer::new(block_params[0]), arg_abi.layout))
|
Some(CValue::by_ref(Pointer::new(block_params[0]), arg_abi.layout))
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ } => {
|
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
|
||||||
assert_eq!(block_params.len(), 2, "{:?}", block_params);
|
assert_eq!(block_params.len(), 2, "{:?}", block_params);
|
||||||
Some(CValue::by_ref_unsized(
|
Some(CValue::by_ref_unsized(
|
||||||
Pointer::new(block_params[0]),
|
Pointer::new(block_params[0]),
|
||||||
|
@ -26,7 +26,7 @@ pub(super) fn codegen_return_param<'tcx>(
|
|||||||
smallvec![],
|
smallvec![],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: _ } => {
|
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
|
||||||
let ret_param = block_params_iter.next().unwrap();
|
let ret_param = block_params_iter.next().unwrap();
|
||||||
assert_eq!(fx.bcx.func.dfg.value_type(ret_param), fx.pointer_type);
|
assert_eq!(fx.bcx.func.dfg.value_type(ret_param), fx.pointer_type);
|
||||||
(
|
(
|
||||||
@ -34,7 +34,7 @@ pub(super) fn codegen_return_param<'tcx>(
|
|||||||
smallvec![ret_param],
|
smallvec![ret_param],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ } => {
|
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
|
||||||
unreachable!("unsized return value")
|
unreachable!("unsized return value")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -62,7 +62,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
|
|||||||
) {
|
) {
|
||||||
let (ret_temp_place, return_ptr) = match ret_arg_abi.mode {
|
let (ret_temp_place, return_ptr) = match ret_arg_abi.mode {
|
||||||
PassMode::Ignore => (None, None),
|
PassMode::Ignore => (None, None),
|
||||||
PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: _ } => {
|
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
|
||||||
if let Some(ret_ptr) = ret_place.try_to_ptr() {
|
if let Some(ret_ptr) = ret_place.try_to_ptr() {
|
||||||
// This is an optimization to prevent unnecessary copies of the return value when
|
// This is an optimization to prevent unnecessary copies of the return value when
|
||||||
// the return place is already a memory place as opposed to a register.
|
// the return place is already a memory place as opposed to a register.
|
||||||
@ -73,7 +73,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
|
|||||||
(Some(place), Some(place.to_ptr().get_addr(fx)))
|
(Some(place), Some(place.to_ptr().get_addr(fx)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs: _, extra_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),
|
||||||
@ -100,14 +100,14 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
|
|||||||
super::pass_mode::from_casted_value(fx, &results, ret_place.layout(), cast);
|
super::pass_mode::from_casted_value(fx, &results, ret_place.layout(), cast);
|
||||||
ret_place.write_cvalue(fx, result);
|
ret_place.write_cvalue(fx, result);
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: _ } => {
|
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
|
||||||
if let Some(ret_temp_place) = ret_temp_place {
|
if let Some(ret_temp_place) = ret_temp_place {
|
||||||
// If ret_temp_place is None, it is not necessary to copy the return value.
|
// If ret_temp_place is None, it is not necessary to copy the return value.
|
||||||
let ret_temp_value = ret_temp_place.to_cvalue(fx);
|
let ret_temp_value = ret_temp_place.to_cvalue(fx);
|
||||||
ret_place.write_cvalue(fx, ret_temp_value);
|
ret_place.write_cvalue(fx, ret_temp_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ } => {
|
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
|
||||||
unreachable!("unsized return value")
|
unreachable!("unsized return value")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,10 +116,10 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
|
|||||||
/// Codegen a return instruction with the right return value(s) if any.
|
/// Codegen a return instruction with the right return value(s) if any.
|
||||||
pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, '_>) {
|
pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, '_>) {
|
||||||
match fx.fn_abi.as_ref().unwrap().ret.mode {
|
match fx.fn_abi.as_ref().unwrap().ret.mode {
|
||||||
PassMode::Ignore | PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: _ } => {
|
PassMode::Ignore | PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
|
||||||
fx.bcx.ins().return_(&[]);
|
fx.bcx.ins().return_(&[]);
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ } => {
|
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
|
||||||
unreachable!("unsized return value")
|
unreachable!("unsized return value")
|
||||||
}
|
}
|
||||||
PassMode::Direct(_) => {
|
PassMode::Direct(_) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user