diff options
| author | Peter Krull <[email protected]> | 2023-04-23 19:05:32 +0200 |
|---|---|---|
| committer | Peter Krull <[email protected]> | 2023-04-23 19:05:32 +0200 |
| commit | b283f213d99c5bfb888f450270dca699ae096fca (patch) | |
| tree | 9845a05192bcabe55596782842d952961d18f3eb /embassy-rp/src | |
| parent | ba47fe9c416818b7fff5bca8092d9f0265407089 (diff) | |
embassy-rs : @pennae Fix division intrinsics naming clash with rp2040-hal
Diffstat (limited to 'embassy-rp/src')
| -rw-r--r-- | embassy-rp/src/intrinsics.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/embassy-rp/src/intrinsics.rs b/embassy-rp/src/intrinsics.rs index d5cb5fe9a..3baabb287 100644 --- a/embassy-rp/src/intrinsics.rs +++ b/embassy-rp/src/intrinsics.rs | |||
| @@ -352,7 +352,6 @@ core::arch::global_asm!( | |||
| 352 | ".endm", | 352 | ".endm", |
| 353 | ); | 353 | ); |
| 354 | 354 | ||
| 355 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | ||
| 356 | macro_rules! division_function { | 355 | macro_rules! division_function { |
| 357 | ( | 356 | ( |
| 358 | $name:ident $($intrinsic:ident)* ( $argty:ty ) { | 357 | $name:ident $($intrinsic:ident)* ( $argty:ty ) { |
| @@ -362,10 +361,11 @@ macro_rules! division_function { | |||
| 362 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | 361 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] |
| 363 | core::arch::global_asm!( | 362 | core::arch::global_asm!( |
| 364 | // Mangle the name slightly, since this is a global symbol. | 363 | // Mangle the name slightly, since this is a global symbol. |
| 365 | concat!(".global _rphal_", stringify!($name)), | 364 | concat!(".section .text._erphal_", stringify!($name)), |
| 366 | concat!(".type _rphal_", stringify!($name), ", %function"), | 365 | concat!(".global _erphal_", stringify!($name)), |
| 366 | concat!(".type _erphal_", stringify!($name), ", %function"), | ||
| 367 | ".align 2", | 367 | ".align 2", |
| 368 | concat!("_rphal_", stringify!($name), ":"), | 368 | concat!("_erphal_", stringify!($name), ":"), |
| 369 | $( | 369 | $( |
| 370 | concat!(".global ", stringify!($intrinsic)), | 370 | concat!(".global ", stringify!($intrinsic)), |
| 371 | concat!(".type ", stringify!($intrinsic), ", %function"), | 371 | concat!(".type ", stringify!($intrinsic), ", %function"), |
| @@ -380,10 +380,11 @@ macro_rules! division_function { | |||
| 380 | #[cfg(all(target_arch = "arm", not(feature = "intrinsics")))] | 380 | #[cfg(all(target_arch = "arm", not(feature = "intrinsics")))] |
| 381 | core::arch::global_asm!( | 381 | core::arch::global_asm!( |
| 382 | // Mangle the name slightly, since this is a global symbol. | 382 | // Mangle the name slightly, since this is a global symbol. |
| 383 | concat!(".global _rphal_", stringify!($name)), | 383 | concat!(".section .text._erphal_", stringify!($name)), |
| 384 | concat!(".type _rphal_", stringify!($name), ", %function"), | 384 | concat!(".global _erphal_", stringify!($name)), |
| 385 | concat!(".type _erphal_", stringify!($name), ", %function"), | ||
| 385 | ".align 2", | 386 | ".align 2", |
| 386 | concat!("_rphal_", stringify!($name), ":"), | 387 | concat!("_erphal_", stringify!($name), ":"), |
| 387 | 388 | ||
| 388 | "hwdivider_head", | 389 | "hwdivider_head", |
| 389 | $($begin),+ , | 390 | $($begin),+ , |
| @@ -393,7 +394,7 @@ macro_rules! division_function { | |||
| 393 | #[cfg(target_arch = "arm")] | 394 | #[cfg(target_arch = "arm")] |
| 394 | extern "aapcs" { | 395 | extern "aapcs" { |
| 395 | // Connect a local name to global symbol above through FFI. | 396 | // Connect a local name to global symbol above through FFI. |
| 396 | #[link_name = concat!("_rphal_", stringify!($name)) ] | 397 | #[link_name = concat!("_erphal_", stringify!($name)) ] |
| 397 | fn $name(n: $argty, d: $argty) -> u64; | 398 | fn $name(n: $argty, d: $argty) -> u64; |
| 398 | } | 399 | } |
| 399 | 400 | ||
| @@ -403,7 +404,6 @@ macro_rules! division_function { | |||
| 403 | }; | 404 | }; |
| 404 | } | 405 | } |
| 405 | 406 | ||
| 406 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | ||
| 407 | division_function! { | 407 | division_function! { |
| 408 | unsigned_divmod __aeabi_uidivmod __aeabi_uidiv ( u32 ) { | 408 | unsigned_divmod __aeabi_uidivmod __aeabi_uidiv ( u32 ) { |
| 409 | "str r0, [r2, #0x060]", // DIV_UDIVIDEND | 409 | "str r0, [r2, #0x060]", // DIV_UDIVIDEND |
| @@ -411,7 +411,6 @@ division_function! { | |||
| 411 | } | 411 | } |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | ||
| 415 | division_function! { | 414 | division_function! { |
| 416 | signed_divmod __aeabi_idivmod __aeabi_idiv ( i32 ) { | 415 | signed_divmod __aeabi_idivmod __aeabi_idiv ( i32 ) { |
| 417 | "str r0, [r2, #0x068]", // DIV_SDIVIDEND | 416 | "str r0, [r2, #0x068]", // DIV_SDIVIDEND |
| @@ -419,7 +418,6 @@ division_function! { | |||
| 419 | } | 418 | } |
| 420 | } | 419 | } |
| 421 | 420 | ||
| 422 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | ||
| 423 | fn divider_unsigned(n: u32, d: u32) -> DivResult<u32> { | 421 | fn divider_unsigned(n: u32, d: u32) -> DivResult<u32> { |
| 424 | let packed = unsafe { unsigned_divmod(n, d) }; | 422 | let packed = unsafe { unsigned_divmod(n, d) }; |
| 425 | DivResult { | 423 | DivResult { |
| @@ -428,7 +426,6 @@ fn divider_unsigned(n: u32, d: u32) -> DivResult<u32> { | |||
| 428 | } | 426 | } |
| 429 | } | 427 | } |
| 430 | 428 | ||
| 431 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | ||
| 432 | fn divider_signed(n: i32, d: i32) -> DivResult<i32> { | 429 | fn divider_signed(n: i32, d: i32) -> DivResult<i32> { |
| 433 | let packed = unsafe { signed_divmod(n, d) }; | 430 | let packed = unsafe { signed_divmod(n, d) }; |
| 434 | // Double casts to avoid sign extension | 431 | // Double casts to avoid sign extension |
| @@ -439,7 +436,6 @@ fn divider_signed(n: i32, d: i32) -> DivResult<i32> { | |||
| 439 | } | 436 | } |
| 440 | 437 | ||
| 441 | /// Result of divide/modulo operation | 438 | /// Result of divide/modulo operation |
| 442 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | ||
| 443 | struct DivResult<T> { | 439 | struct DivResult<T> { |
| 444 | /// The quotient of divide/modulo operation | 440 | /// The quotient of divide/modulo operation |
| 445 | pub quotient: T, | 441 | pub quotient: T, |
| @@ -447,7 +443,6 @@ struct DivResult<T> { | |||
| 447 | pub remainder: T, | 443 | pub remainder: T, |
| 448 | } | 444 | } |
| 449 | 445 | ||
| 450 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | ||
| 451 | intrinsics! { | 446 | intrinsics! { |
| 452 | extern "C" fn __udivsi3(n: u32, d: u32) -> u32 { | 447 | extern "C" fn __udivsi3(n: u32, d: u32) -> u32 { |
| 453 | divider_unsigned(n, d).quotient | 448 | divider_unsigned(n, d).quotient |
