[11/20] Factorize code for checking whether a label is a register

Message ID 1395664691-60544-11-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö March 24, 2014, 12:38 p.m.
---
 gas-preprocessor.pl | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Janne Grunau March 24, 2014, 3:05 p.m. | #1
On 2014-03-24 14:38:02 +0200, Martin Storsjö wrote:
> ---
>  gas-preprocessor.pl | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
> index 27a84b7..3bdc7dd 100755
> --- a/gas-preprocessor.pl
> +++ b/gas-preprocessor.pl
> @@ -605,6 +605,16 @@ my %labels_seen;
>  
>  my %aarch64_req_alias;
>  
> +sub is_register {

maybe is_arm_register? not really important since it's not used
outside of arm context. otherwise ok

Janne

Patch

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index 27a84b7..3bdc7dd 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -605,6 +605,16 @@  my %labels_seen;
 
 my %aarch64_req_alias;
 
+sub is_register {
+    my $name = $_[0];
+    if ($name eq "lr" or
+        $name eq "ip" or
+        $name =~ /^[rav]\d+$/) {
+        return 1;
+    }
+    return 0;
+}
+
 # pass 2
 foreach my $line (@pass1_lines) {
     # handle .previous (only with regard to .section not .subsection)
@@ -836,9 +846,7 @@  foreach my $line (@pass1_lines) {
                     push(@{$next_temp_labels{$num}}, $name);
                     $line =~ s/$target/$name/;
                 }
-            } elsif ($target ne "lr" and
-                     $target ne "ip" and
-                     $target !~ /^[rav]\d+$/) {
+            } elsif (!is_register($target)) {
                 $call_targets{$target}++;
             }
         }