Skip to content

Commit 1c5bc80

Browse files
authored
refactor: replace asm! with llvm_asm! (#1)
1 parent c62af46 commit 1c5bc80

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/asm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ macro_rules! instruction {
77
pub unsafe fn $fnname() {
88
match () {
99
#[cfg(all(riscv, feature = "inline-asm"))]
10-
() => asm!($asm :::: "volatile"),
10+
() => llvm_asm!($asm :::: "volatile"),
1111

1212
#[cfg(all(riscv, not(feature = "inline-asm")))]
1313
() => {
@@ -58,7 +58,7 @@ instruction!(
5858
pub unsafe fn sfence_vma(asid: usize, addr: usize) {
5959
match () {
6060
#[cfg(all(riscv, feature = "inline-asm"))]
61-
() => asm!("sfence.vma $0, $1" :: "r"(asid), "r"(addr) :: "volatile"),
61+
() => llvm_asm!("sfence.vma $0, $1" :: "r"(asid), "r"(addr) :: "volatile"),
6262

6363
#[cfg(all(riscv, not(feature = "inline-asm")))]
6464
() => {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#![no_std]
1919
#![deny(warnings)]
2020
#![feature(nll)]
21-
#![cfg_attr(feature = "inline-asm", feature(asm))]
21+
#![cfg_attr(feature = "inline-asm", feature(llvm_asm))]
2222

2323
extern crate bare_metal;
2424
#[macro_use]

src/register/macros.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ macro_rules! read_csr {
77
#[cfg(all(riscv, feature = "inline-asm"))]
88
() => {
99
let r: usize;
10-
asm!("csrrs $0, $1, x0" : "=r"(r) : "i"($csr_number) :: "volatile");
10+
llvm_asm!("csrrs $0, $1, x0" : "=r"(r) : "i"($csr_number) :: "volatile");
1111
r
1212
}
1313

@@ -36,7 +36,7 @@ macro_rules! read_csr_rv32 {
3636
#[cfg(all(riscv32, feature = "inline-asm"))]
3737
() => {
3838
let r: usize;
39-
asm!("csrrs $0, $1, x0" : "=r"(r) : "i"($csr_number) :: "volatile");
39+
llvm_asm!("csrrs $0, $1, x0" : "=r"(r) : "i"($csr_number) :: "volatile");
4040
r
4141
}
4242

@@ -102,7 +102,7 @@ macro_rules! write_csr {
102102
unsafe fn _write(bits: usize) {
103103
match () {
104104
#[cfg(all(riscv, feature = "inline-asm"))]
105-
() => asm!("csrrw x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
105+
() => llvm_asm!("csrrw x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
106106

107107
#[cfg(all(riscv, not(feature = "inline-asm")))]
108108
() => {
@@ -140,7 +140,7 @@ macro_rules! set {
140140
unsafe fn _set(bits: usize) {
141141
match () {
142142
#[cfg(all(riscv, feature = "inline-asm"))]
143-
() => asm!("csrrs x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
143+
() => llvm_asm!("csrrs x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
144144

145145
#[cfg(all(riscv, not(feature = "inline-asm")))]
146146
() => {
@@ -166,7 +166,7 @@ macro_rules! clear {
166166
unsafe fn _clear(bits: usize) {
167167
match () {
168168
#[cfg(all(riscv, feature = "inline-asm"))]
169-
() => asm!("csrrc x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
169+
() => llvm_asm!("csrrc x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
170170

171171
#[cfg(all(riscv, not(feature = "inline-asm")))]
172172
() => {

0 commit comments

Comments
 (0)