qemu-arm.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: peter.maydell@linaro.org
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
	richard.henderson@linaro.org,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: [PATCH v1 4/8] new contrib/generate_all.sh: batch risugen script
Date: Fri, 23 Feb 2018 15:46:09 +0000	[thread overview]
Message-ID: <20180223154613.2096-5-alex.bennee@linaro.org> (raw)
In-Reply-To: <20180223154613.2096-1-alex.bennee@linaro.org>

This is a simple script for generating all instructions in a given
RISU file. You can split up the batch size by passing a -n N command
line options. For example:

  ./contrib/generate_all.sh -n 2 hp.risu testcases.armv8.2_hp

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 contrib/generate_all.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100755 contrib/generate_all.sh

diff --git a/contrib/generate_all.sh b/contrib/generate_all.sh
new file mode 100755
index 0000000..1e6b847
--- /dev/null
+++ b/contrib/generate_all.sh
@@ -0,0 +1,96 @@
+#!/bin/bash
+#
+# Generate all patterns in a given RISU file
+#
+# Copyright (c) 2017 Linaro Limited
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Alex Bennée <alex.bennee@linaro.org> - initial implementation
+#
+# Usage:
+#   ./contrib/generate_all.sh <arch.risu> <target directory>
+
+set -e
+
+USAGE="Usage: `basename $0` [-h] [-n x] <risufile> <target dir>"
+SPLIT=4
+RISUGEN=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P)/risugen
+
+# Parse command line options.
+while getopts hn: OPT; do
+    case "$OPT" in
+        h)
+            echo $USAGE
+            exit 0
+            ;;
+        n)
+            SPLIT=$OPTARG
+            ;;
+        \?)
+            # getopts issues an error message
+            echo $USAGE >&2
+            exit 1
+            ;;
+    esac
+done
+
+# Remove the switches we parsed above.
+shift `expr $OPTIND - 1`
+
+while [ $# -ne 0 ]; do
+
+    if [ -f $1 ]; then
+        RISU_FILE=$1;
+    elif [ -d $1 ]; then
+        TARGET_DIR=$1;
+    elif [ ! -e $1 ]; then
+        TARGET_DIR=$1
+    fi
+
+    shift
+done
+
+if test -z "${RISUGEN}" || test ! -x "${RISUGEN}";  then
+    echo "Couldn't find risugen (${RISUGEN})"
+    exit 1
+fi
+
+if [ -z "$RISU_FILE" ]; then
+    echo "Need to set a .risu file for patterns"
+    exit 1
+fi
+
+if [ -z "${TARGET_DIR}" ]; then
+    echo "Need to set a TARGET_DIR"
+    exit 1
+fi
+
+
+mkdir -p ${TARGET_DIR}
+
+ALL_INSNS=$(cat ${RISU_FILE} | ag "^\w" | cut -f 1 -d " " | sort)
+COUNT=$(cat ${RISU_FILE=} | ag "^\w" | cut -f 1 -d " " | wc -l)
+set -- $ALL_INSNS
+
+GROUP=$((COUNT / ${SPLIT}))
+
+while test $# -gt 0 ; do
+    INSN_PATTERNS=""
+    I_FILE="${TARGET_DIR}/insn_"
+    for i in `seq 1 ${SPLIT}`; do
+        I=$1
+        if test -n "${I}"; then
+            shift
+            INSN_PATTERNS="${INSN_PATTERNS} --pattern ${I}"
+            I_FILE="${I_FILE}${I}_"
+        fi
+    done
+    I_FILE="${I_FILE}_INC.risu.bin"
+    CMD="${RISUGEN} ${INSN_PATTERNS} ${RISU_FILE} ${I_FILE}"
+    echo "Running: $CMD"
+    $CMD
+done
-- 
2.15.1

  parent reply	other threads:[~2018-02-23 15:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 15:46 [PATCH REPOST v1 0/8] Group support and random clean-ups Alex Bennée
2018-02-23 15:46 ` [PATCH v1 1/8] risugen: support @GroupName in risu files Alex Bennée
2018-02-23 15:46 ` [PATCH v1 2/8] aarch64.risu: clean-up and annotate with groups Alex Bennée
2018-02-23 15:46 ` [PATCH v1 3/8] aarch64.risu: add cryptographic extensions for v8.2 Alex Bennée
2018-02-23 18:17   ` Peter Maydell
2018-02-23 15:46 ` Alex Bennée [this message]
2018-02-23 16:17   ` [Qemu-devel] [PATCH v1 4/8] new contrib/generate_all.sh: batch risugen script Daniel P. Berrangé
2018-02-23 16:42     ` Peter Maydell
2018-02-23 16:45     ` Alex Bennée
2018-02-23 16:49       ` Daniel P. Berrangé
2018-02-23 17:01         ` Peter Maydell
2018-02-23 17:05           ` Daniel P. Berrangé
2018-02-23 17:20           ` Alex Bennée
2018-02-23 15:46 ` [PATCH v1 5/8] contrib/run_risu.sh: allow appending of QEMU_FLAGS Alex Bennée
2018-02-23 18:12   ` Peter Maydell
2018-02-23 15:46 ` [PATCH v1 6/8] contrib/run_risu.sh: don't set -e Alex Bennée
2018-02-23 15:46 ` [PATCH v1 7/8] contrib/run_risu.sh: add a visual cue for a clean-run Alex Bennée
2018-02-23 15:46 ` [PATCH v1 8/8] aarch64.risu: update Floating-point data-processing (1 source) Alex Bennée
2018-02-23 18:23 ` [PATCH REPOST v1 0/8] Group support and random clean-ups Peter Maydell
2018-03-01 11:44   ` 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=20180223154613.2096-5-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).