Skip to content

Commit 9eb15e2

Browse files
folkertdevAmanieu
authored andcommitted
use a tuple to return the condition code
1 parent ffa1235 commit 9eb15e2

File tree

1 file changed

+48
-101
lines changed

1 file changed

+48
-101
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 48 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -4483,10 +4483,8 @@ pub unsafe fn vec_packs<T: sealed::VectorPacks<U>, U>(a: T, b: U) -> T::Result {
44834483
#[inline]
44844484
#[target_feature(enable = "vector")]
44854485
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4486-
pub unsafe fn vec_packs_cc<T: sealed::VectorPacksCC>(a: T, b: T, c: *mut i32) -> T::Result {
4487-
let (x, y) = a.vec_packs_cc(b);
4488-
unsafe { c.write(y) };
4489-
x
4486+
pub unsafe fn vec_packs_cc<T: sealed::VectorPacksCC>(a: T, b: T) -> (T::Result, i32) {
4487+
a.vec_packs_cc(b)
44904488
}
44914489

44924490
/// Vector Pack Saturated Unsigned
@@ -4501,10 +4499,8 @@ pub unsafe fn vec_packsu<T: sealed::VectorPacksu<U>, U>(a: T, b: U) -> T::Result
45014499
#[inline]
45024500
#[target_feature(enable = "vector")]
45034501
#[unstable(feature = "stdarch_s390x", issue = "135681")]
4504-
pub unsafe fn vec_packsu_cc<T: sealed::VectorPacksuCC>(a: T, b: T, c: *mut i32) -> T::Result {
4505-
let (x, y) = a.vec_packsu_cc(b);
4506-
unsafe { c.write(y) };
4507-
x
4502+
pub unsafe fn vec_packsu_cc<T: sealed::VectorPacksuCC>(a: T, b: T) -> (T::Result, i32) {
4503+
a.vec_packsu_cc(b)
45084504
}
45094505

45104506
/// Vector Unpack High
@@ -4878,10 +4874,8 @@ macro_rules! vec_find_any_cc {
48784874
#[target_feature(enable = "vector")]
48794875
#[unstable(feature = "stdarch_s390x", issue = "135681")]
48804876
#[doc = $doc]
4881-
pub unsafe fn $fun<T: sealed::$Trait<U>, U>(a: T, b: U, c: *mut i32) -> T::Result {
4882-
let (x, y) = a.$fun(b);
4883-
unsafe { c.write(y) };
4884-
x
4877+
pub unsafe fn $fun<T: sealed::$Trait<U>, U>(a: T, b: U) -> (T::Result, i32) {
4878+
a.$fun(b)
48854879
}
48864880
)*
48874881
}
@@ -5236,11 +5230,8 @@ pub unsafe fn vec_search_string_cc<T: sealed::VectorSearchString>(
52365230
a: T,
52375231
b: T,
52385232
c: vector_unsigned_char,
5239-
d: *mut i32,
5240-
) -> vector_unsigned_char {
5241-
let (x, y) = a.vec_search_string_cc(b, c);
5242-
unsafe { d.write(y) };
5243-
x
5233+
) -> (vector_unsigned_char, i32) {
5234+
a.vec_search_string_cc(b, c)
52445235
}
52455236

52465237
/// Vector Search String Until Zero
@@ -5251,11 +5242,8 @@ pub unsafe fn vec_search_string_until_zero_cc<T: sealed::VectorSearchString>(
52515242
a: T,
52525243
b: T,
52535244
c: vector_unsigned_char,
5254-
d: *mut i32,
5255-
) -> vector_unsigned_char {
5256-
let (x, y) = a.vec_search_string_until_zero_cc(b, c);
5257-
unsafe { d.write(y) };
5258-
x
5245+
) -> (vector_unsigned_char, i32) {
5246+
a.vec_search_string_until_zero_cc(b, c)
52595247
}
52605248

52615249
/// Vector Convert from float (even elements) to double
@@ -5336,10 +5324,8 @@ pub unsafe fn vec_cp_until_zero<T: sealed::VectorCopyUntilZero>(a: T) -> T {
53365324
#[inline]
53375325
#[target_feature(enable = "vector")]
53385326
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5339-
pub unsafe fn vec_cp_until_zero_cc<T: sealed::VectorCopyUntilZeroCC>(a: T, cc: *mut i32) -> T {
5340-
let (x, y) = a.vec_cp_until_zero_cc();
5341-
unsafe { cc.write(y) };
5342-
x
5327+
pub unsafe fn vec_cp_until_zero_cc<T: sealed::VectorCopyUntilZeroCC>(a: T) -> (T, i32) {
5328+
a.vec_cp_until_zero_cc()
53435329
}
53445330

53455331
/// Vector Multiply Sum Logical
@@ -5603,27 +5589,15 @@ pub unsafe fn vec_cmpne_idx<T: sealed::VectorEqualityIdx>(a: T, b: T) -> T::Resu
56035589
#[inline]
56045590
#[target_feature(enable = "vector")]
56055591
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5606-
pub unsafe fn vec_cmpeq_idx_cc<T: sealed::VectorEqualityIdx>(
5607-
a: T,
5608-
b: T,
5609-
cc: *mut i32,
5610-
) -> T::Result {
5611-
let (x, y) = a.vec_cmpeq_idx_cc(b);
5612-
unsafe { cc.write(y) };
5613-
x
5592+
pub unsafe fn vec_cmpeq_idx_cc<T: sealed::VectorEqualityIdx>(a: T, b: T) -> (T::Result, i32) {
5593+
a.vec_cmpeq_idx_cc(b)
56145594
}
56155595
/// Vector Compare Not Equal Index with Condition Code
56165596
#[inline]
56175597
#[target_feature(enable = "vector")]
56185598
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5619-
pub unsafe fn vec_cmpne_idx_cc<T: sealed::VectorEqualityIdx>(
5620-
a: T,
5621-
b: T,
5622-
cc: *mut i32,
5623-
) -> T::Result {
5624-
let (x, y) = a.vec_cmpne_idx_cc(b);
5625-
unsafe { cc.write(y) };
5626-
x
5599+
pub unsafe fn vec_cmpne_idx_cc<T: sealed::VectorEqualityIdx>(a: T, b: T) -> (T::Result, i32) {
5600+
a.vec_cmpne_idx_cc(b)
56275601
}
56285602
/// Vector Compare Equal or Zero Index
56295603
#[inline]
@@ -5643,27 +5617,15 @@ pub unsafe fn vec_cmpne_or_0_idx<T: sealed::VectorEqualityIdx>(a: T, b: T) -> T:
56435617
#[inline]
56445618
#[target_feature(enable = "vector")]
56455619
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5646-
pub unsafe fn vec_cmpeq_or_0_idx_cc<T: sealed::VectorEqualityIdx>(
5647-
a: T,
5648-
b: T,
5649-
cc: *mut i32,
5650-
) -> T::Result {
5651-
let (x, y) = a.vec_cmpeq_or_0_idx_cc(b);
5652-
unsafe { cc.write(y) };
5653-
x
5620+
pub unsafe fn vec_cmpeq_or_0_idx_cc<T: sealed::VectorEqualityIdx>(a: T, b: T) -> (T::Result, i32) {
5621+
a.vec_cmpeq_or_0_idx_cc(b)
56545622
}
56555623
/// Vector Compare Not Equal or Zero Index with Condition Code
56565624
#[inline]
56575625
#[target_feature(enable = "vector")]
56585626
#[unstable(feature = "stdarch_s390x", issue = "135681")]
5659-
pub unsafe fn vec_cmpne_or_0_idx_cc<T: sealed::VectorEqualityIdx>(
5660-
a: T,
5661-
b: T,
5662-
cc: *mut i32,
5663-
) -> T::Result {
5664-
let (x, y) = a.vec_cmpne_or_0_idx_cc(b);
5665-
unsafe { cc.write(y) };
5666-
x
5627+
pub unsafe fn vec_cmpne_or_0_idx_cc<T: sealed::VectorEqualityIdx>(a: T, b: T) -> (T::Result, i32) {
5628+
a.vec_cmpne_or_0_idx_cc(b)
56675629
}
56685630

56695631
/// All Elements Equal
@@ -6426,138 +6388,126 @@ mod tests {
64266388

64276389
#[simd_test(enable = "vector")]
64286390
fn test_vec_find_any_eq_cc() {
6429-
let mut c = 0i32;
6430-
64316391
let a = vector_unsigned_int([1, 2, 3, 4]);
64326392
let b = vector_unsigned_int([5, 3, 7, 8]);
64336393

6434-
let d = unsafe { vec_find_any_eq_cc(a, b, &mut c) };
6394+
let (d, c) = unsafe { vec_find_any_eq_cc(a, b) };
64356395
assert_eq!(c, 1);
64366396
assert_eq!(d.as_array(), &[0, 0, -1, 0]);
64376397

64386398
let a = vector_unsigned_int([1, 2, 3, 4]);
64396399
let b = vector_unsigned_int([5, 6, 7, 8]);
6440-
let d = unsafe { vec_find_any_eq_cc(a, b, &mut c) };
6400+
let (d, c) = unsafe { vec_find_any_eq_cc(a, b) };
64416401
assert_eq!(c, 3);
64426402
assert_eq!(d.as_array(), &[0, 0, 0, 0]);
64436403
}
64446404

64456405
#[simd_test(enable = "vector")]
64466406
fn test_vec_find_any_ne_cc() {
6447-
let mut c = 0i32;
6448-
64496407
let a = vector_unsigned_int([1, 2, 3, 4]);
64506408
let b = vector_unsigned_int([5, 3, 7, 8]);
64516409

6452-
let d = unsafe { vec_find_any_ne_cc(a, b, &mut c) };
6410+
let (d, c) = unsafe { vec_find_any_ne_cc(a, b) };
64536411
assert_eq!(c, 1);
64546412
assert_eq!(d.as_array(), &[-1, -1, 0, -1]);
64556413

64566414
let a = vector_unsigned_int([1, 2, 3, 4]);
64576415
let b = vector_unsigned_int([1, 2, 3, 4]);
6458-
let d = unsafe { vec_find_any_ne_cc(a, b, &mut c) };
6416+
let (d, c) = unsafe { vec_find_any_ne_cc(a, b) };
64596417
assert_eq!(c, 3);
64606418
assert_eq!(d.as_array(), &[0, 0, 0, 0]);
64616419
}
64626420

64636421
#[simd_test(enable = "vector")]
64646422
fn test_vec_find_any_eq_idx_cc() {
6465-
let mut c = 0i32;
6466-
64676423
let a = vector_unsigned_int([1, 2, 3, 4]);
64686424
let b = vector_unsigned_int([5, 3, 7, 8]);
64696425

6470-
let d = unsafe { vec_find_any_eq_idx_cc(a, b, &mut c) };
6426+
let (d, c) = unsafe { vec_find_any_eq_idx_cc(a, b) };
64716427
assert_eq!(c, 1);
64726428
assert_eq!(d.as_array(), &[0, 8, 0, 0]);
64736429

64746430
let a = vector_unsigned_int([1, 2, 3, 4]);
64756431
let b = vector_unsigned_int([5, 6, 7, 8]);
6476-
let d = unsafe { vec_find_any_eq_idx_cc(a, b, &mut c) };
6432+
let (d, c) = unsafe { vec_find_any_eq_idx_cc(a, b) };
64776433
assert_eq!(c, 3);
64786434
assert_eq!(d.as_array(), &[0, 16, 0, 0]);
64796435
}
64806436

64816437
#[simd_test(enable = "vector")]
64826438
fn test_vec_find_any_ne_idx_cc() {
6483-
let mut c = 0i32;
6484-
64856439
let a = vector_unsigned_int([5, 2, 3, 4]);
64866440
let b = vector_unsigned_int([5, 3, 7, 8]);
64876441

6488-
let d = unsafe { vec_find_any_ne_idx_cc(a, b, &mut c) };
6442+
let (d, c) = unsafe { vec_find_any_ne_idx_cc(a, b) };
64896443
assert_eq!(c, 1);
64906444
assert_eq!(d.as_array(), &[0, 4, 0, 0]);
64916445

64926446
let a = vector_unsigned_int([1, 2, 3, 4]);
64936447
let b = vector_unsigned_int([1, 2, 3, 4]);
6494-
let d = unsafe { vec_find_any_ne_idx_cc(a, b, &mut c) };
6448+
let (d, c) = unsafe { vec_find_any_ne_idx_cc(a, b) };
64956449
assert_eq!(c, 3);
64966450
assert_eq!(d.as_array(), &[0, 16, 0, 0]);
64976451
}
64986452

64996453
#[simd_test(enable = "vector")]
65006454
fn test_vec_find_any_eq_or_0_idx_cc() {
6501-
let mut c = 0i32;
6502-
65036455
// if no element of a matches any element of b with an equal value, and there is at least one element from a with a value of 0
65046456
let a = vector_unsigned_int([0, 1, 2, 3]);
65056457
let b = vector_unsigned_int([4, 5, 6, 7]);
6506-
let d = unsafe { vec_find_any_eq_or_0_idx_cc(a, b, &mut c) };
6458+
let (d, c) = unsafe { vec_find_any_eq_or_0_idx_cc(a, b) };
65076459
assert_eq!(c, 0);
65086460
assert_eq!(d.as_array(), &[0, 0, 0, 0]);
65096461

65106462
// if at least one element of a matches any element of b with an equal value, and no elements of a with a value of 0
65116463
let a = vector_unsigned_int([1, 2, 3, 4]);
65126464
let b = vector_unsigned_int([5, 2, 3, 4]);
6513-
let d = unsafe { vec_find_any_eq_or_0_idx_cc(a, b, &mut c) };
6465+
let (d, c) = unsafe { vec_find_any_eq_or_0_idx_cc(a, b) };
65146466
assert_eq!(c, 1);
65156467
assert_eq!(d.as_array(), &[0, 4, 0, 0]);
65166468

65176469
// if at least one element of a matches any element of b with an equal value, and there is at least one element from a has a value of 0
65186470
let a = vector_unsigned_int([1, 2, 3, 0]);
65196471
let b = vector_unsigned_int([1, 2, 3, 4]);
6520-
let d = unsafe { vec_find_any_eq_or_0_idx_cc(a, b, &mut c) };
6472+
let (d, c) = unsafe { vec_find_any_eq_or_0_idx_cc(a, b) };
65216473
assert_eq!(c, 2);
65226474
assert_eq!(d.as_array(), &[0, 0, 0, 0]);
65236475

65246476
// if no element of a matches any element of b with an equal value, and there is no element from a with a value of 0.
65256477
let a = vector_unsigned_int([1, 2, 3, 4]);
65266478
let b = vector_unsigned_int([5, 6, 7, 8]);
6527-
let d = unsafe { vec_find_any_eq_or_0_idx_cc(a, b, &mut c) };
6479+
let (d, c) = unsafe { vec_find_any_eq_or_0_idx_cc(a, b) };
65286480
assert_eq!(c, 3);
65296481
assert_eq!(d.as_array(), &[0, 16, 0, 0]);
65306482
}
65316483

65326484
#[simd_test(enable = "vector")]
65336485
fn test_vec_find_any_ne_or_0_idx_cc() {
6534-
let mut c = 0i32;
6535-
65366486
// if no element of a matches any element of b with a not equal value, and there is at least one element from a with a value of 0.
65376487
let a = vector_unsigned_int([0, 1, 2, 3]);
65386488
let b = vector_unsigned_int([4, 1, 2, 3]);
6539-
let d = unsafe { vec_find_any_ne_or_0_idx_cc(a, b, &mut c) };
6489+
let (d, c) = unsafe { vec_find_any_ne_or_0_idx_cc(a, b) };
65406490
assert_eq!(c, 0);
65416491
assert_eq!(d.as_array(), &[0, 0, 0, 0]);
65426492

65436493
// if at least one element of a matches any element of b with a not equal value, and no elements of a with a value of 0.
65446494
let a = vector_unsigned_int([4, 2, 3, 4]);
65456495
let b = vector_unsigned_int([4, 5, 6, 7]);
6546-
let d = unsafe { vec_find_any_ne_or_0_idx_cc(a, b, &mut c) };
6496+
let (d, c) = unsafe { vec_find_any_ne_or_0_idx_cc(a, b) };
65476497
assert_eq!(c, 1);
65486498
assert_eq!(d.as_array(), &[0, 4, 0, 0]);
65496499

65506500
// if at least one element of a matches any element of b with a not equal value, and there is at least one element from a has a value of 0.
65516501
let a = vector_unsigned_int([1, 0, 1, 1]);
65526502
let b = vector_unsigned_int([4, 5, 6, 7]);
6553-
let d = unsafe { vec_find_any_ne_or_0_idx_cc(a, b, &mut c) };
6503+
let (d, c) = unsafe { vec_find_any_ne_or_0_idx_cc(a, b) };
65546504
assert_eq!(c, 2);
65556505
assert_eq!(d.as_array(), &[0, 0, 0, 0]);
65566506

65576507
// if no element of a matches any element of b with a not equal value, and there is no element from a with a value of 0.
65586508
let a = vector_unsigned_int([4, 4, 4, 4]);
65596509
let b = vector_unsigned_int([4, 5, 6, 7]);
6560-
let d = unsafe { vec_find_any_ne_or_0_idx_cc(a, b, &mut c) };
6510+
let (d, c) = unsafe { vec_find_any_ne_or_0_idx_cc(a, b) };
65616511
assert_eq!(c, 3);
65626512
assert_eq!(d.as_array(), &[0, 16, 0, 0]);
65636513
}
@@ -6981,30 +6931,29 @@ mod tests {
69816931
unsafe {
69826932
let b = vector_unsigned_char(*b"ABCD------------");
69836933
let c = vector_unsigned_char([4; 16]);
6984-
let mut d = 0i32;
69856934

69866935
let haystack = vector_unsigned_char(*b"__ABCD__________");
6987-
let result = vec_search_string_cc(haystack, b, c, &mut d);
6936+
let (result, d) = vec_search_string_cc(haystack, b, c);
69886937
assert_eq!(result.as_array()[7], 2);
69896938
assert_eq!(d, 2);
69906939

69916940
let haystack = vector_unsigned_char(*b"___ABCD_________");
6992-
let result = vec_search_string_cc(haystack, b, c, &mut d);
6941+
let (result, d) = vec_search_string_cc(haystack, b, c);
69936942
assert_eq!(result.as_array()[7], 3);
69946943
assert_eq!(d, 2);
69956944

69966945
let haystack = vector_unsigned_char(*b"________________");
6997-
let result = vec_search_string_cc(haystack, b, c, &mut d);
6946+
let (result, d) = vec_search_string_cc(haystack, b, c);
69986947
assert_eq!(result.as_array()[7], 16);
69996948
assert_eq!(d, 0);
70006949

70016950
let haystack = vector_unsigned_char(*b"______\0_________");
7002-
let result = vec_search_string_cc(haystack, b, c, &mut d);
6951+
let (result, d) = vec_search_string_cc(haystack, b, c);
70036952
assert_eq!(result.as_array()[7], 16);
70046953
assert_eq!(d, 0);
70056954

70066955
let haystack = vector_unsigned_char(*b"______\0__ABCD___");
7007-
let result = vec_search_string_cc(haystack, b, c, &mut d);
6956+
let (result, d) = vec_search_string_cc(haystack, b, c);
70086957
assert_eq!(result.as_array()[7], 9);
70096958
assert_eq!(d, 2);
70106959
}
@@ -7015,30 +6964,29 @@ mod tests {
70156964
unsafe {
70166965
let b = vector_unsigned_char(*b"ABCD\0\0\0\0\0\0\0\0\0\0\0\0");
70176966
let c = vector_unsigned_char([16; 16]);
7018-
let mut d = 0i32;
70196967

70206968
let haystack = vector_unsigned_char(*b"__ABCD__________");
7021-
let result = vec_search_string_until_zero_cc(haystack, b, c, &mut d);
6969+
let (result, d) = vec_search_string_until_zero_cc(haystack, b, c);
70226970
assert_eq!(result.as_array()[7], 2);
70236971
assert_eq!(d, 2);
70246972

70256973
let haystack = vector_unsigned_char(*b"___ABCD_________");
7026-
let result = vec_search_string_until_zero_cc(haystack, b, c, &mut d);
6974+
let (result, d) = vec_search_string_until_zero_cc(haystack, b, c);
70276975
assert_eq!(result.as_array()[7], 3);
70286976
assert_eq!(d, 2);
70296977

70306978
let haystack = vector_unsigned_char(*b"________________");
7031-
let result = vec_search_string_until_zero_cc(haystack, b, c, &mut d);
6979+
let (result, d) = vec_search_string_until_zero_cc(haystack, b, c);
70326980
assert_eq!(result.as_array()[7], 16);
70336981
assert_eq!(d, 0);
70346982

70356983
let haystack = vector_unsigned_char(*b"______\0_________");
7036-
let result = vec_search_string_until_zero_cc(haystack, b, c, &mut d);
6984+
let (result, d) = vec_search_string_until_zero_cc(haystack, b, c);
70376985
assert_eq!(result.as_array()[7], 16);
70386986
assert_eq!(d, 1);
70396987

70406988
let haystack = vector_unsigned_char(*b"______\0__ABCD___");
7041-
let result = vec_search_string_until_zero_cc(haystack, b, c, &mut d);
6989+
let (result, d) = vec_search_string_until_zero_cc(haystack, b, c);
70426990
assert_eq!(result.as_array()[7], 16);
70436991
assert_eq!(d, 1);
70446992
}
@@ -7132,15 +7080,14 @@ mod tests {
71327080

71337081
#[simd_test(enable = "vector")]
71347082
fn test_vec_cp_until_zero_cc() {
7135-
let mut cc = 0;
71367083
unsafe {
71377084
let v = vector_signed_int([1, 2, 3, 4]);
7138-
let d = vec_cp_until_zero_cc(v, &mut cc);
7085+
let (d, cc) = vec_cp_until_zero_cc(v);
71397086
assert_eq!(d.as_array(), &[1, 2, 3, 4]);
71407087
assert_eq!(cc, 3);
71417088

71427089
let v = vector_signed_int([1, 2, 0, 4]);
7143-
let d = vec_cp_until_zero_cc(v, &mut cc);
7090+
let (d, cc) = vec_cp_until_zero_cc(v);
71447091
assert_eq!(d.as_array(), &[1, 2, 0, 0]);
71457092
assert_eq!(cc, 0);
71467093
}

0 commit comments

Comments
 (0)