57 lines
1.4 KiB
ArmAsm
57 lines
1.4 KiB
ArmAsm
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
#include "textflag.h"
|
|
|
|
// The link-regression kernel for loong64, the amd64 one's sibling:
|
|
// stack discipline (add), an intra-file call (probe calling seven,
|
|
// R_CALLLOONG64), a PCALAU12I pair against static data (word<>,
|
|
// R_LOONG64_ADDR_HI/LO), a symbol-valued DATA field (entry holding
|
|
// seven's address, R_ADDR), NOPTR data outside the GC's type scan
|
|
// (counter) and the data section itself. The callee's result slot sits
|
|
// at the caller's SP+8 (R3), the loong64 ABI0 frame convention.
|
|
|
|
// func add(a, b int64) int64
|
|
TEXT ·add(SB), NOSPLIT, $0-24
|
|
MOVV a+0(FP), R4
|
|
MOVV b+8(FP), R5
|
|
ADDV R5, R4, R4
|
|
MOVV R4, ret+16(FP)
|
|
RET
|
|
|
|
// func seven() int64
|
|
TEXT ·seven(SB), NOSPLIT, $0-8
|
|
MOVV $7, R4
|
|
MOVV R4, ret+0(FP)
|
|
RET
|
|
|
|
// func probe() int64 = seven() + word<>(SB)
|
|
TEXT ·probe(SB), NOSPLIT, $8-8
|
|
CALL ·seven(SB)
|
|
MOVV 8(R3), R4
|
|
MOVV word<>(SB), R5
|
|
ADDV R5, R4, R4
|
|
MOVV R4, ret+0(FP)
|
|
RET
|
|
|
|
// func entryAddr() uintptr
|
|
TEXT ·entryAddr(SB), NOSPLIT, $0-8
|
|
MOVV entry(SB), R4
|
|
MOVV R4, ret+0(FP)
|
|
RET
|
|
|
|
// func counterVal() int64
|
|
TEXT ·counterVal(SB), NOSPLIT, $0-8
|
|
MOVV counter(SB), R4
|
|
MOVV R4, ret+0(FP)
|
|
RET
|
|
|
|
GLOBL word<>(SB), RODATA, $8
|
|
DATA word<>+0(SB)/8, $0x0fedcba987654321
|
|
|
|
GLOBL entry(SB), RODATA, $8
|
|
DATA entry+0(SB)/8, $·seven(SB)
|
|
|
|
GLOBL counter(SB), NOPTR, $8
|
|
DATA counter+0(SB)/8, $1234
|