Xtensa updates for 2.3:

- fix cross-page opcode handling;
 - move window overflow exception generation decision to translation phase;
 - don't generate dead code after privilege, window overflow or coprocessor
   exception;
 - add monitor command 'info opcount' for dumping TCG opcode counters.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJUkPD9AAoJEFH5zJH4P6BE7BQP/jYFMY1+52A99Iwwwf+RpCjA
 Bt5sH6csHlZS+95xI5uuSzaNDjwtzgsJlKdB43e4FtHqRdkPH7p/iFvqAMZW/hJM
 nsx5Hm7LeUM3Ox16o01EZE8HUEMo045RU8Gdt1V6qWRGhskaXgZ756p7zI8R9CrQ
 zKuvie0HMIGa6W126hodvu4paQ9yu49dZt2qrO5DlLujZeYH5OpQeoGs06gV4yb7
 G/A1hQSDSWOl0vyFH9P+zPyB7GLQOvCvokSPbDLoYlnKassYPCELtYILdV1fkgXn
 Nb0Xuv/SktEuEmJf8s6lFa8UOZPOWNsjAO4SY74Z7rR8EGLyCJj+damUdmtlpKDc
 ihysj048UCpWZDU952xWeQisrsoyBQ0Cbste7364Hdm+P0zhslEAX2mKEDzqTIff
 nfHBMvMjqdsmSsgMBGLkcY5Fdrgz0HP1J2JFtFZI0Wh9X8HvQcEuDtwpjZN5WRlu
 LEIp2bI0S1Lyy5I7Okr12m7g4tpFKyzNmw42wPyl6YVpSfT20ErCDFfZL4Wnu88B
 +Be/QlX4AAPpD1paRYyI0yyJvO+bFmcv5bejH3GrGXm1MGo9DSumGIxiHmCYCo4l
 z55/RLdujRxlwnDhOTruIei9gF+BnsQK6WR3f0yIjVZwtzKIe4BaLjqKOad/9INA
 VhrOyDE33GibpFYUygCI
 =quXp
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/xtensa/tags/20141217-xtensa' into staging

Xtensa updates for 2.3:

- fix cross-page opcode handling;
- move window overflow exception generation decision to translation phase;
- don't generate dead code after privilege, window overflow or coprocessor
  exception;
- add monitor command 'info opcount' for dumping TCG opcode counters.

# gpg: Signature made Wed 17 Dec 2014 02:57:01 GMT using RSA key ID F83FA044
# gpg: Good signature from "Max Filippov <max.filippov@cogentembedded.com>"
# gpg:                 aka "Max Filippov <jcmvbkbc@gmail.com>"

* remotes/xtensa/tags/20141217-xtensa:
  target-xtensa: don't generate dead code
  target-xtensa: record available window in TB flags
  target-xtensa: test cross-page opcode
  target-xtensa: fix translation for opcodes crossing page boundary
  tcg: add separate monitor command to dump opcode counters

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2014-12-17 17:31:26 +00:00
commit 86b182ac0e
10 changed files with 427 additions and 363 deletions

View File

@ -342,6 +342,7 @@ extern RAMList ram_list;
#define TLB_MMIO (1 << 5)
void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
void dump_opcount_info(FILE *f, fprintf_function cpu_fprintf);
ram_addr_t last_ram_offset(void);
void qemu_mutex_lock_ramlist(void);
void qemu_mutex_unlock_ramlist(void);

View File

