mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
accel/tcg: Use cpu_ld*_code_mmu in translator.c
Cache the mmu index in DisasContextBase. Perform the read on host endianness, which lets us share code with the translator_ld fast path. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
+27
-31
@@ -11,10 +11,10 @@
|
||||
#include "qemu/log.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "exec/cpu-ldst-common.h"
|
||||
#include "accel/tcg/cpu-mmu-index.h"
|
||||
#include "exec/translator.h"
|
||||
#include "exec/cpu_ldst.h"
|
||||
#include "exec/plugin-gen.h"
|
||||
#include "exec/cpu_ldst.h"
|
||||
#include "exec/tswap.h"
|
||||
#include "tcg/tcg-op-common.h"
|
||||
#include "internal-target.h"
|
||||
@@ -142,6 +142,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
|
||||
db->host_addr[1] = NULL;
|
||||
db->record_start = 0;
|
||||
db->record_len = 0;
|
||||
db->code_mmuidx = cpu_mmu_index(cpu, true);
|
||||
|
||||
ops->init_disas_context(db, cpu);
|
||||
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
|
||||
@@ -457,55 +458,50 @@ bool translator_st(const DisasContextBase *db, void *dest,
|
||||
|
||||
uint8_t translator_ldub(CPUArchState *env, DisasContextBase *db, vaddr pc)
|
||||
{
|
||||
uint8_t raw;
|
||||
uint8_t val;
|
||||
|
||||
if (!translator_ld(env, db, &raw, pc, sizeof(raw))) {
|
||||
raw = cpu_ldub_code(env, pc);
|
||||
record_save(db, pc, &raw, sizeof(raw));
|
||||
if (!translator_ld(env, db, &val, pc, sizeof(val))) {
|
||||
MemOpIdx oi = make_memop_idx(MO_UB, db->code_mmuidx);
|
||||
val = cpu_ldb_code_mmu(env, pc, oi, 0);
|
||||
record_save(db, pc, &val, sizeof(val));
|
||||
}
|
||||
return raw;
|
||||
return val;
|
||||
}
|
||||
|
||||
uint16_t translator_lduw(CPUArchState *env, DisasContextBase *db, vaddr pc)
|
||||
{
|
||||
uint16_t raw, tgt;
|
||||
uint16_t val;
|
||||
|
||||
if (translator_ld(env, db, &raw, pc, sizeof(raw))) {
|
||||
tgt = tswap16(raw);
|
||||
} else {
|
||||
tgt = cpu_lduw_code(env, pc);
|
||||
raw = tswap16(tgt);
|
||||
record_save(db, pc, &raw, sizeof(raw));
|
||||
if (!translator_ld(env, db, &val, pc, sizeof(val))) {
|
||||
MemOpIdx oi = make_memop_idx(MO_UW, db->code_mmuidx);
|
||||
val = cpu_ldw_code_mmu(env, pc, oi, 0);
|
||||
record_save(db, pc, &val, sizeof(val));
|
||||
}
|
||||
return tgt;
|
||||
return tswap16(val);
|
||||
}
|
||||
|
||||
uint32_t translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
|
||||
{
|
||||
uint32_t raw, tgt;
|
||||
uint32_t val;
|
||||
|
||||
if (translator_ld(env, db, &raw, pc, sizeof(raw))) {
|
||||
tgt = tswap32(raw);
|
||||
} else {
|
||||
tgt = cpu_ldl_code(env, pc);
|
||||
raw = tswap32(tgt);
|
||||
record_save(db, pc, &raw, sizeof(raw));
|
||||
if (!translator_ld(env, db, &val, pc, sizeof(val))) {
|
||||
MemOpIdx oi = make_memop_idx(MO_UL, db->code_mmuidx);
|
||||
val = cpu_ldl_code_mmu(env, pc, oi, 0);
|
||||
record_save(db, pc, &val, sizeof(val));
|
||||
}
|
||||
return tgt;
|
||||
return tswap32(val);
|
||||
}
|
||||
|
||||
uint64_t translator_ldq(CPUArchState *env, DisasContextBase *db, vaddr pc)
|
||||
{
|
||||
uint64_t raw, tgt;
|
||||
uint64_t val;
|
||||
|
||||
if (translator_ld(env, db, &raw, pc, sizeof(raw))) {
|
||||
tgt = tswap64(raw);
|
||||
} else {
|
||||
tgt = cpu_ldq_code(env, pc);
|
||||
raw = tswap64(tgt);
|
||||
record_save(db, pc, &raw, sizeof(raw));
|
||||
if (!translator_ld(env, db, &val, pc, sizeof(val))) {
|
||||
MemOpIdx oi = make_memop_idx(MO_UQ, db->code_mmuidx);
|
||||
val = cpu_ldq_code_mmu(env, pc, oi, 0);
|
||||
record_save(db, pc, &val, sizeof(val));
|
||||
}
|
||||
return tgt;
|
||||
return tswap64(val);
|
||||
}
|
||||
|
||||
void translator_fake_ld(DisasContextBase *db, const void *data, size_t len)
|
||||
|
||||
@@ -73,6 +73,7 @@ struct DisasContextBase {
|
||||
int max_insns;
|
||||
bool plugin_enabled;
|
||||
bool fake_insn;
|
||||
uint8_t code_mmuidx;
|
||||
struct TCGOp *insn_start;
|
||||
void *host_addr[2];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user