Skip to content

Instantly share code, notes, and snippets.

@pcercuei
Created September 11, 2023 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcercuei/ec5a539559434875306d94ebf2fd233f to your computer and use it in GitHub Desktop.
Save pcercuei/ec5a539559434875306d94ebf2fd233f to your computer and use it in GitHub Desktop.
/* Copyright (C) Paul Cercueil <paul@crapouillou.net> */
static void * memcpy_64bit_32Bytes_zcrc(void *dest, const void *src, size_t len) {
if(!len)
return dest;
void * ret_dest = dest;
_Complex float double_scratch;
_Complex float double_scratch2;
_Complex float double_scratch3;
_Complex float double_scratch4;
__asm__ volatile (
"fschg\n\t" // Switch to pair move mode (FE)
"clrs\n" // Align for parallelism (CO) - SH4a use "stc SR, Rn" instead with a dummy Rn
".align 2\n"
"1:\n\t"
// *dest++ = *src++
"fmov.d @%[in]+, %[scratch]\n\t" // (LS)
"fmov.d @%[in]+, %[scratch2]\n\t" // (LS)
"fmov.d @%[in]+, %[scratch3]\n\t" // (LS)
"fmov.d @%[in]+, %[scratch4]\n\t" // (LS)
"dt %[size]\n\t" // while(--len) (EX)
"fmov.d %[scratch], @%[out]\n\t" // (LS)
"add #8, %[out]\n\t" // (EX)
"fmov.d %[scratch2], @%[out]\n\t" // (LS)
"add #8, %[out]\n\t" // (EX)
"fmov.d %[scratch3], @%[out]\n\t" // (LS)
"add #8, %[out]\n\t" // (EX)
"fmov.d %[scratch4], @%[out]\n\t" // (LS)
"add #8, %[out]\n\t" // (EX)
"bf 1b\n\t" // (BR)
"fschg\n" // Switch back to single move mode (FE)
: [in] "+&r" ((uint32_t)src), [out] "+&r" ((uint32_t)dest), [size] "+&r" (len),
[scratch] "=&d" (double_scratch), [scratch2] "=&d" (double_scratch2), [scratch3] "=&d" (double_scratch3), [scratch4] "=&d" (double_scratch4) // outputs
: // inputs
: "t", "memory" // clobbers
);
return ret_dest;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment