[libav-commits] Convert ldr/str/ldrb/strb etc into ldurb, when the offset is negative

Martin Storsjo git at libav.org
Wed Oct 18 11:31:13 CEST 2017


Module: gas-preprocessor
Branch: master
Commit: 8f4d04edfb89b349d21cab618eaf1622c0637e29

Author:    Martin Storsjo <martin at martin.st>
Committer: Martin Storsjo <martin at martin.st>
Date:      Mon Oct 16 15:59:39 2017 +0300

Convert ldr/str/ldrb/strb etc into ldurb, when the offset is negative

Gas and clang convert these automatically into the right form,
although it doesn't hurt to update source to use the correct form
from the start (although it might require conditionals in cases where
the actual offset is unclear).

---

 gas-preprocessor.pl | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index f616de3..7644682 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -1024,6 +1024,19 @@ sub handle_serialized_line {
             # variant/combination of prfum tested so far, but it can be
             # left out without any
             $line =~ s/prfum.*\]//;
+
+            # Convert "ldrb w0, [x0, #-1]" into "ldurb w0, [x0, #-1]".
+            # Don't do this for forms with writeback though.
+            if ($line =~ /(ld|st)(r[bh]?)\s+(\w+)\s*,\s*\[\s*(\w+)\s*,\s*#([^\]]+)\s*\][^!]/) {
+              my $instr = $1;
+              my $suffix = $2;
+              my $target = $3;
+              my $base = $4;
+              my $offset = eval_expr($5);
+              if ($offset < 0) {
+                $line =~ s/$instr$suffix/${instr}u$suffix/;
+              }
+            }
         }
         # armasm is unable to parse &0x - add spacing
         $line =~ s/&0x/& 0x/g;



More information about the libav-commits mailing list