Skip to content

Commit b1af76f

Browse files
SparrowLiiAmanieu
authored andcommitted
use transmute in vceqz instructions in aarch64/neon/generated.rs
1 parent 79dfcef commit b1af76f

File tree

3 files changed

+60
-34
lines changed

3 files changed

+60
-34
lines changed

crates/core_arch/src/aarch64/neon/generated.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -78,143 +78,143 @@ pub unsafe fn vceqq_f64(a: float64x2_t, b: float64x2_t) -> uint64x2_t {
7878
#[target_feature(enable = "neon")]
7979
#[cfg_attr(test, assert_instr(vceqz))]
8080
pub unsafe fn vceqz_s8(a: int8x8_t) -> uint8x8_t {
81-
simd_eq(a, int8x8_t(0, 0, 0, 0, 0, 0, 0, 0))
81+
simd_eq(a, transmute(i8x8::new(0, 0, 0, 0, 0, 0, 0, 0)))
8282
}
8383

8484
/// Signed Compare bitwise equal to zero
8585
#[inline]
8686
#[target_feature(enable = "neon")]
8787
#[cfg_attr(test, assert_instr(vceqz))]
8888
pub unsafe fn vceqzq_s8(a: int8x16_t) -> uint8x16_t {
89-
simd_eq(a, int8x16_t(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
89+
simd_eq(a, transmute(i8x16::new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)))
9090
}
9191

9292
/// Signed Compare bitwise equal to zero
9393
#[inline]
9494
#[target_feature(enable = "neon")]
9595
#[cfg_attr(test, assert_instr(vceqz))]
9696
pub unsafe fn vceqz_s16(a: int16x4_t) -> uint16x4_t {
97-
simd_eq(a, int16x4_t(0, 0, 0, 0))
97+
simd_eq(a, transmute(i16x4::new(0, 0, 0, 0)))
9898
}
9999

100100
/// Signed Compare bitwise equal to zero
101101
#[inline]
102102
#[target_feature(enable = "neon")]
103103
#[cfg_attr(test, assert_instr(vceqz))]
104104
pub unsafe fn vceqzq_s16(a: int16x8_t) -> uint16x8_t {
105-
simd_eq(a, int16x8_t(0, 0, 0, 0, 0, 0, 0, 0))
105+
simd_eq(a, transmute(i16x8::new(0, 0, 0, 0, 0, 0, 0, 0)))
106106
}
107107

108108
/// Signed Compare bitwise equal to zero
109109
#[inline]
110110
#[target_feature(enable = "neon")]
111111
#[cfg_attr(test, assert_instr(vceqz))]
112112
pub unsafe fn vceqz_s32(a: int32x2_t) -> uint32x2_t {
113-
simd_eq(a, int32x2_t(0, 0))
113+
simd_eq(a, transmute(i32x2::new(0, 0)))
114114
}
115115

116116
/// Signed Compare bitwise equal to zero
117117
#[inline]
118118
#[target_feature(enable = "neon")]
119119
#[cfg_attr(test, assert_instr(vceqz))]
120120
pub unsafe fn vceqzq_s32(a: int32x4_t) -> uint32x4_t {
121-
simd_eq(a, int32x4_t(0, 0, 0, 0))
121+
simd_eq(a, transmute(i32x4::new(0, 0, 0, 0)))
122122
}
123123

124124
/// Signed Compare bitwise equal to zero
125125
#[inline]
126126
#[target_feature(enable = "neon")]
127127
#[cfg_attr(test, assert_instr(vceqz))]
128128
pub unsafe fn vceqz_s64(a: int64x1_t) -> uint64x1_t {
129-
simd_eq(a, int64x1_t(0))
129+
simd_eq(a, transmute(i64x1::new(0)))
130130
}
131131

132132
/// Signed Compare bitwise equal to zero
133133
#[inline]
134134
#[target_feature(enable = "neon")]
135135
#[cfg_attr(test, assert_instr(vceqz))]
136136
pub unsafe fn vceqzq_s64(a: int64x2_t) -> uint64x2_t {
137-
simd_eq(a, int64x2_t(0, 0))
137+
simd_eq(a, transmute(i64x2::new(0, 0)))
138138
}
139139

140140
/// Signed Compare bitwise equal to zero
141141
#[inline]
142142
#[target_feature(enable = "neon")]
143143
#[cfg_attr(test, assert_instr(vceqz))]
144144
pub unsafe fn vceqz_p64(a: poly64x1_t) -> uint64x1_t {
145-
simd_eq(a, poly64x1_t(0))
145+
simd_eq(a, transmute(i64x1::new(0)))
146146
}
147147

148148
/// Signed Compare bitwise equal to zero
149149
#[inline]
150150
#[target_feature(enable = "neon")]
151151
#[cfg_attr(test, assert_instr(vceqz))]
152152
pub unsafe fn vceqzq_p64(a: poly64x2_t) -> uint64x2_t {
153-
simd_eq(a, poly64x2_t(0, 0))
153+
simd_eq(a, transmute(i64x2::new(0, 0)))
154154
}
155155

156156
/// Unsigned Compare bitwise equal to zero
157157
#[inline]
158158
#[target_feature(enable = "neon")]
159159
#[cfg_attr(test, assert_instr(vceqz))]
160160
pub unsafe fn vceqz_u8(a: uint8x8_t) -> uint8x8_t {
161-
simd_eq(a, uint8x8_t(0, 0, 0, 0, 0, 0, 0, 0))
161+
simd_eq(a, transmute(u8x8::new(0, 0, 0, 0, 0, 0, 0, 0)))
162162
}
163163

164164
/// Unsigned Compare bitwise equal to zero
165165
#[inline]
166166
#[target_feature(enable = "neon")]
167167
#[cfg_attr(test, assert_instr(vceqz))]
168168
pub unsafe fn vceqzq_u8(a: uint8x16_t) -> uint8x16_t {
169-
simd_eq(a, uint8x16_t(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
169+
simd_eq(a, transmute(u8x16::new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)))
170170
}
171171

172172
/// Unsigned Compare bitwise equal to zero
173173
#[inline]
174174
#[target_feature(enable = "neon")]
175175
#[cfg_attr(test, assert_instr(vceqz))]
176176
pub unsafe fn vceqz_u16(a: uint16x4_t) -> uint16x4_t {
177-
simd_eq(a, uint16x4_t(0, 0, 0, 0))
177+
simd_eq(a, transmute(u16x4::new(0, 0, 0, 0)))
178178
}
179179

180180
/// Unsigned Compare bitwise equal to zero
181181
#[inline]
182182
#[target_feature(enable = "neon")]
183183
#[cfg_attr(test, assert_instr(vceqz))]
184184
pub unsafe fn vceqzq_u16(a: uint16x8_t) -> uint16x8_t {
185-
simd_eq(a, uint16x8_t(0, 0, 0, 0, 0, 0, 0, 0))
185+
simd_eq(a, transmute(u16x8::new(0, 0, 0, 0, 0, 0, 0, 0)))
186186
}
187187

188188
/// Unsigned Compare bitwise equal to zero
189189
#[inline]
190190
#[target_feature(enable = "neon")]
191191
#[cfg_attr(test, assert_instr(vceqz))]
192192
pub unsafe fn vceqz_u32(a: uint32x2_t) -> uint32x2_t {
193-
simd_eq(a, uint32x2_t(0, 0))
193+
simd_eq(a, transmute(u32x2::new(0, 0)))
194194
}
195195

196196
/// Unsigned Compare bitwise equal to zero
197197
#[inline]
198198
#[target_feature(enable = "neon")]
199199
#[cfg_attr(test, assert_instr(vceqz))]
200200
pub unsafe fn vceqzq_u32(a: uint32x4_t) -> uint32x4_t {
201-
simd_eq(a, uint32x4_t(0, 0, 0, 0))
201+
simd_eq(a, transmute(u32x4::new(0, 0, 0, 0)))
202202
}
203203

204204
/// Unsigned Compare bitwise equal to zero
205205
#[inline]
206206
#[target_feature(enable = "neon")]
207207
#[cfg_attr(test, assert_instr(vceqz))]
208208
pub unsafe fn vceqz_u64(a: uint64x1_t) -> uint64x1_t {
209-
simd_eq(a, uint64x1_t(0))
209+
simd_eq(a, transmute(u64x1::new(0)))
210210
}
211211

212212
/// Unsigned Compare bitwise equal to zero
213213
#[inline]
214214
#[target_feature(enable = "neon")]
215215
#[cfg_attr(test, assert_instr(vceqz))]
216216
pub unsafe fn vceqzq_u64(a: uint64x2_t) -> uint64x2_t {
217-
simd_eq(a, uint64x2_t(0, 0))
217+
simd_eq(a, transmute(u64x2::new(0, 0)))
218218
}
219219

220220
/// Compare signed greater than

crates/core_arch/src/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,13 @@ macro_rules! constify_imm3 {
426426
macro_rules! types {
427427
($(
428428
$(#[$doc:meta])*
429-
pub struct $name:ident($field:ty$(, $fields:ty)*$(,)?);
429+
pub struct $name:ident($($fields:tt)*);
430430
)*) => ($(
431431
$(#[$doc])*
432432
#[derive(Copy, Clone, Debug)]
433433
#[allow(non_camel_case_types)]
434434
#[repr(simd)]
435435
#[allow(clippy::missing_inline_in_public_items)]
436-
pub struct $name(pub $field$(, pub $fields)*);
436+
pub struct $name($($fields)*);
437437
)*)
438438
}

crates/stdarch-gen/src/main.rs

+40-14
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ fn gen_aarch64(
299299
in_t: &str,
300300
out_t: &str,
301301
current_tests: &[(Vec<String>, Vec<String>, Vec<String>)],
302-
has_b: bool,
302+
single_para: bool,
303303
fixed: &Option<String>,
304304
) -> (String, String) {
305305
let _global_t = type_to_global_type(in_t);
@@ -335,7 +335,7 @@ fn gen_aarch64(
335335
} else {
336336
String::new()
337337
};
338-
let call = if has_b {
338+
let call = if !single_para {
339339
format!(
340340
r#"pub unsafe fn {}(a: {}, b: {}) -> {} {{
341341
{}{}(a, b)
@@ -350,9 +350,15 @@ fn gen_aarch64(
350350
}
351351
format!(
352352
r#"pub unsafe fn {}(a: {}) -> {} {{
353-
{}{}(a, {}({}))
353+
{}{}(a, transmute({}::new({})))
354354
}}"#,
355-
name, in_t, out_t, ext_c, current_fn, in_t, fixed_vals,
355+
name,
356+
in_t,
357+
out_t,
358+
ext_c,
359+
current_fn,
360+
type_to_global_type(in_t),
361+
fixed_vals,
356362
)
357363
} else {
358364
String::new()
@@ -368,7 +374,14 @@ fn gen_aarch64(
368374
current_comment, current_aarch64, call
369375
);
370376

371-
let test = gen_test(name, &in_t, &out_t, current_tests, type_len(in_t), has_b);
377+
let test = gen_test(
378+
name,
379+
&in_t,
380+
&out_t,
381+
current_tests,
382+
type_len(in_t),
383+
single_para,
384+
);
372385
(function, test)
373386
}
374387

@@ -378,7 +391,7 @@ fn gen_test(
378391
out_t: &str,
379392
current_tests: &[(Vec<String>, Vec<String>, Vec<String>)],
380393
len: usize,
381-
has_b: bool,
394+
single_para: bool,
382395
) -> String {
383396
let mut test = format!(
384397
r#"
@@ -390,7 +403,7 @@ fn gen_test(
390403
let a: Vec<String> = a.iter().take(len).cloned().collect();
391404
let b: Vec<String> = b.iter().take(len).cloned().collect();
392405
let e: Vec<String> = e.iter().take(len).cloned().collect();
393-
let t = if has_b {
406+
let t = if !single_para {
394407
format!(
395408
r#"
396409
let a{};
@@ -437,7 +450,7 @@ fn gen_arm(
437450
in_t: &str,
438451
out_t: &str,
439452
current_tests: &[(Vec<String>, Vec<String>, Vec<String>)],
440-
has_b: bool,
453+
single_para: bool,
441454
fixed: &Option<String>,
442455
) -> (String, String) {
443456
let _global_t = type_to_global_type(in_t);
@@ -486,7 +499,7 @@ fn gen_arm(
486499
} else {
487500
String::new()
488501
};
489-
let call = if has_b {
502+
let call = if !single_para {
490503
format!(
491504
r#"pub unsafe fn {}(a: {}, b: {}) -> {} {{
492505
{}{}(a, b)
@@ -501,9 +514,15 @@ fn gen_arm(
501514
}
502515
format!(
503516
r#"pub unsafe fn {}(a: {}) -> {} {{
504-
{}{}(a, {}({}))
517+
{}{}(a, transmute({}::new({})))
505518
}}"#,
506-
name, in_t, out_t, ext_c, current_fn, in_t, fixed_vals,
519+
name,
520+
in_t,
521+
out_t,
522+
ext_c,
523+
current_fn,
524+
type_to_global_type(in_t),
525+
fixed_vals,
507526
)
508527
} else {
509528
String::new()
@@ -523,7 +542,14 @@ fn gen_arm(
523542
expand_intrinsic(&current_aarch64, in_t),
524543
call,
525544
);
526-
let test = gen_test(name, &in_t, &out_t, current_tests, type_len(in_t), has_b);
545+
let test = gen_test(
546+
name,
547+
&in_t,
548+
&out_t,
549+
current_tests,
550+
type_len(in_t),
551+
single_para,
552+
);
527553

528554
(function, test)
529555
}
@@ -752,7 +778,7 @@ mod test {
752778
&in_t,
753779
&out_t,
754780
&current_tests,
755-
b.len() > 0,
781+
b.len() == 0,
756782
&fixed,
757783
);
758784
out_arm.push_str(&function);
@@ -767,7 +793,7 @@ mod test {
767793
&in_t,
768794
&out_t,
769795
&current_tests,
770-
b.len() > 0,
796+
b.len() == 0,
771797
&fixed,
772798
);
773799
out_aarch64.push_str(&function);

0 commit comments

Comments
 (0)