Add new asmdefs mechanism for exporting information only available to the C compiler for use in asm files, and use it in arm jpeg idct. See apps/apps.make, apps/core_asmdefs.c, and apps/recorder/jpeg_idct_arm.S for details.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21831 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andrew Mahone 2009-07-13 00:40:35 +00:00
parent 36eeecbe9a
commit 668a769ca4
6 changed files with 87 additions and 152 deletions

View file

@ -24,3 +24,5 @@ features $(BUILDDIR)/apps/features $(BUILDDIR)/apps/genlang-features: $(APPSDIR)
grep -v "^\#" | grep -v "^$$" > $(BUILDDIR)/apps/features; \
for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
echo "$$feat" >$(BUILDDIR)/apps/genlang-features
ASMDEFS_SRC += $(APPSDIR)/core_asmdefs.c

17
apps/core_asmdefs.c Normal file
View file

@ -0,0 +1,17 @@
#include <config.h>
#include <bmp.h>
/* To export a value for use in assembly files, define an int or unsigned here
* named AD_<name> and include apps/core_asmdefs.h in the assembly file.
* Identifiers without the AD_ prefix will be ignored, and can be used to
* create instances of structs for finding offsets to individual members.
*/
/* Size of a pixel with 8-bit components. */
const int AD_pix8_size =
#ifdef HAVE_LCD_COLOR
sizeof(struct uint8_rgb);
#else
1;
#endif

View file

