Skip to content

Commit

Permalink
Migrate llvm_asm! to asm!
Browse files Browse the repository at this point in the history
The macro llvm_asm! finally got removed as 'asm!' got stabilized in
nightly. See
rust-lang/rust#70173 (comment)
and this gets shipped starting with nightly 2022-01-17.

According to
https://users.rust-lang.org/t/volatile-option-in-new-asm-macro/44289/2
assembly is volatile by default with asm!.
  • Loading branch information
sirhcel committed Jan 19, 2022
1 parent 4e96ba6 commit 566a7be
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ pub fn core() -> u32 {
let mut core = 0;

#[cfg(any(esp32, esp32s3))]
#[allow(deprecated)]
unsafe {
llvm_asm!("rsr.prid $0\nextui $0,$0,13,1" : "=r"(core) : : : "volatile");
asm!("rsr.prid {}\nextui {},{},13,1", out(reg) core);
}

core
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(llvm_asm)]
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(generic_associated_types)] // For mutex

Expand Down
4 changes: 2 additions & 2 deletions src/ulp/sys/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub const ULP_RISCV_CYCLES_PER_US_DENUM: u32 = 10;
pub const ULP_RISCV_CYCLES_PER_MS: u32 =
ULP_RISCV_CYCLES_PER_US_NUM * (1000 / ULP_RISCV_CYCLES_PER_US_DENUM);

use core::arch::asm;
use crate::ulp::pac::*;
use crate::ulp::reg::*;

Expand All @@ -17,9 +18,8 @@ pub fn get_ccount() -> u32 {
#[allow(unused_assignments)]
let mut ccount = 0;

#[allow(deprecated)]
unsafe {
llvm_asm!("rdcycle $0" : "=r"(ccount) : : : "volatile");
asm!("rdcycle {}", out(reg) ccount);
}

ccount
Expand Down

0 comments on commit 566a7be

Please sign in to comment.