]> granicus.if.org Git - libvpx/commitdiff
thumb: Add a parameter for specifying a shift offset for the pc addition conversion
authorMartin Storsjo <martin@martin.st>
Wed, 15 May 2013 14:09:22 +0000 (17:09 +0300)
committerMartin Storsjo <martin@martin.st>
Tue, 21 May 2013 22:50:57 +0000 (01:50 +0300)
The branch instructions are encoded as 16 bit instructions
by the microsoft assembler, while they are encoded as 32 bit
instructions by gnu binutils.

Change-Id: I622b9025df3520c08eef8447df078f5517fb4b67

build/make/ads2armasm_ms.pl
build/make/ads2gas.pl
build/make/thumb.pm

index 2d3e6328fa0f13ce828d303adc81985f5fa7b93d..1def53901d42fb0e214c571b692af2d37f4a40c1 100755 (executable)
@@ -28,7 +28,7 @@ while (<STDIN>)
     s/qsubaddx/qsax/i;
     s/qaddsubx/qasx/i;
 
-    thumb::FixThumbInstructions($_);
+    thumb::FixThumbInstructions($_, 1);
 
     s/ldrneb/ldrbne/i;
     s/ldrneh/ldrhne/i;
index c84941e99475ab108a397ea6edbd7a03bd6e32f1..9c41901295f51ee70febb0b6556d912c2d1fd72f 100755 (executable)
@@ -183,7 +183,7 @@ while (<STDIN>)
     s/(vtbl.\d+\s+[^,]+),([^,]+)/$1,\{$2\}/g;
 
     if ($thumb) {
-        thumb::FixThumbInstructions($_);
+        thumb::FixThumbInstructions($_, 0);
     }
 
     # eabi_attributes numerical equivalents can be found in the
index d04dffe85c1a12b8908b99133d4c972438c862df..f34728743c6f0ae6276e31e03873ca8b94df780e 100644 (file)
 
 package thumb;
 
-sub FixThumbInstructions($)
+sub FixThumbInstructions($$)
 {
+    my $short_branches = $_[1];
+    my $branch_shift_offset = $short_branches ? 1 : 0;
+
     # Write additions with shifts, such as "add r10, r11, lsl #8",
     # in three operand form, "add r10, r10, r11, lsl #8".
     s/(add\s+)(r\d+),\s*(r\d+),\s*(lsl #\d+)/$1$2, $2, $3, $4/g;
@@ -56,7 +59,7 @@ sub FixThumbInstructions($)
     # "itttt lt", "movlt.n r12, pc", "addlt.w r12, #12",
     # "addlt.w r12, r12, r3, lsl #2", "movlt.n pc, r12".
     # This assumes that r12 is free at this point.
-    s/^(\s*)addlt(\s+)pc,\s*pc,\s*(\w+),\s*lsl\s*#(\d+)/$1itttt$2lt\n$1movlt.n$2r12, pc\n$1addlt.w$2r12, #12\n$1addlt.w$2r12, r12, $3, lsl #$4\n$1movlt.n$2pc, r12/g;
+    s/^(\s*)addlt(\s+)pc,\s*pc,\s*(\w+),\s*lsl\s*#(\d+)/$1itttt$2lt\n$1movlt.n$2r12, pc\n$1addlt.w$2r12, #12\n$1addlt.w$2r12, r12, $3, lsl #($4-$branch_shift_offset)\n$1movlt.n$2pc, r12/g;
 
     # Convert "mov pc, lr" into "bx lr", since the former only works
     # for switching from arm to thumb (and only in armv7), but not