forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc] Change the GPU to use builtin memory functions (llvm#68003)
Summary: The GPU build is special in the sense that we always know that up-to-date `clang` is always going to be the compiler. This allows us to rely directly on builtins, which allow us to push a lot of this complexity into the backend. Backend implementations are favored on the GPU because it allows us to do a lot more target specific optimizations. This patch changes over the common memory functions to use builtin versions when building for AMDGPU or NVPTX.
- Loading branch information
Showing
4 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//===-- Trivial builtin implementations ----------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H | ||
#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H | ||
|
||
#include "src/__support/macros/attributes.h" // LIBC_INLINE | ||
#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN | ||
#include "src/string/memory_utils/utils.h" // Ptr, CPtr | ||
|
||
#include <stddef.h> // size_t | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
static_assert(LIBC_HAS_BUILTIN(__builtin_memcpy), "Builtin not defined"); | ||
static_assert(LIBC_HAS_BUILTIN(__builtin_memset), "Builtin not defined"); | ||
static_assert(LIBC_HAS_BUILTIN(__builtin_memmove), "Builtin not defined"); | ||
|
||
[[maybe_unused]] LIBC_INLINE void | ||
inline_memcpy_builtin(Ptr dst, CPtr src, size_t count, size_t offset = 0) { | ||
__builtin_memcpy(dst + offset, src + offset, count); | ||
} | ||
|
||
[[maybe_unused]] LIBC_INLINE void inline_memmove_builtin(Ptr dst, CPtr src, | ||
size_t count) { | ||
__builtin_memmove(dst, src, count); | ||
} | ||
|
||
[[maybe_unused]] LIBC_INLINE static void | ||
inline_memset_builtin(Ptr dst, uint8_t value, size_t count, size_t offset = 0) { | ||
__builtin_memset(dst + offset, value, count); | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_GENERIC_BUILTIN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters