summary refs log tree commit diff stats
path: root/tests/tcg/hexagon/overflow.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-05-26 09:25:42 -0700
committerRichard Henderson <richard.henderson@linaro.org>2023-05-26 09:25:42 -0700
commit9c9fff18c45b54fd9adf2282323aab1b6f0ec866 (patch)
tree9e2a0fef7a8ed9e22c6de6b112fc8655e64b1804 /tests/tcg/hexagon/overflow.c
parentf9bdb3818faae00b950f6a09eda1fa40193ef1f5 (diff)
parent7d196e2196d50e0dda0f87f396d4f4a7ad9aafbe (diff)
downloadfocaccia-qemu-9c9fff18c45b54fd9adf2282323aab1b6f0ec866.tar.gz
focaccia-qemu-9c9fff18c45b54fd9adf2282323aab1b6f0ec866.zip
Merge tag 'pull-hex-20230526' of https://github.com/quic/qemu into staging
Hexagon update

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEENjXHiM5iuR/UxZq0ewJE+xLeRCIFAmRwv6QACgkQewJE+xLe
# RCLRvQf/e0utA8/KAYwmay4dYiiVlrtJ4UVpwogQ8JC7je5H2+Gv633P4BF8uGAF
# HmhdUk031jvG/BvKGH+493ESKgtIX3caLxJInPtYu3elqKxZhqKpke2VPF3srrwI
# Mli8IqdwE2scSilG591xTjhU8vBGSm+hiQptSg9OaSotVcH8Qc/32+vudnr2JZtK
# ko3MqISMW/KvfD+x47UcX4IX4bmQfDyysQITQs9lfwYgzv/4drl6/7CUFQZ3b8Go
# Rz4ClbYhKT8YybJjX+yaKuTaHSrL9r0+90ORzYisEYcPiOOChmy9vv4HbZ1zTCbY
# MVJM69IPdZDi1quE00jULYEEPrHRoA==
# =vczK
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 26 May 2023 07:18:12 AM PDT
# gpg:                using RSA key 3635C788CE62B91FD4C59AB47B0244FB12DE4422
# gpg: Good signature from "Taylor Simpson (Rock on) <tsimpson@quicinc.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 3635 C788 CE62 B91F D4C5  9AB4 7B02 44FB 12DE 4422

* tag 'pull-hex-20230526' of https://github.com/quic/qemu:
  Hexagon (target/hexagon) Change Hexagon maintainer
  Hexagon: fix outdated `hex_new_*` comments
  target/hexagon/*.py: clean up used 'toss' and 'numregs' vars
  Hexagon (target/hexagon) Fix assignment to tmp registers
  Hexagon (tests/tcg/hexagon) Clean up Hexagon check-tcg tests

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'tests/tcg/hexagon/overflow.c')
-rw-r--r--tests/tcg/hexagon/overflow.c61
1 files changed, 26 insertions, 35 deletions
diff --git a/tests/tcg/hexagon/overflow.c b/tests/tcg/hexagon/overflow.c
index 94087851b0..7b5b9ebdde 100644
--- a/tests/tcg/hexagon/overflow.c
+++ b/tests/tcg/hexagon/overflow.c
@@ -1,5 +1,5 @@
 /*
- *  Copyright(c) 2021-2022 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ *  Copyright(c) 2021-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -17,30 +17,21 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <fcntl.h>
 #include <setjmp.h>
 #include <signal.h>
 
-
 int err;
 
-static void __check(const char *filename, int line, int x, int expect)
-{
-    if (x != expect) {
-        printf("ERROR %s:%d - %d != %d\n",
-               filename, line, x, expect);
-        err++;
-    }
-}
-
-#define check(x, expect) __check(__FILE__, __LINE__, (x), (expect))
+#include "hex_test.h"
 
-static int satub(int src, int *p, int *ovf_result)
+static int32_t satub(int32_t src, int32_t *p, bool *ovf_result)
 {
-    int result;
-    int usr;
+    int32_t result;
+    uint32_t usr;
 
     /*
      * This instruction can set bit 0 (OVF/overflow) in usr
@@ -65,30 +56,30 @@ static int satub(int src, int *p, int *ovf_result)
   return result;
 }
 
-int read_usr_overflow(void)
+bool read_usr_overflow(void)
 {
-    int result;
-    asm volatile("%0 = usr\n\t" : "=r"(result));
-    return result & 1;
+    uint32_t usr;
+    asm volatile("%0 = usr\n\t" : "=r"(usr));
+    return usr & 1;
 }
 
-int get_usr_overflow(int usr)
+bool get_usr_overflow(uint32_t usr)
 {
     return usr & 1;
 }
 
-int get_usr_fp_invalid(int usr)
+bool get_usr_fp_invalid(uint32_t usr)
 {
     return (usr >> 1) & 1;
 }
 
-int get_usr_lpcfg(int usr)
+int32_t get_usr_lpcfg(uint32_t usr)
 {
     return (usr >> 8) & 0x3;
 }
 
 jmp_buf jmp_env;
-int usr_overflow;
+bool usr_overflow;
 
 static void sig_segv(int sig, siginfo_t *info, void *puc)
 {
@@ -98,9 +89,9 @@ static void sig_segv(int sig, siginfo_t *info, void *puc)
 
 static void test_packet(void)
 {
-    int convres;
-    int satres;
-    int usr;
+    int32_t convres;
+    int32_t satres;
+    uint32_t usr;
 
     asm("r2 = usr\n\t"
         "r2 = clrbit(r2, #0)\n\t"        /* clear overflow bit */
@@ -115,10 +106,10 @@ static void test_packet(void)
         : "r"(0x6a051b86), "r"(0x0410eec0)
         : "r2", "usr");
 
-    check(convres, 0xffffffff);
-    check(satres, 0x7f);
-    check(get_usr_overflow(usr), 1);
-    check(get_usr_fp_invalid(usr), 1);
+    check32(convres, 0xffffffff);
+    check32(satres, 0x7f);
+    check32(get_usr_overflow(usr), true);
+    check32(get_usr_fp_invalid(usr), true);
 
     asm("r2 = usr\n\t"
         "r2 = clrbit(r2, #0)\n\t"        /* clear overflow bit */
@@ -134,15 +125,15 @@ static void test_packet(void)
         : "r"(0x0410eec0)
         : "r2", "usr", "p3", "sa0", "lc0");
 
-    check(satres, 0x7f);
-    check(get_usr_overflow(usr), 1);
-    check(get_usr_lpcfg(usr), 2);
+    check32(satres, 0x7f);
+    check32(get_usr_overflow(usr), true);
+    check32(get_usr_lpcfg(usr), 2);
 }
 
 int main()
 {
     struct sigaction act;
-    int ovf;
+    bool ovf;
 
     /* SIGSEGV test */
     act.sa_sigaction = sig_segv;
@@ -157,7 +148,7 @@ int main()
     sigemptyset(&act.sa_mask);
     act.sa_flags = 0;
 
-    check(usr_overflow, 0);
+    check32(usr_overflow, false);
 
     test_packet();