6
Usage: $self [options] FILE
8
Reads the Run Time CPU Detections definitions from FILE and generates a
9
C header file on stdout.
12
--arch=ARCH Architecture to generate defs for (required)
13
--disable-EXT Disable support for EXT extensions
14
--require-EXT Require support for EXT extensions
15
--sym=SYMBOL Unique symbol to use for RTCD initialization function
16
--config=FILE File with CONFIG_FOO=yes lines to parse
26
die_argument_required() {
27
die "Option $opt requires argument"
33
--arch) die_argument_required;;
34
--arch=*) arch=${optval};;
35
--disable-*) eval "disable_${opt#--disable-}=true";;
36
--require-*) REQUIRES="${REQUIRES}${opt#--require-} ";;
37
--sym) die_argument_required;;
38
--sym=*) symbol=${optval};;
39
--config=*) config_file=${optval};;
44
die "Unrecognized option: ${opt%%=*}"
47
defs_file="$defs_file $opt"
52
for f in $defs_file; do [ -f "$f" ] || usage; done
53
[ -n "$arch" ] || usage
55
# Import the configuration
56
[ -f "$config_file" ] && eval $(grep CONFIG_ "$config_file")
59
# Routines for the RTCD DSL to call
64
unsigned) rtyp="$1 "; shift;;
70
eval "${2}_rtyp='$rtyp'"
72
ALL_FUNCS="$ALL_FUNCS $fn"
80
eval "${fn}_${opt}=${fn}_${opt}"
85
for fn in $ALL_FUNCS; do
87
ofn=$(eval "echo \$${fn}_${opt}")
88
[ -z "$ofn" ] && continue
90
# if we already have a default, then we can disable it, as we know
92
best=$(eval "echo \$${fn}_default")
93
best_ofn=$(eval "echo \$${best}")
94
[ -n "$best" ] && [ "$best_ofn" != "$ofn" ] && eval "${best}_link=false"
95
eval "${fn}_default=${fn}_${opt}"
96
eval "${fn}_${opt}_link=true"
102
ALL_FORWARD_DECLS="$ALL_FORWARD_DECLS $1"
106
# Include the user's directives
108
for f in $defs_file; do
113
# Process the directives according to the command line
115
process_forward_decls() {
116
for fn in $ALL_FORWARD_DECLS; do
121
determine_indirection() {
122
[ "$CONFIG_RUNTIME_CPU_DETECT" = "yes" ] || require $ALL_ARCHS
123
for fn in $ALL_FUNCS; do
125
rtyp="$(eval "echo \$${fn}_rtyp")"
126
args="$(eval "echo \"\$${fn}_args\"")"
127
dfn="$(eval "echo \$${fn}_default")"
128
dfn=$(eval "echo \$${dfn}")
130
ofn=$(eval "echo \$${fn}_${opt}")
131
[ -z "$ofn" ] && continue
132
link=$(eval "echo \$${fn}_${opt}_link")
133
[ "$link" = "false" ] && continue
136
if [ "$n" = "x" ]; then
137
eval "${fn}_indirect=false"
139
eval "${fn}_indirect=true"
144
declare_function_pointers() {
145
for fn in $ALL_FUNCS; do
146
rtyp="$(eval "echo \$${fn}_rtyp")"
147
args="$(eval "echo \"\$${fn}_args\"")"
148
dfn="$(eval "echo \$${fn}_default")"
149
dfn=$(eval "echo \$${dfn}")
151
ofn=$(eval "echo \$${fn}_${opt}")
152
[ -z "$ofn" ] && continue
153
echo "$rtyp ${ofn}($args);"
155
if [ "$(eval "echo \$${fn}_indirect")" = "false" ]; then
156
echo "#define ${fn} ${dfn}"
158
echo "RTCD_EXTERN $rtyp (*${fn})($args);"
164
set_function_pointers() {
165
for fn in $ALL_FUNCS; do
167
rtyp="$(eval "echo \$${fn}_rtyp")"
168
args="$(eval "echo \"\$${fn}_args\"")"
169
dfn="$(eval "echo \$${fn}_default")"
170
dfn=$(eval "echo \$${dfn}")
171
if $(eval "echo \$${fn}_indirect"); then
174
ofn=$(eval "echo \$${fn}_${opt}")
175
[ -z "$ofn" ] && continue
176
[ "$ofn" = "$dfn" ] && continue;
177
link=$(eval "echo \$${fn}_${opt}_link")
178
[ "$link" = "false" ] && continue
179
cond="$(eval "echo \$have_${opt}")"
180
echo " if (${cond}) $fn = $ofn;"
190
[ -z $(eval "echo \$disable_${opt}") ] && filtered="$filtered $opt"
196
# Helper functions for generating the arch specific RTCD files
199
outfile_basename=$(basename ${symbol:-rtcd})
200
include_guard=$(echo $outfile_basename | tr '[a-z]' '[A-Z]' | \
201
tr -c '[A-Z0-9]' _)H_
203
#ifndef ${include_guard}
204
#define ${include_guard}
209
#define RTCD_EXTERN extern
212
$(process_forward_decls)
214
$(declare_function_pointers c $ALL_ARCHS)
216
void ${symbol:-rtcd}(void);
227
determine_indirection c $ALL_ARCHS
229
# Assign the helper variable for each enabled extension
230
for opt in $ALL_ARCHS; do
231
uc=$(echo $opt | tr '[a-z]' '[A-Z]')
232
eval "have_${opt}=\"flags & HAS_${uc}\""
239
#include "vpx_ports/x86.h"
240
static void setup_rtcd_internal(void)
242
int flags = x86_simd_caps();
246
$(set_function_pointers c $ALL_ARCHS)
254
determine_indirection c $ALL_ARCHS
256
# Assign the helper variable for each enabled extension
257
for opt in $ALL_ARCHS; do
258
uc=$(echo $opt | tr '[a-z]' '[A-Z]')
259
eval "have_${opt}=\"flags & HAS_${uc}\""
264
#include "vpx_config.h"
267
#include "vpx_ports/arm.h"
268
static void setup_rtcd_internal(void)
270
int flags = arm_cpu_caps();
274
$(set_function_pointers c $ALL_ARCHS)
283
determine_indirection c $ALL_ARCHS
286
#include "vpx_config.h"
289
static void setup_rtcd_internal(void)
291
$(set_function_pointers c $ALL_ARCHS)
294
void dsputil_static_init();
295
dsputil_static_init();
298
void vp9_dsputil_static_init();
299
vp9_dsputil_static_init();
309
determine_indirection c
312
#include "vpx_config.h"
315
static void setup_rtcd_internal(void)
317
$(set_function_pointers c)
330
ALL_ARCHS=$(filter mmx sse sse2 sse3 ssse3 sse4_1 avx avx2)
334
ALL_ARCHS=$(filter mmx sse sse2 sse3 ssse3 sse4_1 avx avx2)
335
REQUIRES=${REQUIRES:-mmx sse sse2}
336
require $(filter $REQUIRES)
340
ALL_ARCHS=$(filter mips32)
341
dspr2=$([ -f "$config_file" ] && eval echo $(grep HAVE_DSPR2 "$config_file"))
342
HAVE_DSPR2="${dspr2#*=}"
343
if [ "$HAVE_DSPR2" = "yes" ]; then
344
ALL_ARCHS=$(filter mips32 dspr2)
349
ALL_ARCHS=$(filter edsp)
353
ALL_ARCHS=$(filter edsp media)
357
ALL_ARCHS=$(filter edsp media neon)