1 // assembly-output: emit-asm
2 // compile-flags: --target bpfel-unknown-none -C target_feature=+alu32
3 // needs-llvm-components: bpf
5 #![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)]
6 #![crate_type = "rlib"]
8 #![allow(asm_sub_register, non_camel_case_types)]
10 #[rustc_builtin_macro]
14 #[rustc_builtin_macro]
18 #[rustc_builtin_macro]
19 macro_rules! stringify {
28 type ptr = *const u64;
37 ($func:ident $ty:ident $class:ident) => {
39 pub unsafe fn $func(x: $ty) -> $ty {
41 asm!("{} = {}", out($class) y, in($class) x);
47 macro_rules! check_reg {
48 ($func:ident $ty:ident $reg:tt) => {
50 pub unsafe fn $func(x: $ty) -> $ty {
52 asm!(concat!($reg, " = ", $reg), lateout($reg) y, in($reg) x);
62 // CHECK-LABEL: sym_fn
64 // CHECK: call extern_func
67 pub unsafe fn sym_fn() {
68 asm!("call {}", sym extern_func);
71 // CHECK-LABEL: reg_i8:
73 // CHECK: r{{[0-9]+}} = r{{[0-9]+}}
75 check!(reg_i8 i8 reg);
77 // CHECK-LABEL: reg_i16:
79 // CHECK: r{{[0-9]+}} = r{{[0-9]+}}
81 check!(reg_i16 i16 reg);
83 // CHECK-LABEL: reg_i32:
85 // CHECK: r{{[0-9]+}} = r{{[0-9]+}}
87 check!(reg_i32 i32 reg);
89 // CHECK-LABEL: reg_i64:
91 // CHECK: r{{[0-9]+}} = r{{[0-9]+}}
93 check!(reg_i64 i64 reg);
95 // CHECK-LABEL: wreg_i8:
97 // CHECK: w{{[0-9]+}} = w{{[0-9]+}}
99 check!(wreg_i8 i8 wreg);
101 // CHECK-LABEL: wreg_i16:
103 // CHECK: w{{[0-9]+}} = w{{[0-9]+}}
105 check!(wreg_i16 i16 wreg);
107 // CHECK-LABEL: wreg_i32:
109 // CHECK: w{{[0-9]+}} = w{{[0-9]+}}
111 check!(wreg_i32 i32 wreg);
113 // CHECK-LABEL: r0_i8:
117 check_reg!(r0_i8 i8 "r0");
119 // CHECK-LABEL: r0_i16:
123 check_reg!(r0_i16 i16 "r0");
125 // CHECK-LABEL: r0_i32:
129 check_reg!(r0_i32 i32 "r0");
131 // CHECK-LABEL: r0_i64:
135 check_reg!(r0_i64 i64 "r0");
137 // CHECK-LABEL: w0_i8:
141 check_reg!(w0_i8 i8 "w0");
143 // CHECK-LABEL: w0_i16:
147 check_reg!(w0_i16 i16 "w0");
149 // CHECK-LABEL: w0_i32:
153 check_reg!(w0_i32 i32 "w0");