diff mbox series

[v1,4/8] new contrib/generate_all.sh: batch risugen script

Message ID 20180223154613.2096-5-alex.bennee@linaro.org
State New
Headers show
Series Group support and random clean-ups | expand

Commit Message

Alex Bennée Feb. 23, 2018, 3:46 p.m. UTC
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

-- 
2.15.1

Comments

Daniel P. Berrangé Feb. 23, 2018, 4:17 p.m. UTC | #1
On Fri, Feb 23, 2018 at 03:46:09PM +0000, Alex Bennée wrote:
> 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


Really ? Why this license not our standard GPLv2+, or BSD if it is wanted
to be a public-domain-ish license ?

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Peter Maydell Feb. 23, 2018, 4:42 p.m. UTC | #2
On 23 February 2018 at 16:17, Daniel P. Berrangé <berrange@redhat.com> wrote:
> On Fri, Feb 23, 2018 at 03:46:09PM +0000, Alex Bennée wrote:

>> 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

>

> Really ? Why this license not our standard GPLv2+, or BSD if it is wanted

> to be a public-domain-ish license ?


It's the stock risu license (for historical reasons). Alex forgot
to mark this patchset as being a risu patchset not a qemu one...

thanks
-- PMM
Alex Bennée Feb. 23, 2018, 4:45 p.m. UTC | #3
Daniel P. Berrangé <berrange@redhat.com> writes:

> On Fri, Feb 23, 2018 at 03:46:09PM +0000, Alex Bennée wrote:

>> 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

>

> Really ? Why this license not our standard GPLv2+, or BSD if it is wanted

> to be a public-domain-ish license ?


I just chose what RISU is licensed under - but there is no reason I
couldn't make it something else.

>

> Regards,

> Daniel



--
Alex Bennée
Daniel P. Berrangé Feb. 23, 2018, 4:49 p.m. UTC | #4
On Fri, Feb 23, 2018 at 04:45:58PM +0000, Alex Bennée wrote:
> 

> Daniel P. Berrangé <berrange@redhat.com> writes:

> 

> > On Fri, Feb 23, 2018 at 03:46:09PM +0000, Alex Bennée wrote:

> >> 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

> >

> > Really ? Why this license not our standard GPLv2+, or BSD if it is wanted

> > to be a public-domain-ish license ?

> 

> I just chose what RISU is licensed under - but there is no reason I

> couldn't make it something else.


If it is going to live in QEMU source tree, then avoiding introducing a new
license is desirable.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Peter Maydell Feb. 23, 2018, 5:01 p.m. UTC | #5
On 23 February 2018 at 16:49, Daniel P. Berrangé <berrange@redhat.com> wrote:
> If it is going to live in QEMU source tree, then avoiding introducing a new

> license is desirable.


It isn't -- risu has its own repository.

thanks
-- PMM
Daniel P. Berrangé Feb. 23, 2018, 5:05 p.m. UTC | #6
On Fri, Feb 23, 2018 at 05:01:42PM +0000, Peter Maydell wrote:
> On 23 February 2018 at 16:49, Daniel P. Berrangé <berrange@redhat.com> wrote:

> > If it is going to live in QEMU source tree, then avoiding introducing a new

> > license is desirable.

> 

> It isn't -- risu has its own repository.


Ah, I see what you mean. Disregard my comments here then


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
diff mbox series

Patch

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