]> git.lizzy.rs Git - rust.git/blob - tests/assembly/asm/avr-modifiers.rs
Rollup merge of #106605 - notriddle:notriddle/outdated-rustbook, r=GuillaumeGomez
[rust.git] / tests / assembly / asm / avr-modifiers.rs
1 // assembly-output: emit-asm
2 // compile-flags: --target avr-unknown-gnu-atmega328
3 // needs-llvm-components: avr
4
5 #![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)]
6 #![crate_type = "rlib"]
7 #![no_core]
8 #![allow(non_camel_case_types)]
9
10 #[rustc_builtin_macro]
11 macro_rules! asm {
12     () => {};
13 }
14 #[rustc_builtin_macro]
15 macro_rules! concat {
16     () => {};
17 }
18
19 #[lang = "sized"]
20 trait Sized {}
21 #[lang = "copy"]
22 trait Copy {}
23
24 type ptr = *const u64;
25
26 impl Copy for i8 {}
27 impl Copy for i16 {}
28 impl Copy for i32 {}
29 impl Copy for i64 {}
30 impl Copy for ptr {}
31
32 macro_rules! check {
33     ($func:ident $hi:literal $lo:literal $reg:tt) => {
34         #[no_mangle]
35         unsafe fn $func() -> i16 {
36             let y;
37             asm!(concat!("mov {0:", $hi, "}, {0:", $lo, "}"), out($reg) y);
38             y
39         }
40     };
41 }
42
43 // CHECK-LABEL: reg_pair_modifiers:
44 // CHECK: ;APP
45 // CHECK: mov r{{[1-9]?[13579]}}, r{{[1-9]?[24680]}}
46 // CHECK: ;NO_APP
47 check!(reg_pair_modifiers "h" "l" reg_pair);
48
49 // CHECK-LABEL: reg_iw_modifiers:
50 // CHECK: ;APP
51 // CHECK: mov r{{[1-9]?[13579]}}, r{{[1-9]?[24680]}}
52 // CHECK: ;NO_APP
53 check!(reg_iw_modifiers "h" "l" reg_iw);
54
55 // CHECK-LABEL: reg_ptr_modifiers:
56 // CHECK: ;APP
57 // CHECK: mov r{{[1-9]?[13579]}}, r{{[1-9]?[24680]}}
58 // CHECK: ;NO_APP
59 check!(reg_ptr_modifiers "h" "l" reg_ptr);