Skip to content

Commit e64ba94

Browse files
committed
Adjust assembly tests.
1 parent 6b725d2 commit e64ba94

File tree

6 files changed

+206
-210
lines changed

6 files changed

+206
-210
lines changed

src/test/assembly/asm/avr-types.rs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,50 +30,6 @@ impl Copy for i32 {}
3030
impl Copy for i64 {}
3131
impl Copy for ptr {}
3232

33-
macro_rules! check {
34-
($func:ident $ty:ident $class:ident) => {
35-
#[no_mangle]
36-
pub unsafe fn $func(x: $ty) -> $ty {
37-
let y;
38-
asm!("mov {}, {}", lateout($class) y, in($class) x);
39-
y
40-
}
41-
};
42-
}
43-
44-
macro_rules! checkw {
45-
($func:ident $ty:ident $class:ident) => {
46-
#[no_mangle]
47-
pub unsafe fn $func(x: $ty) -> $ty {
48-
let y;
49-
asm!("movw {}, {}", lateout($class) y, in($class) x);
50-
y
51-
}
52-
};
53-
}
54-
55-
macro_rules! check_reg {
56-
($func:ident $ty:ident $reg:tt) => {
57-
#[no_mangle]
58-
pub unsafe fn $func(x: $ty) -> $ty {
59-
let y;
60-
asm!(concat!("mov ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
61-
y
62-
}
63-
};
64-
}
65-
66-
macro_rules! check_regw {
67-
($func:ident $ty:ident $reg:tt $reg_lit:tt) => {
68-
#[no_mangle]
69-
pub unsafe fn $func(x: $ty) -> $ty {
70-
let y;
71-
asm!(concat!("movw ", $reg_lit, ", ", $reg_lit), lateout($reg) y, in($reg) x);
72-
y
73-
}
74-
};
75-
}
76-
7733
extern "C" {
7834
fn extern_func();
7935
static extern_static: i8;
@@ -161,6 +117,17 @@ pub unsafe fn muls_clobber(x: i8, y: i8) -> i16 {
161117
z
162118
}
163119

120+
macro_rules! check {
121+
($func:ident $ty:ident $class:ident) => {
122+
#[no_mangle]
123+
pub unsafe fn $func(x: $ty) -> $ty {
124+
let y;
125+
asm!("mov {}, {}", lateout($class) y, in($class) x);
126+
y
127+
}
128+
};
129+
}
130+
164131
// CHECK-LABEL: reg_i8:
165132
// CHECK: ;APP
166133
// CHECK: mov r{{[0-9]+}}, r{{[0-9]+}}
@@ -173,6 +140,17 @@ check!(reg_i8 i8 reg);
173140
// CHECK: ;NO_APP
174141
check!(reg_upper_i8 i8 reg_upper);
175142

143+
macro_rules! checkw {
144+
($func:ident $ty:ident $class:ident) => {
145+
#[no_mangle]
146+
pub unsafe fn $func(x: $ty) -> $ty {
147+
let y;
148+
asm!("movw {}, {}", lateout($class) y, in($class) x);
149+
y
150+
}
151+
};
152+
}
153+
176154
// CHECK-LABEL: reg_pair_i16:
177155
// CHECK: ;APP
178156
// CHECK: movw r{{[0-9]+}}, r{{[0-9]+}}
@@ -191,6 +169,17 @@ checkw!(reg_iw_i16 i16 reg_iw);
191169
// CHECK: ;NO_APP
192170
checkw!(reg_ptr_i16 i16 reg_ptr);
193171

172+
macro_rules! check_reg {
173+
($func:ident $ty:ident $reg:tt) => {
174+
#[no_mangle]
175+
pub unsafe fn $func(x: $ty) -> $ty {
176+
let y;
177+
asm!(concat!("mov ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
178+
y
179+
}
180+
};
181+
}
182+
194183
// CHECK-LABEL: r2_i8:
195184
// CHECK: ;APP
196185
// CHECK: mov r2, r2
@@ -209,6 +198,17 @@ check_reg!(xl_i8 i8 "XL");
209198
// CHECK: ;NO_APP
210199
check_reg!(xh_i8 i8 "XH");
211200

201+
macro_rules! check_regw {
202+
($func:ident $ty:ident $reg:tt $reg_lit:tt) => {
203+
#[no_mangle]
204+
pub unsafe fn $func(x: $ty) -> $ty {
205+
let y;
206+
asm!(concat!("movw ", $reg_lit, ", ", $reg_lit), lateout($reg) y, in($reg) x);
207+
y
208+
}
209+
};
210+
}
211+
212212
// CHECK-LABEL: x_i16:
213213
// CHECK: ;APP
214214
// CHECK: movw r26, r26

src/test/assembly/asm/bpf-types.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,6 @@ impl Copy for i32 {}
3434
impl Copy for i64 {}
3535
impl Copy for ptr {}
3636

37-
macro_rules! check {
38-
($func:ident $ty:ident $class:ident) => {
39-
#[no_mangle]
40-
pub unsafe fn $func(x: $ty) -> $ty {
41-
let y;
42-
asm!("{} = {}", out($class) y, in($class) x);
43-
y
44-
}
45-
};
46-
}
47-
48-
macro_rules! check_reg {
49-
($func:ident $ty:ident $reg:tt) => {
50-
#[no_mangle]
51-
pub unsafe fn $func(x: $ty) -> $ty {
52-
let y;
53-
asm!(concat!($reg, " = ", $reg), lateout($reg) y, in($reg) x);
54-
y
55-
}
56-
};
57-
}
58-
5937
extern "C" {
6038
fn extern_func();
6139
}
@@ -69,6 +47,17 @@ pub unsafe fn sym_fn() {
6947
asm!("call {}", sym extern_func);
7048
}
7149

50+
macro_rules! check {
51+
($func:ident $ty:ident $class:ident) => {
52+
#[no_mangle]
53+
pub unsafe fn $func(x: $ty) -> $ty {
54+
let y;
55+
asm!("{} = {}", out($class) y, in($class) x);
56+
y
57+
}
58+
};
59+
}
60+
7261
// CHECK-LABEL: reg_i8:
7362
// CHECK: #APP
7463
// CHECK: r{{[0-9]+}} = r{{[0-9]+}}
@@ -111,6 +100,17 @@ check!(wreg_i16 i16 wreg);
111100
// CHECK: #NO_APP
112101
check!(wreg_i32 i32 wreg);
113102

103+
macro_rules! check_reg {
104+
($func:ident $ty:ident $reg:tt) => {
105+
#[no_mangle]
106+
pub unsafe fn $func(x: $ty) -> $ty {
107+
let y;
108+
asm!(concat!($reg, " = ", $reg), lateout($reg) y, in($reg) x);
109+
y
110+
}
111+
};
112+
}
113+
114114
// CHECK-LABEL: r0_i8:
115115
// CHECK: #APP
116116
// CHECK: r0 = r0

src/test/assembly/asm/hexagon-types.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,6 @@ extern "C" {
3737
static extern_static: u8;
3838
}
3939

40-
macro_rules! check {
41-
($func:ident $ty:ident $class:ident) => {
42-
#[no_mangle]
43-
pub unsafe fn $func(x: $ty) -> $ty {
44-
// Hack to avoid function merging
45-
extern "Rust" {
46-
fn dont_merge(s: &str);
47-
}
48-
dont_merge(stringify!($func));
49-
50-
let y;
51-
asm!("{} = {}", out($class) y, in($class) x);
52-
y
53-
}
54-
};
55-
}
56-
57-
macro_rules! check_reg {
58-
($func:ident $ty:ident $reg:tt) => {
59-
#[no_mangle]
60-
pub unsafe fn $func(x: $ty) -> $ty {
61-
// Hack to avoid function merging
62-
extern "Rust" {
63-
fn dont_merge(s: &str);
64-
}
65-
dont_merge(stringify!($func));
66-
67-
let y;
68-
asm!(concat!($reg, " = ", $reg), lateout($reg) y, in($reg) x);
69-
y
70-
}
71-
};
72-
}
73-
7440
// CHECK-LABEL: sym_static:
7541
// CHECK: InlineAsm Start
7642
// CHECK: r0 = {{#+}}extern_static
@@ -120,6 +86,23 @@ pub unsafe fn packet() {
12086
}}", out(reg) _, in(reg) &val);
12187
}
12288

89+
macro_rules! check {
90+
($func:ident $ty:ident $class:ident) => {
91+
#[no_mangle]
92+
pub unsafe fn $func(x: $ty) -> $ty {
93+
// Hack to avoid function merging
94+
extern "Rust" {
95+
fn dont_merge(s: &str);
96+
}
97+
dont_merge(stringify!($func));
98+
99+
let y;
100+
asm!("{} = {}", out($class) y, in($class) x);
101+
y
102+
}
103+
};
104+
}
105+
123106
// CHECK-LABEL: reg_ptr:
124107
// CHECK: InlineAsm Start
125108
// CHECK: r{{[0-9]+}} = r{{[0-9]+}}
@@ -150,6 +133,23 @@ check!(reg_i8 i8 reg);
150133
// CHECK: InlineAsm End
151134
check!(reg_i16 i16 reg);
152135

136+
macro_rules! check_reg {
137+
($func:ident $ty:ident $reg:tt) => {
138+
#[no_mangle]
139+
pub unsafe fn $func(x: $ty) -> $ty {
140+
// Hack to avoid function merging
141+
extern "Rust" {
142+
fn dont_merge(s: &str);
143+
}
144+
dont_merge(stringify!($func));
145+
146+
let y;
147+
asm!(concat!($reg, " = ", $reg), lateout($reg) y, in($reg) x);
148+
y
149+
}
150+
};
151+
}
152+
153153
// CHECK-LABEL: r0_ptr:
154154
// CHECK: InlineAsm Start
155155
// CHECK: r0 = r0

src/test/assembly/asm/mips-types.rs

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,6 @@ extern "Rust" {
4848
fn dont_merge(s: &str);
4949
}
5050

51-
macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
52-
#[no_mangle]
53-
pub unsafe fn $func(x: $ty) -> $ty {
54-
dont_merge(stringify!($func));
55-
56-
let y;
57-
asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
58-
y
59-
}
60-
};}
61-
62-
macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => {
63-
#[no_mangle]
64-
pub unsafe fn $func(x: $ty) -> $ty {
65-
dont_merge(stringify!($func));
66-
67-
let y;
68-
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
69-
y
70-
}
71-
};}
72-
7351
// mips32-LABEL: sym_static_32:
7452
// mips32: #APP
7553
// mips32: lw $3, %got(extern_static)
@@ -110,46 +88,35 @@ pub unsafe fn sym_fn_64() {
11088
asm!("ld $v1, {}", sym extern_func);
11189
}
11290

