]> git.proxmox.com Git - rustc.git/blame - src/test/assembly/asm/arm-modifiers.rs
New upstream version 1.58.1+dfsg1
[rustc.git] / src / test / assembly / asm / arm-modifiers.rs
CommitLineData
f9f354fc
XL
1// assembly-output: emit-asm
2// compile-flags: -O
3// compile-flags: --target armv7-unknown-linux-gnueabihf
4// compile-flags: -C target-feature=+neon
3dfed10e 5// needs-llvm-components: arm
f9f354fc
XL
6
7#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
8#![crate_type = "rlib"]
9#![no_core]
10#![allow(asm_sub_register, non_camel_case_types)]
11
12#[rustc_builtin_macro]
13macro_rules! asm {
14 () => {};
15}
16#[rustc_builtin_macro]
17macro_rules! concat {
18 () => {};
19}
20#[rustc_builtin_macro]
21macro_rules! stringify {
22 () => {};
23}
24
25#[lang = "sized"]
26trait Sized {}
27#[lang = "copy"]
28trait Copy {}
29
30#[repr(simd)]
31pub struct f32x4(f32, f32, f32, f32);
32
33impl Copy for i32 {}
34impl Copy for f32 {}
35impl Copy for f64 {}
36impl Copy for f32x4 {}
37
38macro_rules! check {
39 ($func:ident $modifier:literal $reg:ident $ty:ident $mov:literal) => {
40 // -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0
41 #[no_mangle]
42 pub unsafe extern "C" fn $func() -> $ty {
43 // Hack to avoid function merging
44 extern "Rust" {
45 fn dont_merge(s: &str);
46 }
47 dont_merge(stringify!($func));
48
49 let y;
50 asm!(concat!($mov, " {0:", $modifier, "}, {0:", $modifier, "}"), out($reg) y);
51 y
52 }
53 };
54}
55
56// CHECK-LABEL: reg:
57// CHECK: @APP
58// CHECK: mov r0, r0
59// CHECK: @NO_APP
60check!(reg "" reg i32 "mov");
61
62// CHECK-LABEL: reg_thumb:
63// CHECK: @APP
64// CHECK: mov r0, r0
65// CHECK: @NO_APP
66check!(reg_thumb "" reg_thumb i32 "mov");
67
68// CHECK-LABEL: sreg:
69// CHECK: @APP
70// CHECK: vmov.f32 s0, s0
71// CHECK: @NO_APP
72check!(sreg "" sreg f32 "vmov.f32");
73
74// CHECK-LABEL: sreg_low16:
75// CHECK: @APP
76// CHECK: vmov.f32 s0, s0
77// CHECK: @NO_APP
78check!(sreg_low16 "" sreg_low16 f32 "vmov.f32");
79
80// CHECK-LABEL: dreg:
81// CHECK: @APP
82// CHECK: vmov.f64 d0, d0
83// CHECK: @NO_APP
84check!(dreg "" dreg f64 "vmov.f64");
85
86// CHECK-LABEL: dreg_low16:
87// CHECK: @APP
88// CHECK: vmov.f64 d0, d0
89// CHECK: @NO_APP
90check!(dreg_low16 "" dreg_low16 f64 "vmov.f64");
91
92// CHECK-LABEL: dreg_low8:
93// CHECK: @APP
94// CHECK: vmov.f64 d0, d0
95// CHECK: @NO_APP
96check!(dreg_low8 "" dreg_low8 f64 "vmov.f64");
97
98// CHECK-LABEL: qreg:
99// CHECK: @APP
100// CHECK: vorr q0, q0, q0
101// CHECK: @NO_APP
102check!(qreg "" qreg f32x4 "vmov");
103
104// CHECK-LABEL: qreg_e:
105// CHECK: @APP
106// CHECK: vmov.f64 d0, d0
107// CHECK: @NO_APP
108check!(qreg_e "e" qreg f32x4 "vmov.f64");
109
110// CHECK-LABEL: qreg_f:
111// CHECK: @APP
112// CHECK: vmov.f64 d1, d1
113// CHECK: @NO_APP
114check!(qreg_f "f" qreg f32x4 "vmov.f64");
115
116// CHECK-LABEL: qreg_low8:
117// CHECK: @APP
118// CHECK: vorr q0, q0, q0
119// CHECK: @NO_APP
120check!(qreg_low8 "" qreg_low8 f32x4 "vmov");
121
122// CHECK-LABEL: qreg_low8_e:
123// CHECK: @APP
124// CHECK: vmov.f64 d0, d0
125// CHECK: @NO_APP
126check!(qreg_low8_e "e" qreg_low8 f32x4 "vmov.f64");
127
128// CHECK-LABEL: qreg_low8_f:
129// CHECK: @APP
130// CHECK: vmov.f64 d1, d1
131// CHECK: @NO_APP
132check!(qreg_low8_f "f" qreg_low8 f32x4 "vmov.f64");
133
134// CHECK-LABEL: qreg_low4:
135// CHECK: @APP
136// CHECK: vorr q0, q0, q0
137// CHECK: @NO_APP
138check!(qreg_low4 "" qreg_low4 f32x4 "vmov");
139
140// CHECK-LABEL: qreg_low4_e:
141// CHECK: @APP
142// CHECK: vmov.f64 d0, d0
143// CHECK: @NO_APP
144check!(qreg_low4_e "e" qreg_low4 f32x4 "vmov.f64");
145
146// CHECK-LABEL: qreg_low4_f:
147// CHECK: @APP
148// CHECK: vmov.f64 d1, d1
149// CHECK: @NO_APP
150check!(qreg_low4_f "f" qreg_low4 f32x4 "vmov.f64");