All of lore.kernel.org
 help / color / mirror / Atom feed
From: Taylor Simpson <tsimpson@quicinc.com>
To: Anton Johansson <anjo@rev.ng>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "ale@rev.ng" <ale@rev.ng>, Brian Cain <bcain@quicinc.com>,
	"richard.henderson@linaro.org" <richard.henderson@linaro.org>,
	"babush@rev.ng" <babush@rev.ng>, "nizzo@rev.ng" <nizzo@rev.ng>
Subject: RE: [PATCH v7 12/13] target/hexagon: import additional tests
Date: Thu, 23 Dec 2021 18:16:44 +0000	[thread overview]
Message-ID: <SN4PR0201MB8808A345E8325BBFDACB3532DE7E9@SN4PR0201MB8808.namprd02.prod.outlook.com> (raw)
In-Reply-To: <20211217090129.23242-13-anjo@rev.ng>


> -----Original Message-----
> From: Anton Johansson <anjo@rev.ng>
> Sent: Friday, December 17, 2021 2:01 AM
> To: qemu-devel@nongnu.org
> Cc: ale@rev.ng; Taylor Simpson <tsimpson@quicinc.com>; Brian Cain
> <bcain@quicinc.com>; babush@rev.ng; nizzo@rev.ng;
> richard.henderson@linaro.org
> Subject: [PATCH v7 12/13] target/hexagon: import additional tests
> 
> From: Niccolò Izzo <nizzo@rev.ng>
> 
> Signed-off-by: Alessandro Di Federico <ale@rev.ng>
> Signed-off-by: Niccolò Izzo <nizzo@rev.ng>
> diff --git a/tests/tcg/hexagon/Makefile.target
> b/tests/tcg/hexagon/Makefile.target
> index 8b07a28166..6f1c0830aa 100644
> --- a/tests/tcg/hexagon/Makefile.target
> +++ b/tests/tcg/hexagon/Makefile.target
> @@ -24,7 +24,7 @@ CFLAGS += -fno-unroll-loops
> HEX_SRC=$(SRC_PATH)/tests/tcg/hexagon
>  VPATH += $(HEX_SRC)
> 
> -first: $(HEX_SRC)/first.S
> +%: $(HEX_SRC)/%.S $(HEX_SRC)/crt.S
>         $(CC) -static -mv67 -nostdlib $^ -o $@
> 
>  HEX_TESTS = first
> @@ -42,4 +42,32 @@ HEX_TESTS += atomics
>  HEX_TESTS += fpstuff
>  HEX_TESTS += overflow
> 
> +HEX_TESTS += test_abs
> +HEX_TESTS += test_bitcnt
> +HEX_TESTS += test_bitsplit
> +HEX_TESTS += test_clobber

You forgot to add test_call to this list.

> +HEX_TESTS += test_cmp
> +HEX_TESTS += test_cmpy


> diff --git a/tests/tcg/hexagon/test_call.S b/tests/tcg/hexagon/test_call.S
> new file mode 100644 index 0000000000..fe59a8f006
> --- /dev/null
> +++ b/tests/tcg/hexagon/test_call.S
> @@ -0,0 +1,60 @@
> +/* Purpose: test function calls and duplex instructions.
> + * The string "Hello there, I'm a test string!" with the first letter
> +replaced
> + * with a capital L should be printed out.
> + */
> +    {
> +        call write
> +    }
> +    {
> +        jump pass
> +    }
> +    {
> +        r31:30=deallocframe(r30):raw
> +    }

The jump to pass will never return, so the deallocframe is unreachable.

> +.Lfunc_end1:
> +.Ltmp1:
> +    .size    _start, .Ltmp1-_start
> +write:
> +    {
> +        r0=##dummy_buffer
> +    }
> +    {
> +        r1=#256
> +    }

