-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #131310 - taiki-e:msp430-clobber-abi, r=Amanieu
Support clobber_abi in MSP430 inline assembly This supports `clobber_abi` which is one of the requirements of stabilization mentioned in #93335. Refs: Section 3.2 "Register Conventions" in [MSP430 Embedded Application Binary Interface](https://www.ti.com/lit/an/slaa534a/slaa534a.pdf) cc ``@cr1901`` r? ``@Amanieu`` ``@rustbot`` label +O-msp430
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//@ assembly-output: emit-asm | ||
//@ compile-flags: --target msp430-none-elf | ||
//@ needs-llvm-components: msp430 | ||
|
||
#![crate_type = "rlib"] | ||
#![feature(no_core, rustc_attrs, lang_items, asm_experimental_arch)] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
|
||
#[rustc_builtin_macro] | ||
macro_rules! asm { | ||
() => {}; | ||
} | ||
|
||
// CHECK-LABEL: @sr_clobber | ||
// CHECK: call void asm sideeffect "", "~{sr}"() | ||
#[no_mangle] | ||
pub unsafe fn sr_clobber() { | ||
asm!("", options(nostack, nomem)); | ||
} | ||
|
||
// CHECK-LABEL: @no_clobber | ||
// CHECK: call void asm sideeffect "", ""() | ||
#[no_mangle] | ||
pub unsafe fn no_clobber() { | ||
asm!("", options(nostack, nomem, preserves_flags)); | ||
} | ||
|
||
// CHECK-LABEL: @clobber_abi | ||
// CHECK: asm sideeffect "", "={r11},={r12},={r13},={r14},={r15}"() | ||
#[no_mangle] | ||
pub unsafe fn clobber_abi() { | ||
asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ||
} |