diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2018-02-23 15:46:06 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2018-02-23 18:06:34 +0000 |
commit | a14740a8961caa58041d78925822f065555d875a (patch) | |
tree | a3992c526cd498e67117498995723476c6690e9e /risugen | |
parent | 8ff81e2a848ba9033397568cee335bb4a9de74c2 (diff) |
risugen: support @GroupName in risu files
The existing pattern support is useful but it does get a little
tedious when faced with large groups of instructions. This introduces
the concept of a @GroupName which can be sprinkled in the risu
definition and is attached to all instructions following its
definition until the next group or an empty group "@" is specified.
It can be combined with the existing pattern support to do things
like:
./risugen --group AdvSIMDAcrossVector --not-pattern ".*_RES" aarch64.risu foo.bin
Multiple groups will further restrict the set, so for example:
./risugen --group v8.2,Cryptographic aarch64.risu v8.2-crypto.bin
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 20180223154613.2096-2-alex.bennee@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'risugen')
-rwxr-xr-x | risugen | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -20,6 +20,7 @@ use Getopt::Long; use Data::Dumper; use Module::Load; use Text::Balanced qw { extract_bracketed extract_multiple }; +use List::Compare::Functional qw( get_intersection ); # Make sure we can find the per-CPU-architecture modules in the # same directory as this script. use FindBin; @@ -34,7 +35,10 @@ my @insn_keys; # The arch will be selected based on .mode directive defined in risu file. my $arch = ""; +# Current groups, updated by @GroupName +my @insn_groups; +my @groups = (); # include groups my @pattern_re = (); # include pattern my @not_pattern_re = (); # exclude pattern @@ -122,6 +126,11 @@ sub parse_config_file($) exit(1); } + if ($tokens[0] =~ /^@(.*)/ ) { + @insn_groups = split(/,/, $1); + next; + } + if ($tokens[0] =~ /^\./) { parse_risu_directive($file, $seen_pattern, @tokens); next; @@ -239,6 +248,9 @@ sub parse_config_file($) $insnrec->{fixedbits} = $fixedbits; $insnrec->{fixedbitmask} = $fixedbitmask; $insnrec->{fields} = [ @fields ]; + if (@insn_groups) { + $insnrec->{groups} = [ @insn_groups ]; + } $insn_details{$insnname} = $insnrec; } close(CFILE) or die "can't close $file: $!"; @@ -247,8 +259,15 @@ sub parse_config_file($) # Select a subset of instructions based on our filter preferences sub select_insn_keys () { - # Get a list of the insn keys which are permitted by the re patterns @insn_keys = sort keys %insn_details; + # Limit insn keys to those in all reqested @groups + if (@groups) { + @insn_keys = grep { + defined($insn_details{$_}->{groups}) && + scalar @groups == get_intersection([$insn_details{$_}->{groups}, \@groups]) + } @insn_keys + } + # Get a list of the insn keys which are permitted by the re patterns if (@pattern_re) { my $re = '\b((' . join(')|(',@pattern_re) . '))\b'; @insn_keys = grep /$re/, @insn_keys; @@ -277,6 +296,7 @@ Valid options: --fpscr n : set initial FPSCR (arm) or FPCR (aarch64) value (default is 0) --condprob p : [ARM only] make instructions conditional with probability p (default is 0, ie all instructions are always executed) + --group name[,name..]: only use instructions in all defined groups --pattern re[,re...] : only use instructions matching regular expression Each re must match a full word (that is, we match on the perl regex '\\b((re)|(re))\\b'). This means that @@ -305,6 +325,7 @@ sub main() GetOptions( "help" => sub { usage(); exit(0); }, "numinsns=i" => \$numinsns, "fpscr=o" => \$fpscr, + "group=s" => \@groups, "pattern=s" => \@pattern_re, "not-pattern=s" => \@not_pattern_re, "condprob=f" => sub { @@ -319,6 +340,7 @@ sub main() # allow "--pattern re,re" and "--pattern re --pattern re" @pattern_re = split(/,/,join(',',@pattern_re)); @not_pattern_re = split(/,/,join(',',@not_pattern_re)); + @groups = split(/,/,join(',',@groups)); if ($#ARGV != 1) { usage(); |