summaryrefslogtreecommitdiff
path: root/build/make/rtcd.sh
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2014-02-23 16:33:14 -0800
committerJames Zern <jzern@google.com>2014-03-03 14:47:11 -0800
commit805078a1bf7c7194da47d5f5e7f9fed5bf734ca3 (patch)
tree234a74aa1d93979b354710e5e07f0a8811844f50 /build/make/rtcd.sh
parent14be7ba6403aabca7a4c9a7858cde15dcd5c03bd (diff)
downloadlibvpx-805078a1bf7c7194da47d5f5e7f9fed5bf734ca3.tar
libvpx-805078a1bf7c7194da47d5f5e7f9fed5bf734ca3.tar.gz
libvpx-805078a1bf7c7194da47d5f5e7f9fed5bf734ca3.tar.bz2
libvpx-805078a1bf7c7194da47d5f5e7f9fed5bf734ca3.zip
build: convert rtcd.sh to perl
significantly speeds up file generation. the goal of this change is to convert rtcd.sh to perl as directly as possible to allow for simple comparison. future changes can make it more perl-like. --- Linux [CREATE] vpx_scale_rtcd.h real 0m0.485s -> 0m0.022s [CREATE] vp8_rtcd.h real 0m4.619s -> 0m0.060s [CREATE] vp9_rtcd.h real 0m10.102s -> 0m0.087s Windows [CREATE] vpx_scale_rtcd.h real 0m8.360s -> 0m0.080s [CREATE] vp8_rtcd.h real 1m8.083s -> 0m0.160s [CREATE] vp9_rtcd.h real 2m6.489s -> 0m0.233s Change-Id: Idfb71188206c91237d6a3c3a81dfe00d103f11ee
Diffstat (limited to 'build/make/rtcd.sh')
-rwxr-xr-xbuild/make/rtcd.sh373
1 files changed, 0 insertions, 373 deletions
diff --git a/build/make/rtcd.sh b/build/make/rtcd.sh
deleted file mode 100755
index 93c9adcac..000000000
--- a/build/make/rtcd.sh
+++ /dev/null
@@ -1,373 +0,0 @@
-#!/bin/sh
-self=$0
-
-usage() {
- cat <<EOF >&2
-Usage: $self [options] FILE
-
-Reads the Run Time CPU Detections definitions from FILE and generates a
-C header file on stdout.
-
-Options:
- --arch=ARCH Architecture to generate defs for (required)
- --disable-EXT Disable support for EXT extensions
- --require-EXT Require support for EXT extensions
- --sym=SYMBOL Unique symbol to use for RTCD initialization function
- --config=FILE File with CONFIG_FOO=yes lines to parse
-EOF
- exit 1
-}
-
-die() {
- echo "$@" >&2
- exit 1
-}
-
-die_argument_required() {
- die "Option $opt requires argument"
-}
-
-for opt; do
- optval="${opt#*=}"
- case "$opt" in
- --arch) die_argument_required;;
- --arch=*) arch=${optval};;
- --disable-*) eval "disable_${opt#--disable-}=true";;
- --require-*) REQUIRES="${REQUIRES}${opt#--require-} ";;
- --sym) die_argument_required;;
- --sym=*) symbol=${optval};;
- --config=*) config_file=${optval};;
- -h|--help)
- usage
- ;;
- -*)
- die "Unrecognized option: ${opt%%=*}"
- ;;
- *)
- defs_file="$defs_file $opt"
- ;;
- esac
- shift
-done
-for f in $defs_file; do [ -f "$f" ] || usage; done
-[ -n "$arch" ] || usage
-
-# Import the configuration
-[ -f "$config_file" ] && eval $(grep CONFIG_ "$config_file")
-
-#
-# Routines for the RTCD DSL to call
-#
-prototype() {
- rtyp=""
- case "$1" in
- unsigned) rtyp="$1 "; shift;;
- esac
- rtyp="${rtyp}$1"
- fn="$2"
- args="$3"
-
- eval "${2}_rtyp='$rtyp'"
- eval "${2}_args='$3'"
- ALL_FUNCS="$ALL_FUNCS $fn"
- specialize $fn c
-}
-
-specialize() {
- fn="$1"
- shift
- for opt in "$@"; do
- eval "${fn}_${opt}=${fn}_${opt}"
- done
-}
-
-require() {
- for fn in $ALL_FUNCS; do
- for opt in "$@"; do
- ofn=$(eval "echo \$${fn}_${opt}")
- [ -z "$ofn" ] && continue
-
- # if we already have a default, then we can disable it, as we know
- # we can do better.
- best=$(eval "echo \$${fn}_default")
- best_ofn=$(eval "echo \$${best}")
- [ -n "$best" ] && [ "$best_ofn" != "$ofn" ] && eval "${best}_link=false"
- eval "${fn}_default=${fn}_${opt}"
- eval "${fn}_${opt}_link=true"
- done
- done
-}
-
-forward_decls() {
- ALL_FORWARD_DECLS="$ALL_FORWARD_DECLS $1"
-}
-
-#
-# Include the user's directives
-#
-for f in $defs_file; do
- . $f
-done
-
-#
-# Process the directives according to the command line
-#
-process_forward_decls() {
- for fn in $ALL_FORWARD_DECLS; do
- eval $fn
- done
-}
-
-determine_indirection() {
- [ "$CONFIG_RUNTIME_CPU_DETECT" = "yes" ] || require $ALL_ARCHS
- for fn in $ALL_FUNCS; do
- n=""
- rtyp="$(eval "echo \$${fn}_rtyp")"
- args="$(eval "echo \"\$${fn}_args\"")"
- dfn="$(eval "echo \$${fn}_default")"
- dfn=$(eval "echo \$${dfn}")
- for opt in "$@"; do
- ofn=$(eval "echo \$${fn}_${opt}")
- [ -z "$ofn" ] && continue
- link=$(eval "echo \$${fn}_${opt}_link")
- [ "$link" = "false" ] && continue
- n="${n}x"
- done
- if [ "$n" = "x" ]; then
- eval "${fn}_indirect=false"
- else
- eval "${fn}_indirect=true"
- fi
- done
-}
-
-declare_function_pointers() {
- for fn in $ALL_FUNCS; do
- rtyp="$(eval "echo \$${fn}_rtyp")"
- args="$(eval "echo \"\$${fn}_args\"")"
- dfn="$(eval "echo \$${fn}_default")"
- dfn=$(eval "echo \$${dfn}")
- for opt in "$@"; do
- ofn=$(eval "echo \$${fn}_${opt}")
- [ -z "$ofn" ] && continue
- echo "$rtyp ${ofn}($args);"
- done
- if [ "$(eval "echo \$${fn}_indirect")" = "false" ]; then
- echo "#define ${fn} ${dfn}"
- else
- echo "RTCD_EXTERN $rtyp (*${fn})($args);"
- fi
- echo
- done
-}
-
-set_function_pointers() {
- for fn in $ALL_FUNCS; do
- n=""
- rtyp="$(eval "echo \$${fn}_rtyp")"
- args="$(eval "echo \"\$${fn}_args\"")"
- dfn="$(eval "echo \$${fn}_default")"
- dfn=$(eval "echo \$${dfn}")
- if $(eval "echo \$${fn}_indirect"); then
- echo " $fn = $dfn;"
- for opt in "$@"; do
- ofn=$(eval "echo \$${fn}_${opt}")
- [ -z "$ofn" ] && continue
- [ "$ofn" = "$dfn" ] && continue;
- link=$(eval "echo \$${fn}_${opt}_link")
- [ "$link" = "false" ] && continue
- cond="$(eval "echo \$have_${opt}")"
- echo " if (${cond}) $fn = $ofn;"
- done
- fi
- echo
- done
-}
-
-filter() {
- filtered=""
- for opt in "$@"; do
- [ -z $(eval "echo \$disable_${opt}") ] && filtered="$filtered $opt"
- done
- echo $filtered
-}
-
-#
-# Helper functions for generating the arch specific RTCD files
-#
-common_top() {
- outfile_basename=$(basename ${symbol:-rtcd})
- include_guard=$(echo $outfile_basename | tr '[a-z]' '[A-Z]' | \
- tr -c '[A-Z0-9]' _)H_
- cat <<EOF
-#ifndef ${include_guard}
-#define ${include_guard}
-
-#ifdef RTCD_C
-#define RTCD_EXTERN
-#else
-#define RTCD_EXTERN extern
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-$(process_forward_decls)
-
-$(declare_function_pointers c $ALL_ARCHS)
-
-void ${symbol:-rtcd}(void);
-EOF
-}
-
-common_bottom() {
- cat <<EOF
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif
-EOF
-}
-
-x86() {
- determine_indirection c $ALL_ARCHS
-
- # Assign the helper variable for each enabled extension
- for opt in $ALL_ARCHS; do
- uc=$(echo $opt | tr '[a-z]' '[A-Z]')
- eval "have_${opt}=\"flags & HAS_${uc}\""
- done
-
- cat <<EOF
-$(common_top)
-
-#ifdef RTCD_C
-#include "vpx_ports/x86.h"
-static void setup_rtcd_internal(void)
-{
- int flags = x86_simd_caps();
-
- (void)flags;
-
-$(set_function_pointers c $ALL_ARCHS)
-}
-#endif
-$(common_bottom)
-EOF
-}
-
-arm() {
- determine_indirection c $ALL_ARCHS
-
- # Assign the helper variable for each enabled extension
- for opt in $ALL_ARCHS; do
- uc=$(echo $opt | tr '[a-z]' '[A-Z]')
- eval "have_${opt}=\"flags & HAS_${uc}\""
- done
-
- cat <<EOF
-$(common_top)
-#include "vpx_config.h"
-
-#ifdef RTCD_C
-#include "vpx_ports/arm.h"
-static void setup_rtcd_internal(void)
-{
- int flags = arm_cpu_caps();
-
- (void)flags;
-
-$(set_function_pointers c $ALL_ARCHS)
-}
-#endif
-$(common_bottom)
-EOF
-}
-
-
-mips() {
- determine_indirection c $ALL_ARCHS
- cat <<EOF
-$(common_top)
-#include "vpx_config.h"
-
-#ifdef RTCD_C
-static void setup_rtcd_internal(void)
-{
-$(set_function_pointers c $ALL_ARCHS)
-#if HAVE_DSPR2
-#if CONFIG_VP8
-void dsputil_static_init();
-dsputil_static_init();
-#endif
-#if CONFIG_VP9
-void vp9_dsputil_static_init();
-vp9_dsputil_static_init();
-#endif
-#endif
-}
-#endif
-$(common_bottom)
-EOF
-}
-
-unoptimized() {
- determine_indirection c
- cat <<EOF
-$(common_top)
-#include "vpx_config.h"
-
-#ifdef RTCD_C
-static void setup_rtcd_internal(void)
-{
-$(set_function_pointers c)
-}
-#endif
-$(common_bottom)
-EOF
-
-}
-#
-# Main Driver
-#
-ALL_FUNCS=$(export LC_ALL=C; echo $ALL_FUNCS | tr ' ' '\n' | sort |tr '\n' ' ')
-require c
-case $arch in
- x86)
- ALL_ARCHS=$(filter mmx sse sse2 sse3 ssse3 sse4_1 avx avx2)
- x86
- ;;
- x86_64)
- ALL_ARCHS=$(filter mmx sse sse2 sse3 ssse3 sse4_1 avx avx2)
- REQUIRES=${REQUIRES:-mmx sse sse2}
- require $(filter $REQUIRES)
- x86
- ;;
- mips32)
- ALL_ARCHS=$(filter mips32)
- dspr2=$([ -f "$config_file" ] && eval echo $(grep HAVE_DSPR2 "$config_file"))
- HAVE_DSPR2="${dspr2#*=}"
- if [ "$HAVE_DSPR2" = "yes" ]; then
- ALL_ARCHS=$(filter mips32 dspr2)
- fi
- mips
- ;;
- armv5te)
- ALL_ARCHS=$(filter edsp)
- arm
- ;;
- armv6)
- ALL_ARCHS=$(filter edsp media)
- arm
- ;;
- armv7)
- ALL_ARCHS=$(filter edsp media neon)
- arm
- ;;
- *)
- unoptimized
- ;;
-esac