Add framework to let make automatically pick optimized asm implementations over generic C ones to firmware.
Example: for a file asm/foo.c, make will look for asm/arm/foo.[cS] and compile it if found. If not found it'll fall back to asm/foo.c. Also introduce new ARCH make variable. This is automatically detected by configure. It is distinct from CPU since CPU defines the dir used for the target tree (i.e. firmware/target/X, so it can be "hosted"). ARCH really has the target isa and can be x86 for sims/raaa too. Change-Id: I18e5d2b7b7bbc2ad2be551a74a0fcae5ffbcbf8b
This commit is contained in:
parent
3c17f28eca
commit
8e8e978de6
4 changed files with 63 additions and 2 deletions
1
firmware/asm/SOURCES
Normal file
1
firmware/asm/SOURCES
Normal file
|
@ -0,0 +1 @@
|
|||
|
27
firmware/asm/asm.make
Normal file
27
firmware/asm/asm.make
Normal file
|
@ -0,0 +1,27 @@
|
|||
# __________ __ ___.
|
||||
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
# \/ \/ \/ \/ \/
|
||||
# $Id$
|
||||
#
|
||||
|
||||
# Collect dummy C files in firmware/asm
|
||||
ASM_DUMMY_SRC := $(notdir $(call preprocess, $(FIRMDIR)/asm/SOURCES))
|
||||
|
||||
# Get the corresponding real source files under firmware/asm/$ARCH (C or ASM)
|
||||
ASM_C_SRC := $(addprefix $(FIRMDIR)/asm/$(ARCH)/,$(ASM_DUMMY_SRC))
|
||||
ASM_S_SRC := $(ASM_C_SRC:.c=.S)
|
||||
|
||||
# ASM_SRC now contains only files that exist under $ARCH
|
||||
ASM_SRC := $(wildcard $(ASM_C_SRC))
|
||||
ASM_SRC += $(wildcard $(ASM_S_SRC))
|
||||
|
||||
# GEN_SRC now contains a .c for each file in ASM_DUMMY_SRC that's not in ASM_SRC
|
||||
# I.e. fallback to a generic C source if no correspinding file in $ARCH is found
|
||||
GEN_SRC := $(filter-out $(notdir $(ASM_SRC:.S=.c)),$(ASM_DUMMY_SRC))
|
||||
GEN_SRC := $(addprefix $(FIRMDIR)/asm/,$(GEN_SRC))
|
||||
|
||||
FIRMLIB_SRC += $(ASM_SRC)
|
||||
FIRMLIB_SRC += $(GEN_SRC)
|
|
@ -12,6 +12,8 @@ ifndef APP_TYPE
|
|||
INCLUDES += -I$(FIRMDIR)/libc/include
|
||||
endif
|
||||
|
||||
include $(FIRMDIR)/asm/asm.make
|
||||
|
||||
FIRMLIB_SRC += $(call preprocess, $(FIRMDIR)/SOURCES)
|
||||
FIRMLIB_OBJ := $(call c2obj, $(FIRMLIB_SRC))
|
||||
ifeq (,$(findstring -DARCHOS_PLAYER,$(TARGET)))
|
||||
|
|
35
tools/configure
vendored
35
tools/configure
vendored
|
@ -49,6 +49,7 @@ input() {
|
|||
prefixtools () {
|
||||
prefix="$1"
|
||||
CC=${prefix}gcc
|
||||
CPP=${prefix}cpp
|
||||
WINDRES=${prefix}windres
|
||||
DLLTOOL=${prefix}dlltool
|
||||
DLLWRAP=${prefix}dllwrap
|
||||
|
@ -671,6 +672,7 @@ ypr0cc () {
|
|||
endian="little"
|
||||
thread_support="HAVE_SIGALTSTACK_THREADS"
|
||||
app_type="ypr0"
|
||||
arch="unknown"
|
||||
|
||||
# Include path
|
||||
GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -U_FORTIFY_SOURCE -D_REENTRANT"
|
||||
|
@ -3639,6 +3641,7 @@ fi
|
|||
HOSTCC=`findtool gcc --lit`
|
||||
HOSTAR=`findtool ar --lit`
|
||||
CC=`findtool ${CC} --lit`
|
||||
CPP=`findtool ${CPP} --lit`
|
||||
LD=`findtool ${AR} --lit`
|
||||
AR=`findtool ${AR} --lit`
|
||||
AS=`findtool ${AS} --lit`
|
||||
|
@ -3648,6 +3651,32 @@ DLLTOOL=`findtool ${DLLTOOL} --lit`
|
|||
DLLWRAP=`findtool ${DLLWRAP} --lit`
|
||||
RANLIB=`findtool ${RANLIB} --lit`
|
||||
|
||||
|
||||
if [ -z "$arch" ]; then
|
||||
cpp_defines=$(echo "" | $CPP -dD)
|
||||
if [ -n "$(echo $cpp_defines | grep -w __sh__)" ]; then
|
||||
arch="sh"
|
||||
elif [ -n "$(echo $cpp_defines | grep -w __m68k__)" ]; then
|
||||
arch="m68k"
|
||||
elif [ -n "$(echo $cpp_defines | grep -w __arm__)" ]; then
|
||||
arch="arm"
|
||||
elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then
|
||||
arch="mips"
|
||||
elif [ -n "$(echo $cpp_defines | grep -w _X86_)" ]; then
|
||||
arch="x86"
|
||||
elif [ -n "$(echo $cpp_defines | grep -w __x86_64__)" ]; then
|
||||
arch="amd64"
|
||||
else
|
||||
arch="unknown"
|
||||
echo "Warning: Could not determine target arch"
|
||||
fi
|
||||
if [ "$arch" != "unknown" ]; then
|
||||
echo "Automatically selected arch: $arch"
|
||||
fi;
|
||||
else
|
||||
echo "Manually selected arch: $arch"
|
||||
fi
|
||||
|
||||
if test -n "$ccache"; then
|
||||
CC="$ccache $CC"
|
||||
fi
|
||||
|
@ -3718,11 +3747,11 @@ EOF
|
|||
if test -n "$t_cpu"; then
|
||||
TARGET_INC="-I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer/$t_model"
|
||||
|
||||
if [ "$t_cpu" = "hosted" ] && [ "$t_manufacturer" = "maemo" ]; then
|
||||
if [ "$application" = "yes" ] && [ "$t_manufacturer" = "maemo" ]; then
|
||||
# Maemo needs the SDL port, too
|
||||
TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app"
|
||||
TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl"
|
||||
elif [ "$t_cpu" = "hosted" ] && [ "$t_manufacturer" = "pandora" ]; then
|
||||
elif [ "$application" = "yes" ] && [ "$t_manufacturer" = "pandora" ]; then
|
||||
# Pandora needs the SDL port, too
|
||||
TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app"
|
||||
TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl"
|
||||
|
@ -3780,6 +3809,7 @@ export ARCHOSROM=${archosrom}
|
|||
export FLASHFILE=${flash}
|
||||
export TARGET_ID=${target_id}
|
||||
export TARGET=-D${target}
|
||||
export ARCH=${arch}
|
||||
export CPU=${t_cpu}
|
||||
export MANUFACTURER=${t_manufacturer}
|
||||
export OBJDIR=${pwd}
|
||||
|
@ -3801,6 +3831,7 @@ export EXTRA_DEFINES=${extradefines}
|
|||
export HOSTCC=${HOSTCC}
|
||||
export HOSTAR=${HOSTAR}
|
||||
export CC=${CC}
|
||||
export CPP=${CPP}
|
||||
export LD=${LD}
|
||||
export AR=${AR}
|
||||
export AS=${AS}
|
||||
|
|
Loading…
Reference in a new issue