Skip to content

Commit cee53b6

Browse files
authored
Support _p8 type in stdarch-gen (#1070)
1 parent fc199fe commit cee53b6

File tree

4 files changed

+137
-3
lines changed

4 files changed

+137
-3
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,24 @@ pub unsafe fn vceqzq_s64(a: int64x2_t) -> uint64x2_t {
171171
simd_eq(a, transmute(b))
172172
}
173173

174+
/// Signed compare bitwise equal to zero
175+
#[inline]
176+
#[target_feature(enable = "neon")]
177+
#[cfg_attr(test, assert_instr(cmeq))]
178+
pub unsafe fn vceqz_p8(a: poly8x8_t) -> uint8x8_t {
179+
let b: i8x8 = i8x8::new(0, 0, 0, 0, 0, 0, 0, 0);
180+
simd_eq(a, transmute(b))
181+
}
182+
183+
/// Signed compare bitwise equal to zero
184+
#[inline]
185+
#[target_feature(enable = "neon")]
186+
#[cfg_attr(test, assert_instr(cmeq))]
187+
pub unsafe fn vceqzq_p8(a: poly8x16_t) -> uint8x16_t {
188+
let b: i8x16 = i8x16::new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
189+
simd_eq(a, transmute(b))
190+
}
191+
174192
/// Signed compare bitwise equal to zero
175193
#[inline]
176194
#[target_feature(enable = "neon")]
@@ -1278,6 +1296,22 @@ mod test {
12781296
assert_eq!(r, e);
12791297
}
12801298

1299+
#[simd_test(enable = "neon")]
1300+
unsafe fn test_vceqz_p8() {
1301+
let a: i8x8 = i8x8::new(-128, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06);
1302+
let e: u8x8 = u8x8::new(0, 0xFF, 0, 0, 0, 0, 0, 0);
1303+
let r: u8x8 = transmute(vceqz_p8(transmute(a)));
1304+
assert_eq!(r, e);
1305+
}
1306+
1307+
#[simd_test(enable = "neon")]
1308+
unsafe fn test_vceqzq_p8() {
1309+
let a: i8x16 = i8x16::new(-128, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x7F);
1310+
let e: u8x16 = u8x16::new(0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1311+
let r: u8x16 = transmute(vceqzq_p8(transmute(a)));
1312+
assert_eq!(r, e);
1313+
}
1314+
12811315
#[simd_test(enable = "neon")]
12821316
unsafe fn test_vceqz_p64() {
12831317
let a: i64x1 = i64x1::new(-9223372036854775808);

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

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,26 @@ pub unsafe fn vceqq_s32(a: int32x4_t, b: int32x4_t) -> uint32x4_t {
833833
simd_eq(a, b)
834834
}
835835

836+
/// Compare bitwise Equal (vector)
837+
#[inline]
838+
#[target_feature(enable = "neon")]
839+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
840+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vceq.i8"))]
841+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(cmeq))]
842+
pub unsafe fn vceq_p8(a: poly8x8_t, b: poly8x8_t) -> uint8x8_t {
843+
simd_eq(a, b)
844+
}
845+
846+
/// Compare bitwise Equal (vector)
847+
#[inline]
848+
#[target_feature(enable = "neon")]
849+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
850+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vceq.i8"))]
851+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(cmeq))]
852+
pub unsafe fn vceqq_p8(a: poly8x16_t, b: poly8x16_t) -> uint8x16_t {
853+
simd_eq(a, b)
854+
}
855+
836856
/// Floating-point compare equal
837857
#[inline]
838858
#[target_feature(enable = "neon")]
@@ -925,6 +945,30 @@ pub unsafe fn vtstq_s32(a: int32x4_t, b: int32x4_t) -> uint32x4_t {
925945
simd_ne(c, transmute(d))
926946
}
927947