@ -1042,6 +1042,11 @@ static void do_info_jit(Monitor *mon, const QDict *qdict)
dump_drift_info((FILE *)mon, monitor_fprintf);
}
static void do_info_opcount(Monitor *mon, const QDict *qdict)
{
dump_opcount_info((FILE *)mon, monitor_fprintf);
}
static void do_info_history(Monitor *mon, const QDict *qdict)
{
int i;
@ -2738,6 +2743,13 @@ static mon_cmd_t info_cmds[] = {
.help = "show dynamic compiler info",
.mhandler.cmd = do_info_jit,
},
{
.name = "opcount",
.args_type = "",
.params = "",
.help = "show dynamic compiler opcode counters",
.mhandler.cmd = do_info_opcount,
},
{
.name = "kvm",
.args_type = "",

View File

@ -497,6 +497,8 @@ static inline int cpu_mmu_index(CPUXtensaState *env)
#define XTENSA_TBFLAG_CPENABLE_MASK 0x3fc0
#define XTENSA_TBFLAG_CPENABLE_SHIFT 6
#define XTENSA_TBFLAG_EXCEPTION 0x4000
#define XTENSA_TBFLAG_WINDOW_MASK 0x18000
#define XTENSA_TBFLAG_WINDOW_SHIFT 15
static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc,
target_ulong *cs_base, int *flags)
@ -528,6 +530,16 @@ static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc,
if (cs->singlestep_enabled && env->exception_taken) {
*flags |= XTENSA_TBFLAG_EXCEPTION;
}
if (xtensa_option_enabled(env->config, XTENSA_OPTION_WINDOWED_REGISTER) &&
(env->sregs[PS] & (PS_WOE | PS_EXCM)) == PS_WOE) {
uint32_t windowstart = xtensa_replicate_windowstart(env) >>
(env->sregs[WINDOW_BASE] + 1);
uint32_t w = ctz32(windowstart | 0x8);
*flags |= w << XTENSA_TBFLAG_WINDOW_SHIFT;
} else {
*flags |= 3 << XTENSA_TBFLAG_WINDOW_SHIFT;
}
}
#include "exec/cpu-all.h"

View File

@ -9,7 +9,7 @@ DEF_HELPER_2(wsr_windowbase, void, env, i32)
DEF_HELPER_4(entry, void, env, i32, i32, i32)
DEF_HELPER_2(retw, i32, env, i32)
DEF_HELPER_2(rotw, void, env, i32)
DEF_HELPER_3(window_check, void, env, i32, i32)
DEF_HELPER_3(window_check, noreturn, env, i32, i32)
DEF_HELPER_1(restore_owb, void, env)
DEF_HELPER_2(movsp, void, env, i32)
DEF_HELPER_2(wsr_lbeg, void, env, i32)

View File

@ -251,34 +251,27 @@ void HELPER(entry)(CPUXtensaState *env, uint32_t pc, uint32_t s, uint32_t imm)
void HELPER(window_check)(CPUXtensaState *env, uint32_t pc, uint32_t w)
{
uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env);
uint32_t windowstart = env->sregs[WINDOW_START];
uint32_t m, n;
uint32_t windowstart = xtensa_replicate_windowstart(env) >>
(env->sregs[WINDOW_BASE] + 1);
uint32_t n = ctz32(windowstart) + 1;
if ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) {
return;
}
assert(n <= w);
for (n = 1; ; ++n) {
if (n > w) {
return;
}
if (windowstart & windowstart_bit(windowbase + n, env)) {
break;
}
}
m = windowbase_bound(windowbase + n, env);
rotate_window(env, n);
env->sregs[PS] = (env->sregs[PS] & ~PS_OWB) |
(windowbase << PS_OWB_SHIFT) | PS_EXCM;
env->sregs[EPC1] = env->pc = pc;
if (windowstart & windowstart_bit(m + 1, env)) {
switch (ctz32(windowstart >> n)) {
case 0:
HELPER(exception)(env, EXC_WINDOW_OVERFLOW4);
} else if (windowstart & windowstart_bit(m + 2, env)) {
break;
case 1:
HELPER(exception)(env, EXC_WINDOW_OVERFLOW8);
} else {
break;
default:
HELPER(exception)(env, EXC_WINDOW_OVERFLOW12);
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -2401,14 +2401,20 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
static int64_t tcg_table_op_count[NB_OPS];
static void dump_op_count(void)
void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf)
{
int i;
for(i = INDEX_op_end; i < NB_OPS; i++) {
qemu_log("%s %" PRId64 "\n", tcg_op_defs[i].name, tcg_table_op_count[i]);
cpu_fprintf(f, "%s %" PRId64 "\n", tcg_op_defs[i].name,
tcg_table_op_count[i]);
}
}
#else
void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf)
{
cpu_fprintf(f, "[TCG profiler not compiled]\n");
}
#endif
@ -2620,8 +2626,6 @@ void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf)
s->restore_count);
cpu_fprintf(f, " avg cycles %0.1f\n",
s->restore_count ? (double)s->restore_time / s->restore_count : 0);
dump_op_count();
}
#else
void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf)