@ -22,6 +22,7 @@
*
****************************************************************************/
#include "config.h"
#include "apps/core_asmdefs.h"
.section .text
.align 2
@ -130,13 +131,8 @@ jpeg_idct2h:
mvnhi r5, r5, asr #31
cmp r4, #255
mvnhi r4, r4, asr #31
#ifdef HAVE_LCD_COLOR
strb r5, [r1]
strb r4, [r1, #4]
#else
strb r5, [r1]
strb r4, [r1, #1]
#endif
strb r4, [r1, #pix8_size]
add r0, r0, #16
add r1, r1, r3
cmp r0, r2
@ -152,13 +148,8 @@ jpeg_idct2h:
usat r4, #8, r12, asr #21
sxth r12, r12
usat r12, #8, r12, asr #5
#ifdef HAVE_LCD_COLOR
strb r4, [r1]
strb r12, [r1, #4]
#else
strb r4, [r1]
strb r12, [r1, #1]
#endif
strb r12, [r1, #pix8_size]
add r0, r0, #16
add r1, r1, r3
cmp r0, r2
@ -325,17 +316,10 @@ jpeg_idct4h:
mvnhi r4, r4, asr #31
cmp r5, #255
mvnhi r5, r5, asr #31
#ifdef HAVE_LCD_COLOR
strb r9, [r1]
strb r8, [r1, #4]
strb r4, [r1, #8]
strb r5, [r1, #12]
#else
strb r9, [r1]
strb r8, [r1, #1]
strb r4, [r1, #2]
strb r5, [r1, #3]
#endif
strb r8, [r1, #pix8_size]
strb r4, [r1, #2*pix8_size]
strb r5, [r1, #3*pix8_size]
add r0, r0, #16
add r1, r1, r3
cmp r0, r2
@ -372,17 +356,10 @@ jpeg_idct4h:
mvnhi r12, r12, asr #31
cmp r9, #255
mvnhi r9, r9, asr #31
#ifdef HAVE_LCD_COLOR
strb r6, [r1]
strb r14, [r1, #4]
strb r12, [r1, #8]
strb r9, [r1, #12]
#else
strb r6, [r1]
strb r14, [r1, #1]
strb r12, [r1, #2]
strb r9, [r1, #3]
#endif
strb r14, [r1, #pix8_size]
strb r12, [r1, #2*pix8_size]
strb r9, [r1, #3*pix8_size]
add r0, r0, #16
add r1, r1, r3
cmp r0, r2
@ -410,17 +387,10 @@ jpeg_idct4h:
usat r6, #8, r6, asr #18
usat r12, #8, r12, asr #18
usat r14, #8, r14, asr #18
#ifdef HAVE_LCD_COLOR
strb r8, [r1]
strb r6, [r1, #12]
strb r12, [r1, #4]
strb r14, [r1, #8]
#else
strb r8, [r1]
strb r6, [r1, #3]
strb r12, [r1, #1]
strb r14, [r1, #2]
#endif
strb r6, [r1, #3*pix8_size]
strb r12, [r1, #pix8_size]
strb r14, [r1, #2*pix8_size]
add r0, r0, #16
add r1, r1, r3
cmp r0, r2
@ -645,25 +615,14 @@ jpeg_idct8h:
mov r8, r8, asr #21
cmp r8, #255
mvnhi r8, r8, asr #31
#ifdef HAVE_LCD_COLOR
strb r8, [r1]
strb r8, [r1, #4]
strb r8, [r1, #8]
strb r8, [r1, #12]
strb r8, [r1, #16]
strb r8, [r1, #20]
strb r8, [r1, #24]
strb r8, [r1, #28]
#else
strb r8, [r1]
strb r8, [r1, #1]
strb r8, [r1, #2]
strb r8, [r1, #3]
strb r8, [r1, #4]
strb r8, [r1, #5]
strb r8, [r1, #6]
strb r8, [r1, #7]
#endif
strb r8, [r1, #pix8_size]
strb r8, [r1, #2*pix8_size]
strb r8, [r1, #3*pix8_size]
strb r8, [r1, #4*pix8_size]
strb r8, [r1, #5*pix8_size]
strb r8, [r1, #6*pix8_size]
strb r8, [r1, #7*pix8_size]
add r1, r1, r3
cmp r0, r2
bcc 1b
@ -752,25 +711,14 @@ jpeg_idct8h:
mov r14, r14, asr #18
cmp r14, #255
mvnhi r14, r14, asr #31
#ifdef HAVE_LCD_COLOR
strb r12, [r1]
strb r4, [r1, #4]
strb r10, [r1, #8]
strb r8, [r1, #12]
strb r9, [r1, #16]
strb r11, [r1, #20]
strb r5, [r1, #24]
strb r14, [r1, #28]
#else
strb r12, [r1]
strb r4, [r1, #1]
strb r10, [r1, #2]
strb r8, [r1, #3]
strb r9, [r1, #4]
strb r11, [r1, #5]
strb r5, [r1, #6]
strb r14, [r1, #7]
#endif
strb r4, [r1, #pix8_size]
strb r10, [r1, #2*pix8_size]
strb r8, [r1, #3*pix8_size]
strb r9, [r1, #4*pix8_size]
strb r11, [r1, #5*pix8_size]
strb r5, [r1, #6*pix8_size]
strb r14, [r1, #7*pix8_size]
#else /* ARMv5+ */
add r12, r14, r4, lsl #16
orrs r9, r6, r7
@ -779,25 +727,14 @@ jpeg_idct8h:
mov r12, r12, asr #21
cmp r12, #255
mvnhi r12, r12, asr #31
#ifdef HAVE_LCD_COLOR
strb r12, [r1]
strb r12, [r1, #4]
strb r12, [r1, #8]
strb r12, [r1, #12]
strb r12, [r1, #16]
strb r12, [r1, #20]
strb r12, [r1, #24]
strb r12, [r1, #28]
#else
strb r12, [r1]
strb r12, [r1, #1]
strb r12, [r1, #2]
strb r12, [r1, #3]
strb r12, [r1, #4]
strb r12, [r1, #5]
strb r12, [r1, #6]
strb r12, [r1, #7]
#endif
strb r12, [r1, #pix8_size]
strb r12, [r1, #2*pix8_size]
strb r12, [r1, #3*pix8_size]
strb r12, [r1, #4*pix8_size]
strb r12, [r1, #5*pix8_size]
strb r12, [r1, #6*pix8_size]
strb r12, [r1, #7*pix8_size]
add r1, r1, r3
cmp r0, r2
bcc 1b
@ -869,25 +806,14 @@ jpeg_idct8h:
mov r11, r11, asr #18
cmp r11, #255
mvnhi r11, r11, asr #31
#ifdef HAVE_LCD_COLOR
strb r10, [r1]
strb r12, [r1, #4]
strb r8, [r1, #8]
strb r6, [r1, #12]
strb r7, [r1, #16]
strb r9, [r1, #20]
strb r14, [r1, #24]
strb r11, [r1, #28]
#else
strb r10, [r1]
strb r12, [r1, #1]
strb r8, [r1, #2]
strb r6, [r1, #3]
strb r7, [r1, #4]
strb r9, [r1, #5]
strb r14, [r1, #6]
strb r11, [r1, #7]
#endif
strb r12, [r1, #pix8_size]
strb r8, [r1, #2*pix8_size]
strb r6, [r1, #3*pix8_size]
strb r7, [r1, #4*pix8_size]
strb r9, [r1, #5*pix8_size]
strb r14, [r1, #6*pix8_size]
strb r11, [r1, #7*pix8_size]
#endif
add r1, r1, r3
cmp r0, r2
@ -1009,25 +935,14 @@ jpeg_idct8h:
bne 2f
sxth r4, r4
usat r4, #8, r4, asr #5
#ifdef HAVE_LCD_COLOR
strb r4, [r1]
strb r4, [r1, #4]
strb r4, [r1, #8]
strb r4, [r1, #12]
strb r4, [r1, #16]
strb r4, [r1, #20]
strb r4, [r1, #24]
strb r4, [r1, #28]
#else
strb r4, [r1]
strb r4, [r1, #1]
strb r4, [r1, #2]
strb r4, [r1, #3]
strb r4, [r1, #4]
strb r4, [r1, #5]
strb r4, [r1, #6]
strb r4, [r1, #7]
#endif
strb r4, [r1, #pix8_size]
strb r4, [r1, #2*pix8_size]
strb r4, [r1, #3*pix8_size]
strb r4, [r1, #4*pix8_size]
strb r4, [r1, #5*pix8_size]
strb r4, [r1, #6*pix8_size]
strb r4, [r1, #7*pix8_size]
add r1, r1, r3
cmp r0, r2
bcc 1b
@ -1083,25 +998,14 @@ jpeg_idct8h:
usat r10, #8, r10, asr #18
usat r7, #8, r7, asr #18
usat r8, #8, r8, asr #18
#ifdef HAVE_LCD_COLOR
strb r6, [r1]
strb r4, [r1, #4]
strb r9, [r1, #8]
strb r14, [r1, #12]
strb r12, [r1, #16]
strb r10, [r1, #20]
strb r7, [r1, #24]
strb r8, [r1, #28]
#else
strb r6, [r1]
strb r4, [r1, #1]
strb r9, [r1, #2]
strb r14, [r1, #3]
strb r12, [r1, #4]
strb r10, [r1, #5]
strb r7, [r1, #6]
strb r8, [r1, #7]
#endif
strb r4, [r1, #pix8_size]
strb r9, [r1, #2*pix8_size]
strb r14, [r1, #3*pix8_size]
strb r12, [r1, #4*pix8_size]
strb r10, [r1, #5*pix8_size]
strb r7, [r1, #6*pix8_size]
strb r8, [r1, #7*pix8_size]
cmp r0, r2
add r1, r1, r3
bcc 1b

View file

@ -23,6 +23,7 @@ my $src;
# Split the input file on any runs of '\' and whitespace.
for (split(/[\s\\]+/m, <STDIN>)) {
/^(\/)?[^:]+(\:)?$/;
print ">>$& $src"
# Save target and continue if this item ends in ':'
if (!($2 && ($target=$&))) {
$src = $&;

View file

@ -25,6 +25,9 @@ preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) |
preprocess2file = $(shell $(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \
grep -v '^\#' | grep -v "^$$" > $(2))
asmdefs2file = $(shell $(CC) $(PPCFLAGS) $(3) -S -x c -o - -include config.h $(1) | \
perl -ne 'if(/^AD_(\w+):$$/){$$var=$$1}else{/^\W\.word\W(.*)$$/ && $$var && print "\#define $$var $$1\n";$$var=0}' > $2)
c2obj = $(addsuffix .o,$(basename $(subst $(ROOTDIR),$(BUILDDIR),$(1))))
# calculate dependencies for a list of source files $(2) and output them
@ -32,6 +35,7 @@ c2obj = $(addsuffix .o,$(basename $(subst $(ROOTDIR),$(BUILDDIR),$(1))))
mkdepfile = $(shell \
$(CC) $(PPCFLAGS) $(OTHER_INC) -MG -MM -include config.h $(2) | \
sed -e "s: lang.h: lang/lang_core.o:" \
-e 's:_asmdefs.o:_asmdefs.h:' \
-e "s: max_language_size.h: lang/max_language_size.h:" | \
$(TOOLSDIR)/addtargetdir.pl $(ROOTDIR) $(BUILDDIR) \
>> $(1)_)

View file

@ -51,8 +51,8 @@ endif
all: $(DEPFILE) build
# Subdir makefiles. their primary purpose is to populate SRC & OTHER_SRC
# but they also define special dependencies and compile rules
# Subdir makefiles. their primary purpose is to populate SRC, OTHER_SRC &
# ASMDEFS_SRC but they also define special dependencies and compile rules
include $(TOOLSDIR)/tools.make
include $(FIRMDIR)/firmware.make
include $(ROOTDIR)/apps/bitmaps/bitmaps.make
@ -96,6 +96,7 @@ $(DEPFILE) dep:
@echo foo > /dev/null # there must be a "real" command in the rule
$(call mkdepfile,$(DEPFILE),$(SRC))
$(call mkdepfile,$(DEPFILE),$(OTHER_SRC))
$(call mkdepfile,$(DEPFILE),$(ASMDEFS_SRC))
@mv $(DEPFILE)_ $(DEPFILE)
$(call bmpdepfile,$(DEPFILE),$(BMP) $(PBMP))
@ -317,6 +318,12 @@ $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
$(SILENT)mkdir -p $(dir $@)
$(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
# generated definitions for use in .S files
$(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
$(call PRINTS,ASMDEFS $(@F))
$(SILENT)mkdir -p $(dir $@)
$(call asmdefs2file,$<,$@)
# when source and object are both in BUILDDIR (generated code):
%.o: %.c
$(SILENT)mkdir -p $(dir $@)