blob: 24df6f3f8288293c3531a8c349a120dd0a37ecd7 [file] [log] [blame]
Alex Van Dammed5554032023-08-01 15:39:38 -07001// Copyright 2023 Google LLC
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#include "crt/kelvin.h"
6
7namespace kelvin::opt {
8
9void *memcpy(void *dst, const void *src, size_t n) {
10 const uint8_t *s = reinterpret_cast<const uint8_t *>(src);
11 uint8_t *d = reinterpret_cast<uint8_t *>(dst);
12 int vl;
13 while (true) {
14 if (n <= 0) break;
15 getvl_b_x_m(vl, n);
16 n -= vl;
17 vld_b_lp_xx_m(v0, s, vl);
18 vst_b_lp_xx_m(v0, d, vl);
19
20 if (n <= 0) break;
21 getvl_b_x_m(vl, n);
22 n -= vl;
23 vld_b_lp_xx_m(v4, s, vl);
24 vst_b_lp_xx_m(v4, d, vl);
25 }
26 return dst;
27}
28
29} // namespace kelvin::opt