util: add optimised memset64

This just adds a memset64 along the lines of the previously
added memset32.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9041>
This commit is contained in:
Dave Airlie 2021-02-15 07:50:38 +10:00 committed by Marge Bot
parent 2ff397c00e
commit 83f0bc5d84

View file

@ -45,3 +45,23 @@ util_memset32(void *s, uint32_t ui, size_t n)
return s;
#endif
}
static inline void *
util_memset64(void *s, uint64_t ui, size_t n)
{
#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86_64)
long d0, d1;
__asm__ volatile("rep\n\t"
"stosq"
: "=&c" (d0), "=&D" (d1)
: "a" (ui), "1" (s), "0" (n)
: "memory");
return s;
#else
uint64_t *xs = (uint64_t *)s;
while (n--)
*xs++ = ui;
return s;
#endif
}