1 // min-llvm-version: 13.0
2 // assembly-output: emit-asm
3 // compile-flags: --target msp430-none-elf
4 // needs-llvm-components: msp430
6 #![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch, asm_const)]
7 #![crate_type = "rlib"]
9 #![allow(non_camel_case_types)]
11 #[rustc_builtin_macro]
15 #[rustc_builtin_macro]
25 type ptr = *const i16;
34 ($func:ident $ty:ident $class:ident) => {
36 pub unsafe fn $func(x: $ty) -> $ty {
38 asm!("mov {}, {}", lateout($class) y, in($class) x);
45 ($func:ident $ty:ident $class:ident) => {
47 pub unsafe fn $func(x: $ty) -> $ty {
49 asm!("mov.b {}, {}", lateout($class) y, in($class) x);
55 macro_rules! check_reg {
56 ($func:ident $ty:ident $reg:tt) => {
58 pub unsafe fn $func(x: $ty) -> $ty {
60 asm!(concat!("mov ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
66 macro_rules! check_regb {
67 ($func:ident $ty:ident $reg:tt) => {
69 pub unsafe fn $func(x: $ty) -> $ty {
71 asm!(concat!("mov.b ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
79 static extern_static: i8;
82 // CHECK-LABEL: sym_fn
84 // CHECK: call extern_func
87 pub unsafe fn sym_fn() {
88 asm!("call {}", sym extern_func);
91 // CHECK-LABEL: sym_static
93 // CHECK: mov.b extern_static, r{{[0-9]+}}
96 pub unsafe fn sym_static() -> i8 {
98 asm!("mov.b {1}, {0}", lateout(reg) y, sym extern_static);
102 // CHECK-LABEL: add_const:
104 // CHECK: add.b #5, r{{[0-9]+}}
107 pub unsafe fn add_const() -> i8 {
109 asm!("add.b #{number}, {}", out(reg) y, number = const 5);
113 // CHECK-LABEL: mov_postincrement:
115 // CHECK: mov @r5+, r{{[0-9]+}}
118 pub unsafe fn mov_postincrement(mut x: *const i16) -> (i16, *const i16) {
120 asm!("mov @r5+, {0}", out(reg) y, inlateout("r5") x);
124 // CHECK-LABEL: reg_i8:
126 // CHECK: mov r{{[0-9]+}}, r{{[0-9]+}}
128 check!(reg_i8 i8 reg);
130 // CHECK-LABEL: reg_i16:
132 // CHECK: mov r{{[0-9]+}}, r{{[0-9]+}}
134 check!(reg_i16 i16 reg);
136 // CHECK-LABEL: reg_i8b:
138 // CHECK: mov.b r{{[0-9]+}}, r{{[0-9]+}}
140 checkb!(reg_i8b i8 reg);
142 // CHECK-LABEL: r5_i8:
146 check_reg!(r5_i8 i8 "r5");
148 // CHECK-LABEL: r5_i16:
152 check_reg!(r5_i16 i16 "r5");
154 // CHECK-LABEL: r5_i8b:
156 // CHECK: mov.b r5, r5
158 check_regb!(r5_i8b i8 "r5");