Skip to contentSkip to conversation

tests: cris: force inlining

PATCH Superseded Rabin Vincent 6 participants 31 messages Sep 5, 2016 – Sep 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/9 tests: cris: force inlining

From: Rabin Vincent <[email protected]>

The CRIS tests expect that functions marked inline are always inline. With newer versions of GCC, building them results warnings like the following and spurious failures when they are run.

In file included from tests/tcg/cris/check_moveq.c:5:0:
tests/tcg/cris/crisutils.h:66:20: warning: inlining failed in call to 'cris_tst_cc.constprop.0': call is unlikely and code size would grow [-Winline] tests/tcg/cris/check_moveq.c:28:13: warning: called from here [-Winline]

Use the always_inline attribute when building them to fix this.

---
 tests/tcg/cris/sys.h | 2 ++
 1 file changed, 2 insertions(+)
tests/tcg/cris/sys.h +2 -0
index c5f88e1..b1bf4c5 100644
@@ -3,6 +3,8 @@
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 
+#define inline inline __attribute__((always_inline))
+
 #define CURRENT_LOCATION __FILE__ ":" TOSTRING(__LINE__)
 
 #define err()                         \
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/9 tests: cris: fix syscall inline asm

From: Rabin Vincent <[email protected]>

Add the clobbered registeres to the inline asm for the write and exit system calls. Without the correct clobbers for the write() function, correct failure messages are not printed succesfully on newer version of GCC.

---
 tests/tcg/cris/sys.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tests/tcg/cris/sys.c +8 -2
index 551c5dd..dfa5e1c 100644
@@ -34,7 +34,10 @@ void *memset (void *s, int c, size_t n) {
 
 void exit (int status) {
 	asm volatile ("moveq 1, $r9\n" /* NR_exit.  */
-		      "break 13\n");
+		      "break 13\n"
+		      :
+		      :
+		      : "r9", "memory" );
 	while(1)
 		;
 }
@@ -45,7 +48,10 @@ ssize_t write (int fd, const void *buf, size_t count) {
 	     "move.d %1, $r11\n"
 	     "move.d %2, $r12\n"
 	     "moveq 4, $r9\n" /* NR_write.  */
-	     "break 13\n" : : "r" (fd), "r" (buf), "r" (count) : "memory");
+	     "break 13\n"
+	     :
+	     : "r" (fd), "r" (buf), "r" (count)
+	     : "r9", "r10", "r11", "r12", "memory");
 	asm ("move.d $r10, %0\n" : "=r" (r));
 	return r;
 }
Signature · 1 line
2.1.4
#2 lore raw

Re: [Qemu-devel] [PATCH 2/9] tests: cris: fix syscall inline asm

Quoted 17 lines · Rabin Vincent

From: Rabin Vincent <[email protected]>

Add the clobbered registeres to the inline asm for the write and exit system calls. Without the correct clobbers for the write() function, correct failure messages are not printed succesfully on newer version of GCC.

---
 tests/tcg/cris/sys.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tests/tcg/cris/sys.c +0 -0
index 551c5dd..dfa5e1c 100644

