...
Run Format

Text file src/runtime/memmove_s390x.s

Documentation: runtime

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

View as plain text