Commit 9b015383 authored by Cheng Wang's avatar Cheng Wang
Browse files

[libc][Obvious] Reorder CMakelists alphabetically.

parent 7abd8f6c
Loading
Loading
Loading
Loading
+120 −120
Original line number Diff line number Diff line
@@ -9,88 +9,98 @@ add_header_library(
)

add_entrypoint_object(
  strcat
  memchr
  SRCS
    strcat.cpp
    memchr.cpp
  HDRS
    strcat.h
    memchr.h
  DEPENDS
    .strcpy
    .string_utils
)

add_entrypoint_object(
  strcpy
  memmove
  SRCS
    strcpy.cpp
    memmove.cpp
  HDRS
    strcpy.h
    memmove.h
  DEPENDS
    .memcpy
    .string_utils
    libc.src.__support.integer_operations
    libc.src.string.memcpy
)

add_entrypoint_object(
  strlen
  memrchr
  SRCS
    strlen.cpp
    memrchr.cpp
  HDRS
    strlen.h
    memrchr.h
)

add_entrypoint_object(
  strcat
  SRCS
    strcat.cpp
  HDRS
    strcat.h
  DEPENDS
    libc.include.string
    .strcpy
    .string_utils
)

add_entrypoint_object(
  strcmp
  strchr
  SRCS
    strcmp.cpp
    strchr.cpp
  HDRS
    strcmp.h
    strchr.h
)

add_entrypoint_object(
  strncmp
  strcmp
  SRCS
    strncmp.cpp
    strcmp.cpp
  HDRS
    strncmp.h
    strcmp.h
)

add_entrypoint_object(
  memchr
  strcpy
  SRCS
    memchr.cpp
    strcpy.cpp
  HDRS
    memchr.h
    strcpy.h
  DEPENDS
    .memcpy
    .string_utils
)

add_entrypoint_object(
  memmove
  strcspn
  SRCS
    memmove.cpp
    strcspn.cpp
  HDRS
    memmove.h
    strcspn.h
  DEPENDS
    libc.src.__support.integer_operations
    libc.src.string.memcpy
    .string_utils
)

add_entrypoint_object(
  strchr
  strlen
  SRCS
    strchr.cpp
    strlen.cpp
  HDRS
    strchr.h
    strlen.h
  DEPENDS
    libc.include.string
)

add_entrypoint_object(
  strstr
  strncmp
  SRCS
    strstr.cpp
    strncmp.cpp
  HDRS
    strstr.h
    strncmp.h
)