View File

@ -610,6 +610,7 @@ int tcg_check_temp_count(void);
#endif
void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf);
void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf);
#define TCG_CT_ALIAS 0x80
#define TCG_CT_IALIAS 0x40

View File

@ -641,7 +641,7 @@ test cross_page_tb
witlb a2, a3
wdtlb a2, a3
movi a2, 0x00007ffd
movi a2, 0x00007ffc
movi a3, 20f
movi a4, 21f
sub a4, a4, a3
@ -651,7 +651,7 @@ test cross_page_tb
addi a2, a2, 1
addi a3, a3, 1
1:
movi a2, 0x00007ffd
movi a2, 0x00007ffc
movi a3, 0x00008000
/* DTLB: OK, ITLB: OK */
jx a2
@ -668,10 +668,10 @@ test cross_page_tb
movi a3, 1
assert eq, a2, a3
rsr a2, epc1
movi a3, 0x8000
movi a3, 0x7fff
assert eq, a2, a3
rsr a2, excsave1
movi a3, 0x00007ffd
movi a3, 0x00007ffc
assert ne, a2, a3
reset_ps
@ -680,7 +680,7 @@ test cross_page_tb
movi a2, 0x0400000c /* PPN */
movi a3, 0x00008000 /* VPN */
wdtlb a2, a3
movi a2, 0x00007ffd
movi a2, 0x00007ffc
movi a3, 0x00008000
/* DTLB: FAIL, ITLB: OK */
jx a2
@ -689,10 +689,10 @@ test cross_page_tb
movi a3, 28
assert eq, a2, a3
rsr a2, epc1
movi a3, 0x7ffd
movi a3, 0x7ffc
assert eq, a2, a3
rsr a2, excsave1
movi a3, 0x00007ffd
movi a3, 0x00007ffc
assert eq, a2, a3
reset_ps
@ -703,7 +703,7 @@ test cross_page_tb
witlb a2, a3
movi a2, 0x04000003 /* PPN */
wdtlb a2, a3
movi a2, 0x00007ffd
movi a2, 0x00007ffc
movi a3, 0x00008000
/* DTLB: OK, ITLB: FAIL */
jx a2
@ -712,10 +712,10 @@ test cross_page_tb
movi a3, 20
assert eq, a2, a3
rsr a2, epc1
movi a3, 0x8000
movi a3, 0x7fff
assert eq, a2, a3
rsr a2, excsave1
movi a3, 0x00007ffd
movi a3, 0x00007ffc
assert ne, a2, a3
reset_ps
@ -724,7 +724,7 @@ test cross_page_tb
movi a2, 0x0400000c /* PPN */
movi a3, 0x00008000 /* VPN */
wdtlb a2, a3
movi a2, 0x00007ffd
movi a2, 0x00007ffc
movi a3, 0x00008000
/* DTLB: FAIL, ITLB: FAIL */
jx a2
@ -733,10 +733,10 @@ test cross_page_tb
movi a3, 28
assert eq, a2, a3
rsr a2, epc1
movi a3, 0x7ffd
movi a3, 0x7ffc
assert eq, a2, a3
rsr a2, excsave1
movi a3, 0x00007ffd
movi a3, 0x00007ffc
assert eq, a2, a3
test_end

View File

@ -1651,6 +1651,11 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)
tcg_dump_info(f, cpu_fprintf);
}
void dump_opcount_info(FILE *f, fprintf_function cpu_fprintf)
{
tcg_dump_op_count(f, cpu_fprintf);
}
#else /* CONFIG_USER_ONLY */
void cpu_interrupt(CPUState *cpu, int mask)