Skip to content

Commit 57a69c5

Browse files
folkertdevAmanieu
authored andcommitted
move unsafe pointer writes to the surface
1 parent 7e56dbf commit 57a69c5

File tree

1 file changed

+70
-63
lines changed

1 file changed

+70
-63
lines changed

Diff for: crates/core_arch/src/s390x/vector.rs

+70-63
Original file line numberDiff line numberDiff line change
@@ -1929,10 +1929,9 @@ mod sealed {
19291929
type Result = $r;
19301930
#[inline]
19311931
#[target_feature(enable = "vector")]
1932-
unsafe fn $m(self, b: Self, c: *mut i32) -> Self::Result {
1932+
unsafe fn $m(self, b: Self) -> (Self::Result, i32) {
19331933
let PackedTuple { x, y } = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b));
1934-
c.write(y);
1935-
transmute(x)
1934+
(transmute(x), y)
19361935
}
19371936
}
19381937
)*
@@ -1959,10 +1958,9 @@ mod sealed {
19591958
type Result = t_b!($ty);
19601959
#[inline]
19611960
#[target_feature(enable = "vector")]
1962-
unsafe fn $m(self, b: Self, c: *mut i32) -> Self::Result {
1961+
unsafe fn $m(self, b: Self) -> (Self::Result, i32) {
19631962
let PackedTuple { x, y } = $fun::<{ FindImm::$imm as i32 }>(transmute(self), transmute(b));
1964-
c.write(y);
1965-
transmute(x)
1963+
(transmute(x), y)
19661964
}
19671965
}
19681966
)*
@@ -2126,47 +2124,47 @@ mod sealed {
21262124
#[unstable(feature = "stdarch_s390x", issue = "135681")]
21272125
pub trait VectorFindAnyEqCC<Other> {
21282126
type Result;
2129-
unsafe fn vec_find_any_eq_cc(self, other: Other, c: *mut i32) -> Self::Result;
2127+
unsafe fn vec_find_any_eq_cc(self, other: Other) -> (Self::Result, i32);
21302128
}
21312129

21322130
impl_vfae! { [cc VectorFindAnyEqCC vec_find_any_eq_cc] Eq vfaebs vfaehs vfaefs }
21332131

21342132
#[unstable(feature = "stdarch_s390x", issue = "135681")]
21352133
pub trait VectorFindAnyNeCC<Other> {
21362134
type Result;
2137-
unsafe fn vec_find_any_ne_cc(self, other: Other, c: *mut i32) -> Self::Result;
2135+
unsafe fn vec_find_any_ne_cc(self, other: Other) -> (Self::Result, i32);
21382136
}
21392137

21402138
impl_vfae! { [cc VectorFindAnyNeCC vec_find_any_ne_cc] Ne vfaebs vfaehs vfaefs }
21412139

21422140
#[unstable(feature = "stdarch_s390x", issue = "135681")]
21432141
pub trait VectorFindAnyEqIdxCC<Other> {
21442142
type Result;
2145-
unsafe fn vec_find_any_eq_idx_cc(self, other: Other, c: *mut i32) -> Self::Result;
2143+
unsafe fn vec_find_any_eq_idx_cc(self, other: Other) -> (Self::Result, i32);
21462144
}
21472145

21482146
impl_vfae! { [idx_cc VectorFindAnyEqIdxCC vec_find_any_eq_idx_cc] EqIdx vfaebs vfaehs vfaefs }
21492147

21502148
#[unstable(feature = "stdarch_s390x", issue = "135681")]
21512149
pub trait VectorFindAnyNeIdxCC<Other> {
21522150
type Result;
2153-
unsafe fn vec_find_any_ne_idx_cc(self, other: Other, c: *mut i32) -> Self::Result;
2151+
unsafe fn vec_find_any_ne_idx_cc(self, other: Other) -> (Self::Result, i32);
21542152
}
21552153

21562154
impl_vfae! { [idx_cc VectorFindAnyNeIdxCC vec_find_any_ne_idx_cc] NeIdx vfaebs vfaehs vfaefs }
21572155

21582156
#[unstable(feature = "stdarch_s390x", issue = "135681")]
21592157
pub trait VectorFindAnyEqOrZeroIdxCC<Other> {
21602158
type Result;
2161-
unsafe fn vec_find_any_eq_or_0_idx_cc(self, other: Other, c: *mut i32) -> Self::Result;
2159+
unsafe fn vec_find_any_eq_or_0_idx_cc(self, other: Other) -> (Self::Result, i32);
21622160
}
21632161

21642162
impl_vfae! { [idx_cc VectorFindAnyEqOrZeroIdxCC vec_find_any_eq_or_0_idx_cc] EqIdx vfaezbs vfaezhs vfaezfs }
21652163

21662164
#[unstable(feature = "stdarch_s390x", issue = "135681")]
21672165
pub trait VectorFindAnyNeOrZeroIdxCC<Other> {
21682166
type Result;
2169-
unsafe fn vec_find_any_ne_or_0_idx_cc(self, other: Other, c: *mut i32) -> Self::Result;
2167+
unsafe fn vec_find_any_ne_or_0_idx_cc(self, other: Other) -> (Self::Result, i32);
21702168
}
21712169

21722170
impl_vfae! { [idx_cc VectorFindAnyNeOrZeroIdxCC vec_find_any_ne_or_0_idx_cc] NeIdx vfaezbs vfaezhs vfaezfs }
@@ -2423,11 +2421,9 @@ mod sealed {
24232421
unsafe fn $intr(
24242422
a: $ty,
24252423
b: $ty,
2426-
c: *mut i32,
2427-
) -> $outty {
2424+
) -> ($outty, i32) {
24282425
let PackedTuple { x, y } = super::$intr(a, b);
2429-
c.write(y);
2430-
x
2426+
(x, y)
24312427
}
24322428

24332429
#[unstable(feature = "stdarch_s390x", issue = "135681")]
@@ -2436,8 +2432,8 @@ mod sealed {
24362432

24372433
#[inline]
24382434
#[target_feature(enable = "vector")]
2439-
unsafe fn vec_packs_cc(self, b: Self, c: *mut i32) -> Self::Result {
2440-
$intr(self, b, c)
2435+
unsafe fn vec_packs_cc(self, b: Self) -> (Self::Result, i32) {
2436+
$intr(self, b)
24412437
}
24422438
}
24432439
)*
@@ -2447,7 +2443,7 @@ mod sealed {
24472443
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
24482444
pub trait VectorPacksCC {
24492445
type Result;
2450-
unsafe fn vec_packs_cc(self, b: Self, c: *mut i32) -> Self::Result;
2446+
unsafe fn vec_packs_cc(self, b: Self) -> (Self::Result, i32);
24512447
}
24522448

24532449
impl_vector_packs_cc! {
@@ -2468,8 +2464,8 @@ mod sealed {
24682464

24692465
#[inline]
24702466
#[target_feature(enable = "vector")]
2471-
unsafe fn vec_packsu_cc(self, b: Self, c: *mut i32) -> Self::Result {
2472-
$intr(self, b, c)
2467+
unsafe fn vec_packsu_cc(self, b: Self) -> (Self::Result, i32) {
2468+
$intr(self, b)
24732469
}
24742470
}
24752471
)*
@@ -2479,7 +2475,7 @@ mod sealed {
24792475
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
24802476
pub trait VectorPacksuCC {
24812477
type Result;
2482-
unsafe fn vec_packsu_cc(self, b: Self, c: *mut i32) -> Self::Result;
2478+
unsafe fn vec_packsu_cc(self, b: Self) -> (Self::Result, i32);
24832479
}
24842480

24852481
impl_vector_packsu_cc! {
@@ -3187,15 +3183,13 @@ mod sealed {
31873183
self,
31883184
b: Self,
31893185
c: vector_unsigned_char,
3190-
d: *mut i32,
3191-
) -> vector_unsigned_char;
3186+
) -> (vector_unsigned_char, i32);
31923187

31933188
unsafe fn vec_search_string_until_zero_cc(
31943189
self,
31953190
b: Self,
31963191
c: vector_unsigned_char,
3197-
d: *mut i32,
3198-
) -> vector_unsigned_char;
3192+
) -> (vector_unsigned_char, i32);
31993193
}
32003194

32013195
macro_rules! impl_vec_search_string{
@@ -3205,18 +3199,16 @@ mod sealed {
32053199
impl VectorSearchString for $ty {
32063200
#[inline]
32073201
#[target_feature(enable = "vector")]
3208-
unsafe fn vec_search_string_cc(self, b: Self, c: vector_unsigned_char, d: *mut i32) -> vector_unsigned_char {
3202+
unsafe fn vec_search_string_cc(self, b: Self, c: vector_unsigned_char) -> (vector_unsigned_char, i32) {
32093203
let PackedTuple { x,y } = $intr_s(transmute(self), transmute(b), c);
3210-
d.write(y);
3211-
x
3204+
(x, y)
32123205
}
32133206

32143207
#[inline]
32153208
#[target_feature(enable = "vector")]
3216-
unsafe fn vec_search_string_until_zero_cc(self, b: Self, c: vector_unsigned_char, d: *mut i32) -> vector_unsigned_char {
3209+
unsafe fn vec_search_string_until_zero_cc(self, b: Self, c: vector_unsigned_char) -> (vector_unsigned_char, i32) {
32173210
let PackedTuple { x,y } = $intr_sz(transmute(self), transmute(b), c);
3218-
d.write(y);
3219-
x
3211+
(x, y)
32203212
}
32213213
}
32223214

@@ -3435,8 +3427,8 @@ mod sealed {
34353427
impl_vec_trait! { [VectorCopyUntilZero vec_cp_until_zero]+ vec_vistrf (vector_unsigned_int) }
34363428

34373429
#[unstable(feature = "stdarch_s390x", issue = "135681")]
3438-
pub trait VectorCopyUntilZeroCC {
3439-
unsafe fn vec_cp_until_zero_cc(self, cc: *mut i32) -> Self;
3430+
pub trait VectorCopyUntilZeroCC: Sized {
3431+
unsafe fn vec_cp_until_zero_cc(self) -> (Self, i32);
34403432
}
34413433

34423434
test_impl! { vec_vistrbs (a: vector_unsigned_char) -> PackedTuple<vector_unsigned_char, i32> [vistrbs, vistrbs] }
@@ -3450,10 +3442,9 @@ mod sealed {
34503442
impl VectorCopyUntilZeroCC for $ty {
34513443
#[inline]
34523444
#[target_feature(enable = "vector")]
3453-
unsafe fn vec_cp_until_zero_cc(self, cc: *mut i32) -> Self {
3445+
unsafe fn vec_cp_until_zero_cc(self) -> (Self, i32) {
34543446
let PackedTuple { x,y } = $intr(transmute(self));
3455-
cc.write(y);
3456-
transmute(x)
3447+
(transmute(x), y)
34573448
}
34583449
}
34593450

@@ -3729,14 +3720,14 @@ mod sealed {
37293720
unsafe fn vec_cmpeq_idx(self, other: Self) -> Self::Result;
37303721
unsafe fn vec_cmpne_idx(self, other: Self) -> Self::Result;
37313722

3732-
unsafe fn vec_cmpeq_idx_cc(self, other: Self, cc: *mut i32) -> Self::Result;
3733-
unsafe fn vec_cmpne_idx_cc(self, other: Self, cc: *mut i32) -> Self::Result;
3723+
unsafe fn vec_cmpeq_idx_cc(self, other: Self) -> (Self::Result, i32);
3724+
unsafe fn vec_cmpne_idx_cc(self, other: Self) -> (Self::Result, i32);
37343725

37353726
unsafe fn vec_cmpeq_or_0_idx(self, other: Self) -> Self::Result;
37363727
unsafe fn vec_cmpne_or_0_idx(self, other: Self) -> Self::Result;
37373728

3738-
unsafe fn vec_cmpeq_or_0_idx_cc(self, other: Self, cc: *mut i32) -> Self::Result;
3739-
unsafe fn vec_cmpne_or_0_idx_cc(self, other: Self, cc: *mut i32) -> Self::Result;
3729+
unsafe fn vec_cmpeq_or_0_idx_cc(self, other: Self) -> (Self::Result, i32);
3730+
unsafe fn vec_cmpne_or_0_idx_cc(self, other: Self) -> (Self::Result, i32);
37403731
}
37413732

37423733
macro_rules! impl_compare_equality_idx {
@@ -3777,34 +3768,30 @@ mod sealed {
37773768

37783769
#[inline]
37793770
#[target_feature(enable = "vector")]
3780-
unsafe fn vec_cmpeq_idx_cc(self, other: Self, cc: *mut i32) -> Self::Result {
3771+
unsafe fn vec_cmpeq_idx_cc(self, other: Self) -> (Self::Result, i32) {
37813772
let PackedTuple { x, y } = $cmpeq_cc(transmute(self), transmute(other));
3782-
*cc = y;
3783-
transmute(x)
3773+
(transmute(x), y)
37843774
}
37853775

37863776
#[inline]
37873777
#[target_feature(enable = "vector")]
3788-
unsafe fn vec_cmpne_idx_cc(self, other: Self, cc: *mut i32) -> Self::Result {
3778+
unsafe fn vec_cmpne_idx_cc(self, other: Self) -> (Self::Result, i32) {
37893779
let PackedTuple { x, y } = $cmpne_cc(transmute(self), transmute(other));
3790-
*cc = y;
3791-
transmute(x)
3780+
(transmute(x),y)
37923781
}
37933782

37943783
#[inline]
37953784
#[target_feature(enable = "vector")]
3796-
unsafe fn vec_cmpeq_or_0_idx_cc(self, other: Self, cc: *mut i32) -> Self::Result {
3785+
unsafe fn vec_cmpeq_or_0_idx_cc(self, other: Self) -> (Self::Result, i32) {
37973786
let PackedTuple { x, y } = $cmpeq_or_0_cc(transmute(self), transmute(other));
3798-
*cc = y;
3799-
transmute(x)
3787+
(transmute(x), y)
38003788
}
38013789

38023790
#[inline]
38033791
#[target_feature(enable = "vector")]
3804-
unsafe fn vec_cmpne_or_0_idx_cc(self, other: Self, cc: *mut i32) -> Self::Result {
3792+
unsafe fn vec_cmpne_or_0_idx_cc(self, other: Self) -> (Self::Result, i32) {
38053793
let PackedTuple { x, y } = $cmpne_or_0_cc(transmute(self), transmute(other));
3806-
*cc = y;
3807-
transmute(x)
3794+
(transmute(x),y)
38083795
}
38093796
}
38103797
)*
@@ -4279,7 +4266,9 @@ pub unsafe fn vec_packs<T: sealed::VectorPacks<U>, U>(a: T, b: U) -> T::Result {
42794266
#[target_feature(enable = "vector")]
42804267
#[unstable(feature = "stdarch_s390x", issue = "135681")]
42814268
pub unsafe fn vec_packs_cc<T: sealed::VectorPacksCC>(a: T, b: T, c: *mut i32) -> T::Result {
4282-
a.vec_packs_cc(b, c)
4269+
let (x, y) = a.vec_packs_cc(b);
4270+
unsafe { c.write(y) };
4271+
x
42834272
}
42844273

42854274
/// Vector Pack Saturated Unsigned
@@ -4295,7 +4284,9 @@ pub unsafe fn vec_packsu<T: sealed::VectorPacksu<U>, U>(a: T, b: U) -> T::Result
42954284
#[target_feature(enable = "vector")]
42964285
#[unstable(feature = "stdarch_s390x", issue = "135681")]
42974286
pub unsafe fn vec_packsu_cc<T: sealed::VectorPacksuCC>(a: T, b: T, c: *mut i32) -> T::Result {
4298-
a.vec_packsu_cc(b, c)
4287+
let (x, y) = a.vec_packsu_cc(b);
4288+
unsafe { c.write(y) };
4289+
x
42994290
}
43004291

43014292
/// Vector Unpack High
@@ -4668,7 +4659,9 @@ macro_rules! vec_find_any_cc {
46684659
#[target_feature(enable = "vector")]
46694660
#[unstable(feature = "stdarch_s390x", issue = "135681")]
46704661
pub unsafe fn $fun<T: sealed::$Trait<U>, U>(a: T, b: U, c: *mut i32) -> T::Result {
4671-
a.$fun(b, c)
4662+
let (x, y) = a.$fun(b);
4663+
unsafe { c.write(y) };
4664+
x
46724665
}
46734666
)*
46744667
}
@@ -5021,7 +5014,9 @@ pub unsafe fn vec_search_string_cc<T: sealed::VectorSearchString>(
50215014
c: vector_unsigned_char,
50225015
d: *mut i32,
50235016
) -> vector_unsigned_char {
5024-
a.vec_search_string_cc(b, c, d)
5017+
let (x, y) = a.vec_search_string_cc(b, c);
5018+
unsafe { d.write(y) };
5019+
x
50255020
}
50265021

50275022
/// Vector Search String Until Zero
@@ -5034,7 +5029,9 @@ pub unsafe fn vec_search_string_until_zero_cc<T: sealed::VectorSearchString>(
50345029
c: vector_unsigned_char,
50355030
d: *mut i32,
50365031
) -> vector_unsigned_char {
5037-
a.vec_search_string_until_zero_cc(b, c, d)
5032+
let (x, y) = a.vec_search_string_until_zero_cc(b, c);
5033+
unsafe { d.write(y) };
5034+
x
50385035
}
50395036

50405037
/// Vector Convert from float (even elements) to double
@@ -5116,7 +5113,9 @@ pub unsafe fn vec_cp_until_zero<T: sealed::VectorCopyUntilZero>(a: T) -> T {
51165113
#[target_feature(enable = "vector")]
51175114
#[unstable(feature = "stdarch_s390x", issue = "135681")]
51185115
pub unsafe fn vec_cp_until_zero_cc<T: sealed::VectorCopyUntilZeroCC>(a: T, cc: *mut i32) -> T {
5119-
a.vec_cp_until_zero_cc(cc)
5116+
let (x, y) = a.vec_cp_until_zero_cc();
5117+
unsafe { cc.write(y) };
5118+
x
51205119
}
51215120

51225121
/// Vector Multiply Sum Logical
@@ -5384,7 +5383,9 @@ pub unsafe fn vec_cmpeq_idx_cc<T: sealed::VectorEqualityIdx>(
53845383
b: T,
53855384
cc: *mut i32,
53865385
) -> T::Result {
5387-
a.vec_cmpeq_idx_cc(b, cc)
5386+
let (x, y) = a.vec_cmpeq_idx_cc(b);
5387+
unsafe { cc.write(y) };
5388+
x
53885389
}
53895390
/// Vector Compare Not Equal Index with Condition Code
53905391
#[inline]
@@ -5395,7 +5396,9 @@ pub unsafe fn vec_cmpne_idx_cc<T: sealed::VectorEqualityIdx>(
53955396
b: T,
53965397
cc: *mut i32,
53975398
) -> T::Result {
5398-
a.vec_cmpne_idx_cc(b, cc)
5399+
let (x, y) = a.vec_cmpne_idx_cc(b);
5400+
unsafe { cc.write(y) };
5401+
x
53995402
}
54005403
/// Vector Compare Equal or Zero Index
54015404
#[inline]
@@ -5420,7 +5423,9 @@ pub unsafe fn vec_cmpeq_or_0_idx_cc<T: sealed::VectorEqualityIdx>(
54205423
b: T,
54215424
cc: *mut i32,
54225425
) -> T::Result {
5423-
a.vec_cmpeq_or_0_idx_cc(b, cc)
5426+
let (x, y) = a.vec_cmpeq_or_0_idx_cc(b);
5427+
unsafe { cc.write(y) };
5428+
x
54245429
}
54255430
/// Vector Compare Not Equal or Zero Index with Condition Code
54265431
#[inline]
@@ -5431,7 +5436,9 @@ pub unsafe fn vec_cmpne_or_0_idx_cc<T: sealed::VectorEqualityIdx>(
54315436
b: T,
54325437
cc: *mut i32,
54335438
) -> T::Result {
5434-
a.vec_cmpne_or_0_idx_cc(b, cc)
5439+
let (x, y) = a.vec_cmpne_or_0_idx_cc(b);
5440+
unsafe { cc.write(y) };
5441+
x
54355442
}
54365443

54375444
/// All Elements Equal

0 commit comments

Comments
 (0)