#include "../../cmd/ld/textflag.h"
TS = 0
TE = 8
FROM = 11
N = 12
TMP = 12
TMP1 = 5
RSHIFT = 5
LSHIFT = 6
OFFSET = 7
BR0 = 0
BW0 = 1
BR1 = 1
BW1 = 2
BR2 = 2
BW2 = 3
BR3 = 3
BW3 = 4
FW0 = 1
FR0 = 2
FW1 = 2
FR1 = 3
FW2 = 3
FR2 = 4
FW3 = 4
FR3 = 8
TEXT runtime·memmove(SB), NOSPLIT, $4-12
_memmove:
MOVW to+0(FP), R(TS)
MOVW from+4(FP), R(FROM)
MOVW n+8(FP), R(N)
ADD R(N), R(TS), R(TE)
CMP R(FROM), R(TS)
BLS _forward
_back:
ADD R(N), R(FROM)
CMP $4, R(N)
BLT _b1tail
_b4align:
AND.S $3, R(TE), R(TMP)
BEQ _b4aligned
MOVBU.W -1(R(FROM)), R(TMP)
MOVBU.W R(TMP), -1(R(TE))
B _b4align
_b4aligned:
AND.S $3, R(FROM), R(TMP)
BNE _bunaligned
ADD $31, R(TS), R(TMP)
MOVW R(TS), savedts-4(SP)
_b32loop:
CMP R(TMP), R(TE)
BLS _b4tail
MOVM.DB.W (R(FROM)), [R0-R7]
MOVM.DB.W [R0-R7], (R(TE))
B _b32loop
_b4tail:
MOVW savedts-4(SP), R(TS)
ADD $3, R(TS), R(TMP)
_b4loop:
CMP R(TMP), R(TE)
BLS _b1tail
MOVW.W -4(R(FROM)), R(TMP1)
MOVW.W R(TMP1), -4(R(TE))
B _b4loop
_b1tail:
CMP R(TE), R(TS)
BEQ _return
MOVBU.W -1(R(FROM)), R(TMP)
MOVBU.W R(TMP), -1(R(TE))
B _b1tail
_forward:
CMP $4, R(N)
BLT _f1tail
_f4align:
AND.S $3, R(TS), R(TMP)
BEQ _f4aligned
MOVBU.P 1(R(FROM)), R(TMP)
MOVBU.P R(TMP), 1(R(TS))
B _f4align
_f4aligned:
AND.S $3, R(FROM), R(TMP)
BNE _funaligned
SUB $31, R(TE), R(TMP)
MOVW R(TE), savedte-4(SP)
_f32loop:
CMP R(TMP), R(TS)
BHS _f4tail
MOVM.IA.W (R(FROM)), [R1-R8]
MOVM.IA.W [R1-R8], (R(TS))
B _f32loop
_f4tail:
MOVW savedte-4(SP), R(TE)
SUB $3, R(TE), R(TMP)
_f4loop:
CMP R(TMP), R(TS)
BHS _f1tail
MOVW.P 4(R(FROM)), R(TMP1)
MOVW.P R(TMP1), 4(R(TS))
B _f4loop
_f1tail:
CMP R(TS), R(TE)
BEQ _return
MOVBU.P 1(R(FROM)), R(TMP)
MOVBU.P R(TMP), 1(R(TS))
B _f1tail
_return:
MOVW to+0(FP), R0
RET
_bunaligned:
CMP $2, R(TMP)
MOVW.LT $8, R(RSHIFT)
MOVW.LT $24, R(LSHIFT)
MOVW.LT $1, R(OFFSET)
MOVW.EQ $16, R(RSHIFT)
MOVW.EQ $16, R(LSHIFT)
MOVW.EQ $2, R(OFFSET)
MOVW.GT $24, R(RSHIFT)
MOVW.GT $8, R(LSHIFT)
MOVW.GT $3, R(OFFSET)
ADD $16, R(TS), R(TMP)
CMP R(TMP), R(TE)
BLS _b1tail
BIC $3, R(FROM)
MOVW R(TS), savedts-4(SP)
MOVW (R(FROM)), R(BR0)
_bu16loop:
CMP R(TMP), R(TE)
BLS _bu1tail
MOVW R(BR0)<<R(LSHIFT), R(BW3)
MOVM.DB.W (R(FROM)), [R(BR0)-R(BR3)]
ORR R(BR3)>>R(RSHIFT), R(BW3)
MOVW R(BR3)<<R(LSHIFT), R(BW2)
ORR R(BR2)>>R(RSHIFT), R(BW2)
MOVW R(BR2)<<R(LSHIFT), R(BW1)
ORR R(BR1)>>R(RSHIFT), R(BW1)
MOVW R(BR1)<<R(LSHIFT), R(BW0)
ORR R(BR0)>>R(RSHIFT), R(BW0)
MOVM.DB.W [R(BW0)-R(BW3)], (R(TE))
B _bu16loop
_bu1tail:
MOVW savedts-4(SP), R(TS)
ADD R(OFFSET), R(FROM)
B _b1tail
_funaligned:
CMP $2, R(TMP)
MOVW.LT $8, R(RSHIFT)
MOVW.LT $24, R(LSHIFT)
MOVW.LT $3, R(OFFSET)
MOVW.EQ $16, R(RSHIFT)
MOVW.EQ $16, R(LSHIFT)
MOVW.EQ $2, R(OFFSET)
MOVW.GT $24, R(RSHIFT)
MOVW.GT $8, R(LSHIFT)
MOVW.GT $1, R(OFFSET)
SUB $16, R(TE), R(TMP)
CMP R(TMP), R(TS)
BHS _f1tail
BIC $3, R(FROM)
MOVW R(TE), savedte-4(SP)
MOVW.P 4(R(FROM)), R(FR3)
_fu16loop:
CMP R(TMP), R(TS)
BHS _fu1tail
MOVW R(FR3)>>R(RSHIFT), R(FW0)
MOVM.IA.W (R(FROM)), [R(FR0),R(FR1),R(FR2),R(FR3)]
ORR R(FR0)<<R(LSHIFT), R(FW0)
MOVW R(FR0)>>R(RSHIFT), R(FW1)
ORR R(FR1)<<R(LSHIFT), R(FW1)
MOVW R(FR1)>>R(RSHIFT), R(FW2)
ORR R(FR2)<<R(LSHIFT), R(FW2)
MOVW R(FR2)>>R(RSHIFT), R(FW3)
ORR R(FR3)<<R(LSHIFT), R(FW3)
MOVM.IA.W [R(FW0),R(FW1),R(FW2),R(FW3)], (R(TS))
B _fu16loop
_fu1tail:
MOVW savedte-4(SP), R(TE)
SUB R(OFFSET), R(FROM)
B _f1tail