llvm-project/libc/cmake/modules/cpu_features/check_cpu_features.cpp.in
Guillaume Chatelet 04a309dd0b [libc] Adding memcpy implementation for x86_64
Summary:
The patch is not ready yet and is here to discuss a few options:
 - How do we customize the implementation? (i.e. how to define `kRepMovsBSize`),
 - How do we specify custom compilation flags? (We'd need `-fno-builtin-memcpy` to be passed in),
 - How do we build? We may want to test in debug but build the libc with `-march=native` for instance,
 - Clang has a brand new builtin `__builtin_memcpy_inline` which makes the implementation easy and efficient, but:
   - If we compile with `gcc` or `msvc` we can't use it, resorting on less efficient code generation,
   - With gcc we can use `__builtin_memcpy` but then we'd need a postprocess step to check that the final assembly do not contain call to `memcpy` (unlikely but allowed),
   - For msvc we'd need to resort on the compiler optimization passes.

Reviewers: sivachandra, abrachet

Subscribers: mgorny, MaskRay, tschuett, libc-commits, courbet

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D74397
2020-03-18 17:43:21 +01:00

30 lines
777 B
C++

#include <cstdio>
#include <cstdlib>
// This file is instantiated by CMake.
// DEFINITIONS below is replaced with a set of lines like so:
// #ifdef __SSE2__
// "SSE2",
// #endif
//
// This allows for introspection of compiler definitions.
// The output of the program is a single line of semi colon separated feature
// names.
// MSVC is using a different set of preprocessor definitions for
// SSE and SSE2, see _M_IX86_FP in
// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
int main(int, char **) {
const char *strings[] = {
@DEFINITIONS@
};
const size_t size = sizeof(strings) / sizeof(strings[0]);
for (size_t i = 0; i < size; ++i) {
if (i)
putchar(';');
fputs(strings[i], stdout);
}
return EXIT_SUCCESS;
}