[libav-devel] [GASPP PATCH] Use the correct variable $line instead of the implicit variable

2018-10-22 Thread Martin Storsjo
This fixes cases if the input parameter is something else than
the currently iterated variable.
---
 gas-preprocessor.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index 41d7b69..39ad08d 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -383,12 +383,12 @@ sub parse_line {
 return if (parse_if_line($line));
 
 if (scalar(@rept_lines) == 0) {
-if (/\.macro/) {
+if ($line =~ /\.macro/) {
 $macro_level++;
 if ($macro_level > 1 && !$current_macro) {
 die "nested macros but we don't have master macro";
 }
-} elsif (/\.endm/) {
+} elsif ($line =~ /\.endm/) {
 $macro_level--;
 if ($macro_level < 0) {
 die "unmatched .endm";
-- 
2.7.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [GASPP PATCH] Add a -verbose option for printing all executed commands

2018-10-22 Thread Martin Storsjo
---
 gas-preprocessor.pl | 9 +
 1 file changed, 9 insertions(+)

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index fd9aac8..41d7b69 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -27,6 +27,7 @@ my $as_type = "apple-gas";
 
 my $fix_unreq = $^O eq "darwin";
 my $force_thumb = 0;
+my $verbose = 0;
 
 my $arm_cond_codes = "eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al|hs|lo";
 
@@ -48,6 +49,7 @@ command. Following options are currently supported:
 -force-thumb  - assemble as thumb regardless of the input source
 (note, this is incomplete and only works for sources
 it explicitly was tested with)
+-verbose  - print executed commands
 ";
 
 sub usage() {
@@ -61,6 +63,8 @@ while (@ARGV) {
 $fix_unreq = $1 ne "no-";
 } elsif ($opt eq "-force-thumb") {
 $force_thumb = 1;
+} elsif ($opt eq "-verbose") {
+$verbose = 1;
 } elsif ($opt eq "-arch") {
 $arch = shift;
 die "unknown arch: '$arch'\n" if not exists $canonical_arch{$arch};
@@ -90,6 +94,7 @@ if (grep /\.c$/, @gcc_cmd) {
 # pass -v/--version along, used during probing. Matching '-v' might have
 # uninteded results but it doesn't matter much if gas-preprocessor or
 # the compiler fails.
+print STDERR join(" ", @gcc_cmd)."\n" if $verbose;
 exec(@gcc_cmd);
 } else {
 die "Unrecognized input filetype";
@@ -115,6 +120,7 @@ if ($as_type eq "armasm") {
 $index++;
 }
 if (grep /^-MM$/, @preprocess_c_cmd) {
+print STDERR join(" ", @preprocess_c_cmd)."\n" if $verbose;
 system(@preprocess_c_cmd) == 0 or die "Error running preprocessor";
 exit 0;
 }
@@ -206,12 +212,14 @@ $comm = ";" if $as_type =~ /armasm/;
 my %ppc_spr = (ctr=> 9,
vrsave => 256);
 
+print STDERR join(" ", @preprocess_c_cmd)."\n" if $verbose;
 open(INPUT, "-|", @preprocess_c_cmd) || die "Error running preprocessor";
 
 if ($ENV{GASPP_DEBUG}) {
 open(ASMFILE, ">");
 } else {
 if ($as_type ne "armasm") {
+print STDERR join(" ", @gcc_cmd)."\n" if $verbose;
 open(ASMFILE, "|-", @gcc_cmd) or die "Error running assembler";
 } else {
 open(ASMFILE, ">", $tempfile);
@@ -1192,6 +1200,7 @@ if ($as_type ne "armasm") {
 close(INPUT) or exit 1;
 close(ASMFILE) or exit 1;
 if ($as_type eq "armasm" and ! defined $ENV{GASPP_DEBUG}) {
+print STDERR join(" ", @gcc_cmd)."\n" if $verbose;
 system(@gcc_cmd) == 0 or die "Error running assembler";
 }
 
-- 
2.7.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [GASPP PATCH 2/2] Don't match whitespace as branch condition codes

2018-10-22 Thread Janne Grunau
On 2018-10-20 00:18:27 +0300, Martin Storsjö wrote:
> For cases like "b1b", this could previously be matched as
> $cond = "  ".
> 
> This fixes preprocessing with a preprocessor that preserves multiple
> consecutive spaces, like cl.exe does.
> ---
> Better fix, which also works in a number of cases where the previous
> version failed.
> ---
>  gas-preprocessor.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
> index b22ee8a..c42412f 100755
> --- a/gas-preprocessor.pl
> +++ b/gas-preprocessor.pl
> @@ -879,7 +879,7 @@ sub handle_serialized_line {
>  
>  
>  # Check branch instructions
> -if ($line =~ 
> /(?:^|\n)\s*(\w+\s*:\s*)?(bl?x?\.?(..)?(\.w)?)\s+(\w+)/) {
> +if ($line =~ 
> /(?:^|\n)\s*(\w+\s*:\s*)?(bl?x?\.?([^\s]{2})?(\.w)?)\s+(\w+)/) {
>  my $instr = $2;
>  my $cond = $3;
>  my $width = $4;

both ok

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [GASPP PATCH] Extend armasm64 workaround for uxtw/sxtw to uxth/sxth and uxtb/sxtb as well

2018-10-22 Thread Janne Grunau
On 2018-10-22 12:51:47 +0300, Martin Storsjö wrote:
> ---
>  gas-preprocessor.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
> index 7efe3b9..669d435 100755
> --- a/gas-preprocessor.pl
> +++ b/gas-preprocessor.pl
> @@ -1011,7 +1011,7 @@ sub handle_serialized_line {
>  
>  # Convert e.g. "add x0, x0, w0, uxtw" into "add x0, x0, w0, uxtw 
> #0",
>  # or "ldr x0, [x0, w0, uxtw]" into "ldr x0, [x0, w0, uxtw #0]".
> -$line =~ s/(uxtw|sxtw)(\s*\]?\s*)$/\1 #0\2/i;
> +$line =~ s/(uxt[whb]|sxt[whb])(\s*\]?\s*)$/\1 #0\2/i;
>  
>  # Convert "mov x0, v0.d[0]" into "umov x0, v0.d[0]"
>  $line =~ s/\bmov\s+[xw]\d+\s*,\s*v\d+\.[ds]/u$&/i;

ok,

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [GASPP PATCH 1/2] Fix the regexp used for replacing .align

2018-10-22 Thread Luca Barbato
On 19/10/2018 23:07, Martin Storsjo wrote:
> The condition above allows multiple spaces, but the actual replacement
> only allowed one space.
> ---
>  gas-preprocessor.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
> index c56301c..b22ee8a 100755
> --- a/gas-preprocessor.pl
> +++ b/gas-preprocessor.pl
> @@ -922,7 +922,7 @@ sub handle_serialized_line {
>  # ALIGN in armasm syntax is the actual number of bytes
>  if ($line =~ /\.(?:p2)?align\s+(\d+)/) {
>  my $align = 1 << $1;
> -$line =~ s/\.(?:p2)?align\s(\d+)/ALIGN $align/;
> +$line =~ s/\.(?:p2)?align\s+(\d+)/ALIGN $align/;
>  }
>  # Convert gas style [r0, :128] into armasm [r0@128] alignment 
> specification
>  $line =~ s/\[([^\[,]+),?\s*:(\d+)\]/[$1\@$2]/g;
> 

I guess it is fine.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [GASPP PATCH] Extend armasm64 workaround for uxtw/sxtw to uxth/sxth and uxtb/sxtb as well

2018-10-22 Thread Luca Barbato
On 22/10/2018 11:51, Martin Storsjo wrote:
> ---
>  gas-preprocessor.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
> index 7efe3b9..669d435 100755
> --- a/gas-preprocessor.pl
> +++ b/gas-preprocessor.pl
> @@ -1011,7 +1011,7 @@ sub handle_serialized_line {
>  
>  # Convert e.g. "add x0, x0, w0, uxtw" into "add x0, x0, w0, uxtw 
> #0",
>  # or "ldr x0, [x0, w0, uxtw]" into "ldr x0, [x0, w0, uxtw #0]".
> -$line =~ s/(uxtw|sxtw)(\s*\]?\s*)$/\1 #0\2/i;
> +$line =~ s/(uxt[whb]|sxt[whb])(\s*\]?\s*)$/\1 #0\2/i;
>  
>  # Convert "mov x0, v0.d[0]" into "umov x0, v0.d[0]"
>  $line =~ s/\bmov\s+[xw]\d+\s*,\s*v\d+\.[ds]/u$&/i;
> 

Seems ok.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [GASPP PATCH 2/2] Don't match whitespace as branch condition codes

2018-10-22 Thread Luca Barbato
On 19/10/2018 23:18, Martin Storsjo wrote:
> For cases like "b1b", this could previously be matched as
> $cond = "  ".
> 
> This fixes preprocessing with a preprocessor that preserves multiple
> consecutive spaces, like cl.exe does.
> ---
> Better fix, which also works in a number of cases where the previous
> version failed.
> ---
>  gas-preprocessor.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
> index b22ee8a..c42412f 100755
> --- a/gas-preprocessor.pl
> +++ b/gas-preprocessor.pl
> @@ -879,7 +879,7 @@ sub handle_serialized_line {
>  
>  
>  # Check branch instructions
> -if ($line =~ 
> /(?:^|\n)\s*(\w+\s*:\s*)?(bl?x?\.?(..)?(\.w)?)\s+(\w+)/) {
> +if ($line =~ 
> /(?:^|\n)\s*(\w+\s*:\s*)?(bl?x?\.?([^\s]{2})?(\.w)?)\s+(\w+)/) {
>  my $instr = $2;
>  my $cond = $3;
>  my $width = $4;
> 

Looks fine.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [GASPP PATCH] Extend armasm64 workaround for uxtw/sxtw to uxth/sxth and uxtb/sxtb as well

2018-10-22 Thread Martin Storsjo
---
 gas-preprocessor.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index 7efe3b9..669d435 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -1011,7 +1011,7 @@ sub handle_serialized_line {
 
 # Convert e.g. "add x0, x0, w0, uxtw" into "add x0, x0, w0, uxtw 
#0",
 # or "ldr x0, [x0, w0, uxtw]" into "ldr x0, [x0, w0, uxtw #0]".
-$line =~ s/(uxtw|sxtw)(\s*\]?\s*)$/\1 #0\2/i;
+$line =~ s/(uxt[whb]|sxt[whb])(\s*\]?\s*)$/\1 #0\2/i;
 
 # Convert "mov x0, v0.d[0]" into "umov x0, v0.d[0]"
 $line =~ s/\bmov\s+[xw]\d+\s*,\s*v\d+\.[ds]/u$&/i;
-- 
2.7.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel