Skip to content

feat: Use new asm! instead of llvm_asm! #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed

- Use new `asm!` instead of `llvm_asm!`

## [v0.7.0] - 2020-07-29

### Added
Expand Down
4 changes: 2 additions & 2 deletions src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro_rules! instruction {
pub unsafe fn $fnname() {
match () {
#[cfg(all(riscv, feature = "inline-asm"))]
() => llvm_asm!($asm :::: "volatile"),
() => asm!($asm),

#[cfg(all(riscv, not(feature = "inline-asm")))]
() => {
Expand Down Expand Up @@ -58,7 +58,7 @@ instruction!(
pub unsafe fn sfence_vma(asid: usize, addr: usize) {
match () {
#[cfg(all(riscv, feature = "inline-asm"))]
() => llvm_asm!("sfence.vma $0, $1" :: "r"(asid), "r"(addr) :: "volatile"),
() => asm!("sfence.vma {0}, {1}", in(reg) asid, in(reg) addr),

#[cfg(all(riscv, not(feature = "inline-asm")))]
() => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! - Wrappers around assembly instructions like `WFI`.

#![no_std]
#![cfg_attr(feature = "inline-asm", feature(llvm_asm))]
#![cfg_attr(feature = "inline-asm", feature(asm))]

extern crate bare_metal;
extern crate bit_field;
Expand Down
12 changes: 6 additions & 6 deletions src/register/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro_rules! read_csr {
#[cfg(all(riscv, feature = "inline-asm"))]
() => {
let r: usize;
llvm_asm!("csrrs $0, $1, x0" : "=r"(r) : "i"($csr_number) :: "volatile");
asm!("csrrs {0}, {1}, x0", out(reg) r, const $csr_number);
r
}

Expand Down Expand Up @@ -36,7 +36,7 @@ macro_rules! read_csr_rv32 {
#[cfg(all(riscv32, feature = "inline-asm"))]
() => {
let r: usize;
llvm_asm!("csrrs $0, $1, x0" : "=r"(r) : "i"($csr_number) :: "volatile");
asm!("csrrs {0}, {1}, x0", out(reg) r, const $csr_number);
r
}

Expand Down Expand Up @@ -102,7 +102,7 @@ macro_rules! write_csr {
unsafe fn _write(bits: usize) {
match () {
#[cfg(all(riscv, feature = "inline-asm"))]
() => llvm_asm!("csrrw x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
() => asm!("csrrw x0, {1}, {0}", in(reg) bits, const $csr_number),

#[cfg(all(riscv, not(feature = "inline-asm")))]
() => {
Expand All @@ -128,7 +128,7 @@ macro_rules! write_csr_rv32 {
unsafe fn _write(bits: usize) {
match () {
#[cfg(all(riscv32, feature = "inline-asm"))]
() => llvm_asm!("csrrw x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
() => asm!("csrrw x0, {1}, {0}", in(reg) bits, const $csr_number),

#[cfg(all(riscv32, not(feature = "inline-asm")))]
() => {
Expand Down Expand Up @@ -178,7 +178,7 @@ macro_rules! set {
unsafe fn _set(bits: usize) {
match () {
#[cfg(all(riscv, feature = "inline-asm"))]
() => llvm_asm!("csrrs x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
() => asm!("csrrs x0, {1}, {0}", in(reg) bits, const $csr_number),

#[cfg(all(riscv, not(feature = "inline-asm")))]
() => {
Expand All @@ -204,7 +204,7 @@ macro_rules! clear {
unsafe fn _clear(bits: usize) {
match () {
#[cfg(all(riscv, feature = "inline-asm"))]
() => llvm_asm!("csrrc x0, $1, $0" :: "r"(bits), "i"($csr_number) :: "volatile"),
() => asm!("csrrc x0, {1}, {0}", in(reg) bits, const $csr_number),

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