Skip to content

Commit 69a387f

Browse files
committed
remove MMX support from translator and tests
this follows upstream dropping support; see #369
1 parent 49fe598 commit 69a387f

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

c2rust-transpile/src/translator/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ impl<'c> Translation<'c> {
17421742
.resolve_decl_name(decl_id)
17431743
.unwrap();
17441744

1745-
if self.import_simd_typedef(new_name) {
1745+
if self.import_simd_typedef(new_name)? {
17461746
return Ok(ConvertedDecl::NoItem);
17471747
}
17481748

c2rust-transpile/src/translator/simd.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,16 @@ impl<'c> Translation<'c> {
7171
/// Given the name of a typedef check if its one of the SIMD types.
7272
/// This function returns `true` when the name of the type is one that
7373
/// it knows how to implement and no further translation should be done.
74-
pub fn import_simd_typedef(&self, name: &str) -> bool {
75-
match name {
74+
pub fn import_simd_typedef(&self, name: &str) -> Result<bool, TranslationError> {
75+
Ok(match name {
7676
// Public API SIMD typedefs:
7777
"__m128i" | "__m128" | "__m128d" | "__m64" | "__m256" | "__m256d" | "__m256i" => {
78-
// __m64 is still behind a feature gate
78+
// __m64 and MMX support were removed from upstream Rust.
79+
// See https://github.com/immunant/c2rust/issues/369
7980
if name == "__m64" {
80-
self.use_feature("stdsimd");
81+
Err(format_err!(
82+
"__m64 and MMX are no longer supported, due to removed upstream support. See https://github.com/immunant/c2rust/issues/369"
83+
))?;
8184
}
8285

8386
self.with_cur_file_item_store(|item_store| {
@@ -138,7 +141,7 @@ impl<'c> Translation<'c> {
138141
| "__mm_loadh_pi_v2f32"
139142
| "__mm_loadl_pi_v2f32" => true,
140143
_ => false,
141-
}
144+
})
142145
}
143146

144147
/// Determine if a particular function name is an SIMD primitive. If so an appropriate

tests/simd/src/test_x86.rs

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ macro_rules! cmp_vector_fields {
6464
impl PartialEq for ShuffleVectors {
6565
fn eq(&self, other: &ShuffleVectors) -> bool {
6666
cmp_vector_fields!(self, other: [
67+
#[cfg(target_feature = "mmx")]
6768
a: u64,
6869
b: u128,
6970
c: u128,
@@ -78,6 +79,7 @@ impl PartialEq for ShuffleVectors {
7879
j: (u128, u128),
7980
#[cfg(target_feature = "avx2")]
8081
k: (u128, u128),
82+
#[cfg(target_feature = "mmx")]
8183
l: u64,
8284
m: u128,
8385
#[cfg(target_feature = "avx2")]

tests/simd/src/x86.c

+32-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
#include <immintrin.h>
44

55
// Our travis-ci machines don't support AVX2 so we conditionally compile those bits out
6+
// Additionally, rust std::arch removed MMX support, so we conditionally compile
7+
// out uses of __m64 and MMX intrinsics pending an alternative translation
68

79
typedef struct {
10+
#ifdef MMX
811
__m64 a;
12+
#endif
913
__m128 b;
1014
__m128d c;
1115
__m256 d;
@@ -14,7 +18,9 @@ typedef struct {
1418
#ifdef __AVX2__
1519
__m256i i, j, k;
1620
#endif
21+
#ifdef MMX
1722
__m64 l;
23+
#endif
1824
__m128i m;
1925
#ifdef __AVX2__
2026
__m256i n, p, q;
@@ -44,21 +50,27 @@ void zero_init_all(void) {
4450
__m128i d;
4551
__m256d e;
4652
__m256i f;
53+
#ifdef MMX
4754
__m64 g;
55+
#endif
4856
}
4957

5058
ShuffleVectors call_all(void) {
5159
__m128 a = _mm_setr_ps(7.8, 5.6, 3.4, 1.2);
5260
__m128d b = _mm_set1_pd(4.13);
61+
#ifdef MMX
5362
__m64 c = _mm_set_pi32(1, 2);
63+
#endif
5464
__m256 d = _mm256_set1_ps(45.2);
5565
__m256d e = _mm256_set_pd(1.1, 2.2, 3.3, 4.4);
5666
__m128i f = _mm_set1_epi8(123);
5767
__m256i g = _mm256_set_epi32(14, 18, 22, 33, -11, -3, 8, 300);
5868

5969
ShuffleVectors sv = {
70+
#ifdef MMX
6071
// Actual Builtin:
6172
_mm_shuffle_pi16(c, _MM_SHUFFLE(0, 1, 2, 3)),
73+
#endif
6274

6375
// Super builtins(in clang 6, but actual in 7):
6476
_mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 2, 1, 0)),
@@ -75,7 +87,9 @@ ShuffleVectors call_all(void) {
7587
_mm256_shufflelo_epi16(g, _MM_SHUFFLE(2, 3, 2, 3)),
7688
#endif
7789
// Functions:
90+
#ifdef MMX
7891
_mm_shuffle_pi8(c, c),
92+
#endif
7993
_mm_shuffle_epi8(f, f),
8094
#ifdef __AVX2__
8195
_mm256_shuffle_epi8(g, g),
@@ -91,28 +105,36 @@ ShuffleVectors call_all(void) {
91105
ShuffleVectors call_all_used(void) {
92106
__m128 aa = _mm_setr_ps(1.2, 3.4, 5.6, 7.8);
93107
__m128d bb = _mm_set1_pd(3.14);
108+
#ifdef MMX
94109
__m64 cc = _mm_set_pi32(1, 2);
110+
#endif
95111
__m256 dd = _mm256_set1_ps(3.34);
96112
__m256d ee = _mm256_set_pd(4.4, 3.3, 2.2, 1.1);
97113
__m128i ff = _mm_set1_epi8(13);
98114
__m256i gg = _mm256_set_epi32(-12, 33, 44, 100, -44, 42, -33, -100);
99115

116+
#ifdef MMX
100117
__m64 a;
118+
#endif
101119
__m128 b;
102120
__m128d c;
103121
__m256 d;
104122
__m256d e;
105123
__m128i f, g, h, o;
106124
__m256i i, j, k;
125+
#ifdef MMX
107126
__m64 l;
127+
#endif
108128
__m128i m;
109129
__m256i n;
110130
__m256i p;
111131
__m256i q;
112132
__m128i r;
113133

134+
#ifdef MMX
114135
// Actual Builtin:
115136
a = _mm_shuffle_pi16(cc, _MM_SHUFFLE(0, 1, 2, 3));
137+
#endif
116138

117139
// Super builtins(in clang 6, but actual in 7):
118140
b = _mm_shuffle_ps(aa, aa, _MM_SHUFFLE(3, 2, 1, 0));
@@ -130,7 +152,9 @@ ShuffleVectors call_all_used(void) {
130152
o = _mm_slli_si128(g, 2);
131153

132154
// Functions:
155+
#ifdef MMX
133156
l = _mm_shuffle_pi8(cc, cc);
157+
#endif
134158
m = _mm_shuffle_epi8(ff, ff);
135159
#ifdef __AVX2__
136160
n = _mm256_shuffle_epi8(gg, gg);
@@ -140,12 +164,18 @@ ShuffleVectors call_all_used(void) {
140164
r = _mm_alignr_epi8(ff, ff, 2);
141165

142166
ShuffleVectors sv = {
143-
a, b, c, d, e, f, g, h, o,
167+
#ifdef MMX
168+
a,
169+
#endif
170+
b, c, d, e, f, g, h, o,
144171

145172
#ifdef __AVX2__
146173
i, j, k,
147174
#endif
148-
l, m,
175+
#ifdef MMX
176+
l,
177+
#endif
178+
m,
149179

150180
#ifdef __AVX2__
151181
n, p, q,

0 commit comments

Comments
 (0)