tests/tcg/cris/sys.c void *memset (void *s, int c, size_t n) { · line 40

Quoted 8 lines
tests/tcg/cris/sys.c +4 -1
@@ -34,7 +34,10 @@ void *memset (void *s, int c, size_t n) {
 
 void exit (int status) {
 	asm volatile ("moveq 1, $r9\n" /* NR_exit.  */
-		      "break 13\n");
+		      "break 13\n"
+		      :
+		      :
+		      : "r9", "memory" );

Better to simply set up the arguments properly. See

http://www.uclibc-ng.org/browser/uclibc-ng/libc/sysdeps/linux/cris/bits/syscalls.h?rev=3b4650a23ff372dde44c264d43af8cfa4ac88e0a

r~

#3 lore raw

PATCH v2 2/8 tests: cris: fix syscall inline asm

From: Rabin Vincent <[email protected]>

Add the appropriate register constraints for the inline asm for the write and exit system calls. Without the correct constraints for the write() function, correct failure messages are not printed succesfully on newer version of GCC.

---
v2: reworked to set up arguments correctly

 tests/tcg/cris/sys.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)
tests/tcg/cris/sys.c +17 -9
index 551c5dd..21f08c0 100644
@@ -33,19 +33,27 @@ void *memset (void *s, int c, size_t n) {
 }
 
 void exit (int status) {
-	asm volatile ("moveq 1, $r9\n" /* NR_exit.  */
-		      "break 13\n");
+	register unsigned int callno asm ("r9") = 1; /* NR_exit */
+
+	asm volatile ("break 13\n"
+		      :
+		      : "r" (callno)
+		      : "memory" );
 	while(1)
 		;
 }
 
 ssize_t write (int fd, const void *buf, size_t count) {
-	int r;
-	asm ("move.d %0, $r10\n"
-	     "move.d %1, $r11\n"
-	     "move.d %2, $r12\n"
-	     "moveq 4, $r9\n" /* NR_write.  */
-	     "break 13\n" : : "r" (fd), "r" (buf), "r" (count) : "memory");
-	asm ("move.d $r10, %0\n" : "=r" (r));
+	register unsigned int callno asm ("r9") = 4; /* NR_write */
+	register unsigned int r10 asm ("r10") = fd;
+	register const void *r11 asm ("r11") = buf;
+	register size_t r12 asm ("r12") = count;
+	register unsigned int r asm ("r10");
+
+	asm volatile ("break 13\n"
+	     : "=r" (r)
+	     : "r" (callno), "0" (r10), "r" (r11), "r" (r12)
+	     : "memory");
+
 	return r;
 }
Signature · 1 line
2.1.4
Reviewed-by on v2 2/8
#4 lore raw

Re: [Qemu-devel] [PATCHv2 2/8] tests: cris: fix syscall inline asm

Quoted 7 lines · Rabin Vincent

From: Rabin Vincent <[email protected]>

Add the appropriate register constraints for the inline asm for the write and exit system calls. Without the correct constraints for the write() function, correct failure messages are not printed succesfully on newer version of GCC.

Quoted 6 lines

---
v2: reworked to set up arguments correctly

 tests/tcg/cris/sys.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

r~

#5 lore raw

PATCH 3/9 tests: cris: remove openpf4 test

In reply to Rabin Vincent

From: Rabin Vincent <[email protected]>

This test, borrowed from the GDB simulator test suite, is meant to test the GDB simulator's --sysroot feature and always fails in QEMU. Remove it. openpf3 tests the same sequence of system calls (without assuming the precence of --sysroot).

---
 tests/tcg/cris/Makefile        | 1 -
 tests/tcg/cris/check_openpf4.c | 5 -----
 2 files changed, 6 deletions(-)
 delete mode 100644 tests/tcg/cris/check_openpf4.c
tests/tcg/cris/Makefile +0 -1
index d34bfd8..f5230fc 100644
@@ -108,7 +108,6 @@ TESTCASES += check_stat4.ctst
 TESTCASES += check_openpf1.ctst
 TESTCASES += check_openpf2.ctst
 TESTCASES += check_openpf3.ctst
-TESTCASES += check_openpf4.ctst
 TESTCASES += check_openpf5.ctst
 TESTCASES += check_mapbrk.ctst
 TESTCASES += check_mmap1.ctst
tests/tcg/cris/check_openpf4.c deleted +0 -5
deleted file mode 100644
index 8bbee41..0000000
@@ -1,5 +0,0 @@
-/* Basic file operations, now *with* sysroot.
-#sim: --sysroot=@exedir@
-*/
-#define PREFIX "/"
-#include "check_openpf3.c"
Signature · 1 line
2.1.4
Reviewed-by on v1 3/9
#6 lore raw

Re: [Qemu-devel] [PATCH 3/9] tests: cris: remove openpf4 test

Quoted 8 lines · Rabin Vincent

From: Rabin Vincent <[email protected]>

This test, borrowed from the GDB simulator test suite, is meant to test the GDB simulator's --sysroot feature and always fails in QEMU. Remove it. openpf3 tests the same sequence of system calls (without assuming the precence of --sysroot).

Quoted 32 lines
---
 tests/tcg/cris/Makefile        | 1 -
 tests/tcg/cris/check_openpf4.c | 5 -----
 2 files changed, 6 deletions(-)
 delete mode 100644 tests/tcg/cris/check_openpf4.c
tests/tcg/cris/Makefile +0 -1
index d34bfd8..f5230fc 100644
@@ -108,7 +108,6 @@ TESTCASES += check_stat4.ctst
 TESTCASES += check_openpf1.ctst
 TESTCASES += check_openpf2.ctst
 TESTCASES += check_openpf3.ctst
-TESTCASES += check_openpf4.ctst
 TESTCASES += check_openpf5.ctst
 TESTCASES += check_mapbrk.ctst
 TESTCASES += check_mmap1.ctst
tests/tcg/cris/check_openpf4.c deleted +0 -5
deleted file mode 100644
index 8bbee41..0000000
@@ -1,5 +0,0 @@
-/* Basic file operations, now *with* sysroot.
-#sim: --sysroot=@exedir@
-*/
-#define PREFIX "/"
-#include "check_openpf3.c"
Signature · 1 line
2.1.4
#7 lore raw

PATCH 4/9 tests: cris: remove check_time1

In reply to Rabin Vincent

From: Rabin Vincent <[email protected]>

This test, borrowed from the GDB simulator test suite, checks that every syscall increments the time returned by gettimeofday() by exactly 1 ms. This is not guaranteed or even desirable on QEMU so remove this test.

---
 tests/tcg/cris/Makefile      |  1 -
 tests/tcg/cris/check_time1.c | 46 --------------------------------------------
 2 files changed, 47 deletions(-)
 delete mode 100644 tests/tcg/cris/check_time1.c
tests/tcg/cris/Makefile +0 -1
index f5230fc..14a9eb5 100644
@@ -114,7 +114,6 @@ TESTCASES += check_mmap1.ctst
 TESTCASES += check_mmap2.ctst
 TESTCASES += check_mmap3.ctst
 TESTCASES += check_sigalrm.ctst
-TESTCASES += check_time1.ctst
 TESTCASES += check_time2.ctst
 TESTCASES += check_settls1.ctst
 
tests/tcg/cris/check_time1.c deleted +0 -46

46 lines not on this page · raw message

Signature · 1 line
2.1.4
Reviewed-by on v1 4/9
#8 lore raw

Re: [Qemu-devel] [PATCH 4/9] tests: cris: remove check_time1

Quoted 7 lines · Rabin Vincent

From: Rabin Vincent <[email protected]>

This test, borrowed from the GDB simulator test suite, checks that every syscall increments the time returned by gettimeofday() by exactly 1 ms. This is not guaranteed or even desirable on QEMU so remove this test.

Quoted 73 lines
---
 tests/tcg/cris/Makefile      |  1 -
 tests/tcg/cris/check_time1.c | 46 --------------------------------------------
 2 files changed, 47 deletions(-)
 delete mode 100644 tests/tcg/cris/check_time1.c
tests/tcg/cris/Makefile +0 -1
index f5230fc..14a9eb5 100644
@@ -114,7 +114,6 @@ TESTCASES += check_mmap1.ctst
 TESTCASES += check_mmap2.ctst
 TESTCASES += check_mmap3.ctst
 TESTCASES += check_sigalrm.ctst
-TESTCASES += check_time1.ctst
 TESTCASES += check_time2.ctst
 TESTCASES += check_settls1.ctst
 
tests/tcg/cris/check_time1.c deleted +0 -46
deleted file mode 100644
index 3fcf0e1..0000000
@@ -1,46 +0,0 @@
-/* Basic time functionality test: check that milliseconds are
-   incremented for each syscall (does not work on host).  */
-#include <stdio.h>
-#include <time.h>
-#include <sys/time.h>
-#include <string.h>
-#include <stdlib.h>
-
-void err (const char *s)
-{
-  perror (s);
-  abort ();
-}
-
-int
-main (void)
-{
-  struct timeval t_m = {0, 0};
-  struct timezone t_z = {0, 0};
-  struct timeval t_m1 = {0, 0};
-  int i;
-
-  if (gettimeofday (&t_m, &t_z) != 0)
-    err ("gettimeofday");
-
-  for (i = 1; i < 10000; i++)
-    if (gettimeofday (&t_m1, NULL) != 0)
-      err ("gettimeofday 1");
-    else
-      if (t_m1.tv_sec * 1000000 + t_m1.tv_usec
-	  != (t_m.tv_sec * 1000000 + t_m.tv_usec + i * 1000))
-	{
-	  fprintf (stderr, "t0 (%ld, %ld), i %d, t1 (%ld, %ld)\n",
-		   t_m.tv_sec, t_m.tv_usec, i, t_m1.tv_sec, t_m1.tv_usec);
-	  abort ();
-	}
-
-  if (time (NULL) != t_m1.tv_sec)
-    {
-      fprintf (stderr, "time != gettod\n");
-      abort ();
-    }
-
-  printf ("pass\n");
-  exit (0);
-}
Signature · 1 line
2.1.4
#9 lore raw

PATCH 5/9 target-cris: sync CC state at load/stores.

In reply to Rabin Vincent

From: "Edgar E. Iglesias" <[email protected]>

Icount may choose to abort and recompile a TB at any load/store. We need to sync the CC state at these insns.

---
 target-cris/translate.c     | 9 +++++++++
 target-cris/translate_v10.c | 3 +++
 2 files changed, 12 insertions(+)
target-cris/translate.c +9 -0
index f4a8d7d..c280e24 100644
@@ -1098,6 +1098,9 @@ static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr)
 {
     int mem_index = cpu_mmu_index(&dc->cpu->env, false);
 
+    /* Due to icount, we need to update the CC flags on load/stores.  */
+    cris_evaluate_flags(dc);
+
     /* If we get a fault on a delayslot we must keep the jmp state in
        the cpu-state to be able to re-execute the jmp.  */
     if (dc->delayed_branch == 1) {
@@ -1112,6 +1115,9 @@ static void gen_load(DisasContext *dc, TCGv dst, TCGv addr,
 {
     int mem_index = cpu_mmu_index(&dc->cpu->env, false);
 
+    /* Due to icount, we need to update the CC flags on load/stores.  */
+    cris_evaluate_flags(dc);
+
     /* If we get a fault on a delayslot we must keep the jmp state in
        the cpu-state to be able to re-execute the jmp.  */
     if (dc->delayed_branch == 1) {
@@ -1127,6 +1133,9 @@ static void gen_store (DisasContext *dc, TCGv addr, TCGv val,
 {
     int mem_index = cpu_mmu_index(&dc->cpu->env, false);
 
+    /* Due to icount, we need to update the CC flags on load/stores.  */
+    cris_evaluate_flags(dc);
+
     /* If we get a fault on a delayslot we must keep the jmp state in
        the cpu-state to be able to re-execute the jmp.  */
     if (dc->delayed_branch == 1) {
target-cris/translate_v10.c +3 -0
index 4707a18..a3da425 100644
@@ -99,6 +99,9 @@ static void gen_store_v10(DisasContext *dc, TCGv addr, TCGv val,
 {
     int mem_index = cpu_mmu_index(&dc->cpu->env, false);
 
+    /* Due to icount, we need to update the CC flags on load/stores.  */
+    cris_evaluate_flags(dc);
+
     /* If we get a fault on a delayslot we must keep the jmp state in
        the cpu-state to be able to re-execute the jmp.  */
     if (dc->delayed_branch == 1) {
Signature · 1 line
2.1.4
#10 lore raw

Re: [Qemu-devel] [PATCH 5/9] target-cris: sync CC state at load/stores.

Quoted 17 lines · Rabin Vincent

From: "Edgar E. Iglesias" <[email protected]>

Icount may choose to abort and recompile a TB at any load/store. We need to sync the CC state at these insns.

---
 target-cris/translate.c     | 9 +++++++++
 target-cris/translate_v10.c | 3 +++
 2 files changed, 12 insertions(+)
target-cris/translate.c +0 -0
index f4a8d7d..c280e24 100644

target-cris/translate.c static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr) · line 1103

Quoted 6 lines
target-cris/translate.c +3 -0
@@ -1098,6 +1098,9 @@ static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr)
 {
     int mem_index = cpu_mmu_index(&dc->cpu->env, false);
 
+    /* Due to icount, we need to update the CC flags on load/stores.  */
+    cris_evaluate_flags(dc);
+

This is not the proper way to handle this. You should arrange to sync the CC flags in restore_state_to_opc. There are plenty of examples in the tree you can examine. It looks like there's plenty of room for cleanup for cris here.

r~

#11 lore raw

Re: [Qemu-devel] [PATCH 5/9] target-cris: sync CC state at load/stores.

Quoted 21 lines · Richard Henderson
Quoted 20 lines · Rabin Vincent

From: "Edgar E. Iglesias" <[email protected]>

Icount may choose to abort and recompile a TB at any load/store. We need to sync the CC state at these insns.

---
target-cris/translate.c | 9 +++++++++
target-cris/translate_v10.c | 3 +++

2 files changed, 12 insertions(+)
target-cris/translate.c +0 -0
index f4a8d7d..c280e24 100644
@@ -1098,6 +1098,9 @@ static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr)
 {
    int mem_index = cpu_mmu_index(&dc->cpu->env, false);
 
Quoted 9 lines

target-cris/translate.c static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr) · line 1103

Quoted 3 lines
target-cris/translate.c +3 -0
+    /* Due to icount, we need to update the CC flags on load/stores.  */
+    cris_evaluate_flags(dc);
+

This is not the proper way to handle this. You should arrange to sync the CC flags in restore_state_to_opc. There are plenty of examples in the tree you can examine. It looks like there's plenty of room for cleanup for cris here.

Thanks, agreed.

Rabin, most of the CRIS patches that I left in the AXIS tree without upstreaming need more work. I don't mind you posting them but keep in mind that there's not much that can go up without tidy up.

Best regards,
Edgar

#12 lore raw

PATCH 6/9 target-cris: reduce v32isms from v10 log dumps

In reply to Rabin Vincent

From: Hans-Peter Nilsson <[email protected]>

Use the correct register names for v10 and don't dump support function registers for pre-v32.

---
 target-cris/translate.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)
target-cris/translate.c +23 -13
index c280e24..a4512b5 100644
@@ -140,14 +140,14 @@ static void gen_BUG(DisasContext *dc, const char *file, int line)
     cpu_abort(CPU(dc->cpu), "%s:%d\n", file, line);
 }
 
-static const char *regnames[] =
+static const char *regnames_v32[] =
 {
     "$r0", "$r1", "$r2", "$r3",
     "$r4", "$r5", "$r6", "$r7",
     "$r8", "$r9", "$r10", "$r11",
     "$r12", "$r13", "$sp", "$acr",
 };
-static const char *pregnames[] =
+static const char *pregnames_v32[] =
 {
     "$bz", "$vr", "$pid", "$srs",
     "$wz", "$exs", "$eda", "$mof",
@@ -3336,12 +3336,20 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
 {
     CRISCPU *cpu = CRIS_CPU(cs);
     CPUCRISState *env = &cpu->env;
+    const char **regnames;
+    const char **pregnames;
     int i;
-    uint32_t srs;
 
     if (!env || !f) {
         return;
     }
+    if (env->pregs[PR_VR] < 32) {
+        pregnames = pregnames_v10;
+        regnames = regnames_v10;
+    } else {
+        pregnames = pregnames_v32;
+        regnames = regnames_v32;
+    }
 
     cpu_fprintf(f, "PC=%x CCS=%x btaken=%d btarget=%x\n"
             "cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n",
@@ -3363,14 +3371,16 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
             cpu_fprintf(f, "\n");
         }
     }
-    srs = env->pregs[PR_SRS];
-    cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
-    if (srs < ARRAY_SIZE(env->sregs)) {
-        for (i = 0; i < 16; i++) {
-            cpu_fprintf(f, "s%2.2d=%8.8x ",
-                    i, env->sregs[srs][i]);
-            if ((i + 1) % 4 == 0) {
-                cpu_fprintf(f, "\n");
+    if (env->pregs[PR_SRS] >= 32) {
+        uint32_t srs = env->pregs[PR_SRS];
+        cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
+        if (srs < ARRAY_SIZE(env->sregs)) {
+            for (i = 0; i < 16; i++) {
+                cpu_fprintf(f, "s%2.2d=%8.8x ",
+                        i, env->sregs[srs][i]);
+                if ((i + 1) % 4 == 0) {
+                    cpu_fprintf(f, "\n");
+                }
             }
         }
     }
@@ -3415,12 +3425,12 @@ void cris_initialize_tcg(void)
     for (i = 0; i < 16; i++) {
         cpu_R[i] = tcg_global_mem_new(cpu_env,
                                       offsetof(CPUCRISState, regs[i]),
-                                      regnames[i]);
+                                      regnames_v32[i]);
     }
     for (i = 0; i < 16; i++) {
         cpu_PR[i] = tcg_global_mem_new(cpu_env,
                                        offsetof(CPUCRISState, pregs[i]),
-                                       pregnames[i]);
+                                       pregnames_v32[i]);
     }
 }
 
Signature · 1 line
2.1.4
#13 lore raw

Re: [Qemu-devel] [PATCH 6/9] target-cris: reduce v32isms from v10 log dumps

Quoted 57 lines · Rabin Vincent

From: Hans-Peter Nilsson <[email protected]>

Use the correct register names for v10 and don't dump support function registers for pre-v32.

---
 target-cris/translate.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)
target-cris/translate.c +11 -3
index c280e24..a4512b5 100644
@@ -140,14 +140,14 @@ static void gen_BUG(DisasContext *dc, const char *file, int line)
     cpu_abort(CPU(dc->cpu), "%s:%d\n", file, line);
 }
 
-static const char *regnames[] =
+static const char *regnames_v32[] =
 {
     "$r0", "$r1", "$r2", "$r3",
     "$r4", "$r5", "$r6", "$r7",
     "$r8", "$r9", "$r10", "$r11",
     "$r12", "$r13", "$sp", "$acr",
 };
-static const char *pregnames[] =
+static const char *pregnames_v32[] =
 {
     "$bz", "$vr", "$pid", "$srs",
     "$wz", "$exs", "$eda", "$mof",
@@ -3336,12 +3336,20 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
 {
     CRISCPU *cpu = CRIS_CPU(cs);
     CPUCRISState *env = &cpu->env;
+    const char **regnames;
+    const char **pregnames;
     int i;
-    uint32_t srs;
 
     if (!env || !f) {
         return;
     }
+    if (env->pregs[PR_VR] < 32) {
+        pregnames = pregnames_v10;
+        regnames = regnames_v10;
+    } else {
+        pregnames = pregnames_v32;
+        regnames = regnames_v32;
+    }
 
     cpu_fprintf(f, "PC=%x CCS=%x btaken=%d btarget=%x\n"
             "cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n",
@@ -3363,14 +3371,16 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
             cpu_fprintf(f, "\n");
         }

target-cris/translate.c void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, · line 3374

Quoted 10 lines
target-cris/translate.c +1 -8
     }
-    srs = env->pregs[PR_SRS];
-    cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
-    if (srs < ARRAY_SIZE(env->sregs)) {
-        for (i = 0; i < 16; i++) {
-            cpu_fprintf(f, "s%2.2d=%8.8x ",
-                    i, env->sregs[srs][i]);
-            if ((i + 1) % 4 == 0) {
-                cpu_fprintf(f, "\n");
+    if (env->pregs[PR_SRS] >= 32) {

did you mean env->pregs[PR_VR] >= 32 here?

Quoted 30 lines
target-cris/translate.c +11 -2
+        uint32_t srs = env->pregs[PR_SRS];
+        cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
+        if (srs < ARRAY_SIZE(env->sregs)) {
+            for (i = 0; i < 16; i++) {
+                cpu_fprintf(f, "s%2.2d=%8.8x ",
+                        i, env->sregs[srs][i]);
+                if ((i + 1) % 4 == 0) {
+                    cpu_fprintf(f, "\n");
+                }
             }
         }
     }
@@ -3415,12 +3425,12 @@ void cris_initialize_tcg(void)
     for (i = 0; i < 16; i++) {
         cpu_R[i] = tcg_global_mem_new(cpu_env,
                                       offsetof(CPUCRISState, regs[i]),
-                                      regnames[i]);
+                                      regnames_v32[i]);
     }
     for (i = 0; i < 16; i++) {
         cpu_PR[i] = tcg_global_mem_new(cpu_env,
                                        offsetof(CPUCRISState, pregs[i]),
-                                       pregnames[i]);
+                                       pregnames_v32[i]);
     }
 }
 
Signature · 1 line
2.1.4
#14 lore raw

Re: [Qemu-devel] [PATCH 6/9] target-cris: reduce v32isms from v10 log dumps

Quoted 32 lines

Date: Tue, 13 Sep 2016 00:59:51 +0200
From: "Edgar E. Iglesias" <[email protected]>

Quoted 30 lines
target-cris/translate.c +9 -5
@@ -3336,12 +3336,20 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
 {
     CRISCPU *cpu = CRIS_CPU(cs);
     CPUCRISState *env = &cpu->env;
+    const char **regnames;
+    const char **pregnames;
     int i;
-    uint32_t srs;
 
     if (!env || !f) {
         return;
     }
+    if (env->pregs[PR_VR] < 32) {
+        pregnames = pregnames_v10;
+        regnames = regnames_v10;
+    } else {
+        pregnames = pregnames_v32;
+        regnames = regnames_v32;
+    }
 
     cpu_fprintf(f, "PC=%x CCS=%x btaken=%d btarget=%x\n"
             "cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n",
@@ -3363,14 +3371,16 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
             cpu_fprintf(f, "\n");
         }
     }
-    srs = env->pregs[PR_SRS];
-    cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
-    if (srs < ARRAY_SIZE(env->sregs)) {
-        for (i = 0; i < 16; i++) {
Quoted 8 lines

target-cris/translate.c void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, · line 3374

Quoted 5 lines
target-cris/translate.c +1 -4
-            cpu_fprintf(f, "s%2.2d=%8.8x ",
-                    i, env->sregs[srs][i]);
-            if ((i + 1) % 4 == 0) {
-                cpu_fprintf(f, "\n");
+    if (env->pregs[PR_SRS] >= 32) {

did you mean env->pregs[PR_VR] >= 32 here?

Oops! Most definitely yes.

brgds, H-P

#15 lore raw

Re: [Qemu-devel] [PATCH 6/9] target-cris: reduce v32isms from v10 log dumps

In reply to Edgar E. Iglesias
Quoted 17 lines · Edgar E. Iglesias

Review void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, · line 3374

Quoted 13 lines · Rabin Vincent
(quoted diff) +1 -8
@@ -3363,14 +3371,16 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
             cpu_fprintf(f, "\n");
         }
     }
-    srs = env->pregs[PR_SRS];
-    cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
-    if (srs < ARRAY_SIZE(env->sregs)) {
-        for (i = 0; i < 16; i++) {
-            cpu_fprintf(f, "s%2.2d=%8.8x ",
-                    i, env->sregs[srs][i]);
-            if ((i + 1) % 4 == 0) {
-                cpu_fprintf(f, "\n");
+    if (env->pregs[PR_SRS] >= 32) {

did you mean env->pregs[PR_VR] >= 32 here?

Here's an updated patch:

8<-------------

Quoted 1 line

From 4143896189ba073d14f6d89ad98ef4109d267bec Mon Sep 17 00:00:00 2001

From: Hans-Peter Nilsson <[email protected]>
Date: Mon, 15 Aug 2016 13:44:46 +0200
Subject: [PATCHv2] target-cris: reduce v32isms from v10 log dumps

Use the correct register names for v10 and don't dump support function registers for pre-v32.

---
v2: Fix PR_SRS -> PR_VR

 target-cris/translate.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)
target-cris/translate.c +23 -13
index f4a8d7d..b5ab0a5 100644
@@ -140,14 +140,14 @@ static void gen_BUG(DisasContext *dc, const char *file, int line)
     cpu_abort(CPU(dc->cpu), "%s:%d\n", file, line);
 }
 
-static const char *regnames[] =
+static const char *regnames_v32[] =
 {
     "$r0", "$r1", "$r2", "$r3",
     "$r4", "$r5", "$r6", "$r7",
     "$r8", "$r9", "$r10", "$r11",
     "$r12", "$r13", "$sp", "$acr",
 };
-static const char *pregnames[] =
+static const char *pregnames_v32[] =
 {
     "$bz", "$vr", "$pid", "$srs",
     "$wz", "$exs", "$eda", "$mof",
@@ -3327,12 +3327,20 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
 {
     CRISCPU *cpu = CRIS_CPU(cs);
     CPUCRISState *env = &cpu->env;
+    const char **regnames;
+    const char **pregnames;
     int i;
-    uint32_t srs;
 
     if (!env || !f) {
         return;
     }
+    if (env->pregs[PR_VR] < 32) {
+        pregnames = pregnames_v10;
+        regnames = regnames_v10;
+    } else {
+        pregnames = pregnames_v32;
+        regnames = regnames_v32;
+    }
 
     cpu_fprintf(f, "PC=%x CCS=%x btaken=%d btarget=%x\n"
             "cc_op=%d cc_src=%d cc_dest=%d cc_result=%x cc_mask=%x\n",
@@ -3354,14 +3362,16 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
             cpu_fprintf(f, "\n");
         }
     }
-    srs = env->pregs[PR_SRS];
-    cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
-    if (srs < ARRAY_SIZE(env->sregs)) {
-        for (i = 0; i < 16; i++) {
-            cpu_fprintf(f, "s%2.2d=%8.8x ",
-                    i, env->sregs[srs][i]);
-            if ((i + 1) % 4 == 0) {
-                cpu_fprintf(f, "\n");
+    if (env->pregs[PR_VR] >= 32) {
+        uint32_t srs = env->pregs[PR_SRS];
+        cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs);
+        if (srs < ARRAY_SIZE(env->sregs)) {
+            for (i = 0; i < 16; i++) {
+                cpu_fprintf(f, "s%2.2d=%8.8x ",
+                        i, env->sregs[srs][i]);
+                if ((i + 1) % 4 == 0) {
+                    cpu_fprintf(f, "\n");
+                }
             }
         }
     }
@@ -3406,12 +3416,12 @@ void cris_initialize_tcg(void)
     for (i = 0; i < 16; i++) {
         cpu_R[i] = tcg_global_mem_new(cpu_env,
                                       offsetof(CPUCRISState, regs[i]),
-                                      regnames[i]);
+                                      regnames_v32[i]);
     }
     for (i = 0; i < 16; i++) {
         cpu_PR[i] = tcg_global_mem_new(cpu_env,
                                        offsetof(CPUCRISState, pregs[i]),
-                                       pregnames[i]);
+                                       pregnames_v32[i]);
     }
 }
 
Signature · 1 line
2.1.4
#16 lore raw

PATCH 7/9 target-cris: ignore prefix insns in singlestep

In reply to Rabin Vincent

From: Hans-Peter Nilsson <[email protected]>

Don't count prefix instructions as separate when singlestepping.

For example, for this following instruction

1ad8: a011 e00b move.d r0,[r1-96]

before this patch, we get two register dumps:

PC=1ad8 CCS=0 btaken=1 btarget=1ac6
cc_op=1 cc_src=3746 cc_dest=1 cc_result=ea2 cc_mask=0 $r0=00000000 $r1=00004360 $r2=00004308 $r3=0000026c $r4=00002076 $r5=00002022 $r6=00000000 $r7=00000000 $r8=00000000 $r9=00000ea2 $r10=00000002 $r11=00004308 $r12=00001080 $r13=00000ec0 $sp=0000bfd8 $pc=00001ad4

PC=1ada CCS=800 btaken=1 btarget=1ac6 cc_op=1 cc_src=3746 cc_dest=1 cc_result=ea2 cc_mask=0 $r0=00000000 $r1=00004360 $r2=00004308 $r3=0000026c $r4=00002076 $r5=00002022 $r6=00000000 $r7=00000000 $r8=00000000 $r9=00000ea2 $r10=00000002 $r11=00004308 $r12=00001080 $r13=00000ec0 $sp=0000bfd8 $pc=00001ad4

With the patch, we get only one:

PC=1ad8 CCS=0 btaken=1 btarget=1ac6
cc_op=1 cc_src=3746 cc_dest=1 cc_result=ea2 cc_mask=0 $r0=00000000 $r1=00004360 $r2=00004308 $r3=0000026c $r4=00002076 $r5=00002022 $r6=00000000 $r7=00000000 $r8=00000000 $r9=00000ea2 $r10=00000002 $r11=00004308 $r12=00001080 $r13=00000ec0 $sp=0000bfd8 $pc=00001ad4

---
 target-cris/translate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target-cris/translate.c +2 -1
index a4512b5..c9b1e65 100644
@@ -3262,7 +3262,8 @@ void gen_intermediate_code(CPUCRISState *env, struct TranslationBlock *tb)
         }
     } while (!dc->is_jmp && !dc->cpustate_changed
             && !tcg_op_buf_full()
-            && !singlestep
+            /* We don't count prefix insns as separate wrt. singlestep.  */
+            && (!singlestep || (dc->tb_flags & PFIX_FLAG))
             && (dc->pc < next_page_start)
             && num_insns < max_insns);
 
Signature · 1 line
2.1.4
#17 lore raw

Re: [Qemu-devel] [PATCH 7/9] target-cris: ignore prefix insns in singlestep

Quoted 24 lines · Rabin Vincent

From: Hans-Peter Nilsson <[email protected]>

Don't count prefix instructions as separate when singlestepping.

For example, for this following instruction

1ad8: a011 e00b move.d r0,[r1-96]

before this patch, we get two register dumps:

PC=1ad8 CCS=0 btaken=1 btarget=1ac6
cc_op=1 cc_src=3746 cc_dest=1 cc_result=ea2 cc_mask=0 $r0=00000000 $r1=00004360 $r2=00004308 $r3=0000026c $r4=00002076 $r5=00002022 $r6=00000000 $r7=00000000 $r8=00000000 $r9=00000ea2 $r10=00000002 $r11=00004308 $r12=00001080 $r13=00000ec0 $sp=0000bfd8 $pc=00001ad4

PC=1ada CCS=800 btaken=1 btarget=1ac6 cc_op=1 cc_src=3746 cc_dest=1 cc_result=ea2 cc_mask=0 $r0=00000000 $r1=00004360 $r2=00004308 $r3=0000026c $r4=00002076 $r5=00002022 $r6=00000000 $r7=00000000 $r8=00000000 $r9=00000ea2 $r10=00000002 $r11=00004308 $r12=00001080 $r13=00000ec0 $sp=0000bfd8 $pc=00001ad4

Quoted 8 lines

With the patch, we get only one:

PC=1ad8 CCS=0 btaken=1 btarget=1ac6
cc_op=1 cc_src=3746 cc_dest=1 cc_result=ea2 cc_mask=0 $r0=00000000 $r1=00004360 $r2=00004308 $r3=0000026c $r4=00002076 $r5=00002022 $r6=00000000 $r7=00000000 $r8=00000000 $r9=00000ea2 $r10=00000002 $r11=00004308 $r12=00001080 $r13=00000ec0 $sp=0000bfd8 $pc=00001ad4

Hi,

A concern I have is that we can't guard against all split prefix sequences (e.g at page boundaries or with icount). So it may be more confusing to see the prefix insns sometimes than every time.

Perhaps we should more clearly be showing prefix state in the logs?

BTW, are you guys doing post-processing on this or is it only for human inspection?

Cheers,
Edgar

Quoted 24 lines
---
 target-cris/translate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target-cris/translate.c +2 -1
index a4512b5..c9b1e65 100644
@@ -3262,7 +3262,8 @@ void gen_intermediate_code(CPUCRISState *env, struct TranslationBlock *tb)
         }
     } while (!dc->is_jmp && !dc->cpustate_changed
             && !tcg_op_buf_full()
-            && !singlestep
+            /* We don't count prefix insns as separate wrt. singlestep.  */
+            && (!singlestep || (dc->tb_flags & PFIX_FLAG))
             && (dc->pc < next_page_start)
             && num_insns < max_insns);
 
Signature · 1 line
2.1.4
#18 lore raw

Re: [Qemu-devel] [PATCH 7/9] target-cris: ignore prefix insns in singlestep

Quoted 36 lines

Date: Tue, 13 Sep 2016 00:49:51 +0200
From: "Edgar E. Iglesias" <[email protected]>

Quoted 24 lines · Rabin Vincent

From: Hans-Peter Nilsson <[email protected]>

Don't count prefix instructions as separate when singlestepping.

For example, for this following instruction

1ad8: a011 e00b move.d r0,[r1-96]

before this patch, we get two register dumps:

PC=1ad8 CCS=0 btaken=1 btarget=1ac6
cc_op=1 cc_src=3746 cc_dest=1 cc_result=ea2 cc_mask=0 $r0=00000000 $r1=00004360 $r2=00004308 $r3=0000026c $r4=00002076 $r5=00002022 $r6=00000000 $r7=00000000 $r8=00000000 $r9=00000ea2 $r10=00000002 $r11=00004308 $r12=00001080 $r13=00000ec0 $sp=0000bfd8 $pc=00001ad4

PC=1ada CCS=800 btaken=1 btarget=1ac6 cc_op=1 cc_src=3746 cc_dest=1 cc_result=ea2 cc_mask=0 $r0=00000000 $r1=00004360 $r2=00004308 $r3=0000026c $r4=00002076 $r5=00002022 $r6=00000000 $r7=00000000 $r8=00000000 $r9=00000ea2 $r10=00000002 $r11=00004308 $r12=00001080 $r13=00000ec0 $sp=0000bfd8 $pc=00001ad4

Quoted 8 lines

With the patch, we get only one:

PC=1ad8 CCS=0 btaken=1 btarget=1ac6
cc_op=1 cc_src=3746 cc_dest=1 cc_result=ea2 cc_mask=0 $r0=00000000 $r1=00004360 $r2=00004308 $r3=0000026c $r4=00002076 $r5=00002022 $r6=00000000 $r7=00000000 $r8=00000000 $r9=00000ea2 $r10=00000002 $r11=00004308 $r12=00001080 $r13=00000ec0 $sp=0000bfd8 $pc=00001ad4

Quoted 5 lines

Hi,

A concern I have is that we can't guard against all split prefix sequences (e.g at page boundaries or with icount). So it may be more confusing to see the prefix insns sometimes than every time.

I've forgotten most details, and have to refer to Rabin for useful answers.

However, from the few glimpses I remember, basically I had to key on "singlestep" and force a re-translation to get usable dumps that didn't skip dump of state from all instructions inside a translated hunk on subsequent executions. There were some hacks^Wpatches left-out (for being too invasive and hackish, IIRC) to that effect, not sure how they affected this particular code here.

Quoted 1 line

Perhaps we should more clearly be showing prefix state in the logs?

No: I'd rather just not have prefix instructions dumped separately whenever possible as dumps get really big really quick, but maybe both this patch and a prefix indicator then, to reduce confusion. I guess a better deal would be a method that enables consistent dumps; page boundaries and icount shouldn't affect dumps. Maybe qemu has improved and there's a generic method to get useful register dumps *from every instruction at every execution* these days.

Quoted 1 line

BTW, are you guys doing post-processing on this

Certainly. The output was massaged to have the same format as dumps from another simulator, then fed into a script for use together with the executable to get readable output (somewhat at call-graph-level).

Quoted 28 lines

or is it only
for human inspection?

Cheers,
Edgar

Quoted 21 lines
---
 target-cris/translate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target-cris/translate.c +2 -1
index a4512b5..c9b1e65 100644
@@ -3262,7 +3262,8 @@ void gen_intermediate_code(CPUCRISState *env, struct TranslationBlock *tb)
         }
     } while (!dc->is_jmp && !dc->cpustate_changed
             && !tcg_op_buf_full()
-            && !singlestep
+            /* We don't count prefix insns as separate wrt. singlestep.  */
+            && (!singlestep || (dc->tb_flags & PFIX_FLAG))
             && (dc->pc < next_page_start)
             && num_insns < max_insns);
 
Quoted 4 lines
Quoted 3 lines
Signature · 1 line
2.1.4

brgds, H-P

#19 lore raw

PATCH 8/9 target-cris: add v17 CPU

In reply to Rabin Vincent

From: Rabin Vincent <[email protected]>

In the CRIS v17 CPU an ADDC (add with carry) instruction has been added compared to the v10 instruction set.

Assembler syntax:

ADDC [Rs],Rd
ADDC [Rs+],Rd

Size: Dword

Description:

The source data is added together with the carry flag to the destination register. The size of the operation is dword.

Operation:

  Rd += s + C-flag;

Flags affected:

S R P U I X N Z V C
- - - - - 0 * * * *

Instruction format: ADDC [Rs],Rd

  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  |Destination(Rd)| 1   0   0   1   1   0   1   0 |   Source(Rs)  |
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

Instruction format: ADDC [Rs+],Rd

  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  |Destination(Rd)| 1   1   0   1   1   0   1   0 |   Source(Rs)  |
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
---
 target-cris/cpu.c            | 14 ++++++++++++++
 target-cris/crisv10-decode.h |  1 +
 target-cris/translate_v10.c  |  8 ++++++++
 3 files changed, 23 insertions(+)
target-cris/cpu.c +14 -0
index c5a656b..d680cfb 100644
@@ -246,6 +246,16 @@ static void crisv11_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_read_register = crisv10_cpu_gdb_read_register;
 }
 
+static void crisv17_cpu_class_init(ObjectClass *oc, void *data)
+{
+    CPUClass *cc = CPU_CLASS(oc);
+    CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
+
+    ccc->vr = 17;
+    cc->do_interrupt = crisv10_cpu_do_interrupt;
+    cc->gdb_read_register = crisv10_cpu_gdb_read_register;
+}
+
 static void crisv32_cpu_class_init(ObjectClass *oc, void *data)
 {
     CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
@@ -273,6 +283,10 @@ static const TypeInfo cris_cpu_model_type_infos[] = {
         .parent = TYPE_CRIS_CPU,
         .class_init = crisv11_cpu_class_init,
     }, {
+        .name = TYPE("crisv17"),
+        .parent = TYPE_CRIS_CPU,
+        .class_init = crisv17_cpu_class_init,
+    }, {
         .name = TYPE("crisv32"),
         .parent = TYPE_CRIS_CPU,
         .class_init = crisv32_cpu_class_init,
target-cris/crisv10-decode.h +1 -0
index 587fbdd..bdb4b6d 100644
@@ -92,6 +92,7 @@
 #define CRISV10_IND_JUMP_M       4
 #define CRISV10_IND_DIP          5
 #define CRISV10_IND_JUMP_R       6
+#define CRISV17_IND_ADDC         6
 #define CRISV10_IND_BOUND        7
 #define CRISV10_IND_BCC_M        7
 #define CRISV10_IND_MOVE_M_SPR   8
target-cris/translate_v10.c +8 -0
index a3da425..33d86eb 100644
@@ -1097,6 +1097,14 @@ static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc)
                 insn_len = dec10_bdap_m(env, dc, size);
                 break;
             default:
+                if (dc->opcode == CRISV17_IND_ADDC && dc->size == 2 &&
+                    env->pregs[PR_VR] == 17) {
+                    LOG_DIS("addc op=%d %d\n",  dc->src, dc->dst);
+                    cris_cc_mask(dc, CC_MASK_NZVC);
+                    insn_len += dec10_ind_alu(env, dc, CC_OP_ADDC, size);
+                    break;
+                }
+
                 LOG_DIS("pc=%x var-ind.%d %d r%d r%d\n",
                           dc->pc, size, dc->opcode, dc->src, dc->dst);
                 cpu_abort(CPU(dc->cpu), "Unhandled opcode");
Signature · 1 line
2.1.4
#20 lore raw

Re: [Qemu-devel] [PATCH 8/9] target-cris: add v17 CPU

Quoted 94 lines · Rabin Vincent

From: Rabin Vincent <[email protected]>

In the CRIS v17 CPU an ADDC (add with carry) instruction has been added compared to the v10 instruction set.

Assembler syntax:

ADDC [Rs],Rd
ADDC [Rs+],Rd

Size: Dword

Description:

The source data is added together with the carry flag to the destination register. The size of the operation is dword.

Operation:

  Rd += s + C-flag;

Flags affected:

S R P U I X N Z V C
- - - - - 0 * * * *

Instruction format: ADDC [Rs],Rd

  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  |Destination(Rd)| 1   0   0   1   1   0   1   0 |   Source(Rs)  |
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

Instruction format: ADDC [Rs+],Rd

  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  |Destination(Rd)| 1   1   0   1   1   0   1   0 |   Source(Rs)  |
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
---
 target-cris/cpu.c            | 14 ++++++++++++++
 target-cris/crisv10-decode.h |  1 +
 target-cris/translate_v10.c  |  8 ++++++++
 3 files changed, 23 insertions(+)
target-cris/cpu.c +14 -0
index c5a656b..d680cfb 100644
@@ -246,6 +246,16 @@ static void crisv11_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_read_register = crisv10_cpu_gdb_read_register;
 }
 
+static void crisv17_cpu_class_init(ObjectClass *oc, void *data)
+{
+    CPUClass *cc = CPU_CLASS(oc);
+    CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
+
+    ccc->vr = 17;
+    cc->do_interrupt = crisv10_cpu_do_interrupt;
+    cc->gdb_read_register = crisv10_cpu_gdb_read_register;
+}
+
 static void crisv32_cpu_class_init(ObjectClass *oc, void *data)
 {
     CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
@@ -273,6 +283,10 @@ static const TypeInfo cris_cpu_model_type_infos[] = {
         .parent = TYPE_CRIS_CPU,
         .class_init = crisv11_cpu_class_init,
     }, {
+        .name = TYPE("crisv17"),
+        .parent = TYPE_CRIS_CPU,
+        .class_init = crisv17_cpu_class_init,
+    }, {
         .name = TYPE("crisv32"),
         .parent = TYPE_CRIS_CPU,
         .class_init = crisv32_cpu_class_init,
target-cris/crisv10-decode.h +1 -0
index 587fbdd..bdb4b6d 100644
@@ -92,6 +92,7 @@
 #define CRISV10_IND_JUMP_M       4
 #define CRISV10_IND_DIP          5
 #define CRISV10_IND_JUMP_R       6
+#define CRISV17_IND_ADDC         6
 #define CRISV10_IND_BOUND        7
 #define CRISV10_IND_BCC_M        7
 #define CRISV10_IND_MOVE_M_SPR   8
target-cris/translate_v10.c +0 -0
index a3da425..33d86eb 100644

target-cris/translate_v10.c static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc) · line 1101

Quoted 5 lines
target-cris/translate_v10.c +2 -0
@@ -1097,6 +1097,14 @@ static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc)
                 insn_len = dec10_bdap_m(env, dc, size);
                 break;
             default:
+                if (dc->opcode == CRISV17_IND_ADDC && dc->size == 2 &&
+                    env->pregs[PR_VR] == 17) {

Hi Rabin,

Could you please add some comments on the insn encoding? Put the stuff from the commit msg in here.
IIRC, ADDC and v17 are modifications made to the CRISv10 family of cores that never made it into the public manuals. Or am I wrong?

Cheers,
Edgar

Quoted 12 lines
target-cris/translate_v10.c +6 -0
+                    LOG_DIS("addc op=%d %d\n",  dc->src, dc->dst);
+                    cris_cc_mask(dc, CC_MASK_NZVC);
+                    insn_len += dec10_ind_alu(env, dc, CC_OP_ADDC, size);
+                    break;
+                }
+
                 LOG_DIS("pc=%x var-ind.%d %d r%d r%d\n",
                           dc->pc, size, dc->opcode, dc->src, dc->dst);
                 cpu_abort(CPU(dc->cpu), "Unhandled opcode");
Signature · 1 line
2.1.4
#21 lore raw

Re: [Qemu-devel] [PATCH 8/9] target-cris: add v17 CPU

Quoted 14 lines · Edgar E. Iglesias

target-cris/translate_v10.c static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc) · line 1101

Quoted 10 lines · Rabin Vincent
target-cris/translate_v10.c +2 -0
index a3da425..33d86eb 100644
@@ -1097,6 +1097,14 @@ static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc)
                 insn_len = dec10_bdap_m(env, dc, size);
                 break;
             default:
+                if (dc->opcode == CRISV17_IND_ADDC && dc->size == 2 &&
+                    env->pregs[PR_VR] == 17) {

Could you please add some comments on the insn encoding? Put the stuff from the commit msg in here.

OK, see new patch below.

Quoted 2 lines

IIRC, ADDC and v17 are modifications made to the CRISv10 family of cores that never made it into the public manuals. Or am I wrong?

No, you're right.

8<---------------

Quoted 1 line

From 513465ad3f007885bafba3482705ba57cacd588b Mon Sep 17 00:00:00 2001

From: Rabin Vincent <[email protected]>
Date: Mon, 15 Aug 2016 13:59:32 +0200
Subject: [PATCH] target-cris: add v17 CPU

In the CRIS v17 CPU an ADDC (add with carry) instruction has been added compared to the v10 instruction set.

Assembler syntax:

ADDC [Rs],Rd
ADDC [Rs+],Rd

Size: Dword

Description:

The source data is added together with the carry flag to the destination register. The size of the operation is dword.

Operation:

  Rd += s + C-flag;

Flags affected:

S R P U I X N Z V C
- - - - - 0 * * * *

Instruction format: ADDC [Rs],Rd

  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  |Destination(Rd)| 1   0   0   1   1   0   1   0 |   Source(Rs)  |
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

Instruction format: ADDC [Rs+],Rd

  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  |Destination(Rd)| 1   1   0   1   1   0   1   0 |   Source(Rs)  |
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
---
 target-cris/cpu.c            | 14 ++++++++++++++
 target-cris/crisv10-decode.h |  1 +
 target-cris/translate_v10.c  | 23 +++++++++++++++++++++++
 3 files changed, 38 insertions(+)
target-cris/cpu.c +14 -0
index c5a656b..d680cfb 100644
@@ -246,6 +246,16 @@ static void crisv11_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_read_register = crisv10_cpu_gdb_read_register;
 }
 
+static void crisv17_cpu_class_init(ObjectClass *oc, void *data)
+{
+    CPUClass *cc = CPU_CLASS(oc);
+    CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
+
+    ccc->vr = 17;
+    cc->do_interrupt = crisv10_cpu_do_interrupt;
+    cc->gdb_read_register = crisv10_cpu_gdb_read_register;
+}
+
 static void crisv32_cpu_class_init(ObjectClass *oc, void *data)
 {
     CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
@@ -273,6 +283,10 @@ static const TypeInfo cris_cpu_model_type_infos[] = {
         .parent = TYPE_CRIS_CPU,
         .class_init = crisv11_cpu_class_init,
     }, {
+        .name = TYPE("crisv17"),
+        .parent = TYPE_CRIS_CPU,
+        .class_init = crisv17_cpu_class_init,
+    }, {
         .name = TYPE("crisv32"),
         .parent = TYPE_CRIS_CPU,
         .class_init = crisv32_cpu_class_init,
target-cris/crisv10-decode.h +1 -0
index 587fbdd..bdb4b6d 100644
@@ -92,6 +92,7 @@
 #define CRISV10_IND_JUMP_M       4
 #define CRISV10_IND_DIP          5
 #define CRISV10_IND_JUMP_R       6
+#define CRISV17_IND_ADDC         6
 #define CRISV10_IND_BOUND        7
 #define CRISV10_IND_BCC_M        7
 #define CRISV10_IND_MOVE_M_SPR   8
target-cris/translate_v10.c +23 -0
index 4707a18..0e4d039 100644
@@ -1094,6 +1094,29 @@ static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc)
                 insn_len = dec10_bdap_m(env, dc, size);
                 break;
             default:
+                /*
+                 * ADDC for v17:
+                 *
+                 * Instruction format: ADDC [Rs],Rd
+                 *
+                 *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
+                 *  |Destination(Rd)| 1   0   0   1   1   0   1   0 |   Source(Rs)  |
+                 *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
+                 *
+                 * Instruction format: ADDC [Rs+],Rd
+                 *
+                 *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
+                 *  |Destination(Rd)| 1   1   0   1   1   0   1   0 |   Source(Rs)  |
+                 *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
+                 */
+                if (dc->opcode == CRISV17_IND_ADDC && dc->size == 2 &&
+                    env->pregs[PR_VR] == 17) {
+                    LOG_DIS("addc op=%d %d\n",  dc->src, dc->dst);
+                    cris_cc_mask(dc, CC_MASK_NZVC);
+                    insn_len += dec10_ind_alu(env, dc, CC_OP_ADDC, size);
+                    break;
+                }
+
                 LOG_DIS("pc=%x var-ind.%d %d r%d r%d\n",
                           dc->pc, size, dc->opcode, dc->src, dc->dst);
                 cpu_abort(CPU(dc->cpu), "Unhandled opcode");
Signature · 1 line
2.1.4
#22 lore raw

Re: [Qemu-devel] [PATCH 8/9] target-cris: add v17 CPU

Quoted 16 lines · Rabin Vincent
Quoted 14 lines · Edgar E. Iglesias

target-cris/translate_v10.c static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc) · line 1101

Quoted 10 lines · Rabin Vincent
target-cris/translate_v10.c +2 -0
index a3da425..33d86eb 100644
@@ -1097,6 +1097,14 @@ static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc)
                 insn_len = dec10_bdap_m(env, dc, size);
                 break;
             default:
+                if (dc->opcode == CRISV17_IND_ADDC && dc->size == 2 &&
+                    env->pregs[PR_VR] == 17) {

Could you please add some comments on the insn encoding? Put the stuff from the commit msg in here.

Quoted 4 lines

OK, see new patch below.

Quoted 2 lines

IIRC, ADDC and v17 are modifications made to the CRISv10 family of cores that never made it into the public manuals. Or am I wrong?

Thanks Rabin,

I've applied these except patch #7 "ignore prefix insns in singlestep". Patch #8 had an issue with checkpatch that I fixed up.

Cheers,
Edgar

Quoted 133 lines

No, you're right.

8<---------------
From 513465ad3f007885bafba3482705ba57cacd588b Mon Sep 17 00:00:00 2001
From: Rabin Vincent <[email protected]>
Date: Mon, 15 Aug 2016 13:59:32 +0200
Subject: [PATCH] target-cris: add v17 CPU

In the CRIS v17 CPU an ADDC (add with carry) instruction has been added compared to the v10 instruction set.

Assembler syntax:

ADDC [Rs],Rd
ADDC [Rs+],Rd

Size: Dword

Description:

The source data is added together with the carry flag to the destination register. The size of the operation is dword.

Operation:

  Rd += s + C-flag;

Flags affected:

S R P U I X N Z V C
- - - - - 0 * * * *

Instruction format: ADDC [Rs],Rd

  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  |Destination(Rd)| 1   0   0   1   1   0   1   0 |   Source(Rs)  |
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

Instruction format: ADDC [Rs+],Rd

  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
  |Destination(Rd)| 1   1   0   1   1   0   1   0 |   Source(Rs)  |
  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
---
 target-cris/cpu.c            | 14 ++++++++++++++
 target-cris/crisv10-decode.h |  1 +
 target-cris/translate_v10.c  | 23 +++++++++++++++++++++++
 3 files changed, 38 insertions(+)
target-cris/cpu.c +14 -0
index c5a656b..d680cfb 100644
@@ -246,6 +246,16 @@ static void crisv11_cpu_class_init(ObjectClass *oc, void *data)
     cc->gdb_read_register = crisv10_cpu_gdb_read_register;
 }
 
+static void crisv17_cpu_class_init(ObjectClass *oc, void *data)
+{
+    CPUClass *cc = CPU_CLASS(oc);
+    CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
+
+    ccc->vr = 17;
+    cc->do_interrupt = crisv10_cpu_do_interrupt;
+    cc->gdb_read_register = crisv10_cpu_gdb_read_register;
+}
+
 static void crisv32_cpu_class_init(ObjectClass *oc, void *data)
 {
     CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
@@ -273,6 +283,10 @@ static const TypeInfo cris_cpu_model_type_infos[] = {
         .parent = TYPE_CRIS_CPU,
         .class_init = crisv11_cpu_class_init,
     }, {
+        .name = TYPE("crisv17"),
+        .parent = TYPE_CRIS_CPU,
+        .class_init = crisv17_cpu_class_init,
+    }, {
         .name = TYPE("crisv32"),
         .parent = TYPE_CRIS_CPU,
         .class_init = crisv32_cpu_class_init,
target-cris/crisv10-decode.h +1 -0
index 587fbdd..bdb4b6d 100644
@@ -92,6 +92,7 @@
 #define CRISV10_IND_JUMP_M       4
 #define CRISV10_IND_DIP          5
 #define CRISV10_IND_JUMP_R       6
+#define CRISV17_IND_ADDC         6
 #define CRISV10_IND_BOUND        7
 #define CRISV10_IND_BCC_M        7
 #define CRISV10_IND_MOVE_M_SPR   8
target-cris/translate_v10.c +23 -0
index 4707a18..0e4d039 100644
@@ -1094,6 +1094,29 @@ static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc)
                 insn_len = dec10_bdap_m(env, dc, size);
                 break;
             default:
+                /*
+                 * ADDC for v17:
+                 *
+                 * Instruction format: ADDC [Rs],Rd
+                 *
+                 *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
+                 *  |Destination(Rd)| 1   0   0   1   1   0   1   0 |   Source(Rs)  |
+                 *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
+                 *
+                 * Instruction format: ADDC [Rs+],Rd
+                 *
+                 *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
+                 *  |Destination(Rd)| 1   1   0   1   1   0   1   0 |   Source(Rs)  |
+                 *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
+                 */
+                if (dc->opcode == CRISV17_IND_ADDC && dc->size == 2 &&
+                    env->pregs[PR_VR] == 17) {
+                    LOG_DIS("addc op=%d %d\n",  dc->src, dc->dst);
+                    cris_cc_mask(dc, CC_MASK_NZVC);
+                    insn_len += dec10_ind_alu(env, dc, CC_OP_ADDC, size);
+                    break;
+                }
+
                 LOG_DIS("pc=%x var-ind.%d %d r%d r%d\n",
                           dc->pc, size, dc->opcode, dc->src, dc->dst);
                 cpu_abort(CPU(dc->cpu), "Unhandled opcode");
Signature · 1 line
2.1.4
#23 lore raw

Re: [Qemu-devel] [PATCH 8/9] target-cris: add v17 CPU

Quoted 2 lines · Edgar E. Iglesias

I've applied these except patch #7 "ignore prefix insns in singlestep". Patch #8 had an issue with checkpatch that I fixed up.

Oops, thank you.

#24 lore raw

PATCH 9/9 tests: cris: add v17 ADDC test

In reply to Rabin Vincent

From: Rabin Vincent <[email protected]>

Add a test for the newly implemented ADDC instruction in the v17 CRIS CPU.

---
 tests/tcg/cris/Makefile        | 19 ++++++++++--
 tests/tcg/cris/check_addcv17.s | 65 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+), 2 deletions(-)
 create mode 100644 tests/tcg/cris/check_addcv17.s
tests/tcg/cris/Makefile +17 -2
index 14a9eb5..6b3dba4 100644
@@ -23,6 +23,7 @@ SYS        = sys.o
 TESTCASES += check_abs.tst
 TESTCASES += check_addc.tst
 TESTCASES += check_addcm.tst
+TESTCASES += check_addcv17.tst
 TESTCASES += check_addo.tst
 TESTCASES += check_addoq.tst
 TESTCASES += check_addi.tst
@@ -134,13 +135,27 @@ all: build
 %.ctst: %.o
 	$(CC) $(CFLAGS) $(LDLIBS) $< -o $@
 
+
+sysv10.o: sys.c
+	$(CC) $(CFLAGS) -mcpu=v10 -c $< -o $@
+
+crtv10.o: crt.s
+	$(AS) $(ASFLAGS) -mcpu=v10 -c $< -o $@
+
+check_addcv17.tst: ASFLAGS += -mcpu=v10
+check_addcv17.tst: CRT := crtv10.o
+check_addcv17.tst: SYS := sysv10.o
+check_addcv17.tst: crtv10.o sysv10.o
+
 build: $(CRT) $(SYS) $(TESTCASES)
 
 check: $(CRT) $(SYS) $(TESTCASES)
 	@echo -e "\nQEMU simulator."
 	for case in $(TESTCASES); do \
 		echo -n "$$case "; \
-		$(SIM) ./$$case; \
+		SIMARGS=; \
+		case $$case in *v17*) SIMARGS="-cpu crisv17";; esac; \
+		$(SIM) $$SIMARGS ./$$case; \
 	done
 check-g: $(CRT) $(SYS) $(TESTCASES)
 	@echo -e "\nGDB simulator."
