From patchwork Tue Oct 31 14:54:42 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: 117637 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp4051219edm; Tue, 31 Oct 2017 07:57:15 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QKkFz+9HJRe9PI1WzxmOfm3mcOMZ7KMwtP/IevXK8h4JHAe4pGypHN9CgoPSJsy3KmD5em X-Received: by 10.129.26.197 with SMTP id a188mr1374253ywa.270.1509461834905; Tue, 31 Oct 2017 07:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509461834; cv=none; d=google.com; s=arc-20160816; b=KuMbRiyCfkCNjCfPYe1/7IUcBvpJWJ13x3HoP1n6uX4GBms7+r7H7dCDqoGhaGdYo/ lKYnMD70oqQAlSKBY3asSBBxzFKHMaelMJ7Ddg8YFkL1i5d8OHPzL3jL8AdqWVqM14jO i0dv5ui5DZD2qB7KPPpxPM07Y14QBaZS/llreI7eS3vwg4O3VTYFZgfnWoRYseX/riMN AHYlSZP0IoWatvnPX1qVv3oejxwURGLiMVMsCC8drLYzt/LFuII9hNzm9xOEE9VyLvHf KeifYc1oPAgnk/bJ1/UxYMdw0sbTIWbmfSOv0XbgK8MaIxV6VlUtr/JIvapLcWIVeI8n Kr/g== 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=cEydfPx65PwbdTZVQ4HV8sNQnw206wmaDJ+KyKBZjTA=; b=a3MyzbxNpKGNLJAGZwuK+LkpG6kUiDINxsYDc4iwkuxhh2nGrU9kwkykGSbz3S58DN gNPXwjVE19J/xMi3m/2oWH4Fijm5kDuUe+IC1+Rcns29Mhur7FjRNb1ASFPhdmo1HS21 JvIxVlZXcXBJqw3C0N3o/KFfWigmGEJxPaj+7PuBg9UlOLu/3VmQj2qQ2dFvtZbfCr++ 9ATEIYpXRAhLOuP41mtBhpOH8AMnb7GTIIwwuwYFm3d490VzqwdTXJKJaBRxAANLo5yv L9hD2G4BR0wVwU5vrrOB+w10QvZojVYPHRimsAoLrYRfe3Yoq2zC4pDGuoftrmtqHbNc DvnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CsK+YOar; 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 w5si442910ywl.511.2017.10.31.07.57.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 31 Oct 2017 07:57:14 -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.s=google header.b=CsK+YOar; 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]:45996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9Xyc-0001qc-7N for patch@linaro.org; Tue, 31 Oct 2017 10:57:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9XwZ-0000ak-H9 for qemu-devel@nongnu.org; Tue, 31 Oct 2017 10:55:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9XwX-000739-T6 for qemu-devel@nongnu.org; Tue, 31 Oct 2017 10:55:07 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:55833) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e9XwX-00072T-Jn for qemu-devel@nongnu.org; Tue, 31 Oct 2017 10:55:05 -0400 Received: by mail-wm0-x244.google.com with SMTP id y83so23682205wmc.4 for ; Tue, 31 Oct 2017 07:55:05 -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=cEydfPx65PwbdTZVQ4HV8sNQnw206wmaDJ+KyKBZjTA=; b=CsK+YOarPpcSC1JZnWbLEFpEmAcZgvE2Y27GBcbRWVxTpr9znZPQyz1ty14nNzUcno WK4As3yx52xJNoFsLJZr+uv94zTDrZ042bzL3zL6nC2g1do23K83nQMmEnEl0/eCd6Af +BfgLW9co1SIblEmyT2tHZBxZ02LOFYfcaEk8= 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=cEydfPx65PwbdTZVQ4HV8sNQnw206wmaDJ+KyKBZjTA=; b=bdj/wJPeC6EqB9zr5InMF3FWi4uAcW1dedZVP4ucPf5dDjyiZq0fMkbPzg2WpOYCPd 3iMbv/vLGds8PnxtHU3dJXCDaSbekfsI1BXHg/bQ0ehEW7FPLQMGt70RYSuOoxQY0lfB QvbCEUtHZuF0aVO5v/6m9fei4MDk5NObaDOHrgSwXpFAusvKxiL4umc2CVP5lHpi+qzE ZIzgMuhKSsrPvx7GTdwfFwcu+jrCIHEw/hRuEpujiaBb+RyOkP14KeVwkl25c98rkYZZ l9ATqHTPwf+Vnz+Khb2GVn8BKUjBmhDMJXxpHNUDBQdLtWqPtAItmqlN9ZFiruyuijT/ QaEg== X-Gm-Message-State: AMCzsaXZnkk2UcuRnmfaOI3CSNVrRk5qva4b13KX5TI9YO1FO7zDfHTm qFybN2bNYd3hSg8GWLdYCEaDzA== X-Received: by 10.28.155.18 with SMTP id d18mr2207577wme.107.1509461704308; Tue, 31 Oct 2017 07:55:04 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k30sm3500874wrf.52.2017.10.31.07.54.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 07:55:03 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id D4E903E0DAA; Tue, 31 Oct 2017 14:54:57 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 31 Oct 2017 14:54:42 +0000 Message-Id: <20171031145444.13766-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171031145444.13766-1-alex.bennee@linaro.org> References: <20171031145444.13766-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::244 Subject: [Qemu-devel] [RISU PATCH 5/7] risugen/risugen_$arch: factor out instruction selection 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" This moves the instruction selection to the common code and passes a list of selection keys to write_test_code instead. This will allow us to add selection features to the common code later. Signed-off-by: Alex Bennée --- risugen | 29 +++++++++++++++++++++++++++-- risugen_arm.pm | 18 +----------------- risugen_m68k.pm | 18 +----------------- risugen_ppc64.pm | 18 +----------------- 4 files changed, 30 insertions(+), 53 deletions(-) -- 2.14.2 diff --git a/risugen b/risugen index 347cf12..8bfb0e9 100755 --- a/risugen +++ b/risugen @@ -26,7 +26,11 @@ use FindBin; use lib "$FindBin::Bin"; use risugen_common; +# insn_details is the full set of instruction definitions whereas +# insn_keys is array of (potentially filtered) keys to index into the +# insn_details hash. my %insn_details; +my @insn_keys; # The arch will be selected based on .mode directive defined in risu file. my $arch = ""; @@ -240,6 +244,26 @@ sub parse_config_file($) close(CFILE) or die "can't close $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; + if (@pattern_re) { + my $re = '\b((' . join(')|(',@pattern_re) . '))\b'; + @insn_keys = grep /$re/, @insn_keys; + } + # exclude any specifics + if (@not_pattern_re) { + my $re = '\b((' . join(')|(',@not_pattern_re) . '))\b'; + @insn_keys = grep !/$re/, @insn_keys; + } + if (!@insn_keys) { + print STDERR "No instruction patterns available! (bad config file or --pattern argument?)\n"; + exit(1); + } +} + sub usage() { print < $numinsns, 'fp_enabled' => $fp_enabled, 'outfile' => $outfile, - 'pattern_re' => \@pattern_re, - 'not_pattern_re' => \@not_pattern_re, 'details' => \%insn_details, + 'keys' => \@insn_keys, 'arch' => $full_arch[0], 'subarch' => $full_arch[1] || '', 'bigendian' => $big_endian diff --git a/risugen_arm.pm b/risugen_arm.pm index 1024660..2f10d58 100644 --- a/risugen_arm.pm +++ b/risugen_arm.pm @@ -895,9 +895,8 @@ sub write_test_code($$$$$$$$) my $fp_enabled = $params->{ 'fp_enabled' }; my $outfile = $params->{ 'outfile' }; - my @pattern_re = @{ $params->{ 'pattern_re' } }; - my @not_pattern_re = @{ $params->{ 'not_pattern_re' } }; my %insn_details = %{ $params->{ 'details' } }; + my @keys = @{ $params->{ 'keys' } }; open_bin($outfile); @@ -908,21 +907,6 @@ sub write_test_code($$$$$$$$) # TODO better random number generator? srand(0); - # Get a list of the insn keys which are permitted by the re patterns - my @keys = sort keys %insn_details; - if (@pattern_re) { - my $re = '\b((' . join(')|(',@pattern_re) . '))\b'; - @keys = grep /$re/, @keys; - } - # exclude any specifics - if (@not_pattern_re) { - my $re = '\b((' . join(')|(',@not_pattern_re) . '))\b'; - @keys = grep !/$re/, @keys; - } - if (!@keys) { - print STDERR "No instruction patterns available! (bad config file or --pattern argument?)\n"; - exit(1); - } print "Generating code using patterns: @keys...\n"; progress_start(78, $numinsns); diff --git a/risugen_m68k.pm b/risugen_m68k.pm index 74e4937..7d62b13 100644 --- a/risugen_m68k.pm +++ b/risugen_m68k.pm @@ -160,9 +160,8 @@ sub write_test_code($) my $numinsns = $params->{ 'numinsns' }; my $outfile = $params->{ 'outfile' }; - my @pattern_re = @{ $params->{ 'pattern_re' } }; - my @not_pattern_re = @{ $params->{ 'not_pattern_re' } }; my %insn_details = %{ $params->{ 'details' } }; + my @keys = @{ $params->{ 'keys' } }; # Specify the order to use for insn32() and insn16() writes. set_endian(1); @@ -176,21 +175,6 @@ sub write_test_code($) # TODO better random number generator? srand(0); - # Get a list of the insn keys which are permitted by the re patterns - my @keys = sort keys %insn_details; - if (@pattern_re) { - my $re = '\b((' . join(')|(',@pattern_re) . '))\b'; - @keys = grep /$re/, @keys; - } - # exclude any specifics - if (@not_pattern_re) { - my $re = '\b((' . join(')|(',@not_pattern_re) . '))\b'; - @keys = grep !/$re/, @keys; - } - if (!@keys) { - print STDERR "No instruction patterns available! (bad config file or --pattern argument?)\n"; - exit(1); - } print "Generating code using patterns: @keys...\n"; progress_start(78, $numinsns); diff --git a/risugen_ppc64.pm b/risugen_ppc64.pm index c0e71cf..b241172 100644 --- a/risugen_ppc64.pm +++ b/risugen_ppc64.pm @@ -371,9 +371,8 @@ sub write_test_code($) my $fp_enabled = $params->{ 'fp_enabled' }; my $outfile = $params->{ 'outfile' }; - my @pattern_re = @{ $params->{ 'pattern_re' } }; - my @not_pattern_re = @{ $params->{ 'not_pattern_re' } }; my %insn_details = %{ $params->{ 'details' } }; + my @keys = @{ $params->{ 'keys' } }; if ($params->{ 'bigendian' } eq 1) { set_endian(1); @@ -388,21 +387,6 @@ sub write_test_code($) # TODO better random number generator? srand(0); - # Get a list of the insn keys which are permitted by the re patterns - my @keys = sort keys %insn_details; - if (@pattern_re) { - my $re = '\b((' . join(')|(',@pattern_re) . '))\b'; - @keys = grep /$re/, @keys; - } - # exclude any specifics - if (@not_pattern_re) { - my $re = '\b((' . join(')|(',@not_pattern_re) . '))\b'; - @keys = grep !/$re/, @keys; - } - if (!@keys) { - print STDERR "No instruction patterns available! (bad config file or --pattern argument?)\n"; - exit(1); - } print "Generating code using patterns: @keys...\n"; progress_start(78, $numinsns);