diff options
author | Andy Polyakov <appro@openssl.org> | 2016-06-08 15:37:46 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2016-06-14 22:50:42 +0200 |
commit | 6a4ea0022c475bbc2c7ad98a6f05f6e2e850575b (patch) | |
tree | a20c82cfa35d1c2ac2357a073cbbd40ed791549a /crypto/perlasm | |
parent | c25278db8e4c21772a0cd81f7873e767cbc6d219 (diff) |
perlasm/x86_64-xlate.pl: refactor argument parsing loop.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/perlasm')
-rwxr-xr-x | crypto/perlasm/x86_64-xlate.pl | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/crypto/perlasm/x86_64-xlate.pl b/crypto/perlasm/x86_64-xlate.pl index 646f68058c..f050b23f00 100755 --- a/crypto/perlasm/x86_64-xlate.pl +++ b/crypto/perlasm/x86_64-xlate.pl @@ -317,15 +317,16 @@ my %globals; } { package register; # pick up registers, which start with %. sub re { - my ($class, $line) = @_; + my ($class, $line, $opcode) = @_; my $self = {}; my $ret; - # optional * ---vvv--- appears in indirect jmp/call + # optional * ----vvv--- appears in indirect jmp/call if ($$line =~ /^(\*?)%(\w+)/) { bless $self,$class; $self->{asterisk} = $1; $self->{value} = $2; + $opcode->size($self->size()); $ret = $self; $$line = substr($$line,@+[0]); $$line =~ s/^\s+//; } @@ -892,19 +893,19 @@ while(defined(my $line=<>)) { my @args; ARGUMENT: while (1) { - my $arg; + my $arg; - if ($arg=register->re(\$line)) { $opcode->size($arg->size()); } - elsif ($arg=const->re(\$line)) { } - elsif ($arg=ea->re(\$line, $opcode)) { } - elsif ($arg=expr->re(\$line, $opcode)) { } - else { last ARGUMENT; } + ($arg=register->re(\$line, $opcode))|| + ($arg=const->re(\$line)) || + ($arg=ea->re(\$line, $opcode)) || + ($arg=expr->re(\$line, $opcode)) || + last ARGUMENT; - push @args,$arg; + push @args,$arg; - last ARGUMENT if ($line !~ /^,/); + last ARGUMENT if ($line !~ /^,/); - $line =~ s/^,\s*//; + $line =~ s/^,\s*//; } # ARGUMENT: if ($#args>=0) { |