@@ -150,4 +165,4 @@ check-g: $(CRT) $(SYS) $(TESTCASES)
 	done
 
 clean:
-	$(RM) -fr $(TESTCASES) $(CRT) $(SYS)
+	$(RM) -fr $(TESTCASES) *.o
tests/tcg/cris/check_addcv17.s new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.1.4
Acked-by on v1 9/9
#25 lore raw

Re: [Qemu-devel] [PATCH 9/9] tests: cris: add v17 ADDC test

Quoted 6 lines · Rabin Vincent

From: Rabin Vincent <[email protected]>

Add a test for the newly implemented ADDC instruction in the v17 CRIS CPU.

Quoted 127 lines
---
 tests/tcg/cris/Makefile        | 19 ++++++++++--
 tests/tcg/cris/check_addcv17.s | 65 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+), 2 deletions(-)
 create mode 100644 tests/tcg/cris/check_addcv17.s
tests/tcg/cris/Makefile +17 -2
index 14a9eb5..6b3dba4 100644
@@ -23,6 +23,7 @@ SYS        = sys.o
 TESTCASES += check_abs.tst
 TESTCASES += check_addc.tst
 TESTCASES += check_addcm.tst
+TESTCASES += check_addcv17.tst
 TESTCASES += check_addo.tst
 TESTCASES += check_addoq.tst
 TESTCASES += check_addi.tst
