From patchwork Tue Jul 4 14:48:55 2017 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: 106987 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1093716qge; Tue, 4 Jul 2017 07:54:05 -0700 (PDT) X-Received: by 10.237.33.69 with SMTP id 63mr22806533qtc.11.1499180045126; Tue, 04 Jul 2017 07:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499180045; cv=none; d=google.com; s=arc-20160816; b=fBbbtbNIHJWvt/K7ZiiHnvahgcFwDBYXBne2Rqab2fJ9H9/NflHHo1JjDIrSWoicTM /WC1wrSb4Q7EmNafjMA0kBilmlil3F8oUYkuN/XxjsNE5sIFSmX02vtpT1MwrG/Dqg3/ MMN2PldEmJUm54oI+yeSJjbfwknSLSEqdxPxP3LdkDJOgP7V2amZF4w1s2pYQWiVe8Qi gQfnj+IsHytxfu7JVUDBADojmoSWB3UXhIq22on1vSXIDPiGSo+QeN8SYzB+Gm7AhLQn 1I7/7xLkz3D3kmORDwtX1RJRXwtPgQP+572QT9ql2qUO984NEb8oCCRO1rkbXDG3JMpN oqcA== 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=6edPI3sV3IojOpL+0ihRIIsv1ygwoR/EzfaS2rzc4zw=; b=I1M6qTUf1UarDOsb5YYEKZ+MWP0HpITk7nYXrDflFSLsEHaMCpLMdyOwh3YxgiwEu8 QdfQkxLuu05s3ZWD4XhDoO+jfiGSFGR05fc5N4YUI2wfm/Yusix5dl2T4R8kOGAg/+To MLvWB+b7euh15glor3Num1YpLGYhmUFI4+KpkXHECOQe3wp1CngWXLeIPSPzChKV9Adc V8616D5yN6sPDrZ1cMSQvm/R0QeKTx7z6WyI/Iy906XF+cKLjtDFaUwwQXjO4elnvEp3 arr9cQBjICWyRh0FWkZMCkX9QyK/zF0FonpUX+TXK5dVf+fFzPw8C/ONybHSAw2krDil u8ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=Uvwzb/wO; 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 b12si17680014qkg.167.2017.07.04.07.54.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 04 Jul 2017 07:54:05 -0700 (PDT) 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.b=Uvwzb/wO; 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]:41786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSPDG-0004wT-CC for patch@linaro.org; Tue, 04 Jul 2017 10:54:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSP7m-0008G0-9o for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:48:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSP7l-0001BQ-82 for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:48:22 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:35231) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSP7l-0001AT-1r for qemu-devel@nongnu.org; Tue, 04 Jul 2017 10:48:21 -0400 Received: by mail-wm0-x22c.google.com with SMTP id w126so198103673wme.0 for ; Tue, 04 Jul 2017 07:48:20 -0700 (PDT) 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=6edPI3sV3IojOpL+0ihRIIsv1ygwoR/EzfaS2rzc4zw=; b=Uvwzb/wOx4OPlCDlcM6SHi/QS9BeKIvbrT5oGIhl4jhS3sXpZ0Ptn+IwG/UEXkt9+i cpgrFaMMVr5hchVE8SUbMahk96qfqi6lUsI+7+Q4wxgc/ecQuExTFVbHkiYf8yTaoOJs j43DOaGgccbcQdwMFVDbujgmfAFCbGV9pB5ZU= 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=6edPI3sV3IojOpL+0ihRIIsv1ygwoR/EzfaS2rzc4zw=; b=Gm/BsH1qrNgYFTa4CWKJhyk5xXAUqzd6LLhD39drjOHxYgnjhTYvBJcfI/oyC/oR4Q 6zE1WzWLO3ILn1uAe/RNcCtQGN3hytiXjGg4sZqwPHzwJn5SBIi8thb5nGcZE4Z/4vZE K67TMvju06rMTRIb009k9KIGI8TU+DIrymrt+Y/YhPV3UE9F7O8+c+BaDO/0KzbxjLl+ IoyJ6kadQkikbfP7amQPEzO3cRpgjrqRFGOhC0TQb9QctJAJPkHLfVGibkti/CttXJUu q5CvlBZDHZUg9YYphXWKClLLpw/8SV44zSKwaZaYFgJydt2V/ceE8IdYz7advTlR5hKV MckA== X-Gm-Message-State: AIVw110FkT99YrLY7SSrjhmLQj5Mq/Ga5Vq+iQwbO8ObH6rt0i30kewO ULP33eL5y2eYHgIb X-Received: by 10.28.217.3 with SMTP id q3mr9685958wmg.115.1499179699848; Tue, 04 Jul 2017 07:48:19 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d1sm24500266wra.43.2017.07.04.07.48.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 07:48:15 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 17DDE3E21FC; Tue, 4 Jul 2017 15:49:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 4 Jul 2017 15:48:55 +0100 Message-Id: <20170704144859.17644-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170704144859.17644-1-alex.bennee@linaro.org> References: <20170704144859.17644-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:c09::22c Subject: [Qemu-devel] [RISU PATCH 07/11] 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: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , 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 Signed-off-by: Alex Bennée --- risugen | 15 +++++++++++++++ risugen_arm.pm | 7 +++++++ 2 files changed, 22 insertions(+) -- 2.13.0 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;