From c105cfbecb1b97b099916c9fb641ca91b9c50c3b Mon Sep 17 00:00:00 2001
Message-Id: <c105cfbecb1b97b099916c9fb641ca91b9c50c3b.1333999313.git.blauwirbel@gmail.com>
In-Reply-To: <524db9d8331b9f4a43459081909e8816f77b3952.1333999313.git.blauwirbel@gmail.com>
References: <524db9d8331b9f4a43459081909e8816f77b3952.1333999313.git.blauwirbel@gmail.com>
From: Blue Swirl <blauwirbel@gmail.com>
Date: Mon, 9 Apr 2012 07:56:30 +0000
Subject: [PATCH 4/4] softmmu: add a faster helper for TCG
Don't recheck the TLB miss which we know is true, instead
call directly the miss path.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
softmmu_template.h | 40 ++++++++++++++++++++++++++++++++++++++++
tcg/arm/tcg-target.c | 19 ++++++++++---------
tcg/hppa/tcg-target.c | 17 +++++++++--------
tcg/i386/tcg-target.c | 17 +++++++++--------
tcg/ia64/tcg-target.c | 17 +++++++++--------
tcg/mips/tcg-target.c | 17 +++++++++--------
tcg/ppc/tcg-target.c | 17 +++++++++--------
tcg/ppc64/tcg-target.c | 17 +++++++++--------
tcg/s390/tcg-target.c | 17 +++++++++--------
tcg/sparc/tcg-target.c | 17 +++++++++--------
10 files changed, 122 insertions(+), 73 deletions(-)
@@ -165,6 +165,26 @@ glue(glue(glue(HELPER_PREFIX, ld), SUFFIX), MMUSUFFIX)(ENV_PARAM
return res;
}
+#if defined(CONFIG_TCG_PASS_AREG0) && defined(GEN_TCG_HELPER)
+/* We know that the page was not in TLB, fill and retry */
+static DATA_TYPE
+glue(tcg_helper_qemu_ld, SUFFIX)(CPUArchState *env, target_ulong addr,
+ int mmu_idx)
+{
+ void *retaddr;
+
+ retaddr = GETPC();
+#ifdef TARGET_ALIGNED_ONLY
+ if ((addr & (DATA_SIZE - 1)) != 0) {
+ cpu_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx,
+ retaddr);
+ }
+#endif
+ tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr);
+ return glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx);
+}
+#endif
+
/* handle all unaligned cases */
static DATA_TYPE
glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(ENV_PARAM
@@ -310,6 +330,26 @@ void glue(glue(glue(HELPER_PREFIX, st), SUFFIX), MMUSUFFIX)(ENV_PARAM
}
}
+#if defined(CONFIG_TCG_PASS_AREG0) && defined(GEN_TCG_HELPER)
+/* We know that the page was not in TLB, fill and retry */
+static void
+glue(tcg_helper_qemu_st, SUFFIX)(CPUArchState *env, target_ulong addr,
+ DATA_TYPE val, int mmu_idx)
+{
+ void *retaddr;
+
+ retaddr = GETPC();
+#ifdef TARGET_ALIGNED_ONLY
+ if ((addr & (DATA_SIZE - 1)) != 0) {
+ cpu_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx,
+ retaddr);
+ }
+#endif
+ tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr);
+ glue(glue(helper_st, SUFFIX), MMUSUFFIX)(env, addr, val, mmu_idx);
+}
+#endif
+
/* handles all unaligned cases */
static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(ENV_PARAM
target_ulong addr,
@@ -931,6 +931,7 @@ static inline void tcg_out_goto_label(TCGContext *s, int cond, int label_index)
#ifdef CONFIG_TCG_PASS_AREG0
#define MMUSUFFIX _mmu
+#define GEN_TCG_HELPER
#define SHIFT 0
#include "softmmu_template.h"
@@ -946,20 +947,20 @@ static inline void tcg_out_goto_label(TCGContext *s, int cond, int label_index)
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
-static const void * const qemu_ld_helpers[4] = {
- helper_ldb_mmu,
- helper_ldw_mmu,
- helper_ldl_mmu,
- helper_ldq_mmu,
+static const void *qemu_ld_helpers[4] = {
+ tcg_helper_qemu_ldb,
+ tcg_helper_qemu_ldw,
+ tcg_helper_qemu_ldl,
+ tcg_helper_qemu_ldq,
};
/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
uintxx_t val, int mmu_idx) */
static const void * const qemu_st_helpers[4] = {
- helper_stb_mmu,
- helper_stw_mmu,
- helper_stl_mmu,
- helper_stq_mmu,
+ tcg_helper_qemu_stb,
+ tcg_helper_qemu_stw,
+ tcg_helper_qemu_stl,
+ tcg_helper_qemu_stq,
};
#else
/* legacy helper signature: __ld_mmu(target_ulong addr, int
@@ -884,6 +884,7 @@ static void tcg_out_setcond2(TCGContext *s, int cond, TCGArg ret,
#ifdef CONFIG_TCG_PASS_AREG0
#define MMUSUFFIX _mmu
+#define GEN_TCG_HELPER
#define SHIFT 0
#include "softmmu_template.h"
@@ -900,19 +901,19 @@ static void tcg_out_setcond2(TCGContext *s, int cond, TCGArg ret,
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
static const void * const qemu_ld_helpers[4] = {
- helper_ldb_mmu,
- helper_ldw_mmu,
- helper_ldl_mmu,
- helper_ldq_mmu,
+ tcg_helper_qemu_ldb,
+ tcg_helper_qemu_ldw,
+ tcg_helper_qemu_ldl,
+ tcg_helper_qemu_ldq,
};
/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
uintxx_t val, int mmu_idx) */
static const void * const qemu_st_helpers[4] = {
- helper_stb_mmu,
- helper_stw_mmu,
- helper_stl_mmu,
- helper_stq_mmu,
+ tcg_helper_qemu_stb,
+ tcg_helper_qemu_stw,
+ tcg_helper_qemu_stl,
+ tcg_helper_qemu_stq,
};
#else
/* legacy helper signature: __ld_mmu(target_ulong addr, int
@@ -962,6 +962,7 @@ static void tcg_out_jmp(TCGContext *s, tcg_target_long dest)
#ifdef CONFIG_TCG_PASS_AREG0
#define MMUSUFFIX _mmu
+#define GEN_TCG_HELPER
#define SHIFT 0
#include "softmmu_template.h"
@@ -978,19 +979,19 @@ static void tcg_out_jmp(TCGContext *s, tcg_target_long dest)
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
static const void *qemu_ld_helpers[4] = {
- helper_ldb_mmu,
- helper_ldw_mmu,
- helper_ldl_mmu,
- helper_ldq_mmu,
+ tcg_helper_qemu_ldb,
+ tcg_helper_qemu_ldw,
+ tcg_helper_qemu_ldl,
+ tcg_helper_qemu_ldq,
};
/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
uintxx_t val, int mmu_idx) */
static const void *qemu_st_helpers[4] = {
- helper_stb_mmu,
- helper_stw_mmu,
- helper_stl_mmu,
- helper_stq_mmu,
+ tcg_helper_qemu_stb,
+ tcg_helper_qemu_stw,
+ tcg_helper_qemu_stl,
+ tcg_helper_qemu_stq,
};
#else
/* legacy helper signature: __ld_mmu(target_ulong addr, int
@@ -1454,6 +1454,7 @@ static inline void tcg_out_qemu_tlb(TCGContext *s, TCGArg addr_reg,
#ifdef CONFIG_TCG_PASS_AREG0
#define MMUSUFFIX _mmu
+#define GEN_TCG_HELPER
#define SHIFT 0
#include "softmmu_template.h"
@@ -1470,10 +1471,10 @@ static inline void tcg_out_qemu_tlb(TCGContext *s, TCGArg addr_reg,
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
static const void * const qemu_ld_helpers[4] = {
- helper_ldb_mmu,
- helper_ldw_mmu,
- helper_ldl_mmu,
- helper_ldq_mmu,
+ tcg_helper_qemu_ldb,
+ tcg_helper_qemu_ldw,
+ tcg_helper_qemu_ldl,
+ tcg_helper_qemu_ldq,
};
#else
/* legacy helper signature: __ld_mmu(target_ulong addr, int
@@ -1587,10 +1588,10 @@ static inline void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
uintxx_t val, int mmu_idx) */
static const void * const qemu_st_helpers[4] = {
- helper_stb_mmu,
- helper_stw_mmu,
- helper_stl_mmu,
- helper_stq_mmu,
+ tcg_helper_qemu_stb,
+ tcg_helper_qemu_stw,
+ tcg_helper_qemu_stl,
+ tcg_helper_qemu_stq,
};
#else
/* legacy helper signature: __st_mmu(target_ulong addr, uintxx_t val,
@@ -752,6 +752,7 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond cond, int ret,
#ifdef CONFIG_TCG_PASS_AREG0
#define MMUSUFFIX _mmu
+#define GEN_TCG_HELPER
#define SHIFT 0
#include "softmmu_template.h"
@@ -768,19 +769,19 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond cond, int ret,
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
static const void * const qemu_ld_helpers[4] = {
- helper_ldb_mmu,
- helper_ldw_mmu,
- helper_ldl_mmu,
- helper_ldq_mmu,
+ tcg_helper_qemu_ldb,
+ tcg_helper_qemu_ldw,
+ tcg_helper_qemu_ldl,
+ tcg_helper_qemu_ldq,
};
/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
uintxx_t val, int mmu_idx) */
static const void * const qemu_st_helpers[4] = {
- helper_stb_mmu,
- helper_stw_mmu,
- helper_stl_mmu,
- helper_stq_mmu,
+ tcg_helper_qemu_stb,
+ tcg_helper_qemu_stw,
+ tcg_helper_qemu_stl,
+ tcg_helper_qemu_stq,
};
#else
/* legacy helper signature: __ld_mmu(target_ulong addr, int
@@ -510,6 +510,7 @@ static void tcg_out_call (TCGContext *s, tcg_target_long arg, int const_arg)
#ifdef CONFIG_TCG_PASS_AREG0
#define MMUSUFFIX _mmu
+#define GEN_TCG_HELPER
#define SHIFT 0
#include "softmmu_template.h"
@@ -526,19 +527,19 @@ static void tcg_out_call (TCGContext *s, tcg_target_long arg, int const_arg)
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
static const void * const qemu_ld_helpers[4] = {
- helper_ldb_mmu,
- helper_ldw_mmu,
- helper_ldl_mmu,
- helper_ldq_mmu,
+ tcg_helper_qemu_ldb,
+ tcg_helper_qemu_ldw,
+ tcg_helper_qemu_ldl,
+ tcg_helper_qemu_ldq,
};
/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
uintxx_t val, int mmu_idx) */
static const void * const qemu_st_helpers[4] = {
- helper_stb_mmu,
- helper_stw_mmu,
- helper_stl_mmu,
- helper_stq_mmu,
+ tcg_helper_qemu_stb,
+ tcg_helper_qemu_stw,
+ tcg_helper_qemu_stl,
+ tcg_helper_qemu_stq,
};
#else
/* legacy helper signature: __ld_mmu(target_ulong addr, int
@@ -554,6 +554,7 @@ static void tcg_out_ldsta (TCGContext *s, int ret, int addr,
#ifdef CONFIG_TCG_PASS_AREG0
#define MMUSUFFIX _mmu
+#define GEN_TCG_HELPER
#define SHIFT 0
#include "softmmu_template.h"
@@ -570,19 +571,19 @@ static void tcg_out_ldsta (TCGContext *s, int ret, int addr,
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
static const void * const qemu_ld_helpers[4] = {
- helper_ldb_mmu,
- helper_ldw_mmu,
- helper_ldl_mmu,
- helper_ldq_mmu,
+ tcg_helper_qemu_ldb,
+ tcg_helper_qemu_ldw,
+ tcg_helper_qemu_ldl,
+ tcg_helper_qemu_ldq,
};
/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
uintxx_t val, int mmu_idx) */
static const void * const qemu_st_helpers[4] = {
- helper_stb_mmu,
- helper_stw_mmu,
- helper_stl_mmu,
- helper_stq_mmu,
+ tcg_helper_qemu_stb,
+ tcg_helper_qemu_stw,
+ tcg_helper_qemu_stl,
+ tcg_helper_qemu_stq,
};
#else
/* legacy helper signature: __ld_mmu(target_ulong addr, int
@@ -303,6 +303,7 @@ static const uint8_t tcg_cond_to_ltr_cond[10] = {
#ifdef CONFIG_TCG_PASS_AREG0
#define MMUSUFFIX _mmu
+#define GEN_TCG_HELPER
#define SHIFT 0
#include "softmmu_template.h"
@@ -319,19 +320,19 @@ static const uint8_t tcg_cond_to_ltr_cond[10] = {
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
static const void * const qemu_ld_helpers[4] = {
- helper_ldb_mmu,
- helper_ldw_mmu,
- helper_ldl_mmu,
- helper_ldq_mmu,
+ tcg_helper_qemu_ldb,
+ tcg_helper_qemu_ldw,
+ tcg_helper_qemu_ldl,
+ tcg_helper_qemu_ldq,
};
/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
uintxx_t val, int mmu_idx) */
static const void * const qemu_st_helpers[4] = {
- helper_stb_mmu,
- helper_stw_mmu,
- helper_stl_mmu,
- helper_stq_mmu,
+ tcg_helper_qemu_stb,
+ tcg_helper_qemu_stw,
+ tcg_helper_qemu_stl,
+ tcg_helper_qemu_stq,
};
#else
/* legacy helper signature: __ld_mmu(target_ulong addr, int
@@ -717,6 +717,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
#ifdef CONFIG_TCG_PASS_AREG0
#define MMUSUFFIX _mmu
+#define GEN_TCG_HELPER
#define SHIFT 0
#include "softmmu_template.h"
@@ -733,19 +734,19 @@ static void tcg_target_qemu_prologue(TCGContext *s)
/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
int mmu_idx) */
static const void * const qemu_ld_helpers[4] = {
- helper_ldb_mmu,
- helper_ldw_mmu,
- helper_ldl_mmu,
- helper_ldq_mmu,
+ tcg_helper_qemu_ldb,
+ tcg_helper_qemu_ldw,
+ tcg_helper_qemu_ldl,
+ tcg_helper_qemu_ldq,
};
/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
uintxx_t val, int mmu_idx) */
static const void * const qemu_st_helpers[4] = {
- helper_stb_mmu,
- helper_stw_mmu,
- helper_stl_mmu,
- helper_stq_mmu,
+ tcg_helper_qemu_stb,
+ tcg_helper_qemu_stw,
+ tcg_helper_qemu_stl,
+ tcg_helper_qemu_stq,
};
#else
/* legacy helper signature: __ld_mmu(target_ulong addr, int
--
1.7.2.5
Don't recheck the TLB miss which we know is true, instead call directly the miss path. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> --- softmmu_template.h | 40 ++++++++++++++++++++++++++++++++++++++++ tcg/arm/tcg-target.c | 19 ++++++++++--------- tcg/hppa/tcg-target.c | 17 +++++++++-------- tcg/i386/tcg-target.c | 17 +++++++++-------- tcg/ia64/tcg-target.c | 17 +++++++++-------- tcg/mips/tcg-target.c | 17 +++++++++-------- tcg/ppc/tcg-target.c | 17 +++++++++-------- tcg/ppc64/tcg-target.c | 17 +++++++++-------- tcg/s390/tcg-target.c | 17 +++++++++-------- tcg/sparc/tcg-target.c | 17 +++++++++-------- 10 files changed, 122 insertions(+), 73 deletions(-)