...
Run Format

Text file src/runtime/internal/atomic/asm_ppc64x.s

Documentation: runtime/internal/atomic

     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	// +build ppc64 ppc64le
     6	
     7	#include "textflag.h"
     8	
     9	// bool cas(uint32 *ptr, uint32 old, uint32 new)
    10	// Atomically:
    11	//	if(*val == old){
    12	//		*val = new;
    13	//		return 1;
    14	//	} else
    15	//		return 0;
    16	TEXT runtime∕internal∕atomic·Cas(SB), NOSPLIT, $0-17
    17		MOVD	ptr+0(FP), R3
    18		MOVWZ	old+8(FP), R4
    19		MOVWZ	new+12(FP), R5
    20		LWSYNC
    21	cas_again:
    22		LWAR	(R3), R6
    23		CMPW	R6, R4
    24		BNE	cas_fail
    25		STWCCC	R5, (R3)
    26		BNE	cas_again
    27		MOVD	$1, R3
    28		LWSYNC
    29		MOVB	R3, ret+16(FP)
    30		RET
    31	cas_fail:
    32		MOVB	R0, ret+16(FP)
    33		RET
    34	
    35	// bool	runtime∕internal∕atomic·Cas64(uint64 *ptr, uint64 old, uint64 new)
    36	// Atomically:
    37	//	if(*val == *old){
    38	//		*val = new;
    39	//		return 1;
    40	//	} else {
    41	//		return 0;
    42	//	}
    43	TEXT runtime∕internal∕atomic·Cas64(SB), NOSPLIT, $0-25
    44		MOVD	ptr+0(FP), R3
    45		MOVD	old+8(FP), R4
    46		MOVD	new+16(FP), R5
    47		LWSYNC
    48	cas64_again:
    49		LDAR	(R3), R6
    50		CMP	R6, R4
    51		BNE	cas64_fail
    52		STDCCC	R5, (R3)
    53		BNE	cas64_again
    54		MOVD	$1, R3
    55		LWSYNC
    56		MOVB	R3, ret+24(FP)
    57		RET
    58	cas64_fail:
    59		MOVB	R0, ret+24(FP)
    60		RET
    61	
    62	TEXT runtime∕internal∕atomic·Casuintptr(SB), NOSPLIT, $0-25
    63		BR	runtime∕internal∕atomic·Cas64(SB)
    64	
    65	TEXT runtime∕internal∕atomic·Loaduintptr(SB),  NOSPLIT|NOFRAME, $0-16
    66		BR	runtime∕internal∕atomic·Load64(SB)
    67	
    68	TEXT runtime∕internal∕atomic·Loaduint(SB), NOSPLIT|NOFRAME, $0-16
    69		BR	runtime∕internal∕atomic·Load64(SB)
    70	
    71	TEXT runtime∕internal∕atomic·Storeuintptr(SB), NOSPLIT, $0-16
    72		BR	runtime∕internal∕atomic·Store64(SB)
    73	
    74	TEXT runtime∕internal∕atomic·Xadduintptr(SB), NOSPLIT, $0-24
    75		BR	runtime∕internal∕atomic·Xadd64(SB)
    76	
    77	TEXT runtime∕internal∕atomic·Loadint64(SB), NOSPLIT, $0-16
    78		BR	runtime∕internal∕atomic·Load64(SB)
    79	
    80	TEXT runtime∕internal∕atomic·Xaddint64(SB), NOSPLIT, $0-24
    81		BR	runtime∕internal∕atomic·Xadd64(SB)
    82	
    83	// bool casp(void **val, void *old, void *new)
    84	// Atomically:
    85	//	if(*val == old){
    86	//		*val = new;
    87	//		return 1;
    88	//	} else
    89	//		return 0;
    90	TEXT runtime∕internal∕atomic·Casp1(SB), NOSPLIT, $0-25
    91		BR runtime∕internal∕atomic·Cas64(SB)
    92	
    93	// uint32 xadd(uint32 volatile *ptr, int32 delta)
    94	// Atomically:
    95	//	*val += delta;
    96	//	return *val;
    97	TEXT runtime∕internal∕atomic·Xadd(SB), NOSPLIT, $0-20
    98		MOVD	ptr+0(FP), R4
    99		MOVW	delta+8(FP), R5
   100		LWSYNC
   101		LWAR	(R4), R3
   102		ADD	R5, R3
   103		STWCCC	R3, (R4)
   104		BNE	-3(PC)
   105		MOVW	R3, ret+16(FP)
   106		RET
   107	
   108	TEXT runtime∕internal∕atomic·Xadd64(SB), NOSPLIT, $0-24
   109		MOVD	ptr+0(FP), R4
   110		MOVD	delta+8(FP), R5
   111		LWSYNC
   112		LDAR	(R4), R3
   113		ADD	R5, R3
   114		STDCCC	R3, (R4)
   115		BNE	-3(PC)
   116		MOVD	R3, ret+16(FP)
   117		RET
   118	
   119	TEXT runtime∕internal∕atomic·Xchg(SB), NOSPLIT, $0-20
   120		MOVD	ptr+0(FP), R4
   121		MOVW	new+8(FP), R5
   122		LWSYNC
   123		LWAR	(R4), R3
   124		STWCCC	R5, (R4)
   125		BNE	-2(PC)
   126		ISYNC
   127		MOVW	R3, ret+16(FP)
   128		RET
   129	
   130	TEXT runtime∕internal∕atomic·Xchg64(SB), NOSPLIT, $0-24
   131		MOVD	ptr+0(FP), R4
   132		MOVD	new+8(FP), R5
   133		LWSYNC
   134		LDAR	(R4), R3
   135		STDCCC	R5, (R4)
   136		BNE	-2(PC)
   137		ISYNC
   138		MOVD	R3, ret+16(FP)
   139		RET
   140	
   141	TEXT runtime∕internal∕atomic·Xchguintptr(SB), NOSPLIT, $0-24
   142		BR	runtime∕internal∕atomic·Xchg64(SB)
   143	
   144	
   145	TEXT runtime∕internal∕atomic·StorepNoWB(SB), NOSPLIT, $0-16
   146		BR	runtime∕internal∕atomic·Store64(SB)
   147	
   148	TEXT runtime∕internal∕atomic·Store(SB), NOSPLIT, $0-12
   149		MOVD	ptr+0(FP), R3
   150		MOVW	val+8(FP), R4
   151		SYNC
   152		MOVW	R4, 0(R3)
   153		RET
   154	
   155	TEXT runtime∕internal∕atomic·Store64(SB), NOSPLIT, $0-16
   156		MOVD	ptr+0(FP), R3
   157		MOVD	val+8(FP), R4
   158		SYNC
   159		MOVD	R4, 0(R3)
   160		RET
   161	
   162	// void runtime∕internal∕atomic·Or8(byte volatile*, byte);
   163	TEXT runtime∕internal∕atomic·Or8(SB), NOSPLIT, $0-9
   164		MOVD	ptr+0(FP), R3
   165		MOVBZ	val+8(FP), R4
   166		LWSYNC
   167	again:
   168		LBAR	(R3), R6
   169		OR	R4, R6
   170		STBCCC	R6, (R3)
   171		BNE	again
   172		RET
   173	
   174	// void runtime∕internal∕atomic·And8(byte volatile*, byte);
   175	TEXT runtime∕internal∕atomic·And8(SB), NOSPLIT, $0-9
   176		MOVD	ptr+0(FP), R3
   177		MOVBZ	val+8(FP), R4
   178		LWSYNC
   179	again:
   180		LBAR	(R3),R6
   181		AND	R4,R6
   182		STBCCC	R6,(R3)
   183		BNE	again
   184		RET

View as plain text