Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ jobs:
tools/check-generated.sh \
tools/check-lvo-matrix.sh \
tools/check-lvo-clobbers.sh \
tools/check-call-abi.sh \
tools/check-option-stubs.sh \
tools/check-gitlinks.sh \
tools/check-test-duration.sh \
Expand Down
3 changes: 2 additions & 1 deletion bench/copycheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#include <stdio.h>

extern VOID n68k_copy_bytes(UBYTE *to, const UBYTE *from, ULONG len);
/* Assembly that reads the stack: __stdargs, as src/net68k/net68k.h pins it. */
extern __stdargs VOID n68k_copy_bytes(UBYTE *to, const UBYTE *from, ULONG len);

#define PAD 8
#define MAXLEN 80
Expand Down
38 changes: 21 additions & 17 deletions bench/sumbench.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,23 @@ struct Device *TimerBase;
static struct IORequest timer_req;
static struct MsgPort *timer_port;

extern ULONG v_addadd(ULONG *to, const ULONG *from, ULONG count);
extern ULONG v_addx(ULONG *to, const ULONG *from, ULONG count);
extern ULONG v_discrete(ULONG *to, const ULONG *from, ULONG count);
extern ULONG v_disc16(ULONG *to, const ULONG *from, ULONG count);
extern ULONG v_disc4(ULONG *to, const ULONG *from, ULONG count);
extern ULONG v_ldmovem(ULONG *to, const ULONG *from, ULONG count);
extern ULONG v_addx14(ULONG *to, const ULONG *from, ULONG count);
extern ULONG v_lm14(ULONG *to, const ULONG *from, ULONG count);
extern ULONG v_lmsep(ULONG *to, const ULONG *from, ULONG count);
extern ULONG v_shift2(ULONG *to, const ULONG *from, ULONG count);

/* The contract, from src/net68k/n68k_checksum.c. */
static ULONG v_reference(ULONG *to, const ULONG *from, ULONG count)
/* sumvar*.S read their arguments from the stack: __stdargs (the compiler's
own spelling of AMIGA_ASM_ARGS) keeps that true under -mregparm, here and
on every pointer the variants are timed through. */
extern __stdargs ULONG v_addadd(ULONG *to, const ULONG *from, ULONG count);
extern __stdargs ULONG v_addx(ULONG *to, const ULONG *from, ULONG count);
extern __stdargs ULONG v_discrete(ULONG *to, const ULONG *from, ULONG count);
extern __stdargs ULONG v_disc16(ULONG *to, const ULONG *from, ULONG count);
extern __stdargs ULONG v_disc4(ULONG *to, const ULONG *from, ULONG count);
extern __stdargs ULONG v_ldmovem(ULONG *to, const ULONG *from, ULONG count);
extern __stdargs ULONG v_addx14(ULONG *to, const ULONG *from, ULONG count);
extern __stdargs ULONG v_lm14(ULONG *to, const ULONG *from, ULONG count);
extern __stdargs ULONG v_lmsep(ULONG *to, const ULONG *from, ULONG count);
extern __stdargs ULONG v_shift2(ULONG *to, const ULONG *from, ULONG count);

