2 // assembly-output: emit-asm
3 //[s390x] compile-flags: --target s390x-unknown-linux-gnu
4 //[s390x] needs-llvm-components: systemz
6 #![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
7 #![crate_type = "rlib"]
9 #![allow(asm_sub_register, non_camel_case_types)]
11 #[rustc_builtin_macro]
15 #[rustc_builtin_macro]
19 #[rustc_builtin_macro]
20 macro_rules! stringify {
29 type ptr = *const i32;
42 static extern_static: u8;
45 // Hack to avoid function merging
47 fn dont_merge(s: &str);
50 macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
52 pub unsafe fn $func(x: $ty) -> $ty {
53 dont_merge(stringify!($func));
56 asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
61 macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => {
63 pub unsafe fn $func(x: $ty) -> $ty {
64 dont_merge(stringify!($func));
67 asm!(concat!($mov, " %", $reg, ", %", $reg), lateout($reg) y, in($reg) x);
72 // CHECK-LABEL: sym_fn_32:
74 // CHECK: brasl %r14, extern_func
78 pub unsafe fn sym_fn_32() {
79 asm!("brasl %r14, {}", sym extern_func);
82 // CHECK-LABEL: sym_static:
84 // CHECK: brasl %r14, extern_static
87 pub unsafe fn sym_static() {
88 asm!("brasl %r14, {}", sym extern_static);
91 // CHECK-LABEL: reg_i8:
93 // CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
95 check!(reg_i8, i8, reg, "lgr");
97 // CHECK-LABEL: reg_i16:
99 // CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
101 check!(reg_i16, i16, reg, "lgr");
103 // CHECK-LABEL: reg_i32:
105 // CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
107 check!(reg_i32, i32, reg, "lgr");
109 // CHECK-LABEL: reg_i64:
111 // CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
113 check!(reg_i64, i64, reg, "lgr");
115 // CHECK-LABEL: reg_f32:
117 // CHECK: ler %f{{[0-9]+}}, %f{{[0-9]+}}
119 check!(reg_f32, f32, freg, "ler");
121 // CHECK-LABEL: reg_f64:
123 // CHECK: ldr %f{{[0-9]+}}, %f{{[0-9]+}}
125 check!(reg_f64, f64, freg, "ldr");
127 // CHECK-LABEL: reg_ptr:
129 // CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
131 check!(reg_ptr, ptr, reg, "lgr");
133 // CHECK-LABEL: r0_i8:
135 // CHECK: lr %r0, %r0
137 check_reg!(r0_i8, i8, "r0", "lr");
139 // CHECK-LABEL: r0_i16:
141 // CHECK: lr %r0, %r0
143 check_reg!(r0_i16, i16, "r0", "lr");
145 // CHECK-LABEL: r0_i32:
147 // CHECK: lr %r0, %r0
149 check_reg!(r0_i32, i32, "r0", "lr");
151 // CHECK-LABEL: r0_i64:
153 // CHECK: lr %r0, %r0
155 check_reg!(r0_i64, i64, "r0", "lr");
157 // CHECK-LABEL: f0_f32:
159 // CHECK: ler %f0, %f0
161 check_reg!(f0_f32, f32, "f0", "ler");
163 // CHECK-LABEL: f0_f64:
165 // CHECK: ldr %f0, %f0
167 check_reg!(f0_f64, f64, "f0", "ldr");