From 79327be6c729ed73cb339630b0ab770e3c54a4ab Mon Sep 17 00:00:00 2001 From: Johann Date: Wed, 8 Jun 2011 14:43:34 -0400 Subject: [PATCH] use GCC inline magic Better fix for #326. ICC happens to support the inline magic Change-Id: Ic367eea608c88d89475cb7b05d73500d2a1bc42b --- build/make/Makefile | 6 +++++ libs.mk | 45 +++++++++++++++++++---------------- vp8/common/asm_com_offsets.c | 31 ++++++------------------ vp8/decoder/asm_dec_offsets.c | 25 +++++-------------- vp8/encoder/asm_enc_offsets.c | 44 ++++++++++++---------------------- vpx_ports/asm_offsets.h | 31 ++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 92 deletions(-) create mode 100644 vpx_ports/asm_offsets.h diff --git a/build/make/Makefile b/build/make/Makefile index a951e99bc..fe2edd96b 100755 --- a/build/make/Makefile +++ b/build/make/Makefile @@ -124,6 +124,12 @@ $(BUILD_PFX)%.s.o: %.s $(if $(quiet),@echo " [AS] $@") $(qexec)$(AS) $(ASFLAGS) -o $@ $< +.PRECIOUS: %.c.S +%.c.S: CFLAGS += -DINLINE_ASM +$(BUILD_PFX)%.c.S: %.c + $(if $(quiet),@echo " [GEN] $@") + $(qexec)$(CC) -S $(CFLAGS) -o $@ $< + .PRECIOUS: %.asm.s $(BUILD_PFX)%.asm.s: %.asm $(if $(quiet),@echo " [ASM CONVERSION] $@") diff --git a/libs.mk b/libs.mk index 2cb7f49ba..1819b240b 100644 --- a/libs.mk +++ b/libs.mk @@ -257,36 +257,41 @@ $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm # # Calculate platform- and compiler-specific offsets for hand coded assembly # -ifeq ($(CONFIG_EXTERNAL_BUILD),) # Visual Studio uses obj_int_extract.bat - ifeq ($(ARCH_ARM), yes) + +ifeq ($(filter icc gcc,$(TGT_CC)), $(TGT_CC)) + asm_com_offsets.asm: $(VP8_PREFIX)common/asm_com_offsets.c.S + grep EQU $< | tr -d '$$\#' $(ADS2GAS) > $@ + $(VP8_PREFIX)common/asm_com_offsets.c.S: vp8/common/asm_com_offsets.c + + asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c.S + grep EQU $< | tr -d '$$\#' $(ADS2GAS) > $@ + $(VP8_PREFIX)encoder/asm_enc_offsets.c.S: vp8/encoder/asm_enc_offsets.c + + asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c.S + grep EQU $< | tr -d '$$\#' $(ADS2GAS) > $@ + $(VP8_PREFIX)decoder/asm_dec_offsets.c.S: vp8/decoder/asm_dec_offsets.c +else + ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC)) asm_com_offsets.asm: obj_int_extract asm_com_offsets.asm: $(VP8_PREFIX)common/asm_com_offsets.c.o ./obj_int_extract rvds $< $(ADS2GAS) > $@ OBJS-yes += $(VP8_PREFIX)common/asm_com_offsets.c.o CLEAN-OBJS += asm_com_offsets.asm $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_com_offsets.asm - endif - ifeq ($(ARCH_ARM)$(ARCH_X86)$(ARCH_X86_64), yes) - ifeq ($(CONFIG_VP8_ENCODER), yes) - asm_enc_offsets.asm: obj_int_extract - asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c.o + asm_enc_offsets.asm: obj_int_extract + asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c.o ./obj_int_extract rvds $< $(ADS2GAS) > $@ - OBJS-yes += $(VP8_PREFIX)encoder/asm_enc_offsets.c.o - CLEAN-OBJS += asm_enc_offsets.asm - $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_enc_offsets.asm - endif - endif + OBJS-yes += $(VP8_PREFIX)encoder/asm_enc_offsets.c.o + CLEAN-OBJS += asm_enc_offsets.asm + $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_enc_offsets.asm - ifeq ($(ARCH_ARM), yes) - ifeq ($(CONFIG_VP8_DECODER), yes) - asm_dec_offsets.asm: obj_int_extract - asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c.o + asm_dec_offsets.asm: obj_int_extract + asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c.o ./obj_int_extract rvds $< $(ADS2GAS) > $@ - OBJS-yes += $(VP8_PREFIX)decoder/asm_dec_offsets.c.o - CLEAN-OBJS += asm_dec_offsets.asm - $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_dec_offsets.asm - endif + OBJS-yes += $(VP8_PREFIX)decoder/asm_dec_offsets.c.o + CLEAN-OBJS += asm_dec_offsets.asm + $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_dec_offsets.asm endif endif diff --git a/vp8/common/asm_com_offsets.c b/vp8/common/asm_com_offsets.c index d299dd2ae..e167d2654 100644 --- a/vp8/common/asm_com_offsets.c +++ b/vp8/common/asm_com_offsets.c @@ -9,27 +9,12 @@ */ -#include "vpx_ports/config.h" -#include - +#include "vpx_ports/asm_offsets.h" #include "vpx_scale/yv12config.h" -#define ct_assert(name,cond) \ - static void assert_##name(void) UNUSED;\ - static void assert_##name(void) {switch(0){case 0:case !!(cond):;}} - -#define DEFINE(sym, val) int sym = val; - -/* -#define BLANK() asm volatile("\n->" : : ) -*/ - -/* - * int main(void) - * { - */ +BEGIN -//vpx_scale +/* vpx_scale */ DEFINE(yv12_buffer_config_y_width, offsetof(YV12_BUFFER_CONFIG, y_width)); DEFINE(yv12_buffer_config_y_height, offsetof(YV12_BUFFER_CONFIG, y_height)); DEFINE(yv12_buffer_config_y_stride, offsetof(YV12_BUFFER_CONFIG, y_stride)); @@ -41,9 +26,7 @@ DEFINE(yv12_buffer_config_u_buffer, offsetof(YV12_BUFFER_CONFIG, u_b DEFINE(yv12_buffer_config_v_buffer, offsetof(YV12_BUFFER_CONFIG, v_buffer)); DEFINE(yv12_buffer_config_border, offsetof(YV12_BUFFER_CONFIG, border)); -//add asserts for any offset that is not supported by assembly code -//add asserts for any size that is not supported by assembly code -/* - * return 0; - * } - */ +END + +/* add asserts for any offset that is not supported by assembly code */ +/* add asserts for any size that is not supported by assembly code */ diff --git a/vp8/decoder/asm_dec_offsets.c b/vp8/decoder/asm_dec_offsets.c index e485cb414..dd2aad2c3 100644 --- a/vp8/decoder/asm_dec_offsets.c +++ b/vp8/decoder/asm_dec_offsets.c @@ -9,21 +9,10 @@ */ -#include "vpx_ports/config.h" -#include - +#include "vpx_ports/asm_offsets.h" #include "onyxd_int.h" -#define DEFINE(sym, val) int sym = val; - -/* -#define BLANK() asm volatile("\n->" : : ) -*/ - -/* - * int main(void) - * { - */ +BEGIN DEFINE(detok_scan, offsetof(DETOK, scan)); DEFINE(detok_ptr_block2leftabove, offsetof(DETOK, ptr_block2leftabove)); @@ -49,9 +38,7 @@ DEFINE(bool_decoder_range, offsetof(BOOL_DECODER, range)); DEFINE(tokenextrabits_min_val, offsetof(TOKENEXTRABITS, min_val)); DEFINE(tokenextrabits_length, offsetof(TOKENEXTRABITS, Length)); -//add asserts for any offset that is not supported by assembly code -//add asserts for any size that is not supported by assembly code -/* - * return 0; - * } - */ +END + +/* add asserts for any offset that is not supported by assembly code */ +/* add asserts for any size that is not supported by assembly code */ diff --git a/vp8/encoder/asm_enc_offsets.c b/vp8/encoder/asm_enc_offsets.c index 9c81c8d0a..c79e915f8 100644 --- a/vp8/encoder/asm_enc_offsets.c +++ b/vp8/encoder/asm_enc_offsets.c @@ -9,31 +9,17 @@ */ -#include "vpx_ports/config.h" -#include - +#include "vpx_ports/asm_offsets.h" +#include "vpx_config.h" #include "block.h" #include "vp8/common/blockd.h" #include "onyx_int.h" #include "treewriter.h" #include "tokenize.h" -#define ct_assert(name,cond) \ - static void assert_##name(void) UNUSED;\ - static void assert_##name(void) {switch(0){case 0:case !!(cond):;}} - -#define DEFINE(sym, val) int sym = val; - -/* -#define BLANK() asm volatile("\n->" : : ) -*/ - -/* - * int main(void) - * { - */ +BEGIN -//regular quantize +/* regular quantize */ DEFINE(vp8_block_coeff, offsetof(BLOCK, coeff)); DEFINE(vp8_block_zbin, offsetof(BLOCK, zbin)); DEFINE(vp8_block_round, offsetof(BLOCK, round)); @@ -48,7 +34,7 @@ DEFINE(vp8_blockd_dequant, offsetof(BLOCKD, dequant)); DEFINE(vp8_blockd_dqcoeff, offsetof(BLOCKD, dqcoeff)); DEFINE(vp8_blockd_eob, offsetof(BLOCKD, eob)); -// subtract +/* subtract */ DEFINE(vp8_block_base_src, offsetof(BLOCK, base_src)); DEFINE(vp8_block_src, offsetof(BLOCK, src)); DEFINE(vp8_block_src_diff, offsetof(BLOCK, src_diff)); @@ -56,7 +42,7 @@ DEFINE(vp8_block_src_stride, offsetof(BLOCK, src_stride)); DEFINE(vp8_blockd_predictor, offsetof(BLOCKD, predictor)); -//pack tokens +/* pack tokens */ DEFINE(vp8_writer_lowvalue, offsetof(vp8_writer, lowvalue)); DEFINE(vp8_writer_range, offsetof(vp8_writer, range)); DEFINE(vp8_writer_value, offsetof(vp8_writer, value)); @@ -90,16 +76,16 @@ DEFINE(TOKENLIST_SZ, sizeof(TOKENLIST)); DEFINE(vp8_common_mb_rows, offsetof(VP8_COMMON, mb_rows)); -// These two sizes are used in vp8cx_pack_tokens. They are hard coded -// so if the size changes this will have to be adjusted. +END + +/* add asserts for any offset that is not supported by assembly code + * add asserts for any size that is not supported by assembly code + + * These are used in vp8cx_pack_tokens. They are hard coded so if their sizes + * change they will have to be adjusted. + */ + #if HAVE_ARMV5TE ct_assert(TOKENEXTRA_SZ, sizeof(TOKENEXTRA) == 8) ct_assert(vp8_extra_bit_struct_sz, sizeof(vp8_extra_bit_struct) == 16) #endif - -//add asserts for any offset that is not supported by assembly code -//add asserts for any size that is not supported by assembly code -/* - * return 0; - * } - */ diff --git a/vpx_ports/asm_offsets.h b/vpx_ports/asm_offsets.h new file mode 100644 index 000000000..d3b4fc706 --- /dev/null +++ b/vpx_ports/asm_offsets.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2011 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + + +#ifndef VPX_PORTS_ASM_OFFSETS_H +#define VPX_PORTS_ASM_OFFSETS_H + +#include + +#define ct_assert(name,cond) \ + static void assert_##name(void) UNUSED;\ + static void assert_##name(void) {switch(0){case 0:case !!(cond):;}} + +#if INLINE_ASM +#define DEFINE(sym, val) asm("\n" #sym " EQU %0" : : "i" (val)); +#define BEGIN int main(void) { +#define END return 0; } +#else +#define DEFINE(sym, val) int sym = val; +#define BEGIN +#define END +#endif + +#endif /* VPX_PORTS_ASM_OFFSETS_H */ -- 2.40.0