/* The contract, from src/net68k/n68k_checksum.c. Timed through the same
pinned pointer as the assembly, so pinned the same way. */
static __stdargs ULONG v_reference(ULONG *to, const ULONG *from, ULONG count)
{
ULONG acc = 0;

Expand Down Expand Up @@ -90,7 +94,7 @@ static ULONG failures;
* writes one too many.
*/
static void check(const char *name,
ULONG (*fn)(ULONG *, const ULONG *, ULONG))
__stdargs ULONG (*fn)(ULONG *, const ULONG *, ULONG))
{
ULONG n;

Expand Down Expand Up @@ -185,7 +189,7 @@ static ULONG ns_tenths_per_byte(ULONG ticks, ULONG bytes)
* byte written must match the C reference over the SAME bytes.
*/
static void check_skewed(const char *name,
ULONG (*fn)(ULONG *, const ULONG *, ULONG))
__stdargs ULONG (*fn)(ULONG *, const ULONG *, ULONG))
{
const ULONG *from = (const ULONG *)(const APTR)((const UBYTE *)src + 2);
ULONG n = 64UL;
Expand Down Expand Up @@ -233,7 +237,7 @@ static void check_skewed(const char *name,
}

static void bench_skewed(const char *name,
ULONG (*fn)(ULONG *, const ULONG *, ULONG),
__stdargs ULONG (*fn)(ULONG *, const ULONG *, ULONG),
ULONG words, ULONG reps)
{
const ULONG *from = (const ULONG *)(const APTR)((const UBYTE *)src + 2);
Expand All @@ -257,7 +261,7 @@ static void bench_skewed(const char *name,
}

static void bench(const char *name,
ULONG (*fn)(ULONG *, const ULONG *, ULONG),
__stdargs ULONG (*fn)(ULONG *, const ULONG *, ULONG),
ULONG words, ULONG reps)
{
ULONG t0, ticks, i, bytes;
Expand Down
4 changes: 3 additions & 1 deletion bench/sumcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

#include <stdio.h>

extern ULONG n68k_copy_sum_longwords(ULONG *to, const ULONG *from, ULONG count);
/* Assembly that reads the stack: __stdargs, as src/net68k/net68k.h pins it. */
extern __stdargs ULONG n68k_copy_sum_longwords(ULONG *to, const ULONG *from,
ULONG count);

static ULONG v_reference(ULONG *to, const ULONG *from, ULONG count)
{
Expand Down
12 changes: 8 additions & 4 deletions src/crypto68k/c68k_p256.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ extern const c68k_limb c68k_p256_comb[C68K_P256_COMB_POINTS][16];
* The three routines c68k_p256.S hand-writes, with portable C fallbacks in
* c68k_p256.c under the same build flag as c68k_prim.S. Exposed rather than
* static because the assembly has to define them, and because the test drives
* the reduction directly against the vendored one.
* the reduction directly against the vendored one. The assembly reads its
* arguments from the stack, so every one carries AMIGA_ASM_ARGS: unpinned, a
* 68020 or 68040 build handed them a0/a1/a2 (aminetxduo/asm_abi.h).
*
* GCC cannot generate the ADD.L / ADDX.L pair these need, C has no carry
* flag, and the disassembly of both plausible C spellings is in the header
Expand All @@ -101,16 +103,18 @@ extern const c68k_limb c68k_p256_comb[C68K_P256_COMB_POINTS][16];
*/

/* r = a + b over eight limbs, no modular reduction. Returns the carry out. */
c68k_limb c68k_p256_add_raw(c68k_limb *r, const c68k_limb *a, const c68k_limb *b);
AMIGA_ASM_ARGS c68k_limb c68k_p256_add_raw(c68k_limb *r, const c68k_limb *a,
const c68k_limb *b);

/* r = a - b over eight limbs, no modular reduction. Returns the borrow out. */
c68k_limb c68k_p256_sub_raw(c68k_limb *r, const c68k_limb *a, const c68k_limb *b);
AMIGA_ASM_ARGS c68k_limb c68k_p256_sub_raw(c68k_limb *r, const c68k_limb *a,
const c68k_limb *b);

/*
* One pass of the Solinas reduction: writes r[0..7] and returns the leftover
* signed coefficient of 2^256, which c68k_p256_fe_reduce() folds in.
*/
INT c68k_p256_reduce_core(c68k_limb *r, const c68k_limb *t);
AMIGA_ASM_ARGS INT c68k_p256_reduce_core(c68k_limb *r, const c68k_limb *t);


/* ------------------------------------------------------ field, exposed --- */
Expand Down
73 changes: 39 additions & 34 deletions tests/crypto68k/c68k_bulk_bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "c68k_sha256.h"
#include "c68k_chacha20.h"

#include "aminetxduo/asm_abi.h"
#include "aminetxduo/crashguard.h"

#include "nx_crypto_aes.h"
Expand Down Expand Up @@ -91,38 +92,40 @@ static ULONG b_kbs(ULONG micros)
}


extern VOID bk_empty(ULONG reps);
extern VOID bk_add(ULONG reps);
extern VOID bk_eor(ULONG reps);
extern VOID bk_and(ULONG reps);
extern VOID bk_moveb_dd(ULONG reps);
extern VOID bk_swapd(ULONG reps);
extern VOID bk_ror1(ULONG reps);
extern VOID bk_ror8(ULONG reps);
extern VOID bk_rorreg(ULONG reps);
extern VOID bk_lsr3(ULONG reps);
extern VOID bk_addself(ULONG reps);
extern VOID bk_exg_da(ULONG reps);
extern VOID bk_movel_ad(ULONG reps);
extern VOID bk_movel_da(ULONG reps);
extern VOID bk_addx(ULONG reps);
extern VOID bk_andi(ULONG reps);
extern VOID bk_rol6(ULONG reps);
extern VOID bk_mulu_dd(APTR table, ULONG reps);
extern VOID bk_mulu_an(APTR table, ULONG reps);
extern VOID bk_mulu_d16(APTR table, ULONG reps);
extern VOID bk_idx1k(APTR table, ULONG reps);
extern VOID bk_idx4k(APTR table, ULONG reps);
extern VOID bk_idxb(APTR table, ULONG reps);
extern VOID bk_movel_d16(APTR table, ULONG reps);
extern VOID bk_moveb_d16(APTR table, ULONG reps);
extern VOID bk_movel_store(APTR table, ULONG reps);
extern VOID bk_ic32(ULONG reps);
extern VOID bk_ic128(ULONG reps);
extern VOID bk_ic256(ULONG reps);
extern VOID bk_ic512(ULONG reps);
extern VOID bk_ic1024(ULONG reps);
extern VOID bk_ic2048(ULONG reps);
/* c68k_bulk_kernels.S reads its arguments from the stack, so every kernel
carries the stack pin (aminetxduo/asm_abi.h). */
extern AMIGA_ASM_ARGS VOID bk_empty(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_add(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_eor(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_and(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_moveb_dd(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_swapd(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_ror1(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_ror8(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_rorreg(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_lsr3(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_addself(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_exg_da(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_movel_ad(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_movel_da(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_addx(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_andi(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_rol6(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_mulu_dd(APTR table, ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_mulu_an(APTR table, ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_mulu_d16(APTR table, ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_idx1k(APTR table, ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_idx4k(APTR table, ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_idxb(APTR table, ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_movel_d16(APTR table, ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_moveb_d16(APTR table, ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_movel_store(APTR table, ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_ic32(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_ic128(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_ic256(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_ic512(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_ic1024(ULONG reps);
extern AMIGA_ASM_ARGS VOID bk_ic2048(ULONG reps);

#define B_KERNEL_REPS 40000UL
#define B_KERNEL_SLOTS 16UL
Expand All @@ -131,8 +134,10 @@ static ULONG b_empty_ps; /* loop overhead, ps per body slot */
static ULONG b_add_ps; /* one ADD.L, the yardstick */
static APTR b_table; /* 4 KB of Fast RAM */

typedef VOID (*B_REG_KERNEL)(ULONG);
typedef VOID (*B_MEM_KERNEL)(APTR, ULONG);
/* Pinned like the kernels: a call through an unpinned pointer passes reps in
d0 whatever the declaration of the routine said. */
typedef AMIGA_ASM_ARGS VOID (*B_REG_KERNEL)(ULONG);
typedef AMIGA_ASM_ARGS VOID (*B_MEM_KERNEL)(APTR, ULONG);

static ULONG b_scale(ULONG micros, ULONG slots)
{
Expand Down
24 changes: 14 additions & 10 deletions tests/perf/cpucal.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdarg.h>
#include <string.h>

#include "aminetxduo/asm_abi.h"
#include "aminetxduo/compat.h"


Expand Down Expand Up @@ -128,16 +129,19 @@ ULONG i, t0, t1, total;

/* ------------------------------------------------------------- kernels --- */

extern VOID cal_empty (ULONG reps);
extern VOID cal_add (ULONG reps);
extern VOID cal_move (ULONG reps);
extern VOID cal_addx (ULONG reps);
extern VOID cal_mulu (ULONG reps);
extern VOID cal_mulu64(ULONG reps);
extern VOID cal_read (APTR buf, ULONG longs, ULONG reps);
extern VOID cal_write (APTR buf, ULONG longs, ULONG reps);
extern VOID cal_m2m (APTR dst, APTR src, ULONG longs, ULONG reps);
extern VOID cal_movem (APTR dst, APTR src, ULONG longs, ULONG reps);
/* cpucal.S reads its arguments from the stack, so each kernel carries the
stack pin (aminetxduo/asm_abi.h); unpinned they got `reps' in d0 and
counted whatever the stack held. */
extern AMIGA_ASM_ARGS VOID cal_empty (ULONG reps);
extern AMIGA_ASM_ARGS VOID cal_add (ULONG reps);
extern AMIGA_ASM_ARGS VOID cal_move (ULONG reps);
extern AMIGA_ASM_ARGS VOID cal_addx (ULONG reps);
extern AMIGA_ASM_ARGS VOID cal_mulu (ULONG reps);
extern AMIGA_ASM_ARGS VOID cal_mulu64(ULONG reps);
extern AMIGA_ASM_ARGS VOID cal_read (APTR buf, ULONG longs, ULONG reps);
extern AMIGA_ASM_ARGS VOID cal_write (APTR buf, ULONG longs, ULONG reps);
extern AMIGA_ASM_ARGS VOID cal_m2m (APTR dst, APTR src, ULONG longs, ULONG reps);
extern AMIGA_ASM_ARGS VOID cal_movem (APTR dst, APTR src, ULONG longs, ULONG reps);

#define K_EMPTY 0
#define K_ADD 1
Expand Down
2 changes: 1 addition & 1 deletion third_party/netxduo
2 changes: 1 addition & 1 deletion third_party/wifipi
32 changes: 32 additions & 0 deletions tools/check-call-abi-allow.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Crossings tools/check-call-abi.py reports that are right as they are.
#
# rule file name reason
#
# One line each, keyed by rule, file and name, so an entry covers only the
# place it names. An entry the tree no longer needs fails the check: delete
# it with the code it described.

# tool_startup.S loads the two flags into d0/d1 AND pushes them, so the call
# is right under either convention; the toolchain file says why it is the one
# unpinned call from assembly (cmake/toolchain-m68k-amigaos.cmake).
asm-call src/tools/tool_startup.S ami_rt_cpu_select both conventions loaded at the call site

# Built by their own scripts without -mregparm, against libgcc, which pushes.
rt-helper tests/endurance/fitz-kprintf.c __udivdi3 tests/endurance/build.sh, no -mregparm
rt-helper tests/endurance/fitz-kprintf.c __umoddi3 tests/endurance/build.sh, no -mregparm
rt-helper tests/toolchain/lto-late-libcall/runtime.c __muldi3 reproduce.sh, plain m68k-amigaos-gcc

# Function-pointer types in include/aminetxduo that never leave the image
# that sets them: caller and callee are linked into one binary, built with
# one set of flags.
shared-type include/aminetxduo/bpf.h AmiBpfInjectFn src/bpf and src/sana2, bsdsocket.library only
shared-type include/aminetxduo/bpf.h inject bsdsocket.library only
shared-type include/aminetxduo/bpf.h AmiBpfAddrFn src/bpf and src/netstack, bsdsocket.library only
shared-type include/aminetxduo/bpf.h AmiBpfCaptureFn src/bpf and src/netstack, bsdsocket.library only
shared-type include/aminetxduo/bpf.h fn bsdsocket.library only
shared-type include/aminetxduo/compat.h AmiLogLineFn src/common/ami_diag.c, set and called in each image
shared-type include/aminetxduo/compat.h fn src/common/ami_diag.c, set and called in each image
shared-type include/aminetxduo/config.h AmiCfgReporter src/config, passed by a caller in the same image
shared-type include/aminetxduo/config.h reporter src/config, passed by a caller in the same image
shared-type include/aminetxduo/netstack.h AmiNetGiveUpFn src/netstack and src/bsdsocket, bsdsocket.library only
shared-type include/aminetxduo/netstack.h give_up bsdsocket.library only
Loading
Loading