From patchwork Fri Feb 23 15:46:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 129424 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp776772lja; Fri, 23 Feb 2018 08:12:00 -0800 (PST) X-Google-Smtp-Source: AG47ELsGUtUsRutvA0SShGmE16hq0AZKQVgSwNdVqvDUenZb7OZfZfP9eWeDMRgygiVoQrfeWMPL X-Received: by 2002:a25:b7c9:: with SMTP id u9-v6mr1419915ybj.294.1519402320562; Fri, 23 Feb 2018 08:12:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519402320; cv=none; d=google.com; s=arc-20160816; b=aXK85CPkEp8GMntsQHPDZNyM6m3RN/1pP/y4tV9+FbPkYXBdo5NrVOzvHk75K+3gJ9 sKHH6hPcSOE1QIvlP9C07btdUJvDcR87W2Noneh6T2IdhUoiDUx0thBUJ3pccvCBi6Qd jhxXaxiP1sy/ojmToK+lCFXhmcvrAIGo590yPapC28ope/0qm2xFtej3Oqt/4cBCxo+N LhJZvRKlEnJViHMwT8qf6oOazkNJ4Xe/q3IP9tEdvhRkhTUzTABbipNemdoApIXL7zZd gqN31/DBNmK8UUoD4TOstvGIB5Lk1Rn5udfKu0/medMCdTOpyDgqr14fEtaIIpxTYqB3 UVZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=042eHVCseG5bJkCjd0/p5J9Kiz1lCnuPUpnjSLFzuqg=; b=Ho9yey7f5Q90Y4rR+BmyXSkRSCPQfP3uxpgaCftSPYkbUVGX+RnuWBD7drg6F3XKAt +9BgPUVUvPnKXhfy5sfITiIpNzMX546nUucQ10eu21l0YQEZRgONXTR5jvwHkfi3uvWL sEI8NhazzpEyZA6QhEXVSfyMFYONBwZYVer36buE6nO/S651m5UWHytHAB2t/IMSJKfW au9Lg6mWkLoYRWBtOlgzXvimJxcAAmYxjgjPueRhbI9/UltKG59S1dgzWR5O4bdx1KyY 1avXrayVArLWJ1wz00ysj5s+mqUWUE71TktIOuB9JgExia5+vyqN1gu3ux9ku5gFEnyo 7wXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=buwfToTh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m12si456974ywi.24.2018.02.23.08.12.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 23 Feb 2018 08:12:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=buwfToTh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45465 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epFx1-0000TV-QM for patch@linaro.org; Fri, 23 Feb 2018 11:11:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epFYB-0003gS-SS for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:46:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1epFY9-00088R-NO for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:46:19 -0500 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:34162) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1epFY9-00086Q-D6 for qemu-devel@nongnu.org; Fri, 23 Feb 2018 10:46:17 -0500 Received: by mail-wr0-x22b.google.com with SMTP id m5so14558495wrg.1 for ; Fri, 23 Feb 2018 07:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=042eHVCseG5bJkCjd0/p5J9Kiz1lCnuPUpnjSLFzuqg=; b=buwfToTh3+aTCe2Io/b1FzqXYi8NvliYZNI5EE8UKXEABAI/YgRTuew/ABkkvM0ESp sf8Davn+RCEZi4tw5trEKjjMct78WGSZhbvi0tXwbErvWIgqb83Z2SivHxFBdeOuD6GO Nk3oYowk4v6k90t6sb3UXnnruKLa11ai5zfcM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=042eHVCseG5bJkCjd0/p5J9Kiz1lCnuPUpnjSLFzuqg=; b=mM+qYf1uigxg3PXuThPCgn6Aqh3Djm/khwW9+6Xg5ezuKRylrOk4Bfxi/S9wEIZ8FL CLGlatcc55ekqwCeodIFKTe0rhigXtQZ3dWsz4IYWS5YjDzJ4zji9wbvOP5Mmcd7ZUmn d1Tkyi81CQDjK6pr840nZpdRBXqZ2lPYh6899dynvKa+Wqy7ONexd4iYKXr3ZrJRdkVx zsgMdGbuFkmO35TqjTUa/LT1J18nmE6c7u2waahpP6Nh8J0V+tbwMtFsnskG3mF2EnyR TxG/PXMRcxO7O8/qcYHC0wbuBe8NJKbSToRIn9yrmRxwmlbMIm7Wj4m/ajE8OFwVDKX8 jmCw== X-Gm-Message-State: APf1xPDGQoPPRzU/0eoO78F3H+Q+pZBZg1DczhUgKXNeeDJ6PAcJKQcR 1HjSlCvJBNsNdbI6BxKtRqe3dQ== X-Received: by 10.223.199.137 with SMTP id l9mr2212465wrg.6.1519400776102; Fri, 23 Feb 2018 07:46:16 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q186sm2264877wmb.33.2018.02.23.07.46.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 07:46:14 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 0A8ED3E0368; Fri, 23 Feb 2018 15:46:14 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 23 Feb 2018 15:46:06 +0000 Message-Id: <20180223154613.2096-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180223154613.2096-1-alex.bennee@linaro.org> References: <20180223154613.2096-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b Subject: [Qemu-devel] [PATCH v1 1/8] risugen: support @GroupName in risu files X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, richard.henderson@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- README | 10 ++++++++++ risugen | 24 +++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) -- 2.15.1 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}, \@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();