From: "Alex Bennée" <alex.bennee@linaro.org>
To: peter.maydell@linaro.org
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [RISU PATCH 07/11] risugen: support @GroupName in risu files
Date: Tue, 4 Jul 2017 15:48:55 +0100 [thread overview]
Message-ID: <20170704144859.17644-8-alex.bennee@linaro.org> (raw)
In-Reply-To: <20170704144859.17644-1-alex.bennee@linaro.org>
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
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
risugen | 15 +++++++++++++++
risugen_arm.pm | 7 +++++++
2 files changed, 22 insertions(+)
diff --git a/risugen b/risugen
index 347cf12..97ffa83 100755
--- a/risugen
+++ b/risugen
@@ -30,7 +30,10 @@ my %insn_details;
# The arch will be selected based on .mode directive defined in risu file.
my $arch = "";
+# Current group, updated by @GroupName
+my $insn_group = "";
+my @group = (); # include groups
my @pattern_re = (); # include pattern
my @not_pattern_re = (); # exclude pattern
@@ -118,6 +121,11 @@ sub parse_config_file($)
exit(1);
}
+ if ($tokens[0] =~ /^@(.*)/ ) {
+ $insn_group = $1;
+ next;
+ }
+
if ($tokens[0] =~ /^\./) {
parse_risu_directive($file, $seen_pattern, @tokens);
next;
@@ -235,6 +243,9 @@ sub parse_config_file($)
$insnrec->{fixedbits} = $fixedbits;
$insnrec->{fixedbitmask} = $fixedbitmask;
$insnrec->{fields} = [ @fields ];
+ if (length $insn_group) {
+ $insnrec->{group} = $insn_group;
+ }
$insn_details{$insnname} = $insnrec;
}
close(CFILE) or die "can't close $file: $!";
@@ -253,6 +264,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 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
@@ -281,6 +293,7 @@ sub main()
GetOptions( "help" => sub { usage(); exit(0); },
"numinsns=i" => \$numinsns,
"fpscr=o" => \$fpscr,
+ "group=s" => \@group,
"pattern=s" => \@pattern_re,
"not-pattern=s" => \@not_pattern_re,
"condprob=f" => sub {
@@ -295,6 +308,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));
+ @group = split(/,/,join(',',@group));
if ($#ARGV != 1) {
usage();
@@ -316,6 +330,7 @@ sub main()
'numinsns' => $numinsns,
'fp_enabled' => $fp_enabled,
'outfile' => $outfile,
+ 'group' => \@group,
'pattern_re' => \@pattern_re,
'not_pattern_re' => \@not_pattern_re,
'details' => \%insn_details,
diff --git a/risugen_arm.pm b/risugen_arm.pm
index 1024660..8ad208a 100644
--- a/risugen_arm.pm
+++ b/risugen_arm.pm
@@ -895,6 +895,7 @@ sub write_test_code($$$$$$$$)
my $fp_enabled = $params->{ 'fp_enabled' };
my $outfile = $params->{ 'outfile' };
+ my @group = @{ $params->{ 'group' } };
my @pattern_re = @{ $params->{ 'pattern_re' } };
my @not_pattern_re = @{ $params->{ 'not_pattern_re' } };
my %insn_details = %{ $params->{ 'details' } };
@@ -910,6 +911,12 @@ sub write_test_code($$$$$$$$)
# Get a list of the insn keys which are permitted by the re patterns
my @keys = sort keys %insn_details;
+ if (@group) {
+ my $re = join("|",@group);
+ @keys = grep {
+ defined($insn_details{$_}->{group}) &&
+ grep /$re/, $insn_details{$_}->{group}} @keys
+ }
if (@pattern_re) {
my $re = '\b((' . join(')|(',@pattern_re) . '))\b';
@keys = grep /$re/, @keys;
--
2.13.0
next prev parent reply other threads:[~2017-07-04 14:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-04 14:48 [Qemu-devel] [RISU PATCH 00/11] Misc fixes, documentation and patterns Alex Bennée
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 01/11] risu: make match status take tracing into account Alex Bennée
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 02/11] reginfo.c: always return 1 on OP_TESTEND Alex Bennée
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 03/11] README: document --static builds Alex Bennée
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 04/11] README: document record/replay support Alex Bennée
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 05/11] risu.el: derive from text-mode Alex Bennée
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 06/11] risugen: fix bad indent Alex Bennée
2017-07-04 14:48 ` Alex Bennée [this message]
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 08/11] aarch64.risu: document naming conventions Alex Bennée
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 09/11] aarch64.risu: remove duplicate AdvSIMD Scalar 3 same block Alex Bennée
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 10/11] aarch64.risu: remove duplicate AdvSIMD scalar 2 reg misc block Alex Bennée
2017-07-04 14:48 ` [Qemu-devel] [RISU PATCH 11/11] aarch64.risu: update AdvancedSIMD across lanes Alex Bennée
2017-07-10 16:57 ` [Qemu-devel] [RISU PATCH 00/11] Misc fixes, documentation and patterns Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170704144859.17644-8-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).