packages feed

crypton-2.2.0: cbits/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S

/* Copyright (c) The mldsa-native project authors
 * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
 */

/*yaml
  Name: poly_pointwise_montgomery_aarch64_asm
  Description: AArch64 pointwise Montgomery multiplication of two polynomials
  Signature: void mld_poly_pointwise_montgomery_aarch64_asm(int32_t a[256], const int32_t b[256])
  ABI:
    Architecture: aarch64
    CallingConvention: AAPCS64
    Features: [NEON]
    x0:
      type: buffer
      size_bytes: 1024
      permissions: read/write
      c_parameter: int32_t a[256]
      description: Input/output polynomial (256 x int32_t)
    x1:
      type: buffer
      size_bytes: 1024
      permissions: read-only
      c_parameter: const int32_t b[256]
      description: Input polynomial (256 x int32_t)
*/

#include "../../../common.h"
#if defined(MLD_ARITH_BACKEND_AARCH64) &&                                      \
    (!defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API) || \
     defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST)) &&              \
    !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)

/*
 * WARNING: This file is auto-derived from the mldsa-native source file
 *   dev/aarch64_opt/src/mldsa_pointwise_montgomery_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
 */

.text
.balign 4
.global MLD_ASM_NAMESPACE(poly_pointwise_montgomery_aarch64_asm)
MLD_ASM_FN_SYMBOL(poly_pointwise_montgomery_aarch64_asm)

        .cfi_startproc
        mov w3, #0xe001             // =57345
        movk w3, #0x7f, lsl #16
        dup v0.4s, w3
        mov w3, #0x2001             // =8193
        movk w3, #0x380, lsl #16
        dup v1.4s, w3
        mov x3, #0x40               // =64

Lmld_poly_pointwise_montgomery_loop_start:
        ldr q16, [x0]
        ldr q17, [x0, #0x10]
        ldr q18, [x0, #0x20]
        ldr q19, [x0, #0x30]
        ldr q21, [x1, #0x10]
        ldr q22, [x1, #0x20]
        ldr q23, [x1, #0x30]
        ldr q20, [x1], #0x40
        smull v24.2d, v16.2s, v20.2s
        smull2 v25.2d, v16.4s, v20.4s
        smull v26.2d, v17.2s, v21.2s
        smull2 v27.2d, v17.4s, v21.4s
        smull v28.2d, v18.2s, v22.2s
        smull2 v29.2d, v18.4s, v22.4s
        smull v30.2d, v19.2s, v23.2s
        smull2 v31.2d, v19.4s, v23.4s
        uzp1 v16.4s, v24.4s, v25.4s
        mul v16.4s, v16.4s, v1.4s
        smlsl v24.2d, v16.2s, v0.2s
        smlsl2 v25.2d, v16.4s, v0.4s
        uzp2 v16.4s, v24.4s, v25.4s
        uzp1 v17.4s, v26.4s, v27.4s
        mul v17.4s, v17.4s, v1.4s
        smlsl v26.2d, v17.2s, v0.2s
        smlsl2 v27.2d, v17.4s, v0.4s
        uzp2 v17.4s, v26.4s, v27.4s
        uzp1 v18.4s, v28.4s, v29.4s
        mul v18.4s, v18.4s, v1.4s
        smlsl v28.2d, v18.2s, v0.2s
        smlsl2 v29.2d, v18.4s, v0.4s
        uzp2 v18.4s, v28.4s, v29.4s
        uzp1 v19.4s, v30.4s, v31.4s
        mul v19.4s, v19.4s, v1.4s
        smlsl v30.2d, v19.2s, v0.2s
        smlsl2 v31.2d, v19.4s, v0.4s
        uzp2 v19.4s, v30.4s, v31.4s
        str q17, [x0, #0x10]
        str q18, [x0, #0x20]
        str q19, [x0, #0x30]
        str q16, [x0], #0x40
        subs x3, x3, #0x4
        cbnz x3, Lmld_poly_pointwise_montgomery_loop_start
        ret
        .cfi_endproc

MLD_ASM_FN_SIZE(poly_pointwise_montgomery_aarch64_asm)

#endif /* MLD_ARITH_BACKEND_AARCH64 && (!MLD_CONFIG_NO_SIGN_API || \
          !MLD_CONFIG_NO_VERIFY_API || MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST) \
          && !MLD_CONFIG_MULTILEVEL_NO_SHARED */

#if defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif