perlasm/arm-xlate.pl update (fix end-less loop and prepare for 32-bit iOS).
(Imported from upstream's 7b644df899d0c818488686affc0bfe2dfdd0d0c2) Looking at update_gypi_and_asm.py with git diff -w, the only differences seem to be that .asciz fixed a bug where a space after a ',' got swallowed (sigh). BUG=338886 Change-Id: Ib52296f4a62bc6f892a0d4ee7367493a8c639a3b Reviewed-on: https://boringssl-review.googlesource.com/4480 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
1022dd3d52
commit
15a08fcca2
@ -18,6 +18,32 @@ my $arch = sub {
|
|||||||
if ($flavour =~ /linux/) { ".arch\t".join(',',@_); }
|
if ($flavour =~ /linux/) { ".arch\t".join(',',@_); }
|
||||||
else { ""; }
|
else { ""; }
|
||||||
};
|
};
|
||||||
|
my $fpu = sub {
|
||||||
|
if ($flavour =~ /linux/) { ".fpu\t".join(',',@_); }
|
||||||
|
else { ""; }
|
||||||
|
};
|
||||||
|
my $hidden = sub {
|
||||||
|
if ($flavour =~ /ios/) { ".private_extern\t".join(',',@_); }
|
||||||
|
else { ".hidden\t".join(',',@_); }
|
||||||
|
};
|
||||||
|
my $comm = sub {
|
||||||
|
my @args = split(/,\s*/,shift);
|
||||||
|
my $name = @args[0];
|
||||||
|
my $global = \$GLOBALS{$name};
|
||||||
|
my $ret;
|
||||||
|
|
||||||
|
if ($flavour =~ /ios32/) {
|
||||||
|
$ret = ".comm\t_$name,@args[1]\n";
|
||||||
|
$ret .= ".non_lazy_symbol_pointer\n";
|
||||||
|
$ret .= "$name:\n";
|
||||||
|
$ret .= ".indirect_symbol\t_$name\n";
|
||||||
|
$ret .= ".long\t0";
|
||||||
|
$name = "_$name";
|
||||||
|
} else { $ret = ".comm\t".join(',',@args); }
|
||||||
|
|
||||||
|
$$global = $name;
|
||||||
|
$ret;
|
||||||
|
};
|
||||||
my $globl = sub {
|
my $globl = sub {
|
||||||
my $name = shift;
|
my $name = shift;
|
||||||
my $global = \$GLOBALS{$name};
|
my $global = \$GLOBALS{$name};
|
||||||
@ -64,44 +90,43 @@ sub range {
|
|||||||
join(",",map("$r$_$sfx",($start..$end)));
|
join(",",map("$r$_$sfx",($start..$end)));
|
||||||
}
|
}
|
||||||
|
|
||||||
sub parse_args {
|
sub expand_line {
|
||||||
my $line = shift;
|
my $line = shift;
|
||||||
my @ret = ();
|
my @ret = ();
|
||||||
|
|
||||||
pos($line)=0;
|
pos($line)=0;
|
||||||
|
|
||||||
while (1) {
|
while ($line =~ m/\G[^@\/\{\"]*/g) {
|
||||||
if ($line =~ m/\G\[/gc) {
|
if ($line =~ m/\G(@|\/\/|$)/gc) {
|
||||||
$line =~ m/\G([^\]]+\][^,]*)\s*/g;
|
last;
|
||||||
push @ret,"[$1";
|
|
||||||
}
|
}
|
||||||
elsif ($line =~ m/\G\{/gc) {
|
elsif ($line =~ m/\G\{/gc) {
|
||||||
$line =~ m/\G([^\}]+\}[^,]*)\s*/g;
|
my $saved_pos = pos($line);
|
||||||
my $arg = $1;
|
$line =~ s/\G([rdqv])([0-9]+)([^\-]*)\-\1([0-9]+)\3/range($1,$3,$2,$4)/e;
|
||||||
$arg =~ s/([rdqv])([0-9]+)([^\-]*)\-\1([0-9]+)\3/range($1,$3,$2,$4)/ge;
|
pos($line) = $saved_pos;
|
||||||
push @ret,"{$arg";
|
$line =~ m/\G[^\}]*\}/g;
|
||||||
|
}
|
||||||
|
elsif ($line =~ m/\G\"/gc) {
|
||||||
|
$line =~ m/\G[^\"]*\"/g;
|
||||||
}
|
}
|
||||||
elsif ($line =~ m/\G([^,]+)\s*/g) {
|
|
||||||
push @ret,$1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
last if ($line =~ m/\G$/gc);
|
$line =~ s/\b(\w+)/$GLOBALS{$1} or $1/ge;
|
||||||
|
|
||||||
$line =~ m/\G,\s*/g;
|
return $line;
|
||||||
}
|
|
||||||
|
|
||||||
map {my $s=$_;$s=~s/\b(\w+)/$GLOBALS{$1} or $1/ge;$s} @ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while($line=<>) {
|
while($line=<>) {
|
||||||
|
|
||||||
|
if ($line =~ m/^\s*(#|@|\/\/)/) { print $line; next; }
|
||||||
|
|
||||||
$line =~ s|/\*.*\*/||; # get rid of C-style comments...
|
$line =~ s|/\*.*\*/||; # get rid of C-style comments...
|
||||||
$line =~ s|^\s+||; # ... and skip white spaces in beginning...
|
$line =~ s|^\s+||; # ... and skip white spaces in beginning...
|
||||||
$line =~ s|\s+$||; # ... and at the end
|
$line =~ s|\s+$||; # ... and at the end
|
||||||
|
|
||||||
{
|
{
|
||||||
$line =~ s|[\b\.]L(\w+)|L$1|g; # common denominator for Locallabel
|
$line =~ s|[\b\.]L(\w{2,})|L$1|g; # common denominator for Locallabel
|
||||||
$line =~ s|\bL(\w+)|\.L$1|g if ($dotinlocallabels);
|
$line =~ s|\bL(\w{2,})|\.L$1|g if ($dotinlocallabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -112,24 +137,24 @@ while($line=<>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($line !~ m/^#/o) {
|
if ($line !~ m/^[#@]/) {
|
||||||
$line =~ s|^\s*(\.?)(\S+)\s*||o;
|
$line =~ s|^\s*(\.?)(\S+)\s*||;
|
||||||
my $c = $1; $c = "\t" if ($c eq "");
|
my $c = $1; $c = "\t" if ($c eq "");
|
||||||
my $mnemonic = $2;
|
my $mnemonic = $2;
|
||||||
my $opcode;
|
my $opcode;
|
||||||
if ($mnemonic =~ m/([^\.]+)\.([^\.]+)/o) {
|
if ($mnemonic =~ m/([^\.]+)\.([^\.]+)/) {
|
||||||
$opcode = eval("\$$1_$2");
|
$opcode = eval("\$$1_$2");
|
||||||
} else {
|
} else {
|
||||||
$opcode = eval("\$$mnemonic");
|
$opcode = eval("\$$mnemonic");
|
||||||
}
|
}
|
||||||
|
|
||||||
my @args=parse_args($line);
|
my $arg=expand_line($line);
|
||||||
|
|
||||||
if (ref($opcode) eq 'CODE') {
|
if (ref($opcode) eq 'CODE') {
|
||||||
$line = &$opcode(@args);
|
$line = &$opcode($arg);
|
||||||
} elsif ($mnemonic) {
|
} elsif ($mnemonic) {
|
||||||
$line = $c.$mnemonic;
|
$line = $c.$mnemonic;
|
||||||
$line.= "\t".join(',',@args) if ($#args>=0);
|
$line.= "\t$arg" if ($arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user