@@ -134,13 +135,27 @@ all: build
 %.ctst: %.o
 	$(CC) $(CFLAGS) $(LDLIBS) $< -o $@
 
+
+sysv10.o: sys.c
+	$(CC) $(CFLAGS) -mcpu=v10 -c $< -o $@
+
+crtv10.o: crt.s
+	$(AS) $(ASFLAGS) -mcpu=v10 -c $< -o $@
+
+check_addcv17.tst: ASFLAGS += -mcpu=v10
+check_addcv17.tst: CRT := crtv10.o
+check_addcv17.tst: SYS := sysv10.o
+check_addcv17.tst: crtv10.o sysv10.o
+
 build: $(CRT) $(SYS) $(TESTCASES)
 
 check: $(CRT) $(SYS) $(TESTCASES)
 	@echo -e "\nQEMU simulator."
 	for case in $(TESTCASES); do \
 		echo -n "$$case "; \
-		$(SIM) ./$$case; \
+		SIMARGS=; \
+		case $$case in *v17*) SIMARGS="-cpu crisv17";; esac; \
+		$(SIM) $$SIMARGS ./$$case; \
 	done
 check-g: $(CRT) $(SYS) $(TESTCASES)
 	@echo -e "\nGDB simulator."
@@ -150,4 +165,4 @@ check-g: $(CRT) $(SYS) $(TESTCASES)
 	done
 
 clean:
-	$(RM) -fr $(TESTCASES) $(CRT) $(SYS)
+	$(RM) -fr $(TESTCASES) *.o
tests/tcg/cris/check_addcv17.s new file +65 -0
new file mode 100644
index 0000000..52ef7a9
@@ -0,0 +1,65 @@
+# mach:  crisv17
+
+ .include "testutils.inc"
+
+ .macro addc Rs Rd inc=0
+# Create the instruction manually since there is no assembler support yet
+ .word (\Rd << 12) | \Rs | (\inc << 10) | 0x09a0
+ .endm
+
+ start
+
+ .data
+mem1:
+ .dword 0x0
+mem2:
+ .dword 0x12345678
+
+ .text
+ move.d mem1,r4
+ clearf nzvc
+ addc 4 3
+ test_cc 0 1 0 0
+ checkr3 0
+
+ move.d mem1,r4
+ clearf nzvc
+ ax
+ addc 4 3
+ test_cc 0 0 0 0
+ checkr3 0
+
+ move.d mem1,r4
+ clearf nzvc
+ setf c
+ addc 4 3
+ test_cc 0 0 0 0
+ checkr3 1
+
+ move.d mem2,r4
+ moveq 2, r3
+ clearf nzvc
+ setf c
+ addc 4 3
+ test_cc 0 0 0 0
+ checkr3 1234567b
+
+ move.d mem2,r5
+ clearf nzvc
+ cmp.d r4,r5
+ test_cc 0 1 0 0
+
+ move.d mem2,r4
+ moveq 2, r3
+ clearf nzvc
+ addc 4 3 inc=1
+ test_cc 0 0 0 0
+ checkr3 1234567a
+
+ move.d mem2,r5
+ clearf nzvc
+ addq 4,r5
+ cmp.d r4,r5
+ test_cc 0 1 0 0
+
+ quit
Signature · 1 line
2.1.4
#26 lore raw
In reply to Rabin Vincent
Quoted 6 lines · Rabin Vincent

From: Rabin Vincent <[email protected]>

The CRIS tests expect that functions marked inline are always inline. With newer versions of GCC, building them results warnings like the following and spurious failures when they are run.

Quoted 6 lines

In file included from tests/tcg/cris/check_moveq.c:5:0:
tests/tcg/cris/crisutils.h:66:20: warning: inlining failed in call to 'cris_tst_cc.constprop.0': call is unlikely and code size would grow [-Winline] tests/tcg/cris/check_moveq.c:28:13: warning: called from here [-Winline]

Use the always_inline attribute when building them to fix this.

Hi Rabin,

Do you happen to have a public git tree/branch with these changes?

Best regards,
Edgar

Quoted 22 lines
---
 tests/tcg/cris/sys.h | 2 ++
 1 file changed, 2 insertions(+)
tests/tcg/cris/sys.h +2 -0
index c5f88e1..b1bf4c5 100644
@@ -3,6 +3,8 @@
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 
+#define inline inline __attribute__((always_inline))
+
 #define CURRENT_LOCATION __FILE__ ":" TOSTRING(__LINE__)
 
 #define err()                         \
Signature · 1 line
2.1.4
#27 lore raw
Quoted 12 lines · Edgar E. Iglesias
Quoted 11 lines · Rabin Vincent

From: Rabin Vincent <[email protected]>

