Skip to content

Commit 86b1fb0

Browse files
committed
tcg: Upgrade to upstream version.
This switches the full TCG implementation to the upstream version from the following upstream commit: 1a8e80d Note that this requires completely reqwriting the softmmu_template.h declarations to adapt to the new world order where all ld/st helpers now accepts a CPUArchState* value as their first parameter. + This also gets rid of the REGPARM macro, which means that on i386, parameters are now passed on the stack instead of using registers. As surprising as it is, this doesn't seem to affect emulation performance in significant ways when starting the emulator with -force-32bit, compared to the latest SDK emulator binary. This may be due to the improved binary translator. Note that this doesn't switch the emulation to use the new MemoryRegion API, so there are still a few minor differences with upstream softmmu_*.h headers. The target-*/ sources have been minimally modified to accomodate for the changes, and everything seems to work. However, not that CONFIG_ANDROID_MEMCHECK_MMU hasn't been tested yet. + get rid of obsolete softmmu_outside_jit.c NOTE: There are two important differences with the upstream sources: - An '#undef small' in tcg.c used to build the Windows binaries with mingw32 on Linux. - The declaration of cc_compute_all and cc_compute_c helpers in target-i386/helper.h use TCG_CALL_NO_SE instead of TCG_CALL_NO_SE_RWG. Otherwise, it's impossible to boot an x86 system image properly. Change-Id: I6ed5c58f237493d29b1cefaff3e0db6f58977fbf
1 parent 780094a commit 86b1fb0

30 files changed

+5826
-2482
lines changed

Makefile.target

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ common_LOCAL_CFLAGS += -I$(GLIB_INCLUDE_DIR)
5252
common_LOCAL_CFLAGS += $(EMULATOR_TARGET_CFLAGS)
5353

5454
common_LOCAL_SRC_FILES += \
55+
tcg/optimize.c \
5556
tcg/tcg.c \
5657
tcg-runtime.c \
58+
util/bitops.c \
5759
util/host-utils.c \
5860

5961
##############################################################################

android/qemu/memcheck/memcheck_util.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
#include "qemu-common.h"
1919
#include "android/utils/path.h"
2020
#include "cpu.h"
21-
#include "exec/softmmu_exec.h"
21+
#include "exec/cpu-all.h"
2222

2323
#include "android/qemu/memcheck/memcheck_util.h"
2424
#include "android/qemu/memcheck/memcheck_proc_management.h"
2525
#include "android/qemu/memcheck/memcheck_logging.h"
2626

27+
#include "exec/softmmu_exec.h"
2728

2829
/* Gets symblos file path for the given module.
2930
* Param:

cputlb.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -373,36 +373,3 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr)
373373

374374
#define SHIFT 3
375375
#include "exec/softmmu_template.h"
376-
377-
// TODO(digit): Remove this once TCG is upgraded.
378-
uint8_t REGPARM __ldb_mmu(target_ulong addr, int mmu_idx) {
379-
return helper_ldb_mmu(cpu_single_env, addr, mmu_idx);
380-
}
381-
382-
void REGPARM __stb_mmu(target_ulong addr, uint8_t val, int mmu_idx) {
383-
return helper_stb_mmu(cpu_single_env, addr, val, mmu_idx);
384-
}
385-
386-
uint16_t REGPARM __ldw_mmu(target_ulong addr, int mmu_idx) {
387-
return helper_ldw_mmu(cpu_single_env, addr, mmu_idx);
388-
}
389-
390-
void REGPARM __stw_mmu(target_ulong addr, uint16_t val, int mmu_idx) {
391-
return helper_stw_mmu(cpu_single_env, addr, val, mmu_idx);
392-
}
393-
394-
uint32_t REGPARM __ldl_mmu(target_ulong addr, int mmu_idx) {
395-
return helper_ldl_mmu(cpu_single_env, addr, mmu_idx);
396-
}
397-
398-
void REGPARM __stl_mmu(target_ulong addr, uint32_t val, int mmu_idx) {
399-
return helper_stl_mmu(cpu_single_env, addr, val, mmu_idx);
400-
}
401-
402-
uint64_t REGPARM __ldq_mmu(target_ulong addr, int mmu_idx) {
403-
return helper_ldq_mmu(cpu_single_env, addr, mmu_idx);
404-
}
405-
406-
void REGPARM __stq_mmu(target_ulong addr, uint64_t val, int mmu_idx) {
407-
return helper_stq_mmu(cpu_single_env, addr, val, mmu_idx);
408-
}

include/exec/exec-all.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,19 @@ typedef struct TranslationBlock TranslationBlock;
4848
/* XXX: make safe guess about sizes */
4949
#define MAX_OP_PER_INSTR 208
5050

