target-sparc: Remove gen_opc_jump_pc

Since jump_pc[1] is always npc + 4, we can infer after incrementing
that jump_pc[1] == pc + 4. Because of that, we can encode the branch
destination into a single word, and store that in npc.

Backports commit 6c42444f9a53b6af39d46008cb9f650b11e96cb9 from qemu
This commit is contained in:
Richard Henderson 2018-02-16 00:52:42 -05:00 committed by Lioncash
parent b709d15b13
commit 2c1ae7a408
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 10 additions and 8 deletions

View file

@ -5440,6 +5440,10 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu,
tcg_ctx->gen_opc_instr_start[lj++] = 0; tcg_ctx->gen_opc_instr_start[lj++] = 0;
tcg_ctx->gen_opc_pc[lj] = dc->pc; tcg_ctx->gen_opc_pc[lj] = dc->pc;
tcg_ctx->gen_opc_npc[lj] = dc->npc; tcg_ctx->gen_opc_npc[lj] = dc->npc;
if (dc->npc & JUMP_PC) {
assert(dc->jump_pc[1] == dc->pc + 4);
tcg_ctx->gen_opc_npc[lj] = dc->jump_pc[0] | JUMP_PC;
}
tcg_ctx->gen_opc_instr_start[lj] = 1; tcg_ctx->gen_opc_instr_start[lj] = 1;
tcg_ctx->gen_opc_icount[lj] = num_insns; tcg_ctx->gen_opc_icount[lj] = num_insns;
} }
@ -5515,8 +5519,6 @@ done_generating:
#if 0 #if 0
log_page_dump(); log_page_dump();
#endif #endif
tcg_ctx->gen_opc_jump_pc[0] = dc->jump_pc[0];
tcg_ctx->gen_opc_jump_pc[1] = dc->jump_pc[1];
} else { } else {
tb->size = last_pc + 4 - pc_start; tb->size = last_pc + 4 - pc_start;
tb->icount = num_insns; tb->icount = num_insns;
@ -5699,16 +5701,17 @@ void gen_intermediate_code_init(CPUSPARCState *env)
void restore_state_to_opc(CPUSPARCState *env, TranslationBlock *tb, int pc_pos) void restore_state_to_opc(CPUSPARCState *env, TranslationBlock *tb, int pc_pos)
{ {
TCGContext *tcg_ctx = env->uc->tcg_ctx; TCGContext *tcg_ctx = env->uc->tcg_ctx;
target_ulong npc; target_ulong pc, npc;
env->pc = pc = tcg_ctx->gen_opc_pc[pc_pos];
npc = tcg_ctx->gen_opc_npc[pc_pos]; npc = tcg_ctx->gen_opc_npc[pc_pos];
if (npc == 1) { if (npc == DYNAMIC_PC) {
/* dynamic NPC: already stored */ /* dynamic NPC: already stored */
} else if (npc == 2) { } else if (npc & JUMP_PC) {
/* jump PC: use 'cond' and the jump targets of the translation */ /* jump PC: use 'cond' and the jump targets of the translation */
if (env->cond) { if (env->cond) {
env->npc = tcg_ctx->gen_opc_jump_pc[0]; env->npc = npc & ~3;
} else { } else {
env->npc = tcg_ctx->gen_opc_jump_pc[1]; env->npc = pc + 4;
} }
} else { } else {
env->npc = npc; env->npc = npc;

View file

@ -804,7 +804,6 @@ struct TCGContext {
TCGv_i64 cpu_fpr[32]; // TARGET_DPREGS = 32 for Sparc64, 16 for Sparc TCGv_i64 cpu_fpr[32]; // TARGET_DPREGS = 32 for Sparc64, 16 for Sparc
target_ulong gen_opc_npc[OPC_BUF_SIZE]; target_ulong gen_opc_npc[OPC_BUF_SIZE];
target_ulong gen_opc_jump_pc[2];
// void *cpu_cc_src, *cpu_cc_src2, *cpu_cc_dst; // void *cpu_cc_src, *cpu_cc_src2, *cpu_cc_dst;
void *cpu_fsr, *sparc_cpu_pc, *cpu_npc, *cpu_gregs[8]; void *cpu_fsr, *sparc_cpu_pc, *cpu_npc, *cpu_gregs[8];