The CRIS tests expect that functions marked inline are always inline. With newer versions of GCC, building them results warnings like the following and spurious failures when they are run.

In file included from tests/tcg/cris/check_moveq.c:5:0:
tests/tcg/cris/crisutils.h:66:20: warning: inlining failed in call to 'cris_tst_cc.constprop.0': call is unlikely and code size would grow [-Winline] tests/tcg/cris/check_moveq.c:28:13: warning: called from here [-Winline]

Quoted 5 lines
Quoted 1 line

Use the always_inline attribute when building them to fix this.

Hi Rabin,

Do you happen to have a public git tree/branch with these changes?

I've dropped the "sync CC state" patch for now and pushed the rest up to the cris branch of https://github.com/rabinv/qemu/.

#28 lore raw
In reply to Rabin Vincent
Quoted 6 lines · Rabin Vincent

From: Rabin Vincent <[email protected]>

The CRIS tests expect that functions marked inline are always inline. With newer versions of GCC, building them results warnings like the following and spurious failures when they are run.

Quoted 6 lines

In file included from tests/tcg/cris/check_moveq.c:5:0:
tests/tcg/cris/crisutils.h:66:20: warning: inlining failed in call to 'cris_tst_cc.constprop.0': call is unlikely and code size would grow [-Winline] tests/tcg/cris/check_moveq.c:28:13: warning: called from here [-Winline]

Use the always_inline attribute when building them to fix this.

This test code is pretty horrific; it relies on a whole bunch of stuff that the compiler doesn't actually guarantee you, and using always-inline is just a bandaid over the real problem (which is that it should really be using multi-insn asm statements when it cares about order, and not assuming it can put two asm statements next to each other and set cflags in one and read them in another).

That said, you probably aren't interested in rewriting it, so:

Quoted 10 lines
---
 tests/tcg/cris/sys.h | 2 ++
 1 file changed, 2 insertions(+)
tests/tcg/cris/sys.h +0 -0
index c5f88e1..b1bf4c5 100644

tests/tcg/cris/sys.h line 7

