Skip to content

Commit

Permalink
Change division_function to use the naked function
Browse files Browse the repository at this point in the history
Solve the issue of not recognizing builtin functions under LTO.
  • Loading branch information
DianQK committed Dec 17, 2023
1 parent a215988 commit 36244e6
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions rp2040-hal/src/sio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,29 +278,32 @@ core::arch::global_asm!(

macro_rules! division_function {
(
$name:ident $($intrinsic:ident)* ( $argty:ty ) {
$name:ident $intrinsic:ident $intrinsic_alias:ident ( $argty:ty ) {
$($begin:literal),+
}
) => {
#[cfg(all(target_arch = "arm", not(feature = "disable-intrinsics")))]
core::arch::global_asm!(
// Mangle the name slightly, since this is a global symbol.
concat!(".global _rphal_", stringify!($name)),
concat!(".type _rphal_", stringify!($name), ", %function"),
".align 2",
concat!("_rphal_", stringify!($name), ":"),
$(
concat!(".global ", stringify!($intrinsic)),
concat!(".type ", stringify!($intrinsic), ", %function"),
concat!(stringify!($intrinsic), ":"),
)*

"hwdivider_head",
$($begin),+ ,
"hwdivider_tail",
);
intrinsics! {
#[naked]
unsafe extern "C" fn $intrinsic() {
core::arch::asm!(
"hwdivider_head",
$($begin),+ ,
"hwdivider_tail",
options(noreturn)
);
}
#[naked]
unsafe extern "C" fn $intrinsic_alias() {
core::arch::asm!(
"hwdivider_head",
$($begin),+ ,
"hwdivider_tail",
options(noreturn)
);
}
}

#[cfg(all(target_arch = "arm", feature = "disable-intrinsics"))]
core::arch::global_asm!(
// Mangle the name slightly, since this is a global symbol.
concat!(".global _rphal_", stringify!($name)),
Expand Down

0 comments on commit 36244e6

Please sign in to comment.