...

Text file src/runtime/memmove_wasm.s

     1	// Copyright 2018 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	// func memmove(to, from unsafe.Pointer, n uintptr)
     8	TEXT runtime·memmove(SB), NOSPLIT, $0-24
     9		MOVD to+0(FP), R0
    10		MOVD from+8(FP), R1
    11		MOVD n+16(FP), R2
    12	
    13		Get R0
    14		Get R1
    15		I64LtU
    16		If // forward
    17	exit_forward_64:
    18			Block
    19	loop_forward_64:
    20				Loop
    21					Get R2
    22					I64Const $8
    23					I64LtU
    24					BrIf exit_forward_64
    25	
    26					MOVD 0(R1), 0(R0)
    27	
    28					Get R0
    29					I64Const $8
    30					I64Add
    31					Set R0
    32	
    33					Get R1
    34					I64Const $8
    35					I64Add
    36					Set R1
    37	
    38					Get R2
    39					I64Const $8
    40					I64Sub
    41					Set R2
    42	
    43					Br loop_forward_64
    44				End
    45			End
    46	
    47	loop_forward_8:
    48			Loop
    49				Get R2
    50				I64Eqz
    51				If
    52					RET
    53				End
    54	
    55				Get R0
    56				I32WrapI64
    57				I64Load8U (R1)
    58				I64Store8 $0
    59	
    60				Get R0
    61				I64Const $1
    62				I64Add
    63				Set R0
    64	
    65				Get R1
    66				I64Const $1
    67				I64Add
    68				Set R1
    69	
    70				Get R2
    71				I64Const $1
    72				I64Sub
    73				Set R2
    74	
    75				Br loop_forward_8
    76			End
    77	
    78		Else
    79			// backward
    80			Get R0
    81			Get R2
    82			I64Add
    83			Set R0
    84	
    85			Get R1
    86			Get R2
    87			I64Add
    88			Set R1
    89	
    90	exit_backward_64:
    91			Block
    92	loop_backward_64:
    93				Loop
    94					Get R2
    95					I64Const $8
    96					I64LtU
    97					BrIf exit_backward_64
    98	
    99					Get R0
   100					I64Const $8
   101					I64Sub
   102					Set R0
   103	
   104					Get R1
   105					I64Const $8
   106					I64Sub
   107					Set R1
   108	
   109					Get R2
   110					I64Const $8
   111					I64Sub
   112					Set R2
   113	
   114					MOVD 0(R1), 0(R0)
   115	
   116					Br loop_backward_64
   117				End
   118			End
   119	
   120	loop_backward_8:
   121			Loop
   122				Get R2
   123				I64Eqz
   124				If
   125					RET
   126				End
   127	
   128				Get R0
   129				I64Const $1
   130				I64Sub
   131				Set R0
   132	
   133				Get R1
   134				I64Const $1
   135				I64Sub
   136				Set R1
   137	
   138				Get R2
   139				I64Const $1
   140				I64Sub
   141				Set R2
   142	
   143				Get R0
   144				I32WrapI64
   145				I64Load8U (R1)
   146				I64Store8 $0
   147	
   148				Br loop_backward_8
   149			End
   150		End
   151	
   152		UNDEF

View as plain text