1 // revisions: mips32 mips64
2 // assembly-output: emit-asm
3 //[mips32] compile-flags: --target mips-unknown-linux-gnu
4 //[mips32] needs-llvm-components: mips
5 //[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64
6 //[mips64] needs-llvm-components: mips
8 #![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
9 #![crate_type = "rlib"]
11 #![allow(asm_sub_register, non_camel_case_types)]
13 #[rustc_builtin_macro]
17 #[rustc_builtin_macro]
21 #[rustc_builtin_macro]
22 macro_rules! stringify {
31 type ptr = *const i32;
43 static extern_static: u8;
46 // Hack to avoid function merging
48 fn dont_merge(s: &str);
51 macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
53 pub unsafe fn $func(x: $ty) -> $ty {
54 dont_merge(stringify!($func));
57 asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
62 macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => {
64 pub unsafe fn $func(x: $ty) -> $ty {
65 dont_merge(stringify!($func));
68 asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
73 // mips32-LABEL: sym_static_32:
75 // mips32: lw $3, %got(extern_static)
79 pub unsafe fn sym_static_32() {
80 asm!("lw $v1, {}", sym extern_static);
83 // mips32-LABEL: sym_fn_32:
85 // mips32: lw $3, %got(extern_func)
89 pub unsafe fn sym_fn_32() {
90 asm!("lw $v1, {}", sym extern_func);
93 // mips64-LABEL: sym_static_64:
95 // mips64: ld $3, %got_disp(extern_static)
99 pub unsafe fn sym_static_64() {
100 asm!("ld $v1, {}", sym extern_static);
103 // mips64-LABEL: sym_fn_64:
105 // mips64: ld $3, %got_disp(extern_func)
109 pub unsafe fn sym_fn_64() {
110 asm!("ld $v1, {}", sym extern_func);
113 // CHECK-LABEL: reg_f32:
115 // CHECK: mov.s $f{{[0-9]+}}, $f{{[0-9]+}}
117 check!(reg_f32, f32, freg, "mov.s");
119 // CHECK-LABEL: f0_f32:
121 // CHECK: mov.s $f0, $f0
124 check_reg!(f0_f32, f32, "$f0", "mov.s");
126 // CHECK-LABEL: reg_f32_64:
128 // CHECK: mov.d $f{{[0-9]+}}, $f{{[0-9]+}}
130 check!(reg_f32_64, f32, freg, "mov.d");
132 // CHECK-LABEL: f0_f32_64:
134 // CHECK: mov.d $f0, $f0
137 check_reg!(f0_f32_64, f32, "$f0", "mov.d");
139 // CHECK-LABEL: reg_f64:
141 // CHECK: mov.d $f{{[0-9]+}}, $f{{[0-9]+}}
144 check!(reg_f64, f64, freg, "mov.d");
146 // CHECK-LABEL: f0_f64:
148 // CHECK: mov.d $f0, $f0
151 check_reg!(f0_f64, f64, "$f0", "mov.d");
153 // CHECK-LABEL: reg_ptr:
155 // CHECK: move ${{[0-9]+}}, ${{[0-9]+}}
157 check!(reg_ptr, ptr, reg, "move");
159 // CHECK-LABEL: reg_i32:
161 // CHECK: move ${{[0-9]+}}, ${{[0-9]+}}
163 check!(reg_i32, i32, reg, "move");
165 // CHECK-LABEL: reg_f32_soft:
167 // CHECK: move ${{[0-9]+}}, ${{[0-9]+}}
169 check!(reg_f32_soft, f32, reg, "move");
171 // mips64-LABEL: reg_f64_soft:
173 // mips64: move ${{[0-9]+}}, ${{[0-9]+}}
176 check!(reg_f64_soft, f64, reg, "move");
178 // CHECK-LABEL: reg_i8:
180 // CHECK: move ${{[0-9]+}}, ${{[0-9]+}}
182 check!(reg_i8, i8, reg, "move");
184 // CHECK-LABEL: reg_u8:
186 // CHECK: move ${{[0-9]+}}, ${{[0-9]+}}
188 check!(reg_u8, u8, reg, "move");
190 // CHECK-LABEL: reg_i16:
192 // CHECK: move ${{[0-9]+}}, ${{[0-9]+}}
194 check!(reg_i16, i16, reg, "move");
196 // mips64-LABEL: reg_i64:
198 // mips64: move ${{[0-9]+}}, ${{[0-9]+}}
201 check!(reg_i64, i64, reg, "move");
203 // CHECK-LABEL: r8_ptr:
205 // CHECK: move $8, $8
207 check_reg!(r8_ptr, ptr, "$8", "move");
209 // CHECK-LABEL: r8_i32:
211 // CHECK: move $8, $8
213 check_reg!(r8_i32, i32, "$8", "move");
215 // CHECK-LABEL: r8_f32:
217 // CHECK: move $8, $8
219 check_reg!(r8_f32, f32, "$8", "move");
221 // CHECK-LABEL: r8_i8:
223 // CHECK: move $8, $8
225 check_reg!(r8_i8, i8, "$8", "move");
227 // CHECK-LABEL: r8_u8:
229 // CHECK: move $8, $8
231 check_reg!(r8_u8, u8, "$8", "move");
233 // CHECK-LABEL: r8_i16:
235 // CHECK: move $8, $8
237 check_reg!(r8_i16, i16, "$8", "move");