tests: cris: force inlining
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
@@ -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
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
@@ -34,7 +34,10 @@ void *memset (void *s, int c, size_t n) {void exit (int status) { asmvolatile ("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
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.Signed-off-by Rabin Vincent <[email protected]>--- tests/tcg/cris/sys.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)tests/tcg/cris/sys.c +0
-0
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) { asmvolatile ("moveq 1, $r9\n" /* NR_exit. */ -"break 13\n" ); +"break 13\n" + : + : + :"r9" ,"memory" );
Better to simply set up the arguments properly. See
r~
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
@@ -33,19 +33,27 @@ void *memset (void *s, int c, size_t n) { }void exit (int status) { - asmvolatile ("moveq 1, $r9\n" /* NR_exit. */ -"break 13\n" ); + register unsigned int callno asm ("r9") = 1; /* NR_exit */ + + asmvolatile ("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; + registerunsigned int r asm ("r10" ); + + asmvolatile ("break 13\n" + :"=r" (r) + :"r" (callno),"0" (r10),"r" (r11),"r" (r12) + :"memory" ); +return r; }
Signature · 1 line
2.1.4
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
Signed-off-by Rabin Vincent <[email protected]>---
v2: reworked to set up arguments correctlytests/tcg/cris/sys.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
r~
PATCH 3/9 tests: cris: remove openpf4 test
In reply to Rabin VincentFrom: 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
@@ -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
@@ -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
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).
Signed-off-by Rabin Vincent <[email protected]>
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.ctests/tcg/cris/Makefile +0
-1@@ -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.ctsttests/tcg/cris/check_openpf4.c deleted +0
-5@@ -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
PATCH 4/9 tests: cris: remove check_time1
In reply to Rabin VincentFrom: 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
@@ -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
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.Signed-off-by Rabin Vincent <[email protected]>
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.ctests/tcg/cris/Makefile +0
-1@@ -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.ctsttests/tcg/cris/check_time1.c deleted +0
-46@@ -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
PATCH 5/9 target-cris: sync CC state at load/stores.
In reply to Rabin VincentFrom: "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
@@ -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
@@ -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
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.
Signed-off-by Edgar E. Iglesias <[email protected]>Signed-off-by Rabin Vincent <[email protected]>--- target-cris/translate.c | 9 +++++++++ target-cris/translate_v10.c | 3 +++ 2 files changed, 12 insertions(+)target-cris/translate.c +0
-0
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~
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.
Signed-off-by Edgar E. Iglesias <[email protected]>Signed-off-by Rabin Vincent <[email protected]>---
target-cris/translate.c| 9 +++++++++target-cris/translate_v10.c| 3 +++2 files changed, 12 insertions(+)target-cris/translate.c +0
-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);
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
PATCH 6/9 target-cris: reduce v32isms from v10 log dumps
In reply to Rabin VincentFrom: 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
@@ -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
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.
Signed-off-by Hans-Peter Nilsson <[email protected]>Signed-off-by Rabin Vincent <[email protected]>--- target-cris/translate.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)target-cris/translate.c +11
-3@@ -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
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
Re: [Qemu-devel] [PATCH 6/9] target-cris: reduce v32isms from v10 log dumps
In reply to Edgar E. IglesiasQuoted 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
4143896189ba073d14f6d89ad98ef4109d267becMon 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
@@ -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
PATCH 7/9 target-cris: ignore prefix insns in singlestep
In reply to Rabin VincentFrom: 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
@@ -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
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=00001ad4PC=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
Signed-off-by Hans-Peter Nilsson <[email protected]>Signed-off-by Rabin Vincent <[email protected]>--- target-cris/translate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)target-cris/translate.c +2
-1@@ -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
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=00001ad4PC=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,
EdgarQuoted 21 lines
Signed-off-by Hans-Peter Nilsson <[email protected]>Signed-off-by Rabin Vincent <[email protected]>--- target-cris/translate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)target-cris/translate.c +2
-1@@ -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
PATCH 8/9 target-cris: add v17 CPU
In reply to Rabin VincentFrom: 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
@@ -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
@@ -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
@@ -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
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+],RdSize: 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) | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+Signed-off-by Rabin Vincent <[email protected]>--- 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@@ -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@@ -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 8target-cris/translate_v10.c +0
-0
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
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@@ -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
513465ad3f007885bafba3482705ba57cacd588bMon 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
@@ -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
@@ -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
@@ -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
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@@ -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<---------------
From513465ad3f007885bafba3482705ba57cacd588bMon 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 CPUIn 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+],RdSize: 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) | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+Signed-off-by Rabin Vincent <[email protected]>--- 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@@ -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@@ -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 8target-cris/translate_v10.c +23
-0@@ -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
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.
PATCH 9/9 tests: cris: add v17 ADDC test
In reply to Rabin VincentFrom: 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
@@ -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
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.
Signed-off-by Rabin Vincent <[email protected]>
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.stests/tcg/cris/Makefile +17
-2@@ -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) *.otests/tcg/cris/check_addcv17.s new file +65
-0@@ -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 + + quitSignature · 1 line
2.1.4
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_inlineattribute 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
Signed-off-by Rabin Vincent <[email protected]>--- tests/tcg/cris/sys.h | 2 ++ 1 file changed, 2 insertions(+)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)) +#define CURRENT_LOCATION __FILE__ ":" TOSTRING(__LINE__)#define err () \Signature · 1 line
2.1.4
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_inlineattribute 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/.
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_inlineattribute 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
Signed-off-by Rabin Vincent <[email protected]>--- tests/tcg/cris/sys.h | 2 ++ 1 file changed, 2 insertions(+)tests/tcg/cris/sys.h +0
-0
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
Quoted 11 lines · Peter Maydell
tests/tcg/cris/sys.h line 7
Quoted 7 lines
+++
b/tests/tcg/cris/sys.htests/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
PATCH v2 1/8 tests: cris: force inlining
In reply to Peter MaydellFrom: 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
@@ -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 voidverify_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
@@ -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
@@ -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) { asmvolatile ("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) { asmvolatile ("addc [%1+], %0\n" :"+r" (a),"+b" (*b));return a;
tests/tcg/cris/check_bound.c +3 -3
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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) { asmvolatile ("bpl _err\n" "nop\n" ); } -static inline void cris_tst_cc_n0 (void ) +static always_inline void cris_tst_cc_n0(void) { asmvolatile ("bmi _err\n" "nop\n" ); } -static inline void cris_tst_cc_z1 (void ) +static always_inline void cris_tst_cc_z1(void) { asmvolatile ("bne _err\n" "nop\n" ); } -static inline void cris_tst_cc_z0 (void ) +static always_inline void cris_tst_cc_z0(void) { asmvolatile ("beq _err\n" "nop\n" ); } -static inline void cris_tst_cc_v1 (void ) +static always_inline void cris_tst_cc_v1(void) { asmvolatile ("bvc _err\n" "nop\n" ); } -static inline void cris_tst_cc_v0 (void ) +static always_inline void cris_tst_cc_v0(void) { asmvolatile ("bvs _err\n" "nop\n" ); } -static inline void cris_tst_cc_c1 (void ) +static always_inline void cris_tst_cc_c1(void) { asmvolatile ("bcc _err\n" "nop\n" ); } -static inline void cris_tst_cc_c0 (void ) +static always_inline void cris_tst_cc_c0(void) { asmvolatile ("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 (); asmvolatile ("" : :"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
@@ -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