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

Side by Side Diff: celt/arm/arm2gnu.pl

Issue 882843002: Update to opus-HEAD-66611f1. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/opus.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 #!/usr/bin/perl 1 #!/usr/bin/perl
2 # Copyright (C) 2002-2013 Xiph.org Foundation 2 # Copyright (C) 2002-2013 Xiph.org Foundation
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions 5 # modification, are permitted provided that the following conditions
6 # are met: 6 # are met:
7 # 7 #
8 # - Redistributions of source code must retain the above copyright 8 # - Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # 10 #
11 # - Redistributions in binary form must reproduce the above copyright 11 # - Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the 12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution. 13 # documentation and/or other materials provided with the distribution.
14 # 14 #
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 18 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 26
27 my $bigend; # little/big endian 27 my $bigend; # little/big endian
28 my $nxstack; 28 my $nxstack;
29 my $apple = 0;
30 my $symprefix = "";
29 31
30 $nxstack = 0; 32 $nxstack = 0;
31 33
32 eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' 34 eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
33 if $running_under_some_shell; 35 if $running_under_some_shell;
34 36
35 while ($ARGV[0] =~ /^-/) { 37 while ($ARGV[0] =~ /^-/) {
36 $_ = shift; 38 $_ = shift;
37 last if /^--/; 39 last if /^--$/;
38 if (/^-n/) { 40 if (/^-n$/) {
39 $nflag++; 41 $nflag++;
40 next; 42 next;
41 } 43 }
44 if (/^--apple$/) {
45 $apple = 1;
46 $symprefix = "_";
47 next;
48 }
42 die "I don't recognize this switch: $_\\n"; 49 die "I don't recognize this switch: $_\\n";
43 } 50 }
44 $printit++ unless $nflag; 51 $printit++ unless $nflag;
45 52
46 $\ = "\n"; # automatically add newline on print 53 $\ = "\n"; # automatically add newline on print
47 $n=0; 54 $n=0;
48 55
49 $thumb = 0; # ARM mode by default, not Thumb. 56 $thumb = 0; # ARM mode by default, not Thumb.
50 @proc_stack = (); 57 @proc_stack = ();
51 58
(...skipping 20 matching lines...) Expand all
72 s/;/@/; 79 s/;/@/;
73 while ( /@.*'/ ) { 80 while ( /@.*'/ ) {
74 s/(@.*)'/$1/g; 81 s/(@.*)'/$1/g;
75 } 82 }
76 s/\{FALSE\}/0/g; 83 s/\{FALSE\}/0/g;
77 s/\{TRUE\}/1/g; 84 s/\{TRUE\}/1/g;
78 s/\{(\w\w\w\w+)\}/$1/g; 85 s/\{(\w\w\w\w+)\}/$1/g;
79 s/\bINCLUDE[ \t]*([^ \t\n]+)/.include \"$1\"/; 86 s/\bINCLUDE[ \t]*([^ \t\n]+)/.include \"$1\"/;
80 s/\bGET[ \t]*([^ \t\n]+)/.include \"${ my $x=$1; $x =~ s|\.s|-gnu.S|; \$x }\ "/; 87 s/\bGET[ \t]*([^ \t\n]+)/.include \"${ my $x=$1; $x =~ s|\.s|-gnu.S|; \$x }\ "/;
81 s/\bIMPORT\b/.extern/; 88 s/\bIMPORT\b/.extern/;
82 s/\bEXPORT\b/.global/; 89 s/\bEXPORT\b\s*/.global $symprefix/;
83 s/^(\s+)\[/$1IF/; 90 s/^(\s+)\[/$1IF/;
84 s/^(\s+)\|/$1ELSE/; 91 s/^(\s+)\|/$1ELSE/;
85 s/^(\s+)\]/$1ENDIF/; 92 s/^(\s+)\]/$1ENDIF/;
86 s/IF *:DEF:/ .ifdef/; 93 s/IF *:DEF:/ .ifdef/;
87 s/IF *:LNOT: *:DEF:/ .ifndef/; 94 s/IF *:LNOT: *:DEF:/ .ifndef/;
88 s/ELSE/ .else/; 95 s/ELSE/ .else/;
89 s/ENDIF/ .endif/; 96 s/ENDIF/ .endif/;
90 97
91 if( /\bIF\b/ ) { 98 if( /\bIF\b/ ) {
92 s/\bIF\b/ .if/; 99 s/\bIF\b/ .if/;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 # Enable NEON instructions but don't produce a binary that requires 135 # Enable NEON instructions but don't produce a binary that requires
129 # ARMv7. RVCT does not have equivalent directives, so we just do this 136 # ARMv7. RVCT does not have equivalent directives, so we just do this
130 # for all CODE areas. 137 # for all CODE areas.
131 if ( /.text/ ) { 138 if ( /.text/ ) {
132 # Separating .arch, .fpu, etc., by semicolons does not work (gas 139 # Separating .arch, .fpu, etc., by semicolons does not work (gas
133 # thinks the semicolon is part of the arch name, even when there's 140 # thinks the semicolon is part of the arch name, even when there's
134 # whitespace separating them). Sadly this means our line numbers 141 # whitespace separating them). Sadly this means our line numbers
135 # won't match the original source file (we could use the .line 142 # won't match the original source file (we could use the .line
136 # directive, which is documented to be obsolete, but then gdb will 143 # directive, which is documented to be obsolete, but then gdb will
137 # show the wrong line in the translated source file). 144 # show the wrong line in the translated source file).
138 s/$/; .arch armv7-a\n .fpu neon\n .object_arch armv4t/; 145 s/$/; .arch armv7-a\n .fpu neon\n .object_arch armv4t/ unless ($apple);
139 } 146 }
140 } 147 }
141 148
142 s/\|\|\.constdata\$(\d+)\|\|/.L_CONST$1/; # ||.constdata$3|| 149 s/\|\|\.constdata\$(\d+)\|\|/.L_CONST$1/; # ||.constdata$3||
143 s/\|\|\.bss\$(\d+)\|\|/.L_BSS$1/; # ||.bss$2|| 150 s/\|\|\.bss\$(\d+)\|\|/.L_BSS$1/; # ||.bss$2||
144 s/\|\|\.data\$(\d+)\|\|/.L_DATA$1/; # ||.data$2|| 151 s/\|\|\.data\$(\d+)\|\|/.L_DATA$1/; # ||.data$2||
145 s/\|\|([a-zA-Z0-9_]+)\@([a-zA-Z0-9_]+)\|\|/@ $&/; 152 s/\|\|([a-zA-Z0-9_]+)\@([a-zA-Z0-9_]+)\|\|/@ $&/;
146 s/^(\s+)\%(\s)/ .space $1/; 153 s/^(\s+)\%(\s)/ .space $1/;
147 154
148 s/\|(.+)\.(\d+)\|/\.$1_$2/; # |L80.123| -> .L80_123 155 s/\|(.+)\.(\d+)\|/\.$1_$2/; # |L80.123| -> .L80_123
149 s/\bCODE32\b/.code 32/ && do {$thumb = 0}; 156 s/\bCODE32\b/.code 32/ && do {$thumb = 0};
150 s/\bCODE16\b/.code 16/ && do {$thumb = 1}; 157 s/\bCODE16\b/.code 16/ && do {$thumb = 1};
151 if (/\bPROC\b/) 158 if (/\bPROC\b/)
152 { 159 {
153 my $prefix; 160 my $prefix;
154 my $proc; 161 my $proc;
155 /^([A-Za-z_\.]\w+)\b/; 162 /^([A-Za-z_\.]\w+)\b/;
156 $proc = $1; 163 $proc = $1;
157 $prefix = ""; 164 $prefix = "";
158 if ($proc) 165 if ($proc)
159 { 166 {
160 $prefix = $prefix.sprintf("\t.type\t%s, %%function; ",$proc); 167 $prefix = $prefix.sprintf("\t.type\t%s, %%function; ",$proc) unless ($apple);
168 # Make sure we $prefix isn't empty here (for the $apple case).
169 # We handle mangling the label here, make sure it doesn't match
170 # the label handling below (if $prefix would be empty).
171 $prefix = "; ";
161 push(@proc_stack, $proc); 172 push(@proc_stack, $proc);
162 s/^[A-Za-z_\.]\w+/$&:/; 173 s/^[A-Za-z_\.]\w+/$symprefix$&:/;
163 } 174 }
164 $prefix = $prefix."\t.thumb_func; " if ($thumb); 175 $prefix = $prefix."\t.thumb_func; " if ($thumb);
165 s/\bPROC\b/@ $&/; 176 s/\bPROC\b/@ $&/;
166 $_ = $prefix.$_; 177 $_ = $prefix.$_;
167 } 178 }
168 s/^(\s*)(S|Q|SH|U|UQ|UH)ASX\b/$1$2ADDSUBX/; 179 s/^(\s*)(S|Q|SH|U|UQ|UH)ASX\b/$1$2ADDSUBX/;
169 s/^(\s*)(S|Q|SH|U|UQ|UH)SAX\b/$1$2SUBADDX/; 180 s/^(\s*)(S|Q|SH|U|UQ|UH)SAX\b/$1$2SUBADDX/;
170 if (/\bENDP\b/) 181 if (/\bENDP\b/)
171 { 182 {
172 my $proc; 183 my $proc;
173 s/\bENDP\b/@ $&/; 184 s/\bENDP\b/@ $&/;
174 $proc = pop(@proc_stack); 185 $proc = pop(@proc_stack);
175 $_ = "\t.size $proc, .-$proc".$_ if ($proc); 186 $_ = "\t.size $proc, .-$proc".$_ if ($proc && !$apple);
176 } 187 }
177 s/\bSUBT\b/@ $&/; 188 s/\bSUBT\b/@ $&/;
178 s/\bDATA\b/@ $&/; # DATA directive is deprecated -- Asm guide, p.7-25 189 s/\bDATA\b/@ $&/; # DATA directive is deprecated -- Asm guide, p.7-25
179 s/\bKEEP\b/@ $&/; 190 s/\bKEEP\b/@ $&/;
180 s/\bEXPORTAS\b/@ $&/; 191 s/\bEXPORTAS\b/@ $&/;
181 s/\|\|(.)+\bEQU\b/@ $&/; 192 s/\|\|(.)+\bEQU\b/@ $&/;
182 s/\|\|([\w\$]+)\|\|/$1/; 193 s/\|\|([\w\$]+)\|\|/$1/;
183 s/\bENTRY\b/@ $&/; 194 s/\bENTRY\b/@ $&/;
184 s/\bASSERT\b/@ $&/; 195 s/\bASSERT\b/@ $&/;
185 s/\bGBLL\b/@ $&/; 196 s/\bGBLL\b/@ $&/;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } continue { 341 } continue {
331 printf ("%s", $_) if $printit; 342 printf ("%s", $_) if $printit;
332 if ($addPadding != 0) 343 if ($addPadding != 0)
333 { 344 {
334 printf (" mov r0,r0\n"); 345 printf (" mov r0,r0\n");
335 $addPadding = 0; 346 $addPadding = 0;
336 } 347 }
337 } 348 }
338 #If we had a code section, mark that this object doesn't need an executable 349 #If we had a code section, mark that this object doesn't need an executable
339 # stack. 350 # stack.
340 if ($nxstack) { 351 if ($nxstack && !$apple) {
341 printf (" .section\t.note.GNU-stack,\"\",\%\%progbits\n"); 352 printf (" .section\t.note.GNU-stack,\"\",\%\%progbits\n");
342 } 353 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698