Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ARM assembly from RISC-V CYW43 SPI PIO #2045

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

earlephilhower
Copy link
Contributor

Replace the ARM assembly for dual 16b swap with generic GCC builtin macros to allow building CYW43 SPI PIO driver for RISC-V

Fixes #2044

@kilograham
Copy link
Contributor

This might be more compact

__force_inline static uint32_t __swap16x2(uint32_t a) {
#ifndef __riscv
    pico_default_asm ("rev16 %0, %0" : "+l" (a) : : );
#else
    uint32_t tmp;
    pico_default_asm (
        "rev8 %1, %0\n"
        "rori %0, %1, 16\n"
        : "+l" (a), "=l" (tmp));
#endif
    return a;
}

@earlephilhower
Copy link
Contributor Author

Agreed. Quick check of generated assembly using __builtin gives

  5c:	6987d713          	rev8	a4,a5
  60:	83c1                	srli	a5,a5,0x10
  62:	8341                	srli	a4,a4,0x10
  64:	6987d793          	rev8	a5,a5
  68:	8fd9                	or	a5,a5,a4

22 bytes vs only 8 for the hand ASM.

  4a:	6987d713          	rev8	a4,a5
  4e:	61075793          	rori	a5,a4,0x10

I'll update and squash accordingly.

Add hand-coded assembly RISC-V version of swap16x2 for CYW32 SPI PIO
driver.

Fixes raspberrypi#2044
@earlephilhower
Copy link
Contributor Author

Updated with hand-asm patch. Verified the assembly output does match the ARM and GCC builtins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants