Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(730)

Side by Side Diff: source/libvpx/build/make/rtcd.sh

Issue 13042014: Description: (Closed) Base URL: https://src.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: libvpx: Pull from upstream Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/build/make/obj_int_extract.c ('k') | source/libvpx/examples.mk » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/bin/sh
2 self=$0 2 self=$0
3 3
4 usage() { 4 usage() {
5 cat <<EOF >&2 5 cat <<EOF >&2
6 Usage: $self [options] FILE 6 Usage: $self [options] FILE
7 7
8 Reads the Run Time CPU Detections definitions from FILE and generates a 8 Reads the Run Time CPU Detections definitions from FILE and generates a
9 C header file on stdout. 9 C header file on stdout.
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 for f in $defs_file; do [ -f "$f" ] || usage; done 52 for f in $defs_file; do [ -f "$f" ] || usage; done
53 [ -n "$arch" ] || usage 53 [ -n "$arch" ] || usage
54 54
55 # Import the configuration 55 # Import the configuration
56 [ -f "$config_file" ] && eval $(grep CONFIG_ "$config_file") 56 [ -f "$config_file" ] && eval $(grep CONFIG_ "$config_file")
57 57
58 # 58 #
59 # Routines for the RTCD DSL to call 59 # Routines for the RTCD DSL to call
60 # 60 #
61 prototype() { 61 prototype() {
62 local rtyp 62 rtyp=""
63 case "$1" in 63 case "$1" in
64 unsigned) rtyp="$1 "; shift;; 64 unsigned) rtyp="$1 "; shift;;
65 esac 65 esac
66 rtyp="${rtyp}$1" 66 rtyp="${rtyp}$1"
67 local fn="$2" 67 fn="$2"
68 local args="$3" 68 args="$3"
69 69
70 eval "${2}_rtyp='$rtyp'" 70 eval "${2}_rtyp='$rtyp'"
71 eval "${2}_args='$3'" 71 eval "${2}_args='$3'"
72 ALL_FUNCS="$ALL_FUNCS $fn" 72 ALL_FUNCS="$ALL_FUNCS $fn"
73 specialize $fn c 73 specialize $fn c
74 } 74 }
75 75
76 specialize() { 76 specialize() {
77 local fn="$1" 77 fn="$1"
78 shift 78 shift
79 for opt in "$@"; do 79 for opt in "$@"; do
80 eval "${fn}_${opt}=${fn}_${opt}" 80 eval "${fn}_${opt}=${fn}_${opt}"
81 done 81 done
82 } 82 }
83 83
84 require() { 84 require() {
85 for fn in $ALL_FUNCS; do 85 for fn in $ALL_FUNCS; do
86 for opt in "$@"; do 86 for opt in "$@"; do
87 local ofn=$(eval "echo \$${fn}_${opt}") 87 ofn=$(eval "echo \$${fn}_${opt}")
88 [ -z "$ofn" ] && continue 88 [ -z "$ofn" ] && continue
89 89
90 # if we already have a default, then we can disable it, as we know 90 # if we already have a default, then we can disable it, as we know
91 # we can do better. 91 # we can do better.
92 local best=$(eval "echo \$${fn}_default") 92 best=$(eval "echo \$${fn}_default")
93 local best_ofn=$(eval "echo \$${best}") 93 best_ofn=$(eval "echo \$${best}")
94 [ -n "$best" ] && [ "$best_ofn" != "$ofn" ] && eval "${best}_link=false" 94 [ -n "$best" ] && [ "$best_ofn" != "$ofn" ] && eval "${best}_link=false"
95 eval "${fn}_default=${fn}_${opt}" 95 eval "${fn}_default=${fn}_${opt}"
96 eval "${fn}_${opt}_link=true" 96 eval "${fn}_${opt}_link=true"
97 done 97 done
98 done 98 done
99 } 99 }
100 100
101 forward_decls() { 101 forward_decls() {
102 ALL_FORWARD_DECLS="$ALL_FORWARD_DECLS $1" 102 ALL_FORWARD_DECLS="$ALL_FORWARD_DECLS $1"
103 } 103 }
(...skipping 10 matching lines...) Expand all
114 # 114 #
115 process_forward_decls() { 115 process_forward_decls() {
116 for fn in $ALL_FORWARD_DECLS; do 116 for fn in $ALL_FORWARD_DECLS; do
117 eval $fn 117 eval $fn
118 done 118 done
119 } 119 }
120 120
121 determine_indirection() { 121 determine_indirection() {
122 [ "$CONFIG_RUNTIME_CPU_DETECT" = "yes" ] || require $ALL_ARCHS 122 [ "$CONFIG_RUNTIME_CPU_DETECT" = "yes" ] || require $ALL_ARCHS
123 for fn in $ALL_FUNCS; do 123 for fn in $ALL_FUNCS; do
124 local n="" 124 n=""
125 local rtyp="$(eval "echo \$${fn}_rtyp")" 125 rtyp="$(eval "echo \$${fn}_rtyp")"
126 local args="$(eval "echo \"\$${fn}_args\"")" 126 args="$(eval "echo \"\$${fn}_args\"")"
127 local dfn="$(eval "echo \$${fn}_default")" 127 dfn="$(eval "echo \$${fn}_default")"
128 dfn=$(eval "echo \$${dfn}") 128 dfn=$(eval "echo \$${dfn}")
129 for opt in "$@"; do 129 for opt in "$@"; do
130 local ofn=$(eval "echo \$${fn}_${opt}") 130 ofn=$(eval "echo \$${fn}_${opt}")
131 [ -z "$ofn" ] && continue 131 [ -z "$ofn" ] && continue
132 local link=$(eval "echo \$${fn}_${opt}_link") 132 link=$(eval "echo \$${fn}_${opt}_link")
133 [ "$link" = "false" ] && continue 133 [ "$link" = "false" ] && continue
134 n="${n}x" 134 n="${n}x"
135 done 135 done
136 if [ "$n" = "x" ]; then 136 if [ "$n" = "x" ]; then
137 eval "${fn}_indirect=false" 137 eval "${fn}_indirect=false"
138 else 138 else
139 eval "${fn}_indirect=true" 139 eval "${fn}_indirect=true"
140 fi 140 fi
141 done 141 done
142 } 142 }
143 143
144 declare_function_pointers() { 144 declare_function_pointers() {
145 for fn in $ALL_FUNCS; do 145 for fn in $ALL_FUNCS; do
146 local rtyp="$(eval "echo \$${fn}_rtyp")" 146 rtyp="$(eval "echo \$${fn}_rtyp")"
147 local args="$(eval "echo \"\$${fn}_args\"")" 147 args="$(eval "echo \"\$${fn}_args\"")"
148 local dfn="$(eval "echo \$${fn}_default")" 148 dfn="$(eval "echo \$${fn}_default")"
149 dfn=$(eval "echo \$${dfn}") 149 dfn=$(eval "echo \$${dfn}")
150 for opt in "$@"; do 150 for opt in "$@"; do
151 local ofn=$(eval "echo \$${fn}_${opt}") 151 ofn=$(eval "echo \$${fn}_${opt}")
152 [ -z "$ofn" ] && continue 152 [ -z "$ofn" ] && continue
153 echo "$rtyp ${ofn}($args);" 153 echo "$rtyp ${ofn}($args);"
154 done 154 done
155 if [ "$(eval "echo \$${fn}_indirect")" = "false" ]; then 155 if [ "$(eval "echo \$${fn}_indirect")" = "false" ]; then
156 echo "#define ${fn} ${dfn}" 156 echo "#define ${fn} ${dfn}"
157 else 157 else
158 echo "RTCD_EXTERN $rtyp (*${fn})($args);" 158 echo "RTCD_EXTERN $rtyp (*${fn})($args);"
159 fi 159 fi
160 echo 160 echo
161 done 161 done
162 } 162 }
163 163
164 set_function_pointers() { 164 set_function_pointers() {
165 for fn in $ALL_FUNCS; do 165 for fn in $ALL_FUNCS; do
166 local n="" 166 n=""
167 local rtyp="$(eval "echo \$${fn}_rtyp")" 167 rtyp="$(eval "echo \$${fn}_rtyp")"
168 local args="$(eval "echo \"\$${fn}_args\"")" 168 args="$(eval "echo \"\$${fn}_args\"")"
169 local dfn="$(eval "echo \$${fn}_default")" 169 dfn="$(eval "echo \$${fn}_default")"
170 dfn=$(eval "echo \$${dfn}") 170 dfn=$(eval "echo \$${dfn}")
171 if $(eval "echo \$${fn}_indirect"); then 171 if $(eval "echo \$${fn}_indirect"); then
172 echo " $fn = $dfn;" 172 echo " $fn = $dfn;"
173 for opt in "$@"; do 173 for opt in "$@"; do
174 local ofn=$(eval "echo \$${fn}_${opt}") 174 ofn=$(eval "echo \$${fn}_${opt}")
175 [ -z "$ofn" ] && continue 175 [ -z "$ofn" ] && continue
176 [ "$ofn" = "$dfn" ] && continue; 176 [ "$ofn" = "$dfn" ] && continue;
177 local link=$(eval "echo \$${fn}_${opt}_link") 177 link=$(eval "echo \$${fn}_${opt}_link")
178 [ "$link" = "false" ] && continue 178 [ "$link" = "false" ] && continue
179 local cond="$(eval "echo \$have_${opt}")" 179 cond="$(eval "echo \$have_${opt}")"
180 echo " if (${cond}) $fn = $ofn;" 180 echo " if (${cond}) $fn = $ofn;"
181 done 181 done
182 fi 182 fi
183 echo 183 echo
184 done 184 done
185 } 185 }
186 186
187 filter() { 187 filter() {
188 local filtered 188 filtered=""
189 for opt in "$@"; do 189 for opt in "$@"; do
190 [ -z $(eval "echo \$disable_${opt}") ] && filtered="$filtered $opt" 190 [ -z $(eval "echo \$disable_${opt}") ] && filtered="$filtered $opt"
191 done 191 done
192 echo $filtered 192 echo $filtered
193 } 193 }
194 194
195 # 195 #
196 # Helper functions for generating the arch specific RTCD files 196 # Helper functions for generating the arch specific RTCD files
197 # 197 #
198 common_top() { 198 common_top() {
199 local outfile_basename=$(basename ${symbol:-rtcd.h}) 199 outfile_basename=$(basename ${symbol:-rtcd})
200 local include_guard=$(echo $outfile_basename | tr '[a-z]' '[A-Z]' | tr -c '[A- Z]' _) 200 include_guard=$(echo $outfile_basename | tr '[a-z]' '[A-Z]' | \
201 tr -c '[A-Z0-9]' _)H_
201 cat <<EOF 202 cat <<EOF
202 #ifndef ${include_guard} 203 #ifndef ${include_guard}
203 #define ${include_guard} 204 #define ${include_guard}
204 205
205 #ifdef RTCD_C 206 #ifdef RTCD_C
206 #define RTCD_EXTERN 207 #define RTCD_EXTERN
207 #else 208 #else
208 #define RTCD_EXTERN extern 209 #define RTCD_EXTERN extern
209 #endif 210 #endif
210 211
211 $(process_forward_decls) 212 $(process_forward_decls)
212 213
213 $(declare_function_pointers c $ALL_ARCHS) 214 $(declare_function_pointers c $ALL_ARCHS)
214 215
215 void ${symbol:-rtcd}(void); 216 void ${symbol:-rtcd}(void);
216 EOF 217 EOF
217 } 218 }
218 219
219 common_bottom() { 220 common_bottom() {
220 cat <<EOF 221 cat <<EOF
221 #endif 222 #endif
222 EOF 223 EOF
223 } 224 }
224 225
225 x86() { 226 x86() {
226 determine_indirection c $ALL_ARCHS 227 determine_indirection c $ALL_ARCHS
227 228
228 # Assign the helper variable for each enabled extension 229 # Assign the helper variable for each enabled extension
229 for opt in $ALL_ARCHS; do 230 for opt in $ALL_ARCHS; do
230 local uc=$(echo $opt | tr '[a-z]' '[A-Z]') 231 uc=$(echo $opt | tr '[a-z]' '[A-Z]')
231 eval "have_${opt}=\"flags & HAS_${uc}\"" 232 eval "have_${opt}=\"flags & HAS_${uc}\""
232 done 233 done
233 234
234 cat <<EOF 235 cat <<EOF
235 $(common_top) 236 $(common_top)
236 237
237 #ifdef RTCD_C 238 #ifdef RTCD_C
238 #include "vpx_ports/x86.h" 239 #include "vpx_ports/x86.h"
239 static void setup_rtcd_internal(void) 240 static void setup_rtcd_internal(void)
240 { 241 {
241 int flags = x86_simd_caps(); 242 int flags = x86_simd_caps();
242 243
243 (void)flags; 244 (void)flags;
244 245
245 $(set_function_pointers c $ALL_ARCHS) 246 $(set_function_pointers c $ALL_ARCHS)
246 } 247 }
247 #endif 248 #endif
248 $(common_bottom) 249 $(common_bottom)
249 EOF 250 EOF
250 } 251 }
251 252
252 arm() { 253 arm() {
253 determine_indirection c $ALL_ARCHS 254 determine_indirection c $ALL_ARCHS
254 255
255 # Assign the helper variable for each enabled extension 256 # Assign the helper variable for each enabled extension
256 for opt in $ALL_ARCHS; do 257 for opt in $ALL_ARCHS; do
257 local uc=$(echo $opt | tr '[a-z]' '[A-Z]') 258 uc=$(echo $opt | tr '[a-z]' '[A-Z]')
258 eval "have_${opt}=\"flags & HAS_${uc}\"" 259 eval "have_${opt}=\"flags & HAS_${uc}\""
259 done 260 done
260 261
261 cat <<EOF 262 cat <<EOF
262 $(common_top) 263 $(common_top)
263 #include "vpx_config.h" 264 #include "vpx_config.h"
264 265
265 #ifdef RTCD_C 266 #ifdef RTCD_C
266 #include "vpx_ports/arm.h" 267 #include "vpx_ports/arm.h"
267 static void setup_rtcd_internal(void) 268 static void setup_rtcd_internal(void)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 arm 348 arm
348 ;; 349 ;;
349 armv7) 350 armv7)
350 ALL_ARCHS=$(filter edsp media neon) 351 ALL_ARCHS=$(filter edsp media neon)
351 arm 352 arm
352 ;; 353 ;;
353 *) 354 *)
354 unoptimized 355 unoptimized
355 ;; 356 ;;
356 esac 357 esac
OLDNEW
« no previous file with comments | « source/libvpx/build/make/obj_int_extract.c ('k') | source/libvpx/examples.mk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698