Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20161101-2' i…
Browse files Browse the repository at this point in the history
…nto staging

tcg queued patches

# gpg: Signature made Tue 01 Nov 2016 16:45:42 GMT
# gpg:                using RSA key 0xAD1270CC4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg:                 aka "Richard Henderson <rth@redhat.com>"
# gpg:                 aka "Richard Henderson <rth@twiddle.net>"
# Primary key fingerprint: 9CB1 8DDA F8E8 49AD 2AFC  16A4 AD12 70CC 4DD0 279B

* remotes/rth/tags/pull-tcg-20161101-2:
  tcg: correct 32-bit tcg_gen_ld8s_i64 sign-extension
  tcg/tcg.h: Improve documentation of TCGv_i32 etc types
  MAINTAINERS: Update PPC status and maintainer
  target-microblaze: Cleanup dec_mul
  tcg: Add tcg_gen_mulsu2_{i32,i64,tl}
  log: Add locking to large logging blocks
  target-openrisc: Do not dump cpu state with -d in_asm
  target-microblaze: Do not dump cpu state with -d in_asm
  target-cris: Do not dump cpu state with -d in_asm

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Nov 1, 2016
2 parents c46ef89 + 3ff91d7 commit 4eb28ab
Show file tree
Hide file tree
Showing 29 changed files with 192 additions and 100 deletions.
4 changes: 2 additions & 2 deletions MAINTAINERS
Expand Up @@ -1504,8 +1504,8 @@ F: tcg/mips/
F: disas/mips.c

PPC
M: Vassili Karpov (malc) <av1474@comtv.ru>
S: Maintained
M: Richard Henderson <rth@twiddle.net>
S: Odd Fixes
F: tcg/ppc/
F: disas/ppc.c

Expand Down
2 changes: 2 additions & 0 deletions cpu-exec.c
Expand Up @@ -150,11 +150,13 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb)
#if defined(DEBUG_DISAS)
if (qemu_loglevel_mask(CPU_LOG_TB_CPU)
&& qemu_log_in_addr_range(itb->pc)) {
qemu_log_lock();
#if defined(TARGET_I386)
log_cpu_state(cpu, CPU_DUMP_CCOP);
#else
log_cpu_state(cpu, 0);
#endif
qemu_log_unlock();
}
#endif /* DEBUG_DISAS */

Expand Down
2 changes: 2 additions & 0 deletions exec.c
Expand Up @@ -911,11 +911,13 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
fprintf(stderr, "\n");
cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_FPU | CPU_DUMP_CCOP);
if (qemu_log_separate()) {
qemu_log_lock();
qemu_log("qemu: fatal: ");
qemu_log_vprintf(fmt, ap2);
qemu_log("\n");
log_cpu_state(cpu, CPU_DUMP_FPU | CPU_DUMP_CCOP);
qemu_log_flush();
qemu_log_unlock();
qemu_log_close();
}
va_end(ap2);
Expand Down
16 changes: 16 additions & 0 deletions include/qemu/log.h
Expand Up @@ -51,6 +51,22 @@ static inline bool qemu_loglevel_mask(int mask)
return (qemu_loglevel & mask) != 0;
}

/* Lock output for a series of related logs. Since this is not needed
* for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we
* assume that qemu_loglevel_mask has already been tested, and that
* qemu_loglevel is never set when qemu_logfile is unset.
*/

static inline void qemu_log_lock(void)
{
qemu_flockfile(qemu_logfile);
}

static inline void qemu_log_unlock(void)
{
qemu_funlockfile(qemu_logfile);
}

/* Logging functions: */

/* main logging function
Expand Down
12 changes: 12 additions & 0 deletions include/sysemu/os-posix.h
Expand Up @@ -87,4 +87,16 @@ void *qemu_alloc_stack(size_t *sz);
*/
void qemu_free_stack(void *stack, size_t sz);

/* POSIX and Mingw32 differ in the name of the stdio lock functions. */

static inline void qemu_flockfile(FILE *f)
{
flockfile(f);
}

static inline void qemu_funlockfile(FILE *f)
{
funlockfile(f);
}

#endif
15 changes: 15 additions & 0 deletions include/sysemu/os-win32.h
Expand Up @@ -103,6 +103,21 @@ static inline char *realpath(const char *path, char *resolved_path)
return resolved_path;
}

/* ??? Mingw appears to export _lock_file and _unlock_file as the functions
* with which to lock a stdio handle. But something is wrong in the markup,
* either in the header or the library, such that we get undefined references
* to "_imp___lock_file" etc when linking. Since we seem to have no other
* alternative, and the usage within the logging functions isn't critical,
* ignore FILE locking.
*/

static inline void qemu_flockfile(FILE *f)
{
}

static inline void qemu_funlockfile(FILE *f)
{
}

