OLD | NEW |
1 #!/usr/bin/env perl | 1 #!/usr/bin/env perl |
2 ## | 2 ## |
3 ## Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 3 ## Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
4 ## | 4 ## |
5 ## Use of this source code is governed by a BSD-style license | 5 ## Use of this source code is governed by a BSD-style license |
6 ## that can be found in the LICENSE file in the root of the source | 6 ## that can be found in the LICENSE file in the root of the source |
7 ## tree. An additional intellectual property rights grant can be found | 7 ## tree. An additional intellectual property rights grant can be found |
8 ## in the file PATENTS. All contributing project authors may | 8 ## in the file PATENTS. All contributing project authors may |
9 ## be found in the AUTHORS file in the root of the source tree. | 9 ## be found in the AUTHORS file in the root of the source tree. |
10 ## | 10 ## |
11 | 11 |
| 12 |
12 # ads2gas_apple.pl | 13 # ads2gas_apple.pl |
13 # Author: Eric Fung (efung (at) acm.org) | 14 # Author: Eric Fung (efung (at) acm.org) |
14 # | 15 # |
15 # Convert ARM Developer Suite 1.0.1 syntax assembly source to GNU as format | 16 # Convert ARM Developer Suite 1.0.1 syntax assembly source to GNU as format |
16 # | 17 # |
17 # Usage: cat inputfile | perl ads2gas_apple.pl > outputfile | 18 # Usage: cat inputfile | perl ads2gas_apple.pl > outputfile |
18 # | 19 # |
| 20 |
| 21 my $chromium = 0; |
| 22 |
| 23 foreach my $arg (@ARGV) { |
| 24 $chromium = 1 if ($arg eq "-chromium"); |
| 25 } |
| 26 |
19 print "@ This file was created from a .asm file\n"; | 27 print "@ This file was created from a .asm file\n"; |
20 print "@ using the ads2gas_apple.pl script.\n\n"; | 28 print "@ using the ads2gas_apple.pl script.\n\n"; |
21 print "\t.set WIDE_REFERENCE, 0\n"; | 29 print "\t.set WIDE_REFERENCE, 0\n"; |
22 print "\t.set ARCHITECTURE, 5\n"; | 30 print "\t.set ARCHITECTURE, 5\n"; |
23 print "\t.set DO1STROUNDING, 0\n"; | 31 print "\t.set DO1STROUNDING, 0\n"; |
24 | 32 |
25 my %register_aliases; | 33 my %register_aliases; |
26 my %macro_aliases; | 34 my %macro_aliases; |
27 | 35 |
28 my @mapping_list = ("\$0", "\$1", "\$2", "\$3", "\$4", "\$5", "\$6", "\$7", "\$8
", "\$9"); | 36 my @mapping_list = ("\$0", "\$1", "\$2", "\$3", "\$4", "\$5", "\$6", "\$7", "\$8
", "\$9"); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 { | 188 { |
181 # Process next line down, which will be the macro definition | 189 # Process next line down, which will be the macro definition |
182 $_ = <STDIN>; | 190 $_ = <STDIN>; |
183 | 191 |
184 $trimmed = trim($_); | 192 $trimmed = trim($_); |
185 | 193 |
186 # remove commas that are separating list | 194 # remove commas that are separating list |
187 $trimmed =~ s/,//g; | 195 $trimmed =~ s/,//g; |
188 | 196 |
189 # string to array | 197 # string to array |
190 @incoming_array = split(/ /, $trimmed); | 198 @incoming_array = split(/\s+/, $trimmed); |
191 | 199 |
192 print ".macro @incoming_array[0]\n"; | 200 print ".macro @incoming_array[0]\n"; |
193 | 201 |
194 # remove the first element, as that is the name of the macro | 202 # remove the first element, as that is the name of the macro |
195 shift (@incoming_array); | 203 shift (@incoming_array); |
196 | 204 |
197 @macro_aliases{@incoming_array} = @mapping_list; | 205 @macro_aliases{@incoming_array} = @mapping_list; |
198 | 206 |
199 next; | 207 next; |
200 } | 208 } |
201 | 209 |
202 while (($key, $value) = each(%macro_aliases)) | 210 while (($key, $value) = each(%macro_aliases)) |
203 { | 211 { |
204 $key =~ s/\$/\\\$/; | 212 $key =~ s/\$/\\\$/; |
205 s/$key\b/$value/g; | 213 s/$key\b/$value/g; |
206 } | 214 } |
207 | 215 |
208 # For macros, use \ to reference formal params | 216 # For macros, use \ to reference formal params |
209 # s/\$/\\/g; # End macro definition | 217 # s/\$/\\/g; # End macro definition |
210 s/MEND/.endm/; # No need to tell it where to stop assembling | 218 s/MEND/.endm/; # No need to tell it where to stop assembling |
211 next if /^\s*END\s*$/; | 219 next if /^\s*END\s*$/; |
212 | 220 |
213 s/qsubaddx/qsax/i; | 221 # Clang used by Chromium differs slightly from clang in XCode in what it |
214 s/qaddsubx/qasx/i; | 222 # will accept in the assembly. |
215 s/ldrneb/ldrbne/i; | 223 if ($chromium) { |
216 s/ldrneh/ldrhne/i; | 224 s/qsubaddx/qsax/i; |
217 s/(vqshrun\.s16 .*, \#)0$/${1}8/i; | 225 s/qaddsubx/qasx/i; |
218 s/\.include/#include/; | 226 s/ldrneb/ldrbne/i; |
| 227 s/ldrneh/ldrhne/i; |
| 228 s/(vqshrun\.s16 .*, \#)0$/${1}8/i; |
| 229 |
| 230 # http://llvm.org/bugs/show_bug.cgi?id=16022 |
| 231 s/\.include/#include/; |
| 232 } |
219 | 233 |
220 print; | 234 print; |
221 } | 235 } |
OLD | NEW |