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 ## |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 # Convert :NOT: to ~ | 68 # Convert :NOT: to ~ |
69 s/:NOT:/ ~ /g; | 69 s/:NOT:/ ~ /g; |
70 | 70 |
71 # Convert :SHL: to << | 71 # Convert :SHL: to << |
72 s/:SHL:/ << /g; | 72 s/:SHL:/ << /g; |
73 | 73 |
74 # Convert :SHR: to >> | 74 # Convert :SHR: to >> |
75 s/:SHR:/ >> /g; | 75 s/:SHR:/ >> /g; |
76 | 76 |
77 # Convert ELSE to .else | 77 # Convert ELSE to .else |
78 s/ELSE/.else/g; | 78 s/\bELSE\b/.else/g; |
79 | 79 |
80 # Convert ENDIF to .endif | 80 # Convert ENDIF to .endif |
81 s/ENDIF/.endif/g; | 81 s/\bENDIF\b/.endif/g; |
82 | 82 |
83 # Convert ELSEIF to .elseif | 83 # Convert ELSEIF to .elseif |
84 s/ELSEIF/.elseif/g; | 84 s/\bELSEIF\b/.elseif/g; |
85 | 85 |
86 # Convert LTORG to .ltorg | 86 # Convert LTORG to .ltorg |
87 s/LTORG/.ltorg/g; | 87 s/\bLTORG\b/.ltorg/g; |
88 | 88 |
89 # Convert IF :DEF:to .if | 89 # Convert IF :DEF:to .if |
90 # gcc doesn't have the ability to do a conditional | 90 # gcc doesn't have the ability to do a conditional |
91 # if defined variable that is set by IF :DEF: on | 91 # if defined variable that is set by IF :DEF: on |
92 # armasm, so convert it to a normal .if and then | 92 # armasm, so convert it to a normal .if and then |
93 # make sure to define a value elesewhere | 93 # make sure to define a value elesewhere |
94 if (s/\bIF :DEF:\b/.if /g) | 94 if (s/\bIF :DEF:\b/.if /g) |
95 { | 95 { |
96 s/=/==/g; | 96 s/=/==/g; |
97 } | 97 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 # No vertical bars required; make additional symbol with prepended | 157 # No vertical bars required; make additional symbol with prepended |
158 # underscore | 158 # underscore |
159 s/^\|(\$?\w+)\|/_$1\n\t$1:/g; | 159 s/^\|(\$?\w+)\|/_$1\n\t$1:/g; |
160 | 160 |
161 # Labels need trailing colon | 161 # Labels need trailing colon |
162 # s/^(\w+)/$1:/ if !/EQU/; | 162 # s/^(\w+)/$1:/ if !/EQU/; |
163 # put the colon at the end of the line in the macro | 163 # put the colon at the end of the line in the macro |
164 s/^([a-zA-Z_0-9\$]+)/$1:/ if !/EQU/; | 164 s/^([a-zA-Z_0-9\$]+)/$1:/ if !/EQU/; |
165 | 165 |
166 # ALIGN directive | 166 # ALIGN directive |
167 s/ALIGN/.balign/g; | 167 s/\bALIGN\b/.balign/g; |
168 | 168 |
169 # Strip ARM | 169 # Strip ARM |
170 s/\sARM/@ ARM/g; | 170 s/\sARM/@ ARM/g; |
171 | 171 |
172 # Strip REQUIRE8 | 172 # Strip REQUIRE8 |
173 #s/\sREQUIRE8/@ REQUIRE8/g; | 173 #s/\sREQUIRE8/@ REQUIRE8/g; |
174 s/\sREQUIRE8/@ /g; | 174 s/\sREQUIRE8/@ /g; |
175 | 175 |
176 # Strip PRESERVE8 | 176 # Strip PRESERVE8 |
177 s/\sPRESERVE8/@ PRESERVE8/g; | 177 s/\sPRESERVE8/@ PRESERVE8/g; |
178 | 178 |
179 # Strip PROC and ENDPROC | 179 # Strip PROC and ENDPROC |
180 s/\bPROC\b/@/g; | 180 s/\bPROC\b/@/g; |
181 s/\bENDP\b/@/g; | 181 s/\bENDP\b/@/g; |
182 | 182 |
183 # EQU directive | 183 # EQU directive |
184 s/(.*)EQU(.*)/.set $1, $2/; | 184 s/(.*)EQU(.*)/.set $1, $2/; |
185 | 185 |
186 # Begin macro definition | 186 # Begin macro definition |
187 if (/MACRO/) | 187 if (/\bMACRO\b/) |
188 { | 188 { |
189 # Process next line down, which will be the macro definition | 189 # Process next line down, which will be the macro definition |
190 $_ = <STDIN>; | 190 $_ = <STDIN>; |
191 | 191 |
192 $trimmed = trim($_); | 192 $trimmed = trim($_); |
193 | 193 |
194 # remove commas that are separating list | 194 # remove commas that are separating list |
195 $trimmed =~ s/,//g; | 195 $trimmed =~ s/,//g; |
196 | 196 |
197 # string to array | 197 # string to array |
(...skipping 10 matching lines...) Expand all Loading... |
208 } | 208 } |
209 | 209 |
210 while (($key, $value) = each(%macro_aliases)) | 210 while (($key, $value) = each(%macro_aliases)) |
211 { | 211 { |
212 $key =~ s/\$/\\\$/; | 212 $key =~ s/\$/\\\$/; |
213 s/$key\b/$value/g; | 213 s/$key\b/$value/g; |
214 } | 214 } |
215 | 215 |
216 # For macros, use \ to reference formal params | 216 # For macros, use \ to reference formal params |
217 # s/\$/\\/g; # End macro definition | 217 # s/\$/\\/g; # End macro definition |
218 s/MEND/.endm/; # No need to tell it where to stop assembling | 218 s/\bMEND\b/.endm/; # No need to tell it where to stop assemblin
g |
219 next if /^\s*END\s*$/; | 219 next if /^\s*END\s*$/; |
220 | 220 |
221 # Clang used by Chromium differs slightly from clang in XCode in what it | 221 # Clang used by Chromium differs slightly from clang in XCode in what it |
222 # will accept in the assembly. | 222 # will accept in the assembly. |
223 if ($chromium) { | 223 if ($chromium) { |
224 s/qsubaddx/qsax/i; | 224 s/qsubaddx/qsax/i; |
225 s/qaddsubx/qasx/i; | 225 s/qaddsubx/qasx/i; |
226 s/ldrneb/ldrbne/i; | 226 s/ldrneb/ldrbne/i; |
227 s/ldrneh/ldrhne/i; | 227 s/ldrneh/ldrhne/i; |
228 s/(vqshrun\.s16 .*, \#)0$/${1}8/i; | 228 s/(vqshrun\.s16 .*, \#)0$/${1}8/i; |
229 | 229 |
230 # http://llvm.org/bugs/show_bug.cgi?id=16022 | 230 # http://llvm.org/bugs/show_bug.cgi?id=16022 |
231 s/\.include/#include/; | 231 s/\.include/#include/; |
232 } | 232 } |
233 | 233 |
234 print; | 234 print; |
235 } | 235 } |
OLD | NEW |