Skip to content

Commit 4eda185

Browse files
authored
use naked_asm! macro for recent nightly (#205)
Co-authored-by: lif <>
1 parent 5337b76 commit 4eda185

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

src/mem.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ mod aeabi_mem_fns {
238238
pub unsafe extern "C" fn __aeabi_memcpy4(
239239
dest: *mut u32, src: *const u32, byte_count: usize,
240240
) {
241-
core::arch::asm! {
241+
core::arch::naked_asm! {
242242
bracer::when!(("r2" >=u "#32") [2] {
243243
"push {{r4-r9}}",
244244
"1:",
@@ -275,7 +275,6 @@ mod aeabi_mem_fns {
275275
"ldrbmi r3, [r1], #1",
276276
"strbmi r3, [r0], #1",
277277
"bx lr",
278-
options(noreturn),
279278
}
280279
}
281280

@@ -309,7 +308,7 @@ mod aeabi_mem_fns {
309308
pub unsafe extern "C" fn __aeabi_memcpy(
310309
dest: *mut u8, src: *const u8, byte_count: usize,
311310
) {
312-
core::arch::asm! {
311+
core::arch::naked_asm! {
313312
"cmp r2, #7", // if count <= (fix+word): just byte copy
314313
"ble {__aeabi_memcpy1}",
315314

@@ -341,7 +340,6 @@ mod aeabi_mem_fns {
341340
__aeabi_memcpy4 = sym __aeabi_memcpy4,
342341
__aeabi_memcpy2 = sym __aeabi_memcpy2,
343342
__aeabi_memcpy1 = sym __aeabi_memcpy1,
344-
options(noreturn)
345343
}
346344
}
347345

@@ -361,13 +359,12 @@ mod aeabi_mem_fns {
361359
) -> *mut u8 {
362360
// I've seen a standard call to `__aeabi_memcpy` give weird codegen,
363361
// so we (currently) do the call manually.
364-
core::arch::asm! {
362+
core::arch::naked_asm! {
365363
"push {{r0, lr}}",
366364
"bl {__aeabi_memcpy}",
367365
"pop {{r0, lr}}",
368366
"bx lr",
369367
__aeabi_memcpy = sym __aeabi_memcpy,
370-
options(noreturn)
371368
}
372369
}
373370

@@ -427,7 +424,7 @@ mod aeabi_mem_fns {
427424
unsafe extern "C" fn reverse_copy_u32(
428425
dest: *mut u32, src: *const u32, byte_count: usize,
429426
) {
430-
core::arch::asm! {
427+
core::arch::naked_asm! {
431428
bracer::when!(("r2" >=u "#32") [2] {
432429
"push {{r4-r9}}",
433430
"1:",
@@ -463,7 +460,6 @@ mod aeabi_mem_fns {
463460
"ldrbmi r3, [r1, #-1]!",
464461
"strbmi r3, [r0, #-1]!",
465462
"bx lr",
466-
options(noreturn),
467463
}
468464
}
469465

@@ -508,7 +504,7 @@ mod aeabi_mem_fns {
508504
pub unsafe extern "C" fn __aeabi_memmove(
509505
dest: *mut u8, src: *const u8, byte_count: usize,
510506
) {
511-
core::arch::asm! {
507+
core::arch::naked_asm! {
512508
// when d > s we need to copy back-to-front
513509
bracer::when!(("r0" >=u "r1") [1] {
514510
"add r0, r0, r2",
@@ -542,7 +538,6 @@ mod aeabi_mem_fns {
542538
reverse_copy_u8 = sym reverse_copy_u8,
543539
reverse_copy_u16 = sym reverse_copy_u16,
544540
reverse_copy_u32 = sym reverse_copy_u32,
545-
options(noreturn),
546541
}
547542
}
548543

@@ -561,13 +556,12 @@ mod aeabi_mem_fns {
561556
pub unsafe extern "C" fn memmove(
562557
dest: *mut u8, src: *const u8, byte_count: usize,
563558
) -> *mut u8 {
564-
core::arch::asm! {
559+
core::arch::naked_asm! {
565560
"push {{r0, lr}}",
566561
"bl {__aeabi_memmove}",
567562
"pop {{r0, lr}}",
568563
"bx lr",
569564
__aeabi_memmove = sym __aeabi_memmove,
570-
options(noreturn)
571565
}
572566
}
573567

@@ -612,7 +606,7 @@ mod aeabi_mem_fns {
612606
pub unsafe extern "C" fn __aeabi_memset(
613607
dest: *mut u8, byte_count: usize, byte: i32,
614608
) {
615-
core::arch::asm! {
609+
core::arch::naked_asm! {
616610
bracer::when!(("r1" >=u "#8") [7] {
617611
// duplicate the byte across all of r2 and r3
618612
"and r2, r2, #0xFF",
@@ -666,7 +660,6 @@ mod aeabi_mem_fns {
666660
"strbcs r2, [r0], #1",
667661
"bgt 9b",
668662
"bx lr",
669-
options(noreturn)
670663
}
671664
}
672665

@@ -686,7 +679,7 @@ mod aeabi_mem_fns {
686679
pub unsafe extern "C" fn memset(
687680
dest: *mut u8, byte: i32, byte_count: usize,
688681
) -> *mut u8 {
689-
core::arch::asm! {
682+
core::arch::naked_asm! {
690683
"push {{r0, lr}}",
691684
"mov r3, r2",
692685
"mov r2, r1",
@@ -695,7 +688,6 @@ mod aeabi_mem_fns {
695688
"pop {{r0, lr}}",
696689
"bx lr",
697690
__aeabi_memset = sym __aeabi_memset,
698-
options(noreturn)
699691
}
700692
}
701693

@@ -747,7 +739,7 @@ mod aeabi_mem_fns {
747739
#[instruction_set(arm::a32)]
748740
#[link_section = ".iwram.aeabi.uread4"]
749741
unsafe extern "C" fn __aeabi_uread4(address: *const c_void) -> u32 {
750-
core::arch::asm!(
742+
core::arch::naked_asm!(
751743
"ldrb r2, [r0]",
752744
"ldrb r3, [r0, #1]",
753745
"orr r2, r2, r3, lsl #8",
@@ -757,7 +749,6 @@ mod aeabi_mem_fns {
757749
"orr r2, r2, r3, lsl #24",
758750
"mov r0, r2",
759751
"bx lr",
760-
options(noreturn),
761752
)
762753
}
763754

@@ -771,7 +762,7 @@ mod aeabi_mem_fns {
771762
#[instruction_set(arm::a32)]
772763
#[link_section = ".iwram.aeabi.uwrite4"]
773764
unsafe extern "C" fn __aeabi_uwrite4(value: u32, address: *mut c_void) {
774-
core::arch::asm!(
765+
core::arch::naked_asm!(
775766
"strb r0, [r1]",
776767
"lsr r2, r0, #8",
777768
"strb r2, [r1, #1]",
@@ -780,7 +771,6 @@ mod aeabi_mem_fns {
780771
"lsr r2, r2, #8",
781772
"strb r2, [r1, #3]",
782773
"bx lr",
783-
options(noreturn),
784774
)
785775
}
786776

@@ -794,7 +784,7 @@ mod aeabi_mem_fns {
794784
#[instruction_set(arm::a32)]
795785
#[link_section = ".iwram.aeabi.uread8"]
796786
unsafe extern "C" fn __aeabi_uread8(address: *const c_void) -> u64 {
797-
core::arch::asm!(
787+
core::arch::naked_asm!(
798788
"ldrb r1, [r0, #4]",
799789
"ldrb r2, [r0, #5]",
800790
"orr r1, r1, r2, lsl #8",
@@ -804,7 +794,6 @@ mod aeabi_mem_fns {
804794
"orr r1, r1, r2, lsl #24",
805795
"b {__aeabi_uread4}",
806796
__aeabi_uread4 = sym __aeabi_uread4,
807-
options(noreturn),
808797
)
809798
}
810799

@@ -818,7 +807,7 @@ mod aeabi_mem_fns {
818807
#[instruction_set(arm::a32)]
819808
#[link_section = ".iwram.aeabi.uwrite8"]
820809
unsafe extern "C" fn __aeabi_uwrite8(value: u64, address: *mut c_void) {
821-
core::arch::asm!(
810+
core::arch::naked_asm!(
822811
"strb r0, [r2]",
823812
"lsr r3, r0, #8",
824813
"strb r3, [r2, #1]",
@@ -834,7 +823,6 @@ mod aeabi_mem_fns {
834823
"lsr r3, r3, #8",
835824
"strb r3, [r2, #7]",
836825
"bx lr",
837-
options(noreturn),
838826
)
839827
}
840828
}

0 commit comments

Comments
 (0)