S/390 support updated
cover S/390 support updated
S/390 support updated again. People are breathing down my neck to get this upstream, so I would really appreciate if someone could commit this, or tell me what's wrong with it. And preferably commit the stuff that is not wrong in the meantime, so I don't have to juggle 300k of patches every time...
CU
Uli
Ulrich Hecht (9):
TCG "sync" op
S/390 CPU emulation
S/390 host/target build system support
S/390 host support for TCG
linux-user: S/390 64-bit (s390x) support
linux-user: don't do locking in single-threaded processes
linux-user: dup3, fallocate syscalls
linux-user: define a couple of syscalls for non-uid16 targets
linux-user: getpriority errno fix
configure | 58 +- cpu-defs.h | 8 + cpu-exec.c | 16 +- default-configs/s390x-linux-user.mak | 1 + disas.c | 3 + dyngen-exec.h | 2 +- linux-user/elfload.c | 18 + linux-user/main.c | 82 ++ linux-user/s390x/syscall.h | 25 + linux-user/s390x/syscall_nr.h | 348 +++++ linux-user/s390x/target_signal.h | 26 + linux-user/s390x/termbits.h | 283 ++++ linux-user/signal.c | 314 +++++ linux-user/syscall.c | 156 ++- linux-user/syscall_defs.h | 56 +- qemu-binfmt-conf.sh | 5 +- s390-dis.c | 4 +- s390x.ld | 194 +++ target-s390x/cpu.h | 132 ++ target-s390x/exec.h | 51 + target-s390x/helper.c | 81 ++ target-s390x/helpers.h | 128 ++ target-s390x/op_helper.c | 1719 +++++++++++++++++++++++ target-s390x/translate.c | 2479 ++++++++++++++++++++++++++++++++++ tcg/s390/tcg-target.c | 1145 ++++++++++++++++ tcg/s390/tcg-target.h | 76 + tcg/tcg-op.h | 12 + tcg/tcg-opc.h | 2 + tcg/tcg.c | 6 + 29 files changed, 7390 insertions(+), 40 deletions(-) create mode 100644 default-configs/s390x-linux-user.mak create mode 100644 linux-user/s390x/syscall.h create mode 100644 linux-user/s390x/syscall_nr.h create mode 100644 linux-user/s390x/target_signal.h create mode 100644 linux-user/s390x/termbits.h create mode 100644 s390x.ld create mode 100644 target-s390x/cpu.h create mode 100644 target-s390x/exec.h create mode 100644 target-s390x/helper.c create mode 100644 target-s390x/helpers.h create mode 100644 target-s390x/op_helper.c create mode 100644 target-s390x/translate.c create mode 100644 tcg/s390/tcg-target.c create mode 100644 tcg/s390/tcg-target.h
PATCH 1/9 TCG "sync" op
sync allows concurrent accesses to locations in memory through different TCG variables. This comes in handy when you are emulating CPU registers that can be used as either 32 or 64 bit, as TCG doesn't know anything about aliases. See the s390x target for an example.
Fixed sync_i64 build failure on 32-bit targets.
--- tcg/tcg-op.h | 12 ++++++++++++ tcg/tcg-opc.h | 2 ++ tcg/tcg.c | 6 ++++++ 3 files changed, 20 insertions(+), 0 deletions(-)
tcg/tcg-op.h +12 -0
@@ -316,6 +316,18 @@ static inline void tcg_gen_br(int label)tcg_gen_op1i (INDEX_op_br, label); } +static inline void tcg_gen_sync_i32 (TCGv_i32 arg) +{ +tcg_gen_op1_i32 (INDEX_op_sync_i32, arg); +} + +#if TCG_TARGET_REG_BITS ==64 +static inline void tcg_gen_sync_i64 (TCGv_i64 arg) +{ +tcg_gen_op1_i64 (INDEX_op_sync_i64, arg); +} +#endif +static inline void tcg_gen_mov_i32 (TCGv_i32 ret,TCGv_i32 arg) {if (!TCGV_EQUAL_I32 (ret, arg))
tcg/tcg-opc.h +2 -0
@@ -40,6 +40,7 @@ DEF2(call, 0, 1, 2, TCG_OPF_SIDE_EFFECTS) /* variable number of parameters */ DEF2(jmp, 0, 1, 0, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS) DEF2(br, 0, 0, 1, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS) +DEF2(sync_i32, 0, 1, 0, 0) DEF2(mov_i32, 1, 1, 0, 0)DEF2 (movi_i32,1 ,0 ,1 ,0 )/* load/store */
@@ -109,6 +110,7 @@ DEF2(neg_i32, 1, 1, 0, 0)#endif #if TCG_TARGET_REG_BITS ==64 +DEF2(sync_i64, 0, 1, 0, 0) DEF2(mov_i64, 1, 1, 0, 0)DEF2 (movi_i64,1 ,0 ,1 ,0 )/* load/store */
tcg/tcg.c +6 -0
@@ -1930,6 +1930,12 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,// dump_regs(s); #endif switch (opc) { +case INDEX_op_sync_i32: +#if TCG_TARGET_REG_BITS ==64 +case INDEX_op_sync_i64: +#endif +temp_save (s, args[0 ], s->reserved_regs); +break ;case INDEX_op_mov_i32:#if TCG_TARGET_REG_BITS ==64 case INDEX_op_mov_i64:
Signature · 1 line
1.6.2.1
PATCH 2/9 S/390 CPU emulation
Currently only does userspace with 64-bit addressing, but it's quite good at that.
replaced always_inline with inline
--- cpu-exec.c | 2 + disas.c | 3 + s390-dis.c | 4 +- target-s390x/cpu.h | 132 +++ target-s390x/exec.h | 51 + target-s390x/helper.c | 81 ++ target-s390x/helpers.h | 128 +++ target-s390x/op_helper.c | 1719 ++++++++++++++++++++++++++++++++ target-s390x/translate.c | 2479 ++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 4597 insertions(+), 2 deletions(-) create mode 100644 target-s390x/cpu.h create mode 100644 target-s390x/exec.h create mode 100644 target-s390x/helper.c create mode 100644 target-s390x/helpers.h create mode 100644 target-s390x/op_helper.c create mode 100644 target-s390x/translate.c
cpu-exec.c +2 -0
@@ -249,6 +249,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_MIPS )#elif defined(TARGET_SH4 )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPU
@@ -673,6 +674,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_SH4 )#elif defined(TARGET_ALPHA )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPU
disas.c +3 -0
@@ -195,6 +195,9 @@ void target_disas(FILE *out, target_ulong code, target_ulong size, int flags)#elif defined(TARGET_CRIS ) disasm_info.mach = bfd_mach_cris_v32; print_insn = print_insn_crisv32; +#elif defined(TARGET_S390X ) + disasm_info.mach = bfd_mach_s390_64; + print_insn = print_insn_s390;#elif defined(TARGET_MICROBLAZE ) disasm_info.mach = bfd_arch_microblaze; print_insn = print_insn_microblaze;
s390-dis.c +2 -2
@@ -191,10 +191,10 @@ init_disasm (struct disassemble_info *info)// switch (info->mach) // { // case bfd_mach_s390_31: - current_arch_mask =1 <<S390_OPCODE_ESA ; +// current_arch_mask = 1 << S390_OPCODE_ESA; // break; // case bfd_mach_s390_64: -// current_arch_mask = 1 << S390_OPCODE_ZARCH; + current_arch_mask =1 <<S390_OPCODE_ZARCH ;// break; // default: // abort ();
target-s390x/cpu.h new file +132 -0
132 lines not on this page · raw message
target-s390x/exec.h new file +51 -0
51 lines not on this page · raw message
target-s390x/helper.c new file +81 -0
81 lines not on this page · raw message
target-s390x/helpers.h new file +128 -0
128 lines not on this page · raw message
target-s390x/op_helper.c new file +1719 -0
1,719 lines not on this page · raw message
target-s390x/translate.c new file +2479 -0
854 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.2.1
Part of the diff is not shown here. View the raw message.
PATCH 3/9 S/390 host/target build system support
changes to configure and makefiles for S/390 host and target support, fixed as suggested by Juan Quintela
adapted to most recent changes in build system
--- configure | 22 ++++++++++++++++------ default-configs/s390x-linux-user.mak | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 default-configs/s390x-linux-user.mak
configure +16 -6
@@ -157,9 +157,12 @@ case "$cpu" in parisc|parisc64) cpu="hppa" ;; - s390*) + s390) cpu="s390" ;; + s390x) + cpu="s390x" + ;; sparc|sun4[cdmuv]) cpu="sparc" ;;
@@ -790,6 +793,7 @@ sh4eb-linux-user \ sparc-linux-user \ sparc64-linux-user \ sparc32plus-linux-user \ +s390x-linux-user \ " fi # the following are Darwin specific
@@ -855,7 +859,7 @@ fi # host long bits test hostlongbits="32" case "$cpu" in - x86_64|alpha|ia64|sparc64|ppc64) + x86_64|alpha|ia64|sparc64|ppc64|s390x) hostlongbits=64 ;; esac
@@ -1819,7 +1823,7 @@ echo >> $config_host_mak echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak case "$cpu" in - i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64) + i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64) ARCH=$cpu ;; armv4b|armv4l)
@@ -2090,7 +2094,7 @@ target_arch2=`echo $target | cut -d '-' -f 1` target_bigendian="no" case "$target_arch2" in - armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus) + armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus) target_bigendian=yes ;; esac
@@ -2250,6 +2254,10 @@ case "$target_arch2" in echo "TARGET_ABI32=y" >> $config_target_mak target_phys_bits=64 ;; + s390x) + target_nptl="yes" + target_phys_bits=64 + ;; *) echo "Unsupported target CPU" exit 1
@@ -2318,7 +2326,7 @@ if test ! -z "$gdb_xml_files" ; then fi case "$target_arch2" in - arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus) + arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus) echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak ;; *)
@@ -2351,6 +2359,8 @@ ldflags="" if test "$ARCH" = "sparc64" ; then cflags="-I\$(SRC_PATH)/tcg/sparc $cflags" +elif test "$ARCH" = "s390x" ; then + cflags="-I\$(SRC_PATH)/tcg/s390 $cflags" else cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags" fi
@@ -2386,7 +2396,7 @@ for i in $ARCH $TARGET_BASE_ARCH ; do ppc*) echo "CONFIG_PPC_DIS=y" >> $config_target_mak ;; - s390) + s390*) echo "CONFIG_S390_DIS=y" >> $config_target_mak ;; sh4)
default-configs/s390x-linux-user.mak new file +1 -0
@@ -0,0 +1 @@ +# Default configuration for s390x-linux-user
Signature · 1 line
1.6.2.1
PATCH 4/9 S/390 host support for TCG
S/390 TCG code generator as posted before
improvements since last time:
- don't use R0 (often means "zero", not "register zero")
- optimized add_i32 immediate
- formatted for better compliance with the QEMU coding style
--- dyngen-exec.h | 2 +- linux-user/syscall.c | 2 +- s390x.ld | 194 +++++++++ tcg/s390/tcg-target.c | 1145 +++++++++++++++++++++++++++++++++++++++++++++++++ tcg/s390/tcg-target.h | 76 ++++ 5 files changed, 1417 insertions(+), 2 deletions(-) create mode 100644 s390x.ld create mode 100644 tcg/s390/tcg-target.c create mode 100644 tcg/s390/tcg-target.h
dyngen-exec.h +1 -1
@@ -117,7 +117,7 @@ extern int printf(const char *, ...);/* The return address may point to the start of the next instruction. Subtracting one gets us the call instruction itself. */ -#if defined(__s390__) +#if defined(__s390__) && !defined(__s390x__)# define GETPC () ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))#elif defined(__arm__)/* Thumb return addresses have the low bit set, so we need to subtract two.
linux-user/syscall.c +1 -1
@@ -183,7 +183,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \#define __NR_sys_inotify_add_watch __NR_inotify_add_watch#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch -#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__) +#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__) || defined(__s390x__)#define __NR__llseek __NR_lseek#endif
s390x.ld new file +194 -0
194 lines not on this page · raw message
tcg/s390/tcg-target.c new file +1145 -0
1,145 lines not on this page · raw message
tcg/s390/tcg-target.h new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
1.6.2.1
PATCH 5/9 linux-user: S/390 64-bit (s390x) support
code for running 64-bit S/390 Linux binaries
--- linux-user/elfload.c | 18 ++ linux-user/main.c | 82 +++++++++ linux-user/s390x/syscall.h | 25 +++ linux-user/s390x/syscall_nr.h | 348 ++++++++++++++++++++++++++++++++++++++ linux-user/s390x/target_signal.h | 26 +++ linux-user/s390x/termbits.h | 283 +++++++++++++++++++++++++++++++ linux-user/signal.c | 314 ++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 16 ++- linux-user/syscall_defs.h | 56 ++++++- qemu-binfmt-conf.sh | 5 +- 10 files changed, 1166 insertions(+), 7 deletions(-) create mode 100644 linux-user/s390x/syscall.h create mode 100644 linux-user/s390x/syscall_nr.h create mode 100644 linux-user/s390x/target_signal.h create mode 100644 linux-user/s390x/termbits.h
linux-user/elfload.c +18 -0
@@ -679,6 +679,24 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i#endif /* TARGET_ALPHA */ +#ifdef TARGET_S390X + +#define ELF_START_MMAP (0x20000000000ULL) + +#define elf_check_arch (x) ( (x) == ELF_ARCH ) + +#define ELF_CLASS ELFCLASS64 +#define ELF_DATA ELFDATA2MSB +#define ELF_ARCH EM_S390 + +static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) +{ + regs->psw.addr = infop->entry; + regs->gprs[15 ] = infop->start_stack; +} + +#endif /* TARGET_S390X */ +#ifndef ELF_PLATFORM #define ELF_PLATFORM (NULL)#endif
linux-user/main.c +82 -0
94 lines not on this page · raw message
linux-user/s390x/syscall.h new file +25 -0
@@ -0,0 +1,25 @@ +/* this typedef defines how a Program Status Word looks like */ +typedef struct +{ +abi_ulong mask; +abi_ulong addr; +} __attribute__ ((aligned (8 )))target_psw_t ; + +/* +* The pt_regs struct defines the way the registers are stored on +* the stack during a system call. +*/ + +#define TARGET_NUM_GPRS 16 + +struct target_pt_regs +{ +abi_ulong args[1 ]; +target_psw_t psw; +abi_ulong gprs[TARGET_NUM_GPRS ]; +abi_ulong orig_gpr2; +unsigned short ilc; +unsigned short trap; +}; + +#define UNAME_MACHINE "s390x"
linux-user/s390x/syscall_nr.h new file +348 -0
348 lines not on this page · raw message
linux-user/s390x/target_signal.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef TARGET_SIGNAL_H +#define TARGET_SIGNAL_H + +#include "cpu.h" + +typedef struct target_sigaltstack { +abi_ulong ss_sp; +int ss_flags; +abi_ulong ss_size; +}target_stack_t ; + +/* +* sigaltstack controls +*/ +#define TARGET_SS_ONSTACK 1 +#define TARGET_SS_DISABLE 2 + +#define TARGET_MINSIGSTKSZ 2048 +#define TARGET_SIGSTKSZ 8192 + +static inline abi_ulong get_sp_from_cpustate (CPUS390XState *state) +{ +return state->regs[15 ]; +} + +#endif /* TARGET_SIGNAL_H */
linux-user/s390x/termbits.h new file +283 -0
283 lines not on this page · raw message
linux-user/signal.c +314 -0
320 lines not on this page · raw message
linux-user/syscall.c +12 -4
@@ -5102,7 +5102,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret =get_errno (settimeofday (&tv,NULL )); }break ; -#ifdef TARGET_NR_select +#if defined(TARGET_NR_select) && !defined(TARGET_S390X ) && !defined(TARGET_S390 )case TARGET_NR_select: {struct target_sel_arg_struct *sel;
@@ -5209,7 +5209,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_mmap case TARGET_NR_mmap: -#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE) +#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || \ + defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE) \ + || defined(TARGET_S390X) { abi_ulong *v; abi_ulong v1, v2, v3, v4, v5, v6;
@@ -5694,6 +5696,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret =get_errno (do_fork (cpu_env, arg1, arg2, arg3, arg5, arg4));#elif defined(TARGET_CRIS ) ret =get_errno (do_fork (cpu_env, arg2, arg1, arg3, arg4, arg5)); +#elif defined(TARGET_S390X ) + ret =get_errno (do_fork (cpu_env, arg2, arg1, arg3, arg5, arg4));#else ret =get_errno (do_fork (cpu_env, arg1, arg2, arg3, arg4, arg5));#endif
@@ -5898,8 +5902,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, }break ;#endif /* TARGET_NR_getdents64 */ -#ifdef TARGET_NR__newselect +#if defined(TARGET_NR__newselect) || defined(TARGET_S390X ) +#ifdef TARGET_S390X +case TARGET_NR_select: +#else case TARGET_NR__newselect: +#endif ret =do_select (arg1, arg2, arg3, arg4, arg5);break ;#endif
@@ -6124,7 +6132,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_sigaltstack:#if defined(TARGET_I386 ) || defined(TARGET_ARM ) || defined(TARGET_MIPS ) || \ defined(TARGET_SPARC ) || defined(TARGET_PPC ) || defined(TARGET_ALPHA ) || \ - defined(TARGET_M68K ) + defined(TARGET_M68K ) || defined(TARGET_S390X ) ret =do_sigaltstack (arg1, arg2,get_sp_from_cpustate ((CPUState *)cpu_env));break ;#else
linux-user/syscall_defs.h +54 -2
80 lines not on this page · raw message
qemu-binfmt-conf.sh +4 -1
@@ -1,5 +1,5 @@ #!/bin/sh -# enable automatic i386/ARM/M68K/MIPS/SPARC/PPC program execution by the kernel +# enable automatic i386/ARM/M68K/MIPS/SPARC/PPC/s390 program execution by the kernel # load the binfmt_misc module if [ ! -d /proc/sys/fs/binfmt_misc ]; then
@@ -57,3 +57,6 @@ if [ $cpu != "mips" ] ; then echo ':mips64:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips64:' > /proc/sys/fs/binfmt_misc/register echo ':mips64el:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mips64el:' > /proc/sys/fs/binfmt_misc/register fi +if [ $cpu != "s390x" ] ; then + echo ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-s390x:' > /proc/sys/fs/binfmt_misc/register +fi
Signature · 1 line
1.6.2.1
PATCH 6/9 linux-user: don't do locking in single-threaded processes
Skips setting the tb_lock if a process doesn't have more than one thread, which is usually the case. Results in about 20% performance gain (measured with the s390x target, but the effect should be similar with other targets).
--- cpu-defs.h | 8 ++++++++ cpu-exec.c | 14 ++++++++++++-- linux-user/syscall.c | 1 + 3 files changed, 21 insertions(+), 2 deletions(-)
cpu-defs.h +8 -0
@@ -135,6 +135,13 @@ typedef struct CPUWatchpoint { } CPUWatchpoint;#define CPU_TEMP_BUF_NLONGS 128 + +#ifdef CONFIG_USER_ONLY +#define MULTITHREAD uint32_t multithreaded; +#else +#define MULTITHREAD +#endif +#define CPU_COMMON \ struct TranslationBlock *current_tb;/* currently executing TB */ \/* soft mmu support */ \
@@ -149,6 +156,7 @@ typedef struct CPUWatchpoint {uint32_t stop;/* Stop request */ \uint32_t stopped;/* Artificially stopped */ \uint32_t interrupt_request; \ +MULTITHREAD /* needs locking when accessing TBs */ \ volatile sig_atomic_t exit_request; \/* The meaning of the MMU modes is defined in the target code. */ \CPUTLBEntry tlb_table[NB_MMU_MODES ][CPU_TLB_SIZE ]; \
cpu-exec.c +12 -2
@@ -219,6 +219,9 @@ int cpu_exec(CPUState *env1)TranslationBlock *tb;uint8_t *tc_ptr;unsigned long next_tb; +#ifdef CONFIG_USER_ONLY +uint32_t multithreaded; +#endif if (cpu_halted (env1) ==EXCP_HALTED )return EXCP_HALTED ;
@@ -576,7 +579,11 @@ int cpu_exec(CPUState *env1)#endif }#endif -spin_lock (&tb_lock); +#ifdef CONFIG_USER_ONLY + multithreaded = env->multithreaded; + if (multithreaded) +#endif +spin_lock (&tb_lock); tb =tb_find_fast ();/* Note: we do it here to avoid a gcc bug on Mac OS X when doing it in tb_find_slow */
@@ -600,7 +607,10 @@ int cpu_exec(CPUState *env1)tb_add_jump ((TranslationBlock *)(next_tb & ~3 ), next_tb &3 , tb); } } -spin_unlock (&tb_lock); +#ifdef CONFIG_USER_ONLY + if (multithreaded) +#endif +spin_unlock (&tb_lock); env->current_tb = tb;/* cpu_interrupt might be called while translating the
linux-user/syscall.c +1 -0
@@ -3549,6 +3549,7 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp, ts =qemu_mallocz (sizeof (TaskState) +NEW_STACK_SIZE );init_task_state (ts); new_stack = ts->stack; + env->multithreaded =1 ;/* we create a new CPU instance. */ new_env =cpu_copy (env);/* Init regs that differ from the parent. */
Signature · 1 line
1.6.2.1
PATCH 7/9 linux-user: dup3, fallocate syscalls
implementations of dup3 and fallocate that are good enough to fool LTP
dup3 check, fallocate check fixed
use compile_prog
--- configure | 36 ++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 10 ++++++++++ 2 files changed, 46 insertions(+), 0 deletions(-)
configure +36 -0
@@ -1573,6 +1573,36 @@ if compile_prog "" "" ; then eventfd=yes fi +# check for fallocate +fallocate=no +cat > $TMPC << EOF +#include <fcntl.h> + +int main(void) +{ + fallocate(0, 0, 0, 0); + return 0; +} +EOF +if compile_prog "" "" ; then + fallocate=yes +fi + +# check for dup3 +dup3=no +cat > $TMPC << EOF +#include <unistd.h> + +int main(void) +{ + dup3(0, 0, 0); + return 0; +} +EOF +if compile_prog "" "" ; then + dup3=yes +fi + # Check if tools are available to build documentation. if test "$docs" != "no" ; then if test -x "`which texi2html 2>/dev/null`" -a \
@@ -1954,6 +1984,12 @@ fi if test "$eventfd" = "yes" ; then echo "CONFIG_EVENTFD=y" >> $config_host_mak fi +if test "$fallocate" = "yes" ; then + echo "CONFIG_FALLOCATE=y" >> $config_host_mak +fi +if test "$dup3" = "yes" ; then + echo "CONFIG_DUP3=y" >> $config_host_mak +fi if test "$inotify" = "yes" ; then echo "CONFIG_INOTIFY=y" >> $config_host_mak fi
linux-user/syscall.c +10 -0
@@ -4747,6 +4747,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_dup2: ret =get_errno (dup2 (arg1, arg2));break ; +#if defined(TARGET_NR_dup3) && defined(CONFIG_DUP3 ) +case TARGET_NR_dup3: + ret =get_errno (dup3 (arg1, arg2, arg3)); +break ; +#endif #ifdef TARGET_NR_getppid/* not on alpha */ case TARGET_NR_getppid: ret =get_errno (getppid ());
@@ -7022,6 +7027,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif #endif /* CONFIG_EVENTFD */ +#if defined(CONFIG_FALLOCATE ) && defined(TARGET_NR_fallocate) +case TARGET_NR_fallocate: + ret =get_errno (fallocate (arg1, arg2, arg3, arg4)); +break ; +#endif default : unimplemented:gemu_log ("qemu: Unsupported syscall: %d\n" , num);
Signature · 1 line
1.6.2.1
PATCH 8/9 linux-user: define a couple of syscalls for non-uid16 targets
Quite a number of syscalls are only defined on systems with USE_UID16 defined; this patch defines them on other systems as well.
Fixes a large number of uid/gid-related testcases on the s390x target (and most likely on other targets as well)
--- linux-user/syscall.c | 125 ++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 105 insertions(+), 20 deletions(-)
linux-user/syscall.c +105 -20
@@ -307,7 +307,7 @@ static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode)return (fchmodat (dirfd, pathname, mode,0 )); }#endif -#if defined(TARGET_NR_fchownat) && defined(USE_UID16 ) +#if defined(TARGET_NR_fchownat)static int sys_fchownat (int dirfd,const char *pathname,uid_t owner,gid_t group,int flags) {
@@ -416,7 +416,7 @@ _syscall3(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode)#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat) _syscall3(int,sys_fchmodat,int,dirfd,const char *,pathname, mode_t,mode)#endif -#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) && defined(USE_UID16 ) +#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) _syscall5(int,sys_fchownat,int,dirfd,const char *,pathname, uid_t,owner,gid_t,group,int,flags)#endif
@@ -6371,18 +6371,35 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_setfsgid: ret =get_errno (setfsgid (arg1));break ; +#else /* USE_UID16 */ +#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) +case TARGET_NR_fchownat: +if (!(p =lock_user_string (arg2))) + goto efault; + ret =get_errno (sys_fchownat (arg1, p, arg3, arg4, arg5)); +unlock_user (p, arg2,0 ); +break ; +#endif #endif /* USE_UID16 */ -#ifdef TARGET_NR_lchown32 +#if defined(TARGET_NR_lchown32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_lchown32)case TARGET_NR_lchown32: +#else +case TARGET_NR_lchown: +#endif if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (lchown (p, arg2, arg3));unlock_user (p, arg1,0 );break ;#endif -#ifdef TARGET_NR_getuid32 +#if defined(TARGET_NR_getuid32) || (defined(TARGET_NR_getuid) && !defined(USE_UID16 )) +#if defined(TARGET_NR_getuid32)case TARGET_NR_getuid32: +#else +case TARGET_NR_getuid: +#endif ret =get_errno (getuid ());break ;#endif
@@ -6410,33 +6427,57 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif -#ifdef TARGET_NR_getgid32 +#if defined(TARGET_NR_getgid32) || (defined(TARGET_NR_getgid) && !defined(USE_UID16 )) +#if defined(TARGET_NR_getgid32)case TARGET_NR_getgid32: +#else +case TARGET_NR_getgid: +#endif ret =get_errno (getgid ());break ;#endif -#ifdef TARGET_NR_geteuid32 +#if defined(TARGET_NR_geteuid32) || (defined(TARGET_NR_geteuid) && !defined(USE_UID16 )) +#if defined(TARGET_NR_geteuid32)case TARGET_NR_geteuid32: +#else +case TARGET_NR_geteuid: +#endif ret =get_errno (geteuid ());break ;#endif -#ifdef TARGET_NR_getegid32 +#if defined(TARGET_NR_getegid32) || (defined(TARGET_NR_getegid) && !defined(USE_UID16 )) +#if defined(TARGET_NR_getegid32)case TARGET_NR_getegid32: +#else +case TARGET_NR_getegid: +#endif ret =get_errno (getegid ());break ;#endif -#ifdef TARGET_NR_setreuid32 +#if defined(TARGET_NR_setreuid32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_setreuid32)case TARGET_NR_setreuid32: +#else +case TARGET_NR_setreuid: +#endif ret =get_errno (setreuid (arg1, arg2));break ;#endif -#ifdef TARGET_NR_setregid32 +#if defined(TARGET_NR_setregid32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_setregid32)case TARGET_NR_setregid32: +#else +case TARGET_NR_setregid: +#endif ret =get_errno (setregid (arg1, arg2));break ;#endif -#ifdef TARGET_NR_getgroups32 +#if defined(TARGET_NR_getgroups32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_getgroups32)case TARGET_NR_getgroups32: +#else +case TARGET_NR_getgroups: +#endif {int gidsetsize = arg1;uint32_t *target_grouplist;
@@ -6460,8 +6501,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, }break ;#endif -#ifdef TARGET_NR_setgroups32 +#if defined(TARGET_NR_setgroups32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_setgroups32)case TARGET_NR_setgroups32: +#else +case TARGET_NR_setgroups: +#endif {int gidsetsize = arg1;uint32_t *target_grouplist;
@@ -6481,18 +6526,30 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, }break ;#endif -#ifdef TARGET_NR_fchown32 +#if defined(TARGET_NR_fchown32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_fchown32)case TARGET_NR_fchown32: +#else +case TARGET_NR_fchown: +#endif ret =get_errno (fchown (arg1, arg2, arg3));break ;#endif -#ifdef TARGET_NR_setresuid32 +#if defined(TARGET_NR_setresuid32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_setresuid32)case TARGET_NR_setresuid32: +#else +case TARGET_NR_setresuid: +#endif ret =get_errno (setresuid (arg1, arg2, arg3));break ;#endif -#ifdef TARGET_NR_getresuid32 +#if defined(TARGET_NR_getresuid32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_getresuid32)case TARGET_NR_getresuid32: +#else +case TARGET_NR_getresuid: +#endif {uid_t ruid, euid, suid; ret =get_errno (getresuid (&ruid, &euid, &suid));
@@ -6505,13 +6562,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, }break ;#endif -#ifdef TARGET_NR_setresgid32 +#if defined(TARGET_NR_setresgid32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_setresgid32)case TARGET_NR_setresgid32: +#else +case TARGET_NR_setresgid: +#endif ret =get_errno (setresgid (arg1, arg2, arg3));break ;#endif +#if defined(TARGET_NR_getresgid32) || !defined(USE_UID16 )#ifdef TARGET_NR_getresgid32case TARGET_NR_getresgid32: +#else +case TARGET_NR_getresgid: +#endif {gid_t rgid, egid, sgid; ret =get_errno (getresgid (&rgid, &egid, &sgid));
@@ -6524,31 +6589,51 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, }break ;#endif -#ifdef TARGET_NR_chown32 +#if defined(TARGET_NR_chown32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_chown32)case TARGET_NR_chown32: +#else +case TARGET_NR_chown: +#endif if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (chown (p, arg2, arg3));unlock_user (p, arg1,0 );break ;#endif -#ifdef TARGET_NR_setuid32 +#if defined(TARGET_NR_setuid32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_setuid32)case TARGET_NR_setuid32: +#else +case TARGET_NR_setuid: +#endif ret =get_errno (setuid (arg1));break ;#endif -#ifdef TARGET_NR_setgid32 +#if defined(TARGET_NR_setgid32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_setgid32)case TARGET_NR_setgid32: +#else +case TARGET_NR_setgid: +#endif ret =get_errno (setgid (arg1));break ;#endif -#ifdef TARGET_NR_setfsuid32 +#if defined(TARGET_NR_setfsuid32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_setfsuid32)case TARGET_NR_setfsuid32: +#else +case TARGET_NR_setfsuid: +#endif ret =get_errno (setfsuid (arg1));break ;#endif -#ifdef TARGET_NR_setfsgid32 +#if defined(TARGET_NR_setfsgid32) || !defined(USE_UID16 ) +#if defined(TARGET_NR_setfsgid32)case TARGET_NR_setfsgid32: +#else +case TARGET_NR_setfsgid: +#endif ret =get_errno (setfsgid (arg1));break ;#endif
Signature · 1 line
1.6.2.1
PATCH 9/9 linux-user: getpriority errno fix
getpriority returned wrong errno; fixes LTP test getpriority02.
--- linux-user/syscall.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
linux-user/syscall.c +1 -1
@@ -5314,7 +5314,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,/* libc does special remapping of the return value of * sys_getpriority() so it's just easiest to call * sys_getpriority() directly rather than through libc. */ - ret =sys_getpriority (arg1, arg2); + ret =get_errno (sys_getpriority (arg1, arg2));break ;case TARGET_NR_setpriority: ret =get_errno (setpriority (arg1, arg2, arg3));
Signature · 1 line
1.6.2.1
Re: [Qemu-devel] [PATCH 3/9] S/390 host/target build system support
In reply to Ulrich HechtQuoted 4 lines · Ulrich Hecht
changes to configure and makefiles for S/390 host and target support, fixed as suggested by Juan Quintela
adapted to most recent changes in build system
Basically looks ok, but it would be worth to split it into host and target part, so that the two resulting patches can be applied separately.
Quoted 111 lines
Signed-off-by Ulrich Hecht <[email protected]>--- configure | 22 ++++++++++++++++------ default-configs/s390x-linux-user.mak | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 default-configs/s390x-linux-user.makconfigure +16
-6@@ -157,9 +157,12 @@ case "$cpu" in parisc|parisc64) cpu="hppa" ;; - s390*) + s390) cpu="s390" ;; + s390x) + cpu="s390x" + ;; sparc|sun4[cdmuv]) cpu="sparc" ;;@@ -790,6 +793,7 @@ sh4eb-linux-user \ sparc-linux-user \ sparc64-linux-user \ sparc32plus-linux-user \ +s390x-linux-user \ " fi # the following are Darwin specific@@ -855,7 +859,7 @@ fi # host long bits test hostlongbits="32" case "$cpu" in - x86_64|alpha|ia64|sparc64|ppc64) + x86_64|alpha|ia64|sparc64|ppc64|s390x) hostlongbits=64 ;; esac@@ -1819,7 +1823,7 @@ echo >> $config_host_mak echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak case "$cpu" in - i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64) + i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64) ARCH=$cpu ;; armv4b|armv4l)@@ -2090,7 +2094,7 @@ target_arch2=`echo $target | cut -d '-' -f 1` target_bigendian="no" case "$target_arch2" in - armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus) + armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus) target_bigendian=yes ;; esac@@ -2250,6 +2254,10 @@ case "$target_arch2" in echo "TARGET_ABI32=y" >> $config_target_mak target_phys_bits=64 ;; + s390x) + target_nptl="yes" + target_phys_bits=64 + ;; *) echo "Unsupported target CPU" exit 1@@ -2318,7 +2326,7 @@ if test ! -z "$gdb_xml_files" ; then fi case "$target_arch2" in - arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus) + arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus) echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak ;; *)@@ -2351,6 +2359,8 @@ ldflags="" if test "$ARCH" = "sparc64" ; then cflags="-I\$(SRC_PATH)/tcg/sparc $cflags" +elif test "$ARCH" = "s390x" ; then + cflags="-I\$(SRC_PATH)/tcg/s390 $cflags" else cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags" fi@@ -2386,7 +2396,7 @@ for i in $ARCH $TARGET_BASE_ARCH ; do ppc*) echo "CONFIG_PPC_DIS=y" >> $config_target_mak ;; - s390) + s390*) echo "CONFIG_S390_DIS=y" >> $config_target_mak ;; sh4)default-configs/s390x-linux-user.mak new file +1
-0@@ -0,0 +1 @@ +# Default configuration for s390x-linux-userSignature · 1 line
1.6.2.1
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 2/9] S/390 CPU emulation
In reply to Ulrich HechtQuoted 15 lines · Ulrich Hecht
Currently only does userspace with 64-bit addressing, but it's quite good at that.
replaced
always_inlinewith inlineSigned-off-by Ulrich Hecht <[email protected]>--- cpu-exec.c | 2 + disas.c | 3 + s390-dis.c | 4 +- target-s390x/cpu.h | 132 +++ target-s390x/exec.h | 51 + target-s390x/helper.c | 81 ++ target-s390x/helpers.h | 128 +++ target-s390x/op_helper.c | 1719 ++++++++++++++++++++++++++++++++
Quoted 8 lines
target-s390x/translate.c | 2479 ++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 4597 insertions(+), 2 deletions(-) create mode 100644 target-s390x/cpu.h create mode 100644 target-s390x/exec.h create mode 100644 target-s390x/helper.c create mode 100644 target-s390x/helpers.h create mode 100644 target-s390x/op_helper.c create mode 100644 target-s390x/translate.c
Thanks for this nice patch. s390 is one if the missing major targets with ia64.
First of all a few general comments. Note that I know very few things about S390/S390X, so I may have dumb comments/questions. Also as the patch is very long, I probably have missed things, we should probably iterate with new versions of the patches.
Is it possible given the current implementation to emulate S390 in addition to S390X? If yes how different would be a S390 only target? If they won't be too different, it probably worth using _tl type registers and call it target-s390. A bit the way it is done with i386/x86_64, ppc/ppc64, mips/mips64 or sparc/sparc64.
Secondly there seems to be a lot of mix between 32-bit and 64-bit TCG registers. They should not be mixed. _i32 ops apply to TCGv_i32 variables, _i64 ops apply to TCGv_i64 variables, and _tl ops to TGCv variables. TCGv/_tl types can map either to _i32 or _i64 depending on your target. You should try to build the target with --enable-debug-tcg
Otherwise please find my comments inline.
Quoted 25 lines
cpu-exec.c +2
-0@@ -249,6 +249,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_MIPS )#elif defined(TARGET_SH4 )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPU@@ -673,6 +674,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_SH4 )#elif defined(TARGET_ALPHA )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPUdisas.c +0
-0
disas.c void target_disas(FILE *out, target_ulong code, target_ulong size, int flags) · line 203
Quoted 9 lines
disas.c +3
-0@@ -195,6 +195,9 @@ void target_disas(FILE *out, target_ulong code, target_ulong size, int flags)#elif defined(TARGET_CRIS ) disasm_info.mach = bfd_mach_cris_v32; print_insn = print_insn_crisv32; +#elif defined(TARGET_S390X ) + disasm_info.mach = bfd_mach_s390_64; + print_insn = print_insn_s390;#elif defined(TARGET_MICROBLAZE ) disasm_info.mach = bfd_arch_microblaze; print_insn = print_insn_microblaze;
It would be nice to split all the disassembling part in a separate combined with the related makefile changes. This way it can be applied separately.
Quoted 7 lines
s390-dis.c +0
-0@@ -191,10 +191,10 @@ init_disasm (struct disassemble_info *info)// switch (info->mach) // {
s390-dis.c init_disasm (struct disassemble_info *info) · line 200
Quoted 10 lines
s390-dis.c +2
-2// case bfd_mach_s390_31: - current_arch_mask =1 <<S390_OPCODE_ESA ; +// current_arch_mask = 1 << S390_OPCODE_ESA; // break; // case bfd_mach_s390_64: -// current_arch_mask = 1 << S390_OPCODE_ZARCH; + current_arch_mask =1 <<S390_OPCODE_ZARCH ;// break; // default: // abort ();
While I understand the second part, Why is it necessary to comment the bfd_mach_s390_31 case?
Quoted 44 lines
target-s390x/cpu.h new file +38
-0@@ -0,0 +1,132 @@ +/* +* S/390 virtual CPU header +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ +#ifndef CPU_S390X_H +#define CPU_S390X_H + +#define TARGET_LONG_BITS 64 + +#define ELF_MACHINE EM_S390 + +#define CPUState struct CPUS390XState + +#include "cpu-defs.h" + +#include "softfloat.h" + +#define NB_MMU_MODES 2 // guess +#define MMU_USER_IDX 0 // guess + +typedef union FPReg { + struct { +#ifdef WORDS_BIGENDIAN
target-s390x/cpu.h line 48
Quoted 10 lines
target-s390x/cpu.h new file +10
-0+float32 e; +int32_t __pad; +#else +int32_t __pad; +float32 e; +#endif + }; +float64 d; +uint64_t i; +} FPReg;
WORDS_BIGENDIAN is wrong here. It should probably be HOST_WORDS_BIGENDIAN. Also it may be a better idea to reuse CPU_FloatU and CPU_DoubleU here.
Quoted 182 lines
target-s390x/cpu.h new file +83
-0+typedef struct CPUS390XState { +uint64_t regs[16 ];/* GP registers */ + +uint32_t aregs[16 ];/* access registers */ + +uint32_t fpc;/* floating-point control register */ +FPReg fregs[16 ];/* FP registers */ +float_status fpu_status;/* passed to softfloat lib */ + +struct { +uint64_t mask; +uint64_t addr; + } psw; + +int cc;/* condition code (0-3) */ + +uint64_t __excp_addr; + + CPU_COMMON +}CPUS390XState ; + +#if defined(CONFIG_USER_ONLY ) +static inline void cpu_clone_regs (CPUState *env,target_ulong newsp) +{ +if (newsp) + env->regs[15 ] = newsp; + env->regs[0 ] =0 ; +} +#endif + +CPUS390XState *cpu_s390x_init (const char *cpu_model); +void s390x_translate_init (void ); +int cpu_s390x_exec (CPUS390XState *s); +void cpu_s390x_close (CPUS390XState *s); +void do_interrupt (CPUState *env); + +/* you can call this signal handler from your SIGBUS and SIGSEGV +signal handlers to inform the virtual CPU of exceptions. non zero +is returned if the signal was handled by the virtual CPU. */ +int cpu_s390x_signal_handler (int host_signum,void *pinfo, +void *puc); +int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong address,int rw, +int mmu_idx,int is_softmuu); +#define cpu_handle_mmu_fault cpu_s390x_handle_mmu_fault + +void cpu_lock (void ); +void cpu_unlock (void ); + +static inline void cpu_set_tls (CPUS390XState *env,target_ulong newtls) +{ + env->aregs[0 ] = newtls >>32 ; + env->aregs[1 ] = newtls &0xffffffffULL ; +} + +#define TARGET_PAGE_BITS 12 // guess + +#define cpu_init cpu_s390x_init +#define cpu_exec cpu_s390x_exec +#define cpu_gen_code cpu_s390x_gen_code +#define cpu_signal_handler cpu_s390x_signal_handler +//#define cpu_list s390x_cpu_list + +#include "cpu-all.h" +#include "exec-all.h" + +#define EXCP_OPEX 1/* operation exception (sigill) */ +#define EXCP_SVC 2/* supervisor call (syscall) */ +#define EXCP_ADDR 5/* addressing exception */ +#define EXCP_EXECUTE_SVC 0xff00000/* supervisor call via execute insn */ + +static inline void cpu_pc_from_tb (CPUState *env,TranslationBlock * tb) +{ + env->psw.addr = tb->pc; +} + +static inline void cpu_get_tb_cpu_state (CPUState * env,target_ulong *pc, +target_ulong *cs_base,int *flags) +{ + *pc = env->psw.addr; + *cs_base =0 ; + *flags = env->psw.mask;// guess +} +#endif target-s390x/exec.h new file +51
-0@@ -0,0 +1,51 @@ +/* +* S/390 execution defines +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ + +#include "dyngen-exec.h" + +register struct CPUS390XState *env asm(AREG0); + +#include "cpu.h" +#include "exec-all.h" + +static inline int cpu_has_work (CPUState *env) +{ +return env->interrupt_request &CPU_INTERRUPT_HARD ;// guess +} + +static inline void regs_to_env (void ) +{ +} + +static inline void env_to_regs (void ) +{ +} + +static inline int cpu_halted (CPUState *env) +{ +if (!env->halted) { +return 0 ; + } +if (cpu_has_work (env)) { + env->halted =0 ; +return 0 ; + } +return EXCP_HALTED ; +}target-s390x/helper.c new file +36
-0@@ -0,0 +1,81 @@ +/* +* S/390 helpers +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "cpu.h" +#include "exec-all.h" +#include "gdbstub.h" +#include "qemu-common.h" + +CPUS390XState *cpu_s390x_init (const char *cpu_model) +{ +CPUS390XState *env; +static int inited =0 ; + + env =qemu_mallocz (sizeof (CPUS390XState)); +cpu_exec_init (env);
target-s390x/helper.c line 46
Quoted 10 lines
target-s390x/helper.c new file +10
-0+if (!inited) { + inited =1 ; +s390x_translate_init (); + } + + env->cpu_model_str = cpu_model; +cpu_reset (env); +qemu_init_vcpu (env); +return env; +}
This function would probably be better in translate.c, so that s390x_translate_init() can be declared static.
target-s390x/helper.c line 58
Quoted 11 lines
target-s390x/helper.c new file +11
-0+#if defined(CONFIG_USER_ONLY ) + +void do_interrupt (CPUState *env) +{ + env->exception_index =-1 ; +} + +int cpu_s390x_handle_mmu_fault (CPUState *env,target_ulong address,int rw, +int mmu_idx,int is_softmmu) +{ +//fprintf(stderr,"%s: address 0x%lx rw %d mmu_idx %d is_softmmu %d\n", __FUNCTION__, address, rw, mmu_idx, is_softmmu);
Please use /* */ for comments (See CODING_STYLE).
Quoted 13 lines
target-s390x/helper.c new file +13
-0+ env->exception_index =EXCP_ADDR ; + env->__excp_addr = address;/* FIXME: find out how this works on a real machine */ + return 1; +} + +target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr; +} + +#endif /* CONFIG_USER_ONLY */ + +void cpu_reset (CPUS390XState *env)
target-s390x/helper.c line 81
Quoted 10 lines
target-s390x/helper.c new file +10
-0+{ +if (qemu_loglevel_mask (CPU_LOG_RESET )) { +qemu_log ("CPU Reset (CPU %d)\n" , env->cpu_index); +log_cpu_state (env,0 ); + } + +memset (env,0 , offsetof(CPUS390XState , breakpoints)); +/* FIXME: reset vector? */ +tlb_flush (env,1 ); +}
Yes, reset vector, MMU mode, default register values, ...
Quoted 160 lines
target-s390x/helpers.h new file +128
-0@@ -0,0 +1,128 @@ +#include "def-helper.h" + +DEF_HELPER_1(exception, void, i32) +DEF_HELPER_4(nc, i32, i32, i32, i32, i32) +DEF_HELPER_4(oc, i32, i32, i32, i32, i32) +DEF_HELPER_4(xc, i32, i32, i32, i32, i32) +DEF_HELPER_4(mvc, void, i32, i32, i32, i32) +DEF_HELPER_4(clc, i32, i32, i32, i32, i32) +DEF_HELPER_4(lmg, void, i32, i32, i32, s32) +DEF_HELPER_4(stmg, void, i32, i32, i32, s32) +DEF_HELPER_FLAGS_1(set_cc_s32, TCG_CALL_PURE|TCG_CALL_CONST, i32, s32) +DEF_HELPER_FLAGS_1(set_cc_s64, TCG_CALL_PURE|TCG_CALL_CONST, i32, s64) +DEF_HELPER_FLAGS_1(set_cc_comp_s32, TCG_CALL_PURE|TCG_CALL_CONST, i32, s32) +DEF_HELPER_FLAGS_1(set_cc_comp_s64, TCG_CALL_PURE|TCG_CALL_CONST, i32, s64) +DEF_HELPER_FLAGS_1(set_cc_nz_u32, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32) +DEF_HELPER_FLAGS_1(set_cc_nz_u64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64) +DEF_HELPER_FLAGS_2(set_cc_icm, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32) +DEF_HELPER_4(brc, void, i32, i32, i64, s32) +DEF_HELPER_3(brctg, void, i64, i64, s32) +DEF_HELPER_3(brct, void, i32, i64, s32) +DEF_HELPER_4(brcl, void, i32, i32, i64, s64) +DEF_HELPER_4(bcr, void, i32, i32, i64, i64) +DEF_HELPER_4(bc, void, i32, i32, i64, i64) +DEF_HELPER_FLAGS_2(cmp_u64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64, i64) +DEF_HELPER_FLAGS_2(cmp_u32, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32) +DEF_HELPER_FLAGS_2(cmp_s32, TCG_CALL_PURE|TCG_CALL_CONST, i32, s32, s32) +DEF_HELPER_FLAGS_2(cmp_s64, TCG_CALL_PURE|TCG_CALL_CONST, i32, s64, s64) +DEF_HELPER_3(clm, i32, i32, i32, i64) +DEF_HELPER_3(stcm, void, i32, i32, i64) +DEF_HELPER_2(mlg, void, i32, i64) +DEF_HELPER_2(dlg, void, i32, i64) +DEF_HELPER_FLAGS_3(set_cc_add64, TCG_CALL_PURE|TCG_CALL_CONST, i32, s64, s64, s64) +DEF_HELPER_FLAGS_3(set_cc_addu64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64, i64, i64) +DEF_HELPER_FLAGS_3(set_cc_add32, TCG_CALL_PURE|TCG_CALL_CONST, i32, s32, s32, s32) +DEF_HELPER_FLAGS_3(set_cc_addu32, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32, i32) +DEF_HELPER_FLAGS_3(set_cc_sub64, TCG_CALL_PURE|TCG_CALL_CONST, i32, s64, s64, s64) +DEF_HELPER_FLAGS_3(set_cc_subu64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64, i64, i64) +DEF_HELPER_FLAGS_3(set_cc_sub32, TCG_CALL_PURE|TCG_CALL_CONST, i32, s32, s32, s32) +DEF_HELPER_FLAGS_3(set_cc_subu32, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32, i32) +DEF_HELPER_3(srst, i32, i32, i32, i32) +DEF_HELPER_3(clst, i32, i32, i32, i32) +DEF_HELPER_3(mvst, i32, i32, i32, i32) +DEF_HELPER_3(csg, i32, i32, i64, i32) +DEF_HELPER_3(cdsg, i32, i32, i64, i32) +DEF_HELPER_3(cs, i32, i32, i64, i32) +DEF_HELPER_4(ex, i32, i32, i64, i64, i64) +DEF_HELPER_FLAGS_2(tm, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32) +DEF_HELPER_FLAGS_2(tmxx, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64, i32) +DEF_HELPER_2(abs_i32, i32, i32, s32) +DEF_HELPER_2(nabs_i32, i32, i32, s32) +DEF_HELPER_2(abs_i64, i32, i32, s64) +DEF_HELPER_2(nabs_i64, i32, i32, s64) +DEF_HELPER_3(stcmh, i32, i32, i64, i32) +DEF_HELPER_3(icmh, i32, i32, i64, i32) +DEF_HELPER_2(ipm, void, i32, i32) +DEF_HELPER_3(addc_u32, i32, i32, i32, i32) +DEF_HELPER_FLAGS_3(set_cc_addc_u64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64, i64, i64) +DEF_HELPER_3(stam, void, i32, i64, i32) +DEF_HELPER_3(mvcle, i32, i32, i64, i32) +DEF_HELPER_3(clcle, i32, i32, i64, i32) +DEF_HELPER_4(slb, i32, i32, i32, i32, i32) +DEF_HELPER_4(slbg, i32, i32, i32, i64, i64) +DEF_HELPER_2(cefbr, void, i32, s32) +DEF_HELPER_2(cdfbr, void, i32, s32) +DEF_HELPER_2(cxfbr, void, i32, s32) +DEF_HELPER_2(cegbr, void, i32, s64) +DEF_HELPER_2(cdgbr, void, i32, s64) +DEF_HELPER_2(cxgbr, void, i32, s64) +DEF_HELPER_2(adbr, i32, i32, i32) +DEF_HELPER_2(aebr, i32, i32, i32) +DEF_HELPER_2(sebr, i32, i32, i32) +DEF_HELPER_2(sdbr, i32, i32, i32) +DEF_HELPER_2(debr, void, i32, i32) +DEF_HELPER_2(dxbr, void, i32, i32) +DEF_HELPER_2(mdbr, void, i32, i32) +DEF_HELPER_2(mxbr, void, i32, i32) +DEF_HELPER_2(ldebr, void, i32, i32) +DEF_HELPER_2(ldxbr, void, i32, i32) +DEF_HELPER_2(lxdbr, void, i32, i32) +DEF_HELPER_2(ledbr, void, i32, i32) +DEF_HELPER_2(lexbr, void, i32, i32) +DEF_HELPER_2(lpebr, i32, i32, i32) +DEF_HELPER_2(lpdbr, i32, i32, i32) +DEF_HELPER_2(lpxbr, i32, i32, i32) +DEF_HELPER_2(ltebr, i32, i32, i32) +DEF_HELPER_2(ltdbr, i32, i32, i32) +DEF_HELPER_2(ltxbr, i32, i32, i32) +DEF_HELPER_2(lcebr, i32, i32, i32) +DEF_HELPER_2(lcdbr, i32, i32, i32) +DEF_HELPER_2(lcxbr, i32, i32, i32) +DEF_HELPER_2(ceb, i32, i32, i64) +DEF_HELPER_2(aeb, i32, i32, i64) +DEF_HELPER_2(deb, void, i32, i64) +DEF_HELPER_2(meeb, void, i32, i64) +DEF_HELPER_2(cdb, i32, i32, i64) +DEF_HELPER_2(adb, i32, i32, i64) +DEF_HELPER_2(seb, i32, i32, i64) +DEF_HELPER_2(sdb, i32, i32, i64) +DEF_HELPER_2(mdb, void, i32, i64) +DEF_HELPER_2(ddb, void, i32, i64) +DEF_HELPER_FLAGS_2(cebr, TCG_CALL_PURE, i32, i32, i32) +DEF_HELPER_FLAGS_2(cdbr, TCG_CALL_PURE, i32, i32, i32) +DEF_HELPER_FLAGS_2(cxbr, TCG_CALL_PURE, i32, i32, i32) +DEF_HELPER_3(cgebr, i32, i32, i32, i32) +DEF_HELPER_3(cgdbr, i32, i32, i32, i32) +DEF_HELPER_3(cgxbr, i32, i32, i32, i32) +DEF_HELPER_1(lzer, void, i32) +DEF_HELPER_1(lzdr, void, i32) +DEF_HELPER_1(lzxr, void, i32) +DEF_HELPER_3(cfebr, i32, i32, i32, i32) +DEF_HELPER_3(cfdbr, i32, i32, i32, i32) +DEF_HELPER_3(cfxbr, i32, i32, i32, i32) +DEF_HELPER_2(axbr, i32, i32, i32) +DEF_HELPER_2(sxbr, i32, i32, i32) +DEF_HELPER_2(meebr, void, i32, i32) +DEF_HELPER_2(ddbr, void, i32, i32) +DEF_HELPER_3(madb, void, i32, i64, i32) +DEF_HELPER_3(maebr, void, i32, i32, i32) +DEF_HELPER_3(madbr, void, i32, i32, i32) +DEF_HELPER_3(msdbr, void, i32, i32, i32) +DEF_HELPER_2(lxdb, void, i32, i64) +DEF_HELPER_FLAGS_2(tceb, TCG_CALL_PURE, i32, i32, i64) +DEF_HELPER_FLAGS_2(tcdb, TCG_CALL_PURE, i32, i32, i64) +DEF_HELPER_FLAGS_2(tcxb, TCG_CALL_PURE, i32, i32, i64) +DEF_HELPER_2(flogr, i32, i32, i64) +DEF_HELPER_2(sqdbr, void, i32, i32) + +#include "def-helper.h" target-s390x/op_helper.c new file +20
-0@@ -0,0 +1,1719 @@ +/* +* S/390 helper routines +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ +
target-s390x/op_helper.c line 30
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+#include "exec.h" +#include "helpers.h" +#include <string.h> + +//#define DEBUG_HELPER +#ifdef DEBUG_HELPER +#define HELPER_LOG(x...) qemu_log(x) +#else +#define HELPER_LOG(x...) +#endif
Small comment for the rest of the file. While I understand HELPER_LOG is very handy while developing, I think some calls to it can be dropped in really simple functions. Keeping it in more complex function is not a problem though.
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+/* raise an exception */ +void HELPER (exception )(uint32_t excp) +{ +HELPER_LOG ("%s: exception %d\n" , __FUNCTION__, excp); + env->exception_index = excp; +cpu_loop_exit (); +} + +/* and on array */ +uint32_t HELPER (nc )(uint32_t l,uint32_t b,uint32_t d1,uint32_t d2)
target-s390x/op_helper.c line 51
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+{ +uint64_t dest = env->regs[b >>4 ] + d1; +uint64_t src = env->regs[b &0xf ] + d2; +int i; +unsigned char x; +uint32_t cc =0 ; +HELPER_LOG ("%s l %d b 0x%x d1 %d d2 %d\n" , __FUNCTION__, l, b, d1, d2); +for (i =0 ; i <= l; i++) { + x =ldub (dest + i) &ldub (src + i); +if (x) cc =1 ;
coding style
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+stb (dest + i, x); + } +return cc; +} + +/* xor on array */ +uint32_t HELPER (xc )(uint32_t l,uint32_t b,uint32_t d1,uint32_t d2)
target-s390x/op_helper.c line 68
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+{ +uint64_t dest = env->regs[b >>4 ] + d1; +uint64_t src = env->regs[b &0xf ] + d2; +int i; +unsigned char x; +uint32_t cc =0 ; +HELPER_LOG ("%s l %d b 0x%x d1 %d d2 %d\n" , __FUNCTION__, l, b, d1, d2); +for (i =0 ; i <= l; i++) { + x =ldub (dest + i) ^ldub (src + i); +if (x) cc =1 ;
coding style
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+stb (dest + i, x); + } +return cc; +} + +/* or on array */ +uint32_t HELPER (oc )(uint32_t l,uint32_t b,uint32_t d1,uint32_t d2)
target-s390x/op_helper.c line 85
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+{ +uint64_t dest = env->regs[b >>4 ] + d1; +uint64_t src = env->regs[b &0xf ] + d2; +int i; +unsigned char x; +uint32_t cc =0 ; +HELPER_LOG ("%s l %d b 0x%x d1 %d d2 %d\n" , __FUNCTION__, l, b, d1, d2); +for (i =0 ; i <= l; i++) { + x =ldub (dest + i) |ldub (src + i); +if (x) cc =1 ;
coding style
Quoted 25 lines
target-s390x/op_helper.c new file +25
-0+stb (dest + i, x); + } +return cc; +} + +/* memcopy */ +void HELPER (mvc )(uint32_t l,uint32_t b,uint32_t d1,uint32_t d2) +{ +uint64_t dest = env->regs[b >>4 ] + d1; +uint64_t src = env->regs[b &0xf ] + d2; +int i; +HELPER_LOG ("%s l %d b 0x%x d1 %d d2 %d\n" , __FUNCTION__, l, b, d1, d2); +for (i =0 ; i <= l; i++) { +stb (dest + i,ldub (src + i)); + } +} + +/* compare unsigned byte arrays */ +uint32_t HELPER (clc )(uint32_t l,uint32_t b,uint32_t d1,uint32_t d2) +{ +uint64_t s1 = env->regs[b >>4 ] + d1; +uint64_t s2 = env->regs[b &0xf ] + d2; +int i; +unsigned char x,y; +uint32_t cc;
target-s390x/op_helper.c line 120
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+HELPER_LOG ("%s l %d b 0x%x d1 %d d2 %d\n" , __FUNCTION__, l, b, d1, d2); +for (i =0 ; i <= l; i++) { + x =ldub (s1 + i); + y =ldub (s2 + i); +HELPER_LOG ("%02x (%c)/%02x (%c) " , x, x, y, y); +if (x < y) { + cc =1 ; + goto done; + } +else if (x > y) {
coding style
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+ cc =2 ; + goto done; + } + } + cc =0 ; +done: +HELPER_LOG ("\n" ); +return cc;
target-s390x/op_helper.c line 138
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+} + +/* load multiple 64-bit registers from memory */ +void HELPER (lmg )(uint32_t r1,uint32_t r3,uint32_t b2,int d2) +{ +uint64_t src = env->regs[b2] + d2; +for (;;) { + env->regs[r1] =ldq (src); + src +=8 ; +if (r1 == r3)break ;
coding style
Quoted 4 lines
target-s390x/op_helper.c new file +4
-0+ r1 = (r1 +1 ) &15 ; + } +} +
target-s390x/op_helper.c line 152
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+/* store multiple 64-bit registers to memory */ +void HELPER (stmg )(uint32_t r1,uint32_t r3,uint32_t b2,int d2) +{ +uint64_t dest = env->regs[b2] + d2; +HELPER_LOG ("%s: r1 %d r3 %d\n" , __FUNCTION__, r1, r3); +for (;;) { +HELPER_LOG ("storing r%d in 0x%lx\n" , r1, dest); +stq (dest, env->regs[r1]); + dest +=8 ; +if (r1 == r3)break ;
coding style
target-s390x/op_helper.c line 161
Quoted 9 lines
target-s390x/op_helper.c new file +9
-0+ r1 = (r1 +1 ) &15 ; + } +} + +/* set condition code for signed 32-bit arithmetics */ +uint32_t HELPER (set_cc_s32 )(int32_t v) +{ +if (v <0 )return 1 ; +else if (v >0 )return 2 ;
coding style
target-s390x/op_helper.c line 169
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+else return 0 ; +} + +/* set condition code for signed 64-bit arithmetics */ +uint32_t HELPER (set_cc_s64 )(int64_t v) +{ +if (v <0 )return 1 ; +else if (v >0 )return 2 ;
coding style
target-s390x/op_helper.c line 179
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+else return 0 ; +} + +/* set condition code for signed 32-bit two's complement */ +uint32_t HELPER (set_cc_comp_s32 )(int32_t v) +{ +if ((uint32_t )v ==0x80000000UL )return 3 ; +else if (v <0 )return 1 ; +else if (v >0 )return 2 ; +else return 0 ;
coding style
target-s390x/op_helper.c line 188
Quoted 9 lines
target-s390x/op_helper.c new file +9
-0+} + +/* set condition code for signed 64-bit two's complement */ +uint32_t HELPER (set_cc_comp_s64 )(int64_t v) +{ +if ((uint64_t )v ==0x8000000000000000ULL )return 3 ; +else if (v <0 )return 1 ; +else if (v >0 )return 2 ; +else return 0 ;
coding style
target-s390x/op_helper.c line 195
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+} + +/* set negative/zero condition code for 32-bit logical op */ +uint32_t HELPER (set_cc_nz_u32 )(uint32_t v) +{ +if (v)return 1 ; +else return 0 ;
coding style
target-s390x/op_helper.c line 202
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+} + +/* set negative/zero condition code for 64-bit logical op */ +uint32_t HELPER (set_cc_nz_u64 )(uint64_t v) +{ +if (v)return 1 ; +else return 0 ;
coding style
target-s390x/op_helper.c line 202
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+}
The last 6 helpers can probably be coded easily in TCG (they are very similar to some PowerPC code), though merging this patch with the helpers is not a problem at all.
Quoted 5 lines
target-s390x/op_helper.c new file +5
-0+/* set condition code for insert character under mask insn */ +uint32_t HELPER (set_cc_icm )(uint32_t mask,uint32_t val) +{ +HELPER_LOG ("%s: mask 0x%x val %d\n" , __FUNCTION__, mask, val); +uint32_t cc;
target-s390x/op_helper.c line 219
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+if (!val || !mask) cc =0 ; +else { +while (mask !=1 ) { + mask >>=1 ; + val >>=8 ; + } +if (val &0x80 ) cc =1 ; +else cc =2 ; + } +return cc;
coding style
Quoted 66 lines
target-s390x/op_helper.c new file +66
-0+} + +/* relative conditional branch */ +void HELPER (brc )(uint32_t cc,uint32_t mask,uint64_t pc,int32_t offset) +{ +if ( mask & (1 << (3 - cc) ) ) { + env->psw.addr = pc + offset; + } +else { + env->psw.addr = pc +4 ; + } +} + +/* branch relative on 64-bit count (condition is computed inline, this only +does the branch */ +void HELPER (brctg )(uint64_t flag,uint64_t pc,int32_t offset) +{ +if (flag) { + env->psw.addr = pc + offset; + } +else { + env->psw.addr = pc +4 ; + } +HELPER_LOG ("%s: pc 0x%lx flag %ld psw.addr 0x%lx\n" , __FUNCTION__, pc, flag, + env->psw.addr); +} + +/* branch relative on 32-bit count (condition is computed inline, this only +does the branch */ +void HELPER (brct )(uint32_t flag,uint64_t pc,int32_t offset) +{ +if (flag) { + env->psw.addr = pc + offset; + } +else { + env->psw.addr = pc +4 ; + } +HELPER_LOG ("%s: pc 0x%lx flag %d psw.addr 0x%lx\n" , __FUNCTION__, pc, flag, + env->psw.addr); +} + +/* relative conditional branch with long displacement */ +void HELPER (brcl )(uint32_t cc,uint32_t mask,uint64_t pc,int64_t offset) +{ +if ( mask & (1 << (3 - cc) ) ) { + env->psw.addr = pc + offset; + } +else { + env->psw.addr = pc +6 ; + } +HELPER_LOG ("%s: pc 0x%lx psw.addr 0x%lx\n" , __FUNCTION__, pc, env->psw.addr); +} + +/* conditional branch to register (register content is passed as target) */ +void HELPER (bcr )(uint32_t cc,uint32_t mask,uint64_t target,uint64_t pc) +{ +if ( mask & (1 << (3 - cc) ) ) { + env->psw.addr = target; + } +else { + env->psw.addr = pc +2 ; + } +} + +/* conditional branch to address (address is passed as target) */ +void HELPER (bc )(uint32_t cc,uint32_t mask,uint64_t target,uint64_t pc)
target-s390x/op_helper.c line 295
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+{ +if ( mask & (1 << (3 - cc) ) ) { + env->psw.addr = target; + } +else { + env->psw.addr = pc +4 ; + } +HELPER_LOG ("%s: pc 0x%lx psw.addr 0x%lx r2 0x%lx r5 0x%lx\n" , __FUNCTION__, + pc, env->psw.addr, env->regs[2 ], env->regs[5 ]); +}
All the branch part would really gain to be coded in TCG, as it will allow TB chaining.
target-s390x/op_helper.c line 302
Quoted 6 lines
target-s390x/op_helper.c new file +6
-0+/* 64-bit unsigned comparison */ +uint32_t HELPER (cmp_u64 )(uint64_t o1,uint64_t o2) +{ +if (o1 < o2)return 1 ; +else if (o1 > o2)return 2 ; +else return 0 ;
coding style
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+} + +/* 32-bit unsigned comparison */ +uint32_t HELPER (cmp_u32 )(uint32_t o1,uint32_t o2) +{ +HELPER_LOG ("%s: o1 0x%x o2 0x%x\n" , __FUNCTION__, o1, o2); +if (o1 < o2)return 1 ; +else if (o1 > o2)return 2 ;
target-s390x/op_helper.c line 320
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+else return 0 ; +} + +/* 64-bit signed comparison */ +uint32_t HELPER (cmp_s64 )(int64_t o1,int64_t o2) +{ +HELPER_LOG ("%s: o1 %ld o2 %ld\n" , __FUNCTION__, o1, o2); +if (o1 < o2)return 1 ; +else if (o1 > o2)return 2 ; +else return 0 ;
coding style
target-s390x/op_helper.c line 328
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+} + +/* 32-bit signed comparison */ +uint32_t HELPER (cmp_s32 )(int32_t o1,int32_t o2) +{ +if (o1 < o2)return 1 ; +else if (o1 > o2)return 2 ; +else return 0 ;
coding style
target-s390x/op_helper.c line 326
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+}
Same remarks as for previous comparisons, this can be done in TCG.
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+/* compare logical under mask */ +uint32_t HELPER (clm )(uint32_t r1,uint32_t mask,uint64_t addr) +{ +uint8_t r,d; +uint32_t cc; +HELPER_LOG ("%s: r1 0x%x mask 0x%x addr 0x%lx\n" ,__FUNCTION__,r1,mask,addr); + cc =0 ;
target-s390x/op_helper.c line 347
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+while (mask) { +if (mask &8 ) { + d =ldub (addr); + r = (r1 &0xff000000UL ) >>24 ; +HELPER_LOG ("mask 0x%x %02x/%02x (0x%lx) " , mask, r, d, addr); +if (r < d) { + cc =1 ; +break ; + } +else if (r > d) {
coding style
Quoted 28 lines
target-s390x/op_helper.c new file +28
-0+ cc =2 ; +break ; + } + addr++; + } + mask = (mask <<1 ) &0xf ; + r1 <<=8 ; + } +HELPER_LOG ("\n" ); +return cc; +} + +/* store character under mask */ +void HELPER (stcm )(uint32_t r1,uint32_t mask,uint64_t addr) +{ +uint8_t r; +HELPER_LOG ("%s: r1 0x%x mask 0x%x addr 0x%lx\n" ,__FUNCTION__,r1,mask,addr); +while (mask) { +if (mask &8 ) { + r = (r1 &0xff000000UL ) >>24 ; +stb (addr, r); +HELPER_LOG ("mask 0x%x %02x (0x%lx) " , mask, r, addr); + addr++; + } + mask = (mask <<1 ) &0xf ; + r1 <<=8 ; + } +HELPER_LOG ("\n" );
target-s390x/op_helper.c line 385
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+} + +/* 64/64 -> 128 unsigned multiplication */ +void HELPER (mlg )(uint32_t r1,uint64_t v2) +{ +__uint128_t res = (__uint128_t )env->regs[r1 +1 ]; + res *= (__uint128_t )v2; + env->regs[r1] = (uint64_t )(res >>64 ); + env->regs[r1 +1 ] = (uint64_t )res; +}
__uint128_t is probably not supported on all hosts/GCC versions. mulu64() should be used instead.
Quoted 4 lines
target-s390x/op_helper.c new file +4
-0+/* 128 -> 64/64 unsigned division */ +void HELPER (dlg )(uint32_t r1,uint64_t v2) +{ + __uint128_t dividend = (((__uint128_t)env->regs[r1]) << 64) |
target-s390x/op_helper.c line 400
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+ (env->regs[r1+1 ]); +uint64_t divisor = v2; +__uint128_t quotient = dividend / divisor; + env->regs[r1+1 ] = quotient; +__uint128_t remainder = dividend % divisor; + env->regs[r1] = remainder; +HELPER_LOG ("%s: dividend 0x%016lx%016lx divisor 0x%lx quotient 0x%lx rem 0x%lx\n" , + __FUNCTION__, (uint64_t )(dividend >>64 ), (uint64_t )dividend, divisor, (uint64_t )quotient, + (uint64_t )remainder); +}
Same here, __uint128_t should not be used, though I don't know what should be used instead.
target-s390x/op_helper.c line 412
Quoted 11 lines
target-s390x/op_helper.c new file +11
-0+/* set condition code for 64-bit signed addition */ +uint32_t HELPER (set_cc_add64 )(int64_t a1,int64_t a2,int64_t ar) +{ +if ((a1 >0 && a2 >0 && ar <0 ) || (a1 <0 && a2 <0 && ar >0 )) { +return 3 ;/* overflow */ + } +else { +if (ar <0 )return 1 ; +else if (ar >0 )return 2 ; +else return 0 ; + }
coding style
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+} + +/* set condition code for 64-bit unsigned addition */ +uint32_t HELPER (set_cc_addu64 )(uint64_t a1,uint64_t a2,uint64_t ar) +{ +if (ar ==0 ) { +if (a1)return 2 ;
target-s390x/op_helper.c line 429
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+else return 0 ; + } +else { +if (ar < a1 || ar < a2) { +return 3 ; + } +else { +return 1 ; + } + }
coding style
target-s390x/op_helper.c line 438
Quoted 9 lines
target-s390x/op_helper.c new file +9
-0+} + +/* set condition code for 32-bit signed addition */ +uint32_t HELPER (set_cc_add32 )(int32_t a1,int32_t a2,int32_t ar) +{ +if ((a1 >0 && a2 >0 && ar <0 ) || (a1 <0 && a2 <0 && ar >0 )) { +return 3 ;/* overflow */ + } +else {
coding style
Quoted 4 lines
target-s390x/op_helper.c new file +4
-0+if (ar <0 )return 1 ; +else if (ar >0 )return 2 ; +else return 0 ; + }
target-s390x/op_helper.c line 452
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+} + +/* set condition code for 32-bit unsigned addition */ +uint32_t HELPER (set_cc_addu32 )(uint32_t a1,uint32_t a2,uint32_t ar) +{ +if (ar ==0 ) { +if (a1)return 2 ; +else return 0 ; + } +else {
coding style
Quoted 6 lines
target-s390x/op_helper.c new file +6
-0+if (ar < a1 || ar < a2) { +return 3 ; + } +else { +return 1 ; + }
target-s390x/op_helper.c line 468
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+ } +} + +/* set condition code for 64-bit signed subtraction */ +uint32_t HELPER (set_cc_sub64 )(int64_t s1,int64_t s2,int64_t sr) +{ +if ((s1 >0 && s2 <0 && sr <0 ) || (s1 <0 && s2 >0 && sr >0 )) { +return 3 ;/* overflow */ + } +else {
coding style
Quoted 14 lines
target-s390x/op_helper.c new file +14
-0+if (sr <0 )return 1 ; +else if (sr >0 )return 2 ; +else return 0 ; + } +} + +/* set condition code for 32-bit signed subtraction */ +uint32_t HELPER (set_cc_sub32 )(int32_t s1,int32_t s2,int32_t sr) +{ +if ((s1 >0 && s2 <0 && sr <0 ) || (s1 <0 && s2 >0 && sr >0 )) { +return 3 ;/* overflow */ + } +else { +if (sr <0 )return 1 ;
target-s390x/op_helper.c line 492
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+else if (sr >0 )return 2 ; +else return 0 ; + } +} + +/* set condition code for 32-bit unsigned subtraction */ +uint32_t HELPER (set_cc_subu32 )(uint32_t s1,uint32_t s2,uint32_t sr) +{ +if (sr ==0 )return 2 ; +else {
coding style
target-s390x/op_helper.c line 502
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+if (s2 > s1)return 1 ; +else return 3 ; + } +} + +/* set condition code for 64-bit unsigned subtraction */ +uint32_t HELPER (set_cc_subu64 )(uint64_t s1,uint64_t s2,uint64_t sr) +{ +if (sr ==0 )return 2 ; +else {
coding style
Quoted 27 lines
target-s390x/op_helper.c new file +27
-0+if (s2 > s1)return 1 ; +else return 3 ; + } +} + +/* search string (c is byte to search, r2 is string, r1 end of string) */ +uint32_t HELPER (srst )(uint32_t c,uint32_t r1,uint32_t r2) +{ +HELPER_LOG ("%s: c %d *r1 0x%lx *r2 0x%lx\n" , __FUNCTION__, c, env->regs[r1], + env->regs[r2]); +uint64_t i; +uint32_t cc; +for (i = env->regs[r2]; i != env->regs[r1]; i++) { +if (ldub (i) == c) { + env->regs[r1] = i; + cc =1 ; +return cc; + } + } + cc =2 ; +return cc; +} + +/* unsigned string compare (c is string terminator) */ +uint32_t HELPER (clst )(uint32_t c,uint32_t r1,uint32_t r2) +{ +uint64_t s1 = env->regs[r1];
target-s390x/op_helper.c line 539
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+uint64_t s2 = env->regs[r2]; +uint8_t v1, v2; +uint32_t cc; + c = c &0xff ; +#ifdef CONFIG_USER_ONLY +if (!c) { +HELPER_LOG ("%s: comparing '%s' and '%s'\n" , + __FUNCTION__, (char *)s1, (char *)s2); + } +#endif
Why CONFIG_USER_ONLY ?
target-s390x/op_helper.c line 546
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+for (;;) { + v1 =ldub (s1); + v2 =ldub (s2); +if (v1 == c || v2 == c)break ; +if (v1 != v2)break ; + s1++; s2++; + }
coding style
Quoted 13 lines
target-s390x/op_helper.c new file +13
-0+ +if (v1 == v2) cc =0 ; +else { +if (v1 < v2) cc =1 ; +else cc =2 ; + env->regs[r1] = s1; + env->regs[r2] = s2; + } +return cc; +} + +/* string copy (c is string terminator) */ +uint32_t HELPER (mvst )(uint32_t c,uint32_t r1,uint32_t r2)
target-s390x/op_helper.c line 569
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+{ +uint64_t dest = env->regs[r1]; +uint64_t src = env->regs[r2]; +uint8_t v; + c = c &0xff ; +#ifdef CONFIG_USER_ONLY +if (!c) { +HELPER_LOG ("%s: copying '%s' to 0x%lx\n" , __FUNCTION__, (char *)src, dest); + } +#endif
Same.
target-s390x/op_helper.c line 573
Quoted 4 lines
target-s390x/op_helper.c new file +4
-0+for (;;) { + v =ldub (src); +stb (dest, v); +if (v == c)break ;
coding style
Quoted 11 lines
target-s390x/op_helper.c new file +11
-0+ src++; dest++; + } + env->regs[r1] = dest; +return 1 ; +} + +/* compare and swap 64-bit */ +uint32_t HELPER (csg )(uint32_t r1,uint64_t a2,uint32_t r3) +{ +/* FIXME: locking? */ +uint32_t cc;
target-s390x/op_helper.c line 594
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+uint64_t v2 =ldq (a2); +if (env->regs[r1] == v2) { + cc =0 ; +stq (a2, env->regs[r3]); + } +else { + cc =1 ; + env->regs[r1] = v2; + } +return cc;
coding style
Quoted 5 lines
target-s390x/op_helper.c new file +5
-0+} + +/* compare double and swap 64-bit */ +uint32_t HELPER (cdsg )(uint32_t r1,uint64_t a2,uint32_t r3) +{
target-s390x/op_helper.c line 609
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+/* FIXME: locking? */ +uint32_t cc; +__uint128_t v2 = (((__uint128_t )ldq (a2)) <<64 ) | (__uint128_t )ldq (a2 +8 ); +__uint128_t v1 = (((__uint128_t )env->regs[r1]) <<64 ) | (__uint128_t )env->regs[r1 +1 ]; +if (v1 == v2) { + cc =0 ; +stq (a2, env->regs[r3]); +stq (a2 +8 , env->regs[r3 +1 ]); + } +else {
coding style
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+ cc =1 ; + env->regs[r1] = v2 >>64 ; + env->regs[r1 +1 ] = v2 &0xffffffffffffffffULL ; + } +return cc; +} + +/* compare and swap 32-bit */
target-s390x/op_helper.c line 627
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+uint32_t HELPER (cs )(uint32_t r1,uint64_t a2,uint32_t r3) +{ +/* FIXME: locking? */ +uint32_t cc; +HELPER_LOG ("%s: r1 %d a2 0x%lx r3 %d\n" , __FUNCTION__, r1, a2, r3); +uint32_t v2 =ldl (a2); +if (((uint32_t )env->regs[r1]) == v2) { + cc =0 ; +stl (a2, (uint32_t )env->regs[r3]); + }
coding style
Quoted 33 lines
target-s390x/op_helper.c new file +33
-0+else { + cc =1 ; + env->regs[r1] = (env->regs[r1] &0xffffffff00000000ULL ) | v2; + } +return cc; +} + +/* execute instruction +this instruction executes an insn modified with the contents of r1 +it does not change the executed instruction in memory +it does not change the program counter +in other words: tricky... +currently implemented by interpreting the cases it is most commonly used in +*/ +uint32_t HELPER (ex )(uint32_t cc,uint64_t v1,uint64_t addr,uint64_t ret) +{ +uint16_t insn =lduw (addr); +HELPER_LOG ("%s: v1 0x%lx addr 0x%lx insn 0x%x\n" , __FUNCTION__, v1, addr, + insn); +if ((insn &0xf0ff ) ==0xd000 ) { +uint32_t l, insn2, b, d1, d2; + l = v1 &0xff ; + insn2 =ldl (addr +2 ); + b = (((insn2 >>28 ) &0xf ) <<4 ) | ((insn2 >>12 ) &0xf ); + d1 = (insn2 >>16 ) &0xfff ; + d2 = insn2 &0xfff ; +switch (insn &0xf00 ) { +case 0x200 :helper_mvc (l, b, d1, d2);return cc;break ; +case 0x500 :return helper_clc (l, b, d1, d2);break ; +case 0x700 :return helper_xc (l, b, d1, d2);break ; +default :helper_exception (23 );break ; + } + }
target-s390x/op_helper.c line 670
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+else if ((insn &0xff00 ) ==0x0a00 ) {/* supervisor call */ +HELPER_LOG ("%s: svc %ld via execute\n" , __FUNCTION__, (insn|v1) &0xff ); + env->psw.addr = ret; +helper_exception (EXCP_EXECUTE_SVC + ((insn | v1) &0xff )); + } +else { +helper_exception (23 ); + } +return cc; +}
Looks a bit ugly, but currently do not have anything else to offer.
target-s390x/op_helper.c line 679
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+/* set condition code for test under mask */ +uint32_t HELPER (tm )(uint32_t val,uint32_t mask) +{ +HELPER_LOG ("%s: val 0x%x mask 0x%x\n" , __FUNCTION__, val, mask); +uint16_t r = val & mask; +if (r ==0 )return 0 ; +else if (r == mask)return 3 ; +else return 1 ;
coding style
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+} + +/* set condition code for test under mask */ +uint32_t HELPER (tmxx )(uint64_t val,uint32_t mask) +{ +uint16_t r = val & mask; +HELPER_LOG ("%s: val 0x%lx mask 0x%x r 0x%x\n" , __FUNCTION__, val, mask, r);
target-s390x/op_helper.c line 696
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+if (r ==0 )return 0 ; +else if (r == mask)return 3 ; +else { +while (!(mask &0x8000 )) { + mask <<=1 ; + val <<=1 ; + } +if (val &0x8000 )return 2 ; +else return 1 ; + }
coding style
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+} + +/* absolute value 32-bit */ +uint32_t HELPER (abs_i32 )(uint32_t reg,int32_t val) +{ +uint32_t cc; +if (val ==0x80000000UL ) cc =3 ;
target-s390x/op_helper.c line 713
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+else if (val) cc =1 ; +else cc =0 ; + +if (val <0 ) { + env->regs[reg] = -val; + } +else { + env->regs[reg] = val; + } +return cc;
coding style
Quoted 6 lines
target-s390x/op_helper.c new file +6
-0+} + +/* negative absolute value 32-bit */ +uint32_t HELPER (nabs_i32 )(uint32_t reg,int32_t val) +{ +uint32_t cc;
target-s390x/op_helper.c line 729
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+if (val) cc =1 ; +else cc =0 ; + +if (val <0 ) { + env->regs[reg] = (env->regs[reg] &0xffffffff00000000ULL ) | val; + } +else { + env->regs[reg] = (env->regs[reg] &0xffffffff00000000ULL ) | ((uint32_t )-val); + } +return cc;
coding style
Quoted 23 lines
target-s390x/op_helper.c new file +23
-0+} + +/* absolute value 64-bit */ +uint32_t HELPER (abs_i64 )(uint32_t reg,int64_t val) +{ +uint32_t cc; +if (val ==0x8000000000000000ULL ) cc =3 ; +else if (val) cc =1 ; +else cc =0 ; + +if (val <0 ) { + env->regs[reg] = -val; + } +else { + env->regs[reg] = val; + } +return cc; +} + +/* negative absolute value 64-bit */ +uint32_t HELPER (nabs_i64 )(uint32_t reg,int64_t val) +{ +uint32_t cc;
target-s390x/op_helper.c line 762
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+if (val) cc =1 ; +else cc =0 ; + +if (val <0 ) { + env->regs[reg] = val; + } +else { + env->regs[reg] = -val; + } +return cc;
coding style
Quoted 12 lines
target-s390x/op_helper.c new file +12
-0+} + +/* add with carry 32-bit unsigned */ +uint32_t HELPER (addc_u32 )(uint32_t cc,uint32_t r1,uint32_t v2) +{ +uint32_t res; +uint32_t v1 = env->regs[r1] &0xffffffffUL ; + res = v1 + v2; +if (cc &2 ) res++; + +if (res ==0 ) { +if (v1) cc =2 ;
target-s390x/op_helper.c line 784
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+else cc =0 ; + } +else { +if (res < v1 || res < v2) + cc =3 ; +else + cc =1 ; + } + env->regs[r1] = (env->regs[r1] &0xffffffff00000000ULL ) | res; +return cc;
coding style
Quoted 55 lines
target-s390x/op_helper.c new file +55
-0+} + +/* CC for add with carry 64-bit unsigned (isn't this a duplicate of some other CC function?) */ +uint32_t HELPER (set_cc_addc_u64 )(uint64_t v1,uint64_t v2,uint64_t res) +{ +uint32_t cc; +if (res ==0 ) { +if (v1) cc =2 ; +else cc =0 ; + } +else { +if (res < v1 || res < v2) { + cc =3 ; + } +else { + cc =1 ; + } + } +return cc; +} + +/* store character under mask high +operates on the upper half of r1 */ +uint32_t HELPER (stcmh )(uint32_t r1,uint64_t address,uint32_t mask) +{ +int pos =56 ;/* top of the upper half of r1 */ + +while (mask) { +if (mask &8 ) { +stb (address, (env->regs[r1] >> pos) &0xff ); + address++; + } + mask = (mask <<1 ) &0xf ; + pos -=8 ; + } +return 0 ; +} + +/* insert character under mask high +same as icm, but operates on the upper half of r1 */ +uint32_t HELPER (icmh )(uint32_t r1,uint64_t address,uint32_t mask) +{ +int pos =56 ;/* top of the upper half of r1 */ +uint64_t rmask =0xff00000000000000ULL ; +uint8_t val =0 ; +int ccd =0 ; +uint32_t cc; + + cc =0 ; + +while (mask) { +if (mask &8 ) { + env->regs[r1] &= ~rmask; + val =ldub (address); +if ((val &0x80 ) && !ccd) cc =1 ;
target-s390x/op_helper.c line 849
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+ ccd =1 ; +if (val && cc ==0 ) cc =2 ; + env->regs[r1] |= (uint64_t )val << pos; + address++; + } + mask = (mask <<1 ) &0xf ; + pos -=8 ; + rmask >>=8 ; + } +return cc;
coding style
Quoted 27 lines
target-s390x/op_helper.c new file +27
-0+} + +/* insert psw mask and condition code into r1 */ +void HELPER (ipm )(uint32_t cc,uint32_t r1) +{ +uint64_t r = env->regs[r1]; + r &=0xffffffff00ffffffULL ; + r |= (cc <<28 ) | ( (env->psw.mask >>40 ) &0xf ); + env->regs[r1] = r; +HELPER_LOG ("%s: cc %d psw.mask 0x%lx r1 0x%lx\n" , __FUNCTION__, cc, env->psw.mask, r); +} + +/* store access registers r1 to r3 in memory at a2 */ +void HELPER (stam )(uint32_t r1,uint64_t a2,uint32_t r3) +{ +int i; +for (i = r1; i != ((r3 +1 ) &15 ); i = (i +1 ) &15 ) { +stl (a2, env->aregs[i]); + a2 +=4 ; + } +} + +/* move long extended +another memcopy insn with more bells and whistles */ +uint32_t HELPER (mvcle )(uint32_t r1,uint64_t a2,uint32_t r3) +{ +uint64_t destlen = env->regs[r1 +1 ];
target-s390x/op_helper.c line 886
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+uint64_t dest = env->regs[r1]; +uint64_t srclen = env->regs[r3 +1 ]; +uint64_t src = env->regs[r3]; +uint8_t pad = a2 &0xff ; +uint8_t v; +uint32_t cc; +if (destlen == srclen) cc =0 ; +else if (destlen < srclen) cc =1 ; +else cc =2 ; +if (srclen > destlen) srclen = destlen;
coding style
Quoted 37 lines
target-s390x/op_helper.c new file +37
-0+for (;destlen && srclen;src++,dest++,destlen--,srclen--) { + v =ldub (src); +stb (dest, v); + } +for (;destlen;dest++,destlen--) { +stb (dest, pad); + } + env->regs[r1 +1 ] = destlen; + env->regs[r3 +1 ] -= src - env->regs[r3];/* can't use srclen here, +we trunc'ed it */ + env->regs[r1] = dest; + env->regs[r3] = src; + +return cc; +} + +/* compare logical long extended +memcompare insn with padding */ +uint32_t HELPER (clcle )(uint32_t r1,uint64_t a2,uint32_t r3) +{ +uint64_t destlen = env->regs[r1 +1 ]; +uint64_t dest = env->regs[r1]; +uint64_t srclen = env->regs[r3 +1 ]; +uint64_t src = env->regs[r3]; +uint8_t pad = a2 &0xff ; +uint8_t v1 =0 ,v2 =0 ; +uint32_t cc =0 ; +if (!(destlen || srclen))return cc; +if (srclen > destlen) srclen = destlen; +for (;destlen || srclen;src++,dest++,destlen--,srclen--) { +if (srclen) v1 =ldub (src); +else v1 = pad; +if (destlen) v2 =ldub (dest); +else v2 = pad; +if (v1 != v2)break ; + } +
target-s390x/op_helper.c line 933
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+ env->regs[r1 +1 ] = destlen; + env->regs[r3 +1 ] -= src - env->regs[r3];/* can't use srclen here, +we trunc'ed it */ + env->regs[r1] = dest; + env->regs[r3] = src; + +if (v1 < v2) cc =1 ; +else if (v1 > v2) cc =2 ; + +return cc;
coding style
Quoted 5 lines
target-s390x/op_helper.c new file +5
-0+} + +/* subtract unsigned v2 from v1 with borrow */ +uint32_t HELPER (slb )(uint32_t cc,uint32_t r1,uint32_t v1,uint32_t v2) +{
target-s390x/op_helper.c line 948
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+uint32_t res = v1 + (~v2) + (cc >>1 ); + env->regs[r1] = (env->regs[r1] &0xffffffff00000000ULL ) | res; +if (cc &2 ) {/* borrow */ +if (v1)return 1 ; +else return 0 ; + } +else { +if (v1)return 3 ; +else return 2 ; + }
coding style
Quoted 5 lines
target-s390x/op_helper.c new file +5
-0+} + +/* subtract unsigned v2 from v1 with borrow */ +uint32_t HELPER (slbg )(uint32_t cc,uint32_t r1,uint64_t v1,uint64_t v2) +{
target-s390x/op_helper.c line 963
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+uint64_t res = v1 + (~v2) + (cc >>1 ); + env->regs[r1] = res; +if (cc &2 ) {/* borrow */ +if (v1)return 1 ; +else return 0 ; + } +else { +if (v1)return 3 ; +else return 2 ; + }
coding style
Quoted 5 lines
target-s390x/op_helper.c new file +5
-0+} + +/* union used for splitting/joining 128-bit floats to/from 64-bit FP regs */ +typedef union { + struct {
target-s390x/op_helper.c line 978
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+#ifdef WORDS_BIGENDIAN +uint64_t h; +uint64_t l; +#else +uint64_t l; +uint64_t h; +#endif + }; +float128 x; +}FP128 ;
WORDS_BIGENDIAN is wrong here. CPU_QuadU can probably be used instead.
target-s390x/op_helper.c line 986
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+/* condition codes for binary FP ops */ +static uint32_t set_cc_f32 (float32 v1,float32 v2) +{ +if (float32_is_nan (v1) ||float32_is_nan (v2))return 3 ; +else if (float32_eq (v1, v2, &env->fpu_status))return 0 ; +else if (float32_lt (v1, v2, &env->fpu_status))return 1 ; +else return 2 ;
coding style
target-s390x/op_helper.c line 994
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+} + +static uint32_t set_cc_f64 (float64 v1,float64 v2) +{ +if (float64_is_nan (v1) ||float64_is_nan (v2))return 3 ; +else if (float64_eq (v1, v2, &env->fpu_status))return 0 ; +else if (float64_lt (v1, v2, &env->fpu_status))return 1 ; +else return 2 ;
coding style
target-s390x/op_helper.c line 1003
Quoted 9 lines
target-s390x/op_helper.c new file +9
-0+} + +/* condition codes for unary FP ops */ +static uint32_t set_cc_nz_f32 (float32 v) +{ +if (float32_is_nan (v))return 3 ; +else if (float32_is_zero (v))return 0 ; +else if (float32_is_neg (v))return 1 ; +else return 2 ;
coding style
target-s390x/op_helper.c line 1011
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+} + +static uint32_t set_cc_nz_f64 (float64 v) +{ +if (float64_is_nan (v))return 3 ; +else if (float64_is_zero (v))return 0 ; +else if (float64_is_neg (v))return 1 ; +else return 2 ;
coding style
target-s390x/op_helper.c line 1019
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+} + +static uint32_t set_cc_nz_f128 (float128 v) +{ +if (float128_is_nan (v))return 3 ; +else if (float128_is_zero (v))return 0 ; +else if (float128_is_neg (v))return 1 ; +else return 2 ;
coding style
Quoted 169 lines
target-s390x/op_helper.c new file +169
-0+} + +/* convert 32-bit int to 64-bit float */ +void HELPER (cdfbr )(uint32_t f1,int32_t v2) +{ +HELPER_LOG ("%s: converting %d to f%d\n" , __FUNCTION__, v2, f1); + env->fregs[f1].d =int32_to_float64 (v2, &env->fpu_status); +} + +/* convert 32-bit int to 128-bit float */ +void HELPER (cxfbr )(uint32_t f1,int32_t v2) +{ +FP128 v1; + v1.x =int32_to_float128 (v2, &env->fpu_status); + env->fregs[f1].i = v1.h; + env->fregs[f1 +2 ].i = v1.l; +} + +/* convert 64-bit int to 32-bit float */ +void HELPER (cegbr )(uint32_t f1,int64_t v2) +{ +HELPER_LOG ("%s: converting %ld to f%d\n" , __FUNCTION__, v2, f1); + env->fregs[f1].e =int64_to_float32 (v2, &env->fpu_status); +} + +/* convert 64-bit int to 64-bit float */ +void HELPER (cdgbr )(uint32_t f1,int64_t v2) +{ +HELPER_LOG ("%s: converting %ld to f%d\n" , __FUNCTION__, v2, f1); + env->fregs[f1].d =int64_to_float64 (v2, &env->fpu_status); +} + +/* convert 64-bit int to 128-bit float */ +void HELPER (cxgbr )(uint32_t f1,int64_t v2) +{ +FP128 x1; + x1.x =int64_to_float128 (v2, &env->fpu_status); +HELPER_LOG ("%s: converted %ld to 0x%lx and 0x%lx\n" , __FUNCTION__, v2, x1.h, x1.l); + env->fregs[f1].i = x1.h; + env->fregs[f1 +2 ].i = x1.l; +} + +/* convert 32-bit int to 32-bit float */ +void HELPER (cefbr )(uint32_t f1,int32_t v2) +{ + env->fregs[f1].e =int32_to_float32 (v2, &env->fpu_status); +HELPER_LOG ("%s: converting %d to 0x%d in f%d\n" , __FUNCTION__, v2, env->fregs[f1].e, f1); +} + +/* 32-bit FP addition RR */ +uint32_t HELPER (aebr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].e =float32_add (env->fregs[f1].e, env->fregs[f2].e, &env->fpu_status); +HELPER_LOG ("%s: adding 0x%d resulting in 0x%d in f%d\n" , __FUNCTION__, env->fregs[f2].e, env->fregs[f1].e, f1); +return set_cc_nz_f32 (env->fregs[f1].e); +} + +/* 64-bit FP addition RR */ +uint32_t HELPER (adbr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].d =float64_add (env->fregs[f1].d, env->fregs[f2].d, &env->fpu_status); +HELPER_LOG ("%s: adding 0x%ld resulting in 0x%ld in f%d\n" , __FUNCTION__, env->fregs[f2].d, env->fregs[f1].d, f1); +return set_cc_nz_f64 (env->fregs[f1].d); +} + +/* 32-bit FP subtraction RR */ +uint32_t HELPER (sebr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].e =float32_sub (env->fregs[f1].e, env->fregs[f2].e, &env->fpu_status); +HELPER_LOG ("%s: adding 0x%d resulting in 0x%d in f%d\n" , __FUNCTION__, env->fregs[f2].e, env->fregs[f1].e, f1); +return set_cc_nz_f32 (env->fregs[f1].e); +} + +/* 64-bit FP subtraction RR */ +uint32_t HELPER (sdbr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].d =float64_sub (env->fregs[f1].d, env->fregs[f2].d, &env->fpu_status); +HELPER_LOG ("%s: subtracting 0x%ld resulting in 0x%ld in f%d\n" , __FUNCTION__, env->fregs[f2].d, env->fregs[f1].d, f1); +return set_cc_nz_f64 (env->fregs[f1].d); +} + +/* 32-bit FP division RR */ +void HELPER (debr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].e =float32_div (env->fregs[f1].e, env->fregs[f2].e, &env->fpu_status); +} + +/* 128-bit FP division RR */ +void HELPER (dxbr )(uint32_t f1,uint32_t f2) +{ +FP128 v1; + v1.h = env->fregs[f1].i; + v1.l = env->fregs[f1 +2 ].i; +FP128 v2; + v2.h = env->fregs[f2].i; + v2.l = env->fregs[f2 +2 ].i; +FP128 res; + res.x =float128_div (v1.x, v2.x, &env->fpu_status); + env->fregs[f1].i = res.h; + env->fregs[f1 +2 ].i = res.l; +} + +/* 64-bit FP multiplication RR */ +void HELPER (mdbr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].d =float64_mul (env->fregs[f1].d, env->fregs[f2].d, &env->fpu_status); +} + +/* 128-bit FP multiplication RR */ +void HELPER (mxbr )(uint32_t f1,uint32_t f2) +{ +FP128 v1; + v1.h = env->fregs[f1].i; + v1.l = env->fregs[f1 +2 ].i; +FP128 v2; + v2.h = env->fregs[f2].i; + v2.l = env->fregs[f2 +2 ].i; +FP128 res; + res.x =float128_mul (v1.x, v2.x, &env->fpu_status); +//HELPER_LOG("%s: 0x%ld * 0x%ld = 0x%ld\n", __FUNCTION__, v1.x, v2.x, res.x); + env->fregs[f1].i = res.h; + env->fregs[f1 +2 ].i = res.l; +} + +/* convert 32-bit float to 64-bit float */ +void HELPER (ldebr )(uint32_t r1,uint32_t r2) +{ + env->fregs[r1].d =float32_to_float64 (env->fregs[r2].e, &env->fpu_status); +} + +/* convert 128-bit float to 64-bit float */ +void HELPER (ldxbr )(uint32_t f1,uint32_t f2) +{ +FP128 x2; + x2.h = env->fregs[f2].i; + x2.l = env->fregs[f2 +2 ].i; +//HELPER_LOG("%s: converted %llf ", __FUNCTION__, x2.x); + env->fregs[f1].d =float128_to_float64 (x2.x, &env->fpu_status); +HELPER_LOG ("%s: to 0x%ld\n" , __FUNCTION__, env->fregs[f1].d); +} + +/* convert 64-bit float to 128-bit float */ +void HELPER (lxdbr )(uint32_t f1,uint32_t f2) +{ +FP128 res; + res.x =float64_to_float128 (env->fregs[f2].d, &env->fpu_status); + env->fregs[f1].i = res.h; + env->fregs[f1 +2 ].i = res.l; +} + +/* convert 64-bit float to 32-bit float */ +void HELPER (ledbr )(uint32_t f1,uint32_t f2) +{ +float64 d2 = env->fregs[f2].d; + env->fregs[f1].e =float64_to_float32 (d2, &env->fpu_status); +} + +/* convert 128-bit float to 32-bit float */ +void HELPER (lexbr )(uint32_t f1,uint32_t f2) +{ +FP128 x2; + x2.h = env->fregs[f2].i; + x2.l = env->fregs[f2 +2 ].i; +//HELPER_LOG("%s: converted %llf ", __FUNCTION__, x2.x); + env->fregs[f1].e =float128_to_float32 (x2.x, &env->fpu_status); +HELPER_LOG ("%s: to 0x%d\n" , __FUNCTION__, env->fregs[f1].e); +} + +/* absolute value of 32-bit float */
target-s390x/op_helper.c line 1198
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+uint32_t HELPER (lpebr )(uint32_t f1,uint32_t f2) +{ +float32 v1; +float32 v2 = env->fregs[f2].d; +if (float32_is_neg (v2)) { + v1 =float32_abs (v2); + } +else { + v1 = v2; + }
I don't see the point of such a test here.
Quoted 5 lines
target-s390x/op_helper.c new file +5
-0+ env->fregs[f1].d = v1; +return set_cc_nz_f32 (v1); +} + +/* absolute value of 64-bit float */
target-s390x/op_helper.c line 1213
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+uint32_t HELPER (lpdbr )(uint32_t f1,uint32_t f2) +{ +float64 v1; +float64 v2 = env->fregs[f2].d; +if (float64_is_neg (v2)) { + v1 =float64_abs (v2); + } +else { + v1 = v2; + }
Same.
Quoted 7 lines
target-s390x/op_helper.c new file +7
-0+ env->fregs[f1].d = v1; +return set_cc_nz_f64 (v1); +} + +/* absolute value of 128-bit float */ +uint32_t HELPER (lpxbr )(uint32_t f1,uint32_t f2) +{
target-s390x/op_helper.c line 1230
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+FP128 v1; +FP128 v2; + v2.h = env->fregs[f2].i; + v2.l = env->fregs[f2 +2 ].i; +if (float128_is_neg (v2.x)) { + v1.x =float128_abs (v2.x); + } +else { + v1 = v2; + }
Same.
Quoted 54 lines
target-s390x/op_helper.c new file +54
-0+ env->fregs[f1].i = v1.h; + env->fregs[f1 +2 ].i = v1.l; +return set_cc_nz_f128 (v1.x); +} + +/* load and test 64-bit float */ +uint32_t HELPER (ltdbr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].d = env->fregs[f2].d; +return set_cc_nz_f64 (env->fregs[f1].d); +} + +/* load and test 32-bit float */ +uint32_t HELPER (ltebr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].e = env->fregs[f2].e; +return set_cc_nz_f32 (env->fregs[f1].e); +} + +/* load and test 128-bit float */ +uint32_t HELPER (ltxbr )(uint32_t f1,uint32_t f2) +{ +FP128 x; + x.h = env->fregs[f2].i; + x.l = env->fregs[f2 +2 ].i; + env->fregs[f1].i = x.h; + env->fregs[f1 +2 ].i = x.l; +return set_cc_nz_f128 (x.x); +} + +/* negative absolute of 32-bit float */ +uint32_t HELPER (lcebr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].e =float32_sub (float32_zero, env->fregs[f2].e, &env->fpu_status); +return set_cc_nz_f32 (env->fregs[f1].e); +} + +/* negative absolute of 64-bit float */ +uint32_t HELPER (lcdbr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].d =float64_sub (float64_zero, env->fregs[f2].d, &env->fpu_status); +return set_cc_nz_f64 (env->fregs[f1].d); +} + +/* convert 64-bit float to 128-bit float */ +uint32_t HELPER (lcxbr )(uint32_t f1,uint32_t f2) +{ +FP128 x1, x2; + x2.h = env->fregs[f2].i; + x2.l = env->fregs[f2 +2 ].i; + x1.x =float128_sub (float64_to_float128 (float64_zero, &env->fpu_status), x2.x, &env->fpu_status); + env->fregs[f1].i = x1.h; + env->fregs[f1 +2 ].i = x1.l; +return set_cc_nz_f128 (x1.x);
target-s390x/op_helper.c line 1294
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+} + +/* 32-bit FP compare RM */ +uint32_t HELPER (ceb )(uint32_t f1,uint64_t a2) +{ +float32 v1 = env->fregs[f1].e; +union { +float32 e; +uint32_t i; + } v2;
CPU_FloatU should be used instead.
target-s390x/op_helper.c line 1287
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldl (a2);
The value should be passed directly instead of loaded here, as ldl is is wrong depending on the MMU mode.
target-s390x/op_helper.c line 1307
Quoted 12 lines
target-s390x/op_helper.c new file +12
-0+HELPER_LOG ("%s: comparing 0x%d from f%d and 0x%d\n" , __FUNCTION__, v1, f1, v2.e); +return set_cc_f32 (v1, v2.e); +} + +/* 32-bit FP addition RM */ +uint32_t HELPER (aeb )(uint32_t f1,uint64_t a2) +{ +float32 v1 = env->fregs[f1].e; +union { +float32 e; +uint32_t i; + } v2;
same
target-s390x/op_helper.c line 1300
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldl (a2);
same
target-s390x/op_helper.c line 1321
Quoted 13 lines
target-s390x/op_helper.c new file +13
-0+HELPER_LOG ("%s: adding 0x%d from f%d and 0x%d\n" , __FUNCTION__, v1, f1, v2.e); + env->fregs[f1].e =float32_add (v1, v2.e, &env->fpu_status); +return set_cc_nz_f32 (env->fregs[f1].e); +} + +/* 32-bit FP division RM */ +void HELPER (deb )(uint32_t f1,uint64_t a2) +{ +float32 v1 = env->fregs[f1].e; +union { +float32 e; +uint32_t i; + } v2;
same
target-s390x/op_helper.c line 1314
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldl (a2);
same
target-s390x/op_helper.c line 1334
Quoted 12 lines
target-s390x/op_helper.c new file +12
-0+HELPER_LOG ("%s: dividing 0x%d from f%d by 0x%d\n" , __FUNCTION__, v1, f1, v2.e); + env->fregs[f1].e =float32_div (v1, v2.e, &env->fpu_status); +} + +/* 32-bit FP multiplication RM */ +void HELPER (meeb )(uint32_t f1,uint64_t a2) +{ +float32 v1 = env->fregs[f1].e; +union { +float32 e; +uint32_t i; + } v2;
same
target-s390x/op_helper.c line 1327
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldl (a2);
same
Quoted 26 lines
target-s390x/op_helper.c new file +26
-0+HELPER_LOG ("%s: multiplying 0x%d from f%d and 0x%d\n" , __FUNCTION__, v1, f1, v2.e); + env->fregs[f1].e =float32_mul (v1, v2.e, &env->fpu_status); +} + +/* 32-bit FP compare RR */ +uint32_t HELPER (cebr )(uint32_t f1,uint32_t f2) +{ +float32 v1 = env->fregs[f1].e; +float32 v2 = env->fregs[f2].e;; +HELPER_LOG ("%s: comparing 0x%d from f%d and 0x%d\n" , __FUNCTION__, v1, f1, v2); +return set_cc_f32 (v1, v2); +} + +/* 64-bit FP compare RR */ +uint32_t HELPER (cdbr )(uint32_t f1,uint32_t f2) +{ +float64 v1 = env->fregs[f1].d; +float64 v2 = env->fregs[f2].d;; +HELPER_LOG ("%s: comparing 0x%ld from f%d and 0x%ld\n" , __FUNCTION__, v1, f1, v2); +return set_cc_f64 (v1, v2); +} + +/* 128-bit FP compare RR */ +uint32_t HELPER (cxbr )(uint32_t f1,uint32_t f2) +{ +FP128 v1;
target-s390x/op_helper.c line 1371
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+ v1.h = env->fregs[f1].i; + v1.l = env->fregs[f1 +2 ].i; +FP128 v2; + v2.h = env->fregs[f2].i; + v2.l = env->fregs[f2 +2 ].i; +//HELPER_LOG("%s: comparing %llf from f%d and %llf\n", __FUNCTION__, v1.x, f1, v2.x); +if (float128_is_nan (v1.x) ||float128_is_nan (v2.x))return 3 ; +else if (float128_eq (v1.x, v2.x, &env->fpu_status))return 0 ; +else if (float128_lt (v1.x, v2.x, &env->fpu_status))return 1 ; +else return 2 ;
coding style
target-s390x/op_helper.c line 1381
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+} + +/* 64-bit FP compare RM */ +uint32_t HELPER (cdb )(uint32_t f1,uint64_t a2) +{ +float64 v1 = env->fregs[f1].d; +union { +float64 d; +uint64_t i; + } v2;
same
target-s390x/op_helper.c line 1374
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldq (a2);
same
target-s390x/op_helper.c line 1394
Quoted 12 lines
target-s390x/op_helper.c new file +12
-0+HELPER_LOG ("%s: comparing 0x%ld from f%d and 0x%lx\n" , __FUNCTION__, v1, f1, v2.d); +return set_cc_f64 (v1, v2.d); +} + +/* 64-bit FP addition RM */ +uint32_t HELPER (adb )(uint32_t f1,uint64_t a2) +{ +float64 v1 = env->fregs[f1].d; +union { +float64 d; +uint64_t i; + } v2;
same
target-s390x/op_helper.c line 1387
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldq (a2);
same
target-s390x/op_helper.c line 1408
Quoted 13 lines
target-s390x/op_helper.c new file +13
-0+HELPER_LOG ("%s: adding 0x%lx from f%d and 0x%lx\n" , __FUNCTION__, v1, f1, v2.d); + env->fregs[f1].d = v1 =float64_add (v1, v2.d, &env->fpu_status); +return set_cc_nz_f64 (v1); +} + +/* 32-bit FP subtraction RM */ +uint32_t HELPER (seb )(uint32_t f1,uint64_t a2) +{ +float32 v1 = env->fregs[f1].e; +union { +float32 e; +uint32_t i; + } v2;
same
target-s390x/op_helper.c line 1401
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldl (a2);
same
target-s390x/op_helper.c line 1421
Quoted 12 lines
target-s390x/op_helper.c new file +12
-0+ env->fregs[f1].e = v1 =float32_sub (v1, v2.e, &env->fpu_status); +return set_cc_nz_f32 (v1); +} + +/* 64-bit FP subtraction RM */ +uint32_t HELPER (sdb )(uint32_t f1,uint64_t a2) +{ +float64 v1 = env->fregs[f1].d; +union { +float64 d; +uint64_t i; + } v2;
same
target-s390x/op_helper.c line 1414
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldq (a2);
same
target-s390x/op_helper.c line 1434
Quoted 12 lines
target-s390x/op_helper.c new file +12
-0+ env->fregs[f1].d = v1 =float64_sub (v1, v2.d, &env->fpu_status); +return set_cc_nz_f64 (v1); +} + +/* 64-bit FP multiplication RM */ +void HELPER (mdb )(uint32_t f1,uint64_t a2) +{ +float64 v1 = env->fregs[f1].d; +union { +float64 d; +uint64_t i; + } v2;
same
target-s390x/op_helper.c line 1427
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldq (a2);
same
target-s390x/op_helper.c line 1447
Quoted 12 lines
target-s390x/op_helper.c new file +12
-0+HELPER_LOG ("%s: multiplying 0x%lx from f%d and 0x%ld\n" , __FUNCTION__, v1, f1, v2.d); + env->fregs[f1].d =float64_mul (v1, v2.d, &env->fpu_status); +} + +/* 64-bit FP division RM */ +void HELPER (ddb )(uint32_t f1,uint64_t a2) +{ +float64 v1 = env->fregs[f1].d; +union { +float64 d; +uint64_t i; + } v2;
same
target-s390x/op_helper.c line 1440
Quoted 1 line
target-s390x/op_helper.c new file +1
-0+ v2.i =ldq (a2);
same
Quoted 44 lines
target-s390x/op_helper.c new file +44
-0+HELPER_LOG ("%s: dividing 0x%lx from f%d by 0x%ld\n" , __FUNCTION__, v1, f1, v2.d); + env->fregs[f1].d =float64_div (v1, v2.d, &env->fpu_status); +} + +static void set_round_mode (int m3) +{ +switch (m3) { +case 0 :break ;/* current mode */ +case 1 :/* biased round no nearest */ +case 4 :/* round to nearest */ +set_float_rounding_mode (float_round_nearest_even, &env->fpu_status); +break ; +case 5 :/* round to zero */ +set_float_rounding_mode (float_round_to_zero, &env->fpu_status); +break ; +case 6 :/* round to +inf */ +set_float_rounding_mode (float_round_up, &env->fpu_status); +break ; +case 7 :/* round to -inf */ +set_float_rounding_mode (float_round_down, &env->fpu_status); +break ; + } +} + +/* convert 32-bit float to 64-bit int */ +uint32_t HELPER (cgebr )(uint32_t r1,uint32_t f2,uint32_t m3) +{ +float32 v2 = env->fregs[f2].e; +set_round_mode (m3); + env->regs[r1] =float32_to_int64 (v2, &env->fpu_status); +return set_cc_nz_f32 (v2); +} + +/* convert 64-bit float to 64-bit int */ +uint32_t HELPER (cgdbr )(uint32_t r1,uint32_t f2,uint32_t m3) +{ +float64 v2 = env->fregs[f2].d; +set_round_mode (m3); + env->regs[r1] =float64_to_int64 (v2, &env->fpu_status); +return set_cc_nz_f64 (v2); +} + +/* convert 128-bit float to 64-bit int */ +uint32_t HELPER (cgxbr )(uint32_t r1,uint32_t f2,uint32_t m3)
target-s390x/op_helper.c line 1502
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+{ +FP128 v2; + v2.h = env->fregs[f2].i; + v2.l = env->fregs[f2 +2 ].i; +set_round_mode (m3); + env->regs[r1] =float128_to_int64 (v2.x, &env->fpu_status); +if (float128_is_nan (v2.x))return 3 ; +else if (float128_is_zero (v2.x))return 0 ; +else if (float128_is_neg (v2.x))return 1 ; +else return 2 ;
coding style
Quoted 124 lines
target-s390x/op_helper.c new file +123
-0+} + +/* convert 32-bit float to 32-bit int */ +uint32_t HELPER (cfebr )(uint32_t r1,uint32_t f2,uint32_t m3) +{ +float32 v2 = env->fregs[f2].e; +set_round_mode (m3); + env->regs[r1] = (env->regs[r1] &0xffffffff00000000ULL ) |float32_to_int32 (v2, &env->fpu_status); +return set_cc_nz_f32 (v2); +} + +/* convert 64-bit float to 32-bit int */ +uint32_t HELPER (cfdbr )(uint32_t r1,uint32_t f2,uint32_t m3) +{ +float64 v2 = env->fregs[f2].d; +set_round_mode (m3); + env->regs[r1] = (env->regs[r1] &0xffffffff00000000ULL ) |float64_to_int32 (v2, &env->fpu_status); +return set_cc_nz_f64 (v2); +} + +/* convert 128-bit float to 32-bit int */ +uint32_t HELPER (cfxbr )(uint32_t r1,uint32_t f2,uint32_t m3) +{ +FP128 v2; + v2.h = env->fregs[f2].i; + v2.l = env->fregs[f2 +2 ].i; + env->regs[r1] = (env->regs[r1] &0xffffffff00000000ULL ) |float128_to_int32 (v2.x, &env->fpu_status); +return set_cc_nz_f128 (v2.x); +} + +/* load 32-bit FP zero */ +void HELPER (lzer )(uint32_t f1) +{ + env->fregs[f1].e = float32_zero; +} + +/* load 64-bit FP zero */ +void HELPER (lzdr )(uint32_t f1) +{ + env->fregs[f1].d = float64_zero; +} +/* load 128-bit FP zero */ +void HELPER (lzxr )(uint32_t f1) +{ +FP128 x; + x.x =float64_to_float128 (float64_zero, &env->fpu_status); + env->fregs[f1].i = x.h; + env->fregs[f1 +1 ].i = x.l; +} + +/* 128-bit FP subtraction RR */ +uint32_t HELPER (sxbr )(uint32_t f1,uint32_t f2) +{ +FP128 v1; + v1.h = env->fregs[f1].i; + v1.l = env->fregs[f1 +2 ].i; +FP128 v2; + v2.h = env->fregs[f2].i; + v2.l = env->fregs[f2 +2 ].i; +FP128 res; + res.x =float128_sub (v1.x, v2.x, &env->fpu_status); + env->fregs[f1].i = res.h; + env->fregs[f1 +2 ].i = res.l; +return set_cc_nz_f128 (res.x); +} + +/* 128-bit FP addition RR */ +uint32_t HELPER (axbr )(uint32_t f1,uint32_t f2) +{ +FP128 v1; + v1.h = env->fregs[f1].i; + v1.l = env->fregs[f1 +2 ].i; +FP128 v2; + v2.h = env->fregs[f2].i; + v2.l = env->fregs[f2 +2 ].i; +FP128 res; + res.x =float128_add (v1.x, v2.x, &env->fpu_status); + env->fregs[f1].i = res.h; + env->fregs[f1 +2 ].i = res.l; +return set_cc_nz_f128 (res.x); +} + +/* 32-bit FP multiplication RR */ +void HELPER (meebr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].e =float32_mul (env->fregs[f1].e, env->fregs[f2].e, &env->fpu_status); +} + +/* 64-bit FP division RR */ +void HELPER (ddbr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].d =float64_div (env->fregs[f1].d, env->fregs[f2].d, &env->fpu_status); +} + +/* 64-bit FP multiply and add RM */ +void HELPER (madb )(uint32_t f1,uint64_t a2,uint32_t f3) +{ +HELPER_LOG ("%s: f1 %d a2 0x%lx f3 %d\n" , __FUNCTION__, f1, a2, f3); +union { +float64 d; +uint64_t i; + } v2; + v2.i =ldq (a2); + env->fregs[f1].d =float64_add (env->fregs[f1].d,float64_mul (v2.d, env->fregs[f3].d, &env->fpu_status), &env->fpu_status); +} + +/* 64-bit FP multiply and add RR */ +void HELPER (madbr )(uint32_t f1,uint32_t f3,uint32_t f2) +{ +HELPER_LOG ("%s: f1 %d f2 %d f3 %d\n" , __FUNCTION__, f1, f2, f3); + env->fregs[f1].d =float64_add (float64_mul (env->fregs[f2].d, env->fregs[f3].d, &env->fpu_status), env->fregs[f1].d, &env->fpu_status); +} + +/* 64-bit FP multiply and subtract RR */ +void HELPER (msdbr )(uint32_t f1,uint32_t f3,uint32_t f2) +{ +HELPER_LOG ("%s: f1 %d f2 %d f3 %d\n" , __FUNCTION__, f1, f2, f3); + env->fregs[f1].d =float64_sub (float64_mul (env->fregs[f2].d, env->fregs[f3].d, &env->fpu_status), env->fregs[f1].d, &env->fpu_status); +} + +/* 32-bit FP multiply and add RR */ +void HELPER (maebr )(uint32_t f1,uint32_t f3,uint32_t f2) +{
target-s390x/op_helper.c line 1636
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+ env->fregs[f1].e =float32_add (env->fregs[f1].e,float32_mul (env->fregs[f2].e, env->fregs[f3].e, &env->fpu_status), &env->fpu_status); +} + +/* convert 64-bit float to 128-bit float */ +void HELPER (lxdb )(uint32_t f1,uint64_t a2) +{ +union { +float64 d; +uint64_t i; + } v2;
same
Quoted 1 line
+ v2.i = ldq(a2);
same
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+FP128 v1; + v1.x =float64_to_float128 (v2.d, &env->fpu_status); + env->fregs[f1].i = v1.h; + env->fregs[f1 +2 ].i = v1.l; +} + +/* test data class 32-bit */ +uint32_t HELPER (tceb )(uint32_t f1,uint64_t m2) +{ +float32 v1 = env->fregs[f1].e;
target-s390x/op_helper.c line 1657
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+int neg =float32_is_neg (v1); +uint32_t cc =0 ; +HELPER_LOG ("%s: v1 0x%lx m2 0x%lx neg %d\n" , __FUNCTION__, v1, m2, neg); +if (float32_is_zero (v1) && (m2 & (1 << (11 -neg)))) cc =1 ; +else if (float32_is_infinity (v1) && (m2 & (1 << (5 -neg)))) cc =1 ; +else if (float32_is_nan (v1) && (m2 & (1 << (3 -neg)))) cc =1 ; +else if (float32_is_signaling_nan (v1) && (m2 & (1 << (1 -neg)))) cc =1 ; +else /* assume normalized number */ if (m2 & (1 << (9 -neg))) cc =1 ; +/* FIXME: denormalized? */ +return cc;
coding style
Quoted 6 lines
target-s390x/op_helper.c new file +6
-0+} + +/* test data class 64-bit */ +uint32_t HELPER (tcdb )(uint32_t f1,uint64_t m2) +{ +float64 v1 = env->fregs[f1].d;
target-s390x/op_helper.c line 1673
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+int neg =float64_is_neg (v1); +uint32_t cc =0 ; +HELPER_LOG ("%s: v1 0x%lx m2 0x%lx neg %d\n" , __FUNCTION__, v1, m2, neg); +if (float64_is_zero (v1) && (m2 & (1 << (11 -neg)))) cc =1 ; +else if (float64_is_infinity (v1) && (m2 & (1 << (5 -neg)))) cc =1 ; +else if (float64_is_nan (v1) && (m2 & (1 << (3 -neg)))) cc =1 ; +else if (float64_is_signaling_nan (v1) && (m2 & (1 << (1 -neg)))) cc =1 ; +else /* assume normalized number */ if (m2 & (1 << (9 -neg))) cc =1 ; +/* FIXME: denormalized? */ +return cc;
coding style
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+} + +/* test data class 128-bit */ +uint32_t HELPER (tcxb )(uint32_t f1,uint64_t m2) +{ +FP128 v1; +uint32_t cc =0 ; + v1.h = env->fregs[f1].i;
target-s390x/op_helper.c line 1691
Quoted 10 lines
target-s390x/op_helper.c new file +10
-0+ v1.l = env->fregs[f1 +2 ].i; + +int neg =float128_is_neg (v1.x); +if (float128_is_zero (v1.x) && (m2 & (1 << (11 -neg)))) cc =1 ; +else if (float128_is_infinity (v1.x) && (m2 & (1 << (5 -neg)))) cc =1 ; +else if (float128_is_nan (v1.x) && (m2 & (1 << (3 -neg)))) cc =1 ; +else if (float128_is_signaling_nan (v1.x) && (m2 & (1 << (1 -neg)))) cc =1 ; +else /* assume normalized number */ if (m2 & (1 << (9 -neg))) cc =1 ; +/* FIXME: denormalized? */ +return cc;
coding style
Quoted 88 lines
target-s390x/op_helper.c new file +28
-0+} + +/* find leftmost one */ +uint32_t HELPER (flogr )(uint32_t r1,uint64_t v2) +{ +uint64_t res =0 ; +uint64_t ov2 = v2; +while (!(v2 &0x8000000000000000ULL ) && v2) { + v2 <<=1 ; + res++; + } +if (!v2) { + env->regs[r1] =64 ; + env->regs[r1 +1 ] =0 ; +return 0 ; + } +else { + env->regs[r1] = res; + env->regs[r1 +1 ] = ov2 & ~(0x8000000000000000ULL >> res); +return 2 ; + } +} + +/* square root 64-bit RR */ +void HELPER (sqdbr )(uint32_t f1,uint32_t f2) +{ + env->fregs[f1].d =float64_sqrt (env->fregs[f2].d, &env->fpu_status); +}target-s390x/translate.c new file +54
-0@@ -0,0 +1,2479 @@ +/* +* S/390 translation +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ +#include <stdarg.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <inttypes.h> + +#define S390X_DEBUG_DISAS +#ifdef S390X_DEBUG_DISAS +# define LOG_DISAS (...) qemu_log(__VA_ARGS__) +#else +# define LOG_DISAS (...) do { } while (0) +#endif + +#include "cpu.h" +#include "exec-all.h" +#include "disas.h" +#include "tcg-op.h" +#include "qemu-log.h" + +/* global register indexes */ +static TCGv_ptr cpu_env; + +#include "gen-icount.h" +#include "helpers.h" +#define GEN_HELPER 1 +#include "helpers.h" + +typedef struct DisasContext DisasContext ; +struct DisasContext { +uint64_t pc; +int is_jmp; +CPUS390XState *env; +}; + +#define DISAS_EXCP 4
target-s390x/translate.c line 64
Quoted 10 lines
target-s390x/translate.c new file +10
-0+#define DISAS_SVC 5 + +void cpu_dump_state (CPUState *env,FILE *f, +int (*cpu_fprintf)(FILE *f,const char *fmt, ...), +int flags) +{ +int i; +for (i =0 ; i <16 ; i++) { +cpu_fprintf (f,"R%02d=%016lx" , i, env->regs[i]); +if ((i %4 ) ==3 )cpu_fprintf (f,"\n" );
coding style
target-s390x/translate.c line 69
Quoted 5 lines
target-s390x/translate.c new file +5
-0+else cpu_fprintf (f," " ); + } +for (i =0 ; i <16 ; i++) { +cpu_fprintf (f,"F%02d=%016lx" , i, env->fregs[i]); +if ((i %4 ) ==3 )cpu_fprintf (f,"\n" );
coding style
target-s390x/translate.c line 81
Quoted 12 lines
target-s390x/translate.c new file +12
-0+else cpu_fprintf (f," " ); + } +cpu_fprintf (f,"PSW=mask %016lx addr %016lx cc %02x\n" , env->psw.mask, env->psw.addr, env->cc); +} + +#define TCGREGS + +static TCGv global_cc; +#ifdef TCGREGS +/* registers stored in TCG variables enhance performance */ +static TCGv tcgregs[16 ]; +static TCGv tcgregs32[16 ];
This variables hold 32-bit TCG values, it should be of type TCGv_i32.
Quoted 7 lines
target-s390x/translate.c new file +7
-0+#endif +static TCGv cc; +static TCGv psw_addr; + +void s390x_translate_init (void ) +{ + cpu_env =tcg_global_reg_new_ptr (TCG_AREG0 ,"env" );
target-s390x/translate.c line 98
Quoted 10 lines
target-s390x/translate.c new file +10
-0+ global_cc =tcg_global_mem_new_i32 (TCG_AREG0 , offsetof(CPUState , cc),"global_cc" ); +#ifdef TCGREGS +int i; +char rn[4 ]; +for (i =0 ; i <16 ; i++) { +sprintf (rn,"R%d" , i); + tcgregs[i] = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUState, regs[i]), strdup(rn)); +sprintf (rn,"r%d" , i); + tcgregs32[i] = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUState, regs[i]) +#ifdef WORDS_BIGENDIAN
This is wrong. It should probably be HOST_WORDS_BIGENDIAN.
Quoted 21 lines
target-s390x/translate.c new file +21
-0+ +4 +#endif + , strdup(rn)); + } +#endif + psw_addr = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUState, psw.addr), "psw_addr"); +} + +#ifdef TCGREGS +static inline void sync_reg64 (int reg) +{ +tcg_gen_sync_i64 (tcgregs[reg]); +} +static inline void sync_reg32 (int reg) +{ +tcg_gen_sync_i32 (tcgregs32[reg]); +} +#endif + +static TCGv load_reg (int reg) +{
target-s390x/translate.c line 129
Quoted 10 lines
target-s390x/translate.c new file +10
-0+TCGv r =tcg_temp_new_i64 (); +#ifdef TCGREGS +sync_reg32 (reg); +tcg_gen_mov_i64 (r, tcgregs[reg]); +return r; +#else + tcg_gen_ld_i64(r, cpu_env, offsetof(CPUState, regs[reg])); +return r; +#endif +}
I don't really like implicit TCGv temp allocation. In other targets it often has caused missing tcg_temp_free(). It should probably be rewritten as load_reg(TCGv t, int reg).
target-s390x/translate.c line 143
Quoted 13 lines
target-s390x/translate.c new file +13
-0+static TCGv load_freg (int reg) +{ +TCGv r =tcg_temp_new_i64 (); + tcg_gen_ld_i64(r, cpu_env, offsetof(CPUState, fregs[reg].d)); +return r; +} + +static TCGv load_freg32 (int reg) +{ +TCGv r =tcg_temp_new_i32 (); + tcg_gen_ld_i32(r, cpu_env, offsetof(CPUState, fregs[reg].e)); +return r; +}
Should be of type TCGv_i32.
target-s390x/translate.c line 151
Quoted 7 lines
target-s390x/translate.c new file +7
-0+static void load_reg32_var (TCGv r,int reg) +{ +#ifdef TCGREGS +sync_reg64 (reg); +tcg_gen_mov_i32 (r, tcgregs32[reg]); +#else +#ifdef WORDS_BIGENDIAN
HOST_WORDS_BIGENDIAN ?
target-s390x/translate.c line 157
Quoted 6 lines
target-s390x/translate.c new file +6
-0+ tcg_gen_ld_i32(r, cpu_env, offsetof(CPUState, regs[reg]) + 4); +#else + tcg_gen_ld_i32(r, cpu_env, offsetof(CPUState, regs[reg])); +#endif +#endif +}
Should be of type TCGv_i32.
target-s390x/translate.c line 164
Quoted 7 lines
target-s390x/translate.c new file +7
-0+ +static TCGv load_reg32 (int reg) +{ +TCGv r =tcg_temp_new_i32 (); +load_reg32_var (r, reg); +return r; +}
Should be of type TCGv_i32.
Quoted 13 lines
target-s390x/translate.c new file +13
-0+ +static void store_reg (int reg,TCGv v) +{ +#ifdef TCGREGS +sync_reg32 (reg); +tcg_gen_mov_i64 (tcgregs[reg], v); +#else + tcg_gen_st_i64(v, cpu_env, offsetof(CPUState, regs[reg])); +#endif +} + +static void store_freg (int reg,TCGv v) +{
target-s390x/translate.c line 187
Quoted 10 lines
target-s390x/translate.c new file +10
-0+ tcg_gen_st_i64(v, cpu_env, offsetof(CPUState, fregs[reg].d)); +} + +static void store_reg32 (int reg,TCGv v) +{ +#ifdef TCGREGS +sync_reg64 (reg); +tcg_gen_mov_i32 (tcgregs32[reg], v); +#else +#ifdef WORDS_BIGENDIAN
HOST_WORDS_BIGENDIAN ?
target-s390x/translate.c line 192
Quoted 5 lines
target-s390x/translate.c new file +5
-0+ tcg_gen_st_i32(v, cpu_env, offsetof(CPUState, regs[reg]) + 4); +#else + tcg_gen_st_i32(v, cpu_env, offsetof(CPUState, regs[reg])); +#endif +#endif
This should use TCGv_i32.
target-s390x/translate.c line 204
Quoted 12 lines
target-s390x/translate.c new file +12
-0+} + +static void store_reg8 (int reg,TCGv v) +{ +#ifdef TCGREGS +TCGv tmp =tcg_temp_new_i32 (); +sync_reg64 (reg); +tcg_gen_andi_i32 (tmp, tcgregs32[reg],0xffffff00UL ); +tcg_gen_or_i32 (tcgregs32[reg], tmp, v); +tcg_temp_free (tmp); +#else +#ifdef WORDS_BIGENDIAN
HOST_WORDS_BIGENDIAN ?
target-s390x/translate.c line 210
Quoted 6 lines
target-s390x/translate.c new file +6
-0+ tcg_gen_st8_i32(v, cpu_env, offsetof(CPUState, regs[reg]) + 7); +#else + tcg_gen_st8_i32(v, cpu_env, offsetof(CPUState, regs[reg])); +#endif +#endif +}
This should use TCGv_i32.
target-s390x/translate.c line 215
Quoted 5 lines
target-s390x/translate.c new file +5
-0+ +static void store_freg32 (int reg,TCGv v) +{ + tcg_gen_st_i32(v, cpu_env, offsetof(CPUState, fregs[reg].e)); +}
This should use TCGv_i32.
For all register load/store, as already explained in the TCG sync op patch, I am in favor of using the ld/st version (TCGREGS not defined).
target-s390x/translate.c line 220
Quoted 5 lines
target-s390x/translate.c new file +5
-0+ +static void gen_illegal_opcode (DisasContext *s) +{ +TCGv tmp =tcg_temp_new_i64 (); +tcg_gen_movi_i64 (tmp,42 );
tcg_const_i64 could be used instead.
target-s390x/translate.c line 219
Quoted 1 line
target-s390x/translate.c new file +1
-0+gen_helper_exception (tmp);
Missing tcg_temp_free_i64(tmp);
Quoted 23 lines
target-s390x/translate.c new file +23
-0+ s->is_jmp =DISAS_EXCP ; +} + +#define DEBUGINSN LOG_DISAS("insn: 0x%lx\n", insn); + +static TCGv get_address (int x2,int b2,int d2) +{ +TCGv tmp =0 ,tmp2 =0 ; +if (d2) tmp =tcg_const_i64 (d2); +if (x2) { +if (d2) { + tmp2 =load_reg (x2); +tcg_gen_add_i64 (tmp, tmp, tmp2); +tcg_temp_free (tmp2); + } +else { + tmp =load_reg (x2); + } + } +if (b2) { +if (d2 || x2) { + tmp2 =load_reg (b2); +tcg_gen_add_i64 (tmp, tmp, tmp2);
target-s390x/translate.c line 254
Quoted 10 lines
target-s390x/translate.c new file +10
-0+tcg_temp_free (tmp2); + } +else { + tmp =load_reg (b2); + } + } + +if (!(d2 || x2 || b2)) tmp =tcg_const_i64 (0 ); + +return tmp;
coding style
Quoted 26 lines
target-s390x/translate.c new file +26
-0+} + +static inline void set_cc_nz_u32 (TCGv val) +{ +gen_helper_set_cc_nz_u32 (cc, val); +} + +static inline void set_cc_nz_u64 (TCGv val) +{ +gen_helper_set_cc_nz_u64 (cc, val); +} + +static inline void set_cc_s32 (TCGv val) +{ +gen_helper_set_cc_s32 (cc, val); +} + +static inline void set_cc_s64 (TCGv val) +{ +gen_helper_set_cc_s64 (cc, val); +} + +static inline void cmp_s32 (TCGv v1,TCGv v2) +{ +gen_helper_cmp_s32 (cc, v1, v2); +}
target-s390x/translate.c line 290
Quoted 10 lines
target-s390x/translate.c new file +10
-0+ +static inline void cmp_u32 (TCGv v1,TCGv v2) +{ +gen_helper_cmp_u32 (cc, v1, v2); +} + +/* this is a hysterical raisin */ +static inline void cmp_s32c (TCGv v1,int32_t v2) +{ +gen_helper_cmp_s32 (cc, v1,tcg_const_i32 (v2));
The TCG passed to the helper should be freed.
target-s390x/translate.c line 294
Quoted 4 lines
target-s390x/translate.c new file +4
-0+} +static inline void cmp_u32c (TCGv v1,uint32_t v2) +{ +gen_helper_cmp_u32 (cc, v1,tcg_const_i32 (v2));
Same.
Quoted 7 lines
target-s390x/translate.c new file +7
-0+} + + +static inline void cmp_s64 (TCGv v1,TCGv v2) +{ +gen_helper_cmp_s64 (cc, v1, v2); +}
target-s390x/translate.c line 311
Quoted 10 lines
target-s390x/translate.c new file +10
-0+ +static inline void cmp_u64 (TCGv v1,TCGv v2) +{ +gen_helper_cmp_u64 (cc, v1, v2); +} + +/* see cmp_[su]32c() */ +static inline void cmp_s64c (TCGv v1,int64_t v2) +{ +gen_helper_cmp_s64 (cc, v1,tcg_const_i64 (v2));
Same
target-s390x/translate.c line 315
Quoted 4 lines
target-s390x/translate.c new file +4
-0+} +static inline void cmp_u64c (TCGv v1,uint64_t v2) +{ +gen_helper_cmp_u64 (cc, v1,tcg_const_i64 (v2));
Same
Quoted 14 lines
target-s390x/translate.c new file +14
-0+} + +static void gen_bcr (uint32_t mask,int tr,uint64_t offset) +{ +TCGv target; +if (mask ==0xf ) {/* unconditional */ + target =load_reg (tr); +tcg_gen_mov_i64 (psw_addr, target); + } +else { +gen_helper_bcr (cc,tcg_const_i32 (mask), (target =load_reg (tr)),tcg_const_i64 (offset)); + } +tcg_temp_free (target); +}
target-s390x/translate.c line 339
Quoted 10 lines
target-s390x/translate.c new file +10
-0+ +static void gen_brc (uint32_t mask,uint64_t pc,int32_t offset) +{ +if (mask ==0xf ) {/* unconditional */ +tcg_gen_movi_i64 (psw_addr, pc + offset); + } +else { +gen_helper_brc (cc,tcg_const_i32 (mask),tcg_const_i64 (pc),tcg_const_i32 (offset)); + } +}
The branches should be handled using brcond and goto_tb and exit_tb and not with helpers, to allow TB chaining.
target-s390x/translate.c line 348
Quoted 8 lines
target-s390x/translate.c new file +8
-0+static void gen_set_cc_add64 (TCGv v1,TCGv v2,TCGv vr) +{ +gen_helper_set_cc_add64 (cc, v1, v2, vr); +} + +static void disas_e3 (DisasContext * s,int op,int r1,int x2,int b2,int d2) +{ +TCGv tmp =0 , tmp2 =0 , tmp3 =0 ;
This is wrong. 0 maps to global 0 (env in your case). -1 should be used instead, or even better the TCGV_UNUSED macro.
target-s390x/translate.c line 358
Quoted 10 lines
target-s390x/translate.c new file +10
-0+ +LOG_DISAS ("disas_e3: op 0x%x r1 %d x2 %d b2 %d d2 %d\n" , op, r1, x2, b2, d2); + tmp =get_address (x2, b2, d2); +switch (op) { +case 0x2 :/* LTG R1,D2(X2,B2) [RXY] */ +case 0x4 :/* lg r1,d2(x2,b2) */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); +store_reg (r1, tmp2); +if (op ==0x2 )set_cc_s64 (tmp2);
coding style
target-s390x/translate.c line 361
Quoted 3 lines
target-s390x/translate.c new file +3
-0+break ; +case 0x12 :/* LT R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 359
Quoted 1 line
target-s390x/translate.c new file +1
-0+tcg_gen_qemu_ld32s (tmp2, tmp,1 );
tcg_gen_qemu_ld32s loads a 32 bit value in the default size register, that is 64-bit here.
target-s390x/translate.c line 374
Quoted 12 lines
target-s390x/translate.c new file +12
-0+store_reg32 (r1, tmp2); +set_cc_s32 (tmp2); +break ; +case 0xc :/* MSG R1,D2(X2,B2) [RXY] */ +case 0x1c :/* MSGF R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +if (op ==0xc ) { +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); + } +else { +tcg_gen_qemu_ld32s (tmp2, tmp,1 ); +tcg_gen_ext32s_i64 (tmp2, tmp2);
The sign extension is already done by qemu_ld32s
target-s390x/translate.c line 385
Quoted 11 lines
target-s390x/translate.c new file +11
-0+ } + tmp =load_reg (r1); +tcg_gen_mul_i64 (tmp, tmp, tmp2); +store_reg (r1, tmp); +break ; +case 0xd :/* DSG R1,D2(X2,B2) [RXY] */ +case 0x1d :/* DSGF R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +if (op ==0x1d ) { +tcg_gen_qemu_ld32s (tmp2, tmp,1 ); +tcg_gen_ext32s_i64 (tmp2, tmp2);
The sign extension is already done by qemu_ld32s
Quoted 7 lines
target-s390x/translate.c new file +7
-0+ } +else { +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); + } + tmp =load_reg (r1 +1 ); + tmp3 =tcg_temp_new_i64 (); +tcg_gen_div_i64 (tmp3, tmp, tmp2);
target-s390x/translate.c line 402
Quoted 10 lines
target-s390x/translate.c new file +10
-0+store_reg (r1 +1 , tmp3); +tcg_gen_rem_i64 (tmp3, tmp, tmp2); +store_reg (r1, tmp3); +break ; +case 0x8 :/* AG R1,D2(X2,B2) [RXY] */ +case 0xa :/* ALG R1,D2(X2,B2) [RXY] */ +case 0x18 :/* AGF R1,D2(X2,B2) [RXY] */ +case 0x1a :/* ALGF R1,D2(X2,B2) [RXY] */ +if (op ==0x1a ) { + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 401
Quoted 2 lines
target-s390x/translate.c new file +2
-0+tcg_gen_qemu_ld32u (tmp2, tmp,1 ); +tcg_gen_ext32u_i64 (tmp2, tmp2);
The zero extension is already done by qemu_ld32u
target-s390x/translate.c line 407
Quoted 3 lines
target-s390x/translate.c new file +3
-0+ } +else if (op ==0x18 ) { + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 406
Quoted 2 lines
target-s390x/translate.c new file +2
-0+tcg_gen_qemu_ld32s (tmp2, tmp,1 ); +tcg_gen_ext32s_i64 (tmp2, tmp2);
The sign extension is already done by qemu_ld32s
target-s390x/translate.c line 408
Quoted 2 lines
target-s390x/translate.c new file +2
-0+ } +else {
coding style
target-s390x/translate.c line 422
Quoted 11 lines
target-s390x/translate.c new file +11
-0+ tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); + } + tmp =load_reg (r1); + tmp3 =tcg_temp_new_i64 (); +tcg_gen_add_i64 (tmp3, tmp, tmp2); +store_reg (r1, tmp3); +switch (op) { +case 0x8 :case 0x18 :gen_set_cc_add64 (tmp, tmp2, tmp3);break ; +case 0xa :case 0x1a :gen_helper_set_cc_addu64 (cc, tmp, tmp2, tmp3);break ; +default :tcg_abort ();
tcg_abort() is wrong here, it is for internal TCG use. Also all the real CPU it probably launch an illegal instruction exception, it does not power off the machin.
target-s390x/translate.c line 430
Quoted 8 lines
target-s390x/translate.c new file +8
-0+ } +break ; +case 0x9 :/* SG R1,D2(X2,B2) [RXY] */ +case 0xb :/* SLG R1,D2(X2,B2) [RXY] */ +case 0x19 :/* SGF R1,D2(X2,B2) [RXY] */ +case 0x1b :/* SLGF R1,D2(X2,B2) [RXY] */ +if (op ==0x19 ) { + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 429
Quoted 2 lines
target-s390x/translate.c new file +2
-0+tcg_gen_qemu_ld32s (tmp2, tmp,1 ); +tcg_gen_ext32s_i64 (tmp2, tmp2);
The sign extension is already done by qemu_ld32s
target-s390x/translate.c line 435
Quoted 3 lines
target-s390x/translate.c new file +3
-0+ } +else if (op ==0x1b ) { + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 434
Quoted 2 lines
target-s390x/translate.c new file +2
-0+tcg_gen_qemu_ld32u (tmp2, tmp,1 ); +tcg_gen_ext32u_i64 (tmp2, tmp2);
The zero extension is already done by qemu_ld32u
target-s390x/translate.c line 450
Quoted 13 lines
target-s390x/translate.c new file +13
-0+ } +else { + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); + } + tmp =load_reg (r1); + tmp3 =tcg_temp_new_i64 (); +tcg_gen_sub_i64 (tmp3, tmp, tmp2); +store_reg (r1, tmp3); +switch (op) { +case 0x9 :case 0x19 :gen_helper_set_cc_sub64 (cc, tmp, tmp2, tmp3);break ; +case 0xb :case 0x1b :gen_helper_set_cc_subu64 (cc, tmp, tmp2, tmp3);break ; +default :tcg_abort ();
Same comment as previous tcg_abort() one.
target-s390x/translate.c line 460
Quoted 10 lines
target-s390x/translate.c new file +10
-0+ } +break ; +case 0x14 :/* LGF R1,D2(X2,B2) [RXY] */ +case 0x16 :/* LLGF R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld32u (tmp2, tmp,1 ); +switch (op) { +case 0x14 :tcg_gen_ext32s_i64 (tmp2, tmp2);break ; +case 0x16 :tcg_gen_ext32u_i64 (tmp2, tmp2);break ; +default :tcg_abort ();
Same comment as previous tcg_abort() one.
target-s390x/translate.c line 473
Quoted 13 lines
target-s390x/translate.c new file +13
-0+ } +store_reg (r1, tmp2); +break ; +case 0x15 :/* LGH R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld16s (tmp2, tmp,1 ); +tcg_gen_ext16s_i64 (tmp2, tmp2); +store_reg (r1, tmp2); +break ; +case 0x17 :/* LLGT R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld32u (tmp2, tmp,1 ); +tcg_gen_ext32u_i64 (tmp2, tmp2);
The zero extension is already done by qemu_ld32u
target-s390x/translate.c line 478
Quoted 5 lines
target-s390x/translate.c new file +5
-0+tcg_gen_andi_i64 (tmp2, tmp2,0x7fffffffULL ); +store_reg (r1, tmp2); +break ; +case 0x1e :/* LRV R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type;
target-s390x/translate.c line 477
Quoted 2 lines
target-s390x/translate.c new file +2
-0+tcg_gen_qemu_ld32u (tmp2, tmp,1 ); +tcg_gen_bswap32_i32 (tmp2, tmp2);
Wrong TCGv type;
Quoted 5 lines
target-s390x/translate.c new file +5
-0+store_reg (r1, tmp2); +break ; +case 0x20 :/* CG R1,D2(X2,B2) [RXY] */ +case 0x21 :/* CLG R1,D2(X2,B2) */ +case 0x30 :/* CGF R1,D2(X2,B2) [RXY] */
target-s390x/translate.c line 495
Quoted 10 lines
target-s390x/translate.c new file +10
-0+case 0x31 :/* CLGF R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +switch (op) { +case 0x20 : +case 0x21 : +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); +break ; +case 0x30 : +tcg_gen_qemu_ld32s (tmp2, tmp,1 ); +tcg_gen_ext32s_i64 (tmp2, tmp2);
The zero extension is already done by qemu_ld32s
target-s390x/translate.c line 499
Quoted 4 lines
target-s390x/translate.c new file +4
-0+break ; +case 0x31 : +tcg_gen_qemu_ld32u (tmp2, tmp,1 ); +tcg_gen_ext32u_i64 (tmp2, tmp2);
The zero extension is already done by qemu_ld32u
target-s390x/translate.c line 502
Quoted 3 lines
target-s390x/translate.c new file +3
-0+break ; +default : +tcg_abort ();
Same comment as previous tcg_abort() one.
target-s390x/translate.c line 508
Quoted 6 lines
target-s390x/translate.c new file +6
-0+ } + tmp =load_reg (r1); +switch (op) { +case 0x20 :case 0x30 :cmp_s64 (tmp, tmp2);break ; +case 0x21 :case 0x31 :cmp_u64 (tmp, tmp2);break ; +default :tcg_abort ();
Same comment as previous tcg_abort() one.
target-s390x/translate.c line 518
Quoted 10 lines
target-s390x/translate.c new file +10
-0+ } +break ; +case 0x24 :/* stg r1, d2(x2,b2) */ + tmp2 =load_reg (r1); +tcg_gen_qemu_st64 (tmp2, tmp,1 ); +break ; +case 0x3e :/* STRV R1,D2(X2,B2) [RXY] */ + tmp2 =load_reg32 (r1); +tcg_gen_bswap32_i32 (tmp2, tmp2); +tcg_gen_qemu_st32 (tmp2, tmp,1 );
Wrong TCGv type.
target-s390x/translate.c line 522
Quoted 4 lines
target-s390x/translate.c new file +4
-0+break ; +case 0x50 :/* STY R1,D2(X2,B2) [RXY] */ + tmp2 =load_reg32 (r1); +tcg_gen_qemu_st32 (tmp2, tmp,1 );
Wrong TCGv type.
target-s390x/translate.c line 530
Quoted 8 lines
target-s390x/translate.c new file +8
-0+break ; +case 0x57 :/* XY R1,D2(X2,B2) [RXY] */ + tmp2 =load_reg32 (r1); + tmp3 =tcg_temp_new_i32 (); +tcg_gen_qemu_ld32u (tmp3, tmp,1 ); +tcg_gen_xor_i32 (tmp, tmp2, tmp3); +store_reg32 (r1, tmp); +set_cc_nz_u32 (tmp);
Wrong TCGv type.
target-s390x/translate.c line 535
Quoted 5 lines
target-s390x/translate.c new file +5
-0+break ; +case 0x58 :/* LY R1,D2(X2,B2) [RXY] */ + tmp3 =tcg_temp_new_i32 (); +tcg_gen_qemu_ld32u (tmp3, tmp,1 ); +store_reg32 (r1, tmp3);
Wrong TCGv type.
target-s390x/translate.c line 540
Quoted 5 lines
target-s390x/translate.c new file +5
-0+break ; +case 0x5a :/* AY R1,D2(X2,B2) [RXY] */ +case 0x5b :/* SY R1,D2(X2,B2) [RXY] */ + tmp2 =load_reg32 (r1); + tmp3 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 545
Quoted 5 lines
target-s390x/translate.c new file +5
-0+tcg_gen_qemu_ld32s (tmp3, tmp,1 ); +switch (op) { +case 0x5a :tcg_gen_add_i32 (tmp, tmp2, tmp3);break ; +case 0x5b :tcg_gen_sub_i32 (tmp, tmp2, tmp3);break ; +default :tcg_abort ();
Same comment as previous tcg_abort() one.
target-s390x/translate.c line 551
Quoted 6 lines
target-s390x/translate.c new file +6
-0+ } +store_reg32 (r1, tmp); +switch (op) { +case 0x5a :gen_helper_set_cc_add32 (cc, tmp2, tmp3, tmp);break ; +case 0x5b :gen_helper_set_cc_sub32 (cc, tmp2, tmp3, tmp);break ; +default :tcg_abort ();
Same comment as previous tcg_abort() one.
target-s390x/translate.c line 562
Quoted 11 lines
target-s390x/translate.c new file +11
-0+ } +break ; +case 0x71 :/* LAY R1,D2(X2,B2) [RXY] */ +store_reg (r1, tmp); +break ; +case 0x72 :/* STCY R1,D2(X2,B2) [RXY] */ + tmp2 =load_reg32 (r1); +tcg_gen_qemu_st8 (tmp2, tmp,1 ); +break ; +case 0x73 :/* ICY R1,D2(X2,B2) [RXY] */ + tmp3 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 572
Quoted 10 lines
target-s390x/translate.c new file +10
-0+tcg_gen_qemu_ld8u (tmp3, tmp,1 ); +store_reg8 (r1, tmp3); +break ; +case 0x76 :/* LB R1,D2(X2,B2) [RXY] */ +case 0x77 :/* LGB R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld8s (tmp2, tmp,1 ); +switch (op) { +case 0x76 : +tcg_gen_ext8s_i32 (tmp2, tmp2);
Wrong TCGv type.
target-s390x/translate.c line 576
Quoted 4 lines
target-s390x/translate.c new file +4
-0+store_reg32 (r1, tmp2); +break ; +case 0x77 : +tcg_gen_ext8s_i64 (tmp2, tmp2);
Wrong TCGv type.
target-s390x/translate.c line 422
Quoted 3 lines
target-s390x/translate.c new file +3
-0+store_reg (r1, tmp2); +break ; +default :tcg_abort ();
Same comment as previous tcg_abort() one.
target-s390x/translate.c line 583
Quoted 4 lines
target-s390x/translate.c new file +4
-0+ } +break ; +case 0x78 :/* LHY R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type.
Quoted 5 lines
target-s390x/translate.c new file +5
-0+tcg_gen_qemu_ld16s (tmp2, tmp,1 ); +tcg_gen_ext16s_i32 (tmp2, tmp2); +store_reg32 (r1, tmp2); +break ; +case 0x80 :/* NG R1,D2(X2,B2) [RXY] */
target-s390x/translate.c line 598
Quoted 10 lines
target-s390x/translate.c new file +10
-0+case 0x81 :/* OG R1,D2(X2,B2) [RXY] */ +case 0x82 :/* XG R1,D2(X2,B2) [RXY] */ + tmp2 =load_reg (r1); + tmp3 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp3, tmp,1 ); +switch (op) { +case 0x80 :tcg_gen_and_i64 (tmp, tmp2, tmp3);break ; +case 0x81 :tcg_gen_or_i64 (tmp, tmp2, tmp3);break ; +case 0x82 :tcg_gen_xor_i64 (tmp, tmp2, tmp3);break ; +default :tcg_abort ();
Same comment as previous tcg_abort() one.
target-s390x/translate.c line 606
Quoted 8 lines
target-s390x/translate.c new file +8
-0+ } +store_reg (r1, tmp); +set_cc_nz_u64 (tmp); +break ; +case 0x86 :/* MLG R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); + tmp =tcg_const_i32 (r1);
Wrong TCGv type.
target-s390x/translate.c line 612
Quoted 6 lines
target-s390x/translate.c new file +6
-0+gen_helper_mlg (tmp, tmp2); +break ; +case 0x87 :/* DLG R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); + tmp =tcg_const_i32 (r1);
Wrong TCGv type.
Quoted 9 lines
target-s390x/translate.c new file +9
-0+gen_helper_dlg (tmp, tmp2); +break ; +case 0x88 :/* ALCG R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); + tmp =load_reg (r1); + tmp3 =tcg_temp_new_i64 (); +tcg_gen_shri_i64 (tmp3, cc,1 ); +tcg_gen_andi_i64 (tmp3, tmp3,1 );
target-s390x/translate.c line 631
Quoted 10 lines
target-s390x/translate.c new file +10
-0+tcg_gen_add_i64 (tmp3, tmp2, tmp3);; +tcg_gen_add_i64 (tmp3, tmp, tmp3); +store_reg (r1, tmp3); +gen_helper_set_cc_addc_u64 (cc, tmp, tmp2, tmp3); +break ; +case 0x89 :/* SLBG R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); + tmp =load_reg (r1); + tmp3 =tcg_const_i32 (r1);
Wrong TCGv type.
Quoted 4 lines
target-s390x/translate.c new file +4
-0+gen_helper_slbg (cc, cc, tmp3, tmp, tmp2); +break ; +case 0x90 :/* LLGC R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 ();
target-s390x/translate.c line 645
Quoted 10 lines
target-s390x/translate.c new file +10
-0+tcg_gen_qemu_ld8u (tmp2, tmp,1 ); +store_reg (r1, tmp2); +break ; +case 0x91 :/* LLGH R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld16u (tmp2, tmp,1 ); +store_reg (r1, tmp2); +break ; +case 0x94 :/* LLC R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 655
Quoted 10 lines
target-s390x/translate.c new file +10
-0+tcg_gen_qemu_ld8u (tmp2, tmp,1 ); +store_reg32 (r1, tmp2); +break ; +case 0x95 :/* LLH R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i32 (); +tcg_gen_qemu_ld16u (tmp2, tmp,1 ); +store_reg32 (r1, tmp2); +break ; +case 0x98 :/* ALC R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 661
Quoted 6 lines
target-s390x/translate.c new file +6
-0+tcg_gen_qemu_ld32u (tmp2, tmp,1 ); + tmp =tcg_const_i32 (r1); +gen_helper_addc_u32 (cc, cc, tmp, tmp2); +break ; +case 0x99 :/* SLB R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 674
Quoted 13 lines
target-s390x/translate.c new file +13
-0+tcg_gen_qemu_ld32u (tmp2, tmp,1 ); + tmp =load_reg32 (r1); + tmp3 =tcg_const_i32 (r1); +gen_helper_slb (cc, cc, tmp3, tmp, tmp2); +break ; +default : +LOG_DISAS ("illegal e3 operation 0x%x\n" , op); +gen_illegal_opcode (s); +break ; + } +tcg_temp_free (tmp); +if (tmp2)tcg_temp_free (tmp2); +if (tmp3)tcg_temp_free (tmp3);
Comparison on TCGv type is not allowed.
target-s390x/translate.c line 679
Quoted 5 lines
target-s390x/translate.c new file +5
-0+} + +static void disas_eb (DisasContext *s,int op,int r1,int r3,int b2,int d2) +{ +TCGv tmp =0 ,tmp2 =0 ,tmp3 =0 ,tmp4 =0 ;
Same comment as in the previous function. 0 maps to a global.
target-s390x/translate.c line 691
Quoted 12 lines
target-s390x/translate.c new file +12
-0+int i; + +LOG_DISAS ("disas_eb: op 0x%x r1 %d r3 %d b2 %d d2 0x%x\n" , op, r1, r3, b2, d2); +switch (op) { +case 0xc :/* SRLG R1,R3,D2(B2) [RSY] */ +case 0xd :/* SLLG R1,R3,D2(B2) [RSY] */ +case 0xa :/* SRAG R1,R3,D2(B2) [RSY] */ +case 0x1c :/* RLLG R1,R3,D2(B2) [RSY] */ +if (b2) { + tmp =get_address (0 , b2, d2); +tcg_gen_andi_i64 (tmp, tmp,0x3f ); + }
coding style
target-s390x/translate.c line 689
Quoted 1 line
target-s390x/translate.c new file +1
-0+else tmp =tcg_const_i32 (d2 &0x3f );
Wrong TCGv type.
target-s390x/translate.c line 700
Quoted 8 lines
target-s390x/translate.c new file +8
-0+ tmp2 =load_reg (r3); + tmp3 =tcg_temp_new_i64 (); +switch (op) { +case 0xc :tcg_gen_shr_i64 (tmp3, tmp2, tmp);break ; +case 0xd :tcg_gen_shl_i64 (tmp3, tmp2, tmp);break ; +case 0xa :tcg_gen_sar_i64 (tmp3, tmp2, tmp);break ; +case 0x1c :tcg_gen_rotl_i64 (tmp3, tmp2, tmp);break ; +default :tcg_abort ();break ;
Same comment as previous tcg_abort() one.
target-s390x/translate.c line 712
Quoted 12 lines
target-s390x/translate.c new file +12
-0+ } +store_reg (r1, tmp3); +if (op ==0xa )set_cc_s64 (tmp3); +break ; +case 0x1d :/* RLL R1,R3,D2(B2) [RSY] */ +if (b2) { + tmp =get_address (0 , b2, d2); +tcg_gen_andi_i64 (tmp, tmp,0x3f ); + } +else tmp =tcg_const_i32 (d2 &0x3f ); + tmp2 =load_reg32 (r3); + tmp3 =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 715
Quoted 3 lines
target-s390x/translate.c new file +3
-0+switch (op) { +case 0x1d :tcg_gen_rotl_i32 (tmp3, tmp2, tmp);break ; +default :tcg_abort ();break ;
Same comment as previous tcg_abort() one.
Quoted 24 lines
target-s390x/translate.c new file +24
-0+ } +store_reg32 (r1, tmp3); +break ; +case 0x4 :/* LMG R1,R3,D2(B2) [RSY] */ +case 0x24 :/* stmg */ +/* Apparently, unrolling lmg/stmg of any size gains performance - +even for very long ones... */ +if (r3 > r1) { + tmp =get_address (0 , b2, d2); +for (i = r1; i <= r3; i++) { +if (op ==0x4 ) { + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); +store_reg (i, tmp2); +/* At least one register is usually read after an lmg +(br %rsomething), which is why freeing them is +detrimental to performance */ + } +else { + tmp2 =load_reg (i); +tcg_gen_qemu_st64 (tmp2, tmp,1 ); +/* R15 is usually read after an stmg; other registers +generally aren't and can be free'd */ +if (i !=15 )tcg_temp_free (tmp2);
target-s390x/translate.c line 749
Quoted 10 lines
target-s390x/translate.c new file +10
-0+ } +tcg_gen_addi_i64 (tmp, tmp,8 ); + } + tmp2 =0 ; + } +else { + tmp =tcg_const_i32 (r1); + tmp2 =tcg_const_i32 (r3); + tmp3 =tcg_const_i32 (b2); + tmp4 =tcg_const_i32 (d2);
Wrong TCGv type.
target-s390x/translate.c line 757
Quoted 8 lines
target-s390x/translate.c new file +8
-0+if (op ==0x4 )gen_helper_lmg (tmp, tmp2, tmp3, tmp4); +else gen_helper_stmg (tmp, tmp2, tmp3, tmp4); + } +break ; +case 0x2c :/* STCMH R1,M3,D2(B2) [RSY] */ + tmp2 =get_address (0 , b2, d2); + tmp =tcg_const_i32 (r1); + tmp3 =tcg_const_i32 (r3);
Wrong TCGv type.
target-s390x/translate.c line 763
Quoted 6 lines
target-s390x/translate.c new file +6
-0+gen_helper_stcmh (cc, tmp, tmp2, tmp3); +break ; +case 0x30 :/* CSG R1,R3,D2(B2) [RSY] */ + tmp2 =get_address (0 , b2, d2); + tmp =tcg_const_i32 (r1); + tmp3 =tcg_const_i32 (r3);
Wrong TCGv type.
target-s390x/translate.c line 769
Quoted 6 lines
target-s390x/translate.c new file +6
-0+gen_helper_csg (cc, tmp, tmp2, tmp3); +break ; +case 0x3e :/* CDSG R1,R3,D2(B2) [RSY] */ + tmp2 =get_address (0 , b2, d2); + tmp =tcg_const_i32 (r1); + tmp3 =tcg_const_i32 (r3);
Wrong TCGv type.
target-s390x/translate.c line 776
Quoted 7 lines
target-s390x/translate.c new file +7
-0+gen_helper_cdsg (cc, tmp, tmp2, tmp3); +break ; +case 0x51 :/* TMY D1(B1),I2 [SIY] */ + tmp =get_address (0 , b2, d2);/* SIY -> this is the destination */ + tmp2 =tcg_temp_new_i32 (); +tcg_gen_qemu_ld8u (tmp2, tmp,1 ); + tmp =tcg_const_i32 ((r1 <<4 ) | r3);
Wrong TCGv type.
target-s390x/translate.c line 780
Quoted 4 lines
target-s390x/translate.c new file +4
-0+gen_helper_tm (cc, tmp2, tmp); +break ; +case 0x52 :/* MVIY D1(B1),I2 [SIY] */ + tmp2 =tcg_const_i32 ((r1 <<4 ) | r3);
Wrong TCGv type.
target-s390x/translate.c line 786
Quoted 6 lines
target-s390x/translate.c new file +6
-0+ tmp =get_address (0 , b2, d2);/* SIY -> this is the destination */ +tcg_gen_qemu_st8 (tmp2, tmp,1 ); +break ; +case 0x55 :/* CLIY D1(B1),I2 [SIY] */ + tmp3 =get_address (0 , b2, d2);/* SIY -> this is the 1st operand */ + tmp =tcg_temp_new_i32 ();
Wrong TCGv type.
target-s390x/translate.c line 793
Quoted 7 lines
target-s390x/translate.c new file +7
-0+tcg_gen_qemu_ld8u (tmp, tmp3,1 ); +cmp_u32c (tmp, (r1 <<4 ) | r3); +break ; +case 0x80 :/* ICMH R1,M3,D2(B2) [RSY] */ + tmp2 =get_address (0 , b2, d2); + tmp =tcg_const_i32 (r1); + tmp3 =tcg_const_i32 (r3);
Wrong TCGv type.
target-s390x/translate.c line 804
Quoted 11 lines
target-s390x/translate.c new file +11
-0+gen_helper_icmh (cc, tmp, tmp2, tmp3); +break ; +default : +LOG_DISAS ("illegal eb operation 0x%x\n" , op); +gen_illegal_opcode (s); +break ; + } +if (tmp)tcg_temp_free (tmp); +if (tmp2)tcg_temp_free (tmp2); +if (tmp3)tcg_temp_free (tmp3); +if (tmp4)tcg_temp_free (tmp4);
Comparison on TCGv type is not allowed.
target-s390x/translate.c line 809
Quoted 5 lines
target-s390x/translate.c new file +5
-0+} + +static void disas_ed (DisasContext *s,int op,int r1,int x2,int b2,int d2,int r1b) +{ +TCGv tmp, tmp2, tmp3 =0 ;
tmp should be declared as TGV_i32 here, so that the types are correct for the whole function. Also tmp3 should not be initialized to 0.
Quoted 39 lines
target-s390x/translate.c new file +39
-0+ tmp2 =get_address (x2, b2, d2); + tmp =tcg_const_i32 (r1); +switch (op) { +case 0x5 :/* LXDB R1,D2(X2,B2) [RXE] */ +gen_helper_lxdb (tmp, tmp2); +break ; +case 0x9 :/* CEB R1,D2(X2,B2) [RXE] */ +gen_helper_ceb (cc, tmp, tmp2); +break ; +case 0xa :/* AEB R1,D2(X2,B2) [RXE] */ +gen_helper_aeb (cc, tmp, tmp2); +break ; +case 0xb :/* SEB R1,D2(X2,B2) [RXE] */ +gen_helper_seb (cc, tmp, tmp2); +break ; +case 0xd :/* DEB R1,D2(X2,B2) [RXE] */ +gen_helper_deb (tmp, tmp2); +break ; +case 0x10 :/* TCEB R1,D2(X2,B2) [RXE] */ +gen_helper_tceb (cc, tmp, tmp2); +break ; +case 0x11 :/* TCDB R1,D2(X2,B2) [RXE] */ +gen_helper_tcdb (cc, tmp, tmp2); +break ; +case 0x12 :/* TCXB R1,D2(X2,B2) [RXE] */ +gen_helper_tcxb (cc, tmp, tmp2); +break ; +case 0x17 :/* MEEB R1,D2(X2,B2) [RXE] */ +gen_helper_meeb (tmp, tmp2); +break ; +case 0x19 :/* CDB R1,D2(X2,B2) [RXE] */ +gen_helper_cdb (cc, tmp, tmp2); +break ; +case 0x1a :/* ADB R1,D2(X2,B2) [RXE] */ +gen_helper_adb (cc, tmp, tmp2); +break ; +case 0x1b :/* SDB R1,D2(X2,B2) [RXE] */ +gen_helper_sdb (cc, tmp, tmp2); +break ;
target-s390x/translate.c line 858
Quoted 10 lines
target-s390x/translate.c new file +10
-0+case 0x1c :/* MDB R1,D2(X2,B2) [RXE] */ +gen_helper_mdb (tmp, tmp2); +break ; +case 0x1d :/* DDB R1,D2(X2,B2) [RXE] */ +gen_helper_ddb (tmp, tmp2); +break ; +case 0x1e :/* MADB R1,R3,D2(X2,B2) [RXF] */ +/* for RXF insns, r1 is R3 and r1b is R1 */ + tmp3 =tcg_const_i32 (r1b); +gen_helper_madb (tmp3, tmp2, tmp);
tmp3 should be freed after the helper.
target-s390x/translate.c line 868
Quoted 13 lines
target-s390x/translate.c new file +13
-0+break ; +default : +LOG_DISAS ("illegal ed operation 0x%x\n" , op); +gen_illegal_opcode (s); +break ; + } +tcg_temp_free (tmp); +tcg_temp_free (tmp2); +} +Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same.
target-s390x/translate.c
Quoted 11 lines
target-s390x/translate.c new file +11
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 17 lines
target-s390x/translate.c new file +17
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 15 lines
target-s390x/translate.c new file +15
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 16 lines
target-s390x/translate.c new file +16
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 19 lines
target-s390x/translate.c new file +19
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 25 lines
target-s390x/translate.c new file +25
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Comparison on TCGv type is not allowed.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same
target-s390x/translate.c
Quoted 6 lines
target-s390x/translate.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 6 lines
target-s390x/translate.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 6 lines
target-s390x/translate.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 20 lines
target-s390x/translate.c new file +20
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 9 lines
target-s390x/translate.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 12 lines
target-s390x/translate.c new file +12
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 13 lines
target-s390x/translate.c new file +13
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 23 lines
target-s390x/translate.c new file +23
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Comparison on TCGv type is not allowed.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
The three should be of type TCGv_i32 and not initialized to 0
target-s390x/translate.c
Quoted 47 lines
target-s390x/translate.c new file +47
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Comparison on TCGv type is not allowed.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
The three should be of type TCGv_i32 and not initialized to 0
target-s390x/translate.c
Quoted 61 lines
target-s390x/translate.c new file +61
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 61 lines
target-s390x/translate.c new file +61
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 13 lines
target-s390x/translate.c new file +13
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 43 lines
target-s390x/translate.c new file +43
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Comparison on TCGv type is not allowed.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
The variables should not be initialized to 0
target-s390x/translate.c
Quoted 12 lines
target-s390x/translate.c new file +12
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
coding style
target-s390x/translate.c
Quoted 6 lines
target-s390x/translate.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 29 lines
target-s390x/translate.c new file +29
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 12 lines
target-s390x/translate.c new file +12
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
coding style
target-s390x/translate.c
Quoted 12 lines
target-s390x/translate.c new file +12
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 40 lines
target-s390x/translate.c new file +40
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 10 lines
target-s390x/translate.c new file +10
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 9 lines
target-s390x/translate.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 19 lines
target-s390x/translate.c new file +19
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 17 lines
target-s390x/translate.c new file +17
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 14 lines
target-s390x/translate.c new file +14
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 18 lines
target-s390x/translate.c new file +18
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 10 lines
target-s390x/translate.c new file +10
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 10 lines
target-s390x/translate.c new file +10
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Comparison on TCGv type is not allowed.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
The variables should not be initialized to 0
target-s390x/translate.c
Quoted 3 lines
target-s390x/translate.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
That should be fixed before a merge.
target-s390x/translate.c
Quoted 11 lines
target-s390x/translate.c new file +11
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 20 lines
target-s390x/translate.c new file +20
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 1 line
target-s390x/translate.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 3 lines
target-s390x/translate.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 18 lines
target-s390x/translate.c new file +18
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Comparison on TCGv type is not allowed.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
The variables should not be initialized to 0
target-s390x/translate.c
Quoted 16 lines
target-s390x/translate.c new file +16
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 8 lines
target-s390x/translate.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 3 lines
target-s390x/translate.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCG type.
target-s390x/translate.c
Quoted 3 lines
target-s390x/translate.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 18 lines
target-s390x/translate.c new file +18
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 10 lines
target-s390x/translate.c new file +10
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Comparison on TCGv type is not allowed.
target-s390x/translate.c
Quoted 3 lines
target-s390x/translate.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Coding style.
target-s390x/translate.c
Quoted 1 line
target-s390x/translate.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Coding style.
target-s390x/translate.c
Quoted 11 lines
target-s390x/translate.c new file +11
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
The variables should not be initialized to 0
target-s390x/translate.c
Quoted 75 lines
target-s390x/translate.c new file +75
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 15 lines
target-s390x/translate.c new file +15
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 12 lines
target-s390x/translate.c new file +12
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 1 line
target-s390x/translate.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 20 lines
target-s390x/translate.c new file +20
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 11 lines
target-s390x/translate.c new file +11
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 11 lines
target-s390x/translate.c new file +11
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 35 lines
target-s390x/translate.c new file +35
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 15 lines
target-s390x/translate.c new file +15
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 8 lines
target-s390x/translate.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 10 lines
target-s390x/translate.c new file +10
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 16 lines
target-s390x/translate.c new file +16
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 13 lines
target-s390x/translate.c new file +13
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 9 lines
target-s390x/translate.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 1 line
target-s390x/translate.c new file +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 8 lines
target-s390x/translate.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 13 lines
target-s390x/translate.c new file +13
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 8 lines
target-s390x/translate.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 25 lines
target-s390x/translate.c new file +25
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 25 lines
target-s390x/translate.c new file +25
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 3 lines
target-s390x/translate.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
coding style
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 14 lines
target-s390x/translate.c new file +14
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 5 lines
target-s390x/translate.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 9 lines
target-s390x/translate.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 9 lines
target-s390x/translate.c new file +9
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 23 lines
target-s390x/translate.c new file +23
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 21 lines
target-s390x/translate.c new file +21
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 33 lines
target-s390x/translate.c new file +33
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 8 lines
target-s390x/translate.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 12 lines
target-s390x/translate.c new file +12
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 23 lines
target-s390x/translate.c new file +23
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 4 lines
target-s390x/translate.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 14 lines
target-s390x/translate.c new file +14
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 15 lines
target-s390x/translate.c new file +15
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Wrong TCGv type.
target-s390x/translate.c
Quoted 7 lines
target-s390x/translate.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Same comment as previous tcg_abort() one.
target-s390x/translate.c
Quoted 42 lines
target-s390x/translate.c new file +42
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Comparison on TCGv type is not allowed.
target-s390x/translate.c
Quoted 36 lines
target-s390x/translate.c new file +36
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Why this?
target-s390x/translate.c
Quoted 22 lines
target-s390x/translate.c new file +22
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
The also translation should be stopped if in singlestep mode (singlestep variable).
Quoted 59 lines
target-s390x/translate.c new file +53
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.2.1
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Part of the diff is not shown here. View the raw message.
Re: [Qemu-devel] [PATCH 2/9] S/390 CPU emulation
Quoted 8 lines · Aurelien Jarno
On Fri, Oct 16, 2009 at 02:38:48PM +0200, Ulrich Hecht wrote:
First of all a few general comments. Note that I know very few things about S390/S390X, so I may have dumb comments/questions. Also as the patch is very long, I probably have missed things, we should probably iterate with new versions of the patches.Is it possible given the current implementation to emulate S390 in addition to S390X?
Not as it stands. The S/390 instruction set is a subset of zArch (64-bit), but currently only 64-bit addressing is implemented (because that is the only mode used by 64-bit Linux binaries).
Quoted 1 line
If yes how different would be a S390 only target?
It would need support for 31-bit addressing. 24-bit, too, if you want to run the really old stuff.
Quoted 3 lines
If they won't be too different, it probably worth using
_tltype registers and call it target-s390. A bit the way it is done with i386/x86_64, ppc/ppc64, mips/mips64 or sparc/sparc64.
If it's going to be implemented, it will certainly share most code with the 64-bit target, so having a common directory would most likely be a good idea.
There are some cases where _tl types might be appropriate, but generally everything that is shared between S/390 and zArch is 32-bit, and instructions present in both architectures also have the same operand
size: L, for instance, is a 32-bit load to a 32-bit register on both architectures.
Quoted 6 lines
Secondly there seems to be a lot of mix between 32-bit and 64-bit TCG registers. They should not be mixed.
_i32ops apply toTCGv_i32variables,_i64ops apply toTCGv_i64variables, and_tlops to TGCv variables. TCGv/_tl types can map either to_i32or_i64depending on your target. You should try to build the target with --enable-debug-tcg
Er, reading the code and observing the behavior of the (AMD64) code generator, it seemed to me that neither frontends nor backends care one bit about that. I'll look into it, though. (I won't comment on those below, except in cases where the solution or, indeed, the problem is not clear to me.)
Quoted 3 lines
It would be nice to split all the disassembling part in a separate combined with the related makefile changes. This way it can be applied separately.
Can do.
Quoted 7 lines
Quoted 7 lines
// switch (
info->mach)
// {
// casebfd_mach_s390_31:s390-dis.c +1
-1- current_arch_mask =1 <<S390_OPCODE_ESA ; +// current_arch_mask = 1 << S390_OPCODE_ESA; // break; // case bfd_mach_s390_64:
Quoted 8 lines
s390-dis.c init_disasm (struct disassemble_info *info) · line 200
Quoted 5 lines
s390-dis.c +1
-1-// current_arch_mask = 1 << S390_OPCODE_ZARCH; + current_arch_mask =1 <<S390_OPCODE_ZARCH ;// break; // default: // abort (); While I understand the second part, Why is it necessary to comment the
bfd_mach_s390_31case?
It's not necessary, but current_arch_mask can only hold one value...
Quoted 8 lines
Quoted 8 lines
target-s390x/cpu.h new file +8
-0+typedef union FPReg { + struct { +#ifdef WORDS_BIGENDIAN + float32 e; + int32_t __pad; +#else + int32_t __pad; + float32 e;
Quoted 8 lines
target-s390x/cpu.h line 48
Quoted 5 lines
target-s390x/cpu.h new file +5
-0+#endif + }; +float64 d; +uint64_t i; +} FPReg;
WORDS_BIGENDIANis wrong here. It should probably beHOST_WORDS_BIGENDIAN.
Indeed.
Quoted 2 lines
Also it may be a better idea to
reuseCPU_FloatUandCPU_DoubleUhere.
Yes. Didn't know about those.
Quoted 4 lines
Quoted 1 line
+CPUS390XState *cpu_s390x_init(const char
*cpu_model)This function would probably be better in
translate.c, so thats390x_translate_init()can be declared static.
I'll check that.
Quoted 1 line
Please use /* */ for comments (See
CODING_STYLE).
OK.
Quoted 3 lines
Quoted 1 line
+ /* FIXME: reset vector? */
Yes, reset vector, MMU mode, default register values, ...
Works perfectly fine without. ;)
Also, the question remains what kind of reset cpu_reset() is supposed to be. For instance, a CPU Reset or Initial CPU Reset on S/390 leaves the general-purpose registers unchanged, a Clear Reset or Power-On Reset sets them to zero. See the table on p. 4-50 in the zArchitecture Principles of Operation (POP),
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/download/A2278324.pdf,
for the gory details.
Quoted 10 lines
target-s390x/op_helper.c line 30
Quoted 6 lines
target-s390x/op_helper.c new file +6
-0+//#define DEBUG_HELPER +#ifdef DEBUG_HELPER +#define HELPER_LOG(x...) qemu_log(x) +#else +#define HELPER_LOG(x...) +#endif Small comment for the rest of the file. While I understand
HELPER_LOGis very handy while developing, I think some calls to it can be dropped in really simple functions.
Yes, a bit of cleanup will be in order.
Quoted 5 lines
target-s390x/op_helper.c line 51
Quoted 3 lines
target-s390x/op_helper.c new file +3
-0+for (i =0 ; i <= l; i++) { + x =ldub (dest + i) &ldub (src + i); +if (x) cc =1 ;coding style
Maybe you are referring to "Every indented statement is braced; even if the block contains just one statement.", but I figured that that does not apply here because there is no indentation...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (v < 0) return 1; + else if (v > 0) return 2;coding style
Same here.
Quoted 3 lines
The last 6 helpers can probably be coded easily in TCG (they are very similar to some PowerPC code), though merging this patch with the helpers is not a problem at all.
Again, that would be detrimental to performance. I have experimented with that and found that TCG is well capable of optimizing out a pure helper call, but not a complex piece of code with branches. Condition codes are not used most times, and the overhead of calling a helper in the cases they are is far smaller than doing all the condition code stuff that is not used. Also reduces code size.
Quoted 2 lines
All the branch part would really gain to be coded in TCG, as it will allow TB chaining.
I vaguely remember trying that as well, but I don't know if I gave up on it because it was slower, or because I couldn't get it to work...
Quoted 4 lines
target-s390x/op_helper.c line 347
Quoted 2 lines
target-s390x/op_helper.c new file +2
-0+ } +else if (r > d) {coding style
OK, this one is valid. :)
Quoted 1 line
__uint128_tis probably not supported on all hosts/GCC versions.
Definitely does not work on 32-bit hosts.
Quoted 1 line
mulu64()should be used instead.
Excellent, didn't know about that either.
Quoted 2 lines
Same here,
__uint128_tshould not be used, though I don't know what should be used instead.
Hmmmm...
Quoted 8 lines
Quoted 8 lines
target-s390x/op_helper.c new file +8
-0+/* unsigned string compare (c is string terminator) */ +uint32_t HELPER (clst )(uint32_t c,uint32_t r1,uint32_t r2) +{ +uint64_t s1 = env->regs[r1]; +uint64_t s2 = env->regs[r2]; +uint8_t v1, v2; +uint32_t cc; + c = c &0xff ;
Quoted 8 lines
target-s390x/op_helper.c line 539
Quoted 6 lines
target-s390x/op_helper.c new file +6
-0+#ifdef CONFIG_USER_ONLY +if (!c) { +HELPER_LOG ("%s: comparing '%s' and '%s'\n" , + __FUNCTION__, (char *)s1, (char *)s2); + } +#endif Why
CONFIG_USER_ONLY?
s1 and s2 are target addresses and not valid on the host system in the SOFTMMU case, so this would segfault.
Quoted 7 lines
Quoted 7 lines
+/* union used for splitting/joining 128-bit floats to/from 64-bit FP regs */ +typedef union {
target-s390x/op_helper.c new file +5
-0+struct { +#ifdef WORDS_BIGENDIAN +uint64_t h; +uint64_t l; +#else
Quoted 8 lines
target-s390x/op_helper.c line 978
Quoted 6 lines
target-s390x/op_helper.c new file +6
-0+uint64_t l; +uint64_t h; +#endif + }; +float128 x; +}FP128 ;
WORDS_BIGENDIANis wrong here.CPU_QuadUcan probably be used instead.
Agree.
Quoted 8 lines
target-s390x/op_helper.c line 1198
Quoted 6 lines
target-s390x/op_helper.c new file +6
-0+if (float32_is_neg (v2)) { + v1 =float32_abs (v2); + } +else { + v1 = v2; + }I don't see the point of such a test here.
Now that you mention it, I don't really see it either.
Quoted 4 lines
Quoted 1 line
+ v2.i = ldl(a2);
The value should be passed directly instead of loaded here, as ldl is is wrong depending on the MMU mode.
Yup.
Quoted 3 lines
Quoted 1 line
+#ifdef
WORDS_BIGENDIANThis is wrong. It should probably be
HOST_WORDS_BIGENDIAN.
I concur.
Quoted 7 lines
Quoted 7 lines
target-s390x/translate.c new file +7
-0+static TCGv load_reg (int reg) +{ +TCGv r =tcg_temp_new_i64 (); +#ifdef TCGREGS +sync_reg32 (reg); +tcg_gen_mov_i64 (r, tcgregs[reg]); +return r;
Quoted 8 lines
target-s390x/translate.c line 129
Quoted 5 lines
target-s390x/translate.c new file +5
-0+#else + tcg_gen_ld_i64(r, cpu_env, offsetof(CPUState, regs[reg])); +return r; +#endif +}I don't really like implicit TCGv temp allocation. In other targets it often has caused missing
tcg_temp_free().
I did in fact run into problems with this and was thus forced to make sure that no tcg_temp_free()s are missing... :)
Quoted 2 lines
It should probably be
rewritten asload_reg(TCGv t, int reg).
Later. This is the kind of change that you never get right on the first try, so I'd like to do that after everything went upstream.
Quoted 2 lines
For all register load/store, as already explained in the TCG sync op patch, I am in favor of using the ld/st version (TCGREGS not defined).
It doesn't perform.
Quoted 6 lines
target-s390x/translate.c line 220
Quoted 4 lines
target-s390x/translate.c new file +4
-0+static void gen_illegal_opcode (DisasContext *s) +{ +TCGv tmp =tcg_temp_new_i64 (); +tcg_gen_movi_i64 (tmp,42 );
tcg_const_i64could be used instead.
Yes. Using the actual value for a specification exception instead of 42 might be a good idea as well. :)
Quoted 4 lines
Quoted 2 lines
+
gen_helper_exception(tmp);Missing
tcg_temp_free_i64(tmp);
OK, so I missed _that_ one. Fine. Be like that if you want to. Illegal instructions are not that frequent anyway...
Quoted 3 lines
Quoted 1 line
+
gen_helper_cmp_s32(cc, v1, tcg_const_i32(v2));The TCG passed to the helper should be freed.
And that one...
Quoted 3 lines
Quoted 1 line
+
gen_helper_cmp_u32(cc, v1, tcg_const_i32(v2));Same.
And that one... :(
Quoted 3 lines
Quoted 1 line
+
gen_helper_cmp_s64(cc, v1, tcg_const_i64(v2));Same
And that one... :((
Quoted 3 lines
Quoted 1 line
+
gen_helper_cmp_u64(cc, v1, tcg_const_i64(v2));Same
And that one... :(((
Quoted 2 lines
The branches should be handled using brcond and
goto_tbandexit_tband not with helpers, to allow TB chaining.
I'll look into that, but I guess it's not entirely trivial.
Quoted 4 lines
Quoted 1 line
+ TCGv tmp = 0, tmp2 = 0, tmp3 = 0;
This is wrong. 0 maps to global 0 (env in your case). -1 should be used instead, or even better the
TCGV_UNUSEDmacro.
OK.
Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ case 0x12: /* LT R1,D2(X2,B2) [RXY] */ + tmp2 = tcg_temp_new_i32();Wrong TCGv type.
Quoted 1 line
+
tcg_gen_qemu_ld32s(tmp2, tmp, 1);
tcg_gen_qemu_ld32sloads a 32 bit value in the default size register, that is 64-bit here.
Actually, this a purely 32-bit insn, so it should be tcg_gen_qemu_ld32() in the first place.
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ tcg_gen_qemu_ld32s(tmp2, tmp, 1); + tcg_gen_ext32s_i64(tmp2, tmp2);The sign extension is already done by
qemu_ld32s
Just to be on the safe side. :)
Quoted 8 lines
Quoted 4 lines
(quoted diff) +2
-0+ switch (op) { + case 0x8: case 0x18: gen_set_cc_add64(tmp, tmp2, tmp3);break; + case
0xa: case0x1a: gen_helper_set_cc_addu64(cc,
tmp, tmp2, tmp3); break; + default:tcg_abort();
tcg_abort()is wrong here, it is for internal TCG use. Also all the real CPU it probably launch an illegal instruction exception, it does not power off the machin.
Actually, if default is reached here there's an error in the translator (it should only get here in the explicit cases), so I'd consider tcg_abort() appropriate.
Quoted 11 lines
target-s390x/translate.c line 478
Quoted 2 lines
target-s390x/translate.c new file +2
-0+case 0x1e :/* LRV R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i32 ();Wrong TCGv type;
Review
Quoted 2 lines
(quoted diff) +2
-0+ tcg_gen_qemu_ld32u(tmp2, tmp, 1); + tcg_gen_bswap32_i32(tmp2, tmp2);Wrong TCGv type;
Quoted 1 line
+
store_reg(r1, tmp2);
This is more wrong than you think, because this is a 32-bit insn, so it shouldn't overwrite the top 32 bits. Rarely used, I guess that's how it could slip through.
Quoted 6 lines
target-s390x/translate.c line 518
Quoted 4 lines
target-s390x/translate.c new file +4
-0+case 0x3e :/* STRV R1,D2(X2,B2) [RXY] */ + tmp2 =load_reg32 (r1); +tcg_gen_bswap32_i32 (tmp2, tmp2); +tcg_gen_qemu_st32 (tmp2, tmp,1 );Wrong TCGv type.
What's wrong here? Everything's 32-bit.
Quoted 9 lines
target-s390x/translate.c line 530
Quoted 7 lines
target-s390x/translate.c new file +7
-0+case 0x57 :/* XY R1,D2(X2,B2) [RXY] */ + tmp2 =load_reg32 (r1); + tmp3 =tcg_temp_new_i32 (); +tcg_gen_qemu_ld32u (tmp3, tmp,1 ); +tcg_gen_xor_i32 (tmp, tmp2, tmp3); +store_reg32 (r1, tmp); +set_cc_nz_u32 (tmp);Wrong TCGv type.
No need to zero-extend anyway, it's a 32-bit insn.
Quoted 8 lines
target-s390x/translate.c line 572
Quoted 7 lines
target-s390x/translate.c new file +7
-0+case 0x76 :/* LB R1,D2(X2,B2) [RXY] */ +case 0x77 :/* LGB R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld8s (tmp2, tmp,1 ); +switch (op) { +case 0x76 : +tcg_gen_ext8s_i32 (tmp2, tmp2);
Quoted 8 lines
Wrong TCGv type.
target-s390x/translate.c line 576
Quoted 4 lines
target-s390x/translate.c new file +4
-0+store_reg32 (r1, tmp2); +break ; +case 0x77 : +tcg_gen_ext8s_i64 (tmp2, tmp2);Wrong TCGv type.
The way I see it, there are only 32-bit and 64-bit types, so it can only be wrong in one case, right?
Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ case 0x78: /* LHY R1,D2(X2,B2) [RXY] */ + tmp2 = tcg_temp_new_i32();Wrong TCGv type.
Quoted 4 lines
target-s390x/translate.c new file +4
-0+tcg_gen_qemu_ld16s (tmp2, tmp,1 ); +tcg_gen_ext16s_i32 (tmp2, tmp2); +store_reg32 (r1, tmp2); +break ;
Replacing that tcg_gen_qemu_ld16s() with tcg_gen_qemu_ld16() should do it, right?
Quoted 8 lines
target-s390x/translate.c line 606
Quoted 4 lines
target-s390x/translate.c new file +4
-0+case 0x86 :/* MLG R1,D2(X2,B2) [RXY] */ + tmp2 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld64 (tmp2, tmp,1 ); + tmp =tcg_const_i32 (r1);Wrong TCGv type.
Quoted 1 line
+
gen_helper_mlg(tmp, tmp2);
Huh? It's a register number. There are only 16 GP registers. Fits a 32-bit value, last time I checked. The helper also expects a 32-bit value.
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (tmp2) tcg_temp_free(tmp2); + if (tmp3) tcg_temp_free(tmp3);Comparison on TCGv type is not allowed.
Not even to TCGV_UNUSED?
Quoted 6 lines
Quoted 3 lines
+static void
disas_ed(DisasContext *s, int op, int r1, int x2, int b2, int d2, int r1b)+{
+ TCGv tmp, tmp2, tmp3 = 0;tmp should be declared as
TGV_i32here, so that the types are correct for the whole function. Also tmp3 should not be initialized to 0.
OK.
Quoted 3 lines
Quoted 1 line
+
gen_helper_madb(tmp3, tmp2, tmp);tmp3 should be freed after the helper.
Yup.
Quoted 5 lines
target-s390x/translate.c line 1591
Quoted 3 lines
target-s390x/translate.c new file +3
-0+LOG_DISAS ("disas_c0: op 0x%x r1 %d i2 %d\n" , op, r1, i2); +uint64_t target = s->pc + i2 *2 ; +/* FIXME: huh? */ target &=0xffffffff ;That should be fixed before a merge.
Tricky, because I have not yet understood why it is necessary. According to the POP, the address calculation in 64-bit addressing mode should be 64 bits. In practice, on a real machine running a real Linux kernel, it wraps around at 32 bits, and userland code actually relies on that. No clue what I could be missing here...
Quoted 4 lines
Quoted 2 lines
+static inline
uint64_tld_code2(uint64_t pc){ return (uint64_t)lduw_code(pc); }Coding style.
OK.
Quoted 8 lines
target-s390x/translate.c line 2404
Quoted 6 lines
target-s390x/translate.c new file +6
-0+#if 1 + cc =tcg_temp_local_new_i32 (); +tcg_gen_mov_i32 (cc, global_cc); +#else + cc = global_cc; +#endif Why this?
Because it didn't work otherwise. I don't claim to understand the mysterious ways of the TCG to its full extent...
Quoted 5 lines
Quoted 2 lines
+ } while (!dc.is_jmp &&
gen_opc_ptr<gen_opc_end&& dc.pc <next_page_start&&num_insns<max_insns);The also translation should be stopped if in singlestep mode (singlestep variable).
OK.
Phew, that was a big one. :)
Thanks for reviewing. I'll fix what makes sense to me and send a new one when I'm done.
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 2/9] S/390 CPU emulation
Quoted 27 lines · Ulrich Hecht
Quoted 8 lines · Aurelien Jarno
On Fri, Oct 16, 2009 at 02:38:48PM +0200, Ulrich Hecht wrote:
First of all a few general comments. Note that I know very few things about S390/S390X, so I may have dumb comments/questions. Also as the patch is very long, I probably have missed things, we should probably iterate with new versions of the patches.Is it possible given the current implementation to emulate S390 in addition to S390X?
Not as it stands. The S/390 instruction set is a subset of zArch (64-bit), but currently only 64-bit addressing is implemented (because that is the only mode used by 64-bit Linux binaries).
Quoted 1 line
If yes how different would be a S390 only target?
It would need support for 31-bit addressing. 24-bit, too, if you want to run the really old stuff.
Quoted 3 lines
If they won't be too different, it probably worth using
_tltype registers and call it target-s390. A bit the way it is done with i386/x86_64, ppc/ppc64, mips/mips64 or sparc/sparc64.If it's going to be implemented, it will certainly share most code with the 64-bit target, so having a common directory would most likely be a good idea.
Quoted 5 lines
There are some cases where
_tltypes might be appropriate, but generally everything that is shared between S/390 and zArch is 32-bit, and instructions present in both architectures also have the same operand
size: L, for instance, is a 32-bit load to a 32-bit register on both architectures.
Ok, so I think we should go for putting the code is the target-s390 directory. As no code is shared for now, we can just ignore the _tl stuff.
Quoted 7 lines
Quoted 6 lines
Secondly there seems to be a lot of mix between 32-bit and 64-bit TCG registers. They should not be mixed.
_i32ops apply toTCGv_i32variables,_i64ops apply toTCGv_i64variables, and_tlops to TGCv variables. TCGv/_tl types can map either to_i32or_i64depending on your target. You should try to build the target with --enable-debug-tcg
Quoted 5 lines
Er, reading the code and observing the behavior of the (AMD64) code generator, it seemed to me that neither frontends nor backends care one bit about that. I'll look into it, though. (I won't comment on those below, except in cases where the solution or, indeed, the problem is not clear to me.)
It is not strictly needed on AMD64, because a move between 32- and 64- bit registers also zero extends the value. It is definitely needs on other hosts (and most probably s390x as I understand).
Quoted 22 lines
Quoted 3 lines
It would be nice to split all the disassembling part in a separate combined with the related makefile changes. This way it can be applied separately.
Can do.
Quoted 7 lines
Quoted 7 lines
// switch (
info->mach)
// {
// casebfd_mach_s390_31:s390-dis.c +1
-1- current_arch_mask =1 <<S390_OPCODE_ESA ; +// current_arch_mask = 1 << S390_OPCODE_ESA; // break; // case bfd_mach_s390_64: Quoted 8 lines
s390-dis.c init_disasm (struct disassemble_info *info) · line 200
Quoted 5 lines
s390-dis.c +1
-1-// current_arch_mask = 1 << S390_OPCODE_ZARCH; + current_arch_mask =1 <<S390_OPCODE_ZARCH ;// break; // default: // abort (); While I understand the second part, Why is it necessary to comment the
bfd_mach_s390_31case?
Quoted 1 line
It's not necessary, but
current_arch_maskcan only hold one value...
I'll answer in the new version of the patch.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
+ /* FIXME: reset vector? */
Yes, reset vector, MMU mode, default register values, ...
Works perfectly fine without. ;)
Quoted 7 lines
Also, the question remains what kind of reset
cpu_reset()is supposed to be. For instance, a CPU Reset or Initial CPU Reset on S/390 leaves the general-purpose registers unchanged, a Clear Reset or Power-On Reset sets them to zero. See the table on p. 4-50 in the zArchitecture Principles of Operation (POP),
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/download/A2278324.pdf,
for the gory details.
I don't know what is the best, probably a CPU Reset is enough. Just consider that as the code that will be run if someone press the reset button.
Quoted 9 lines
Quoted 5 lines
target-s390x/op_helper.c line 51
Quoted 3 lines
target-s390x/op_helper.c new file +3
-0+for (i =0 ; i <= l; i++) { + x =ldub (dest + i) &ldub (src + i); +if (x) cc =1 ;coding style
Maybe you are referring to "Every indented statement is braced; even if the block contains just one statement.", but I figured that that does not apply here because there is no indentation...
You are basically trying to workaround the coding style. The idea behind it is to write:
if (x) {
cc = 1;
}Quoted 5 lines
Quoted 2 lines
All the branch part would really gain to be coded in TCG, as it will allow TB chaining.
I vaguely remember trying that as well, but I don't know if I gave up on it because it was slower, or because I couldn't get it to work...
Probably the second. Changing the instruction pointer in the helper instead of using the proper goto_tb TCG op prevents TB chaining, and therefore as a huge impact on performance.
It's something not difficult to implement, and that I would definitely want to see in the patch before getting it merged.
Quoted 5 lines
Quoted 2 lines
It should probably be
rewritten asload_reg(TCGv t, int reg).Later. This is the kind of change that you never get right on the first try, so I'd like to do that after everything went upstream.
It also means huge patch difficult to review when it is done after the initial merge, as they need to be checked within the context.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
+ tmp =
tcg_const_i32(r1);Wrong TCGv type.
Quoted 1 line
+
gen_helper_mlg(tmp, tmp2);Huh? It's a register number. There are only 16 GP registers. Fits a 32-bit value, last time I checked. The helper also expects a 32-bit value.
Then a TCGv_i32 variable should be used. TCGv is 64-bit, as the whole target is 64-bit.
Quoted 6 lines
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (tmp2) tcg_temp_free(tmp2); + if (tmp3) tcg_temp_free(tmp3);Comparison on TCGv type is not allowed.
Not even to
TCGV_UNUSED?
TCGV_UNUSED() is a macro to set the value, not to retrieve it.
Quoted 11 lines
Quoted 5 lines
target-s390x/translate.c line 1591
Quoted 3 lines
target-s390x/translate.c new file +3
-0+LOG_DISAS ("disas_c0: op 0x%x r1 %d i2 %d\n" , op, r1, i2); +uint64_t target = s->pc + i2 *2 ; +/* FIXME: huh? */ target &=0xffffffff ;That should be fixed before a merge.
Tricky, because I have not yet understood why it is necessary. According to the POP, the address calculation in 64-bit addressing mode should be 64 bits. In practice, on a real machine running a real Linux kernel, it wraps around at 32 bits, and userland code actually relies on that. No clue what I could be missing here...
Does it means the userspace is actually limited to 32-bit addressing?
Quoted 11 lines
Quoted 8 lines
target-s390x/translate.c line 2404
Quoted 6 lines
target-s390x/translate.c new file +6
-0+#if 1 + cc =tcg_temp_local_new_i32 (); +tcg_gen_mov_i32 (cc, global_cc); +#else + cc = global_cc; +#endif Why this?
Because it didn't work otherwise. I don't claim to understand the mysterious ways of the TCG to its full extent...
What do you mean by didn't work? TCG error? Wrong emulation? Something else?
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 2/9] S/390 CPU emulation
Quoted 6 lines · Aurelien Jarno
Probably the second. Changing the instruction pointer in the helper instead of using the proper
goto_tbTCG op prevents TB chaining, and therefore as a huge impact on performance.It's something not difficult to implement, and that I would definitely want to see in the patch before getting it merged.
OK, I implemented it, and the surprising result is that performance does not get any better; in fact it even suffers a little bit. (My standard quick test, the polarssl test suite, shows about a 2% performance impact when profiled with cachegrind).
Could there be anything I overlooked? I modelled my implementation after those in the existing targets. (See the attached patch that goes on top of my other S/390 patches.)
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
target-s390/helpers.h +0 -1
@@ -15,7 +15,6 @@ DEF_HELPER_FLAGS_1(set_cc_comp_s64, TCG_CALL_PURE|TCG_CALL_CONST, i32, s64) DEF_HELPER_FLAGS_1(set_cc_nz_u32, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32) DEF_HELPER_FLAGS_1(set_cc_nz_u64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64) DEF_HELPER_FLAGS_2(set_cc_icm, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32) -DEF_HELPER_4(brc, void, i32, i32, i64, s32) DEF_HELPER_3(brctg, void, i64, i64, s32) DEF_HELPER_3(brct, void, i32, i64, s32)DEF_HELPER_4 (brcl, void, i32, i32, i64, s64)
target-s390/op_helper.c +0 -11
@@ -218,17 +218,6 @@ uint32_t HELPER(set_cc_icm)(uint32_t mask, uint32_t val)return cc; } -/* relative conditional branch */ -void HELPER (brc )(uint32_t cc,uint32_t mask,uint64_t pc,int32_t offset) -{ -if ( mask & (1 << (3 - cc) ) ) { - env->psw.addr = pc + offset; - } -else { - env->psw.addr = pc +4 ; - } -} -/* branch relative on 64-bit count (condition is computed inline, this only does the branch */ void HELPER (brctg )(uint64_t flag,uint64_t pc,int32_t offset)
target-s390/translate.c +54 -17
113 lines not on this page · raw message
Re: [Qemu-devel] [PATCH 2/9] S/390 CPU emulation
Quoted 5 lines · Ulrich Hecht
Quoted 4 lines · Aurelien Jarno
Probably the second. Changing the instruction pointer in the helper instead of using the proper
goto_tbTCG op prevents TB chaining, and therefore as a huge impact on performance.
Quoted 7 lines
Quoted 2 lines
It's something not difficult to implement, and that I would definitely want to see in the patch before getting it merged.
OK, I implemented it, and the surprising result is that performance does not get any better; in fact it even suffers a little bit. (My standard quick test, the polarssl test suite, shows about a 2% performance impact when profiled with cachegrind).
That looks really strange, as TB chaining clearly reduce the number of instructions to execute, by not have to lookup for the TB after each branch. Also using a brcond instead of a helper should change nothing as it is located at the end of the TB, where all the globals must be saved in anyway.
Also a recent bug found on ARM host with regard to TB chaining has shown it can gives a noticeably speed gain.
On what host are you doing your benchmarks?
Quoted 4 lines
Could there be anything I overlooked? I modelled my implementation after those in the existing targets. (See the attached patch that goes on top of my other S/390 patches.)
Your patch looks good overall, I have minor comments (see below), but nothing that should improve the speed noticeably.
Quoted 54 lines
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)target-s390/helpers.h +0
-1@@ -15,7 +15,6 @@ DEF_HELPER_FLAGS_1(set_cc_comp_s64, TCG_CALL_PURE|TCG_CALL_CONST, i32, s64) DEF_HELPER_FLAGS_1(set_cc_nz_u32, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32) DEF_HELPER_FLAGS_1(set_cc_nz_u64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64) DEF_HELPER_FLAGS_2(set_cc_icm, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32) -DEF_HELPER_4(brc, void, i32, i32, i64, s32) DEF_HELPER_3(brctg, void, i64, i64, s32) DEF_HELPER_3(brct, void, i32, i64, s32)DEF_HELPER_4 (brcl, void, i32, i32, i64, s64)target-s390/op_helper.c +0
-11@@ -218,17 +218,6 @@ uint32_t HELPER(set_cc_icm)(uint32_t mask, uint32_t val)return cc; } -/* relative conditional branch */ -void HELPER (brc )(uint32_t cc,uint32_t mask,uint64_t pc,int32_t offset) -{ -if ( mask & (1 << (3 - cc) ) ) { - env->psw.addr = pc + offset; - } -else { - env->psw.addr = pc +4 ; - } -} -/* branch relative on 64-bit count (condition is computed inline, this only does the branch */ void HELPER (brctg )(uint64_t flag,uint64_t pc,int32_t offset)target-s390/translate.c +1
-1@@ -49,6 +49,7 @@ struct DisasContext {uint64_t pc;int is_jmp;CPUS390XState *env; +struct TranslationBlock *tb; };#define DISAS_EXCP 4@@ -359,23 +360,55 @@ static void gen_bcr(uint32_t mask, int tr, uint64_t offset)tcg_temp_free (target); } -static void gen_brc (uint32_t mask,uint64_t pc,int32_t offset)
target-s390/translate.c static void gen_bcr(uint32_t mask, int tr, uint64_t offset) · line 370
Quoted 10 lines
target-s390/translate.c +7
-2+static inline void gen_goto_tb (DisasContext *s,int tb_num,target_ulong pc) { -TCGv p; -TCGv_i32 m, o; +TranslationBlock *tb; + + tb = s->tb; +/* NOTE: we handle the case where the TB spans two pages here */ +if ((pc &TARGET_PAGE_MASK ) == (tb->pc &TARGET_PAGE_MASK ) || + (pc &TARGET_PAGE_MASK ) == ((s->pc -1 ) &TARGET_PAGE_MASK )) {
I have difficulties to figure out why the second comparison is needed. I know it comes from target-i386, but on the other hand it is not present in other targets.
Quoted 36 lines
target-s390/translate.c +24
-8+/* jump to same page: we can use a direct jump */ +tcg_gen_mov_i32 (global_cc, cc); +tcg_gen_goto_tb (tb_num); +tcg_gen_movi_i64 (psw_addr, pc); +tcg_gen_exit_tb ((long )tb + tb_num); + }else { +/* jump to another page: currently not optimized */ +tcg_gen_movi_i64 (psw_addr, pc); +tcg_gen_mov_i32 (global_cc, cc); +tcg_gen_exit_tb (0 ); + } +} + +static void gen_brc (uint32_t mask,DisasContext *s,int32_t offset) +{ +TCGv_i32 r; +TCGv_i32 tmp, tmp2; +int skip;if (mask ==0xf ) {/* unconditional */ -tcg_gen_movi_i64 (psw_addr, pc + offset); +//tcg_gen_movi_i64(psw_addr, s->pc + offset); +gen_goto_tb (s,0 , s->pc + offset); }else { - m =tcg_const_i32 (mask); - p =tcg_const_i64 (pc); - o =tcg_const_i32 (offset); -gen_helper_brc (cc, m, p, o); -tcg_temp_free (m); -tcg_temp_free (p); -tcg_temp_free (o); + tmp =tcg_const_i32 (3 ); +tcg_gen_sub_i32 (tmp, tmp, cc);/* 3 - cc */ + tmp2 =tcg_const_i32 (1 ); +tcg_gen_shl_i32 (tmp2, tmp2, tmp);/* 1 << (3 - cc) */
target-s390/translate.c static void gen_bcr(uint32_t mask, int tr, uint64_t offset) · line 408
Quoted 10 lines
target-s390/translate.c +10
-0+ r =tcg_const_i32 (mask); +tcg_gen_and_i32 (r, r, tmp2);/* mask & (1 << (3 - cc)) */ +tcg_temp_free (tmp); +tcg_temp_free (tmp2); + skip =gen_new_label (); +tcg_gen_brcondi_i32 (TCG_COND_EQ , r,0 , skip); +gen_goto_tb (s,0 , s->pc + offset); +gen_set_label (skip); +gen_goto_tb (s,1 , s->pc +4 ); +tcg_gen_mov_i32 (global_cc, cc);
This is probably not needed as this is already done in gen_goto_tb().
Quoted 50 lines
target-s390/translate.c +12
-6+tcg_temp_free (r); } + s->is_jmp =DISAS_TB_JUMP ; }static void gen_set_cc_add64 (TCGv v1,TCGv v2,TCGv vr)@@ -1143,9 +1176,7 @@ static void disas_a7(DisasContext *s, int op, int r1, int i2)tcg_temp_free (tmp2);break ;case 0x4 :/* brc m1, i2 */ -/* FIXME: optimize m1 == 0xf (unconditional) case */ -gen_brc (r1, s->pc, i2 *2 ); - s->is_jmp =DISAS_JUMP ; +gen_brc (r1, s, i2 *2 );return ;case 0x5 :/* BRAS R1,I2 [RI] */ tmp =tcg_const_i64 (s->pc +4 );@@ -2739,6 +2770,7 @@ static inline void gen_intermediate_code_internal (CPUState *env, dc.env = env; dc.pc = pc_start; dc.is_jmp =DISAS_NEXT ; + dc.tb = tb; gen_opc_end = gen_opc_buf +OPC_MAX_SIZE ;@@ -2778,8 +2810,11 @@ static inline void gen_intermediate_code_internal (CPUState *env, num_insns++; }while (!dc.is_jmp && gen_opc_ptr < gen_opc_end && dc.pc < next_page_start && num_insns < max_insns && !env->singlestep_enabled); -tcg_gen_mov_i32 (global_cc, cc); -tcg_temp_free (cc); + +if (dc.is_jmp !=DISAS_TB_JUMP ) { +tcg_gen_mov_i32 (global_cc, cc); +tcg_temp_free (cc); + }if (!dc.is_jmp) { tcg_gen_st_i64(tcg_const_i64(dc.pc), cpu_env, offsetof(CPUState, psw.addr));@@ -2794,7 +2829,9 @@ static inline void gen_intermediate_code_internal (CPUState *env,if (tb->cflags &CF_LAST_IO )gen_io_end ();/* Generate the return instruction */ -tcg_gen_exit_tb (0 ); +if (dc.is_jmp !=DISAS_TB_JUMP ) { +tcg_gen_exit_tb (0 ); + }gen_icount_end (tb, num_insns); *gen_opc_ptr = INDEX_op_end;if (search_pc) {
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 2/9] S/390 CPU emulation
Quoted 14 lines · Aurelien Jarno
Quoted 5 lines · Ulrich Hecht
Quoted 4 lines · Aurelien Jarno
Probably the second. Changing the instruction pointer in the helper instead of using the proper
goto_tbTCG op prevents TB chaining, and therefore as a huge impact on performance.Quoted 7 lines
Quoted 2 lines
It's something not difficult to implement, and that I would definitely want to see in the patch before getting it merged.
OK, I implemented it, and the surprising result is that performance does not get any better; in fact it even suffers a little bit. (My standard quick test, the polarssl test suite, shows about a 2% performance impact when profiled with cachegrind).
Quoted 8 lines
That looks really strange, as TB chaining clearly reduce the number of instructions to execute, by not have to lookup for the TB after each branch. Also using a brcond instead of a helper should change nothing as it is located at the end of the TB, where all the globals must be saved in anyway.
Also a recent bug found on ARM host with regard to TB chaining has shown it can gives a noticeably speed gain.
That indeed looks strange: fixing the TB chaining on ARM made nbench i386 three times faster. Note the gain was less for FP parts of the benchmark due to the use of helpers.
Ulrich,
out of curiosity could you post your tb_set_jmp_target1 function? The only thing I can think of at the moment that could make the code slower is that the program you ran was not reusing blocks and/or cache flushing in tb_set_jmp_target1 is overkill.
Laurent
Re: [Qemu-devel] [PATCH 2/9] S/390 CPU emulation
Quoted 7 lines · Laurent Desnogues
That indeed looks strange: fixing the TB chaining on ARM made nbench i386 three times faster. Note the gain was less for FP parts of the benchmark due to the use of helpers.
out of curiosity could you post your
tb_set_jmp_target1function?
I'm on an AMD64 host, so it's the same code as in mainline.
Quoted 4 lines
The only thing I can think of at the moment that could make the code slower is that the program you ran was not reusing blocks and/or cache flushing in
tb_set_jmp_target1is overkill.
There is no cache flushing in the AMD64 tb_set_jmp_target1() function, and the polarssl test suite is by nature rather repetitive.
I did some experiments, and it seems disabling the TB chaining (by emptying tb_set_jmp_target()) does not have any impact on performance at all on AMD64. I tested it with several CPU-intensive programs (md5sum and the like) with AMD64 on AMD64 userspace emulation (qemu-x86_64), and the difference in performance with TB chaining and without is hardly measurable. The chaining is performed as advertised if enabled, I checked that, but it does not seem to help performance.
How is this possible? Could this be related to cache size? I suspect the Phenom 9500 of mine is better equipped in that area than the average ARM controller.
And does the TB chaining actually work on AMD64 at all? I checked by adding some debug output, and it seems to patch the jumps correctly, but maybe somebody can verify that.
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 2/9] S/390 CPU emulation
Quoted 19 lines · Ulrich Hecht
Quoted 7 lines · Laurent Desnogues
That indeed looks strange: fixing the TB chaining on ARM made nbench i386 three times faster. Note the gain was less for FP parts of the benchmark due to the use of helpers.
out of curiosity could you post your
tb_set_jmp_target1function?I'm on an AMD64 host, so it's the same code as in mainline.
Quoted 4 lines
The only thing I can think of at the moment that could make the code slower is that the program you ran was not reusing blocks and/or cache flushing in
tb_set_jmp_target1is overkill.There is no cache flushing in the AMD64
tb_set_jmp_target1()function, and the polarssl test suite is by nature rather repetitive.
Quoted 7 lines
I did some experiments, and it seems disabling the TB chaining (by emptying
tb_set_jmp_target()) does not have any impact on performance at all on AMD64. I tested it with several CPU-intensive programs (md5sum and the like) with AMD64 on AMD64 userspace emulation (qemu-x86_64), and the difference in performance with TB chaining and without is hardly measurable. The chaining is performed as advertised if enabled, I checked that, but it does not seem to help performance.
I have tested it by removing all the block around tb_add_jump in cpu_exec.c. I have a speed loss of about 2.5x in the boot time of an x86_64 image.
Quoted 3 lines
How is this possible? Could this be related to cache size? I suspect the Phenom 9500 of mine is better equipped in that area than the average ARM controller.
For me it's on a Core 2 Duo T7200, so I doubt it is related to cache size.
Quoted 4 lines
And does the TB chaining actually work on AMD64 at all? I checked by adding some debug output, and it seems to patch the jumps correctly, but maybe somebody can verify that.
Given the gain in speed I have, I guess it works.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 2/9] S/390 CPU emulation
Quoted 3 lines · Aurelien Jarno
I have tested it by removing all the block around
tb_add_jumpincpu_exec.c. I have a speed loss of about 2.5x in the boot time of anx86_64image.
I just tried it with qemu-system-x86_64, and with that I can observe a noticable performance gain using TB chaining as well. Maybe it's simply a lot more effective in system than in userspace emulation.
Anyway, having implemented it for BRC already, I might as well leave it in for future generations to enjoy.
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 1/9] TCG "sync" op
In reply to Ulrich HechtQuoted 6 lines · Ulrich Hecht
sync allows concurrent accesses to locations in memory through different TCG variables. This comes in handy when you are emulating CPU registers that can be used as either 32 or 64 bit, as TCG doesn't know anything about aliases. See the s390x target for an example.
Fixed
sync_i64build failure on 32-bit targets.
It don't really see the point of such a new op, especially the way it is used in the S390 target.
If a global is "synced" before each load/store, it will be load/stored from/to memory each time it is used. This is exactly what tcg_gen_ld/st do, except it's only one op. The benefit of globals in TCG is to hold them as long as possible in host register and avoid costly memory load/store. tcg_gen_ld/st would probably be even more efficient, as it is one op instead of two, and also because mapping more globals means more time spent in the code looping over all globals.
IMHO, the correct way to do it is to use the following code, assuming you want to use 64-bit TCG regs to hold 32-bit values (that's something that is not really clear in your next patch):
- for register load:
| static TCGv load_reg(int reg)
| {
| TCGv r = tcg_temp_new_i64();
| tcg_gen_ext32u_i64(r, tcgregs[reg]);
| return r;
| }
|
| static void store_reg32(int reg, TCGv v)
| {
| tcg_gen_ext32u_i64(v, v); /* may be optional */
| tcg_gen_andi_i64(tcgregs[reg], tcgregs[reg], 0xffffffff00000000ULL);
| tcg_gen_or_i64(tcgregs[reg], tcgregs[reg], v);
| }If you want to do the same using 32-bit TCG regs:
| static TCGv_i32 load_reg(int reg)
| {
| TCGv_i32 r = tcg_temp_new_i32();
| tcg_gen_extu_i32_i64(r, tcgregs[reg]);
| return r;
| }
|
| static void store_reg32(int reg, TCGv_i32 v)
| {
| TCGv tmp = tcg_temp_new();
| tcg_gen_extu_i32_i64(tmp, v);
| tcg_gen_andi_i64(tcgregs[reg], tcgregs[reg], 0xffffffff00000000ULL);
| tcg_gen_or_i64(tcgregs[reg], tcgregs[reg], tmp);
| tcg_temp_free(tmp);
| }Regards,
Aurelien
Quoted 73 lines
Signed-off-by Ulrich Hecht <[email protected]>--- tcg/tcg-op.h | 12 ++++++++++++ tcg/tcg-opc.h | 2 ++ tcg/tcg.c | 6 ++++++ 3 files changed, 20 insertions(+), 0 deletions(-)tcg/tcg-op.h +12
-0@@ -316,6 +316,18 @@ static inline void tcg_gen_br(int label)tcg_gen_op1i (INDEX_op_br, label); } +static inline void tcg_gen_sync_i32 (TCGv_i32 arg) +{ +tcg_gen_op1_i32 (INDEX_op_sync_i32, arg); +} + +#if TCG_TARGET_REG_BITS ==64 +static inline void tcg_gen_sync_i64 (TCGv_i64 arg) +{ +tcg_gen_op1_i64 (INDEX_op_sync_i64, arg); +} +#endif +static inline void tcg_gen_mov_i32 (TCGv_i32 ret,TCGv_i32 arg) {if (!TCGV_EQUAL_I32 (ret, arg))tcg/tcg-opc.h +2
-0@@ -40,6 +40,7 @@ DEF2(call, 0, 1, 2, TCG_OPF_SIDE_EFFECTS) /* variable number of parameters */ DEF2(jmp, 0, 1, 0, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS) DEF2(br, 0, 0, 1, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS) +DEF2(sync_i32, 0, 1, 0, 0) DEF2(mov_i32, 1, 1, 0, 0)DEF2 (movi_i32,1 ,0 ,1 ,0 )/* load/store */ @@ -109,6 +110,7 @@ DEF2(neg_i32, 1, 1, 0, 0)#endif #if TCG_TARGET_REG_BITS ==64 +DEF2(sync_i64, 0, 1, 0, 0) DEF2(mov_i64, 1, 1, 0, 0)DEF2 (movi_i64,1 ,0 ,1 ,0 )/* load/store */ tcg/tcg.c +6
-0@@ -1930,6 +1930,12 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,// dump_regs(s); #endif switch (opc) { +case INDEX_op_sync_i32: +#if TCG_TARGET_REG_BITS ==64 +case INDEX_op_sync_i64: +#endif +temp_save (s, args[0 ], s->reserved_regs); +break ;case INDEX_op_mov_i32:#if TCG_TARGET_REG_BITS ==64 case INDEX_op_mov_i64:Signature · 1 line
1.6.2.1
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 1/9] TCG "sync" op
Quoted 5 lines · Aurelien Jarno
IMHO, the correct way to do it is to use the following code, assuming you want to use 64-bit TCG regs to hold 32-bit values (that's something that is not really clear in your next patch):
- for register load:
Quoted 14 lines
| static TCGv load_reg(int reg)
| {
| TCGv r = tcg_temp_new_i64();
| tcg_gen_ext32u_i64(r, tcgregs[reg]);
| return r;
| }
|
| static void store_reg32(int reg, TCGv v)
| {
| tcg_gen_ext32u_i64(v, v); /* may be optional */
| tcg_gen_andi_i64(tcgregs[reg], tcgregs[reg],
| 0xffffffff00000000ULL); tcg_gen_or_i64(tcgregs[reg], tcgregs[reg],
| v);
| }This is _extremely_ detrimental to performance. The point of the sync op is that in most cases it's a nop because registers are usually used with the same bitness again and again. The sign extension/masking stuff is done every time a register is accessed as 32 bits, which is the most common case. Compare the translation of the following sequence of instructions:
IN: _dl_aux_init
0x0000000080044ff6: lhi %r4,0 0x0000000080044ffa: lhi %r5,0 0x0000000080044ffe: lhi %r0,0
with sync:
OP:
mov_i32 loc0,global_cc
movi_i32 tmp1,$0x0
sync_i64 R4
mov_i32 r4,tmp1
movi_i32 tmp1,$0x0
sync_i64 R5
mov_i32 r5,tmp1
movi_i32 tmp1,$0x0
sync_i64 R0
mov_i32 r0,tmp1
mov_i32 global_cc,loc0
movi_i64 tmp2,$0x80045002
st_i64 tmp2,env,$0x158
exit_tb $0x0
OUT: [size=61]
0x6019a030: mov 0x160(%r14),%ebp 0x6019a037: mov %rbp,%rbx 0x6019a03a: mov $0x80045002,%r12d 0x6019a040: mov %r12,0x158(%r14) 0x6019a047: mov %ebp,0xd1a0(%r14) 0x6019a04e: mov %ebx,0x160(%r14) 0x6019a055: xor %ebp,%ebp 0x6019a057: mov %ebp,(%r14) 0x6019a05a: xor %ebp,%ebp 0x6019a05c: mov %ebp,0x20(%r14) 0x6019a060: xor %ebp,%ebp 0x6019a062: mov %ebp,0x28(%r14) 0x6019a066: xor %eax,%eax 0x6019a068: jmpq 0x621dc8ce
with sign extension:
OP:
mov_i32 loc0,global_cc
movi_i32 tmp1,$0x0
ext32u_i64 tmp1,tmp1
movi_i64 tmp2,$0xffffffff00000000
and_i64 R4,R4,tmp2
or_i64 R4,R4,tmp1
movi_i32 tmp1,$0x0
ext32u_i64 tmp1,tmp1
movi_i64 tmp2,$0xffffffff00000000
and_i64 R5,R5,tmp2
or_i64 R5,R5,tmp1
movi_i32 tmp1,$0x0
ext32u_i64 tmp1,tmp1
movi_i64 tmp2,$0xffffffff00000000
and_i64 R0,R0,tmp2
or_i64 R0,R0,tmp1
mov_i32 global_cc,loc0
movi_i64 tmp2,$0x80045002
st_i64 tmp2,env,$0x158
exit_tb $0x0
OUT: [size=126]
0x6019af10: mov 0x160(%r14),%ebp 0x6019af17: xor %ebx,%ebx 0x6019af19: mov %ebx,%ebx 0x6019af1b: mov 0x20(%r14),%r12 0x6019af1f: mov $0xffffffff00000000,%r13 0x6019af29: and %r13,%r12 0x6019af2c: or %rbx,%r12 0x6019af2f: xor %ebx,%ebx 0x6019af31: mov %ebx,%ebx 0x6019af33: mov 0x28(%r14),%r13 0x6019af37: mov $0xffffffff00000000,%r15 0x6019af41: and %r15,%r13 0x6019af44: or %rbx,%r13 0x6019af47: xor %ebx,%ebx 0x6019af49: mov %ebx,%ebx 0x6019af4b: mov (%r14),%r15 0x6019af4e: mov $0xffffffff00000000,%r10 0x6019af58: and %r10,%r15 0x6019af5b: or %rbx,%r15 0x6019af5e: mov %rbp,%rbx 0x6019af61: mov $0x80045002,%r10d 0x6019af67: mov %r10,0x158(%r14) 0x6019af6e: mov %ebp,0xd1a0(%r14) 0x6019af75: mov %ebx,0x160(%r14) 0x6019af7c: mov %r15,(%r14) 0x6019af7f: mov %r12,0x20(%r14) 0x6019af83: mov %r13,0x28(%r14) 0x6019af87: xor %eax,%eax 0x6019af89: jmpq 0x621dd78e
Its more than twice the size and has ten memory accesses instead of seven.
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 1/9] TCG "sync" op
Quoted 21 lines · Ulrich Hecht
Quoted 5 lines · Aurelien Jarno
IMHO, the correct way to do it is to use the following code, assuming you want to use 64-bit TCG regs to hold 32-bit values (that's something that is not really clear in your next patch):
- for register load:
Quoted 14 lines
| static TCGv load_reg(int reg) | { | TCGv r = tcg_temp_new_i64(); | tcg_gen_ext32u_i64(r, tcgregs[reg]); | return r; | } | | static void store_reg32(int reg, TCGv v) | { | tcg_gen_ext32u_i64(v, v); /* may be optional */ | tcg_gen_andi_i64(tcgregs[reg], tcgregs[reg], | 0xffffffff00000000ULL); tcg_gen_or_i64(tcgregs[reg], tcgregs[reg], | v); | }
Quoted 3 lines
This is _extremely_ detrimental to performance. The point of the sync op is that in most cases it's a nop because registers are usually used with the same bitness again and again. The sign extension/masking stuff is
I don't really understand how it can be simply be a nop, given it calls temp_save. It means if a register is used twice in a BB, it is fetch again from memory.
Quoted 8 lines
done every time a register is accessed as 32 bits, which is the most common case. Compare the translation of the following sequence of instructions:
IN:
_dl_aux_init0x0000000080044ff6: lhi %r4,0 0x0000000080044ffa: lhi %r5,0 0x0000000080044ffe: lhi %r0,0
This example is a bit biased, as registers are only saved, and never reused. Let's comment on it though.
Quoted 90 lines
with sync:
OP:
mov_i32loc0,global_cc
movi_i32tmp1,$0x0
sync_i64R4
mov_i32r4,tmp1
movi_i32tmp1,$0x0
sync_i64R5
mov_i32r5,tmp1
movi_i32tmp1,$0x0
sync_i64R0
mov_i32r0,tmp1
mov_i32global_cc,loc0
movi_i64tmp2,$0x80045002
st_i64tmp2,env,$0x158
exit_tb$0x0OUT: [size=61]
0x6019a030: mov 0x160(%r14),%ebp 0x6019a037: mov %rbp,%rbx 0x6019a03a: mov $0x80045002,%r12d 0x6019a040: mov %r12,0x158(%r14) 0x6019a047: mov %ebp,0xd1a0(%r14) 0x6019a04e: mov %ebx,0x160(%r14) 0x6019a055: xor %ebp,%ebp 0x6019a057: mov %ebp,(%r14) 0x6019a05a: xor %ebp,%ebp 0x6019a05c: mov %ebp,0x20(%r14) 0x6019a060: xor %ebp,%ebp 0x6019a062: mov %ebp,0x28(%r14) 0x6019a066: xor %eax,%eax 0x6019a068: jmpq 0x621dc8cewith sign extension:
OP:
mov_i32loc0,global_cc
movi_i32tmp1,$0x0
ext32u_i64tmp1,tmp1
movi_i64tmp2,$0xffffffff00000000
and_i64R4,R4,tmp2
or_i64R4,R4,tmp1
movi_i32tmp1,$0x0
ext32u_i64tmp1,tmp1
movi_i64tmp2,$0xffffffff00000000
and_i64R5,R5,tmp2
or_i64R5,R5,tmp1
movi_i32tmp1,$0x0
ext32u_i64tmp1,tmp1
movi_i64tmp2,$0xffffffff00000000
and_i64R0,R0,tmp2
or_i64R0,R0,tmp1
mov_i32global_cc,loc0
movi_i64tmp2,$0x80045002
st_i64tmp2,env,$0x158
exit_tb$0x0OUT: [size=126]
0x6019af10: mov 0x160(%r14),%ebp 0x6019af17: xor %ebx,%ebx 0x6019af19: mov %ebx,%ebx 0x6019af1b: mov 0x20(%r14),%r12 0x6019af1f: mov $0xffffffff00000000,%r13 0x6019af29: and %r13,%r12 0x6019af2c: or %rbx,%r12 0x6019af2f: xor %ebx,%ebx 0x6019af31: mov %ebx,%ebx 0x6019af33: mov 0x28(%r14),%r13 0x6019af37: mov $0xffffffff00000000,%r15 0x6019af41: and %r15,%r13 0x6019af44: or %rbx,%r13 0x6019af47: xor %ebx,%ebx 0x6019af49: mov %ebx,%ebx 0x6019af4b: mov (%r14),%r15 0x6019af4e: mov $0xffffffff00000000,%r10 0x6019af58: and %r10,%r15 0x6019af5b: or %rbx,%r15 0x6019af5e: mov %rbp,%rbx 0x6019af61: mov $0x80045002,%r10d 0x6019af67: mov %r10,0x158(%r14) 0x6019af6e: mov %ebp,0xd1a0(%r14) 0x6019af75: mov %ebx,0x160(%r14) 0x6019af7c: mov %r15,(%r14) 0x6019af7f: mov %r12,0x20(%r14) 0x6019af83: mov %r13,0x28(%r14) 0x6019af87: xor %eax,%eax 0x6019af89: jmpq 0x621dd78e
Quoted 3 lines
Its more than twice the size and has ten memory accesses instead of seven.
There is clearly a huge impact for saving the globals, that I didn't expect. I still believe a sync op as implemented in your patch is in opposite direction to TCG's philosophy, probably does not work with fixed registers, and I don't understand what is the gain compared to the use of tcg_gen_ld/st. Maybe you can post a dump of such a version so that we can see the benefit?
I think instead of a sync op, we should think of a way to use only the low part of a global variable, maybe by adding new ops. That can also help to improve the concat_i32_i64 op on 64-bit hosts. Does someone has any idea?
Aurelien
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 1/9] TCG "sync" op
Quoted 2 lines · Aurelien Jarno
This example is a bit biased, as registers are only saved, and never reused. Let's comment on it though.
Yeah, well, I searched from the top for the first case where it makes a difference. If it's of any help, I can upload a complete dump of both versions somewhere.
Quoted 2 lines
and I don't understand what is the gain compared to the use of tcg_gen_ld/st.
There are two sets of TCG values, tcgregs (which would arguably better called tcgregs64) and tcgregs32. When doing a 32-bit access, tcgregs(64) is synced, which is a nop if tcgregs(64) hasn't been touched. When doing a 64-bit access, tcgregs32 is synced, which is a nop if tcgregs32 hasn't been touched. In practice, 32-bit accesses followed by 64-bit accesses and vice versa are very rare, so in most cases, sync is a nop. tcg_gen_ld/st is never a nop. That's the benefit.
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 1/9] TCG "sync" op
In reply to Aurelien JarnoQuoted 10 lines · Aurelien Jarno
Quoted 6 lines · Ulrich Hecht
sync allows concurrent accesses to locations in memory through different TCG variables. This comes in handy when you are emulating CPU registers that can be used as either 32 or 64 bit, as TCG doesn't know anything about aliases. See the s390x target for an example.
Fixed
sync_i64build failure on 32-bit targets.It don't really see the point of such a new op, especially the way it is used in the S390 target.
Hi,
I looked at the s390 patches and was also unsure about this sync op. I'm not convinced it's bad but my first feeling was as Aurelien points out that the translator shoud take care of it. Not sure though, it would be nice to hear what other ppl think.
Another thing I noticed was the large amount of helpers. Without looking at the details my feeling was that you could probably do more at translation time. That kind of optimization can be done incrementally with follow-up patches though.
Other than that the s390 series looks OK and should IMO get committed.
Nice work!
Cheers
Re: [Qemu-devel] [PATCH 1/9] TCG "sync" op
Quoted 3 lines · Edgar E. Iglesias
I looked at the s390 patches and was also unsure about this sync op. I'm not convinced it's bad but my first feeling was as Aurelien points out that the translator shoud take care of it.
Indeed. I would have expected it to, in fact. But it doesn't. The sync op is the simplest and quickest way to get what I want that I could come up with. I'd be perfectly happy if TCG could handle aliases on its own, but doing a lot of ALU operations on every register access is not an option.
Quoted 3 lines
Another thing I noticed was the large amount of helpers. Without looking at the details my feeling was that you could probably do more at translation time.
My experience is that helper functions have an undeservedly bad image. A pure const helper call is very easy to optimize away for TCG. Random bit shifting, comparing and branching isn't.
Quoted 1 line
Nice work!
Thank you.
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)