Skip to content

Commit

Permalink
armv8-r/libc: optimize libc string apis with asm
Browse files Browse the repository at this point in the history
Optimize libc string apis(memcpy/memset/memmove/memchr/strcmp/strlen)
with arm32 assembly instruction including vfp and neon.
Add arch releated elf parsing

Signed-off-by: Jinliang Li <[email protected]>
  • Loading branch information
jinliangli authored and xiaoxiang781216 committed Nov 26, 2024
1 parent f5136b2 commit f3213ef
Show file tree
Hide file tree
Showing 14 changed files with 2,601 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/libc/machine/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ elseif(CONFIG_ARCH_ARMV7M) # All ARMv7-M
add_subdirectory(armv7-m)
elseif(CONFIG_ARCH_ARMV8M) # All ARMv8-M
add_subdirectory(armv8-m)
elseif(CONFIG_ARCH_ARMV8R) # All ARMv8-R
add_subdirectory(armv8-r)
endif()

if(NOT CONFIG_LIBSUPCXX_TOOLCHAIN)
Expand Down
4 changes: 4 additions & 0 deletions libs/libc/machine/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ endif
if ARCH_ARMV8M
source "libs/libc/machine/arm/armv8-m/Kconfig"
endif

if ARCH_ARMV8R
source "libs/libc/machine/arm/armv8-r/Kconfig"
endif
2 changes: 2 additions & 0 deletions libs/libc/machine/arm/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ else ifeq ($(CONFIG_ARCH_ARMV7M),y) # All ARMv7-M
include $(TOPDIR)/libs/libc/machine/arm/armv7-m/Make.defs
else ifeq ($(CONFIG_ARCH_ARMV8M),y) # All ARMv8-M
include $(TOPDIR)/libs/libc/machine/arm/armv8-m/Make.defs
else ifeq ($(CONFIG_ARCH_ARMV8R),y) # All ARMv8-R
include $(TOPDIR)/libs/libc/machine/arm/armv8-r/Make.defs
endif

ifneq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
Expand Down
55 changes: 55 additions & 0 deletions libs/libc/machine/arm/armv8-r/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# ##############################################################################
# libs/libc/machine/arm/armv8-r/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################

if(CONFIG_ARCH_TOOLCHAIN_GNU)
set(ARCH_TOOLCHAIN_DIR gnu)
endif()

if(CONFIG_ARMV8R_MEMCHR)
list(APPEND SRCS ${ARCH_TOOLCHAIN_DIR}/arch_memchr.S)
endif()

if(CONFIG_ARMV8R_MEMCPY)
list(APPEND SRCS ${ARCH_TOOLCHAIN_DIR}/arch_memcpy.S)
endif()

if(CONFIG_ARMV8R_MEMMOVE)
list(APPEND SRCS ${ARCH_TOOLCHAIN_DIR}/arch_memmove.S)
endif()

if(CONFIG_ARMV8R_MEMSET)
list(APPEND SRCS ${ARCH_TOOLCHAIN_DIR}/arch_memset.S)
endif()

if(CONFIG_ARMV8R_STRCMP)
list(APPEND SRCS ${ARCH_TOOLCHAIN_DIR}/arch_strcmp.S)
endif()

if(CONFIG_ARMV8R_STRLEN)
list(APPEND SRCS ${ARCH_TOOLCHAIN_DIR}/arch_strlen.S)
endif()

if(CONFIG_LIBC_ARCH_ELF)
list(APPEND SRCS arch_elf.c)
endif()

target_sources(c PRIVATE ${SRCS})
63 changes: 63 additions & 0 deletions libs/libc/machine/arm/armv8-r/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config ARMV8R_STRING_FUNCTION
bool "Enable optimized ARMV8R specific string function"
default n
depends on ARCH_TOOLCHAIN_GNU
select ARMV8R_MEMCHR
select ARMV8R_MEMCPY
select ARMV8R_MEMMOVE
select ARMV8R_MEMSET
select ARMV8R_STRCMP
select ARMV8R_STRLEN

config ARMV8R_MEMCHR
bool "Enable optimized memchr() for ARMv8-R"
default n
select LIBC_ARCH_MEMCHR
depends on ARCH_TOOLCHAIN_GNU
---help---
Enable optimized ARMv8-R specific memchr() library function

config ARMV8R_MEMCPY
bool "Enable optimized memcpy() for ARMv8-R"
select LIBC_ARCH_MEMCPY
depends on ARCH_TOOLCHAIN_GNU
---help---
Enable optimized ARMv8-R specific memcpy() library function

config ARMV8R_MEMMOVE
bool "Enable optimized memmove() for ARMv8-R"
default n
select LIBC_ARCH_MEMMOVE
depends on ARCH_TOOLCHAIN_GNU
---help---
Enable optimized ARMv8-R specific memmove() library function

config ARMV8R_MEMSET
bool "Enable optimized memset() for ARMv8-R"
default n
select LIBC_ARCH_MEMSET
depends on ARCH_TOOLCHAIN_GNU
depends on ARM_NEON
---help---
Enable optimized ARMv8-R specific memset() library function

config ARMV8R_STRCMP
bool "Enable optimized strcmp() for ARMv8-R"
default n
select LIBC_ARCH_STRCMP
depends on ARCH_TOOLCHAIN_GNU
---help---
Enable optimized ARMv8-R specific strcmp() library function

config ARMV8R_STRLEN
bool "Enable optimized strlen() for ARMv8-R"
default n
select LIBC_ARCH_STRLEN
depends on ARCH_TOOLCHAIN_GNU
---help---
Enable optimized ARMv8-R specific strlen() library function
57 changes: 57 additions & 0 deletions libs/libc/machine/arm/armv8-r/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
############################################################################
# libs/libc/machine/arm/armv8-r/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

ifeq ($(CONFIG_ARMV8R_MEMCHR),y)
ASRCS += arch_memchr.S
endif

ifeq ($(CONFIG_ARMV8R_MEMCPY),y)
ASRCS += arch_memcpy.S
endif

ifeq ($(CONFIG_ARMV8R_MEMMOVE),y)
ASRCS += arch_memmove.S
endif

ifeq ($(CONFIG_ARMV8R_MEMSET),y)
ASRCS += arch_memset.S
endif

ifeq ($(CONFIG_ARMV8R_STRCMP),y)
ASRCS += arch_strcmp.S
endif

ifeq ($(CONFIG_ARMV8R_STRLEN),y)
ASRCS += arch_strlen.S
endif

ifeq ($(CONFIG_LIBC_ARCH_ELF),y)
CSRCS += arch_elf.c
endif

ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y)
DEPPATH += --dep-path machine/arm/armv8-r/gnu
VPATH += :machine/arm/armv8-r/gnu
endif

DEPPATH += --dep-path machine/arm/armv8-r
VPATH += :machine/arm/armv8-r
Loading

0 comments on commit f3213ef

Please sign in to comment.