Skip to content

Commit 566a7be

Browse files
committed
Migrate llvm_asm! to asm!
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!.
1 parent 4e96ba6 commit 566a7be

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

src/cpu.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ pub fn core() -> u32 {
2020
let mut core = 0;
2121

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

2827
core

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(llvm_asm)]
21
#![cfg_attr(not(feature = "std"), no_std)]
32
#![feature(generic_associated_types)] // For mutex
43

src/ulp/sys/cpu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub const ULP_RISCV_CYCLES_PER_US_DENUM: u32 = 10;
99
pub const ULP_RISCV_CYCLES_PER_MS: u32 =
1010
ULP_RISCV_CYCLES_PER_US_NUM * (1000 / ULP_RISCV_CYCLES_PER_US_DENUM);
1111

12+
use core::arch::asm;
1213
use crate::ulp::pac::*;
1314
use crate::ulp::reg::*;
1415

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

20-
#[allow(deprecated)]
2121
unsafe {
22-
llvm_asm!("rdcycle $0" : "=r"(ccount) : : : "volatile");
22+
asm!("rdcycle {}", out(reg) ccount);
2323
}
2424

2525
ccount

0 commit comments

Comments
 (0)