91+
macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
92+
#[no_mangle]
93+
pub unsafe fn $func(x: $ty) -> $ty {
94+
dont_merge(stringify!($func));
95+
96+
let y;
97+
asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
98+
y
99+
}
100+
};}
101+
113102
// CHECK-LABEL: reg_f32:
114103
// CHECK: #APP
115104
// CHECK: mov.s $f{{[0-9]+}}, $f{{[0-9]+}}
116105
// CHECK: #NO_APP
117106
check!(reg_f32, f32, freg, "mov.s");
118107

119-
// CHECK-LABEL: f0_f32:
120-
// CHECK: #APP
121-
// CHECK: mov.s $f0, $f0
122-
// CHECK: #NO_APP
123-
#[no_mangle]
124-
check_reg!(f0_f32, f32, "$f0", "mov.s");
125-
126108
// CHECK-LABEL: reg_f32_64:
127109
// CHECK: #APP
128110
// CHECK: mov.d $f{{[0-9]+}}, $f{{[0-9]+}}
129111
// CHECK: #NO_APP
130112
check!(reg_f32_64, f32, freg, "mov.d");
131113

132-
// CHECK-LABEL: f0_f32_64:
133-
// CHECK: #APP
134-
// CHECK: mov.d $f0, $f0
135-
// CHECK: #NO_APP
136-
#[no_mangle]
137-
check_reg!(f0_f32_64, f32, "$f0", "mov.d");
138-
139114
// CHECK-LABEL: reg_f64:
140115
// CHECK: #APP
141116
// CHECK: mov.d $f{{[0-9]+}}, $f{{[0-9]+}}
142117
// CHECK: #NO_APP
143-
#[no_mangle]
144118
check!(reg_f64, f64, freg, "mov.d");
145119

