mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
tcg: Introduce tcg_splitwx_to_{rx,rw}
Add two helper functions, using a global variable to hold the displacement. The displacement is currently always 0, so no change in behaviour. Begin using the functions in tcg common code only. Reviewed-by: Joelle van Dyne <j@getutm.app> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
4846cd37df
commit
db0c51a380
13 changed files with 105 additions and 40 deletions
|
@ -161,7 +161,7 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb)
|
|||
uintptr_t ret;
|
||||
TranslationBlock *last_tb;
|
||||
int tb_exit;
|
||||
uint8_t *tb_ptr = itb->tc.ptr;
|
||||
const void *tb_ptr = itb->tc.ptr;
|
||||
|
||||
qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc,
|
||||
"Trace %d: %p ["
|
||||
|
|
|
@ -145,7 +145,7 @@ uint64_t HELPER(ctpop_i64)(uint64_t arg)
|
|||
return ctpop64(arg);
|
||||
}
|
||||
|
||||
void *HELPER(lookup_tb_ptr)(CPUArchState *env)
|
||||
const void *HELPER(lookup_tb_ptr)(CPUArchState *env)
|
||||
{
|
||||
CPUState *cpu = env_cpu(env);
|
||||
TranslationBlock *tb;
|
||||
|
|
|
@ -24,7 +24,7 @@ DEF_HELPER_FLAGS_1(clrsb_i64, TCG_CALL_NO_RWG_SE, i64, i64)
|
|||
DEF_HELPER_FLAGS_1(ctpop_i32, TCG_CALL_NO_RWG_SE, i32, i32)
|
||||
DEF_HELPER_FLAGS_1(ctpop_i64, TCG_CALL_NO_RWG_SE, i64, i64)
|
||||
|
||||
DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, ptr, env)
|
||||
DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, cptr, env)
|
||||
|
||||
DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env)
|
||||
|
||||
|
|
|
@ -7,4 +7,4 @@ exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR
|
|||
exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=0x%x"
|
||||
|
||||
# translate-all.c
|
||||
translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p"
|
||||
translate_block(void *tb, uintptr_t pc, const void *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p"
|
||||
|
|
|
@ -269,9 +269,9 @@ static uint8_t *encode_sleb128(uint8_t *p, target_long val)
|
|||
|
||||
/* Decode a signed leb128 sequence at *PP; increment *PP past the
|
||||
decoded value. Return the decoded value. */
|
||||
static target_long decode_sleb128(uint8_t **pp)
|
||||
static target_long decode_sleb128(const uint8_t **pp)
|
||||
{
|
||||
uint8_t *p = *pp;
|
||||
const uint8_t *p = *pp;
|
||||
target_long val = 0;
|
||||
int byte, shift = 0;
|
||||
|
||||
|
@ -342,7 +342,7 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
|
|||
target_ulong data[TARGET_INSN_START_WORDS] = { tb->pc };
|
||||
uintptr_t host_pc = (uintptr_t)tb->tc.ptr;
|
||||
CPUArchState *env = cpu->env_ptr;
|
||||
uint8_t *p = tb->tc.ptr + tb->tc.size;
|
||||
const uint8_t *p = tb->tc.ptr + tb->tc.size;
|
||||
int i, j, num_insns = tb->icount;
|
||||
#ifdef CONFIG_PROFILER
|
||||
TCGProfile *prof = &tcg_ctx->prof;
|
||||
|
@ -393,7 +393,7 @@ void tb_destroy(TranslationBlock *tb)
|
|||
bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit)
|
||||
{
|
||||
/*
|
||||
* The host_pc has to be in the region of the code buffer.
|
||||
* The host_pc has to be in the rx region of the code buffer.
|
||||
* If it is not we will not be able to resolve it here.
|
||||
* The two cases where host_pc will not be correct are:
|
||||
*
|
||||
|
@ -402,7 +402,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit)
|
|||
*
|
||||
* Either way we need return early as we can't resolve it here.
|
||||
*/
|
||||
if (in_code_gen_buffer((const void *)host_pc)) {
|
||||
if (in_code_gen_buffer((const void *)(host_pc - tcg_splitwx_diff))) {
|
||||
TranslationBlock *tb = tcg_tb_lookup(host_pc);
|
||||
if (tb) {
|
||||
cpu_restore_state_from_tb(cpu, tb, host_pc, will_exit);
|
||||
|
@ -1712,7 +1712,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||
}
|
||||
|
||||
gen_code_buf = tcg_ctx->code_gen_ptr;
|
||||
tb->tc.ptr = gen_code_buf;
|
||||
tb->tc.ptr = tcg_splitwx_to_rx(gen_code_buf);
|
||||
tb->pc = pc;
|
||||
tb->cs_base = cs_base;
|
||||
tb->flags = flags;
|
||||
|
@ -1806,15 +1806,19 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) &&
|
||||
qemu_log_in_addr_range(tb->pc)) {
|
||||
FILE *logfile = qemu_log_lock();
|
||||
int code_size, data_size = 0;
|
||||
int code_size, data_size;
|
||||
const tcg_target_ulong *rx_data_gen_ptr;
|
||||
size_t chunk_start;
|
||||
int insn = 0;
|
||||
|
||||
if (tcg_ctx->data_gen_ptr) {
|
||||
code_size = tcg_ctx->data_gen_ptr - tb->tc.ptr;
|
||||
rx_data_gen_ptr = tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr);
|
||||
code_size = (const void *)rx_data_gen_ptr - tb->tc.ptr;
|
||||
data_size = gen_code_size - code_size;
|
||||
} else {
|
||||
rx_data_gen_ptr = 0;
|
||||
code_size = gen_code_size;
|
||||
data_size = 0;
|
||||
}
|
||||
|
||||
/* Dump header and the first instruction */
|
||||
|
@ -1849,16 +1853,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
|||
if (data_size) {
|
||||
int i;
|
||||
qemu_log(" data: [size=%d]\n", data_size);
|
||||
for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
|
||||
if (sizeof(tcg_target_ulong) == 8) {
|
||||
qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n",
|
||||
(uintptr_t)tcg_ctx->data_gen_ptr + i,
|
||||
*(uint64_t *)(tcg_ctx->data_gen_ptr + i));
|
||||
} else {
|
||||
qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n",
|
||||
(uintptr_t)tcg_ctx->data_gen_ptr + i,
|
||||
*(uint32_t *)(tcg_ctx->data_gen_ptr + i));
|
||||
}
|
||||
for (i = 0; i < data_size / sizeof(tcg_target_ulong); i++) {
|
||||
qemu_log("0x%08" PRIxPTR ": .quad 0x%" TCG_PRIlx "\n",
|
||||
(uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]);
|
||||
}
|
||||
}
|
||||
qemu_log("\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue