|
| 1 | +//@ revisions: z10 z10_vector z13 z13_no_vector |
| 2 | +// ignore-tidy-linelength |
| 3 | +//@ assembly-output: emit-asm |
| 4 | +//@ compile-flags: -O -Z merge-functions=disabled |
| 5 | +//@[z10] compile-flags: --target s390x-unknown-linux-gnu --cfg no_vector |
| 6 | +//@[z10] needs-llvm-components: systemz |
| 7 | +//@[z10_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector |
| 8 | +//@[z10_vector] needs-llvm-components: systemz |
| 9 | +//@[z13] compile-flags: --target s390x-unknown-linux-gnu -C target-cpu=z13 |
| 10 | +//@[z13] needs-llvm-components: systemz |
| 11 | +//@[z13_no_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-cpu=z13 -C target-feature=-vector --cfg no_vector |
| 12 | +//@[z13_no_vector] needs-llvm-components: systemz |
| 13 | + |
| 14 | +#![feature(no_core, lang_items, repr_simd, s390x_target_feature)] |
| 15 | +#![no_core] |
| 16 | +#![crate_type = "lib"] |
| 17 | +#![allow(non_camel_case_types)] |
| 18 | + |
| 19 | +// Cases where vector feature is disabled are rejected. |
| 20 | +// See tests/ui/simd-abi-checks-s390x.rs for test for them. |
| 21 | + |
| 22 | +#[lang = "sized"] |
| 23 | +pub trait Sized {} |
| 24 | +#[lang = "copy"] |
| 25 | +pub trait Copy {} |
| 26 | +#[lang = "freeze"] |
| 27 | +pub trait Freeze {} |
| 28 | + |
| 29 | +impl<T: Copy, const N: usize> Copy for [T; N] {} |
| 30 | + |
| 31 | +#[repr(simd)] |
| 32 | +pub struct i8x8([i8; 8]); |
| 33 | +#[repr(simd)] |
| 34 | +pub struct i8x16([i8; 16]); |
| 35 | +#[repr(simd)] |
| 36 | +pub struct i8x32([i8; 32]); |
| 37 | +#[repr(C)] |
| 38 | +pub struct Wrapper<T>(T); |
| 39 | +#[repr(transparent)] |
| 40 | +pub struct TransparentWrapper<T>(T); |
| 41 | + |
| 42 | +impl Copy for i8 {} |
| 43 | +impl Copy for i64 {} |
| 44 | +impl Copy for i8x8 {} |
| 45 | +impl Copy for i8x16 {} |
| 46 | +impl Copy for i8x32 {} |
| 47 | +impl<T: Copy> Copy for Wrapper<T> {} |
| 48 | +impl<T: Copy> Copy for TransparentWrapper<T> {} |
| 49 | + |
| 50 | +// CHECK-LABEL: vector_ret_small: |
| 51 | +// CHECK: vlrepg %v24, 0(%r2) |
| 52 | +// CHECK-NEXT: br %r14 |
| 53 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 54 | +#[no_mangle] |
| 55 | +unsafe extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { |
| 56 | + *x |
| 57 | +} |
| 58 | +// CHECK-LABEL: vector_ret: |
| 59 | +// CHECK: vl %v24, 0(%r2), 3 |
| 60 | +// CHECK-NEXT: br %r14 |
| 61 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 62 | +#[no_mangle] |
| 63 | +unsafe extern "C" fn vector_ret(x: &i8x16) -> i8x16 { |
| 64 | + *x |
| 65 | +} |
| 66 | +// CHECK-LABEL: vector_ret_large: |
| 67 | +// z10: vl %v0, 16(%r3), 4 |
| 68 | +// z10-NEXT: vl %v1, 0(%r3), 4 |
| 69 | +// z10-NEXT: vst %v0, 16(%r2), 4 |
| 70 | +// z10-NEXT: vst %v1, 0(%r2), 4 |
| 71 | +// z10-NEXT: br %r14 |
| 72 | +// z13: vl %v0, 0(%r3), 4 |
| 73 | +// z13-NEXT: vl %v1, 16(%r3), 4 |
| 74 | +// z13-NEXT: vst %v1, 16(%r2), 4 |
| 75 | +// z13-NEXT: vst %v0, 0(%r2), 4 |
| 76 | +// z13-NEXT: br %r14 |
| 77 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 78 | +#[no_mangle] |
| 79 | +unsafe extern "C" fn vector_ret_large(x: &i8x32) -> i8x32 { |
| 80 | + *x |
| 81 | +} |
| 82 | + |
| 83 | +// CHECK-LABEL: vector_wrapper_ret_small: |
| 84 | +// CHECK: mvc 0(8,%r2), 0(%r3) |
| 85 | +// CHECK-NEXT: br %r14 |
| 86 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 87 | +#[no_mangle] |
| 88 | +unsafe extern "C" fn vector_wrapper_ret_small(x: &Wrapper<i8x8>) -> Wrapper<i8x8> { |
| 89 | + *x |
| 90 | +} |
| 91 | +// CHECK-LABEL: vector_wrapper_ret: |
| 92 | +// CHECK: mvc 0(16,%r2), 0(%r3) |
| 93 | +// CHECK-NEXT: br %r14 |
| 94 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 95 | +#[no_mangle] |
| 96 | +unsafe extern "C" fn vector_wrapper_ret(x: &Wrapper<i8x16>) -> Wrapper<i8x16> { |
| 97 | + *x |
| 98 | +} |
| 99 | +// CHECK-LABEL: vector_wrapper_ret_large: |
| 100 | +// z10: vl %v0, 16(%r3), 4 |
| 101 | +// z10-NEXT: vl %v1, 0(%r3), 4 |
| 102 | +// z10-NEXT: vst %v0, 16(%r2), 4 |
| 103 | +// z10-NEXT: vst %v1, 0(%r2), 4 |
| 104 | +// z10-NEXT: br %r14 |
| 105 | +// z13: vl %v0, 16(%r3), 4 |
| 106 | +// z13-NEXT: vst %v0, 16(%r2), 4 |
| 107 | +// z13-NEXT: vl %v0, 0(%r3), 4 |
| 108 | +// z13-NEXT: vst %v0, 0(%r2), 4 |
| 109 | +// z13-NEXT: br %r14 |
| 110 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 111 | +#[no_mangle] |
| 112 | +unsafe extern "C" fn vector_wrapper_ret_large(x: &Wrapper<i8x32>) -> Wrapper<i8x32> { |
| 113 | + *x |
| 114 | +} |
| 115 | + |
| 116 | +// CHECK-LABEL: vector_transparent_wrapper_ret_small: |
| 117 | +// CHECK: vlrepg %v24, 0(%r2) |
| 118 | +// CHECK-NEXT: br %r14 |
| 119 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 120 | +#[no_mangle] |
| 121 | +unsafe extern "C" fn vector_transparent_wrapper_ret_small( |
| 122 | + x: &TransparentWrapper<i8x8>, |
| 123 | +) -> TransparentWrapper<i8x8> { |
| 124 | + *x |
| 125 | +} |
| 126 | +// CHECK-LABEL: vector_transparent_wrapper_ret: |
| 127 | +// CHECK: vl %v24, 0(%r2), 3 |
| 128 | +// CHECK-NEXT: br %r14 |
| 129 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 130 | +#[no_mangle] |
| 131 | +unsafe extern "C" fn vector_transparent_wrapper_ret( |
| 132 | + x: &TransparentWrapper<i8x16>, |
| 133 | +) -> TransparentWrapper<i8x16> { |
| 134 | + *x |
| 135 | +} |
| 136 | +// CHECK-LABEL: vector_transparent_wrapper_ret_large: |
| 137 | +// z10: vl %v0, 16(%r3), 4 |
| 138 | +// z10-NEXT: vl %v1, 0(%r3), 4 |
| 139 | +// z10-NEXT: vst %v0, 16(%r2), 4 |
| 140 | +// z10-NEXT: vst %v1, 0(%r2), 4 |
| 141 | +// z10-NEXT: br %r14 |
| 142 | +// z13: vl %v0, 0(%r3), 4 |
| 143 | +// z13-NEXT: vl %v1, 16(%r3), 4 |
| 144 | +// z13-NEXT: vst %v1, 16(%r2), 4 |
| 145 | +// z13-NEXT: vst %v0, 0(%r2), 4 |
| 146 | +// z13-NEXT: br %r14 |
| 147 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 148 | +#[no_mangle] |
| 149 | +unsafe extern "C" fn vector_transparent_wrapper_ret_large( |
| 150 | + x: &TransparentWrapper<i8x32>, |
| 151 | +) -> TransparentWrapper<i8x32> { |
| 152 | + *x |
| 153 | +} |
| 154 | + |
| 155 | +// CHECK-LABEL: vector_arg_small: |
| 156 | +// CHECK: vlgvg %r2, %v24, 0 |
| 157 | +// CHECK-NEXT: br %r14 |
| 158 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 159 | +#[no_mangle] |
| 160 | +unsafe extern "C" fn vector_arg_small(x: i8x8) -> i64 { |
| 161 | + unsafe { *(&x as *const i8x8 as *const i64) } |
| 162 | +} |
| 163 | +// CHECK-LABEL: vector_arg: |
| 164 | +// CHECK: vlgvg %r2, %v24, 0 |
| 165 | +// CHECK-NEXT: br %r14 |
| 166 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 167 | +#[no_mangle] |
| 168 | +unsafe extern "C" fn vector_arg(x: i8x16) -> i64 { |
| 169 | + unsafe { *(&x as *const i8x16 as *const i64) } |
| 170 | +} |
| 171 | +// CHECK-LABEL: vector_arg_large: |
| 172 | +// CHECK: lg %r2, 0(%r2) |
| 173 | +// CHECK-NEXT: br %r14 |
| 174 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 175 | +#[no_mangle] |
| 176 | +unsafe extern "C" fn vector_arg_large(x: i8x32) -> i64 { |
| 177 | + unsafe { *(&x as *const i8x32 as *const i64) } |
| 178 | +} |
| 179 | + |
| 180 | +// CHECK-LABEL: vector_wrapper_arg_small: |
| 181 | +// CHECK: vlgvg %r2, %v24, 0 |
| 182 | +// CHECK-NEXT: br %r14 |
| 183 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 184 | +#[no_mangle] |
| 185 | +unsafe extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { |
| 186 | + unsafe { *(&x as *const Wrapper<i8x8> as *const i64) } |
| 187 | +} |
| 188 | +// CHECK-LABEL: vector_wrapper_arg: |
| 189 | +// CHECK: vlgvg %r2, %v24, 0 |
| 190 | +// CHECK-NEXT: br %r14 |
| 191 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 192 | +#[no_mangle] |
| 193 | +unsafe extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { |
| 194 | + unsafe { *(&x as *const Wrapper<i8x16> as *const i64) } |
| 195 | +} |
| 196 | +// CHECK-LABEL: vector_wrapper_arg_large: |
| 197 | +// CHECK: lg %r2, 0(%r2) |
| 198 | +// CHECK-NEXT: br %r14 |
| 199 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 200 | +#[no_mangle] |
| 201 | +unsafe extern "C" fn vector_wrapper_arg_large(x: Wrapper<i8x32>) -> i64 { |
| 202 | + unsafe { *(&x as *const Wrapper<i8x32> as *const i64) } |
| 203 | +} |
| 204 | + |
| 205 | +// CHECK-LABEL: vector_transparent_wrapper_arg_small: |
| 206 | +// CHECK: vlgvg %r2, %v24, 0 |
| 207 | +// CHECK-NEXT: br %r14 |
| 208 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 209 | +#[no_mangle] |
| 210 | +unsafe extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { |
| 211 | + unsafe { *(&x as *const TransparentWrapper<i8x8> as *const i64) } |
| 212 | +} |
| 213 | +// CHECK-LABEL: vector_transparent_wrapper_arg: |
| 214 | +// CHECK: vlgvg %r2, %v24, 0 |
| 215 | +// CHECK-NEXT: br %r14 |
| 216 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 217 | +#[no_mangle] |
| 218 | +unsafe extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { |
| 219 | + unsafe { *(&x as *const TransparentWrapper<i8x16> as *const i64) } |
| 220 | +} |
| 221 | +// CHECK-LABEL: vector_transparent_wrapper_arg_large: |
| 222 | +// CHECK: lg %r2, 0(%r2) |
| 223 | +// CHECK-NEXT: br %r14 |
| 224 | +#[cfg_attr(no_vector, target_feature(enable = "vector"))] |
| 225 | +#[no_mangle] |
| 226 | +unsafe extern "C" fn vector_transparent_wrapper_arg_large(x: TransparentWrapper<i8x32>) -> i64 { |
| 227 | + unsafe { *(&x as *const TransparentWrapper<i8x32> as *const i64) } |
| 228 | +} |
0 commit comments