67 lines
1.4 KiB
ArmAsm
67 lines
1.4 KiB
ArmAsm
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
|||
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
||
|
|
|
||
|
|
// Differential kernel for the arm64 integer slice: carry-setting arithmetic,
|
||
|
|
// widening multiplies, bit manipulation, conditional compares, the compare
|
||
|
|
// and test branches, ADR and the wide-constant moves. Every function is
|
||
|
|
// byte-compared against go tool asm.
|
||
|
|
|
||
|
|
#include "textflag.h"
|
||
|
|
|
||
|
|
// func carryArith()
|
||
|
|
TEXT ·carryArith(SB), NOSPLIT, $0-0
|
||
|
|
ADC R0, R2, R12
|
||
|
|
ADCS R23, R22, R22
|
||
|
|
ADC $0, R1
|
||
|
|
SBC R25, R10, R26
|
||
|
|
SBCS R5, R9, R5
|
||
|
|
SBCS $0, R1
|
||
|
|
RET
|
||
|
|
|
||
|
|
// func wideningMul()
|
||
|
|
TEXT ·wideningMul(SB), NOSPLIT, $0-0
|
||
|
|
MUL R4, R3, R0
|
||
|
|
MSUB R19, R16, R26, R2
|
||
|
|
SMULH R24, R20, R24
|
||
|
|
UMULH R24, R20, R24
|
||
|
|
RET
|
||
|
|
|
||
|
|
// func bitManip()
|
||
|
|
TEXT ·bitManip(SB), NOSPLIT, $0-0
|
||
|
|
RBIT R11, R4
|
||
|
|
REV R1, R2
|
||
|
|
CLZ R21, R9
|
||
|
|
REVW R1, R2
|
||
|
|
CLSW R1, R2
|
||
|
|
UBFX $33, R17, $25, R5
|
||
|
|
UBFXW $4, R1, $9, R2
|
||
|
|
RET
|
||
|
|
|
||
|
|
// func condCompare()
|
||
|
|
TEXT ·condCompare(SB), NOSPLIT, $0-0
|
||
|
|
CCMP LE, R7, $19, $3
|
||
|
|
CCMP LT, R30, R6, $7
|
||
|
|
CCMN EQ, R1, R2, $3
|
||
|
|
CCMPW LE, R7, $19, $3
|
||
|
|
RET
|
||
|
|
|
||
|
|
// func branchForms()
|
||
|
|
TEXT ·branchForms(SB), NOSPLIT, $0-0
|
||
|
|
CBZ R1, target
|
||
|
|
CBNZ R7, target
|
||
|
|
CBNZW R2, target
|
||
|
|
TBZ $4, R7, target
|
||
|
|
TBNZ $33, R7, target
|
||
|
|
ADR target, R10
|
||
|
|
|
||
|
|
target:
|
||
|
|
RET
|
||
|
|
|
||
|
|
// func wideMoves()
|
||
|
|
TEXT ·wideMoves(SB), NOSPLIT, $0-0
|
||
|
|
MOVK $1234, R5
|
||
|
|
MOVK $305397760, R5
|
||
|
|
MOVKW $1234, R5
|
||
|
|
MOVK $16771847290880, R21
|
||
|
|
RET
|