146-
// CHECK-LABEL: f0_f64:
147-
// CHECK: #APP
148-
// CHECK: mov.d $f0, $f0
149-
// CHECK: #NO_APP
150-
#[no_mangle]
151-
check_reg!(f0_f64, f64, "$f0", "mov.d");
152-
153120
// CHECK-LABEL: reg_ptr:
154121
// CHECK: #APP
155122
// CHECK: move ${{[0-9]+}}, ${{[0-9]+}}
@@ -200,6 +167,35 @@ check!(reg_i16, i16, reg, "move");
200167
#[cfg(mips64)]
201168
check!(reg_i64, i64, reg, "move");
202169

170+
macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => {
171+
#[no_mangle]
172+
pub unsafe fn $func(x: $ty) -> $ty {
173+
dont_merge(stringify!($func));
174+
175+
let y;
176+
asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
177+
y
178+
}
179+
};}
180+
181+
// CHECK-LABEL: f0_f32:
182+
// CHECK: #APP
183+
// CHECK: mov.s $f0, $f0
184+
// CHECK: #NO_APP
185+
check_reg!(f0_f32, f32, "$f0", "mov.s");
186+
187+
// CHECK-LABEL: f0_f32_64:
188+
// CHECK: #APP
189+
// CHECK: mov.d $f0, $f0
190+
// CHECK: #NO_APP
191+
check_reg!(f0_f32_64, f32, "$f0", "mov.d");
192+
193+
// CHECK-LABEL: f0_f64:
194+
// CHECK: #APP
195+
// CHECK: mov.d $f0, $f0
196+
// CHECK: #NO_APP
197+
check_reg!(f0_f64, f64, "$f0", "mov.d");
198+
203199
// CHECK-LABEL: r8_ptr:
204200
// CHECK: #APP
205201
// CHECK: move $8, $8

0 commit comments

Comments
 (0)