Skip to content

Commit f8e846d

Browse files
committed
Add load_vector function
1 parent dadfbea commit f8e846d

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/common.rs

-8
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,6 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<types:
6666
}
6767
}
6868
ty::Param(_) => bug!("ty param {:?}", ty),
69-
_ if ty.is_simd() => {
70-
let (lane_type, lane_count) = crate::intrinsics::lane_type_and_count(
71-
tcx,
72-
tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(),
73-
);
74-
let lane_type = clif_type_from_ty(tcx, lane_type.ty)?;
75-
return lane_type.by(u16::try_from(lane_count).unwrap());
76-
}
7769
_ => return None,
7870
})
7971
}

src/value_and_place.rs

+18
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ impl<'tcx> CValue<'tcx> {
161161
}
162162
}
163163

164+
/// Load a value with layout.abi of vector
165+
pub fn load_vector<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value {
166+
let layout = self.1;
167+
match self.0 {
168+
CValueInner::ByRef(ptr) => {
169+
let clif_ty = match layout.abi {
170+
layout::Abi::Vector { ref element, count } => {
171+
scalar_to_clif_type(fx.tcx, element.clone()).by(u16::try_from(count).unwrap()).unwrap()
172+
}
173+
_ => unreachable!(),
174+
};
175+
ptr.load(fx, clif_ty, MemFlags::new())
176+
}
177+
CValueInner::ByVal(value) => value,
178+
CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"),
179+
}
180+
}
181+
164182
pub fn value_field<'a>(
165183
self,
166184
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,

0 commit comments

Comments
 (0)