948+
/// Signed compare bitwise Test bits nonzero
949+
#[inline]
950+
#[target_feature(enable = "neon")]
951+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
952+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vtst))]
953+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(cmtst))]
954+
pub unsafe fn vtst_p8(a: poly8x8_t, b: poly8x8_t) -> uint8x8_t {
955+
let c: poly8x8_t = simd_and(a, b);
956+
let d: i8x8 = i8x8::new(0, 0, 0, 0, 0, 0, 0, 0);
957+
simd_ne(c, transmute(d))
958+
}
959+
960+
/// Signed compare bitwise Test bits nonzero
961+
#[inline]
962+
#[target_feature(enable = "neon")]
963+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
964+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vtst))]
965+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(cmtst))]
966+
pub unsafe fn vtstq_p8(a: poly8x16_t, b: poly8x16_t) -> uint8x16_t {
967+
let c: poly8x16_t = simd_and(a, b);
968+
let d: i8x16 = i8x16::new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
969+
simd_ne(c, transmute(d))
970+
}
971+
928972
/// Unsigned compare bitwise Test bits nonzero
929973
#[inline]
930974
#[target_feature(enable = "neon")]
@@ -4147,6 +4191,36 @@ mod test {
41474191
assert_eq!(r, e);
41484192
}
41494193