Were you intending to make a system call here?  If so, the sequence would be (see first.S for #define's)
	r6 = #SYS_write
	r0 = #FD_STDOUT
	r1 = ##dummy_buffer
	r2 = #33
	trap0(#1)

> +    {
> +        jumpr r31
> +    }


> diff --git a/tests/tcg/hexagon/test_cmpy.S
> b/tests/tcg/hexagon/test_cmpy.S new file mode 100644 index
> 0000000000..0b3dfb95de
> --- /dev/null
> +++ b/tests/tcg/hexagon/test_cmpy.S
> @@ -0,0 +1,31 @@
> +/* Purpose: test example, verify the soundness of the cmpy operation
> + *
> + *  3j+5 * 2j+4 = 22j+14
> + *
> + * the complex multiply between 0x00030005 and 0x00020004 is
> +0x000000160000000e  */
> +
> +    .text
> +    .globl _start
> +
> +_start:
> +    {
> +        call init
> +    }
> +    {
> +        r0=#196613
> +        r1=#131076
> +    }
> +    {
> +        r3:2=cmpy(r0, r1):sat
> +    }

You should also check the overflow bit in USR from the :sat.
Also, have one set of inputs that overflows and one that doesn't in order to verify the proper USR behavior.

> +    {
> +        p0 = cmp.eq(r2, #14); if (p0.new) jump:t test2
> +        jump fail
> +    }
> +
> +test2:
> +    {
> +        p0 = cmp.eq(r3, #22); if (p0.new) jump:t pass
> +        jump fail
> +    }
> diff --git a/tests/tcg/hexagon/test_dotnew.S
> b/tests/tcg/hexagon/test_dotnew.S new file mode 100644 index
> 0000000000..70886d9483
> --- /dev/null
> +++ b/tests/tcg/hexagon/test_dotnew.S
> @@ -0,0 +1,36 @@
> +/* Purpose: test the .new operator while performing memory stores. */
> +    .text
> +    .globl _start
> +
> +_start:
> +    {
> +        call init
> +    }
> +    {
> +        r0=#1
> +        memw(sp+#0)=r0.new
> +    }

You should allocframe before writing to the stack.

> diff --git a/tests/tcg/hexagon/test_jmp.S b/tests/tcg/hexagon/test_jmp.S
> new file mode 100644 index 0000000000..9bf6ea34e5
> --- /dev/null
> +++ b/tests/tcg/hexagon/test_jmp.S
> @@ -0,0 +1,25 @@
> +/* Purpose: test example, verify the soundness of the add operation */

This test is named test_jmp.S, but you are testing add?

diff --git a/tests/tcg/hexagon/test_overflow.S b/tests/tcg/hexagon/test_overflow.S
new file mode 100644
index 0000000000..9e2a235616
--- /dev/null
+++ b/tests/tcg/hexagon/test_overflow.S
@@ -0,0 +1,63 @@
+// Purpose: test example, verify the soundness of the overflow bit // 
+// a right shift with negative amount should make r0 saturate, setting 
+the // overflow bit
+
+    .text
+    .globl _start
+
+_start:
+    {
+        call init
+    }
+    {
+        r0=#0x10000000
+        r1=#-2
+    }

You should clear bit 0 in USR before doing the asr(r0,r1):sat.

Also, do this for the other places in this review that mention USR.

+    {
+        r2=asr(r0, r1):sat
+    }
+    {
+        r4=USR
+    }
+    {
+        r5=and(r4,#1)
+    }

> diff --git a/tests/tcg/hexagon/test_packet.S
> b/tests/tcg/hexagon/test_packet.S new file mode 100644 index
> 0000000000..d26e284be9
> --- /dev/null
> +++ b/tests/tcg/hexagon/test_packet.S
> @@ -0,0 +1,26 @@
> +/* Purpose: test that writes of a register in a packet are performed
> +only after
> + * that packet has finished its execution.
> + */
> +
> +    .text
> +    .globl _start
> +
> +_start:
> +    {
> +        call init
> +    }
> +    {
> +        r2=#4
> +        r3=#6
> +    }
> +    {
> +        memw(sp+#0)=r2
> +    }

Need allocframe first

> +    {
> +        r3=memw(sp+#0)
> +        r0=add(r2,r3)
> +    }
> +    {
> +        p0 = cmp.eq(r0, #10); if (p0.new) jump:t pass
> +        jump fail
> +    }

Also check that r3 == 4


> diff --git a/tests/tcg/hexagon/test_vcmpb.S
> b/tests/tcg/hexagon/test_vcmpb.S new file mode 100644 index
> 0000000000..3c6700a63a
> --- /dev/null
> +++ b/tests/tcg/hexagon/test_vcmpb.S
> @@ -0,0 +1,32 @@
> +/* Purpose: test example, verify the soundness of the vector compare
> +bytes
> + * operation
> + *
> + * Vector word comparison between 0x1234567887654321 and
> +0x1234567800000000
> + * should result in 0x11110000

Comment is incorrect - should be Vector byte comparison.

> diff --git a/tests/tcg/hexagon/test_vcmpw.S
> b/tests/tcg/hexagon/test_vcmpw.S new file mode 100644 index
> 0000000000..112f08c92f
> --- /dev/null
> +++ b/tests/tcg/hexagon/test_vcmpw.S
> @@ -0,0 +1,29 @@
> +/* Purpose: test example, verify the soundness of the vector compare
> +words
> + * operation
> + *
> + * Vector word comparison between 0x1234567887654321 and
> +0x1234567800000000
> + * should result in 0x11110000

That's the expected result in binary, not hex.

> + */
> +
> +    .text
> +    .globl _start
> +
> +_start:
> +    {
> +        call init
> +    }
> +    {
> +        r0=#305419896
> +        r1=#-2023406815
> +    }
> +    {
> +        r2=#305419896
> +        r3=#0
> +    }
> +    {
> +        p2=vcmpw.eq(r1:0, r3:2)
> +    }
> +    {
> +        if (p2) jump:t pass

Check for the actual expected value, not just LSB.

Also, this doesn't match the comment above.  You're actually comparing
    0x8765432112345678
    0x0000000012345678
So, p2 will have 0xf, not 0xf0.

In other words, the assignments to r0/r1 and r2/r3 are swapped.

Go ahead and swap them and check that p2 gets 0xf0.
 

> diff --git a/tests/tcg/hexagon/test_vcmpy.S
> b/tests/tcg/hexagon/test_vcmpy.S new file mode 100644 index
> 0000000000..df379f9186
> --- /dev/null
> +++ b/tests/tcg/hexagon/test_vcmpy.S
> +    {
> +        r5:4=vcmpyr(r1:0, r3:2):sat
> +        r7:6=vcmpyi(r1:0, r3:2):sat
> +    }

Create some inputs that will saturate and check for overflow in USR.

> diff --git a/tests/tcg/hexagon/test_vspliceb.S
> b/tests/tcg/hexagon/test_vspliceb.S
> new file mode 100644
> index 0000000000..bae2a9c163
> --- /dev/null
> +++ b/tests/tcg/hexagon/test_vspliceb.S
> @@ -0,0 +1,33 @@
> +/* Purpose: test example, verify the soundness of the vspliceb
> +operation
> + * the operation is a binary splice of two 64bit operators
> + *
> + *  vspliceb(0xffffffffffffffff,0x0000000000000000,5) =
> +0x000000000000001f  */

The comment is incorrect.  The result is 0x000000ffffffffff.

The test is correct, though.



  reply	other threads:[~2021-12-23 18:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17  9:01 [PATCH v7 00/13] target/hexagon: introduce idef-parser Anton Johansson via
2021-12-17  9:01 ` [PATCH v7 01/13] target/hexagon: update MAINTAINERS for idef-parser Anton Johansson via
2021-12-20 22:50   ` Taylor Simpson
2021-12-17  9:01 ` [PATCH v7 02/13] target/hexagon: import README " Anton Johansson via
2021-12-22 21:05   ` Taylor Simpson
2021-12-17  9:01 ` [PATCH v7 03/13] target/hexagon: make slot number an unsigned Anton Johansson via
2021-12-22 21:47   ` Taylor Simpson
2021-12-17  9:01 ` [PATCH v7 04/13] target/hexagon: make helper functions non-static Anton Johansson via
2021-12-17  9:01 ` [PATCH v7 05/13] target/hexagon: introduce new helper functions Anton Johansson via
2021-12-21 18:51   ` Taylor Simpson
2021-12-22 19:29   ` Taylor Simpson
2021-12-17  9:01 ` [PATCH v7 06/13] target/hexagon: expose next PC in DisasContext Anton Johansson via
2021-12-17  9:01 ` [PATCH v7 07/13] target/hexagon: prepare input for the idef-parser Anton Johansson via
2021-12-22 21:53   ` Taylor Simpson
2021-12-23  1:53   ` Taylor Simpson
2021-12-17  9:01 ` [PATCH v7 08/13] target/hexagon: import flex/bison to docker files Anton Johansson via
2021-12-17  9:01 ` [PATCH v7 09/13] target/hexagon: import lexer for idef-parser Anton Johansson via
2021-12-21 18:48   ` Taylor Simpson
2021-12-17  9:01 ` [PATCH v7 10/13] target/hexagon: import parser " Anton Johansson via
2021-12-17  9:01 ` [PATCH v7 11/13] target/hexagon: call idef-parser functions Anton Johansson via
2021-12-22 23:21   ` Taylor Simpson
2021-12-17  9:01 ` [PATCH v7 12/13] target/hexagon: import additional tests Anton Johansson via
2021-12-23 18:16   ` Taylor Simpson [this message]
2021-12-17  9:01 ` [PATCH v7 13/13] gitlab-ci: do not use qemu-project Docker registry Anton Johansson via

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=SN4PR0201MB8808A345E8325BBFDACB3532DE7E9@SN4PR0201MB8808.namprd02.prod.outlook.com \
    --to=tsimpson@quicinc.com \
    --cc=ale@rev.ng \
    --cc=anjo@rev.ng \
    --cc=babush@rev.ng \
    --cc=bcain@quicinc.com \
    --cc=nizzo@rev.ng \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.