/* We wrap all the sockets functions so that we can
* set errno based on WSAGetLastError()
Expand Down
2 changes: 2 additions & 0 deletions target-alpha/translate.c
Expand Up @@ -2994,9 +2994,11 @@ void gen_intermediate_code(CPUAlphaState *env, struct TranslationBlock *tb)
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(cs, pc_start, ctx.pc - pc_start, 1);
qemu_log("\n");
qemu_log_unlock();
}
#endif
}
Expand Down
2 changes: 2 additions & 0 deletions target-arm/translate-a64.c
Expand Up @@ -11420,11 +11420,13 @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb)
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) &&
qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(cs, pc_start, dc->pc - pc_start,
4 | (bswap_code(dc->sctlr_b) ? 2 : 0));
qemu_log("\n");
qemu_log_unlock();
}
#endif
tb->size = dc->pc - pc_start;
Expand Down
2 changes: 2 additions & 0 deletions target-arm/translate.c
Expand Up @@ -11963,11 +11963,13 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) &&
qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(cs, pc_start, dc->pc - pc_start,
dc->thumb | (dc->sctlr_b << 1));
qemu_log("\n");
qemu_log_unlock();
}
#endif
tb->size = dc->pc - pc_start;
Expand Down
27 changes: 4 additions & 23 deletions target-cris/translate.c
Expand Up @@ -3135,29 +3135,6 @@ void gen_intermediate_code(CPUCRISState *env, struct TranslationBlock *tb)

dc->cpustate_changed = 0;

if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log(
"pc=%x %x flg=%" PRIx64 " bt=%x ds=%u ccs=%x\n"
"pid=%x usp=%x\n"
"%x.%x.%x.%x\n"
"%x.%x.%x.%x\n"
"%x.%x.%x.%x\n"
"%x.%x.%x.%x\n",
dc->pc, dc->ppc,
(uint64_t)tb->flags,
env->btarget, (unsigned)tb->flags & 7,
env->pregs[PR_CCS],
env->pregs[PR_PID], env->pregs[PR_USP],
env->regs[0], env->regs[1], env->regs[2], env->regs[3],
env->regs[4], env->regs[5], env->regs[6], env->regs[7],
env->regs[8], env->regs[9],
env->regs[10], env->regs[11],
env->regs[12], env->regs[13],
env->regs[14], env->regs[15]);
qemu_log("--------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
}

next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
Expand Down Expand Up @@ -3313,10 +3290,14 @@ void gen_intermediate_code(CPUCRISState *env, struct TranslationBlock *tb)
#if !DISAS_CRIS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("--------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(cs, pc_start, dc->pc - pc_start,
env->pregs[PR_VR]);
qemu_log("\nisize=%d osize=%d\n",
dc->pc - pc_start, tcg_op_buf_count());
qemu_log_unlock();
}
#endif
#endif
Expand Down
4 changes: 4 additions & 0 deletions target-i386/translate.c
Expand Up @@ -2432,11 +2432,13 @@ static void gen_unknown_opcode(CPUX86State *env, DisasContext *s)

if (qemu_loglevel_mask(LOG_UNIMP)) {
target_ulong pc = s->pc_start, end = s->pc;
qemu_log_lock();
qemu_log("ILLOPC: " TARGET_FMT_lx ":", pc);
for (; pc < end; ++pc) {
qemu_log(" %02x", cpu_ldub_code(env, pc));
}
qemu_log("\n");
qemu_log_unlock();
}
}

Expand Down Expand Up @@ -8470,6 +8472,7 @@ void gen_intermediate_code(CPUX86State *env, TranslationBlock *tb)
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
int disas_flags;
qemu_log_lock();
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
#ifdef TARGET_X86_64
Expand All @@ -8480,6 +8483,7 @@ void gen_intermediate_code(CPUX86State *env, TranslationBlock *tb)
disas_flags = !dc->code32;
log_target_disas(cs, pc_start, pc_ptr - pc_start, disas_flags);
qemu_log("\n");
qemu_log_unlock();
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions target-lm32/translate.c
Expand Up @@ -1148,10 +1148,12 @@ void gen_intermediate_code(CPULM32State *env, struct TranslationBlock *tb)
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("\n");
log_target_disas(cs, pc_start, dc->pc - pc_start, 0);
qemu_log("\nisize=%d osize=%d\n",
dc->pc - pc_start, tcg_op_buf_count());
qemu_log_unlock();
}
#endif
}
Expand Down
2 changes: 2 additions & 0 deletions target-m68k/translate.c
Expand Up @@ -3549,10 +3549,12 @@ void gen_intermediate_code(CPUM68KState *env, TranslationBlock *tb)
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(cs, pc_start, dc->pc - pc_start, 0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
tb->size = dc->pc - pc_start;
Expand Down
72 changes: 12 additions & 60 deletions target-microblaze/translate.c
Expand Up @@ -581,50 +581,10 @@ static void dec_msr(DisasContext *dc)
}
}

/* 64-bit signed mul, lower result in d and upper in d2. */
static void t_gen_muls(TCGv d, TCGv d2, TCGv a, TCGv b)
{
TCGv_i64 t0, t1;

t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();

tcg_gen_ext_i32_i64(t0, a);
tcg_gen_ext_i32_i64(t1, b);
tcg_gen_mul_i64(t0, t0, t1);

tcg_gen_extrl_i64_i32(d, t0);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_extrl_i64_i32(d2, t0);

tcg_temp_free_i64(t0);
tcg_temp_free_i64(t1);
}

