48 #ifndef included_clib_memcpy_sse3_h 49 #define included_clib_memcpy_sse3_h 52 #include <x86intrin.h> 54 typedef u8 u8x16u __attribute__ ((vector_size (16), aligned (1)));
55 typedef u8 u8x32u __attribute__ ((vector_size (32), aligned (1)));
101 #define CLIB_MVUNALIGN_LEFT47_IMM(dst, src, len, offset) \ 104 while (len >= 128 + 16 - offset) { \ 105 xmm0 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 0 * 16)); \ 107 xmm1 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 1 * 16)); \ 108 xmm2 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 2 * 16)); \ 109 xmm3 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 3 * 16)); \ 110 xmm4 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 4 * 16)); \ 111 xmm5 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 5 * 16)); \ 112 xmm6 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 6 * 16)); \ 113 xmm7 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 7 * 16)); \ 114 xmm8 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 8 * 16)); \ 115 src = (const u8 *)src + 128; \ 116 _mm_storeu_si128((__m128i *)((u8 *)dst + 0 * 16), _mm_alignr_epi8(xmm1, xmm0, offset)); \ 117 _mm_storeu_si128((__m128i *)((u8 *)dst + 1 * 16), _mm_alignr_epi8(xmm2, xmm1, offset)); \ 118 _mm_storeu_si128((__m128i *)((u8 *)dst + 2 * 16), _mm_alignr_epi8(xmm3, xmm2, offset)); \ 119 _mm_storeu_si128((__m128i *)((u8 *)dst + 3 * 16), _mm_alignr_epi8(xmm4, xmm3, offset)); \ 120 _mm_storeu_si128((__m128i *)((u8 *)dst + 4 * 16), _mm_alignr_epi8(xmm5, xmm4, offset)); \ 121 _mm_storeu_si128((__m128i *)((u8 *)dst + 5 * 16), _mm_alignr_epi8(xmm6, xmm5, offset)); \ 122 _mm_storeu_si128((__m128i *)((u8 *)dst + 6 * 16), _mm_alignr_epi8(xmm7, xmm6, offset)); \ 123 _mm_storeu_si128((__m128i *)((u8 *)dst + 7 * 16), _mm_alignr_epi8(xmm8, xmm7, offset)); \ 124 dst = (u8 *)dst + 128; \ 127 len = ((len - 16 + offset) & 127) + 16 - offset; \ 129 src = (const u8 *)src + tmp; \ 130 dst = (u8 *)dst + tmp; \ 131 if (len >= 32 + 16 - offset) { \ 132 while (len >= 32 + 16 - offset) { \ 133 xmm0 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 0 * 16)); \ 135 xmm1 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 1 * 16)); \ 136 xmm2 = _mm_loadu_si128((const __m128i *)((const u8 *)src - offset + 2 * 16)); \ 137 src = (const u8 *)src + 32; \ 138 _mm_storeu_si128((__m128i *)((u8 *)dst + 0 * 16), _mm_alignr_epi8(xmm1, xmm0, offset)); \ 139 _mm_storeu_si128((__m128i *)((u8 *)dst + 1 * 16), _mm_alignr_epi8(xmm2, xmm1, offset)); \ 140 dst = (u8 *)dst + 32; \ 143 len = ((len - 16 + offset) & 31) + 16 - offset; \ 145 src = (const u8 *)src + tmp; \ 146 dst = (u8 *)dst + tmp; \ 162 #define CLIB_MVUNALIGN_LEFT47(dst, src, len, offset) \ 165 case 0x01: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x01); break; \ 166 case 0x02: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x02); break; \ 167 case 0x03: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x03); break; \ 168 case 0x04: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x04); break; \ 169 case 0x05: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x05); break; \ 170 case 0x06: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x06); break; \ 171 case 0x07: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x07); break; \ 172 case 0x08: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x08); break; \ 173 case 0x09: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x09); break; \ 174 case 0x0A: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x0A); break; \ 175 case 0x0B: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x0B); break; \ 176 case 0x0C: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x0C); break; \ 177 case 0x0D: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x0D); break; \ 178 case 0x0E: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x0E); break; \ 179 case 0x0F: CLIB_MVUNALIGN_LEFT47_IMM(dst, src, n, 0x0F); break; \ 187 __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8;
201 *(
u8 *) dstu = *(
const u8 *) srcu;
202 srcu = (
uword) ((
const u8 *) srcu + 1);
203 dstu = (
uword) ((
u8 *) dstu + 1);
207 *(
u16 *) dstu = *(
const u16 *) srcu;
208 srcu = (
uword) ((
const u16 *) srcu + 1);
213 *(
u32 *) dstu = *(
const u32 *) srcu;
214 srcu = (
uword) ((
const u32 *) srcu + 1);
219 *(
u64 *) dstu = *(
const u64 *) srcu;
248 goto COPY_BLOCK_128_BACK15;
257 src = (
const u8 *) src + 256;
258 dst = (
u8 *) dst + 256;
260 COPY_BLOCK_255_BACK15:
265 src = (
const u8 *) src + 128;
266 dst = (
u8 *) dst + 128;
268 COPY_BLOCK_128_BACK15:
273 src = (
const u8 *) src + 64;
274 dst = (
u8 *) dst + 64;
276 COPY_BLOCK_64_BACK15:
281 src = (
const u8 *) src + 32;
282 dst = (
u8 *) dst + 32;
303 dstofss = 16 - ((
uword) dst & 0x0F) + 16;
306 src = (
const u8 *) src + dstofss;
307 dst = (
u8 *) dst + dstofss;
308 srcofs = ((
uword) src & 0x0F);
318 for (; n >= 256; n -= 256)
321 dst = (
u8 *) dst + 256;
322 src = (
const u8 *) src + 256;
328 goto COPY_BLOCK_255_BACK15;
339 goto COPY_BLOCK_64_BACK15;
343 #undef CLIB_MVUNALIGN_LEFT47_IMM 344 #undef CLIB_MVUNALIGN_LEFT47 #define CLIB_MVUNALIGN_LEFT47(dst, src, len, offset)
Macro for copying unaligned block from one location to another, 47 bytes leftover maximum...
static void clib_mov64(u8 *dst, const u8 *src)
static void clib_mov128(u8 *dst, const u8 *src)
static void clib_mov16(u8 *dst, const u8 *src)
static void clib_mov256(u8 *dst, const u8 *src)
static void clib_mov32(u8 *dst, const u8 *src)
static void * clib_memcpy(void *dst, const void *src, size_t n)