github.com/primecitizens/pcz/std@v0.2.1/core/mem/move_s390x.s (about)

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