// Copyright (c) 2026 Petr Balvín (https://petrbalvin.org) // SPDX-License-Identifier: BSD-3-Clause #include "textflag.h" // fp exercises the floating-point set: 3R arithmetic, 2R unary, compares // into FCC, fused multiply-add and the register moves. TEXT ·fp(SB), NOSPLIT, $0-0 ADDD F4, F5, F6 SUBD F7, F8, F9 MULD F9, F10, F11 DIVD F11, F12, F13 MULF F13, F14, F15 ADDF F15, F16, F17 SQRTD F17, F18 SQRTF F18, F19 ABSD F19, F20 NEGD F20, F21 MOVD F21, F22 CMPEQD F22, F23, FCC0 CMPGTF F23, F24, FCC1 CMPGED F24, F25, FCC2 FMADDD F0, F1, F2, F3 FMSUBF F3, F4, F5, F6 FNMADDD F6, F7, F8, F9 FNMSUBF F9, F10, F11, F12 FMAXD F12, F13, F14 FMINF F14, F15, F16 FMAXAD F16, F17, F18 FMINAF F18, F19, F20 FSCALEBF F20, F21, F22 FCOPYSGD F22, F23, F24 MOVV F25, R25 MOVV R26, F27 MOVW R28, F29 MOVW F30, R31 RET // mov forms: register moves, immediates (12/32/64-bit), memory with FP/SP // pseudo-registers and the register-indexed forms. TEXT ·mov(SB), NOSPLIT, $0-16 MOVV R4, R5 MOVW R6, R7 MOVB R8, R9 MOVBU R10, R11 MOVHU R12, R13 MOVWU R14, R15 MOVV $42, R16 MOVV $0x12345, R17 MOVV $0x100000, R18 MOVW $-100, R19 MOVV $0x123456789, R20 MOVV a+0(FP), R21 MOVV R23, b+8(FP) MOVW c+16(FP), R24 MOVV (R24)(R25), R26 MOVV R27, (R28)(R29) RET // frame exercises the prologue/epilogue of a function with a real frame. TEXT ·frame(SB), NOSPLIT, $32-8 MOVV R4, R5 MOVV arg+0(FP), R6 MOVV R7, local-8(SP) MOVV local-8(SP), R8 MOVV R9, ret+0(FP) RET // branches21 exercises the single-register and zero-register branch forms // with 21-bit offsets. TEXT ·branches21(SB), NOSPLIT, $0-0 BEQ R0, R4, l1 BEQ R5, R0, l2 BNE R0, R6, l3 BNE R7, R0, l4 BLTZ R8, l5 BGEZ R9, l6 BLEZ R10, l7 BGTZ R11, l8 JMP l9 l1: JMP l10 l2: JMP l11 l3: JMP l12 l4: JMP l13 l5: JMP l14 l6: JMP l15 l7: JMP l16 l8: JMP l16 l9: MOVV R1, R2 l10: LL (R12), R13 LLV (R14), R15 SC R16, (R17) SCV R18, (R19) RDTIMED R20, R21 SYSCALL DBAR RET l11: JAL (R30) RET l12: BSTRINSV $7, R4, $0, R5 BSTRPICKV $63, R6, $32, R7 ALSLV $2, R8, R9, R10 ADDV16 $65536, R11, R12 RET l13: MOVV $0xffffffffffffffff, R13 RET l14: CPUCFG R14, R14 RET l15: NOR R15, R16, R17 ORN R18, R19, R20 ANDN R21, R24, R25 RET l16: MOVB R26, (R27) MOVB (R28), R29 RET // sbdata loads and stores a static symbol with relocations (the relocation // fields are masked before comparison). GLOBL ·table(SB), RODATA, $16 DATA ·table+0(SB)/8, $0x1122334455667788 DATA ·table+8(SB)/8, $0x8877665544332211 TEXT ·sbdata(SB), NOSPLIT, $0-0 MOVV $·table(SB), R4 MOVV ·table(SB), R5 MOVV R6, ·table+8(SB) RET