add_entrypoint_object(
@@ -112,11 +122,13 @@ add_entrypoint_object(
)

add_entrypoint_object(
  memrchr
  strpbrk
  SRCS
    memrchr.cpp
    strpbrk.cpp
  HDRS
    memrchr.h
    strpbrk.h
  DEPENDS
    .string_utils
)

add_entrypoint_object(
@@ -127,16 +139,6 @@ add_entrypoint_object(
    strrchr.h
)

add_entrypoint_object(
  strcspn
  SRCS
    strcspn.cpp
  HDRS
    strcspn.h
  DEPENDS
    .string_utils
)

add_entrypoint_object(
  strspn
  SRCS
@@ -148,13 +150,11 @@ add_entrypoint_object(
)

add_entrypoint_object(
  strpbrk
  strstr
  SRCS
    strpbrk.cpp
    strstr.cpp
  HDRS
    strpbrk.h
  DEPENDS
    .string_utils
    strstr.h
)

add_entrypoint_object(
@@ -202,70 +202,35 @@ function(add_implementation name impl_name)
endfunction()

# ------------------------------------------------------------------------------
# memcpy
# ------------------------------------------------------------------------------

function(add_memcpy memcpy_name)
  add_implementation(memcpy ${memcpy_name}
    SRCS ${MEMCPY_SRC}
    HDRS ${LIBC_SOURCE_DIR}/src/string/memcpy.h
    DEPENDS
      .memory_utils.memory_utils
      libc.include.string
    COMPILE_OPTIONS
      -fno-builtin-memcpy
    ${ARGN}
  )
endfunction()

if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
  set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/x86_64/memcpy.cpp)
  add_memcpy(memcpy_x86_64_opt_sse2   COMPILE_OPTIONS -march=k8             REQUIRE SSE2)
  add_memcpy(memcpy_x86_64_opt_sse4   COMPILE_OPTIONS -march=nehalem        REQUIRE SSE4_2)
  add_memcpy(memcpy_x86_64_opt_avx2   COMPILE_OPTIONS -march=haswell        REQUIRE AVX2)
  add_memcpy(memcpy_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
  add_memcpy(memcpy_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_memcpy(memcpy)
elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
  set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/aarch64/memcpy.cpp)
  # Disable tail merging as it leads to lower performance.
  # Note that '-mllvm' needs to be prefixed with 'SHELL:' to prevent CMake flag deduplication.
  add_memcpy(memcpy_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}
                                      COMPILE_OPTIONS "SHELL:-mllvm --tail-merge-threshold=0")
  add_memcpy(memcpy                   COMPILE_OPTIONS "SHELL:-mllvm --tail-merge-threshold=0")
else()
  set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/memcpy.cpp)
  add_memcpy(memcpy_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_memcpy(memcpy)
endif()

# ------------------------------------------------------------------------------
# memset
# bcmp
# ------------------------------------------------------------------------------

function(add_memset memset_name)
  add_implementation(memset ${memset_name}
    SRCS ${LIBC_SOURCE_DIR}/src/string/memset.cpp
    HDRS ${LIBC_SOURCE_DIR}/src/string/memset.h
function(add_bcmp bcmp_name)
  add_implementation(bcmp ${bcmp_name}
    SRCS ${LIBC_BCMP_SRC}
    HDRS ${LIBC_SOURCE_DIR}/src/string/bcmp.h
    DEPENDS
      .memory_utils.memory_utils
      libc.include.string
    COMPILE_OPTIONS
      -fno-builtin-memset
      -fno-builtin-memcmp
      -fno-builtin-bcmp
    ${ARGN}
  )
endfunction()

if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
  add_memset(memset_x86_64_opt_sse2   COMPILE_OPTIONS -march=k8             REQUIRE SSE2)
  add_memset(memset_x86_64_opt_sse4   COMPILE_OPTIONS -march=nehalem        REQUIRE SSE4_2)
  add_memset(memset_x86_64_opt_avx2   COMPILE_OPTIONS -march=haswell        REQUIRE AVX2)
  add_memset(memset_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
  add_memset(memset_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_memset(memset)
  set(LIBC_BCMP_SRC ${LIBC_SOURCE_DIR}/src/string/bcmp.cpp)
  add_bcmp(bcmp_x86_64_opt_sse2   COMPILE_OPTIONS -march=k8             REQUIRE SSE2)
  add_bcmp(bcmp_x86_64_opt_sse4   COMPILE_OPTIONS -march=nehalem        REQUIRE SSE4_2)
  add_bcmp(bcmp_x86_64_opt_avx2   COMPILE_OPTIONS -march=haswell        REQUIRE AVX2)
  add_bcmp(bcmp_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
  add_bcmp(bcmp_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_bcmp(bcmp)
else()
  add_memset(memset_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_memset(memset)
  set(LIBC_BCMP_SRC ${LIBC_SOURCE_DIR}/src/string/bcmp.cpp)
  add_bcmp(bcmp_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_bcmp(bcmp)
endif()

# ------------------------------------------------------------------------------
@@ -333,33 +298,68 @@ else()
endif()

# ------------------------------------------------------------------------------
# bcmp
# memcpy
# ------------------------------------------------------------------------------

function(add_bcmp bcmp_name)
  add_implementation(bcmp ${bcmp_name}
    SRCS ${LIBC_BCMP_SRC}
    HDRS ${LIBC_SOURCE_DIR}/src/string/bcmp.h
function(add_memcpy memcpy_name)
  add_implementation(memcpy ${memcpy_name}
    SRCS ${MEMCPY_SRC}
    HDRS ${LIBC_SOURCE_DIR}/src/string/memcpy.h
    DEPENDS
      .memory_utils.memory_utils
      libc.include.string
    COMPILE_OPTIONS
      -fno-builtin-memcmp
      -fno-builtin-bcmp
      -fno-builtin-memcpy
    ${ARGN}
  )
endfunction()

if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
  set(LIBC_BCMP_SRC ${LIBC_SOURCE_DIR}/src/string/bcmp.cpp)
  add_bcmp(bcmp_x86_64_opt_sse2   COMPILE_OPTIONS -march=k8             REQUIRE SSE2)
  add_bcmp(bcmp_x86_64_opt_sse4   COMPILE_OPTIONS -march=nehalem        REQUIRE SSE4_2)
  add_bcmp(bcmp_x86_64_opt_avx2   COMPILE_OPTIONS -march=haswell        REQUIRE AVX2)
  add_bcmp(bcmp_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
  add_bcmp(bcmp_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_bcmp(bcmp)
  set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/x86_64/memcpy.cpp)
  add_memcpy(memcpy_x86_64_opt_sse2   COMPILE_OPTIONS -march=k8             REQUIRE SSE2)
  add_memcpy(memcpy_x86_64_opt_sse4   COMPILE_OPTIONS -march=nehalem        REQUIRE SSE4_2)
  add_memcpy(memcpy_x86_64_opt_avx2   COMPILE_OPTIONS -march=haswell        REQUIRE AVX2)
  add_memcpy(memcpy_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
  add_memcpy(memcpy_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_memcpy(memcpy)
elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
  set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/aarch64/memcpy.cpp)
  # Disable tail merging as it leads to lower performance.
  # Note that '-mllvm' needs to be prefixed with 'SHELL:' to prevent CMake flag deduplication.
  add_memcpy(memcpy_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE}
                                      COMPILE_OPTIONS "SHELL:-mllvm --tail-merge-threshold=0")
  add_memcpy(memcpy                   COMPILE_OPTIONS "SHELL:-mllvm --tail-merge-threshold=0")
else()
  set(LIBC_BCMP_SRC ${LIBC_SOURCE_DIR}/src/string/bcmp.cpp)
  add_bcmp(bcmp_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_bcmp(bcmp)
  set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/memcpy.cpp)
  add_memcpy(memcpy_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_memcpy(memcpy)
endif()

# ------------------------------------------------------------------------------
# memset
# ------------------------------------------------------------------------------

function(add_memset memset_name)
  add_implementation(memset ${memset_name}
    SRCS ${LIBC_SOURCE_DIR}/src/string/memset.cpp
    HDRS ${LIBC_SOURCE_DIR}/src/string/memset.h
    DEPENDS
      .memory_utils.memory_utils
      libc.include.string
    COMPILE_OPTIONS
      -fno-builtin-memset
    ${ARGN}
  )
endfunction()

if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
  add_memset(memset_x86_64_opt_sse2   COMPILE_OPTIONS -march=k8             REQUIRE SSE2)
  add_memset(memset_x86_64_opt_sse4   COMPILE_OPTIONS -march=nehalem        REQUIRE SSE4_2)
  add_memset(memset_x86_64_opt_avx2   COMPILE_OPTIONS -march=haswell        REQUIRE AVX2)
  add_memset(memset_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
  add_memset(memset_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_memset(memset)
else()
  add_memset(memset_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
  add_memset(memset)
endif()
+40 −40
Original line number Diff line number Diff line
@@ -3,33 +3,43 @@ add_libc_testsuite(libc_string_unittests)
add_subdirectory(memory_utils)

add_libc_unittest(
  strcat_test
  memchr_test
  SUITE
    libc_string_unittests
  SRCS
    strcat_test.cpp
    memchr_test.cpp
  DEPENDS
    libc.src.string.strcat
    libc.src.string.memchr
)

add_libc_unittest(
  strcpy_test
  memrchr_test
  SUITE
    libc_string_unittests
  SRCS
    strcpy_test.cpp
    memrchr_test.cpp
  DEPENDS
    libc.src.string.strcpy
    libc.src.string.memrchr
)

add_libc_unittest(
  strlen_test
  strcat_test
  SUITE
    libc_string_unittests
  SRCS
    strlen_test.cpp
    strcat_test.cpp
  DEPENDS
    libc.src.string.strlen
    libc.src.string.strcat
)

add_libc_unittest(
  strchr_test
  SUITE
    libc_string_unittests
  SRCS
    strchr_test.cpp
  DEPENDS
    libc.src.string.strchr
)

add_libc_unittest(
@@ -43,43 +53,43 @@ add_libc_unittest(
)

add_libc_unittest(
  strncmp_test
  strcpy_test
  SUITE
    libc_string_unittests
  SRCS
    strncmp_test.cpp
    strcpy_test.cpp
  DEPENDS
    libc.src.string.strncmp
    libc.src.string.strcpy
)

add_libc_unittest(
  memchr_test
  strcspn_test
  SUITE
    libc_string_unittests
  SRCS
    memchr_test.cpp
    strcspn_test.cpp
  DEPENDS
    libc.src.string.memchr
    libc.src.string.strcspn
)

add_libc_unittest(
  strchr_test
  strlen_test
  SUITE
    libc_string_unittests
  SRCS
    strchr_test.cpp
    strlen_test.cpp
  DEPENDS
    libc.src.string.strchr
    libc.src.string.strlen
)

add_libc_unittest(
  strstr_test
  strncmp_test
  SUITE
    libc_string_unittests
  SRCS
    strstr_test.cpp
    strncmp_test.cpp
  DEPENDS
    libc.src.string.strstr
    libc.src.string.strncmp
)

add_libc_unittest(
@@ -103,13 +113,13 @@ add_libc_unittest(
)

add_libc_unittest(
  memrchr_test
  strpbrk_test
  SUITE
    libc_string_unittests
  SRCS
    memrchr_test.cpp
    strpbrk_test.cpp
  DEPENDS
    libc.src.string.memrchr
    libc.src.string.strpbrk
)

add_libc_unittest(
@@ -122,16 +132,6 @@ add_libc_unittest(
    libc.src.string.strrchr
)

add_libc_unittest(
  strcspn_test
  SUITE
    libc_string_unittests
  SRCS
    strcspn_test.cpp
  DEPENDS
    libc.src.string.strcspn
)

add_libc_unittest(
  strspn_test
  SUITE
@@ -143,13 +143,13 @@ add_libc_unittest(
)

add_libc_unittest(
  strpbrk_test
  strstr_test
  SUITE
    libc_string_unittests
  SRCS
    strpbrk_test.cpp
    strstr_test.cpp
  DEPENDS
    libc.src.string.strpbrk
    libc.src.string.strstr
)

add_libc_unittest(
@@ -195,9 +195,9 @@ function(add_libc_multi_impl_test name)
  endforeach()
endfunction()

add_libc_multi_impl_test(memcpy SRCS memcpy_test.cpp)
add_libc_multi_impl_test(memset SRCS memset_test.cpp)
add_libc_multi_impl_test(bcmp SRCS bcmp_test.cpp)
add_libc_multi_impl_test(bzero SRCS bzero_test.cpp)
add_libc_multi_impl_test(memcmp SRCS memcmp_test.cpp)
add_libc_multi_impl_test(bcmp SRCS bcmp_test.cpp)
add_libc_multi_impl_test(memcpy SRCS memcpy_test.cpp)
add_libc_multi_impl_test(memmove SRCS memmove_test.cpp)
add_libc_multi_impl_test(memset SRCS memset_test.cpp)