]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/interpret/operand.rs
Refactor
[rust.git] / src / librustc_mir / interpret / operand.rs
index 184e2ee9516fcb08c9900c081afa10a2966b53ad..c5771e4f34378125768fa932525f704ceb8336c3 100644 (file)
@@ -335,18 +335,15 @@ pub fn read_immediate(
         }
     }
 
-    /// Read vector from operand `op`
-    pub fn read_vector(&self, op: OpTy<'tcx, M::PointerTag>)
-                       -> InterpResult<'tcx, Vec<ImmTy<'tcx, M::PointerTag>>> {
-        if let layout::Abi::Vector { count, .. } = op.layout.abi {
-            assert_ne!(count, 0);
-            let mut scalars = Vec::new();
-            for index in 0..count {
-                scalars.push(self.read_immediate(self.operand_field(op, index as _)?)?);
-            }
-            Ok(scalars)
+    /// Read vector length and element type
+    pub fn read_vector_ty(
+        &self, op: OpTy<'tcx, M::PointerTag>
+    )
+        -> (u64, &rustc::ty::TyS<'tcx>) {
+        if let layout::Abi::Vector { .. } = op.layout.abi {
+            (op.layout.ty.simd_size(*self.tcx) as _, op.layout.ty.simd_type(*self.tcx))
         } else {
-            bug!("type is not a vector: {:?}, abi: {:?}", op.layout.ty, op.layout.abi);
+            bug!("Type `{}` is not a SIMD vector type", op.layout.ty)
         }
     }