51-
/* A Call op needs up to 6 + 2N parameters (N = number of arguments). */
52-
#define MAX_OPC_PARAM 10
51+
#if HOST_LONG_BITS == 32
52+
#define MAX_OPC_PARAM_PER_ARG 2
53+
#else
54+
#define MAX_OPC_PARAM_PER_ARG 1
55+
#endif
56+
#define MAX_OPC_PARAM_IARGS 5
57+
#define MAX_OPC_PARAM_OARGS 1
58+
#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS)
59+
60+
/* A Call op needs up to 4 + 2N parameters on 32-bit archs,
61+
* and up to 4 + N parameters on 64-bit archs
62+
* (N = number of input arguments + output arguments). */
63+
#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS))
5364
#define OPC_BUF_SIZE 2048
5465
#define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR)
5566

@@ -416,7 +427,10 @@ extern void *io_mem_opaque[IO_MEM_NB_ENTRIES];
416427
void tlb_fill(CPUArchState *env1, target_ulong addr, int is_write, int mmu_idx,
417428
uintptr_t retaddr);
418429

419-
#include "exec/softmmu_defs.h"
430+
uint8_t helper_ldb_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
431+
uint16_t helper_ldw_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
432+
uint32_t helper_ldl_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
433+
uint64_t helper_ldq_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
420434

421435
#define ACCESS_TYPE (NB_MMU_MODES + 1)
422436
#define MEMSUFFIX _code
@@ -444,6 +458,7 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong
444458
return addr;
445459
}
446460
#else
461+
/* cputlb.c */
447462
tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr);
448463
#endif
449464

include/exec/poison.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#pragma GCC poison TARGET_M68K
1515
#pragma GCC poison TARGET_MIPS
1616
#pragma GCC poison TARGET_MIPS64
17+
#pragma GCC poison TARGET_OPENRISC
1718
#pragma GCC poison TARGET_PPC
1819
#pragma GCC poison TARGET_PPCEMB
1920
#pragma GCC poison TARGET_PPC64
@@ -35,6 +36,7 @@
3536
#pragma GCC poison TARGET_PAGE_ALIGN
3637

3738
#pragma GCC poison CPUOldState
39+
#pragma GCC poison CPUArchState
3840
#pragma GCC poison env
3941

4042
#pragma GCC poison lduw_phys

include/exec/softmmu_defs.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

include/exec/softmmu_exec.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
/* Common softmmu definitions and inline routines. */
1+
/*
2+
* Software MMU support
3+
*
4+
* Generate inline load/store functions for all MMU modes (typically
5+
* at least _user and _kernel) as well as _data versions, for all data
6+
* sizes.
7+
*
8+
* Used by target op helpers.
9+
*
10+
* MMU mode suffixes are defined in target cpu.h.
11+
*/
212

313
/* XXX: find something cleaner.
414
* Furthermore, this is false for 64 bits targets
@@ -9,7 +19,8 @@
919
#define ldul_executive ldl_executive
1020
#define ldul_supervisor ldl_supervisor
1121

12-
#include "exec/softmmu_defs.h"
22+
/* The memory helpers for tcg-generated code need tcg_target_long etc. */
23+
#include "tcg.h"
1324

1425
#define ACCESS_TYPE 0
1526
#define MEMSUFFIX MMU_MODE0_SUFFIX

include/exec/softmmu_header.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
114114
mmu_idx = CPU_MMU_INDEX;
115115
if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ !=
116116
(addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) {
117-
res = (DATA_STYPE)glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx);
117+
res = (DATA_STYPE)glue(glue(helper_ld, SUFFIX),
118+
MMUSUFFIX)(env, addr, mmu_idx);
118119
} else {
119120
uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend;
120121
res = glue(glue(lds, SUFFIX), _raw)(hostaddr);

0 commit comments

Comments
 (0)