|
| 1 | +//@ assembly-output: emit-asm |
| 2 | +//@ compile-flags: --target avr-unknown-gnu-atmega328 |
| 3 | +//@ needs-llvm-components: avr |
| 4 | + |
| 5 | +#![crate_type = "rlib"] |
| 6 | +#![feature(no_core, rustc_attrs, lang_items, asm_experimental_arch)] |
| 7 | +#![no_core] |
| 8 | + |
| 9 | +#[lang = "sized"] |
| 10 | +trait Sized {} |
| 11 | + |
| 12 | +#[rustc_builtin_macro] |
| 13 | +macro_rules! asm { |
| 14 | + () => {}; |
| 15 | +} |
| 16 | + |
| 17 | +// CHECK-LABEL: @sreg_is_clobbered |
| 18 | +// CHECK: void asm sideeffect "", "~{sreg}"() |
| 19 | +#[no_mangle] |
| 20 | +pub unsafe fn sreg_is_clobbered() { |
| 21 | + asm!("", options(nostack, nomem)); |
| 22 | +} |
| 23 | + |
| 24 | +// CHECK-LABEL: @sreg_is_not_clobbered_if_preserve_flags_is_used |
| 25 | +// CHECK: void asm sideeffect "", ""() |
| 26 | +#[no_mangle] |
| 27 | +pub unsafe fn sreg_is_not_clobbered_if_preserve_flags_is_used() { |
| 28 | + asm!("", options(nostack, nomem, preserves_flags)); |
| 29 | +} |
| 30 | + |
| 31 | +// CHECK-LABEL: @clobber_abi |
| 32 | +// CHECK: asm sideeffect "", "={r18},={r19},={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31},~{sreg}"() |
| 33 | +#[no_mangle] |
| 34 | +pub unsafe fn clobber_abi() { |
| 35 | + asm!("", clobber_abi("C"), options(nostack, nomem)); |
| 36 | +} |
| 37 | + |
| 38 | +// CHECK-LABEL: @clobber_abi_with_preserved_flags |
| 39 | +// CHECK: asm sideeffect "", "={r18},={r19},={r20},={r21},={r22},={r23},={r24},={r25},={r26},={r27},={r30},={r31}"() |
| 40 | +#[no_mangle] |
| 41 | +pub unsafe fn clobber_abi_with_preserved_flags() { |
| 42 | + asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); |
| 43 | +} |
0 commit comments