[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 1/8] risugen: support @GroupName in risu files
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PATCH v1 1/8] risugen: support @GroupName in risu files |
Date: |
Fri, 23 Feb 2018 15:46:06 +0000 |
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 <address@hidden>
---
README | 10 ++++++++++
risugen | 24 +++++++++++++++++++++++-
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/README b/README
index e90d33c..35e8b29 100644
--- a/README
+++ b/README
@@ -81,6 +81,10 @@ reads the configuration file arm.risu, and generates 10000
instructions
based on the instruction patterns matching the regular expression
"VQSHL.*imm.*". The resulting binary is written to vqshlimm.out.
+An alternative to using regular expression patterns is to use the
+--group specifier. This relies on the configuration file having been
+annotated with suitable @ markers.
+
This binary can then be passed to the risu program, which is
written in C. You need to run risu on both an ARM native target
and on the program under test. The ARM native system is the 'master'
@@ -146,6 +150,12 @@ Lines starting with a '.' are directives to risu/risugen:
* ".mode [thumb|arm]" specifies whether the file contains ARM
or Thumb instructions; it must precede all instruction patterns.
+Lines starting with a '@' are a grouping directive. Instructions
+following will be assigned to a comma separated list of groups. The
+list of groups is reset at the next '@' directive which may be empty.
+This provides an alternative method to selecting instructions than RE
+patterns.
+
Other lines are instruction patterns:
insnname encodingname bitfield ... [ [ !blockname ] { blocktext } ]
where each bitfield is either:
diff --git a/risugen b/risugen
index 8bfb0e9..488d804 100755
--- a/risugen
+++ b/risugen
@@ -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}, address@hidden)
+ } @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" => address@hidden,
"pattern=s" => address@hidden,
"not-pattern=s" => address@hidden,
"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();
--
2.15.1
- [Qemu-devel] [PATCH REPOST v1 0/8] Group support and random clean-ups, Alex Bennée, 2018/02/23
- [Qemu-devel] [PATCH v1 3/8] aarch64.risu: add cryptographic extensions for v8.2, Alex Bennée, 2018/02/23
- [Qemu-devel] [PATCH v1 1/8] risugen: support @GroupName in risu files,
Alex Bennée <=
- [Qemu-devel] [PATCH v1 5/8] contrib/run_risu.sh: allow appending of QEMU_FLAGS, Alex Bennée, 2018/02/23
- [Qemu-devel] [PATCH v1 6/8] contrib/run_risu.sh: don't set -e, Alex Bennée, 2018/02/23
- [Qemu-devel] [PATCH v1 4/8] new contrib/generate_all.sh: batch risugen script, Alex Bennée, 2018/02/23
- Re: [Qemu-devel] [PATCH v1 4/8] new contrib/generate_all.sh: batch risugen script, Daniel P . Berrangé, 2018/02/23
- Re: [Qemu-devel] [PATCH v1 4/8] new contrib/generate_all.sh: batch risugen script, Peter Maydell, 2018/02/23
- Re: [Qemu-devel] [PATCH v1 4/8] new contrib/generate_all.sh: batch risugen script, Alex Bennée, 2018/02/23
- Re: [Qemu-devel] [PATCH v1 4/8] new contrib/generate_all.sh: batch risugen script, Daniel P . Berrangé, 2018/02/23
- Re: [Qemu-devel] [PATCH v1 4/8] new contrib/generate_all.sh: batch risugen script, Peter Maydell, 2018/02/23
- Re: [Qemu-devel] [PATCH v1 4/8] new contrib/generate_all.sh: batch risugen script, Daniel P . Berrangé, 2018/02/23