[x264-devel] [PATCH 11/14] gas-preprocessor: Convert ldr with a too large shift into add+ldr for thumb
Martin Storsjö
martin at martin.st
Fri Mar 24 10:33:43 CET 2017
This only works in the special case when the base register is the
same as the target for the ldr.
---
tools/gas-preprocessor.pl | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/gas-preprocessor.pl b/tools/gas-preprocessor.pl
index 4c2cf9d..afdfc9e 100755
--- a/tools/gas-preprocessor.pl
+++ b/tools/gas-preprocessor.pl
@@ -957,6 +957,14 @@ sub handle_serialized_line {
# Convert "and r0, sp, #xx" into "mov r0, sp", "and r0, r0, #xx"
$line =~ s/and\s+(\w+),\s*(sp|r13)\,\s*#(\w+)/mov $1, $2\n\tand $1, $1, #$3/g;
+ # Convert "ldr r0, [r0, r1, lsl #6]" where the shift is >3 (which
+ # can't be handled in thumb) into "add r0, r0, r1, lsl #6",
+ # "ldr r0, [r0]", for the special case where the same address is
+ # used as base and target for the ldr.
+ if ($line =~ /(ldr[bh]?)\s+(\w+),\s*\[\2,\s*(\w+),\s*lsl\s*#(\w+)\]/ and $4 > 3) {
+ $line =~ s/(ldr[bh]?)\s+(\w+),\s*\[\2,\s*(\w+),\s*lsl\s*#(\w+)\]/add $2, $2, $3, lsl #$4\n\t$1 $2, [$2]/;
+ }
+
$line =~ s/\.arm/.thumb/x;
}
--
2.7.4
More information about the x264-devel
mailing list