Skip to content

Commit bce1e58

Browse files
committed
refactor(port_arm): replace llvm_asm! with asm!
1 parent 0d32343 commit bce1e58

File tree

6 files changed

+126
-148
lines changed

6 files changed

+126
-148
lines changed

src/constance_port_arm/src/arm.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ macro_rules! sys_coproc_read_raw {
55
fn get(&self) -> u32 {
66
let reg;
77
unsafe {
8-
llvm_asm!(
8+
asm!(
99
concat!(
10-
"mrc ", stringify!($cp), ", ", stringify!($opc1), ", $0, ",
10+
"mrc ", stringify!($cp), ", ", stringify!($opc1), ", {}, ",
1111
stringify!($crn), ", ", stringify!($crm), ", ", stringify!($opc2)
12-
)
13-
: "=r"(reg)
14-
:
15-
:
16-
: "volatile"
12+
),
13+
lateout(reg) reg,
1714
);
1815
}
1916
reg
@@ -26,15 +23,12 @@ macro_rules! sys_coproc_write_raw {
2623
#[inline]
2724
fn set(&self, value: u32) {
2825
unsafe {
29-
llvm_asm!(
26+
asm!(
3027
concat!(
31-
"mcr ", stringify!($cp), ", ", stringify!($opc1), ", $0, ",
28+
"mcr ", stringify!($cp), ", ", stringify!($opc1), ", {}, ",
3229
stringify!($crn), ", ", stringify!($crm), ", ", stringify!($opc2)
33-
)
34-
:
35-
: "r"(value)
36-
:
37-
: "volatile"
30+
),
31+
in(reg) value,
3832
);
3933
}
4034
}

src/constance_port_arm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(const_panic)]
55
#![feature(const_ptr_offset)]
66
#![feature(decl_macro)]
7-
#![feature(llvm_asm)]
7+
#![feature(asm)]
88
#![feature(naked_functions)]
99
#![feature(slice_ptr_len)]
1010
#![feature(unsafe_block_in_unsafe_fn)] // `unsafe fn` doesn't imply `unsafe {}`

src/constance_port_arm/src/startup/imp.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl VectorTable {
3535
pub fn start<System: EntryPoint + StartupOptions>() {
3636
unsafe {
3737
// Set the stack pointer before calling Rust code
38-
llvm_asm!("
38+
asm!("
3939
ldr r0, =_stack_start
4040
4141
# Set the stack for IRQ mode
@@ -59,12 +59,11 @@ pub fn start<System: EntryPoint + StartupOptions>() {
5959
msr cpsr_c, #0xd3
6060
mov sp, r0
6161
62-
b $0
63-
"
64-
:
65-
: "X"(reset_handler1::<System> as extern "C" fn())
66-
:
67-
: "volatile");
62+
b {reset_handler1}
63+
",
64+
reset_handler1 = sym reset_handler1::<System>,
65+
options(noreturn),
66+
);
6867
}
6968
}
7069

@@ -99,7 +98,7 @@ extern "C" fn reset_handler1<System: EntryPoint + StartupOptions>() {
9998
// Level = level, InD = 0
10099
// Use `isb` to make sure the change to CSSELR takes effect.
101100
arm::CSSELR.set(level * 2);
102-
unsafe { llvm_asm!("isb") };
101+
unsafe { asm!("isb") };
103102

104103
let cssidr = arm::CCSIDR.extract();
105104
let log2_line_size = cssidr.read(arm::CCSIDR::LineSize) + 4;
@@ -151,8 +150,8 @@ extern "C" fn reset_handler1<System: EntryPoint + StartupOptions>() {
151150
// DSB causes completion of all preceding cache and branch predictor
152151
// mantenance operations. ISB causes the effect to be visible to all
153152
// subsequent instructions.
154-
unsafe { llvm_asm!("dsb") };
155-
unsafe { llvm_asm!("isb") };
153+
unsafe { asm!("dsb") };
154+
unsafe { asm!("isb") };
156155

157156
arm::SCTLR.modify(
158157
// Enable data and unified caches
@@ -178,7 +177,7 @@ extern "C" fn reset_handler1<System: EntryPoint + StartupOptions>() {
178177
);
179178

180179
// Ensure the changes made to `SCTLR` here take effect immediately
181-
unsafe { llvm_asm!("isb") };
180+
unsafe { asm!("isb") };
182181

183182
extern "C" {
184183
// These symbols come from `link.x`

0 commit comments

Comments
 (0)