...

Text file src/crypto/internal/fips140/subtle/xor_loong64.s

Documentation: crypto/internal/fips140/subtle

     1// Copyright 2024 The Go Authors. All rights reserved.
     2// Use of this source code is governed by a BSD-style
     3// license that can be found in the LICENSE file.
     4
     5//go:build !purego
     6
     7#include "textflag.h"
     8
     9// func xorBytes(dst, a, b *byte, n int)
    10TEXT ·xorBytes(SB), NOSPLIT, $0
    11	MOVV	dst+0(FP), R4
    12	MOVV	a+8(FP), R5
    13	MOVV	b+16(FP), R6
    14	MOVV	n+24(FP), R7
    15
    16	MOVV	$64, R9
    17	BGEU	R7, R9, loop64	// n >= 64
    18tail:
    19	SRLV	$1, R9
    20	BGEU	R7, R9, xor_32	// n >= 32 && n < 64
    21	SRLV	$1, R9
    22	BGEU	R7, R9, xor_16	// n >= 16 && n < 32
    23	SRLV	$1, R9
    24	BGEU	R7, R9, xor_8	// n >= 8 && n < 16
    25	SRLV	$1, R9
    26	BGEU	R7, R9, xor_4	// n >= 4 && n < 8
    27	SRLV	$1, R9
    28	BGEU	R7, R9, xor_2	// n >= 2 && n < 4
    29	SRLV	$1, R9
    30	BGEU	R7, R9, xor_1	// n = 1
    31
    32loop64:
    33	MOVV	(R5), R10
    34	MOVV	8(R5), R11
    35	MOVV	16(R5), R12
    36	MOVV	24(R5), R13
    37	MOVV	(R6), R14
    38	MOVV	8(R6), R15
    39	MOVV	16(R6), R16
    40	MOVV	24(R6), R17
    41	XOR	R10, R14
    42	XOR	R11, R15
    43	XOR	R12, R16
    44	XOR	R13, R17
    45	MOVV	R14, (R4)
    46	MOVV	R15, 8(R4)
    47	MOVV	R16, 16(R4)
    48	MOVV	R17, 24(R4)
    49	MOVV	32(R5), R10
    50	MOVV	40(R5), R11
    51	MOVV	48(R5), R12
    52	MOVV	56(R5), R13
    53	MOVV	32(R6), R14
    54	MOVV	40(R6), R15
    55	MOVV	48(R6), R16
    56	MOVV	56(R6), R17
    57	XOR	R10, R14
    58	XOR	R11, R15
    59	XOR	R12, R16
    60	XOR	R13, R17
    61	MOVV	R14, 32(R4)
    62	MOVV	R15, 40(R4)
    63	MOVV	R16, 48(R4)
    64	MOVV	R17, 56(R4)
    65	ADDV	$64, R5
    66	ADDV	$64, R6
    67	ADDV	$64, R4
    68	SUBV	$64, R7
    69	// 64 in R9
    70	BGEU	R7, R9, loop64
    71	BEQ	R7, R0, end
    72
    73xor_32_check:
    74	SRLV	$1, R9
    75	BLT	R7, R9, xor_16_check
    76xor_32:
    77	MOVV	(R5), R10
    78	MOVV	8(R5), R11
    79	MOVV	16(R5), R12
    80	MOVV	24(R5), R13
    81	MOVV	(R6), R14
    82	MOVV	8(R6), R15
    83	MOVV	16(R6), R16
    84	MOVV	24(R6), R17
    85	XOR	R10, R14
    86	XOR	R11, R15
    87	XOR	R12, R16
    88	XOR	R13, R17
    89	MOVV	R14, (R4)
    90	MOVV	R15, 8(R4)
    91	MOVV	R16, 16(R4)
    92	MOVV	R17, 24(R4)
    93	ADDV	$32, R5
    94	ADDV	$32, R6
    95	ADDV	$32, R4
    96	SUBV	$32, R7
    97	BEQ	R7, R0, end
    98
    99xor_16_check:
   100	SRLV	$1, R9
   101	BLT	R7, R9, xor_8_check
   102xor_16:
   103	MOVV	(R5), R10
   104	MOVV	8(R5), R11
   105	MOVV	(R6), R12
   106	MOVV	8(R6), R13
   107	XOR	R10, R12
   108	XOR	R11, R13
   109	MOVV	R12, (R4)
   110	MOVV	R13, 8(R4)
   111	ADDV	$16, R5
   112	ADDV	$16, R6
   113	ADDV	$16, R4
   114	SUBV	$16, R7
   115	BEQ	R7, R0, end
   116
   117xor_8_check:
   118	SRLV	$1, R9
   119	BLT	R7, R9, xor_4_check
   120xor_8:
   121	MOVV	(R5), R10
   122	MOVV	(R6), R11
   123	XOR	R10, R11
   124	MOVV	R11, (R4)
   125	ADDV	$8, R5
   126	ADDV	$8, R6
   127	ADDV	$8, R4
   128	SUBV	$8, R7
   129	BEQ	R7, R0, end
   130
   131xor_4_check:
   132	SRLV	$1, R9
   133	BLT	R7, R9, xor_2_check
   134xor_4:
   135	MOVW	(R5), R10
   136	MOVW	(R6), R11
   137	XOR	R10, R11
   138	MOVW	R11, (R4)
   139	ADDV	$4, R5
   140	ADDV	$4, R6
   141	ADDV	$4, R4
   142	SUBV	$4, R7
   143	BEQ	R7, R0, end
   144
   145xor_2_check:
   146	SRLV	$1, R9
   147	BLT	R7, R9, xor_1
   148xor_2:
   149	MOVH	(R5), R10
   150	MOVH	(R6), R11
   151	XOR	R10, R11
   152	MOVH	R11, (R4)
   153	ADDV	$2, R5
   154	ADDV	$2, R6
   155	ADDV	$2, R4
   156	SUBV	$2, R7
   157	BEQ	R7, R0, end
   158
   159xor_1:
   160	MOVB	(R5), R10
   161	MOVB	(R6), R11
   162	XOR	R10, R11
   163	MOVB	R11, (R4)
   164
   165end:
   166	RET

View as plain text