4194+
#[simd_test(enable = "neon")]
4195+
unsafe fn test_vceq_p8() {
4196+
let a: i8x8 = i8x8::new(-128, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);
4197+
let b: i8x8 = i8x8::new(-128, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);
4198+
let e: u8x8 = u8x8::new(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
4199+
let r: u8x8 = transmute(vceq_p8(transmute(a), transmute(b)));
4200+
assert_eq!(r, e);
4201+
4202+
let a: i8x8 = i8x8::new(-128, -128, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);
4203+
let b: i8x8 = i8x8::new(-128, 0x7F, 0x02, 0x04, 0x04, 0x00, 0x06, 0x08);
4204+
let e: u8x8 = u8x8::new(0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0);
4205+
let r: u8x8 = transmute(vceq_p8(transmute(a), transmute(b)));
4206+
assert_eq!(r, e);
4207+
}
4208+
4209+
#[simd_test(enable = "neon")]
4210+
unsafe fn test_vceqq_p8() {
4211+
let a: i8x16 = i8x16::new(-128, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x7F);
4212+
let b: i8x16 = i8x16::new(-128, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x7F);
4213+
let e: u8x16 = u8x16::new(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
4214+
let r: u8x16 = transmute(vceqq_p8(transmute(a), transmute(b)));
4215+
assert_eq!(r, e);
4216+
4217+
let a: i8x16 = i8x16::new(-128, -128, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0xCC, 0x0D, 0xEE, 0x7F);
4218+
let b: i8x16 = i8x16::new(-128, 0x7F, 0x02, 0x04, 0x04, 0x00, 0x06, 0x08, 0x08, 0x00, 0x0A, 0x0A, 0xCC, 0xD0, 0xEE, -128);
4219+
let e: u8x16 = u8x16::new(0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0);
4220+
let r: u8x16 = transmute(vceqq_p8(transmute(a), transmute(b)));
4221+
assert_eq!(r, e);
4222+
}
4223+
41504224
#[simd_test(enable = "neon")]
41514225
unsafe fn test_vceq_f32() {
41524226
let a: f32x2 = f32x2::new(1.2, 3.4);
@@ -4219,6 +4293,24 @@ mod test {
42194293
assert_eq!(r, e);
42204294
}
42214295

4296+
#[simd_test(enable = "neon")]
4297+
unsafe fn test_vtst_p8() {
4298+
let a: i8x8 = i8x8::new(-128, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06);
4299+
let b: i8x8 = i8x8::new(-128, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06);
4300+
let e: u8x8 = u8x8::new(0xFF, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
4301+
let r: u8x8 = transmute(vtst_p8(transmute(a), transmute(b)));
4302+
assert_eq!(r, e);
4303+
}
4304+
4305+
#[simd_test(enable = "neon")]
4306+
unsafe fn test_vtstq_p8() {
4307+
let a: i8x16 = i8x16::new(-128, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x7F);
4308+
let b: i8x16 = i8x16::new(-128, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x7F);
4309+
let e: u8x16 = u8x16::new(0xFF, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
4310+
let r: u8x16 = transmute(vtstq_p8(transmute(a), transmute(b)));
4311+
assert_eq!(r, e);
4312+
}
4313+
42224314
#[simd_test(enable = "neon")]
42234315
unsafe fn test_vtst_u8() {
42244316
let a: u8x8 = u8x8::new(0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06);

crates/stdarch-gen/neon.spec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ aarch64 = cmeq
158158
generate uint64x*_t, int64x1_t:uint64x1_t, int64x2_t:uint64x2_t, poly64x1_t:uint64x1_t, poly64x2_t:uint64x2_t
159159

160160
arm = vceq.
161-
generate uint*_t, int8x8_t:uint8x8_t, int8x16_t:uint8x16_t, int16x4_t:uint16x4_t, int16x8_t:uint16x8_t, int32x2_t:uint32x2_t, int32x4_t:uint32x4_t
161+
generate uint*_t, int8x8_t:uint8x8_t, int8x16_t:uint8x16_t, int16x4_t:uint16x4_t, int16x8_t:uint16x8_t, int32x2_t:uint32x2_t, int32x4_t:uint32x4_t, poly8x8_t:uint8x8_t, poly8x16_t:uint8x16_t
162162

163163
/// Floating-point compare equal
164164
name = vceq
@@ -182,7 +182,7 @@ fixed = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
182182
validate FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE
183183

184184
aarch64 = cmeq
185-
generate int8x8_t:uint8x8_t, int8x16_t:uint8x16_t, int16x4_t:uint16x4_t, int16x8_t:uint16x8_t, int32x2_t:uint32x2_t, int32x4_t:uint32x4_t, int64x1_t:uint64x1_t, int64x2_t:uint64x2_t, poly64x1_t:uint64x1_t, poly64x2_t:uint64x2_t
185+
generate int8x8_t:uint8x8_t, int8x16_t:uint8x16_t, int16x4_t:uint16x4_t, int16x8_t:uint16x8_t, int32x2_t:uint32x2_t, int32x4_t:uint32x4_t, int64x1_t:uint64x1_t, int64x2_t:uint64x2_t, poly8x8_t:uint8x8_t, poly8x16_t:uint8x16_t, poly64x1_t:uint64x1_t, poly64x2_t:uint64x2_t
186186

187187
/// Unsigned compare bitwise equal to zero
188188
name = vceqz
@@ -218,7 +218,7 @@ aarch64 = cmtst
218218
generate int64x1_t:uint64x1_t, int64x2_t:uint64x2_t, poly64x1_t:uint64x1_t, poly64x2_t:uint64x2_t
219219

220220
arm = vtst
221-
generate int8x8_t:uint8x8_t, int8x16_t:uint8x16_t, int16x4_t:uint16x4_t, int16x8_t:uint16x8_t, int32x2_t:uint32x2_t, int32x4_t:uint32x4_t
221+
generate int8x8_t:uint8x8_t, int8x16_t:uint8x16_t, int16x4_t:uint16x4_t, int16x8_t:uint16x8_t, int32x2_t:uint32x2_t, int32x4_t:uint32x4_t, poly8x8_t:uint8x8_t, poly8x16_t:uint8x16_t
222222

223223
/// Unsigned compare bitwise Test bits nonzero
224224
name = vtst

crates/stdarch-gen/src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ fn type_len(t: &str) -> usize {
7272
"float32x4_t" => 4,
7373
"float64x1_t" => 1,
7474
"float64x2_t" => 2,
75+
"poly8x8_t" => 8,
76+
"poly8x16_t" => 16,
7577
"poly64x1_t" => 1,
7678
"poly64x2_t" => 2,
7779
_ => panic!("unknown type: {}", t),
@@ -102,6 +104,8 @@ fn type_to_suffix(t: &str) -> &str {
102104
"float32x4_t" => "q_f32",
103105
"float64x1_t" => "_f64",
104106
"float64x2_t" => "q_f64",
107+
"poly8x8_t" => "_p8",
108+
"poly8x16_t" => "q_p8",
105109
"poly64x1_t" => "_p64",
106110
"poly64x2_t" => "q_p64",
107111
_ => panic!("unknown type: {}", t),
@@ -132,6 +136,8 @@ fn type_to_global_type(t: &str) -> &str {
132136
"float32x4_t" => "f32x4",
133137
"float64x1_t" => "f64",
134138
"float64x2_t" => "f64x2",
139+
"poly8x8_t" => "i8x8",
140+
"poly8x16_t" => "i8x16",
135141
"poly64x1_t" => "i64x1",
136142
"poly64x2_t" => "i64x2",
137143
_ => panic!("unknown type: {}", t),
@@ -650,6 +656,8 @@ fn expand_intrinsic(intr: &str, t: &str) -> String {
650656
"float32x4_t" => "f32",
651657
"float64x1_t" => "f64",
652658
"float64x2_t" => "f64",
659+
"poly8x8_t" => "i8",
660+
"poly8x16_t" => "i8",
653661
/*
654662
"poly64x1_t" => "i64x1",
655663
"poly64x2_t" => "i64x2",

0 commit comments

Comments
 (0)