github.com/primecitizens/pcz/std@v0.2.1/core/gc/wb_ppc64x.s (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  //
     4  // Copyright 2014 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 ppc64 || ppc64le
     9  
    10  #include "textflag.h"
    11  
    12  // gcWriteBarrier informs the GC about heap pointer writes.
    13  //
    14  // gcWriteBarrier does NOT follow the Go ABI. It accepts the
    15  // number of bytes of buffer needed in R29, and returns a pointer
    16  // to the buffer space in R29.
    17  // It clobbers condition codes.
    18  // It does not clobber R0 through R17 (except special registers),
    19  // but may clobber any other register, *including* R31.
    20  TEXT gcWriteBarrier<>(SB),NOSPLIT,$120
    21  	// The standard prologue clobbers R31.
    22  	// We use R18, R19, and R31 as scratch registers.
    23  retry:
    24  	MOVD g_m(g), R18
    25  	MOVD m_p(R18), R18
    26  	MOVD (p_wbBuf+wbBuf_next)(R18), R19
    27  	MOVD (p_wbBuf+wbBuf_end)(R18), R31
    28  	// Increment wbBuf.next position.
    29  	ADD R29, R19
    30  	// Is the buffer full?
    31  	CMPU R31, R19
    32  	BLT flush
    33  	// Commit to the larger buffer.
    34  	MOVD R19, (p_wbBuf+wbBuf_next)(R18)
    35  	// Make return value (the original next position)
    36  	SUB R29, R19, R29
    37  	RET
    38  
    39  flush:
    40  	// Save registers R0 through R15 since these were not saved by the caller.
    41  	// We don't save all registers on ppc64 because it takes too much space.
    42  	MOVD R20, (FIXED_FRAME+0)(R1)
    43  	MOVD R21, (FIXED_FRAME+8)(R1)
    44  	// R0 is always 0, so no need to spill.
    45  	// R1 is SP.
    46  	// R2 is SB.
    47  	MOVD R3, (FIXED_FRAME+16)(R1)
    48  	MOVD R4, (FIXED_FRAME+24)(R1)
    49  	MOVD R5, (FIXED_FRAME+32)(R1)
    50  	MOVD R6, (FIXED_FRAME+40)(R1)
    51  	MOVD R7, (FIXED_FRAME+48)(R1)
    52  	MOVD R8, (FIXED_FRAME+56)(R1)
    53  	MOVD R9, (FIXED_FRAME+64)(R1)
    54  	MOVD R10, (FIXED_FRAME+72)(R1)
    55  	// R11, R12 may be clobbered by external-linker-inserted trampoline
    56  	// R13 is REGTLS
    57  	MOVD R14, (FIXED_FRAME+80)(R1)
    58  	MOVD R15, (FIXED_FRAME+88)(R1)
    59  	MOVD R16, (FIXED_FRAME+96)(R1)
    60  	MOVD R17, (FIXED_FRAME+104)(R1)
    61  	MOVD R29, (FIXED_FRAME+112)(R1)
    62  
    63  	CALL runtime·wbBufFlush(SB)
    64  
    65  	MOVD (FIXED_FRAME+0)(R1), R20
    66  	MOVD (FIXED_FRAME+8)(R1), R21
    67  	MOVD (FIXED_FRAME+16)(R1), R3
    68  	MOVD (FIXED_FRAME+24)(R1), R4
    69  	MOVD (FIXED_FRAME+32)(R1), R5
    70  	MOVD (FIXED_FRAME+40)(R1), R6
    71  	MOVD (FIXED_FRAME+48)(R1), R7
    72  	MOVD (FIXED_FRAME+56)(R1), R8
    73  	MOVD (FIXED_FRAME+64)(R1), R9
    74  	MOVD (FIXED_FRAME+72)(R1), R10
    75  	MOVD (FIXED_FRAME+80)(R1), R14
    76  	MOVD (FIXED_FRAME+88)(R1), R15
    77  	MOVD (FIXED_FRAME+96)(R1), R16
    78  	MOVD (FIXED_FRAME+104)(R1), R17
    79  	MOVD (FIXED_FRAME+112)(R1), R29
    80  	JMP retry
    81  
    82  TEXT runtime·gcWriteBarrier1<ABIInternal>(SB),NOSPLIT,$0
    83  	MOVD $8, R29
    84  	JMP gcWriteBarrier<>(SB)
    85  TEXT runtime·gcWriteBarrier2<ABIInternal>(SB),NOSPLIT,$0
    86  	MOVD $16, R29
    87  	JMP gcWriteBarrier<>(SB)
    88  TEXT runtime·gcWriteBarrier3<ABIInternal>(SB),NOSPLIT,$0
    89  	MOVD $24, R29
    90  	JMP gcWriteBarrier<>(SB)
    91  TEXT runtime·gcWriteBarrier4<ABIInternal>(SB),NOSPLIT,$0
    92  	MOVD $32, R29
    93  	JMP gcWriteBarrier<>(SB)
    94  TEXT runtime·gcWriteBarrier5<ABIInternal>(SB),NOSPLIT,$0
    95  	MOVD $40, R29
    96  	JMP gcWriteBarrier<>(SB)
    97  TEXT runtime·gcWriteBarrier6<ABIInternal>(SB),NOSPLIT,$0
    98  	MOVD $48, R29
    99  	JMP gcWriteBarrier<>(SB)
   100  TEXT runtime·gcWriteBarrier7<ABIInternal>(SB),NOSPLIT,$0
   101  	MOVD $56, R29
   102  	JMP gcWriteBarrier<>(SB)
   103  TEXT runtime·gcWriteBarrier8<ABIInternal>(SB),NOSPLIT,$0
   104  	MOVD $64, R29
   105  	JMP gcWriteBarrier<>(SB)