| 1 |
// Copyright 2015 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
//go:build mips64 || mips64le |
| 6 |
|
| 7 |
#include "textflag.h" |
| 8 |
|
| 9 |
// See memmove Go doc for important implementation constraints. |
| 10 |
|
| 11 |
// func memmove(to, from unsafe.Pointer, n uintptr) |
| 12 |
TEXT runtime·memmove(SB), NOSPLIT|NOFRAME, $0-24 |
| 13 |
MOVV to+0(FP), R1 |
| 14 |
MOVV from+8(FP), R2 |
| 15 |
MOVV n+16(FP), R3 |
| 16 |
BNE R3, check |
| 17 |
RET |
| 18 |
|
| 19 |
check: |
| 20 |
SGTU R1, R2, R4 |
| 21 |
BNE R4, backward |
| 22 |
|
| 23 |
ADDV R1, R3, R6 // end pointer |
| 24 |
|
| 25 |
// if the two pointers are not of same alignments, do byte copying |
| 26 |
SUBVU R2, R1, R4 |
| 27 |
AND $7, R4 |
| 28 |
BNE R4, out |
| 29 |
|
| 30 |
// if less than 8 bytes, do byte copying |
| 31 |
SGTU $8, R3, R4 |
| 32 |
BNE R4, out |
| 33 |
|
| 34 |
// do one byte at a time until 8-aligned |
| 35 |
AND $7, R1, R5 |
| 36 |
BEQ R5, words |
| 37 |
MOVB (R2), R4 |
| 38 |
ADDV $1, R2 |
| 39 |
MOVB R4, (R1) |
| 40 |
ADDV $1, R1 |
| 41 |
JMP -6(PC) |
| 42 |
|
| 43 |
words: |
| 44 |
// do 8 bytes at a time if there is room |
| 45 |
ADDV $-7, R6, R3 // R3 is end pointer-7 |
| 46 |
|
| 47 |
SGTU R3, R1, R5 |
| 48 |
BEQ R5, out |
| 49 |
MOVV (R2), R4 |
| 50 |
ADDV $8, R2 |
| 51 |
MOVV R4, (R1) |
| 52 |
ADDV $8, R1 |
| 53 |
JMP -6(PC) |
| 54 |
|
| 55 |
out: |
| 56 |
BEQ R1, R6, done |
| 57 |
MOVB (R2), R4 |
| 58 |
ADDV $1, R2 |
| 59 |
MOVB R4, (R1) |
| 60 |
ADDV $1, R1 |
| 61 |
JMP -5(PC) |
| 62 |
done: |
| 63 |
RET |
| 64 |
|
| 65 |
backward: |
| 66 |
ADDV R3, R2 // from-end pointer |
| 67 |
ADDV R1, R3, R6 // to-end pointer |
| 68 |
|
| 69 |
// if the two pointers are not of same alignments, do byte copying |
| 70 |
SUBVU R6, R2, R4 |
| 71 |
AND $7, R4 |
| 72 |
BNE R4, out1 |
| 73 |
|
| 74 |
// if less than 8 bytes, do byte copying |
| 75 |
SGTU $8, R3, R4 |
| 76 |
BNE R4, out1 |
| 77 |
|
| 78 |
// do one byte at a time until 8-aligned |
| 79 |
AND $7, R6, R5 |
| 80 |
BEQ R5, words1 |
| 81 |
ADDV $-1, R2 |
| 82 |
MOVB (R2), R4 |
| 83 |
ADDV $-1, R6 |
| 84 |
MOVB R4, (R6) |
| 85 |
JMP -6(PC) |
| 86 |
|
| 87 |
words1: |
| 88 |
// do 8 bytes at a time if there is room |
| 89 |
ADDV $7, R1, R3 // R3 is start pointer+7 |
| 90 |
|
| 91 |
SGTU R6, R3, R5 |
| 92 |
BEQ R5, out1 |
| 93 |
ADDV $-8, R2 |
| 94 |
MOVV (R2), R4 |
| 95 |
ADDV $-8, R6 |
| 96 |
MOVV R4, (R6) |
| 97 |
JMP -6(PC) |
| 98 |
|
| 99 |
out1: |
| 100 |
BEQ R1, R6, done1 |
| 101 |
ADDV $-1, R2 |
| 102 |
MOVB (R2), R4 |
| 103 |
ADDV $-1, R6 |
| 104 |
MOVB R4, (R6) |
| 105 |
JMP -5(PC) |
| 106 |
done1: |
| 107 |
RET |