diff --git a/c2rust-transpile/src/translator/mod.rs b/c2rust-transpile/src/translator/mod.rs index 860f0621bc..f3a445a502 100644 --- a/c2rust-transpile/src/translator/mod.rs +++ b/c2rust-transpile/src/translator/mod.rs @@ -4589,7 +4589,7 @@ impl<'c> Translation<'c> { .implicit_default_expr(inner, is_static)? .map(|val| vec_expr(val, count))) } else if let &CTypeKind::Vector(CQualTypeId { ctype, .. }, len) = resolved_ty { - self.implicit_vector_default(ctype, len, is_static) + self.implicit_vector_default(ctype, len, is_static).map_err(Into::into) } else { Err(format_err!("Unsupported default initializer: {:?}", resolved_ty).into()) } diff --git a/c2rust-transpile/src/translator/simd.rs b/c2rust-transpile/src/translator/simd.rs index 4a4e60134c..bcd1b444af 100644 --- a/c2rust-transpile/src/translator/simd.rs +++ b/c2rust-transpile/src/translator/simd.rs @@ -1,30 +1,30 @@ #![deny(missing_docs)] //! This module provides translation for SIMD operations and expressions. -use super::*; +use failure::bail; use crate::c_ast::BinOp::{Add, BitAnd, ShiftRight}; +use crate::c_ast::CastKind::{BitCast, IntegralCast}; use crate::c_ast::CExprKind::{Binary, Call, Conditional, ExplicitCast, ImplicitCast, Literal}; use crate::c_ast::CLiteral::Integer; use crate::c_ast::CTypeKind::{Char, Double, Float, Int, LongLong, Short}; -use crate::c_ast::CastKind::{BitCast, IntegralCast}; -/// As of rustc 1.29, rust is known to be missing some SIMD functions. +use super::*; + +/// As of rustc 1.58, rust is known to be missing some SIMD functions. /// See https://github.com/rust-lang-nursery/stdsimd/issues/579 -static MISSING_SIMD_FUNCTIONS: [&str; 36] = [ +static MISSING_SIMD_FUNCTIONS: &[&str] = &[ "_mm_and_si64", "_mm_andnot_si64", "_mm_cmpeq_pi16", "_mm_cmpeq_pi32", "_mm_cmpeq_pi8", "_mm_cvtm64_si64", - "_mm_cvtph_ps", "_mm_cvtsi32_si64", "_mm_cvtsi64_m64", "_mm_cvtsi64_si32", "_mm_empty", "_mm_free", - "_mm_loadu_si64", "_mm_madd_pi16", "_mm_malloc", "_mm_mulhi_pi16", @@ -173,12 +173,8 @@ impl<'c> Translation<'c> { ))?; } - // The majority of x86/64 SIMD is stable, however there are still some - // bits that are behind a feature gate. - self.use_feature("stdsimd"); - self.with_cur_file_item_store(|item_store| { - let std_or_core = if self.tcfg.emit_no_std { "core" } else { "std" }.to_string(); + let std_or_core = if self.tcfg.emit_no_std { "core" } else { "std" }; // REVIEW: Also a linear lookup if !SIMD_X86_64_ONLY.contains(&name) { @@ -193,7 +189,7 @@ impl<'c> Translation<'c> { .pub_(); item_store.add_use_with_attr( - vec![std_or_core.clone(), "arch".into(), "x86".into()], + vec![std_or_core.to_owned(), "arch".into(), "x86".into()], name, x86_attr, ); @@ -212,7 +208,7 @@ impl<'c> Translation<'c> { .pub_(); item_store.add_use_with_attr( - vec![std_or_core, "arch".into(), "x86_64".into()], + vec![std_or_core.to_owned(), "arch".into(), "x86_64".into()], name, x86_64_attr, ); @@ -286,7 +282,7 @@ impl<'c> Translation<'c> { ctype: CTypeId, len: usize, is_static: bool, - ) -> Result>, TranslationError> { + ) -> Result>, failure::Error> { // NOTE: This is only for x86/_64, and so support for other architectures // might need some sort of disambiguation to be exported let (fn_name, bytes) = match (&self.ast_context[ctype].kind, len) { @@ -296,17 +292,10 @@ impl<'c> Translation<'c> { (Double, 4) => ("_mm256_setzero_pd", 32), (Char, 16) | (Int, 4) | (LongLong, 2) => ("_mm_setzero_si128", 16), (Char, 32) | (Int, 8) | (LongLong, 4) => ("_mm256_setzero_si256", 32), - (Char, 8) | (Int, 2) | (LongLong, 1) => { - // __m64 is still unstable as of rust 1.29 - self.use_feature("stdsimd"); - - ("_mm_setzero_si64", 8) - } - (kind, len) => Err(format_err!( - "Unsupported vector default initializer: {:?} x {}", - kind, - len - ))?, + (Char, 8) | (Int, 2) | (LongLong, 1) => + bail!("__m64 and MMX are no longer supported, due to removed upstream support. See https://github.com/immunant/c2rust/issues/369"), + (kind, len) => + bail!("Unsupported vector default initializer: {:?} x {}", kind, len), }; if is_static {