OLD | NEW |
1 #!/usr/bin/perl | 1 #!/usr/bin/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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 # Convert :NOT: to ~ | 54 # Convert :NOT: to ~ |
55 s/:NOT:/ ~ /g; | 55 s/:NOT:/ ~ /g; |
56 | 56 |
57 # Convert :SHL: to << | 57 # Convert :SHL: to << |
58 s/:SHL:/ << /g; | 58 s/:SHL:/ << /g; |
59 | 59 |
60 # Convert :SHR: to >> | 60 # Convert :SHR: to >> |
61 s/:SHR:/ >> /g; | 61 s/:SHR:/ >> /g; |
62 | 62 |
63 # Convert ELSE to .else | 63 # Convert ELSE to .else |
64 s/ELSE/.else/g; | 64 s/\bELSE\b/.else/g; |
65 | 65 |
66 # Convert ENDIF to .endif | 66 # Convert ENDIF to .endif |
67 s/ENDIF/.endif/g; | 67 s/\bENDIF\b/.endif/g; |
68 | 68 |
69 # Convert ELSEIF to .elseif | 69 # Convert ELSEIF to .elseif |
70 s/ELSEIF/.elseif/g; | 70 s/\bELSEIF\b/.elseif/g; |
71 | 71 |
72 # Convert LTORG to .ltorg | 72 # Convert LTORG to .ltorg |
73 s/LTORG/.ltorg/g; | 73 s/\bLTORG\b/.ltorg/g; |
74 | 74 |
75 # Convert endfunc to nothing. | 75 # Convert endfunc to nothing. |
76 s/endfunc//ig; | 76 s/\bendfunc\b//ig; |
77 | 77 |
78 # Convert FUNCTION to nothing. | 78 # Convert FUNCTION to nothing. |
79 s/FUNCTION//g; | 79 s/\bFUNCTION\b//g; |
80 s/function//g; | 80 s/\bfunction\b//g; |
81 | 81 |
82 s/ENTRY//g; | 82 s/\bENTRY\b//g; |
83 s/MSARMASM/0/g; | 83 s/\bMSARMASM\b/0/g; |
84 s/^\s+end\s+$//g; | 84 s/^\s+end\s+$//g; |
85 | 85 |
86 # Convert IF :DEF:to .if | 86 # Convert IF :DEF:to .if |
87 # gcc doesn't have the ability to do a conditional | 87 # gcc doesn't have the ability to do a conditional |
88 # if defined variable that is set by IF :DEF: on | 88 # if defined variable that is set by IF :DEF: on |
89 # armasm, so convert it to a normal .if and then | 89 # armasm, so convert it to a normal .if and then |
90 # make sure to define a value elesewhere | 90 # make sure to define a value elesewhere |
91 if (s/\bIF :DEF:\b/.if /g) | 91 if (s/\bIF :DEF:\b/.if /g) |
92 { | 92 { |
93 s/=/==/g; | 93 s/=/==/g; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 # s/^(\w+)/$1:/ if !/EQU/; | 147 # s/^(\w+)/$1:/ if !/EQU/; |
148 # put the colon at the end of the line in the macro | 148 # put the colon at the end of the line in the macro |
149 s/^([a-zA-Z_0-9\$]+)/$1:/ if !/EQU/; | 149 s/^([a-zA-Z_0-9\$]+)/$1:/ if !/EQU/; |
150 | 150 |
151 # ALIGN directive | 151 # ALIGN directive |
152 s/\bALIGN\b/.balign/g; | 152 s/\bALIGN\b/.balign/g; |
153 | 153 |
154 # ARM code | 154 # ARM code |
155 s/\sARM/.arm/g; | 155 s/\sARM/.arm/g; |
156 | 156 |
| 157 # push/pop |
| 158 s/(push\s+)(r\d+)/stmdb sp\!, \{$2\}/g; |
| 159 s/(pop\s+)(r\d+)/ldmia sp\!, \{$2\}/g; |
| 160 |
157 # NEON code | 161 # NEON code |
158 s/(vld1.\d+\s+)(q\d+)/$1\{$2\}/g; | 162 s/(vld1.\d+\s+)(q\d+)/$1\{$2\}/g; |
159 s/(vtbl.\d+\s+[^,]+),([^,]+)/$1,\{$2\}/g; | 163 s/(vtbl.\d+\s+[^,]+),([^,]+)/$1,\{$2\}/g; |
160 | 164 |
161 # eabi_attributes numerical equivalents can be found in the | 165 # eabi_attributes numerical equivalents can be found in the |
162 # "ARM IHI 0045C" document. | 166 # "ARM IHI 0045C" document. |
163 | 167 |
164 # REQUIRE8 Stack is required to be 8-byte aligned | 168 # REQUIRE8 Stack is required to be 8-byte aligned |
165 s/\sREQUIRE8/.eabi_attribute 24, 1 \@Tag_ABI_align_needed/g; | 169 s/\sREQUIRE8/.eabi_attribute 24, 1 \@Tag_ABI_align_needed/g; |
166 | 170 |
(...skipping 15 matching lines...) Expand all Loading... |
182 my $proc; | 186 my $proc; |
183 s/\bENDP\b/@ $&/; | 187 s/\bENDP\b/@ $&/; |
184 $proc = pop(@proc_stack); | 188 $proc = pop(@proc_stack); |
185 $_ = "\t.size $proc, .-$proc".$_ if ($proc); | 189 $_ = "\t.size $proc, .-$proc".$_ if ($proc); |
186 } | 190 } |
187 | 191 |
188 # EQU directive | 192 # EQU directive |
189 s/(\S+\s+)EQU(\s+\S+)/.equ $1, $2/; | 193 s/(\S+\s+)EQU(\s+\S+)/.equ $1, $2/; |
190 | 194 |
191 # Begin macro definition | 195 # Begin macro definition |
192 if (/MACRO/) { | 196 if (/\bMACRO\b/) { |
193 $_ = <STDIN>; | 197 $_ = <STDIN>; |
194 s/^/.macro/; | 198 s/^/.macro/; |
195 s/\$//g; # remove formal param reference | 199 s/\$//g; # remove formal param reference |
196 s/;/@/g; # change comment characters | 200 s/;/@/g; # change comment characters |
197 } | 201 } |
198 | 202 |
199 # For macros, use \ to reference formal params | 203 # For macros, use \ to reference formal params |
200 s/\$/\\/g; # End macro definition | 204 s/\$/\\/g; # End macro definition |
201 s/MEND/.endm/; # No need to tell it where to stop assembling | 205 s/\bMEND\b/.endm/; # No need to tell it where to stop assemblin
g |
202 next if /^\s*END\s*$/; | 206 next if /^\s*END\s*$/; |
203 print; | 207 print; |
204 print "$comment_sub$comment\n" if defined $comment; | 208 print "$comment_sub$comment\n" if defined $comment; |
205 } | 209 } |
206 | 210 |
207 # Mark that this object doesn't need an executable stack. | 211 # Mark that this object doesn't need an executable stack. |
208 printf ("\t.section\t.note.GNU-stack,\"\",\%\%progbits\n"); | 212 printf ("\t.section\t.note.GNU-stack,\"\",\%\%progbits\n"); |
OLD | NEW |