37 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// This file contains basic implementations of Scalable Matrix Extension (SME)11/// compatible memset and memchr functions to be used when their assembly-12/// optimized counterparts can't.13///14//===----------------------------------------------------------------------===//15 16#include <stddef.h>17 18extern void *__arm_sc_memset(void *dest, int c,19 size_t n) __arm_streaming_compatible {20 unsigned char *destp = (unsigned char *)dest;21 unsigned char c8 = (unsigned char)c;22 for (size_t i = 0; i < n; ++i)23 destp[i] = c8;24 25 return dest;26}27 28extern const void *__arm_sc_memchr(const void *src, int c,29 size_t n) __arm_streaming_compatible {30 const unsigned char *srcp = (const unsigned char *)src;31 unsigned char c8 = (unsigned char)c;32 for (size_t i = 0; i < n; ++i)33 if (srcp[i] == c8)34 return &srcp[i];35 36 return NULL;37}