Use PassMode::ByVal for Abi::Vector

This commit is contained in:
bjorn3 2020-03-28 15:33:50 +01:00
parent 08fc673190
commit 67028cee51
2 changed files with 8 additions and 2 deletions

View File

@ -100,7 +100,13 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>)
}
// FIXME implement Vector Abi in a cg_llvm compatible way
Abi::Vector { .. } => PassMode::ByRef { size: Some(layout.size) },
Abi::Vector { .. } => {
if let Some(vector_ty) = crate::intrinsics::clif_vector_type(tcx, layout) {
PassMode::ByVal(vector_ty)
} else {
PassMode::ByRef { size: Some(layout.size) }
}
}
Abi::Aggregate { sized: true } => PassMode::ByRef { size: Some(layout.size) },
Abi::Aggregate { sized: false } => PassMode::ByRef { size: None },

View File

@ -175,7 +175,7 @@ fn lane_type_and_count<'tcx>(
(lane_layout, lane_count)
}
fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Option<Type> {
pub(crate) fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Option<Type> {
let (element, count) = match &layout.abi {
Abi::Vector { element, count } => (element.clone(), *count),
_ => unreachable!(),