[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-02-11 20:37:02 +08:00
|
|
|
#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@
|
2021-01-27 17:18:58 +08:00
|
|
|
// If DEFINITIONS turns out to be empty, we don't want to list
|
|
|
|
// an empty array. So, we add an end of list marker.
|
|
|
|
"<end_of_feature_list>"
|
[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-02-11 20:37:02 +08:00
|
|
|
};
|
|
|
|
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;
|
|
|
|
}
|