From f8e846dee0cfc0de4a30605df6611855721ca537 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 16:48:19 +0100 Subject: [PATCH] Add load_vector function --- src/common.rs | 8 -------- src/value_and_place.rs | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/common.rs b/src/common.rs index 6bef21afff2..b14e8af79a8 100644 --- a/src/common.rs +++ b/src/common.rs @@ -66,14 +66,6 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option bug!("ty param {:?}", ty), - _ if ty.is_simd() => { - let (lane_type, lane_count) = crate::intrinsics::lane_type_and_count( - tcx, - tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(), - ); - let lane_type = clif_type_from_ty(tcx, lane_type.ty)?; - return lane_type.by(u16::try_from(lane_count).unwrap()); - } _ => return None, }) } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 5ae1e9b06af..1d6e55b9137 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -161,6 +161,24 @@ impl<'tcx> CValue<'tcx> { } } + /// Load a value with layout.abi of vector + pub fn load_vector<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { + let layout = self.1; + match self.0 { + CValueInner::ByRef(ptr) => { + let clif_ty = match layout.abi { + layout::Abi::Vector { ref element, count } => { + scalar_to_clif_type(fx.tcx, element.clone()).by(u16::try_from(count).unwrap()).unwrap() + } + _ => unreachable!(), + }; + ptr.load(fx, clif_ty, MemFlags::new()) + } + CValueInner::ByVal(value) => value, + CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"), + } + } + pub fn value_field<'a>( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>,