/* 64-bit unsigned muls, lower result in d and upper in d2. */
static void t_gen_mulu(TCGv d, TCGv d2, TCGv a, TCGv b)
{
TCGv_i64 t0, t1;

t0 = tcg_temp_new_i64();
t1 = tcg_temp_new_i64();

tcg_gen_extu_i32_i64(t0, a);
tcg_gen_extu_i32_i64(t1, b);
tcg_gen_mul_i64(t0, t0, t1);

tcg_gen_extrl_i64_i32(d, t0);
tcg_gen_shri_i64(t0, t0, 32);
tcg_gen_extrl_i64_i32(d2, t0);

tcg_temp_free_i64(t0);
tcg_temp_free_i64(t1);
}

/* Multiplier unit. */
static void dec_mul(DisasContext *dc)
{
TCGv d[2];
TCGv tmp;
unsigned int subcode;

if ((dc->tb_flags & MSR_EE_FLAG)
Expand All @@ -636,13 +596,11 @@ static void dec_mul(DisasContext *dc)
}

subcode = dc->imm & 3;
d[0] = tcg_temp_new();
d[1] = tcg_temp_new();

if (dc->type_b) {
LOG_DIS("muli r%d r%d %x\n", dc->rd, dc->ra, dc->imm);
t_gen_mulu(cpu_R[dc->rd], d[1], cpu_R[dc->ra], *(dec_alu_op_b(dc)));
goto done;
tcg_gen_mul_tl(cpu_R[dc->rd], cpu_R[dc->ra], *(dec_alu_op_b(dc)));
return;
}

/* mulh, mulhsu and mulhu are not available if C_USE_HW_MUL is < 2. */
Expand All @@ -651,30 +609,29 @@ static void dec_mul(DisasContext *dc)
/* nop??? */
}

tmp = tcg_temp_new();
switch (subcode) {
case 0:
LOG_DIS("mul r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_mulu(cpu_R[dc->rd], d[1], cpu_R[dc->ra], cpu_R[dc->rb]);
tcg_gen_mul_tl(cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 1:
LOG_DIS("mulh r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_muls(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
tcg_gen_muls2_tl(tmp, cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 2:
LOG_DIS("mulhsu r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_muls(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
tcg_gen_mulsu2_tl(tmp, cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
case 3:
LOG_DIS("mulhu r%d r%d r%d\n", dc->rd, dc->ra, dc->rb);
t_gen_mulu(d[0], cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
tcg_gen_mulu2_tl(tmp, cpu_R[dc->rd], cpu_R[dc->ra], cpu_R[dc->rb]);
break;
default:
cpu_abort(CPU(dc->cpu), "unknown MUL insn %x\n", subcode);
break;
}
done:
tcg_temp_free(d[0]);
tcg_temp_free(d[1]);
tcg_temp_free(tmp);
}

/* Div unit. */
Expand Down Expand Up @@ -1670,13 +1627,6 @@ void gen_intermediate_code(CPUMBState *env, struct TranslationBlock *tb)
cpu_abort(cs, "Microblaze: unaligned PC=%x\n", pc_start);
}

if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
#if !SIM_COMPAT
qemu_log("--------------\n");
log_cpu_state(CPU(cpu), 0);
#endif
}

next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
Expand Down Expand Up @@ -1820,12 +1770,14 @@ void gen_intermediate_code(CPUMBState *env, struct TranslationBlock *tb)
#if !SIM_COMPAT
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log("\n");
qemu_log_lock();
qemu_log("--------------\n");
#if DISAS_GNU
log_target_disas(cs, pc_start, dc->pc - pc_start, 0);
#endif
qemu_log("\nisize=%d osize=%d\n",
dc->pc - pc_start, tcg_op_buf_count());
qemu_log_unlock();
}
#endif
#endif
Expand Down
2 changes: 2 additions & 0 deletions target-mips/translate.c
Expand Up @@ -20043,9 +20043,11 @@ void gen_intermediate_code(CPUMIPSState *env, struct TranslationBlock *tb)
LOG_DISAS("\n");
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(pc_start)) {
qemu_log_lock();
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
qemu_log_unlock();
}
#endif
}
Expand Down

0 comments on commit 4eb28ab

Please sign in to comment.