Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *   library function for memcpy where length bytes are copied from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *   ptr_in to ptr_out. ptr_out is returned unchanged.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *   Allows any combination of alignment on input and output pointers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *   and length from 0 to 2^32-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * Restrictions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *   The arrays should not overlap, the program will produce undefined output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *   if they do.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *   For blocks less than 16 bytes a byte by byte copy is performed. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *   8byte alignments, and length multiples, a dword copy is performed up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *   96bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * History
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *   DJH  5/15/09 Initial version 1.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *   DJH  6/ 1/09 Version 1.1 modified ABI to inlcude R16-R19
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *   DJH  7/12/09 Version 1.2 optimized codesize down to 760 was 840
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *   DJH 10/14/09 Version 1.3 added special loop for aligned case, was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *                            overreading bloated codesize back up to 892
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *   DJH  4/20/10 Version 1.4 fixed Ldword_loop_epilog loop to prevent loads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *                            occurring if only 1 left outstanding, fixes bug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *                            # 3888, corrected for all alignments. Peeled off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *                            1 32byte chunk from kernel loop and extended 8byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *                            loop at end to solve all combinations and prevent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *                            over read.  Fixed Ldword_loop_prolog to prevent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *                            overread for blocks less than 48bytes. Reduced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *                            codesize to 752 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *   DJH  4/21/10 version 1.5 1.4 fix broke code for input block ends not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *                            aligned to dword boundaries,underwriting by 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *                            byte, added detection for this and fixed. A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *                            little bloat.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *   DJH  4/23/10 version 1.6 corrected stack error, R20 was not being restored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *                            always, fixed the error of R20 being modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *                            before it was being saved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * Natural c model
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * void * memcpy(char * ptr_out, char * ptr_in, int length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *   int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  *   if(length) for(i=0; i < length; i++) { ptr_out[i] = ptr_in[i]; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *   return(ptr_out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * Optimized memcpy function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * =========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * void * memcpy(char * ptr_out, char * ptr_in, int len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *   int i, prolog, kernel, epilog, mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  *   u8 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *   s64 data0, dataF8, data70;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *   s64 * ptr8_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *   s64 * ptr8_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *   s32 * ptr4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  *   s16 * ptr2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  *   offset = ((int) ptr_in) & 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  *   ptr8_in = (s64 *) &ptr_in[-offset];   //read in the aligned pointers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  *   data70 = *ptr8_in++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  *   dataF8 = *ptr8_in++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  *   data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *   prolog = 32 - ((int) ptr_out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *   mask  = 0x7fffffff >> HEXAGON_R_cl0_R(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  *   prolog = prolog & mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *   kernel = len - prolog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  *   epilog = kernel & 0x1F;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *   kernel = kernel>>5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *   if (prolog & 1) { ptr_out[0] = (u8) data0; data0 >>= 8; ptr_out += 1;}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  *   ptr2 = (s16 *) &ptr_out[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *   if (prolog & 2) { ptr2[0] = (u16) data0;  data0 >>= 16; ptr_out += 2;}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  *   ptr4 = (s32 *) &ptr_out[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  *   if (prolog & 4) { ptr4[0] = (u32) data0;  data0 >>= 32; ptr_out += 4;}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *   offset = offset + (prolog & 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  *   if (offset >= 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  *     data70 = dataF8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  *     dataF8 = *ptr8_in++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  *   offset = offset & 0x7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  *   prolog = prolog >> 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *   if (prolog) for (i=0; i < prolog; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  *       data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  *       ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  *       data70 = dataF8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  *       dataF8 = *ptr8_in++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  *   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  *   if(kernel) { kernel -= 1; epilog += 32; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  *   if(kernel) for(i=0; i < kernel; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  *       data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  *       ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  *       data70 = *ptr8_in++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *       data0 = HEXAGON_P_valignb_PPp(data70, dataF8, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  *       ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *       dataF8 = *ptr8_in++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  *       data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  *       ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  *       data70 = *ptr8_in++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  *       data0 = HEXAGON_P_valignb_PPp(data70, dataF8, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *       ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  *       dataF8 = *ptr8_in++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *   epilogdws = epilog >> 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *   if (epilogdws) for (i=0; i < epilogdws; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  *       data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  *       ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  *       data70 = dataF8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  *       dataF8 = *ptr8_in++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  *   }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  *   data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *   ptr4 = (s32 *) &ptr_out[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  *   if (epilog & 4) { ptr4[0] = (u32) data0; data0 >>= 32; ptr_out += 4;}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  *   ptr2 = (s16 *) &ptr_out[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *   if (epilog & 2) { ptr2[0] = (u16) data0; data0 >>= 16; ptr_out += 2;}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  *   if (epilog & 1) { *ptr_out++ = (u8) data0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  *   return(ptr_out - length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  * }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * Codesize : 784 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define ptr_out		R0	/*  destination  pounter  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #define ptr_in		R1	/*  source pointer  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define len		R2	/*  length of copy in bytes  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #define data70		R13:12	/*  lo 8 bytes of non-aligned transfer  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define dataF8		R11:10	/*  hi 8 bytes of non-aligned transfer  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define ldata0		R7:6	/*  even 8 bytes chunks  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #define ldata1		R25:24	/*  odd 8 bytes chunks  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #define data1		R7	/*  lower 8 bytes of ldata1  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define data0		R6	/*  lower 8 bytes of ldata0  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define ifbyte		p0	/*  if transfer has bytes in epilog/prolog  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define ifhword		p0	/*  if transfer has shorts in epilog/prolog  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #define ifword		p0	/*  if transfer has words in epilog/prolog  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #define noprolog	p0	/*  no prolog, xfer starts at 32byte  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define nokernel	p1	/*  no 32byte multiple block in the transfer  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #define noepilog	p0	/*  no epilog, xfer ends on 32byte boundary  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #define align		p2	/*  alignment of input rel to 8byte boundary  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define kernel1		p0	/*  kernel count == 1  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define dalign		R25	/*  rel alignment of input to output data  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #define star3		R16	/*  number bytes in prolog - dwords  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #define rest		R8	/*  length - prolog bytes  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #define back		R7	/*  nr bytes > dword boundary in src block  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define epilog		R3	/*  bytes in epilog  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #define inc		R15:14	/*  inc kernel by -1 and defetch ptr by 32  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #define kernel		R4	/*  number of 32byte chunks in kernel  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #define ptr_in_p_128	R5	/*  pointer for prefetch of input data  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define mask		R8	/*  mask used to determine prolog size  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #define shift		R8	/*  used to work a shifter to extract bytes  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #define shift2		R5	/*  in epilog to workshifter to extract bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #define prolog		R15	/*  bytes in  prolog  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #define epilogdws	R15	/*  number dwords in epilog  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #define shiftb		R14	/*  used to extract bytes  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #define offset		R9	/*  same as align in reg  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #define ptr_out_p_32	R17	/*  pointer to output dczero  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #define align888	R14	/*  if simple dword loop can be used  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) #define len8		R9	/*  number of dwords in length  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #define over		R20	/*  nr of bytes > last inp buf dword boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #define ptr_in_p_128kernel	R5:4	/*  packed fetch pointer & kernel cnt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	.section .text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	.p2align 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)         .global memcpy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)         .type memcpy, @function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) memcpy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	p2 = cmp.eq(len, #0);		/*  =0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	align888 = or(ptr_in, ptr_out);	/*  %8 < 97 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	p0 = cmp.gtu(len, #23);		/*  %1, <24 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	p1 = cmp.eq(ptr_in, ptr_out);	/*  attempt to overwrite self */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	p1 = or(p2, p1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	p3 = cmp.gtu(len, #95);		/*  %8 < 97 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	align888 = or(align888, len);	/*  %8 < 97 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	len8 = lsr(len, #3);		/*  %8 < 97 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	dcfetch(ptr_in);		/*  zero/ptrin=ptrout causes fetch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	p2 = bitsclr(align888, #7);	/*  %8 < 97  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	if(p1) jumpr r31;		/*  =0  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	p2 = and(p2,!p3);			/*  %8 < 97  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	if (p2.new) len = add(len, #-8);	/*  %8 < 97  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	if (p2.new) jump:NT .Ldwordaligned; 	/*  %8 < 97  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if(!p0) jump .Lbytes23orless;	/*  %1, <24  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	mask.l = #LO(0x7fffffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	/*  all bytes before line multiples of data  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	prolog = sub(#0, ptr_out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	/*  save r31 on stack, decrement sp by 16  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	allocframe(#24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	mask.h = #HI(0x7fffffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	ptr_in_p_128 = add(ptr_in, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	back = cl0(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	memd(sp+#0) = R17:16;		/*  save r16,r17 on stack6  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	r31.l = #LO(.Lmemcpy_return);	/*  set up final return pointer  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	prolog &= lsr(mask, back);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	offset = and(ptr_in, #7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	memd(sp+#8) = R25:24;		/*  save r25,r24 on stack  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	dalign = sub(ptr_out, ptr_in);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	r31.h = #HI(.Lmemcpy_return);	/*  set up final return pointer  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	/*  see if there if input buffer end if aligned  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	over = add(len, ptr_in);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	back = add(len, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	memd(sp+#16) = R21:20;		/*  save r20,r21 on stack  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	noprolog = bitsclr(prolog, #7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	prolog = and(prolog, #31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	dcfetch(ptr_in_p_128);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	ptr_in_p_128 = add(ptr_in_p_128, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	kernel = sub(len, prolog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	shift = asl(prolog, #3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	star3 = and(prolog, #7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	ptr_in = and(ptr_in, #-8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	prolog = lsr(prolog, #3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	epilog = and(kernel, #31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	ptr_out_p_32 = add(ptr_out, prolog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	over = and(over, #7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	p3 = cmp.gtu(back, #8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	kernel = lsr(kernel, #5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	dcfetch(ptr_in_p_128);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	ptr_in_p_128 = add(ptr_in_p_128, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	p1 = cmp.eq(prolog, #0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	if(!p1.new) prolog = add(prolog, #1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	dcfetch(ptr_in_p_128);	/*  reserve the line 64bytes on  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	ptr_in_p_128 = add(ptr_in_p_128, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	nokernel = cmp.eq(kernel,#0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	dcfetch(ptr_in_p_128);	/* reserve the line 64bytes on  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	ptr_in_p_128 = add(ptr_in_p_128, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	shiftb = and(shift, #8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	dcfetch(ptr_in_p_128);		/*  reserve the line 64bytes on  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	ptr_in_p_128 = add(ptr_in_p_128, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	if(nokernel) jump .Lskip64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	p2 = cmp.eq(kernel, #1);	/*  skip ovr if kernel == 0  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	dczeroa(ptr_out_p_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	/*  don't advance pointer  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	if(!p2) ptr_out_p_32 = add(ptr_out_p_32, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	dalign = and(dalign, #31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	dczeroa(ptr_out_p_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) .Lskip64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	data70 = memd(ptr_in++#16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	if(p3) dataF8 = memd(ptr_in+#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	if(noprolog) jump .Lnoprolog32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	align = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) /*  upto initial 7 bytes  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	ldata0 = valignb(dataF8, data70, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	ifbyte = tstbit(shift,#3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	offset = add(offset, star3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	if(ifbyte) memb(ptr_out++#1) = data0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	ldata0 = lsr(ldata0, shiftb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	shiftb = and(shift, #16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	ifhword = tstbit(shift,#4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	if(ifhword) memh(ptr_out++#2) = data0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	ldata0 = lsr(ldata0, shiftb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	ifword = tstbit(shift,#5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	p2 = cmp.gtu(offset, #7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	if(ifword) memw(ptr_out++#4) = data0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	if(p2) data70 = dataF8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	if(p2) dataF8 = memd(ptr_in++#8);	/*  another 8 bytes  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	align = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) .Lnoprolog32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	p3 = sp1loop0(.Ldword_loop_prolog, prolog)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	rest = sub(len, star3);	/*  whats left after the loop  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	p0 = cmp.gt(over, #0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	if(p0) rest = add(rest, #16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) .Ldword_loop_prolog:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	if(p3) memd(ptr_out++#8) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	ldata0 = valignb(dataF8, data70, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	p0 = cmp.gt(rest, #16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	data70 = dataF8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	if(p0) dataF8 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	rest = add(rest, #-8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) }:endloop0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) .Lkernel:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	/*  kernel is at least 32bytes  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	p3 = cmp.gtu(kernel, #0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	/*  last itn. remove edge effects  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	if(p3.new) kernel = add(kernel, #-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	/*  dealt with in last dword loop  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	if(p3.new) epilog = add(epilog, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	nokernel = cmp.eq(kernel, #0);		/*  after adjustment, recheck */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	if(nokernel.new) jump:NT .Lepilog;	/*  likely not taken  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	inc = combine(#32, #-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	p3 = cmp.gtu(dalign, #24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	if(p3) jump .Lodd_alignment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	loop0(.Loword_loop_25to31, kernel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	kernel1 = cmp.gtu(kernel, #1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	rest = kernel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	.falign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) .Loword_loop_25to31:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	dcfetch(ptr_in_p_128);	/*  prefetch 4 lines ahead  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	if(kernel1) ptr_out_p_32 = add(ptr_out_p_32, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	dczeroa(ptr_out_p_32);	/*  reserve the next 32bytes in cache  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	p3 = cmp.eq(kernel, rest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	/*  kernel -= 1  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	ptr_in_p_128kernel = vaddw(ptr_in_p_128kernel, inc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	/*  kill write on first iteration  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	if(!p3) memd(ptr_out++#8) = ldata1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	ldata1 = valignb(dataF8, data70, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	data70 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	memd(ptr_out++#8) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	ldata0 = valignb(data70, dataF8, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	dataF8 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	memd(ptr_out++#8) = ldata1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	ldata1 = valignb(dataF8, data70, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	data70 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	memd(ptr_out++#8) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	ldata0 = valignb(data70, dataF8, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	dataF8 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	kernel1 = cmp.gtu(kernel, #1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }:endloop0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	memd(ptr_out++#8) = ldata1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	jump .Lepilog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) .Lodd_alignment:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	loop0(.Loword_loop_00to24, kernel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	kernel1 = cmp.gtu(kernel, #1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	rest = add(kernel, #-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	.falign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) .Loword_loop_00to24:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	dcfetch(ptr_in_p_128);	/*  prefetch 4 lines ahead  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	ptr_in_p_128kernel = vaddw(ptr_in_p_128kernel, inc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	if(kernel1) ptr_out_p_32 = add(ptr_out_p_32, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	dczeroa(ptr_out_p_32);	/*  reserve the next 32bytes in cache  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	memd(ptr_out++#8) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	ldata0 = valignb(dataF8, data70, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	data70 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	memd(ptr_out++#8) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	ldata0 = valignb(data70, dataF8, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	dataF8 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	memd(ptr_out++#8) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	ldata0 = valignb(dataF8, data70, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	data70 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	memd(ptr_out++#8) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	ldata0 = valignb(data70, dataF8, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	dataF8 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	kernel1 = cmp.gtu(kernel, #1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }:endloop0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) .Lepilog:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	noepilog = cmp.eq(epilog,#0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	epilogdws = lsr(epilog, #3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	kernel = and(epilog, #7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	if(noepilog) jumpr r31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	if(noepilog) ptr_out = sub(ptr_out, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	p3 = cmp.eq(epilogdws, #0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	shift2 = asl(epilog, #3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	shiftb = and(shift2, #32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	ifword = tstbit(epilog,#2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	if(p3) jump .Lepilog60;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	if(!p3) epilog = add(epilog, #-16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	loop0(.Ldword_loop_epilog, epilogdws);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	/*  stop criteria is lsbs unless = 0 then its 8  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	p3 = cmp.eq(kernel, #0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	if(p3.new) kernel= #8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	p1 = cmp.gt(over, #0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	/*  if not aligned to end of buffer execute 1 more iteration  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	if(p1) kernel= #0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) .Ldword_loop_epilog:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	memd(ptr_out++#8) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	ldata0 = valignb(dataF8, data70, align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	p3 = cmp.gt(epilog, kernel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	data70 = dataF8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	if(p3) dataF8 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	epilog = add(epilog, #-8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }:endloop0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) /* copy last 7 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) .Lepilog60:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	if(ifword) memw(ptr_out++#4) = data0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	ldata0 = lsr(ldata0, shiftb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	ifhword = tstbit(epilog,#1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	shiftb = and(shift2, #16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	if(ifhword) memh(ptr_out++#2) = data0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	ldata0 = lsr(ldata0, shiftb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	ifbyte = tstbit(epilog,#0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	if(ifbyte.new) len = add(len, #-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	if(ifbyte) memb(ptr_out) = data0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	ptr_out = sub(ptr_out, len);	/*  return dest pointer  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)         jumpr r31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) /*  do byte copy for small n  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) .Lbytes23orless:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	p3 = sp1loop0(.Lbyte_copy, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	len = add(len, #-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) .Lbyte_copy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	data0 = memb(ptr_in++#1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	if(p3) memb(ptr_out++#1) = data0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) }:endloop0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	memb(ptr_out) = data0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	ptr_out = sub(ptr_out, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	jumpr r31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) /*  do dword copies for aligned in, out and length  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) .Ldwordaligned:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	p3 = sp1loop0(.Ldword_copy, len8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) .Ldword_copy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	if(p3) memd(ptr_out++#8) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	ldata0 = memd(ptr_in++#8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }:endloop0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	memd(ptr_out) = ldata0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	ptr_out = sub(ptr_out, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	jumpr r31;	/*  return to function caller  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) .Lmemcpy_return:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	r21:20 = memd(sp+#16);	/*  restore r20+r21  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	r25:24 = memd(sp+#8);	/*  restore r24+r25  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	r17:16 = memd(sp+#0);	/*  restore r16+r17  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	deallocframe;	/*  restore r31 and incrment stack by 16  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	jumpr r31