Text file src/runtime/memmove_s390x.s

     1  // Copyright 2016 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  #include "textflag.h"
     6  
     7  // See memmove Go doc for important implementation constraints.
     8  
     9  // func memmove(to, from unsafe.Pointer, n uintptr)
    10  TEXT runtime¬∑memmove(SB),NOSPLIT|NOFRAME,$0-24
    11  	MOVD	to+0(FP), R6
    12  	MOVD	from+8(FP), R4
    13  	MOVD	n+16(FP), R5
    14  
    15  	CMPBEQ	R6, R4, done
    16  
    17  start:
    18  	CMPBLE	R5, $3, move0to3
    19  	CMPBLE	R5, $7, move4to7
    20  	CMPBLE	R5, $11, move8to11
    21  	CMPBLE	R5, $15, move12to15
    22  	CMPBNE	R5, $16, movemt16
    23  	MOVD	0(R4), R7
    24  	MOVD	8(R4), R8
    25  	MOVD	R7, 0(R6)
    26  	MOVD	R8, 8(R6)
    27  	RET
    28  
    29  movemt16:
    30  	CMPBGT	R4, R6, forwards
    31  	ADD	R5, R4, R7
    32  	CMPBLE	R7, R6, forwards
    33  	ADD	R5, R6, R8
    34  backwards:
    35  	MOVD	-8(R7), R3
    36  	MOVD	R3, -8(R8)
    37  	MOVD	-16(R7), R3
    38  	MOVD	R3, -16(R8)
    39  	ADD	$-16, R5
    40  	ADD	$-16, R7
    41  	ADD	$-16, R8
    42  	CMP	R5, $16
    43  	BGE	backwards
    44  	BR	start
    45  
    46  forwards:
    47  	CMPBGT	R5, $64, forwards_fast
    48  	MOVD	0(R4), R3
    49  	MOVD	R3, 0(R6)
    50  	MOVD	8(R4), R3
    51  	MOVD	R3, 8(R6)
    52  	ADD	$16, R4
    53  	ADD	$16, R6
    54  	ADD	$-16, R5
    55  	CMP	R5, $16
    56  	BGE	forwards
    57  	BR	start
    58  
    59  forwards_fast:
    60  	CMP	R5, $256
    61  	BLE	forwards_small
    62  	MVC	$256, 0(R4), 0(R6)
    63  	ADD	$256, R4
    64  	ADD	$256, R6
    65  	ADD	$-256, R5
    66  	BR	forwards_fast
    67  
    68  forwards_small:
    69  	CMPBEQ	R5, $0, done
    70  	ADD	$-1, R5
    71  	EXRL	$memmove_exrl_mvc<>(SB), R5
    72  	RET
    73  
    74  move0to3:
    75  	CMPBEQ	R5, $0, done
    76  move1:
    77  	CMPBNE	R5, $1, move2
    78  	MOVB	0(R4), R3
    79  	MOVB	R3, 0(R6)
    80  	RET
    81  move2:
    82  	CMPBNE	R5, $2, move3
    83  	MOVH	0(R4), R3
    84  	MOVH	R3, 0(R6)
    85  	RET
    86  move3:
    87  	MOVH	0(R4), R3
    88  	MOVB	2(R4), R7
    89  	MOVH	R3, 0(R6)
    90  	MOVB	R7, 2(R6)
    91  	RET
    92  
    93  move4to7:
    94  	CMPBNE	R5, $4, move5
    95  	MOVW	0(R4), R3
    96  	MOVW	R3, 0(R6)
    97  	RET
    98  move5:
    99  	CMPBNE	R5, $5, move6
   100  	MOVW	0(R4), R3
   101  	MOVB	4(R4), R7
   102  	MOVW	R3, 0(R6)
   103  	MOVB	R7, 4(R6)
   104  	RET
   105  move6:
   106  	CMPBNE	R5, $6, move7
   107  	MOVW	0(R4), R3
   108  	MOVH	4(R4), R7
   109  	MOVW	R3, 0(R6)
   110  	MOVH	R7, 4(R6)
   111  	RET
   112  move7:
   113  	MOVW	0(R4), R3
   114  	MOVH	4(R4), R7
   115  	MOVB	6(R4), R8
   116  	MOVW	R3, 0(R6)
   117  	MOVH	R7, 4(R6)
   118  	MOVB	R8, 6(R6)
   119  	RET
   120  
   121  move8to11:
   122  	CMPBNE	R5, $8, move9
   123  	MOVD	0(R4), R3
   124  	MOVD	R3, 0(R6)
   125  	RET
   126  move9:
   127  	CMPBNE	R5, $9, move10
   128  	MOVD	0(R4), R3
   129  	MOVB	8(R4), R7
   130  	MOVD	R3, 0(R6)
   131  	MOVB	R7, 8(R6)
   132  	RET
   133  move10:
   134  	CMPBNE	R5, $10, move11
   135  	MOVD	0(R4), R3
   136  	MOVH	8(R4), R7
   137  	MOVD	R3, 0(R6)
   138  	MOVH	R7, 8(R6)
   139  	RET
   140  move11:
   141  	MOVD	0(R4), R3
   142  	MOVH	8(R4), R7
   143  	MOVB	10(R4), R8
   144  	MOVD	R3, 0(R6)
   145  	MOVH	R7, 8(R6)
   146  	MOVB	R8, 10(R6)
   147  	RET
   148  
   149  move12to15:
   150  	CMPBNE	R5, $12, move13
   151  	MOVD	0(R4), R3
   152  	MOVW	8(R4), R7
   153  	MOVD	R3, 0(R6)
   154  	MOVW	R7, 8(R6)
   155  	RET
   156  move13:
   157  	CMPBNE	R5, $13, move14
   158  	MOVD	0(R4), R3
   159  	MOVW	8(R4), R7
   160  	MOVB	12(R4), R8
   161  	MOVD	R3, 0(R6)
   162  	MOVW	R7, 8(R6)
   163  	MOVB	R8, 12(R6)
   164  	RET
   165  move14:
   166  	CMPBNE	R5, $14, move15
   167  	MOVD	0(R4), R3
   168  	MOVW	8(R4), R7
   169  	MOVH	12(R4), R8
   170  	MOVD	R3, 0(R6)
   171  	MOVW	R7, 8(R6)
   172  	MOVH	R8, 12(R6)
   173  	RET
   174  move15:
   175  	MOVD	0(R4), R3
   176  	MOVW	8(R4), R7
   177  	MOVH	12(R4), R8
   178  	MOVB	14(R4), R10
   179  	MOVD	R3, 0(R6)
   180  	MOVW	R7, 8(R6)
   181  	MOVH	R8, 12(R6)
   182  	MOVB	R10, 14(R6)
   183  done:
   184  	RET
   185  
   186  // DO NOT CALL - target for exrl (execute relative long) instruction.
   187  TEXT memmove_exrl_mvc<>(SB),NOSPLIT|NOFRAME,$0-0
   188  	MVC	$1, 0(R4), 0(R6)
   189  	MOVD	R0, 0(R0)
   190  	RET
   191  
   192  

View as plain text