Quoted 5 lines
tests/tcg/cris/sys.h +2 -0
@@ -3,6 +3,8 @@
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 
+#define inline inline __attribute__((always_inline))
+

I think redefining C keywords is generally a bad idea. Can you instead define an "always_inline" macro and use it where necessary?

thanks
-- PMM

#29 lore raw
Quoted 11 lines · Peter Maydell

tests/tcg/cris/sys.h line 7

Quoted 7 lines

+++ b/tests/tcg/cris/sys.h

tests/tcg/cris/sys.h +2 -0
@@ -3,6 +3,8 @@
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 
+#define inline inline __attribute__((always_inline))
+

I think redefining C keywords is generally a bad idea. Can you instead define an "always_inline" macro and use it where necessary?

In fact, commit b11d029b is an instance where compilation failed weirdly because we redefined inline. I agree that a separate macro name, added on where desired, rather than redefining 'inline' itself, is desirable.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#30 lore raw

PATCH v2 1/8 tests: cris: force inlining

In reply to Peter Maydell

From: Rabin Vincent <[email protected]>

The CRIS tests expect that functions marked inline are always inline. With newer versions of GCC, building them results warnings like the following and spurious failures when they are run.

In file included from tests/tcg/cris/check_moveq.c:5:0:
tests/tcg/cris/crisutils.h:66:20: warning: inlining failed in call to 'cris_tst_cc.constprop.0': call is unlikely and code size would grow [-Winline] tests/tcg/cris/check_moveq.c:28:13: warning: called from here [-Winline]

Use the always_inline attribute when building them to fix this.

---
v2: don't redefine inline

 tests/tcg/cris/check_abs.c   |  4 ++--
 tests/tcg/cris/check_addc.c  |  2 +-
 tests/tcg/cris/check_addcm.c |  4 ++--
 tests/tcg/cris/check_bound.c |  6 +++---
 tests/tcg/cris/check_ftag.c  |  8 ++++----
 tests/tcg/cris/check_int64.c |  4 ++--
 tests/tcg/cris/check_lz.c    |  2 +-
 tests/tcg/cris/check_swap.c  |  2 +-
 tests/tcg/cris/crisutils.h   | 20 ++++++++++----------
 tests/tcg/cris/sys.h         |  2 ++
 10 files changed, 28 insertions(+), 26 deletions(-)
tests/tcg/cris/check_abs.c +2 -2
index 9770a8d..08b67b6 100644
@@ -4,14 +4,14 @@
 #include "sys.h"
 #include "crisutils.h"
 
-static inline int cris_abs(int n)
+static always_inline int cris_abs(int n)
 {
 	int r;
 	asm ("abs\t%1, %0\n" : "=r" (r) : "r" (n));
 	return r;
 }
 
-static inline void
+static always_inline void
 verify_abs(int val, int res,
 	   const int n, const int z, const int v, const int c)
 {
tests/tcg/cris/check_addc.c +1 -1
index facd1be..fc3fb1f 100644
@@ -4,7 +4,7 @@
 #include "sys.h"
 #include "crisutils.h"
 
-static inline int cris_addc(int a, const int b)
+static always_inline int cris_addc(int a, const int b)
 {
 	asm ("addc\t%1, %0\n" : "+r" (a) : "r" (b));
 	return a;
tests/tcg/cris/check_addcm.c +2 -2
index 7928bc9..b355ba1 100644
@@ -5,14 +5,14 @@
 #include "crisutils.h"
 
 /* need to avoid acr as source here.  */
-static inline int cris_addc_m(int a, const int *b)
+static always_inline int cris_addc_m(int a, const int *b)
 {
 	asm volatile ("addc [%1], %0\n" : "+r" (a) : "r" (b));
 	return a;
 }
 
 /* 'b' is a crisv32 constrain to avoid postinc with $acr.  */
-static inline int cris_addc_pi_m(int a, int **b)
+static always_inline int cris_addc_pi_m(int a, int **b)
 {
 	asm volatile ("addc [%1+], %0\n" : "+r" (a), "+b" (*b));
 	return a;
tests/tcg/cris/check_bound.c +3 -3
index e883175..d956ab9 100644
@@ -4,21 +4,21 @@
 #include "sys.h"
 #include "crisutils.h"
 
-static inline int cris_bound_b(int v, int b)
+static always_inline int cris_bound_b(int v, int b)
 {
 	int r = v;
 	asm ("bound.b\t%1, %0\n" : "+r" (r) : "ri" (b));
 	return r;
 }
 
-static inline int cris_bound_w(int v, int b)
+static always_inline int cris_bound_w(int v, int b)
 {
 	int r = v;
 	asm ("bound.w\t%1, %0\n" : "+r" (r) : "ri" (b));
 	return r;
 }
 
-static inline int cris_bound_d(int v, int b)
+static always_inline int cris_bound_d(int v, int b)
 {
 	int r = v;
 	asm ("bound.d\t%1, %0\n" : "+r" (r) : "ri" (b));
tests/tcg/cris/check_ftag.c +4 -4
index 908773a..aaa5c97 100644
@@ -4,22 +4,22 @@
 #include "sys.h"
 #include "crisutils.h"
 
-static inline void cris_ftag_i(unsigned int x)
+static always_inline void cris_ftag_i(unsigned int x)
 {
 	register unsigned int v asm("$r10") = x;
 	asm ("ftagi\t[%0]\n" : : "r" (v) );
 }
-static inline void cris_ftag_d(unsigned int x)
+static always_inline void cris_ftag_d(unsigned int x)
 {
 	register unsigned int v asm("$r10") = x;
 	asm ("ftagd\t[%0]\n" : : "r" (v) );
 }
-static inline void cris_fidx_i(unsigned int x)
+static always_inline void cris_fidx_i(unsigned int x)
 {
 	register unsigned int v asm("$r10") = x;
 	asm ("fidxi\t[%0]\n" : : "r" (v) );
 }
-static inline void cris_fidx_d(unsigned int x)
+static always_inline void cris_fidx_d(unsigned int x)
 {
 	register unsigned int v asm("$r10") = x;
 	asm ("fidxd\t[%0]\n" : : "r" (v) );
tests/tcg/cris/check_int64.c +2 -2
index fc60017..69caec1 100644
@@ -5,12 +5,12 @@
 #include "crisutils.h"
 
 
-static inline int64_t add64(const int64_t a, const int64_t b)
+static always_inline int64_t add64(const int64_t a, const int64_t b)
 {
 	return a + b;
 }
 
-static inline int64_t sub64(const int64_t a, const int64_t b)
+static always_inline int64_t sub64(const int64_t a, const int64_t b)
 {
 	return a - b;
 }
tests/tcg/cris/check_lz.c +1 -1
index 69c2e6d..bf051a6 100644
@@ -3,7 +3,7 @@
 #include <stdint.h>
 #include "sys.h"
 
-static inline int cris_lz(int x)
+static always_inline int cris_lz(int x)
 {
 	int r;
 	asm ("lz\t%1, %0\n" : "=r" (r) : "r" (x));
tests/tcg/cris/check_swap.c +1 -1
index f851cbc..9a68c1e 100644
@@ -9,7 +9,7 @@
 #define B 2
 #define R 1
 
-static inline int cris_swap(const int mode, int x)
+static always_inline int cris_swap(const int mode, int x)
 {
 	switch (mode)
 	{
tests/tcg/cris/crisutils.h +10 -10
index 3456b9d..bbbe6c5 100644
@@ -13,57 +13,57 @@ void _err(void) {
 	_fail(tst_cc_loc);
 }
 
-static inline void cris_tst_cc_n1(void)
+static always_inline void cris_tst_cc_n1(void)
 {
 	asm volatile ("bpl _err\n"
 		      "nop\n");
 }
-static inline void cris_tst_cc_n0(void)
+static always_inline void cris_tst_cc_n0(void)
 {
 	asm volatile ("bmi _err\n"
 		      "nop\n");
 }
 
-static inline void cris_tst_cc_z1(void)
+static always_inline void cris_tst_cc_z1(void)
 {
 	asm volatile ("bne _err\n"
 		      "nop\n");
 }
-static inline void cris_tst_cc_z0(void)
+static always_inline void cris_tst_cc_z0(void)
 {
 	asm volatile ("beq _err\n"
 		      "nop\n");
 }
-static inline void cris_tst_cc_v1(void)
+static always_inline void cris_tst_cc_v1(void)
 {
 	asm volatile ("bvc _err\n"
 		      "nop\n");
 }
-static inline void cris_tst_cc_v0(void)
+static always_inline void cris_tst_cc_v0(void)
 {
 	asm volatile ("bvs _err\n"
 		      "nop\n");
 }
 
-static inline void cris_tst_cc_c1(void)
+static always_inline void cris_tst_cc_c1(void)
 {
 	asm volatile ("bcc _err\n"
 		      "nop\n");
 }
-static inline void cris_tst_cc_c0(void)
+static always_inline void cris_tst_cc_c0(void)
 {
 	asm volatile ("bcs _err\n"
 		      "nop\n");
 }
 
-static inline void cris_tst_mov_cc(int n, int z)
+static always_inline void cris_tst_mov_cc(int n, int z)
 {
 	if (n) cris_tst_cc_n1(); else cris_tst_cc_n0();
 	if (z) cris_tst_cc_z1(); else cris_tst_cc_z0();
 	asm volatile ("" : : "g" (_err));
 }
 
-static inline void cris_tst_cc(const int n, const int z,
+static always_inline void cris_tst_cc(const int n, const int z,
 			       const int v, const int c)
 {
 	if (n) cris_tst_cc_n1(); else cris_tst_cc_n0();
tests/tcg/cris/sys.h +2 -0
index c5f88e1..3dd47bb 100644
@@ -3,6 +3,8 @@
 #define STRINGIFY(x) #x
 #define TOSTRING(x) STRINGIFY(x)
 
+#define always_inline inline __attribute__((always_inline))
+
 #define CURRENT_LOCATION __FILE__ ":" TOSTRING(__LINE__)
 
 #define err()                         \
Signature · 1 line
2.1.4