5
5
//@ [arm64ec] compile-flags: --target arm64ec-pc-windows-msvc
6
6
//@ [arm64ec] needs-llvm-components: aarch64
7
7
8
- #![ feature( no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch) ]
8
+ #![ feature( no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch, f16 , f128 ) ]
9
9
#![ crate_type = "rlib" ]
10
10
#![ no_core]
11
11
#![ allow( asm_sub_register, non_camel_case_types) ]
12
+ // FIXME(f16_f128): Only needed for FIXME in check! and check_reg!
13
+ #![ feature( auto_traits) ]
12
14
13
15
#[ rustc_builtin_macro]
14
16
macro_rules! asm {
@@ -39,6 +41,8 @@ pub struct i32x2(i32, i32);
39
41
#[ repr( simd) ]
40
42
pub struct i64x1 ( i64 ) ;
41
43
#[ repr( simd) ]
44
+ pub struct f16x4 ( f16 , f16 , f16 , f16 ) ;
45
+ #[ repr( simd) ]
42
46
pub struct f32x2 ( f32 , f32 ) ;
43
47
#[ repr( simd) ]
44
48
pub struct f64x1 ( f64 ) ;
@@ -51,30 +55,42 @@ pub struct i32x4(i32, i32, i32, i32);
51
55
#[ repr( simd) ]
52
56
pub struct i64x2 ( i64 , i64 ) ;
53
57
#[ repr( simd) ]
58
+ pub struct f16x8 ( f16 , f16 , f16 , f16 , f16 , f16 , f16 , f16 ) ;
59
+ #[ repr( simd) ]
54
60
pub struct f32x4 ( f32 , f32 , f32 , f32 ) ;
55
61
#[ repr( simd) ]
56
62
pub struct f64x2 ( f64 , f64 ) ;
57
63
58
64
impl Copy for i8 { }
59
65
impl Copy for i16 { }
66
+ impl Copy for f16 { }
60
67
impl Copy for i32 { }
61
68
impl Copy for f32 { }
62
69
impl Copy for i64 { }
63
70
impl Copy for f64 { }
71
+ impl Copy for f128 { }
64
72
impl Copy for ptr { }
65
73
impl Copy for i8x8 { }
66
74
impl Copy for i16x4 { }
67
75
impl Copy for i32x2 { }
68
76
impl Copy for i64x1 { }
77
+ impl Copy for f16x4 { }
69
78
impl Copy for f32x2 { }
70
79
impl Copy for f64x1 { }
71
80
impl Copy for i8x16 { }
72
81
impl Copy for i16x8 { }
73
82
impl Copy for i32x4 { }
74
83
impl Copy for i64x2 { }
84
+ impl Copy for f16x8 { }
75
85
impl Copy for f32x4 { }
76
86
impl Copy for f64x2 { }
77
87
88
+ // FIXME(f16_f128): Only needed for FIXME in check! and check_reg!
89
+ #[ lang = "freeze" ]
90
+ unsafe auto trait Freeze { }
91
+ #[ lang = "unpin" ]
92
+ auto trait Unpin { }
93
+
78
94
extern "C" {
79
95
fn extern_func ( ) ;
80
96
static extern_static: u8 ;
@@ -111,38 +127,44 @@ pub unsafe fn issue_75761() {
111
127
112
128
macro_rules! check {
113
129
( $func: ident $ty: ident $class: ident $mov: literal $modifier: literal) => {
130
+ // FIXME(f16_f128): Change back to `$func(x: $ty) -> $ty` once arm64ec can pass and return
131
+ // `f16` and `f128` without LLVM erroring.
132
+ // LLVM issue: <https://github.com/llvm/llvm-project/issues/94434>
114
133
#[ no_mangle]
115
- pub unsafe fn $func( x : $ty) -> $ty {
134
+ pub unsafe fn $func( inp : & $ty, out : & mut $ty) {
116
135
// Hack to avoid function merging
117
136
extern "Rust" {
118
137
fn dont_merge( s: & str ) ;
119
138
}
120
139
dont_merge( stringify!( $func) ) ;
121
140
141
+ let x = * inp;
122
142
let y;
123
143
asm!(
124
144
concat!( $mov, " {:" , $modifier, "}, {:" , $modifier, "}" ) ,
125
145
out( $class) y,
126
146
in( $class) x
127
147
) ;
128
- y
148
+ * out = y ;
129
149
}
130
150
} ;
131
151
}
132
152
133
153
macro_rules! check_reg {
134
154
( $func: ident $ty: ident $reg: tt $mov: literal) => {
155
+ // FIXME(f16_f128): See FIXME in `check!`
135
156
#[ no_mangle]
136
- pub unsafe fn $func( x : $ty) -> $ty {
157
+ pub unsafe fn $func( inp : & $ty, out : & mut $ty) {
137
158
// Hack to avoid function merging
138
159
extern "Rust" {
139
160
fn dont_merge( s: & str ) ;
140
161
}
141
162
dont_merge( stringify!( $func) ) ;
142
163
164
+ let x = * inp;
143
165
let y;
144
166
asm!( concat!( $mov, " " , $reg, ", " , $reg) , lateout( $reg) y, in( $reg) x) ;
145
- y
167
+ * out = y ;
146
168
}
147
169
} ;
148
170
}
@@ -159,6 +181,12 @@ check!(reg_i8 i8 reg "mov" "");
159
181
// CHECK: //NO_APP
160
182
check ! ( reg_i16 i16 reg "mov" "" ) ;
161
183
184
+ // CHECK-LABEL: {{("#)?}}reg_f16{{"?}}
185
+ // CHECK: //APP
186
+ // CHECK: mov x{{[0-9]+}}, x{{[0-9]+}}
187
+ // CHECK: //NO_APP
188
+ check ! ( reg_f16 f16 reg "mov" "" ) ;
189
+
162
190
// CHECK-LABEL: {{("#)?}}reg_i32{{"?}}
163
191
// CHECK: //APP
164
192
// CHECK: mov x{{[0-9]+}}, x{{[0-9]+}}
@@ -201,6 +229,12 @@ check!(vreg_i8 i8 vreg "fmov" "s");
201
229
// CHECK: //NO_APP
202
230
check ! ( vreg_i16 i16 vreg "fmov" "s" ) ;
203
231
232
+ // CHECK-LABEL: {{("#)?}}vreg_f16{{"?}}
233
+ // CHECK: //APP
234
+ // CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
235
+ // CHECK: //NO_APP
236
+ check ! ( vreg_f16 f16 vreg "fmov" "s" ) ;
237
+
204
238
// CHECK-LABEL: {{("#)?}}vreg_i32{{"?}}
205
239
// CHECK: //APP
206
240
// CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
@@ -225,6 +259,12 @@ check!(vreg_i64 i64 vreg "fmov" "s");
225
259
// CHECK: //NO_APP
226
260
check ! ( vreg_f64 f64 vreg "fmov" "s" ) ;
227
261
262
+ // CHECK-LABEL: {{("#)?}}vreg_f128{{"?}}
263
+ // CHECK: //APP
264
+ // CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
265
+ // CHECK: //NO_APP
266
+ check ! ( vreg_f128 f128 vreg "fmov" "s" ) ;
267
+
228
268
// CHECK-LABEL: {{("#)?}}vreg_ptr{{"?}}
229
269
// CHECK: //APP
230
270
// CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
@@ -255,6 +295,12 @@ check!(vreg_i32x2 i32x2 vreg "fmov" "s");
255
295
// CHECK: //NO_APP
256
296
check ! ( vreg_i64x1 i64x1 vreg "fmov" "s" ) ;
257
297
298
+ // CHECK-LABEL: {{("#)?}}vreg_f16x4{{"?}}
299
+ // CHECK: //APP
300
+ // CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
301
+ // CHECK: //NO_APP
302
+ check ! ( vreg_f16x4 f16x4 vreg "fmov" "s" ) ;
303
+
258
304
// CHECK-LABEL: {{("#)?}}vreg_f32x2{{"?}}
259
305
// CHECK: //APP
260
306
// CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
@@ -291,6 +337,12 @@ check!(vreg_i32x4 i32x4 vreg "fmov" "s");
291
337
// CHECK: //NO_APP
292
338
check ! ( vreg_i64x2 i64x2 vreg "fmov" "s" ) ;
293
339
340
+ // CHECK-LABEL: {{("#)?}}vreg_f16x8{{"?}}
341
+ // CHECK: //APP
342
+ // CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
343
+ // CHECK: //NO_APP
344
+ check ! ( vreg_f16x8 f16x8 vreg "fmov" "s" ) ;
345
+
294
346
// CHECK-LABEL: {{("#)?}}vreg_f32x4{{"?}}
295
347
// CHECK: //APP
296
348
// CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
@@ -315,6 +367,12 @@ check!(vreg_low16_i8 i8 vreg_low16 "fmov" "s");
315
367
// CHECK: //NO_APP
316
368
check ! ( vreg_low16_i16 i16 vreg_low16 "fmov" "s" ) ;
317
369
370
+ // CHECK-LABEL: {{("#)?}}vreg_low16_f16{{"?}}
371
+ // CHECK: //APP
372
+ // CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
373
+ // CHECK: //NO_APP
374
+ check ! ( vreg_low16_f16 f16 vreg_low16 "fmov" "s" ) ;
375
+
318
376
// CHECK-LABEL: {{("#)?}}vreg_low16_f32{{"?}}
319
377
// CHECK: //APP
320
378
// CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
@@ -333,6 +391,12 @@ check!(vreg_low16_i64 i64 vreg_low16 "fmov" "s");
333
391
// CHECK: //NO_APP
334
392
check ! ( vreg_low16_f64 f64 vreg_low16 "fmov" "s" ) ;
335
393
394
+ // CHECK-LABEL: {{("#)?}}vreg_low16_f128{{"?}}
395
+ // CHECK: //APP
396
+ // CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
397
+ // CHECK: //NO_APP
398
+ check ! ( vreg_low16_f128 f128 vreg_low16 "fmov" "s" ) ;
399
+
336
400
// CHECK-LABEL: {{("#)?}}vreg_low16_ptr{{"?}}
337
401
// CHECK: //APP
338
402
// CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
@@ -363,6 +427,12 @@ check!(vreg_low16_i32x2 i32x2 vreg_low16 "fmov" "s");
363
427
// CHECK: //NO_APP
364
428
check ! ( vreg_low16_i64x1 i64x1 vreg_low16 "fmov" "s" ) ;
365
429
430
+ // CHECK-LABEL: {{("#)?}}vreg_low16_f16x4{{"?}}
431
+ // CHECK: //APP
432
+ // CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
433
+ // CHECK: //NO_APP
434
+ check ! ( vreg_low16_f16x4 f16x4 vreg_low16 "fmov" "s" ) ;
435
+
366
436
// CHECK-LABEL: {{("#)?}}vreg_low16_f32x2{{"?}}
367
437
// CHECK: //APP
368
438
// CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
@@ -399,6 +469,12 @@ check!(vreg_low16_i32x4 i32x4 vreg_low16 "fmov" "s");
399
469
// CHECK: //NO_APP
400
470
check ! ( vreg_low16_i64x2 i64x2 vreg_low16 "fmov" "s" ) ;
401
471
472
+ // CHECK-LABEL: {{("#)?}}vreg_low16_f16x8{{"?}}
473
+ // CHECK: //APP
474
+ // CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
475
+ // CHECK: //NO_APP
476
+ check ! ( vreg_low16_f16x8 f16x8 vreg_low16 "fmov" "s" ) ;
477
+
402
478
// CHECK-LABEL: {{("#)?}}vreg_low16_f32x4{{"?}}
403
479
// CHECK: //APP
404
480
// CHECK: fmov s{{[0-9]+}}, s{{[0-9]+}}
@@ -423,6 +499,12 @@ check_reg!(x0_i8 i8 "x0" "mov");
423
499
// CHECK: //NO_APP
424
500
check_reg ! ( x0_i16 i16 "x0" "mov" ) ;
425
501
502
+ // CHECK-LABEL: {{("#)?}}x0_f16{{"?}}
503
+ // CHECK: //APP
504
+ // CHECK: mov x{{[0-9]+}}, x{{[0-9]+}}
505
+ // CHECK: //NO_APP
506
+ check_reg ! ( x0_f16 f16 "x0" "mov" ) ;
507
+
426
508
// CHECK-LABEL: {{("#)?}}x0_i32{{"?}}
427
509
// CHECK: //APP
428
510
// CHECK: mov x{{[0-9]+}}, x{{[0-9]+}}
@@ -465,6 +547,12 @@ check_reg!(v0_i8 i8 "s0" "fmov");
465
547
// CHECK: //NO_APP
466
548
check_reg ! ( v0_i16 i16 "s0" "fmov" ) ;
467
549
550
+ // CHECK-LABEL: {{("#)?}}v0_f16{{"?}}
551
+ // CHECK: //APP
552
+ // CHECK: fmov s0, s0
553
+ // CHECK: //NO_APP
554
+ check_reg ! ( v0_f16 f16 "s0" "fmov" ) ;
555
+
468
556
// CHECK-LABEL: {{("#)?}}v0_i32{{"?}}
469
557
// CHECK: //APP
470
558
// CHECK: fmov s0, s0
@@ -489,6 +577,12 @@ check_reg!(v0_i64 i64 "s0" "fmov");
489
577
// CHECK: //NO_APP
490
578
check_reg ! ( v0_f64 f64 "s0" "fmov" ) ;
491
579
580
+ // CHECK-LABEL: {{("#)?}}v0_f128{{"?}}
581
+ // CHECK: //APP
582
+ // CHECK: fmov s0, s0
583
+ // CHECK: //NO_APP
584
+ check_reg ! ( v0_f128 f128 "s0" "fmov" ) ;
585
+
492
586
// CHECK-LABEL: {{("#)?}}v0_ptr{{"?}}
493
587
// CHECK: //APP
494
588
// CHECK: fmov s0, s0
@@ -519,6 +613,12 @@ check_reg!(v0_i32x2 i32x2 "s0" "fmov");
519
613
// CHECK: //NO_APP
520
614
check_reg ! ( v0_i64x1 i64x1 "s0" "fmov" ) ;
521
615
616
+ // CHECK-LABEL: {{("#)?}}v0_f16x4{{"?}}
617
+ // CHECK: //APP
618
+ // CHECK: fmov s0, s0
619
+ // CHECK: //NO_APP
620
+ check_reg ! ( v0_f16x4 f16x4 "s0" "fmov" ) ;
621
+
522
622
// CHECK-LABEL: {{("#)?}}v0_f32x2{{"?}}
523
623
// CHECK: //APP
524
624
// CHECK: fmov s0, s0
@@ -555,6 +655,12 @@ check_reg!(v0_i32x4 i32x4 "s0" "fmov");
555
655
// CHECK: //NO_APP
556
656
check_reg ! ( v0_i64x2 i64x2 "s0" "fmov" ) ;
557
657
658
+ // CHECK-LABEL: {{("#)?}}v0_f16x8{{"?}}
659
+ // CHECK: //APP
660
+ // CHECK: fmov s0, s0
661
+ // CHECK: //NO_APP
662
+ check_reg ! ( v0_f16x8 f16x8 "s0" "fmov" ) ;
663
+
558
664
// CHECK-LABEL: {{("#)?}}v0_f32x4{{"?}}
559
665
// CHECK: //APP
560
666
// CHECK: fmov s0, s0
0 commit comments