Skip to content

Commit 3d0a439

Browse files
bors[bot]Disasm
andauthored
Merge #91
91: Add inline-asm build to CI, fix build r=dkhayes117 a=Disasm #86 introduced new `asm!` syntax which is enabled with the `inline-asm` feature. However, it doesn't work with current nightly since `asm_const` unstable feature is not enabled. This PR fixes the problem and adds automatic checks to CI. Co-authored-by: Vadim Kaushan <[email protected]>
2 parents 8357d8d + 0b28f19 commit 3d0a439

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

.github/workflows/ci.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ jobs:
3434
run: cargo check --target x86_64-unknown-linux-gnu
3535
- name: Run CI script for riscv32imac-unknown-none-elf under ${{ matrix.rust }}
3636
run: cargo check --target riscv32imac-unknown-none-elf
37+
- name: Run CI script for riscv32imac-unknown-none-elf (inline-asm) under ${{ matrix.rust }}
38+
run: |
39+
if [ "${{ matrix.rust }}" == "nightly" ]; then
40+
cargo check --target riscv32imac-unknown-none-elf --features inline-asm
41+
fi
3742
- name: Run CI script for riscv64imac-unknown-none-elf under ${{ matrix.rust }}
3843
run: cargo check --target riscv64imac-unknown-none-elf
3944
- name: Run CI script for riscv64gc-unknown-none-elf under ${{ matrix.rust }}

src/asm.rs

+2-2
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),
10+
() => core::arch::asm!($asm),
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}", in(reg) addr, in(reg) asid),
61+
() => core::arch::asm!("sfence.vma {0}, {1}", in(reg) addr, in(reg) asid),
6262

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

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
1616
#![no_std]
1717
#![cfg_attr(feature = "inline-asm", feature(asm))]
18+
#![cfg_attr(feature = "inline-asm", feature(asm_const))]
1819

1920
extern crate bare_metal;
2021
extern crate bit_field;

src/register/macros.rs

+6-6
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", out(reg) r, const $csr_number);
10+
core::arch::asm!("csrrs {0}, {1}, x0", out(reg) r, const $csr_number);
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", out(reg) r, const $csr_number);
39+
core::arch::asm!("csrrs {0}, {1}, x0", out(reg) r, const $csr_number);
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}", in(reg) bits, const $csr_number),
105+
() => core::arch::asm!("csrrw x0, {1}, {0}", in(reg) bits, const $csr_number),
106106

107107
#[cfg(all(riscv, not(feature = "inline-asm")))]
108108
() => {
@@ -128,7 +128,7 @@ macro_rules! write_csr_rv32 {
128128
unsafe fn _write(bits: usize) {
129129
match () {
130130
#[cfg(all(riscv32, feature = "inline-asm"))]
131-
() => asm!("csrrw x0, {1}, {0}", in(reg) bits, const $csr_number),
131+
() => core::arch::asm!("csrrw x0, {1}, {0}", in(reg) bits, const $csr_number),
132132

133133
#[cfg(all(riscv32, not(feature = "inline-asm")))]
134134
() => {
@@ -178,7 +178,7 @@ macro_rules! set {
178178
unsafe fn _set(bits: usize) {
179179
match () {
180180
#[cfg(all(riscv, feature = "inline-asm"))]
181-
() => asm!("csrrs x0, {1}, {0}", in(reg) bits, const $csr_number),
181+
() => core::arch::asm!("csrrs x0, {1}, {0}", in(reg) bits, const $csr_number),
182182

183183
#[cfg(all(riscv, not(feature = "inline-asm")))]
184184
() => {
@@ -204,7 +204,7 @@ macro_rules! clear {
204204
unsafe fn _clear(bits: usize) {
205205
match () {
206206
#[cfg(all(riscv, feature = "inline-asm"))]
207-
() => asm!("csrrc x0, {1}, {0}", in(reg) bits, const $csr_number),
207+
() => core::arch::asm!("csrrc x0, {1}, {0}", in(reg) bits, const $csr_number),
208208

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

0 commit comments

Comments
 (0)