1/* SPDX-License-Identifier: GPL-2.0 */ 2/* Copyright (C) 2024 Rivos Inc. */ 3 4#include <linux/args.h> 5#include <linux/linkage.h> 6#include <asm/asm.h> 7 8 .text 9 10#define WORD_EEW 32 11 12#define WORD_SEW CONCATENATE(e, WORD_EEW) 13#define VEC_L CONCATENATE(vle, WORD_EEW).v 14#define VEC_S CONCATENATE(vle, WORD_EEW).v 15 16/* void __riscv_copy_vec_words_unaligned(void *, const void *, size_t) */ 17/* Performs a memcpy without aligning buffers, using word loads and stores. */ 18/* Note: The size is truncated to a multiple of WORD_EEW */ 19SYM_FUNC_START(__riscv_copy_vec_words_unaligned) 20 andi a4, a2, ~(WORD_EEW-1) 21 beqz a4, 2f 22 add a3, a1, a4 23 .option push 24 .option arch, +zve32x 251: 26 vsetivli t0, 8, WORD_SEW, m8, ta, ma 27 VEC_L v0, (a1) 28 VEC_S v0, (a0) 29 addi a0, a0, WORD_EEW 30 addi a1, a1, WORD_EEW 31 bltu a1, a3, 1b 32 332: 34 .option pop 35 ret 36SYM_FUNC_END(__riscv_copy_vec_words_unaligned) 37 38/* void __riscv_copy_vec_bytes_unaligned(void *, const void *, size_t) */ 39/* Performs a memcpy without aligning buffers, using only byte accesses. */ 40/* Note: The size is truncated to a multiple of 8 */ 41SYM_FUNC_START(__riscv_copy_vec_bytes_unaligned) 42 andi a4, a2, ~(8-1) 43 beqz a4, 2f 44 add a3, a1, a4 45 .option push 46 .option arch, +zve32x 471: 48 vsetivli t0, 8, e8, m8, ta, ma 49 vle8.v v0, (a1) 50 vse8.v v0, (a0) 51 addi a0, a0, 8 52 addi a1, a1, 8 53 bltu a1, a3, 1b 54 552: 56 .option pop 57 ret 58SYM_FUNC_END(__riscv_copy_vec_bytes_unaligned) 59