Skip to content

Commit 2c54a1c

Browse files
authored
Merge pull request #4 from cr1901/new-asm
New asm
2 parents da617ba + f4a60ff commit 2c54a1c

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

CHANGELOG.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
## v0.1.3 - 2021-05-17
10+
## [v0.1.4] - 2022-01-27
11+
12+
- Use Rust's inline `asm` macro instead of `llvm_asm`; the latter was [removed](https://github.com/rust-lang/rust/pull/92816)
13+
from `rustc`.
14+
15+
## [v0.1.3] - 2021-05-17
1116

1217
- Remove `const_fn` feature gate, as it was removed from `rustc` after `v1.53.0`.
1318

14-
## v0.1.2 - 2020-06-09
19+
## [v0.1.2] - 2020-06-09
1520

16-
- Use llvm_asm instead of asm
21+
- Use `llvm_asm` instead of `asm`
1722

18-
## v0.1.1 - 2019-12-16
23+
## [v0.1.1] - 2019-12-16
1924

2025
- Expose AtomicOperations trait for public use
2126

@@ -27,5 +32,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2732

2833
Initial release
2934

30-
[Unreleased]: https://github.com/pftbest/msp430-atomic/compare/v0.1.2...HEAD
35+
[Unreleased]: https://github.com/pftbest/msp430-atomic/compare/v0.1.4...HEAD
36+
[v0.1.4]: https://github.com/pftbest/msp430-atomic/compare/v0.1.3...v0.1.4
37+
[v0.1.3]: https://github.com/pftbest/msp430-atomic/compare/v0.1.2...v0.1.3
3138
[v0.1.2]: https://github.com/pftbest/msp430-atomic/compare/v0.1.1...v0.1.2
39+
[v0.1.1]: https://github.com/pftbest/msp430-atomic/compare/v0.1.0...v0.1.1

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ description = "Atomic operations for MSP430 microcontrollers"
77
documentation = "https://docs.rs/msp430-atomic"
88
license = "MIT OR Apache-2.0"
99
repository = "https://github.com/pftbest/msp430-atomic"
10-
version = "0.1.3"
10+
version = "0.1.4"
11+
12+
[profile.release]
13+
opt-level = "s"

src/lib.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@
6868
//! ```
6969
7070
#![no_std]
71-
#![feature(llvm_asm)]
71+
#![feature(asm_experimental_arch)]
7272
#![cfg_attr(not(target_arch = "msp430"), feature(core_intrinsics))]
7373

74+
use core::arch::asm;
7475
use core::cell::UnsafeCell;
7576
use core::fmt;
7677

@@ -630,52 +631,44 @@ macro_rules! atomic_int {
630631
impl AtomicOperations for $int_type {
631632
#[inline(always)]
632633
unsafe fn atomic_store(dst: *mut Self, val: Self) {
633-
llvm_asm!(concat!("mov", $asm_suffix, " $1, $0")
634-
:: "*m"(dst), "ir"(val) : "memory" : "volatile");
634+
asm!(concat!("mov", $asm_suffix, " {1}, 0({0})"), in(reg) dst, in(reg) val);
635635
}
636636

637637
#[inline(always)]
638638
unsafe fn atomic_load(dst: *const Self) -> Self {
639639
let out;
640-
llvm_asm!(concat!("mov", $asm_suffix, " $1, $0")
641-
: "=r"(out) : "*m"(dst) : "memory" : "volatile");
640+
asm!(concat!("mov", $asm_suffix, " @{0}, {1}"), in(reg) dst, lateout(reg) out);
642641
out
643642
}
644643

645644
#[inline(always)]
646645
unsafe fn atomic_add(dst: *mut Self, val: Self) {
647-
llvm_asm!(concat!("add", $asm_suffix, " $1, $0")
648-
:: "*m"(dst), "ir"(val) : "memory" : "volatile");
646+
asm!(concat!("add", $asm_suffix, " {1}, 0({0})"), in(reg) dst, in(reg) val);
649647
}
650648

651649
#[inline(always)]
652650
unsafe fn atomic_sub(dst: *mut Self, val: Self) {
653-
llvm_asm!(concat!("sub", $asm_suffix, " $1, $0")
654-
:: "*m"(dst), "ir"(val) : "memory" : "volatile");
651+
asm!(concat!("sub", $asm_suffix, " {1}, 0({0})"), in(reg) dst, in(reg) val);
655652
}
656653

657654
#[inline(always)]
658655
unsafe fn atomic_and(dst: *mut Self, val: Self) {
659-
llvm_asm!(concat!("and", $asm_suffix, " $1, $0")
660-
:: "*m"(dst), "ir"(val) : "memory" : "volatile");
656+
asm!(concat!("and", $asm_suffix, " {1}, 0({0})"), in(reg) dst, in(reg) val);
661657
}
662658

663659
#[inline(always)]
664660
unsafe fn atomic_clear(dst: *mut Self, val: Self) {
665-
llvm_asm!(concat!("bic", $asm_suffix, " $1, $0")
666-
:: "*m"(dst), "ir"(val) : "memory" : "volatile");
661+
asm!(concat!("bic", $asm_suffix, " {1}, 0({0})"), in(reg) dst, in(reg) val);
667662
}
668663

669664
#[inline(always)]
670665
unsafe fn atomic_or(dst: *mut Self, val: Self) {
671-
llvm_asm!(concat!("bis", $asm_suffix, " $1, $0")
672-
:: "*m"(dst), "ir"(val) : "memory" : "volatile");
666+
asm!(concat!("bis", $asm_suffix, " {1}, 0({0})"), in(reg) dst, in(reg) val);
673667
}
674668

675669
#[inline(always)]
676670
unsafe fn atomic_xor(dst: *mut Self, val: Self) {
677-
llvm_asm!(concat!("xor", $asm_suffix, " $1, $0")
678-
:: "*m"(dst), "ir"(val) : "memory" : "volatile");
671+
asm!(concat!("xor", $asm_suffix, " {1}, 0({0})"), in(reg) dst, in(reg) val);
679672
}
680673
}
681674

0 commit comments

Comments
 (0)