VirtualBox

Changeset 36170 in vbox for trunk/src/recompiler/target-i386


Ignore:
Timestamp:
Mar 4, 2011 12:49:02 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70361
Message:

rem: synced up to svn://svn.savannah.nongnu.org/qemu/trunk@6686 (repo UUID c046a42c-6fe2-441c-8c8c-71466251a162).

Location:
trunk/src/recompiler/target-i386
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler/target-i386/cpu.h

    r36140 r36170  
    1616 * You should have received a copy of the GNU Lesser General Public
    1717 * License along with this library; if not, write to the Free Software
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
    1919 */
    2020
     
    179179#define HF_EM_MASK           (1 << HF_EM_SHIFT)
    180180#define HF_TS_MASK           (1 << HF_TS_SHIFT)
     181#define HF_IOPL_MASK         (3 << HF_IOPL_SHIFT)
    181182#define HF_LMA_MASK          (1 << HF_LMA_SHIFT)
    182183#define HF_CS64_MASK         (1 << HF_CS64_SHIFT)
    183184#define HF_OSFXSR_MASK       (1 << HF_OSFXSR_SHIFT)
     185#define HF_VM_MASK           (1 << HF_VM_SHIFT)
    184186#define HF_SMM_MASK          (1 << HF_SMM_SHIFT)
    185187#define HF_SVME_MASK         (1 << HF_SVME_SHIFT)
     
    197199#define HF2_NMI_MASK          (1 << HF2_NMI_SHIFT)
    198200#define HF2_VINTR_MASK        (1 << HF2_VINTR_SHIFT)
     201
     202#define CR0_PE_SHIFT 0
     203#define CR0_MP_SHIFT 1
    199204
    200205#define CR0_PE_MASK  (1 << 0)
     
    216221#define CR4_PGE_MASK  (1 << 7)
    217222#define CR4_PCE_MASK  (1 << 8)
    218 #define CR4_OSFXSR_MASK (1 << 9)
     223#define CR4_OSFXSR_SHIFT 9
     224#define CR4_OSFXSR_MASK (1 << CR4_OSFXSR_SHIFT)
    219225#define CR4_OSXMMEXCPT_MASK  (1 << 10)
     226
     227#define DR6_BD          (1 << 13)
     228#define DR6_BS          (1 << 14)
     229#define DR6_BT          (1 << 15)
     230#define DR6_FIXED_1     0xffff0ff0
     231
     232#define DR7_GD          (1 << 13)
     233#define DR7_TYPE_SHIFT  16
     234#define DR7_LEN_SHIFT   18
     235#define DR7_FIXED_1     0x00000400
    220236
    221237#define PG_PRESENT_BIT  0
     
    249265#define PG_ERROR_I_D_MASK  0x10
    250266
     267#define MSR_IA32_TSC                    0x10
    251268#define MSR_IA32_APICBASE               0x1b
    252269#define MSR_IA32_APICBASE_BSP           (1<<8)
     
    254271#define MSR_IA32_APICBASE_BASE          (0xfffff<<12)
    255272
     273#define MSR_MTRRcap                     0xfe
     274#define MSR_MTRRcap_VCNT                8
     275#define MSR_MTRRcap_FIXRANGE_SUPPORT    (1 << 8)
     276#define MSR_MTRRcap_WC_SUPPORTED        (1 << 10)
     277
    256278#define MSR_IA32_SYSENTER_CS            0x174
    257279#define MSR_IA32_SYSENTER_ESP           0x175
     
    264286#define MSR_IA32_PERF_STATUS            0x198
    265287
     288#define MSR_MTRRphysBase(reg)           (0x200 + 2 * (reg))
     289#define MSR_MTRRphysMask(reg)           (0x200 + 2 * (reg) + 1)
     290
     291#define MSR_MTRRfix64K_00000            0x250
     292#define MSR_MTRRfix16K_80000            0x258
     293#define MSR_MTRRfix16K_A0000            0x259
     294#define MSR_MTRRfix4K_C0000             0x268
     295#define MSR_MTRRfix4K_C8000             0x269
     296#define MSR_MTRRfix4K_D0000             0x26a
     297#define MSR_MTRRfix4K_D8000             0x26b
     298#define MSR_MTRRfix4K_E0000             0x26c
     299#define MSR_MTRRfix4K_E8000             0x26d
     300#define MSR_MTRRfix4K_F0000             0x26e
     301#define MSR_MTRRfix4K_F8000             0x26f
     302
    266303#define MSR_PAT                         0x277
     304
     305#define MSR_MTRRdefType                 0x2ff
    267306
    268307#define MSR_EFER                        0xc0000080
     
    380419
    381420#define EXCP00_DIVZ     0
    382 #define EXCP01_SSTP     1
     421#define EXCP01_DB       1
    383422#define EXCP02_NMI      2
    384423#define EXCP03_INT3     3
     
    618657#endif
    619658
     659    uint64_t tsc;
     660
    620661    uint64_t pat;
    621662
     
    625666    target_ulong exception_next_eip;
    626667    target_ulong dr[8]; /* debug registers */
     668    union {
     669        CPUBreakpoint *cpu_breakpoint[4];
     670        CPUWatchpoint *cpu_watchpoint[4];
     671    }; /* break/watchpoints for dr[0..3] */
    627672    uint32_t smbase;
    628673    int old_exception;  /* exception in flight */
     
    662707
    663708#ifndef VBOX
     709    /* MTRRs */
     710    uint64_t mtrr_fixed[11];
     711    uint64_t mtrr_deftype;
     712    struct {
     713        uint64_t base;
     714        uint64_t mask;
     715    } mtrr_var[8];
     716
    664717#ifdef USE_KQEMU
    665718    int kqemu_enabled;
    666719    int last_io_time;
    667720#endif
     721
     722    /* For KVM */
     723    uint64_t interrupt_bitmap[256 / 64];
     724
    668725    /* in order to simplify APIC support, we leave this pointer to the
    669726       user */
     
    874931}
    875932
     933/* op_helper.c */
    876934/* used for debug or cpu save/restore */
    877935void cpu_get_fp80(uint64_t *pmant, uint16_t *pexp, CPU86_LDouble f);
    878936CPU86_LDouble cpu_set_fp80(uint64_t mant, uint16_t upper);
    879937
     938/* cpu-exec.c */
    880939/* the following helpers are only usable in user mode simulation as
    881940   they can trigger unexpected exceptions */
     
    889948int cpu_x86_signal_handler(int host_signum, void *pinfo,
    890949                           void *puc);
     950
     951/* helper.c */
     952int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
     953                             int is_write, int mmu_idx, int is_softmmu);
    891954void cpu_x86_set_a20(CPUX86State *env, int a20_state);
    892 
    893 uint64_t cpu_get_tsc(CPUX86State *env);
    894 
     955void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
     956                   uint32_t *eax, uint32_t *ebx,
     957                   uint32_t *ecx, uint32_t *edx);
     958
     959static inline int hw_breakpoint_enabled(unsigned long dr7, int index)
     960{
     961    return (dr7 >> (index * 2)) & 3;
     962}
     963
     964static inline int hw_breakpoint_type(unsigned long dr7, int index)
     965{
     966    return (dr7 >> (DR7_TYPE_SHIFT + (index * 2))) & 3;
     967}
     968
     969static inline int hw_breakpoint_len(unsigned long dr7, int index)
     970{
     971    int len = ((dr7 >> (DR7_LEN_SHIFT + (index * 2))) & 3);
     972    return (len == 2) ? 8 : len + 1;
     973}
     974
     975void hw_breakpoint_insert(CPUX86State *env, int index);
     976void hw_breakpoint_remove(CPUX86State *env, int index);
     977int check_hw_breakpoints(CPUX86State *env, int force_dr6_update);
     978
     979/* will be suppressed */
     980void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0);
     981void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3);
     982void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4);
     983
     984/* hw/apic.c */
    895985void cpu_set_apic_base(CPUX86State *env, uint64_t val);
    896986uint64_t cpu_get_apic_base(CPUX86State *env);
     
    899989uint8_t cpu_get_apic_tpr(CPUX86State *env);
    900990#endif
    901 #ifdef VBOX
    902 int cpu_rdmsr(CPUX86State *env, uint32_t idMsr, uint64_t *puValue);
    903 int cpu_wrmsr(CPUX86State *env, uint32_t idMsr, uint64_t uValue);
    904 #endif
     991
     992/* hw/pc.c */
    905993void cpu_smm_update(CPUX86State *env);
    906 
    907 /* will be suppressed */
    908 void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0);
     994uint64_t cpu_get_tsc(CPUX86State *env);
    909995
    910996/* used to debug */
     
    9221008
    9231009#ifdef VBOX
     1010int  cpu_rdmsr(CPUX86State *env, uint32_t idMsr, uint64_t *puValue);
     1011int  cpu_wrmsr(CPUX86State *env, uint32_t idMsr, uint64_t uValue);
    9241012void cpu_trap_raw(CPUX86State *env1);
    9251013
     
    9481036#define cpu_list x86_cpu_list
    9491037
    950 #define CPU_SAVE_VERSION 7
     1038#define CPU_SAVE_VERSION 8
    9511039
    9521040/* MMU modes definitions */
     
    9591047}
    9601048
     1049/* translate.c */
    9611050void optimize_flags_init(void);
    9621051
     
    9651054    int (*compute_c)(void);  /* return the C flag */
    9661055} CCTable;
    967 
    968 extern CCTable cc_table[];
    9691056
    9701057#if defined(CONFIG_USER_ONLY)
     
    9771064#endif
    9781065
    979 #define CPU_PC_FROM_TB(env, tb) env->eip = tb->pc - tb->cs_base
    980 
    9811066#include "cpu-all.h"
     1067#include "exec-all.h"
    9821068
    9831069#include "svm.h"
    9841070
     1071static inline void cpu_pc_from_tb(CPUState *env, TranslationBlock *tb)
     1072{
     1073    env->eip = tb->pc - tb->cs_base;
     1074}
     1075
     1076static inline void cpu_get_tb_cpu_state(CPUState *env, target_ulong *pc,
     1077                                        target_ulong *cs_base, int *flags)
     1078{
     1079    *cs_base = env->segs[R_CS].base;
     1080    *pc = *cs_base + env->eip;
     1081    *flags = env->hflags | (env->eflags & (IOPL_MASK | TF_MASK | VM_MASK));
     1082}
     1083
    9851084#endif /* CPU_I386_H */
  • trunk/src/recompiler/target-i386/exec.h

    r36140 r36170  
    1616 * You should have received a copy of the GNU Lesser General Public
    1717 * License along with this library; if not, write to the Free Software
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
    1919 */
    2020
     
    4242register struct CPUX86State *env asm(AREG0);
    4343
     44#include "qemu-common.h"
    4445#include "qemu-log.h"
    4546
     
    6869#include "exec-all.h"
    6970
    70 void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3);
    71 void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4);
    72 int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
    73                              int is_write, int mmu_idx, int is_softmmu);
    74 void __hidden cpu_lock(void);
    75 void __hidden cpu_unlock(void);
     71/* op_helper.c */
    7672void do_interrupt(int intno, int is_int, int error_code,
    7773                  target_ulong next_eip, int is_hw);
    7874void do_interrupt_user(int intno, int is_int, int error_code,
    7975                       target_ulong next_eip);
    80 void raise_interrupt(int intno, int is_int, int error_code,
    81                      int next_eip_addend);
    82 void raise_exception_err(int exception_index, int error_code);
    83 void raise_exception(int exception_index);
     76void QEMU_NORETURN raise_exception_err(int exception_index, int error_code);
     77void QEMU_NORETURN raise_exception(int exception_index);
    8478void do_smm_enter(void);
    85 void __hidden cpu_loop_exit(void);
    86 
    87 void OPPROTO op_movl_eflags_T0(void);
    88 void OPPROTO op_movl_T0_eflags(void);
    89 #ifdef VBOX
    90 void OPPROTO op_movl_T0_eflags_vme(void);
    91 void OPPROTO op_movw_eflags_T0_vme(void);
    92 void OPPROTO op_cli_vme(void);
    93 void OPPROTO op_sti_vme(void);
    94 #endif
    9579
    9680/* n must be a constant to be efficient */
     
    331315#define FPUC_EM 0x3f
    332316
    333 extern const CPU86_LDouble f15rk[7];
    334 
    335 void fpu_raise_exception(void);
    336 void restore_native_fp_state(CPUState *env);
    337 void save_native_fp_state(CPUState *env);
    338 
    339 extern const uint8_t parity_table[256];
    340 extern const uint8_t rclw_table[32];
    341 extern const uint8_t rclb_table[32];
    342 
    343317static inline uint32_t compute_eflags(void)
    344318{
    345     return env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK);
     319    return env->eflags | helper_cc_compute_all(CC_OP) | (DF & DF_MASK);
    346320}
    347321
  • trunk/src/recompiler/target-i386/helper.c

    r36140 r36170  
    1616 * You should have received a copy of the GNU Lesser General Public
    1717 * License along with this library; if not, write to the Free Software
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
    1919 */
    2020
     
    3333#include <string.h>
    3434#ifndef VBOX
    35 # include <inttypes.h>
    36 # include <signal.h>
    37 # include <assert.h>
    38 #endif
     35#include <inttypes.h>
     36#include <signal.h>
     37#include <assert.h>
     38#endif /* !VBOX */
    3939
    4040#include "cpu.h"
    4141#include "exec-all.h"
    42 #include "svm.h"
    4342#include "qemu-common.h"
     43#include "kvm.h"
    4444
    4545//#define DEBUG_MMU
    46 
    47 static int cpu_x86_register (CPUX86State *env, const char *cpu_model);
    4846
    4947#ifndef VBOX
     
    7169    static const char *ext2_feature_name[] = {
    7270       "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
    73        "cx8" /* AMD CMPXCHG8B */, "apic", NULL, "syscall", "mttr", "pge", "mca", "cmov",
     71       "cx8" /* AMD CMPXCHG8B */, "apic", NULL, "syscall", "mtrr", "pge", "mca", "cmov",
    7472       "pat", "pse36", NULL, NULL /* Linux mp */, "nx" /* Intel xd */, NULL, "mmxext", "mmx",
    7573       "fxsr", "fxsr_opt" /* AMD ffxsr */, "pdpe1gb" /* AMD Page1GB */, "rdtscp", NULL, "lm" /* Intel 64 */, "3dnowext", "3dnow",
     
    105103}
    106104#endif /* !VBOX */
    107 
    108 #ifndef VBOX
    109 CPUX86State *cpu_x86_init(const char *cpu_model)
    110 #else
    111 CPUX86State *cpu_x86_init(CPUX86State *env, const char *cpu_model)
    112 #endif
    113 {
    114 #ifndef VBOX
    115     CPUX86State *env;
    116 #endif
    117     static int inited;
    118 
    119 #ifndef VBOX
    120     env = qemu_mallocz(sizeof(CPUX86State));
    121     if (!env)
    122         return NULL;
    123 #endif
    124     cpu_exec_init(env);
    125     env->cpu_model_str = cpu_model;
    126 
    127     /* init various static tables */
    128     if (!inited) {
    129         inited = 1;
    130         optimize_flags_init();
    131     }
    132     if (cpu_x86_register(env, cpu_model) < 0) {
    133         cpu_x86_close(env);
    134         return NULL;
    135     }
    136     cpu_reset(env);
    137 #ifdef USE_KQEMU
    138     kqemu_init(env);
    139 #endif
    140     return env;
    141 }
    142105
    143106typedef struct x86_def_t {
     
    188151        .xlevel = 0x8000000A,
    189152        .model_id = "QEMU Virtual CPU version " QEMU_VERSION,
     153    },
     154    {
     155        .name = "phenom",
     156        .level = 5,
     157        .vendor1 = CPUID_VENDOR_AMD_1,
     158        .vendor2 = CPUID_VENDOR_AMD_2,
     159        .vendor3 = CPUID_VENDOR_AMD_3,
     160        .family = 16,
     161        .model = 2,
     162        .stepping = 3,
     163        /* Missing: CPUID_VME, CPUID_HT */
     164        .features = PPRO_FEATURES |
     165            CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
     166            CPUID_PSE36,
     167        /* Missing: CPUID_EXT_CX16, CPUID_EXT_POPCNT */
     168        .ext_features = CPUID_EXT_SSE3 | CPUID_EXT_MONITOR,
     169        /* Missing: CPUID_EXT2_PDPE1GB, CPUID_EXT2_RDTSCP */
     170        .ext2_features = (PPRO_FEATURES & 0x0183F3FF) |
     171            CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX |
     172            CPUID_EXT2_3DNOW | CPUID_EXT2_3DNOWEXT | CPUID_EXT2_MMXEXT |
     173            CPUID_EXT2_FFXSR,
     174        /* Missing: CPUID_EXT3_LAHF_LM, CPUID_EXT3_CMP_LEG, CPUID_EXT3_EXTAPIC,
     175                    CPUID_EXT3_CR8LEG, CPUID_EXT3_ABM, CPUID_EXT3_SSE4A,
     176                    CPUID_EXT3_MISALIGNSSE, CPUID_EXT3_3DNOWPREFETCH,
     177                    CPUID_EXT3_OSVW, CPUID_EXT3_IBS */
     178        .ext3_features = CPUID_EXT3_SVM,
     179        .xlevel = 0x8000001A,
     180        .model_id = "AMD Phenom(tm) 9550 Quad-Core Processor"
    190181    },
    191182    {
     
    305296            /* Some CPUs got no CPUID_SEP */
    306297        .ext_features = CPUID_EXT_MONITOR |
    307             CPUID_EXT_SSE3 /* PNI */, CPUID_EXT_SSSE3,
     298            CPUID_EXT_SSE3 /* PNI */ | CPUID_EXT_SSSE3,
    308299            /* Missing: CPUID_EXT_DSCPL | CPUID_EXT_EST |
    309300             * CPUID_EXT_TM2 | CPUID_EXT_XTPR */
     
    327318
    328319    def = NULL;
    329     for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++) {
     320    for (i = 0; i < ARRAY_SIZE(x86_defs); i++) {
    330321        if (strcmp(name, x86_defs[i].name) == 0) {
    331322            def = &x86_defs[i];
     
    358349                char *err;
    359350                model = strtol(val, &err, 10);
    360                 if (!*val || *err || model < 0 || model > 0xf) {
     351                if (!*val || *err || model < 0 || model > 0xff) {
    361352                    fprintf(stderr, "bad numerical value %s\n", val);
    362353                    goto error;
     
    417408    unsigned int i;
    418409
    419     for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++)
     410    for (i = 0; i < ARRAY_SIZE(x86_defs); i++)
    420411        (*cpu_fprintf)(f, "x86 %16s\n", x86_defs[i].name);
    421412}
     
    439430    }
    440431    env->cpuid_level = def->level;
    441     env->cpuid_version = (def->family << 8) | (def->model << 4) | def->stepping;
     432    if (def->family > 0x0f)
     433        env->cpuid_version = 0xf00 | ((def->family - 0x0f) << 20);
     434    else
     435        env->cpuid_version = def->family << 8;
     436    env->cpuid_version |= ((def->model & 0xf) << 4) | ((def->model >> 4) << 16);
     437    env->cpuid_version |= def->stepping;
    442438    env->cpuid_features = def->features;
    443439    env->pat = 0x0007040600070406ULL;
     
    469465    int i;
    470466
     467    if (qemu_loglevel_mask(CPU_LOG_RESET)) {
     468        qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
     469        log_cpu_state(env, X86_DUMP_FPU | X86_DUMP_CCOP);
     470    }
     471
    471472    memset(env, 0, offsetof(CPUX86State, breakpoints));
    472473
     
    522523
    523524    env->mxcsr = 0x1f80;
     525
     526    memset(env->dr, 0, sizeof(env->dr));
     527    env->dr[6] = DR6_FIXED_1;
     528    env->dr[7] = DR7_FIXED_1;
     529    cpu_breakpoint_remove_all(env, BP_CPU);
     530    cpu_watchpoint_remove_all(env, BP_CPU);
    524531}
    525532
     
    596603    char cc_op_name[32];
    597604    static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" };
     605
     606    if (kvm_enabled())
     607        kvm_arch_get_registers(env);
    598608
    599609    eflags = env->eflags;
     
    694704                    env->cr[3],
    695705                    (uint32_t)env->cr[4]);
     706        for(i = 0; i < 4; i++)
     707            cpu_fprintf(f, "DR%d=%016" PRIx64 " ", i, env->dr[i]);
     708        cpu_fprintf(f, "\nDR6=%016" PRIx64 " DR7=%016" PRIx64 "\n",
     709                    env->dr[6], env->dr[7]);
    696710    } else
    697711#endif
     
    725739                    (uint32_t)env->cr[3],
    726740                    (uint32_t)env->cr[4]);
     741        for(i = 0; i < 4; i++)
     742            cpu_fprintf(f, "DR%d=%08x ", i, env->dr[i]);
     743        cpu_fprintf(f, "\nDR6=%08x DR7=%08x\n", env->dr[6], env->dr[7]);
    727744    }
    728745    if (flags & X86_DUMP_CCOP) {
     
    899916}
    900917
    901 /* XXX: also flush 4MB pages */
    902 void cpu_x86_flush_tlb(CPUX86State *env, target_ulong addr)
    903 {
    904     tlb_flush_page(env, addr);
    905 }
    906 
    907918#if defined(CONFIG_USER_ONLY)
    908919
     
    13271338    return paddr;
    13281339}
     1340
     1341void hw_breakpoint_insert(CPUState *env, int index)
     1342{
     1343    int type, err = 0;
     1344
     1345    switch (hw_breakpoint_type(env->dr[7], index)) {
     1346    case 0:
     1347        if (hw_breakpoint_enabled(env->dr[7], index))
     1348            err = cpu_breakpoint_insert(env, env->dr[index], BP_CPU,
     1349                                        &env->cpu_breakpoint[index]);
     1350        break;
     1351    case 1:
     1352        type = BP_CPU | BP_MEM_WRITE;
     1353        goto insert_wp;
     1354    case 2:
     1355         /* No support for I/O watchpoints yet */
     1356        break;
     1357    case 3:
     1358        type = BP_CPU | BP_MEM_ACCESS;
     1359    insert_wp:
     1360        err = cpu_watchpoint_insert(env, env->dr[index],
     1361                                    hw_breakpoint_len(env->dr[7], index),
     1362                                    type, &env->cpu_watchpoint[index]);
     1363        break;
     1364    }
     1365    if (err)
     1366        env->cpu_breakpoint[index] = NULL;
     1367}
     1368
     1369void hw_breakpoint_remove(CPUState *env, int index)
     1370{
     1371    if (!env->cpu_breakpoint[index])
     1372        return;
     1373    switch (hw_breakpoint_type(env->dr[7], index)) {
     1374    case 0:
     1375        if (hw_breakpoint_enabled(env->dr[7], index))
     1376            cpu_breakpoint_remove_by_ref(env, env->cpu_breakpoint[index]);
     1377        break;
     1378    case 1:
     1379    case 3:
     1380        cpu_watchpoint_remove_by_ref(env, env->cpu_watchpoint[index]);
     1381        break;
     1382    case 2:
     1383        /* No support for I/O watchpoints yet */
     1384        break;
     1385    }
     1386}
     1387
     1388int check_hw_breakpoints(CPUState *env, int force_dr6_update)
     1389{
     1390    target_ulong dr6;
     1391    int reg, type;
     1392    int hit_enabled = 0;
     1393
     1394    dr6 = env->dr[6] & ~0xf;
     1395    for (reg = 0; reg < 4; reg++) {
     1396        type = hw_breakpoint_type(env->dr[7], reg);
     1397        if ((type == 0 && env->dr[reg] == env->eip) ||
     1398            ((type & 1) && env->cpu_watchpoint[reg] &&
     1399             (env->cpu_watchpoint[reg]->flags & BP_WATCHPOINT_HIT))) {
     1400            dr6 |= 1 << reg;
     1401            if (hw_breakpoint_enabled(env->dr[7], reg))
     1402                hit_enabled = 1;
     1403        }
     1404    }
     1405    if (hit_enabled || force_dr6_update)
     1406        env->dr[6] = dr6;
     1407    return hit_enabled;
     1408}
     1409
     1410static CPUDebugExcpHandler *prev_debug_excp_handler;
     1411
     1412void raise_exception(int exception_index);
     1413
     1414static void breakpoint_handler(CPUState *env)
     1415{
     1416    CPUBreakpoint *bp;
     1417
     1418    if (env->watchpoint_hit) {
     1419        if (env->watchpoint_hit->flags & BP_CPU) {
     1420            env->watchpoint_hit = NULL;
     1421            if (check_hw_breakpoints(env, 0))
     1422                raise_exception(EXCP01_DB);
     1423            else
     1424                cpu_resume_from_signal(env, NULL);
     1425        }
     1426    } else {
     1427        TAILQ_FOREACH(bp, &env->breakpoints, entry)
     1428            if (bp->pc == env->eip) {
     1429                if (bp->flags & BP_CPU) {
     1430                    check_hw_breakpoints(env, 1);
     1431                    raise_exception(EXCP01_DB);
     1432                }
     1433                break;
     1434            }
     1435    }
     1436    if (prev_debug_excp_handler)
     1437        prev_debug_excp_handler(env);
     1438}
    13291439#endif /* !CONFIG_USER_ONLY */
     1440
     1441#ifndef VBOX
     1442static void host_cpuid(uint32_t function, uint32_t count,
     1443                       uint32_t *eax, uint32_t *ebx,
     1444                       uint32_t *ecx, uint32_t *edx)
     1445{
     1446#if defined(CONFIG_KVM)
     1447    uint32_t vec[4];
     1448
     1449#ifdef __x86_64__
     1450    asm volatile("cpuid"
     1451                 : "=a"(vec[0]), "=b"(vec[1]),
     1452                   "=c"(vec[2]), "=d"(vec[3])
     1453                 : "0"(function), "c"(count) : "cc");
     1454#else
     1455    asm volatile("pusha \n\t"
     1456                 "cpuid \n\t"
     1457                 "mov %%eax, 0(%1) \n\t"
     1458                 "mov %%ebx, 4(%1) \n\t"
     1459                 "mov %%ecx, 8(%1) \n\t"
     1460                 "mov %%edx, 12(%1) \n\t"
     1461                 "popa"
     1462                 : : "a"(function), "c"(count), "S"(vec)
     1463                 : "memory", "cc");
     1464#endif
     1465
     1466    if (eax)
     1467        *eax = vec[0];
     1468    if (ebx)
     1469        *ebx = vec[1];
     1470    if (ecx)
     1471        *ecx = vec[2];
     1472    if (edx)
     1473        *edx = vec[3];
     1474#endif
     1475}
     1476
     1477void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
     1478                   uint32_t *eax, uint32_t *ebx,
     1479                   uint32_t *ecx, uint32_t *edx)
     1480{
     1481    /* test if maximum index reached */
     1482    if (index & 0x80000000) {
     1483        if (index > env->cpuid_xlevel)
     1484            index = env->cpuid_level;
     1485    } else {
     1486        if (index > env->cpuid_level)
     1487            index = env->cpuid_level;
     1488    }
     1489
     1490    switch(index) {
     1491    case 0:
     1492        *eax = env->cpuid_level;
     1493        *ebx = env->cpuid_vendor1;
     1494        *edx = env->cpuid_vendor2;
     1495        *ecx = env->cpuid_vendor3;
     1496
     1497        /* sysenter isn't supported on compatibility mode on AMD.  and syscall
     1498         * isn't supported in compatibility mode on Intel.  so advertise the
     1499         * actuall cpu, and say goodbye to migration between different vendors
     1500         * is you use compatibility mode. */
     1501        if (kvm_enabled())
     1502            host_cpuid(0, 0, NULL, ebx, ecx, edx);
     1503        break;
     1504    case 1:
     1505        *eax = env->cpuid_version;
     1506        *ebx = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */
     1507        *ecx = env->cpuid_ext_features;
     1508        *edx = env->cpuid_features;
     1509
     1510        /* "Hypervisor present" bit required for Microsoft SVVP */
     1511        if (kvm_enabled())
     1512            *ecx |= (1 << 31);
     1513        break;
     1514    case 2:
     1515        /* cache info: needed for Pentium Pro compatibility */
     1516        *eax = 1;
     1517        *ebx = 0;
     1518        *ecx = 0;
     1519        *edx = 0x2c307d;
     1520        break;
     1521    case 4:
     1522        /* cache info: needed for Core compatibility */
     1523        switch (count) {
     1524            case 0: /* L1 dcache info */
     1525                *eax = 0x0000121;
     1526                *ebx = 0x1c0003f;
     1527                *ecx = 0x000003f;
     1528                *edx = 0x0000001;
     1529                break;
     1530            case 1: /* L1 icache info */
     1531                *eax = 0x0000122;
     1532                *ebx = 0x1c0003f;
     1533                *ecx = 0x000003f;
     1534                *edx = 0x0000001;
     1535                break;
     1536            case 2: /* L2 cache info */
     1537                *eax = 0x0000143;
     1538                *ebx = 0x3c0003f;
     1539                *ecx = 0x0000fff;
     1540                *edx = 0x0000001;
     1541                break;
     1542            default: /* end of info */
     1543                *eax = 0;
     1544                *ebx = 0;
     1545                *ecx = 0;
     1546                *edx = 0;
     1547                break;
     1548        }
     1549        break;
     1550    case 5:
     1551        /* mwait info: needed for Core compatibility */
     1552        *eax = 0; /* Smallest monitor-line size in bytes */
     1553        *ebx = 0; /* Largest monitor-line size in bytes */
     1554        *ecx = CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;
     1555        *edx = 0;
     1556        break;
     1557    case 6:
     1558        /* Thermal and Power Leaf */
     1559        *eax = 0;
     1560        *ebx = 0;
     1561        *ecx = 0;
     1562        *edx = 0;
     1563        break;
     1564    case 9:
     1565        /* Direct Cache Access Information Leaf */
     1566        *eax = 0; /* Bits 0-31 in DCA_CAP MSR */
     1567        *ebx = 0;
     1568        *ecx = 0;
     1569        *edx = 0;
     1570        break;
     1571    case 0xA:
     1572        /* Architectural Performance Monitoring Leaf */
     1573        *eax = 0;
     1574        *ebx = 0;
     1575        *ecx = 0;
     1576        *edx = 0;
     1577        break;
     1578    case 0x80000000:
     1579        *eax = env->cpuid_xlevel;
     1580        *ebx = env->cpuid_vendor1;
     1581        *edx = env->cpuid_vendor2;
     1582        *ecx = env->cpuid_vendor3;
     1583        break;
     1584    case 0x80000001:
     1585        *eax = env->cpuid_features;
     1586        *ebx = 0;
     1587        *ecx = env->cpuid_ext3_features;
     1588        *edx = env->cpuid_ext2_features;
     1589
     1590        if (kvm_enabled()) {
     1591            uint32_t h_eax, h_edx;
     1592
     1593            host_cpuid(index, 0, &h_eax, NULL, NULL, &h_edx);
     1594
     1595            /* disable CPU features that the host does not support */
     1596
     1597            /* long mode */
     1598            if ((h_edx & 0x20000000) == 0 /* || !lm_capable_kernel */)
     1599                *edx &= ~0x20000000;
     1600            /* syscall */
     1601            if ((h_edx & 0x00000800) == 0)
     1602                *edx &= ~0x00000800;
     1603            /* nx */
     1604            if ((h_edx & 0x00100000) == 0)
     1605                *edx &= ~0x00100000;
     1606
     1607            /* disable CPU features that KVM cannot support */
     1608
     1609            /* svm */
     1610            *ecx &= ~4UL;
     1611            /* 3dnow */
     1612            *edx &= ~0xc0000000;
     1613        }
     1614        break;
     1615    case 0x80000002:
     1616    case 0x80000003:
     1617    case 0x80000004:
     1618        *eax = env->cpuid_model[(index - 0x80000002) * 4 + 0];
     1619        *ebx = env->cpuid_model[(index - 0x80000002) * 4 + 1];
     1620        *ecx = env->cpuid_model[(index - 0x80000002) * 4 + 2];
     1621        *edx = env->cpuid_model[(index - 0x80000002) * 4 + 3];
     1622        break;
     1623    case 0x80000005:
     1624        /* cache info (L1 cache) */
     1625        *eax = 0x01ff01ff;
     1626        *ebx = 0x01ff01ff;
     1627        *ecx = 0x40020140;
     1628        *edx = 0x40020140;
     1629        break;
     1630    case 0x80000006:
     1631        /* cache info (L2 cache) */
     1632        *eax = 0;
     1633        *ebx = 0x42004200;
     1634        *ecx = 0x02008140;
     1635        *edx = 0;
     1636        break;
     1637    case 0x80000008:
     1638        /* virtual & phys address size in low 2 bytes. */
     1639/* XXX: This value must match the one used in the MMU code. */
     1640        if (env->cpuid_ext2_features & CPUID_EXT2_LM) {
     1641            /* 64 bit processor */
     1642#if defined(USE_KQEMU)
     1643            *eax = 0x00003020;  /* 48 bits virtual, 32 bits physical */
     1644#else
     1645/* XXX: The physical address space is limited to 42 bits in exec.c. */
     1646            *eax = 0x00003028;  /* 48 bits virtual, 40 bits physical */
     1647#endif
     1648        } else {
     1649#if defined(USE_KQEMU)
     1650            *eax = 0x00000020;  /* 32 bits physical */
     1651#else
     1652            if (env->cpuid_features & CPUID_PSE36)
     1653                *eax = 0x00000024; /* 36 bits physical */
     1654            else
     1655                *eax = 0x00000020; /* 32 bits physical */
     1656#endif
     1657        }
     1658        *ebx = 0;
     1659        *ecx = 0;
     1660        *edx = 0;
     1661        break;
     1662    case 0x8000000A:
     1663        *eax = 0x00000001; /* SVM Revision */
     1664        *ebx = 0x00000010; /* nr of ASIDs */
     1665        *ecx = 0;
     1666        *edx = 0; /* optional features */
     1667        break;
     1668    default:
     1669        /* reserved values: zero */
     1670        *eax = 0;
     1671        *ebx = 0;
     1672        *ecx = 0;
     1673        *edx = 0;
     1674        break;
     1675    }
     1676}
     1677#endif /* !VBOX */
     1678
     1679#ifndef VBOX
     1680CPUX86State *cpu_x86_init(const char *cpu_model)
     1681#else
     1682CPUX86State *cpu_x86_init(CPUX86State *env, const char *cpu_model)
     1683#endif
     1684{
     1685#ifndef VBOX
     1686    CPUX86State *env;
     1687#endif
     1688    static int inited;
     1689
     1690#ifndef VBOX
     1691    env = qemu_mallocz(sizeof(CPUX86State));
     1692#endif
     1693    cpu_exec_init(env);
     1694    env->cpu_model_str = cpu_model;
     1695
     1696    /* init various static tables */
     1697    if (!inited) {
     1698        inited = 1;
     1699        optimize_flags_init();
     1700#ifndef CONFIG_USER_ONLY
     1701        prev_debug_excp_handler =
     1702            cpu_set_debug_excp_handler(breakpoint_handler);
     1703#endif
     1704    }
     1705    if (cpu_x86_register(env, cpu_model) < 0) {
     1706        cpu_x86_close(env);
     1707        return NULL;
     1708    }
     1709    cpu_reset(env);
     1710#ifdef USE_KQEMU
     1711    kqemu_init(env);
     1712#endif
     1713    if (kvm_enabled())
     1714        kvm_init_vcpu(env);
     1715    return env;
     1716}
  • trunk/src/recompiler/target-i386/helper.h

    r36140 r36170  
    1 #ifndef DEF_HELPER
    2 #define DEF_HELPER(ret, name, params) ret name params;
    3 #endif
    4 
    5 DEF_HELPER(void, helper_lock, (void))
    6 DEF_HELPER(void, helper_unlock, (void))
    7 DEF_HELPER(void, helper_write_eflags, (target_ulong t0, uint32_t update_mask))
    8 DEF_HELPER(target_ulong, helper_read_eflags, (void))
    9 #ifdef VBOX
    10 DEF_HELPER(void, helper_write_eflags_vme, (target_ulong t0))
    11 DEF_HELPER(target_ulong, helper_read_eflags_vme, (void))
    12 #endif
    13 DEF_HELPER(void, helper_divb_AL, (target_ulong t0))
    14 DEF_HELPER(void, helper_idivb_AL, (target_ulong t0))
    15 DEF_HELPER(void, helper_divw_AX, (target_ulong t0))
    16 DEF_HELPER(void, helper_idivw_AX, (target_ulong t0))
    17 DEF_HELPER(void, helper_divl_EAX, (target_ulong t0))
    18 DEF_HELPER(void, helper_idivl_EAX, (target_ulong t0))
    19 #ifdef TARGET_X86_64
    20 DEF_HELPER(void, helper_mulq_EAX_T0, (target_ulong t0))
    21 DEF_HELPER(void, helper_imulq_EAX_T0, (target_ulong t0))
    22 DEF_HELPER(target_ulong, helper_imulq_T0_T1, (target_ulong t0, target_ulong t1))
    23 DEF_HELPER(void, helper_divq_EAX, (target_ulong t0))
    24 DEF_HELPER(void, helper_idivq_EAX, (target_ulong t0))
    25 #endif
    26 
    27 DEF_HELPER(void, helper_aam, (int base))
    28 DEF_HELPER(void, helper_aad, (int base))
    29 DEF_HELPER(void, helper_aaa, (void))
    30 DEF_HELPER(void, helper_aas, (void))
    31 DEF_HELPER(void, helper_daa, (void))
    32 DEF_HELPER(void, helper_das, (void))
    33 
    34 DEF_HELPER(target_ulong, helper_lsl, (target_ulong selector1))
    35 DEF_HELPER(target_ulong, helper_lar, (target_ulong selector1))
    36 DEF_HELPER(void, helper_verr, (target_ulong selector1))
    37 DEF_HELPER(void, helper_verw, (target_ulong selector1))
    38 DEF_HELPER(void, helper_lldt, (int selector))
    39 DEF_HELPER(void, helper_ltr, (int selector))
    40 DEF_HELPER(void, helper_load_seg, (int seg_reg, int selector))
    41 DEF_HELPER(void, helper_ljmp_protected, (int new_cs, target_ulong new_eip,
    42                            int next_eip_addend))
    43 DEF_HELPER(void, helper_lcall_real, (int new_cs, target_ulong new_eip1,
    44                        int shift, int next_eip))
    45 DEF_HELPER(void, helper_lcall_protected, (int new_cs, target_ulong new_eip,
    46                             int shift, int next_eip_addend))
    47 DEF_HELPER(void, helper_iret_real, (int shift))
    48 DEF_HELPER(void, helper_iret_protected, (int shift, int next_eip))
    49 DEF_HELPER(void, helper_lret_protected, (int shift, int addend))
    50 DEF_HELPER(target_ulong, helper_read_crN, (int reg))
    51 DEF_HELPER(void, helper_write_crN, (int reg, target_ulong t0))
    52 DEF_HELPER(void, helper_lmsw, (target_ulong t0))
    53 DEF_HELPER(void, helper_clts, (void))
    54 DEF_HELPER(void, helper_movl_drN_T0, (int reg, target_ulong t0))
    55 DEF_HELPER(void, helper_invlpg, (target_ulong addr))
    56 
    57 DEF_HELPER(void, helper_enter_level, (int level, int data32, target_ulong t1))
    58 #ifdef TARGET_X86_64
    59 DEF_HELPER(void, helper_enter64_level, (int level, int data64, target_ulong t1))
    60 #endif
    61 DEF_HELPER(void, helper_sysenter, (void))
    62 DEF_HELPER(void, helper_sysexit, (int dflag))
    63 #ifdef TARGET_X86_64
    64 DEF_HELPER(void, helper_syscall, (int next_eip_addend))
    65 DEF_HELPER(void, helper_sysret, (int dflag))
    66 #endif
    67 DEF_HELPER(void, helper_hlt, (int next_eip_addend))
    68 DEF_HELPER(void, helper_monitor, (target_ulong ptr))
    69 DEF_HELPER(void, helper_mwait, (int next_eip_addend))
    70 DEF_HELPER(void, helper_debug, (void))
    71 DEF_HELPER(void, helper_raise_interrupt, (int intno, int next_eip_addend))
    72 DEF_HELPER(void, helper_raise_exception, (int exception_index))
    73 DEF_HELPER(void, helper_cli, (void))
    74 DEF_HELPER(void, helper_sti, (void))
    75 #ifdef VBOX
    76 DEF_HELPER(void, helper_cli_vme, (void))
    77 DEF_HELPER(void, helper_sti_vme, (void))
    78 #endif
    79 DEF_HELPER(void, helper_set_inhibit_irq, (void))
    80 DEF_HELPER(void, helper_reset_inhibit_irq, (void))
    81 DEF_HELPER(void, helper_boundw, (target_ulong a0, int v))
    82 DEF_HELPER(void, helper_boundl, (target_ulong a0, int v))
    83 DEF_HELPER(void, helper_rsm, (void))
    84 DEF_HELPER(void, helper_into, (int next_eip_addend))
    85 DEF_HELPER(void, helper_cmpxchg8b, (target_ulong a0))
    86 #ifdef TARGET_X86_64
    87 DEF_HELPER(void, helper_cmpxchg16b, (target_ulong a0))
    88 #endif
    89 DEF_HELPER(void, helper_single_step, (void))
    90 DEF_HELPER(void, helper_cpuid, (void))
    91 DEF_HELPER(void, helper_rdtsc, (void))
    92 DEF_HELPER(void, helper_rdpmc, (void))
    93 DEF_HELPER(void, helper_rdmsr, (void))
    94 DEF_HELPER(void, helper_wrmsr, (void))
    95 #ifdef VBOX
    96 DEF_HELPER(void, helper_rdtscp, (void))
    97 #endif
    98 
    99 DEF_HELPER(void, helper_check_iob, (uint32_t t0))
    100 DEF_HELPER(void, helper_check_iow, (uint32_t t0))
    101 DEF_HELPER(void, helper_check_iol, (uint32_t t0))
    102 #ifdef VBOX
    103 DEF_HELPER(void, helper_check_external_event, (void))
    104 DEF_HELPER(void, helper_dump_state, (void))
    105 DEF_HELPER(void, helper_sync_seg, (uint32_t t0))
    106 #endif
    107 DEF_HELPER(void, helper_outb, (uint32_t port, uint32_t data))
    108 DEF_HELPER(target_ulong, helper_inb, (uint32_t port))
    109 DEF_HELPER(void, helper_outw, (uint32_t port, uint32_t data))
    110 DEF_HELPER(target_ulong, helper_inw, (uint32_t port))
    111 DEF_HELPER(void, helper_outl, (uint32_t port, uint32_t data))
    112 DEF_HELPER(target_ulong, helper_inl, (uint32_t port))
    113 
    114 DEF_HELPER(void, helper_svm_check_intercept_param, (uint32_t type, uint64_t param))
    115 DEF_HELPER(void, helper_vmexit, (uint32_t exit_code, uint64_t exit_info_1))
    116 DEF_HELPER(void, helper_svm_check_io, (uint32_t port, uint32_t param,
    117                          uint32_t next_eip_addend))
    118 DEF_HELPER(void, helper_vmrun, (int aflag, int next_eip_addend))
    119 DEF_HELPER(void, helper_vmmcall, (void))
    120 DEF_HELPER(void, helper_vmload, (int aflag))
    121 DEF_HELPER(void, helper_vmsave, (int aflag))
    122 DEF_HELPER(void, helper_stgi, (void))
    123 DEF_HELPER(void, helper_clgi, (void))
    124 DEF_HELPER(void, helper_skinit, (void))
    125 DEF_HELPER(void, helper_invlpga, (int aflag))
     1#include "def-helper.h"
     2
     3DEF_HELPER_FLAGS_1(cc_compute_all, TCG_CALL_PURE, i32, int)
     4DEF_HELPER_FLAGS_1(cc_compute_c, TCG_CALL_PURE, i32, int)
     5
     6DEF_HELPER_0(lock, void)
     7DEF_HELPER_0(unlock, void)
     8DEF_HELPER_2(write_eflags, void, tl, i32)
     9DEF_HELPER_0(read_eflags, tl)
     10DEF_HELPER_1(divb_AL, void, tl)
     11DEF_HELPER_1(idivb_AL, void, tl)
     12DEF_HELPER_1(divw_AX, void, tl)
     13DEF_HELPER_1(idivw_AX, void, tl)
     14DEF_HELPER_1(divl_EAX, void, tl)
     15DEF_HELPER_1(idivl_EAX, void, tl)
     16#ifdef TARGET_X86_64
     17DEF_HELPER_1(mulq_EAX_T0, void, tl)
     18DEF_HELPER_1(imulq_EAX_T0, void, tl)
     19DEF_HELPER_2(imulq_T0_T1, tl, tl, tl)
     20DEF_HELPER_1(divq_EAX, void, tl)
     21DEF_HELPER_1(idivq_EAX, void, tl)
     22#endif
     23
     24DEF_HELPER_1(aam, void, int)
     25DEF_HELPER_1(aad, void, int)
     26DEF_HELPER_0(aaa, void)
     27DEF_HELPER_0(aas, void)
     28DEF_HELPER_0(daa, void)
     29DEF_HELPER_0(das, void)
     30
     31DEF_HELPER_1(lsl, tl, tl)
     32DEF_HELPER_1(lar, tl, tl)
     33DEF_HELPER_1(verr, void, tl)
     34DEF_HELPER_1(verw, void, tl)
     35DEF_HELPER_1(lldt, void, int)
     36DEF_HELPER_1(ltr, void, int)
     37DEF_HELPER_2(load_seg, void, int, int)
     38DEF_HELPER_3(ljmp_protected, void, int, tl, int)
     39DEF_HELPER_4(lcall_real, void, int, tl, int, int)
     40DEF_HELPER_4(lcall_protected, void, int, tl, int, int)
     41DEF_HELPER_1(iret_real, void, int)
     42DEF_HELPER_2(iret_protected, void, int, int)
     43DEF_HELPER_2(lret_protected, void, int, int)
     44DEF_HELPER_1(read_crN, tl, int)
     45DEF_HELPER_2(write_crN, void, int, tl)
     46DEF_HELPER_1(lmsw, void, tl)
     47DEF_HELPER_0(clts, void)
     48DEF_HELPER_2(movl_drN_T0, void, int, tl)
     49DEF_HELPER_1(invlpg, void, tl)
     50
     51DEF_HELPER_3(enter_level, void, int, int, tl)
     52#ifdef TARGET_X86_64
     53DEF_HELPER_3(enter64_level, void, int, int, tl)
     54#endif
     55DEF_HELPER_0(sysenter, void)
     56DEF_HELPER_1(sysexit, void, int)
     57#ifdef TARGET_X86_64
     58DEF_HELPER_1(syscall, void, int)
     59DEF_HELPER_1(sysret, void, int)
     60#endif
     61DEF_HELPER_1(hlt, void, int)
     62DEF_HELPER_1(monitor, void, tl)
     63DEF_HELPER_1(mwait, void, int)
     64DEF_HELPER_0(debug, void)
     65DEF_HELPER_2(raise_interrupt, void, int, int)
     66DEF_HELPER_1(raise_exception, void, int)
     67DEF_HELPER_0(cli, void)
     68DEF_HELPER_0(sti, void)
     69DEF_HELPER_0(set_inhibit_irq, void)
     70DEF_HELPER_0(reset_inhibit_irq, void)
     71DEF_HELPER_2(boundw, void, tl, int)
     72DEF_HELPER_2(boundl, void, tl, int)
     73DEF_HELPER_0(rsm, void)
     74DEF_HELPER_1(into, void, int)
     75DEF_HELPER_1(cmpxchg8b, void, tl)
     76#ifdef TARGET_X86_64
     77DEF_HELPER_1(cmpxchg16b, void, tl)
     78#endif
     79DEF_HELPER_0(single_step, void)
     80DEF_HELPER_0(cpuid, void)
     81DEF_HELPER_0(rdtsc, void)
     82DEF_HELPER_0(rdpmc, void)
     83DEF_HELPER_0(rdmsr, void)
     84DEF_HELPER_0(wrmsr, void)
     85
     86DEF_HELPER_1(check_iob, void, i32)
     87DEF_HELPER_1(check_iow, void, i32)
     88DEF_HELPER_1(check_iol, void, i32)
     89DEF_HELPER_2(outb, void, i32, i32)
     90DEF_HELPER_1(inb, tl, i32)
     91DEF_HELPER_2(outw, void, i32, i32)
     92DEF_HELPER_1(inw, tl, i32)
     93DEF_HELPER_2(outl, void, i32, i32)
     94DEF_HELPER_1(inl, tl, i32)
     95
     96DEF_HELPER_2(svm_check_intercept_param, void, i32, i64)
     97DEF_HELPER_2(vmexit, void, i32, i64)
     98DEF_HELPER_3(svm_check_io, void, i32, i32, i32)
     99DEF_HELPER_2(vmrun, void, int, int)
     100DEF_HELPER_0(vmmcall, void)
     101DEF_HELPER_1(vmload, void, int)
     102DEF_HELPER_1(vmsave, void, int)
     103DEF_HELPER_0(stgi, void)
     104DEF_HELPER_0(clgi, void)
     105DEF_HELPER_0(skinit, void)
     106DEF_HELPER_1(invlpga, void, int)
    126107
    127108/* x86 FPU */
    128109
    129 DEF_HELPER(void, helper_flds_FT0, (uint32_t val))
    130 DEF_HELPER(void, helper_fldl_FT0, (uint64_t val))
    131 DEF_HELPER(void, helper_fildl_FT0, (int32_t val))
    132 DEF_HELPER(void, helper_flds_ST0, (uint32_t val))
    133 DEF_HELPER(void, helper_fldl_ST0, (uint64_t val))
    134 DEF_HELPER(void, helper_fildl_ST0, (int32_t val))
    135 DEF_HELPER(void, helper_fildll_ST0, (int64_t val))
     110DEF_HELPER_1(flds_FT0, void, i32)
     111DEF_HELPER_1(fldl_FT0, void, i64)
     112DEF_HELPER_1(fildl_FT0, void, s32)
     113DEF_HELPER_1(flds_ST0, void, i32)
     114DEF_HELPER_1(fldl_ST0, void, i64)
     115DEF_HELPER_1(fildl_ST0, void, s32)
     116DEF_HELPER_1(fildll_ST0, void, s64)
    136117#ifndef VBOX
    137 DEF_HELPER(uint32_t, helper_fsts_ST0, (void))
    138 DEF_HELPER(uint64_t, helper_fstl_ST0, (void))
    139 DEF_HELPER(int32_t, helper_fist_ST0, (void))
    140 DEF_HELPER(int32_t, helper_fistl_ST0, (void))
    141 DEF_HELPER(int64_t, helper_fistll_ST0, (void))
    142 DEF_HELPER(int32_t, helper_fistt_ST0, (void))
    143 DEF_HELPER(int32_t, helper_fisttl_ST0, (void))
    144 DEF_HELPER(int64_t, helper_fisttll_ST0, (void))
     118DEF_HELPER_0(fsts_ST0, i32)
     119DEF_HELPER_0(fstl_ST0, i64)
     120DEF_HELPER_0(fist_ST0, s32)
     121DEF_HELPER_0(fistl_ST0, s32)
     122DEF_HELPER_0(fistll_ST0, s64)
     123DEF_HELPER_0(fistt_ST0, s32)
     124DEF_HELPER_0(fisttl_ST0, s32)
     125DEF_HELPER_0(fisttll_ST0, s64)
    145126#else  /* VBOX */
    146 DEF_HELPER(RTCCUINTREG, helper_fsts_ST0, (void))
    147 DEF_HELPER(uint64_t, helper_fstl_ST0, (void))
    148 DEF_HELPER(RTCCINTREG, helper_fist_ST0, (void))
    149 DEF_HELPER(RTCCINTREG, helper_fistl_ST0, (void))
    150 DEF_HELPER(int64_t, helper_fistll_ST0, (void))
    151 DEF_HELPER(RTCCINTREG, helper_fistt_ST0, (void))
    152 DEF_HELPER(RTCCINTREG, helper_fisttl_ST0, (void))
    153 DEF_HELPER(int64_t, helper_fisttll_ST0, (void))
     127DEF_HELPER_0(fsts_ST0, RTCCUINTREG)
     128DEF_HELPER_0(fstl_ST0, i64)
     129DEF_HELPER_0(fist_ST0, RTCCINTREG)
     130DEF_HELPER_0(fistl_ST0, RTCCINTREG)
     131DEF_HELPER_0(fistll_ST0, s64)
     132DEF_HELPER_0(fistt_ST0, RTCCINTREG)
     133DEF_HELPER_0(fisttl_ST0, RTCCINTREG)
     134DEF_HELPER_0(fisttll_ST0, s64)
    154135#endif /* VBOX */
    155 DEF_HELPER(void, helper_fldt_ST0, (target_ulong ptr))
    156 DEF_HELPER(void, helper_fstt_ST0, (target_ulong ptr))
    157 DEF_HELPER(void, helper_fpush, (void))
    158 DEF_HELPER(void, helper_fpop, (void))
    159 DEF_HELPER(void, helper_fdecstp, (void))
    160 DEF_HELPER(void, helper_fincstp, (void))
    161 DEF_HELPER(void, helper_ffree_STN, (int st_index))
    162 DEF_HELPER(void, helper_fmov_ST0_FT0, (void))
    163 DEF_HELPER(void, helper_fmov_FT0_STN, (int st_index))
    164 DEF_HELPER(void, helper_fmov_ST0_STN, (int st_index))
    165 DEF_HELPER(void, helper_fmov_STN_ST0, (int st_index))
    166 DEF_HELPER(void, helper_fxchg_ST0_STN, (int st_index))
    167 DEF_HELPER(void, helper_fcom_ST0_FT0, (void))
    168 DEF_HELPER(void, helper_fucom_ST0_FT0, (void))
    169 DEF_HELPER(void, helper_fcomi_ST0_FT0, (void))
    170 DEF_HELPER(void, helper_fucomi_ST0_FT0, (void))
    171 DEF_HELPER(void, helper_fadd_ST0_FT0, (void))
    172 DEF_HELPER(void, helper_fmul_ST0_FT0, (void))
    173 DEF_HELPER(void, helper_fsub_ST0_FT0, (void))
    174 DEF_HELPER(void, helper_fsubr_ST0_FT0, (void))
    175 DEF_HELPER(void, helper_fdiv_ST0_FT0, (void))
    176 DEF_HELPER(void, helper_fdivr_ST0_FT0, (void))
    177 DEF_HELPER(void, helper_fadd_STN_ST0, (int st_index))
    178 DEF_HELPER(void, helper_fmul_STN_ST0, (int st_index))
    179 DEF_HELPER(void, helper_fsub_STN_ST0, (int st_index))
    180 DEF_HELPER(void, helper_fsubr_STN_ST0, (int st_index))
    181 DEF_HELPER(void, helper_fdiv_STN_ST0, (int st_index))
    182 DEF_HELPER(void, helper_fdivr_STN_ST0, (int st_index))
    183 DEF_HELPER(void, helper_fchs_ST0, (void))
    184 DEF_HELPER(void, helper_fabs_ST0, (void))
    185 DEF_HELPER(void, helper_fxam_ST0, (void))
    186 DEF_HELPER(void, helper_fld1_ST0, (void))
    187 DEF_HELPER(void, helper_fldl2t_ST0, (void))
    188 DEF_HELPER(void, helper_fldl2e_ST0, (void))
    189 DEF_HELPER(void, helper_fldpi_ST0, (void))
    190 DEF_HELPER(void, helper_fldlg2_ST0, (void))
    191 DEF_HELPER(void, helper_fldln2_ST0, (void))
    192 DEF_HELPER(void, helper_fldz_ST0, (void))
    193 DEF_HELPER(void, helper_fldz_FT0, (void))
     136DEF_HELPER_1(fldt_ST0, void, tl)
     137DEF_HELPER_1(fstt_ST0, void, tl)
     138DEF_HELPER_0(fpush, void)
     139DEF_HELPER_0(fpop, void)
     140DEF_HELPER_0(fdecstp, void)
     141DEF_HELPER_0(fincstp, void)
     142DEF_HELPER_1(ffree_STN, void, int)
     143DEF_HELPER_0(fmov_ST0_FT0, void)
     144DEF_HELPER_1(fmov_FT0_STN, void, int)
     145DEF_HELPER_1(fmov_ST0_STN, void, int)
     146DEF_HELPER_1(fmov_STN_ST0, void, int)
     147DEF_HELPER_1(fxchg_ST0_STN, void, int)
     148DEF_HELPER_0(fcom_ST0_FT0, void)
     149DEF_HELPER_0(fucom_ST0_FT0, void)
     150DEF_HELPER_0(fcomi_ST0_FT0, void)
     151DEF_HELPER_0(fucomi_ST0_FT0, void)
     152DEF_HELPER_0(fadd_ST0_FT0, void)
     153DEF_HELPER_0(fmul_ST0_FT0, void)
     154DEF_HELPER_0(fsub_ST0_FT0, void)
     155DEF_HELPER_0(fsubr_ST0_FT0, void)
     156DEF_HELPER_0(fdiv_ST0_FT0, void)
     157DEF_HELPER_0(fdivr_ST0_FT0, void)
     158DEF_HELPER_1(fadd_STN_ST0, void, int)
     159DEF_HELPER_1(fmul_STN_ST0, void, int)
     160DEF_HELPER_1(fsub_STN_ST0, void, int)
     161DEF_HELPER_1(fsubr_STN_ST0, void, int)
     162DEF_HELPER_1(fdiv_STN_ST0, void, int)
     163DEF_HELPER_1(fdivr_STN_ST0, void, int)
     164DEF_HELPER_0(fchs_ST0, void)
     165DEF_HELPER_0(fabs_ST0, void)
     166DEF_HELPER_0(fxam_ST0, void)
     167DEF_HELPER_0(fld1_ST0, void)
     168DEF_HELPER_0(fldl2t_ST0, void)
     169DEF_HELPER_0(fldl2e_ST0, void)
     170DEF_HELPER_0(fldpi_ST0, void)
     171DEF_HELPER_0(fldlg2_ST0, void)
     172DEF_HELPER_0(fldln2_ST0, void)
     173DEF_HELPER_0(fldz_ST0, void)
     174DEF_HELPER_0(fldz_FT0, void)
    194175#ifndef VBOX
    195 DEF_HELPER(uint32_t, helper_fnstsw, (void))
    196 DEF_HELPER(uint32_t, helper_fnstcw, (void))
     176DEF_HELPER_0(fnstsw, i32)
     177DEF_HELPER_0(fnstcw, i32)
    197178#else  /* VBOX */
    198 DEF_HELPER(RTCCUINTREG, helper_fnstsw, (void))
    199 DEF_HELPER(RTCCUINTREG, helper_fnstcw, (void))
     179DEF_HELPER_0(fnstsw, RTCCUINTREG)
     180DEF_HELPER_0(fnstcw, RTCCUINTREG)
    200181#endif /* VBOX */
    201 DEF_HELPER(void, helper_fldcw, (uint32_t val))
    202 DEF_HELPER(void, helper_fclex, (void))
    203 DEF_HELPER(void, helper_fwait, (void))
    204 DEF_HELPER(void, helper_fninit, (void))
    205 DEF_HELPER(void, helper_fbld_ST0, (target_ulong ptr))
    206 DEF_HELPER(void, helper_fbst_ST0, (target_ulong ptr))
    207 DEF_HELPER(void, helper_f2xm1, (void))
    208 DEF_HELPER(void, helper_fyl2x, (void))
    209 DEF_HELPER(void, helper_fptan, (void))
    210 DEF_HELPER(void, helper_fpatan, (void))
    211 DEF_HELPER(void, helper_fxtract, (void))
    212 DEF_HELPER(void, helper_fprem1, (void))
    213 DEF_HELPER(void, helper_fprem, (void))
    214 DEF_HELPER(void, helper_fyl2xp1, (void))
    215 DEF_HELPER(void, helper_fsqrt, (void))
    216 DEF_HELPER(void, helper_fsincos, (void))
    217 DEF_HELPER(void, helper_frndint, (void))
    218 DEF_HELPER(void, helper_fscale, (void))
    219 DEF_HELPER(void, helper_fsin, (void))
    220 DEF_HELPER(void, helper_fcos, (void))
    221 DEF_HELPER(void, helper_fstenv, (target_ulong ptr, int data32))
    222 DEF_HELPER(void, helper_fldenv, (target_ulong ptr, int data32))
    223 DEF_HELPER(void, helper_fsave, (target_ulong ptr, int data32))
    224 DEF_HELPER(void, helper_frstor, (target_ulong ptr, int data32))
    225 DEF_HELPER(void, helper_fxsave, (target_ulong ptr, int data64))
    226 DEF_HELPER(void, helper_fxrstor, (target_ulong ptr, int data64))
    227 DEF_HELPER(target_ulong, helper_bsf, (target_ulong t0))
    228 DEF_HELPER(target_ulong, helper_bsr, (target_ulong t0))
     182DEF_HELPER_1(fldcw, void, i32)
     183DEF_HELPER_0(fclex, void)
     184DEF_HELPER_0(fwait, void)
     185DEF_HELPER_0(fninit, void)
     186DEF_HELPER_1(fbld_ST0, void, tl)
     187DEF_HELPER_1(fbst_ST0, void, tl)
     188DEF_HELPER_0(f2xm1, void)
     189DEF_HELPER_0(fyl2x, void)
     190DEF_HELPER_0(fptan, void)
     191DEF_HELPER_0(fpatan, void)
     192DEF_HELPER_0(fxtract, void)
     193DEF_HELPER_0(fprem1, void)
     194DEF_HELPER_0(fprem, void)
     195DEF_HELPER_0(fyl2xp1, void)
     196DEF_HELPER_0(fsqrt, void)
     197DEF_HELPER_0(fsincos, void)
     198DEF_HELPER_0(frndint, void)
     199DEF_HELPER_0(fscale, void)
     200DEF_HELPER_0(fsin, void)
     201DEF_HELPER_0(fcos, void)
     202DEF_HELPER_2(fstenv, void, tl, int)
     203DEF_HELPER_2(fldenv, void, tl, int)
     204DEF_HELPER_2(fsave, void, tl, int)
     205DEF_HELPER_2(frstor, void, tl, int)
     206DEF_HELPER_2(fxsave, void, tl, int)
     207DEF_HELPER_2(fxrstor, void, tl, int)
     208DEF_HELPER_1(bsf, tl, tl)
     209DEF_HELPER_1(bsr, tl, tl)
    229210
    230211/* MMX/SSE */
    231212
    232 DEF_HELPER(void, helper_enter_mmx, (void))
    233 DEF_HELPER(void, helper_emms, (void))
    234 DEF_HELPER(void, helper_movq, (uint64_t *d, uint64_t *s))
     213DEF_HELPER_0(enter_mmx, void)
     214DEF_HELPER_0(emms, void)
     215DEF_HELPER_2(movq, void, ptr, ptr)
    235216
    236217#define SHIFT 0
     
    239220#include "ops_sse_header.h"
    240221
    241 DEF_HELPER(target_ulong, helper_rclb, (target_ulong t0, target_ulong t1))
    242 DEF_HELPER(target_ulong, helper_rclw, (target_ulong t0, target_ulong t1))
    243 DEF_HELPER(target_ulong, helper_rcll, (target_ulong t0, target_ulong t1))
    244 DEF_HELPER(target_ulong, helper_rcrb, (target_ulong t0, target_ulong t1))
    245 DEF_HELPER(target_ulong, helper_rcrw, (target_ulong t0, target_ulong t1))
    246 DEF_HELPER(target_ulong, helper_rcrl, (target_ulong t0, target_ulong t1))
    247 #ifdef TARGET_X86_64
    248 DEF_HELPER(target_ulong, helper_rclq, (target_ulong t0, target_ulong t1))
    249 DEF_HELPER(target_ulong, helper_rcrq, (target_ulong t0, target_ulong t1))
     222DEF_HELPER_2(rclb, tl, tl, tl)
     223DEF_HELPER_2(rclw, tl, tl, tl)
     224DEF_HELPER_2(rcll, tl, tl, tl)
     225DEF_HELPER_2(rcrb, tl, tl, tl)
     226DEF_HELPER_2(rcrw, tl, tl, tl)
     227DEF_HELPER_2(rcrl, tl, tl, tl)
     228#ifdef TARGET_X86_64
     229DEF_HELPER_2(rclq, tl, tl, tl)
     230DEF_HELPER_2(rcrq, tl, tl, tl)
    250231#endif
    251232
    252233#ifdef VBOX
     234DEF_HELPER_1(write_eflags_vme, void, tl)
     235DEF_HELPER_0(read_eflags_vme, tl)
     236DEF_HELPER_0(cli_vme, void)
     237DEF_HELPER_0(sti_vme, void)
     238DEF_HELPER_0(rdtscp, void)
     239DEF_HELPER_0(check_external_event, void)
     240DEF_HELPER_0(dump_state, void)
     241DEF_HELPER_1(sync_seg, void, i32)
     242
    253243void helper_external_event(void);
    254244void helper_record_call(void);
     
    259249#endif /* VBOX */
    260250
    261 #undef DEF_HELPER
     251#include "def-helper.h"
  • trunk/src/recompiler/target-i386/helper_template.h

    r33656 r36170  
    1616 * You should have received a copy of the GNU Lesser General Public
    1717 * License along with this library; if not, write to the Free Software
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
    1919 */
    2020
     
    291291#endif
    292292    if (count) {
    293         eflags = cc_table[CC_OP].compute_all();
     293        eflags = helper_cc_compute_all(CC_OP);
    294294        t0 &= DATA_MASK;
    295295        src = t0;
     
    320320#endif
    321321    if (count) {
    322         eflags = cc_table[CC_OP].compute_all();
     322        eflags = helper_cc_compute_all(CC_OP);
    323323        t0 &= DATA_MASK;
    324324        src = t0;
  • trunk/src/recompiler/target-i386/op_helper.c

    r36140 r36170  
    1616 * You should have received a copy of the GNU Lesser General Public
    1717 * License along with this library; if not, write to the Free Software
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
    1919 */
    2020
     
    3030#define CPU_NO_GLOBAL_REGS
    3131#include "exec.h"
     32#include "exec-all.h"
    3233#include "host-utils.h"
    3334
     
    3940//#define DEBUG_PCALL
    4041
     42
     43#ifdef DEBUG_PCALL
     44#  define LOG_PCALL(...) qemu_log_mask(CPU_LOG_PCALL, ## __VA_ARGS__)
     45#  define LOG_PCALL_STATE(env) \
     46          log_cpu_state_mask(CPU_LOG_PCALL, (env), X86_DUMP_CCOP)
     47#else
     48#  define LOG_PCALL(...) do { } while (0)
     49#  define LOG_PCALL_STATE(env) do { } while (0)
     50#endif
     51
     52
    4153#if 0
    4254#define raise_exception_err(a, b)\
    4355do {\
    44     if (logfile)\
    45         fprintf(logfile, "raise_exception line=%d\n", __LINE__);\
     56    qemu_log("raise_exception line=%d\n", __LINE__);\
    4657    (raise_exception_err)(a, b);\
    4758} while (0)
    4859#endif
    4960
    50 const uint8_t parity_table[256] = {
     61static const uint8_t parity_table[256] = {
    5162    CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0,
    5263    0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P,
     
    8495
    8596/* modulo 17 table */
    86 const uint8_t rclw_table[32] = {
     97static const uint8_t rclw_table[32] = {
    8798    0, 1, 2, 3, 4, 5, 6, 7,
    8899    8, 9,10,11,12,13,14,15,
     
    92103
    93104/* modulo 9 table */
    94 const uint8_t rclb_table[32] = {
     105static const uint8_t rclb_table[32] = {
    95106    0, 1, 2, 3, 4, 5, 6, 7,
    96107    8, 0, 1, 2, 3, 4, 5, 6,
     
    99110};
    100111
    101 const CPU86_LDouble f15rk[7] =
     112static const CPU86_LDouble f15rk[7] =
    102113{
    103114    0.00000000000000000000L,
     
    112123/* broken thread support */
    113124
    114 spinlock_t global_cpu_lock = SPIN_LOCK_UNLOCKED;
     125static spinlock_t global_cpu_lock = SPIN_LOCK_UNLOCKED;
    115126
    116127void helper_lock(void)
     
    132143{
    133144    uint32_t eflags;
    134     eflags = cc_table[CC_OP].compute_all();
     145    eflags = helper_cc_compute_all(CC_OP);
    135146    eflags |= (DF & DF_MASK);
    136147    eflags |= env->eflags & ~(VM_MASK | RF_MASK);
     
    166177{
    167178    uint32_t eflags;
    168     eflags = cc_table[CC_OP].compute_all();
     179    eflags = helper_cc_compute_all(CC_OP);
    169180    eflags |= (DF & DF_MASK);
    170181    eflags |= env->eflags & ~(VM_MASK | RF_MASK);
     
    308319
    309320#ifdef VBOX
    310     e1 = e2 = 0;
     321    e1 = e2 = 0; /* gcc warning? */
    311322    cpl = env->hflags & HF_CPL_MASK;
    312323    /* Trying to load a selector with CPL=1? */
     
    392403
    393404    type = (e2 >> DESC_TYPE_SHIFT) & 0xf;
    394 #ifdef DEBUG_PCALL
    395     if (loglevel & CPU_LOG_PCALL)
    396         fprintf(logfile, "switch_tss: sel=0x%04x type=%d src=%d\n", tss_selector, type, source);
    397 #endif
    398 
    399 #if defined(VBOX) && defined(DEBUG)
    400     printf("switch_tss %x %x %x %d %08x\n", tss_selector, e1, e2, source, next_eip);
    401 #endif
     405    LOG_PCALL("switch_tss: sel=0x%04x type=%d src=%d\n", tss_selector, type, source);
    402406
    403407    /* if task gate, we read the TSS segment and we load it */
     
    628632        raise_exception_err(EXCP0D_GPF, 0);
    629633    }
     634
     635#ifndef CONFIG_USER_ONLY
     636    /* reset local breakpoints */
     637    if (env->dr[7] & 0x55) {
     638        for (i = 0; i < 4; i++) {
     639            if (hw_breakpoint_enabled(env->dr[7], i) == 0x1)
     640                hw_breakpoint_remove(env, i);
     641        }
     642        env->dr[7] &= ~0x55;
     643    }
     644#endif
    630645}
    631646
     
    787802    int type, dpl, selector, ss_dpl, cpl;
    788803    int has_error_code, new_stack, shift;
    789     uint32_t e1, e2, offset, ss, esp, ss_e1, ss_e2;
     804    uint32_t e1, e2, offset, ss = 0, esp, ss_e1 = 0, ss_e2 = 0;
    790805    uint32_t old_eip, sp_mask;
    791806
    792807#ifdef VBOX
    793     ss = ss_e1 = ss_e2 = 0;
    794808    if (remR3NotifyTrap(env, intno, error_code, next_eip) != VINF_SUCCESS)
    795809        cpu_loop_exit();
     
    12711285        env->eflags &= ~IF_MASK;
    12721286    }
    1273 
    12741287#ifndef VBOX
    12751288    env->eflags &= ~(TF_MASK | VM_MASK | RF_MASK | NT_MASK);
     
    12851298#endif
    12861299
     1300#ifdef TARGET_X86_64
    12871301#if defined(CONFIG_USER_ONLY)
    12881302void helper_syscall(int next_eip_addend)
     
    13011315    }
    13021316    selector = (env->star >> 32) & 0xffff;
    1303 #ifdef TARGET_X86_64
    13041317    if (env->hflags & HF_LMA_MASK) {
    13051318        int code64;
     
    13271340        else
    13281341            env->eip = env->cstar;
    1329     } else
    1330 #endif
    1331     {
     1342    } else {
    13321343        ECX = (uint32_t)(env->eip + next_eip_addend);
    13331344
     
    13481359}
    13491360#endif
    1350 
     1361#endif
     1362
     1363#ifdef TARGET_X86_64
    13511364void helper_sysret(int dflag)
    13521365{
     
    13611374    }
    13621375    selector = (env->star >> 48) & 0xffff;
    1363 #ifdef TARGET_X86_64
    13641376    if (env->hflags & HF_LMA_MASK) {
    13651377        if (dflag == 2) {
     
    13871399                    IF_MASK | IOPL_MASK | VM_MASK | RF_MASK | NT_MASK);
    13881400        cpu_x86_set_cpl(env, 3);
    1389     } else
    1390 #endif
    1391     {
     1401    } else {
    13921402        cpu_x86_load_seg_cache(env, R_CS, selector | 3,
    13931403                               0, 0xffffffff,
     
    14131423#endif
    14141424}
     1425#endif
    14151426
    14161427#ifdef VBOX
     
    14211432void helper_external_event(void)
    14221433{
    1423 #if defined(RT_OS_DARWIN) && defined(VBOX_STRICT)
     1434# if defined(RT_OS_DARWIN) && defined(VBOX_STRICT)
    14241435    uintptr_t uSP;
    1425 # ifdef RT_ARCH_AMD64
     1436#  ifdef RT_ARCH_AMD64
    14261437    __asm__ __volatile__("movq %%rsp, %0" : "=r" (uSP));
    1427 # else
     1438#  else
    14281439    __asm__ __volatile__("movl %%esp, %0" : "=r" (uSP));
     1440#  endif
     1441    AssertMsg(!(uSP & 15), ("xSP=%#p\n", uSP));
    14291442# endif
    1430     AssertMsg(!(uSP & 15), ("xSP=%#p\n", uSP));
    1431 #endif
    14321443    /* Keep in sync with flags checked by gen_check_external_event() */
    14331444    if (env->interrupt_request & CPU_INTERRUPT_EXTERNAL_HARD)
     
    15461557                  target_ulong next_eip, int is_hw)
    15471558{
     1559    if (qemu_loglevel_mask(CPU_LOG_INT)) {
     1560        if ((env->cr[0] & CR0_PE_MASK)) {
     1561            static int count;
     1562            qemu_log("%6d: v=%02x e=%04x i=%d cpl=%d IP=%04x:" TARGET_FMT_lx " pc=" TARGET_FMT_lx " SP=%04x:" TARGET_FMT_lx,
     1563                    count, intno, error_code, is_int,
     1564                    env->hflags & HF_CPL_MASK,
     1565                    env->segs[R_CS].selector, EIP,
     1566                    (int)env->segs[R_CS].base + EIP,
     1567                    env->segs[R_SS].selector, ESP);
     1568            if (intno == 0x0e) {
     1569                qemu_log(" CR2=" TARGET_FMT_lx, env->cr[2]);
     1570            } else {
     1571                qemu_log(" EAX=" TARGET_FMT_lx, EAX);
     1572            }
     1573            qemu_log("\n");
     1574            log_cpu_state(env, X86_DUMP_CCOP);
     1575#if 0
     1576            {
     1577                int i;
     1578                uint8_t *ptr;
     1579                qemu_log("       code=");
     1580                ptr = env->segs[R_CS].base + env->eip;
     1581                for(i = 0; i < 16; i++) {
     1582                    qemu_log(" %02x", ldub(ptr + i));
     1583                }
     1584                qemu_log("\n");
     1585            }
     1586#endif
     1587            count++;
     1588        }
     1589    }
    15481590#ifdef VBOX
    15491591    if (RT_UNLIKELY(env->state & CPU_EMULATE_SINGLE_STEP)) {
     
    15571599    }
    15581600#endif
    1559 
    1560     if (loglevel & CPU_LOG_INT) {
    1561         if ((env->cr[0] & CR0_PE_MASK)) {
    1562             static int count;
    1563             fprintf(logfile, "%6d: v=%02x e=%04x i=%d cpl=%d IP=%04x:" TARGET_FMT_lx " pc=" TARGET_FMT_lx " SP=%04x:" TARGET_FMT_lx,
    1564                     count, intno, error_code, is_int,
    1565                     env->hflags & HF_CPL_MASK,
    1566                     env->segs[R_CS].selector, EIP,
    1567                     (int)env->segs[R_CS].base + EIP,
    1568                     env->segs[R_SS].selector, ESP);
    1569             if (intno == 0x0e) {
    1570                 fprintf(logfile, " CR2=" TARGET_FMT_lx, env->cr[2]);
    1571             } else {
    1572                 fprintf(logfile, " EAX=" TARGET_FMT_lx, EAX);
    1573             }
    1574             fprintf(logfile, "\n");
    1575             cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
    1576 #if 0
    1577             {
    1578                 int i;
    1579                 uint8_t *ptr;
    1580                 fprintf(logfile, "       code=");
    1581                 ptr = env->segs[R_CS].base + env->eip;
    1582                 for(i = 0; i < 16; i++) {
    1583                     fprintf(logfile, " %02x", ldub(ptr + i));
    1584                 }
    1585                 fprintf(logfile, "\n");
    1586             }
    1587 #endif
    1588             count++;
    1589         }
    1590     }
    15911601    if (env->cr[0] & CR0_PE_MASK) {
    15921602#ifdef TARGET_X86_64
     
    16141624}
    16151625
     1626/* This should come from sysemu.h - if we could include it here... */
     1627void qemu_system_reset_request(void);
     1628
    16161629/*
    16171630 * Check nested exceptions and change to double or triple fault if
     
    16271640                               (intno >= 10 && intno <= 13);
    16281641
    1629     if (loglevel & CPU_LOG_INT)
    1630         fprintf(logfile, "check_exception old: 0x%x new 0x%x\n",
     1642    qemu_log_mask(CPU_LOG_INT, "check_exception old: 0x%x new 0x%x\n",
    16311643                env->old_exception, intno);
    16321644
    1633     if (env->old_exception == EXCP08_DBLE)
    1634         cpu_abort(env, "triple fault");
     1645#if !defined(CONFIG_USER_ONLY)
     1646    if (env->old_exception == EXCP08_DBLE) {
     1647        if (env->hflags & HF_SVMI_MASK)
     1648            helper_vmexit(SVM_EXIT_SHUTDOWN, 0); /* does not return */
     1649
     1650        qemu_log_mask(CPU_LOG_RESET, "Triple fault\n");
     1651
     1652# ifndef VBOX
     1653        qemu_system_reset_request();
     1654# else
     1655        remR3RaiseRC(env->pVM, VINF_EM_RESET); /** @todo test + improve tripple fault handling. */
     1656# endif
     1657        return EXCP_HLT;
     1658    }
     1659#endif
    16351660
    16361661    if ((first_contributory && second_contributory)
     
    16541679 * is_int is TRUE.
    16551680 */
    1656 void raise_interrupt(int intno, int is_int, int error_code,
    1657                      int next_eip_addend)
     1681static void QEMU_NORETURN raise_interrupt(int intno, int is_int, int error_code,
     1682                                          int next_eip_addend)
    16581683{
    16591684#if defined(VBOX) && defined(DEBUG)
     
    16761701/* shortcuts to generate exceptions */
    16771702
    1678 void (raise_exception_err)(int exception_index, int error_code)
     1703void raise_exception_err(int exception_index, int error_code)
    16791704{
    16801705    raise_interrupt(exception_index, 0, error_code, 0);
     
    17121737    int i, offset;
    17131738
    1714     if (loglevel & CPU_LOG_INT) {
    1715         fprintf(logfile, "SMM: enter\n");
    1716         cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
    1717     }
     1739    qemu_log_mask(CPU_LOG_INT, "SMM: enter\n");
     1740    log_cpu_state_mask(CPU_LOG_INT, env, X86_DUMP_CCOP);
    17181741
    17191742    env->hflags |= HF_SMM_MASK;
     
    18461869   cpu_abort(env, "helper_rsm");
    18471870#else /* !VBOX */
    1848     target_ulong sm_
    1849 
    18501871    target_ulong sm_state;
    18511872    int i, offset;
     
    19601981    cpu_smm_update(env);
    19611982
    1962     if (loglevel & CPU_LOG_INT) {
    1963         fprintf(logfile, "SMM: after RSM\n");
    1964         cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
    1965     }
     1983    qemu_log_mask(CPU_LOG_INT, "SMM: after RSM\n");
     1984    log_cpu_state_mask(CPU_LOG_INT, env, X86_DUMP_CCOP);
    19661985#endif /* !VBOX */
    19671986}
     
    21072126    int eflags;
    21082127
    2109     eflags = cc_table[CC_OP].compute_all();
     2128    eflags = helper_cc_compute_all(CC_OP);
    21102129    af = eflags & CC_A;
    21112130    al = EAX & 0xff;
     
    21232142    EAX = (EAX & ~0xffff) | al | (ah << 8);
    21242143    CC_SRC = eflags;
    2125     FORCE_RET();
    21262144}
    21272145
     
    21322150    int eflags;
    21332151
    2134     eflags = cc_table[CC_OP].compute_all();
     2152    eflags = helper_cc_compute_all(CC_OP);
    21352153    af = eflags & CC_A;
    21362154    al = EAX & 0xff;
     
    21482166    EAX = (EAX & ~0xffff) | al | (ah << 8);
    21492167    CC_SRC = eflags;
    2150     FORCE_RET();
    21512168}
    21522169
     
    21562173    int eflags;
    21572174
    2158     eflags = cc_table[CC_OP].compute_all();
     2175    eflags = helper_cc_compute_all(CC_OP);
    21592176    cf = eflags & CC_C;
    21602177    af = eflags & CC_A;
     
    21762193    eflags |= (al & 0x80); /* sf */
    21772194    CC_SRC = eflags;
    2178     FORCE_RET();
    21792195}
    21802196
     
    21842200    int eflags;
    21852201
    2186     eflags = cc_table[CC_OP].compute_all();
     2202    eflags = helper_cc_compute_all(CC_OP);
    21872203    cf = eflags & CC_C;
    21882204    af = eflags & CC_A;
     
    22072223    eflags |= (al & 0x80); /* sf */
    22082224    CC_SRC = eflags;
    2209     FORCE_RET();
    22102225}
    22112226
     
    22132228{
    22142229    int eflags;
    2215     eflags = cc_table[CC_OP].compute_all();
     2230    eflags = helper_cc_compute_all(CC_OP);
    22162231    if (eflags & CC_O) {
    22172232        raise_interrupt(EXCP04_INTO, 1, 0, next_eip_addend);
     
    22242239    int eflags;
    22252240
    2226     eflags = cc_table[CC_OP].compute_all();
     2241    eflags = helper_cc_compute_all(CC_OP);
    22272242    d = ldq(a0);
    22282243    if (d == (((uint64_t)EDX << 32) | (uint32_t)EAX)) {
     
    22472262    if ((a0 & 0xf) != 0)
    22482263        raise_exception(EXCP0D_GPF);
    2249     eflags = cc_table[CC_OP].compute_all();
     2264    eflags = helper_cc_compute_all(CC_OP);
    22502265    d0 = ldq(a0);
    22512266    d1 = ldq(a0 + 8);
     
    22682283void helper_single_step(void)
    22692284{
    2270     env->dr[6] |= 0x4000;
    2271     raise_exception(EXCP01_SSTP);
     2285#ifndef CONFIG_USER_ONLY
     2286    check_hw_breakpoints(env, 1);
     2287    env->dr[6] |= DR6_BS;
     2288#endif
     2289    raise_exception(EXCP01_DB);
    22722290}
    22732291
    22742292void helper_cpuid(void)
    22752293{
    2276 #ifndef VBOX
    2277     uint32_t index;
     2294    uint32_t eax, ebx, ecx, edx;
    22782295
    22792296    helper_svm_check_intercept_param(SVM_EXIT_CPUID, 0);
    22802297
    2281     index = (uint32_t)EAX;
    2282     /* test if maximum index reached */
    2283     if (index & 0x80000000) {
    2284         if (index > env->cpuid_xlevel)
    2285             index = env->cpuid_level;
    2286     } else {
    2287         if (index > env->cpuid_level)
    2288             index = env->cpuid_level;
    2289     }
    2290 
    2291     switch(index) {
    2292     case 0:
    2293         EAX = env->cpuid_level;
    2294         EBX = env->cpuid_vendor1;
    2295         EDX = env->cpuid_vendor2;
    2296         ECX = env->cpuid_vendor3;
    2297         break;
    2298     case 1:
    2299         EAX = env->cpuid_version;
    2300         EBX = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */
    2301         ECX = env->cpuid_ext_features;
    2302         EDX = env->cpuid_features;
    2303         break;
    2304     case 2:
    2305         /* cache info: needed for Pentium Pro compatibility */
    2306         EAX = 1;
    2307         EBX = 0;
    2308         ECX = 0;
    2309         EDX = 0x2c307d;
    2310         break;
    2311     case 4:
    2312         /* cache info: needed for Core compatibility */
    2313         switch (ECX) {
    2314             case 0: /* L1 dcache info */
    2315                 EAX = 0x0000121;
    2316                 EBX = 0x1c0003f;
    2317                 ECX = 0x000003f;
    2318                 EDX = 0x0000001;
    2319                 break;
    2320             case 1: /* L1 icache info */
    2321                 EAX = 0x0000122;
    2322                 EBX = 0x1c0003f;
    2323                 ECX = 0x000003f;
    2324                 EDX = 0x0000001;
    2325                 break;
    2326             case 2: /* L2 cache info */
    2327                 EAX = 0x0000143;
    2328                 EBX = 0x3c0003f;
    2329                 ECX = 0x0000fff;
    2330                 EDX = 0x0000001;
    2331                 break;
    2332             default: /* end of info */
    2333                 EAX = 0;
    2334                 EBX = 0;
    2335                 ECX = 0;
    2336                 EDX = 0;
    2337                 break;
    2338         }
    2339 
    2340         break;
    2341     case 5:
    2342         /* mwait info: needed for Core compatibility */
    2343         EAX = 0; /* Smallest monitor-line size in bytes */
    2344         EBX = 0; /* Largest monitor-line size in bytes */
    2345         ECX = CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;
    2346         EDX = 0;
    2347         break;
    2348     case 6:
    2349         /* Thermal and Power Leaf */
    2350         EAX = 0;
    2351         EBX = 0;
    2352         ECX = 0;
    2353         EDX = 0;
    2354         break;
    2355     case 9:
    2356         /* Direct Cache Access Information Leaf */
    2357         EAX = 0; /* Bits 0-31 in DCA_CAP MSR */
    2358         EBX = 0;
    2359         ECX = 0;
    2360         EDX = 0;
    2361         break;
    2362     case 0xA:
    2363         /* Architectural Performance Monitoring Leaf */
    2364         EAX = 0;
    2365         EBX = 0;
    2366         ECX = 0;
    2367         EDX = 0;
    2368         break;
    2369     case 0x80000000:
    2370         EAX = env->cpuid_xlevel;
    2371         EBX = env->cpuid_vendor1;
    2372         EDX = env->cpuid_vendor2;
    2373         ECX = env->cpuid_vendor3;
    2374         break;
    2375     case 0x80000001:
    2376         EAX = env->cpuid_features;
    2377         EBX = 0;
    2378         ECX = env->cpuid_ext3_features;
    2379         EDX = env->cpuid_ext2_features;
    2380         break;
    2381     case 0x80000002:
    2382     case 0x80000003:
    2383     case 0x80000004:
    2384         EAX = env->cpuid_model[(index - 0x80000002) * 4 + 0];
    2385         EBX = env->cpuid_model[(index - 0x80000002) * 4 + 1];
    2386         ECX = env->cpuid_model[(index - 0x80000002) * 4 + 2];
    2387         EDX = env->cpuid_model[(index - 0x80000002) * 4 + 3];
    2388         break;
    2389     case 0x80000005:
    2390         /* cache info (L1 cache) */
    2391         EAX = 0x01ff01ff;
    2392         EBX = 0x01ff01ff;
    2393         ECX = 0x40020140;
    2394         EDX = 0x40020140;
    2395         break;
    2396     case 0x80000006:
    2397         /* cache info (L2 cache) */
    2398         EAX = 0;
    2399         EBX = 0x42004200;
    2400         ECX = 0x02008140;
    2401         EDX = 0;
    2402         break;
    2403     case 0x80000008:
    2404         /* virtual & phys address size in low 2 bytes. */
    2405 /* XXX: This value must match the one used in the MMU code. */
    2406         if (env->cpuid_ext2_features & CPUID_EXT2_LM) {
    2407             /* 64 bit processor */
    2408 #if defined(USE_KQEMU)
    2409             EAX = 0x00003020;   /* 48 bits virtual, 32 bits physical */
    2410 #else
    2411 /* XXX: The physical address space is limited to 42 bits in exec.c. */
    2412             EAX = 0x00003028;   /* 48 bits virtual, 40 bits physical */
    2413 #endif
    2414         } else {
    2415 #if defined(USE_KQEMU)
    2416             EAX = 0x00000020;   /* 32 bits physical */
    2417 #else
    2418             if (env->cpuid_features & CPUID_PSE36)
    2419                 EAX = 0x00000024; /* 36 bits physical */
    2420             else
    2421                 EAX = 0x00000020; /* 32 bits physical */
    2422 #endif
    2423         }
    2424         EBX = 0;
    2425         ECX = 0;
    2426         EDX = 0;
    2427         break;
    2428     case 0x8000000A:
    2429         EAX = 0x00000001;
    2430         EBX = 0;
    2431         ECX = 0;
    2432         EDX = 0;
    2433         break;
    2434     default:
    2435         /* reserved values: zero */
    2436         EAX = 0;
    2437         EBX = 0;
    2438         ECX = 0;
    2439         EDX = 0;
    2440         break;
    2441     }
    2442 #else /* VBOX */
    2443     remR3CpuId(env, EAX, &EAX, &EBX, &ECX, &EDX);
    2444 #endif /* VBOX */
     2298    cpu_x86_cpuid(env, (uint32_t)EAX, (uint32_t)ECX, &eax, &ebx, &ecx, &edx);
     2299    EAX = eax;
     2300    EBX = ebx;
     2301    ECX = ecx;
     2302    EDX = edx;
    24452303}
    24462304
     
    27242582                       e2);
    27252583#if 0
    2726         fprintf(logfile, "load_seg: sel=0x%04x base=0x%08lx limit=0x%08lx flags=%08x\n",
     2584        qemu_log("load_seg: sel=0x%04x base=0x%08lx limit=0x%08lx flags=%08x\n",
    27272585                selector, (unsigned long)sc->base, sc->limit, sc->flags);
    27282586#endif
     
    27382596    target_ulong next_eip;
    27392597
    2740 #ifdef VBOX
     2598#ifdef VBOX /** @todo Why do we do this? */
    27412599    e1 = e2 = 0;
    27422600#endif
     
    28592717    int new_stack, i;
    28602718    uint32_t e1, e2, cpl, dpl, rpl, selector, offset, param_count;
    2861     uint32_t ss, ss_e1, ss_e2, sp, type, ss_dpl, sp_mask;
     2719    uint32_t ss = 0, ss_e1 = 0, ss_e2 = 0, sp, type, ss_dpl, sp_mask;
    28622720    uint32_t val, limit, old_sp_mask;
    28632721    target_ulong ssp, old_ssp, next_eip;
    28642722
    2865 #ifdef VBOX
    2866     ss = ss_e1 = ss_e2 = e1 = e2 = 0;
     2723#ifdef VBOX /** @todo Why do we do this? */
     2724    e1 = e2 = 0;
    28672725#endif
    28682726    next_eip = env->eip + next_eip_addend;
    2869 #ifdef DEBUG_PCALL
    2870     if (loglevel & CPU_LOG_PCALL) {
    2871         fprintf(logfile, "lcall %04x:%08x s=%d\n",
    2872                 new_cs, (uint32_t)new_eip, shift);
    2873         cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
    2874     }
    2875 #endif
     2727    LOG_PCALL("lcall %04x:%08x s=%d\n", new_cs, (uint32_t)new_eip, shift);
     2728    LOG_PCALL_STATE(env);
    28762729    if ((new_cs & 0xfffc) == 0)
    28772730        raise_exception_err(EXCP0D_GPF, 0);
     
    28792732        raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc);
    28802733    cpl = env->hflags & HF_CPL_MASK;
    2881 #ifdef DEBUG_PCALL
    2882     if (loglevel & CPU_LOG_PCALL) {
    2883         fprintf(logfile, "desc=%08x:%08x\n", e1, e2);
    2884     }
    2885 #endif
     2734    LOG_PCALL("desc=%08x:%08x\n", e1, e2);
    28862735    if (e2 & DESC_S_MASK) {
    28872736        if (!(e2 & DESC_CS_MASK))
     
    29872836            /* to inner privilege */
    29882837            get_ss_esp_from_tss(&ss, &sp, dpl);
    2989 #ifdef DEBUG_PCALL
    2990             if (loglevel & CPU_LOG_PCALL)
    2991                 fprintf(logfile, "new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n",
     2838            LOG_PCALL("new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n",
    29922839                        ss, sp, param_count, ESP);
    2993 #endif
    29942840            if ((ss & 0xfffc) == 0)
    29952841                raise_exception_err(EXCP0A_TSS, ss & 0xfffc);
     
    31783024    target_ulong ssp, sp, new_eip, new_esp, sp_mask;
    31793025
    3180 #ifdef VBOX
     3026#ifdef VBOX /** @todo Why do we do this? */
    31813027    ss_e1 = ss_e2 = e1 = e2 = 0;
    31823028#endif
     
    32333079            POPW(ssp, sp, sp_mask, new_eflags);
    32343080    }
    3235 #ifdef DEBUG_PCALL
    3236     if (loglevel & CPU_LOG_PCALL) {
    3237         fprintf(logfile, "lret new %04x:" TARGET_FMT_lx " s=%d addend=0x%x\n",
    3238                 new_cs, new_eip, shift, addend);
    3239         cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
    3240     }
    3241 #endif
     3081    LOG_PCALL("lret new %04x:" TARGET_FMT_lx " s=%d addend=0x%x\n",
     3082              new_cs, new_eip, shift, addend);
     3083    LOG_PCALL_STATE(env);
    32423084    if ((new_cs & 0xfffc) == 0)
    32433085    {
     
    33243166            POPW(ssp, sp, sp_mask, new_ss);
    33253167        }
    3326 #ifdef DEBUG_PCALL
    3327         if (loglevel & CPU_LOG_PCALL) {
    3328             fprintf(logfile, "new ss:esp=%04x:" TARGET_FMT_lx "\n",
     3168        LOG_PCALL("new ss:esp=%04x:" TARGET_FMT_lx "\n",
    33293169                    new_ss, new_esp);
    3330         }
    3331 #endif
    33323170        if ((new_ss & 0xfffc) == 0) {
    33333171#ifdef TARGET_X86_64
     
    34363274
    34373275#ifdef VBOX
    3438     e1 = e2 = 0;
     3276    e1 = e2 = 0; /** @todo Why do we do this? */
    34393277    remR3TrapClear(env->pVM);
    34403278#endif
     
    35673405{
    35683406}
     3407
     3408void helper_movl_drN_T0(int reg, target_ulong t0)
     3409{
     3410}
    35693411#else
    35703412target_ulong helper_read_crN(int reg)
     
    36123454    }
    36133455}
     3456
     3457void helper_movl_drN_T0(int reg, target_ulong t0)
     3458{
     3459    int i;
     3460
     3461    if (reg < 4) {
     3462        hw_breakpoint_remove(env, reg);
     3463        env->dr[reg] = t0;
     3464        hw_breakpoint_insert(env, reg);
     3465    } else if (reg == 7) {
     3466        for (i = 0; i < 4; i++)
     3467            hw_breakpoint_remove(env, i);
     3468        env->dr[7] = t0;
     3469        for (i = 0; i < 4; i++)
     3470            hw_breakpoint_insert(env, i);
     3471    } else
     3472        env->dr[reg] = t0;
     3473}
    36143474#endif
    36153475
     
    36263486    env->cr[0] &= ~CR0_TS_MASK;
    36273487    env->hflags &= ~HF_TS_MASK;
    3628 }
    3629 
    3630 /* XXX: do more */
    3631 void helper_movl_drN_T0(int reg, target_ulong t0)
    3632 {
    3633     env->dr[reg] = t0;
    36343488}
    36353489
     
    37213575        break;
    37223576    case MSR_IA32_APICBASE:
    3723 #ifndef VBOX /* The CPUMSetGuestMsr call below does this now. */
     3577# ifndef VBOX /* The CPUMSetGuestMsr call below does this now. */
    37243578        cpu_set_apic_base(env, val);
    3725 #endif
     3579# endif
    37263580        break;
    37273581    case MSR_EFER:
     
    37393593            if (env->cpuid_ext3_features & CPUID_EXT3_SVM)
    37403594                update_mask |= MSR_EFER_SVME;
     3595            if (env->cpuid_ext2_features & CPUID_EXT2_FFXSR)
     3596                update_mask |= MSR_EFER_FFXSR;
    37413597            cpu_load_efer(env, (env->efer & ~update_mask) |
    37423598                          (val & update_mask));
     
    37723628        break;
    37733629#endif
     3630# ifndef VBOX
     3631    case MSR_MTRRphysBase(0):
     3632    case MSR_MTRRphysBase(1):
     3633    case MSR_MTRRphysBase(2):
     3634    case MSR_MTRRphysBase(3):
     3635    case MSR_MTRRphysBase(4):
     3636    case MSR_MTRRphysBase(5):
     3637    case MSR_MTRRphysBase(6):
     3638    case MSR_MTRRphysBase(7):
     3639        env->mtrr_var[((uint32_t)ECX - MSR_MTRRphysBase(0)) / 2].base = val;
     3640        break;
     3641    case MSR_MTRRphysMask(0):
     3642    case MSR_MTRRphysMask(1):
     3643    case MSR_MTRRphysMask(2):
     3644    case MSR_MTRRphysMask(3):
     3645    case MSR_MTRRphysMask(4):
     3646    case MSR_MTRRphysMask(5):
     3647    case MSR_MTRRphysMask(6):
     3648    case MSR_MTRRphysMask(7):
     3649        env->mtrr_var[((uint32_t)ECX - MSR_MTRRphysMask(0)) / 2].mask = val;
     3650        break;
     3651    case MSR_MTRRfix64K_00000:
     3652        env->mtrr_fixed[(uint32_t)ECX - MSR_MTRRfix64K_00000] = val;
     3653        break;
     3654    case MSR_MTRRfix16K_80000:
     3655    case MSR_MTRRfix16K_A0000:
     3656        env->mtrr_fixed[(uint32_t)ECX - MSR_MTRRfix16K_80000 + 1] = val;
     3657        break;
     3658    case MSR_MTRRfix4K_C0000:
     3659    case MSR_MTRRfix4K_C8000:
     3660    case MSR_MTRRfix4K_D0000:
     3661    case MSR_MTRRfix4K_D8000:
     3662    case MSR_MTRRfix4K_E0000:
     3663    case MSR_MTRRfix4K_E8000:
     3664    case MSR_MTRRfix4K_F0000:
     3665    case MSR_MTRRfix4K_F8000:
     3666        env->mtrr_fixed[(uint32_t)ECX - MSR_MTRRfix4K_C0000 + 3] = val;
     3667        break;
     3668    case MSR_MTRRdefType:
     3669        env->mtrr_deftype = val;
     3670        break;
     3671# endif /* !VBOX */
    37743672    default:
    3775 #ifndef VBOX
     3673# ifndef VBOX
    37763674        /* XXX: exception ? */
    3777 #endif
    3778         break;
    3779     }
    3780 
    3781 #ifdef VBOX
     3675# endif
     3676        break;
     3677    }
     3678
     3679# ifdef VBOX
    37823680    /* call CPUM. */
    37833681    if (cpu_wrmsr(env, (uint32_t)ECX, val) != 0)
     
    37853683        /** @todo be a brave man and raise a \#GP(0) here as we should... */
    37863684    }
    3787 #endif
     3685# endif
    37883686}
    37893687
     
    37913689{
    37923690    uint64_t val;
     3691
    37933692    helper_svm_check_intercept_param(SVM_EXIT_MSR, 0);
    37943693
     
    38183717        val = env->vm_hsave;
    38193718        break;
    3820 #ifndef VBOX /* forward to CPUMQueryGuestMsr. */
     3719# ifndef VBOX /* forward to CPUMQueryGuestMsr. */
    38213720    case MSR_IA32_PERF_STATUS:
    38223721        /* tsc_increment_by_tick */
     
    38253724        val |= (((uint64_t)4ULL) << 40);
    38263725        break;
    3827 #endif /* !VBOX */
     3726# endif /* !VBOX */
    38283727#ifdef TARGET_X86_64
    38293728    case MSR_LSTAR:
     
    38553754        break;
    38563755#endif
     3756# ifndef VBOX
     3757    case MSR_MTRRphysBase(0):
     3758    case MSR_MTRRphysBase(1):
     3759    case MSR_MTRRphysBase(2):
     3760    case MSR_MTRRphysBase(3):
     3761    case MSR_MTRRphysBase(4):
     3762    case MSR_MTRRphysBase(5):
     3763    case MSR_MTRRphysBase(6):
     3764    case MSR_MTRRphysBase(7):
     3765        val = env->mtrr_var[((uint32_t)ECX - MSR_MTRRphysBase(0)) / 2].base;
     3766        break;
     3767    case MSR_MTRRphysMask(0):
     3768    case MSR_MTRRphysMask(1):
     3769    case MSR_MTRRphysMask(2):
     3770    case MSR_MTRRphysMask(3):
     3771    case MSR_MTRRphysMask(4):
     3772    case MSR_MTRRphysMask(5):
     3773    case MSR_MTRRphysMask(6):
     3774    case MSR_MTRRphysMask(7):
     3775        val = env->mtrr_var[((uint32_t)ECX - MSR_MTRRphysMask(0)) / 2].mask;
     3776        break;
     3777    case MSR_MTRRfix64K_00000:
     3778        val = env->mtrr_fixed[0];
     3779        break;
     3780    case MSR_MTRRfix16K_80000:
     3781    case MSR_MTRRfix16K_A0000:
     3782        val = env->mtrr_fixed[(uint32_t)ECX - MSR_MTRRfix16K_80000 + 1];
     3783        break;
     3784    case MSR_MTRRfix4K_C0000:
     3785    case MSR_MTRRfix4K_C8000:
     3786    case MSR_MTRRfix4K_D0000:
     3787    case MSR_MTRRfix4K_D8000:
     3788    case MSR_MTRRfix4K_E0000:
     3789    case MSR_MTRRfix4K_E8000:
     3790    case MSR_MTRRfix4K_F0000:
     3791    case MSR_MTRRfix4K_F8000:
     3792        val = env->mtrr_fixed[(uint32_t)ECX - MSR_MTRRfix4K_C0000 + 3];
     3793        break;
     3794    case MSR_MTRRdefType:
     3795        val = env->mtrr_deftype;
     3796        break;
     3797    case MSR_MTRRcap:
     3798        if (env->cpuid_features & CPUID_MTRR)
     3799            val = MSR_MTRRcap_VCNT | MSR_MTRRcap_FIXRANGE_SUPPORT | MSR_MTRRcap_WC_SUPPORTED;
     3800        else
     3801            /* XXX: exception ? */
     3802            val = 0;
     3803        break;
     3804# endif /* !VBOX */
    38573805    default:
    3858 #ifndef VBOX
     3806# ifndef VBOX
    38593807        /* XXX: exception ? */
    38603808        val = 0;
    3861 #else  /* VBOX */
     3809# else  /* VBOX */
    38623810        if (cpu_rdmsr(env, (uint32_t)ECX, &val) != 0)
    38633811        {
     
    38653813            val = 0;
    38663814        }
    3867 #endif /* VBOX */
     3815# endif /* VBOX */
    38683816        break;
    38693817    }
     
    38713819    EDX = (uint32_t)(val >> 32);
    38723820
    3873 #ifdef VBOX_STRICT
     3821# ifdef VBOX_STRICT
    38743822    if (cpu_rdmsr(env, (uint32_t)ECX, &val) != 0)
    38753823        val = 0;
    38763824    AssertMsg(val == RT_MAKE_U64(EAX, EDX), ("idMsr=%#x val=%#llx eax:edx=%#llx\n", (uint32_t)ECX, val, RT_MAKE_U64(EAX, EDX)));
    3877 #endif
     3825# endif
    38783826}
    38793827#endif
     
    38863834
    38873835    selector = selector1 & 0xffff;
    3888     eflags = cc_table[CC_OP].compute_all();
     3836    eflags = helper_cc_compute_all(CC_OP);
    38893837    if (load_segment(&e1, &e2, selector) != 0)
    38903838        goto fail;
     
    39283876
    39293877    selector = selector1 & 0xffff;
    3930     eflags = cc_table[CC_OP].compute_all();
     3878    eflags = helper_cc_compute_all(CC_OP);
    39313879    if ((selector & 0xfffc) == 0)
    39323880        goto fail;
     
    39743922
    39753923    selector = selector1 & 0xffff;
    3976     eflags = cc_table[CC_OP].compute_all();
     3924    eflags = helper_cc_compute_all(CC_OP);
    39773925    if ((selector & 0xfffc) == 0)
    39783926        goto fail;
     
    40073955
    40083956    selector = selector1 & 0xffff;
    4009     eflags = cc_table[CC_OP].compute_all();
     3957    eflags = helper_cc_compute_all(CC_OP);
    40103958    if ((selector & 0xfffc) == 0)
    40113959        goto fail;
     
    40473995}
    40483996
    4049 void fpu_raise_exception(void)
     3997static void fpu_raise_exception(void)
    40503998{
    40513999    if (env->cr[0] & CR0_NE_MASK) {
     
    42974245    ret = floatx_compare(ST0, FT0, &env->fp_status);
    42984246    env->fpus = (env->fpus & ~0x4500) | fcom_ccval[ret + 1];
    4299     FORCE_RET();
    43004247}
    43014248
     
    43064253    ret = floatx_compare_quiet(ST0, FT0, &env->fp_status);
    43074254    env->fpus = (env->fpus & ~0x4500) | fcom_ccval[ret+ 1];
    4308     FORCE_RET();
    43094255}
    43104256
     
    43174263
    43184264    ret = floatx_compare(ST0, FT0, &env->fp_status);
    4319     eflags = cc_table[CC_OP].compute_all();
     4265    eflags = helper_cc_compute_all(CC_OP);
    43204266    eflags = (eflags & ~(CC_Z | CC_P | CC_C)) | fcomi_ccval[ret + 1];
    43214267    CC_SRC = eflags;
    4322     FORCE_RET();
    43234268}
    43244269
     
    43294274
    43304275    ret = floatx_compare_quiet(ST0, FT0, &env->fp_status);
    4331     eflags = cc_table[CC_OP].compute_all();
     4276    eflags = helper_cc_compute_all(CC_OP);
    43324277    eflags = (eflags & ~(CC_Z | CC_P | CC_C)) | fcomi_ccval[ret + 1];
    43334278    CC_SRC = eflags;
    4334     FORCE_RET();
    43354279}
    43364280
     
    45254469    if (env->fpus & FPUS_SE)
    45264470        fpu_raise_exception();
    4527     FORCE_RET();
    45284471}
    45294472
     
    50404983            nb_xmm_regs = 8;
    50414984        addr = ptr + 0xa0;
    5042         for(i = 0; i < nb_xmm_regs; i++) {
    5043             stq(addr, env->xmm_regs[i].XMM_Q(0));
    5044             stq(addr + 8, env->xmm_regs[i].XMM_Q(1));
    5045             addr += 16;
     4985        /* Fast FXSAVE leaves out the XMM registers */
     4986        if (!(env->efer & MSR_EFER_FFXSR)
     4987          || (env->hflags & HF_CPL_MASK)
     4988          || !(env->hflags & HF_LMA_MASK)) {
     4989            for(i = 0; i < nb_xmm_regs; i++) {
     4990                stq(addr, env->xmm_regs[i].XMM_Q(0));
     4991                stq(addr + 8, env->xmm_regs[i].XMM_Q(1));
     4992                addr += 16;
     4993            }
    50464994        }
    50474995    }
     
    50805028            nb_xmm_regs = 8;
    50815029        addr = ptr + 0xa0;
    5082         for(i = 0; i < nb_xmm_regs; i++) {
     5030        /* Fast FXRESTORE leaves out the XMM registers */
     5031        if (!(env->efer & MSR_EFER_FFXSR)
     5032          || (env->hflags & HF_CPL_MASK)
     5033          || !(env->hflags & HF_LMA_MASK)) {
     5034            for(i = 0; i < nb_xmm_regs; i++) {
    50835035#if !defined(VBOX) || __GNUC__ < 4
    5084             env->xmm_regs[i].XMM_Q(0) = ldq(addr);
    5085             env->xmm_regs[i].XMM_Q(1) = ldq(addr + 8);
     5036                env->xmm_regs[i].XMM_Q(0) = ldq(addr);
     5037                env->xmm_regs[i].XMM_Q(1) = ldq(addr + 8);
    50865038#else /* VBOX + __GNUC__ >= 4: gcc 4.x compiler bug - it runs out of registers for the 64-bit value. */
    50875039# if 1
    5088             env->xmm_regs[i].XMM_L(0) = ldl(addr);
    5089             env->xmm_regs[i].XMM_L(1) = ldl(addr + 4);
    5090             env->xmm_regs[i].XMM_L(2) = ldl(addr + 8);
    5091             env->xmm_regs[i].XMM_L(3) = ldl(addr + 12);
     5040                env->xmm_regs[i].XMM_L(0) = ldl(addr);
     5041                env->xmm_regs[i].XMM_L(1) = ldl(addr + 4);
     5042                env->xmm_regs[i].XMM_L(2) = ldl(addr + 8);
     5043                env->xmm_regs[i].XMM_L(3) = ldl(addr + 12);
    50925044# else
    5093             /* this works fine on Mac OS X, gcc 4.0.1 */
    5094             uint64_t u64 = ldq(addr);
    5095             env->xmm_regs[i].XMM_Q(0);
    5096             u64 = ldq(addr + 4);
    5097             env->xmm_regs[i].XMM_Q(1) = u64;
     5045                /* this works fine on Mac OS X, gcc 4.0.1 */
     5046                uint64_t u64 = ldq(addr);
     5047                env->xmm_regs[i].XMM_Q(0);
     5048                u64 = ldq(addr + 4);
     5049                env->xmm_regs[i].XMM_Q(1) = u64;
    50985050# endif
    50995051#endif
    5100             addr += 16;
     5052                addr += 16;
     5053            }
    51015054        }
    51025055    }
     
    54295382        raise_exception(EXCP05_BOUND);
    54305383    }
    5431     FORCE_RET();
    54325384}
    54335385
     
    54405392        raise_exception(EXCP05_BOUND);
    54415393    }
    5442     FORCE_RET();
    54435394}
    54445395
     
    55205471#endif /* VBOX */
    55215472
     5473#if !defined(CONFIG_USER_ONLY)
    55225474/* try to fill the TLB and return an exception if error. If retaddr is
    55235475   NULL, it means that the function was called in C code (i.e. not
     
    55525504    env = saved_env;
    55535505}
     5506#endif
    55545507
    55555508#ifdef VBOX
     
    61486101        addr = (uint32_t)EAX;
    61496102
    6150     if (loglevel & CPU_LOG_TB_IN_ASM)
    6151         fprintf(logfile,"vmrun! " TARGET_FMT_lx "\n", addr);
     6103    qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmrun! " TARGET_FMT_lx "\n", addr);
    61526104
    61536105    env->vm_vmcb = addr;
     
    62696221        stl_phys(env->vm_vmcb + offsetof(struct vmcb, control.event_inj), event_inj & ~SVM_EVTINJ_VALID);
    62706222
    6271         if (loglevel & CPU_LOG_TB_IN_ASM)
    6272             fprintf(logfile, "Injecting(%#hx): ", valid_err);
     6223        qemu_log_mask(CPU_LOG_TB_IN_ASM, "Injecting(%#hx): ", valid_err);
    62736224        /* FIXME: need to implement valid_err */
    62746225        switch (event_inj & SVM_EVTINJ_TYPE_MASK) {
     
    62786229                env->exception_is_int = 0;
    62796230                env->exception_next_eip = -1;
    6280                 if (loglevel & CPU_LOG_TB_IN_ASM)
    6281                     fprintf(logfile, "INTR");
     6231                qemu_log_mask(CPU_LOG_TB_IN_ASM, "INTR");
    62826232                /* XXX: is it always correct ? */
    62836233                do_interrupt(vector, 0, 0, 0, 1);
     
    62886238                env->exception_is_int = 0;
    62896239                env->exception_next_eip = EIP;
    6290                 if (loglevel & CPU_LOG_TB_IN_ASM)
    6291                     fprintf(logfile, "NMI");
     6240                qemu_log_mask(CPU_LOG_TB_IN_ASM, "NMI");
    62926241                cpu_loop_exit();
    62936242                break;
     
    62976246                env->exception_is_int = 0;
    62986247                env->exception_next_eip = -1;
    6299                 if (loglevel & CPU_LOG_TB_IN_ASM)
    6300                     fprintf(logfile, "EXEPT");
     6248                qemu_log_mask(CPU_LOG_TB_IN_ASM, "EXEPT");
    63016249                cpu_loop_exit();
    63026250                break;
     
    63066254                env->exception_is_int = 1;
    63076255                env->exception_next_eip = EIP;
    6308                 if (loglevel & CPU_LOG_TB_IN_ASM)
    6309                     fprintf(logfile, "SOFT");
     6256                qemu_log_mask(CPU_LOG_TB_IN_ASM, "SOFT");
    63106257                cpu_loop_exit();
    63116258                break;
    63126259        }
    6313         if (loglevel & CPU_LOG_TB_IN_ASM)
    6314             fprintf(logfile, " %#x %#x\n", env->exception_index, env->error_code);
     6260        qemu_log_mask(CPU_LOG_TB_IN_ASM, " %#x %#x\n", env->exception_index, env->error_code);
    63156261    }
    63166262}
     
    63326278        addr = (uint32_t)EAX;
    63336279
    6334     if (loglevel & CPU_LOG_TB_IN_ASM)
    6335         fprintf(logfile,"vmload! " TARGET_FMT_lx "\nFS: %016" PRIx64 " | " TARGET_FMT_lx "\n",
     6280    qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmload! " TARGET_FMT_lx "\nFS: %016" PRIx64 " | " TARGET_FMT_lx "\n",
    63366281                addr, ldq_phys(addr + offsetof(struct vmcb, save.fs.base)),
    63376282                env->segs[R_FS].base);
     
    63686313        addr = (uint32_t)EAX;
    63696314
    6370     if (loglevel & CPU_LOG_TB_IN_ASM)
    6371         fprintf(logfile,"vmsave! " TARGET_FMT_lx "\nFS: %016" PRIx64 " | " TARGET_FMT_lx "\n",
     6315    qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmsave! " TARGET_FMT_lx "\nFS: %016" PRIx64 " | " TARGET_FMT_lx "\n",
    63726316                addr, ldq_phys(addr + offsetof(struct vmcb, save.fs.base)),
    63736317                env->segs[R_FS].base);
     
    65216465    uint32_t int_ctl;
    65226466
    6523     if (loglevel & CPU_LOG_TB_IN_ASM)
    6524         fprintf(logfile,"vmexit(%08x, %016" PRIx64 ", %016" PRIx64 ", " TARGET_FMT_lx ")!\n",
     6467    qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmexit(%08x, %016" PRIx64 ", %016" PRIx64 ", " TARGET_FMT_lx ")!\n",
    65256468                exit_code, exit_info_1,
    65266469                ldq_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2)),
     
    66686611
    66696612/* XXX: suppress */
    6670 void helper_movq(uint64_t *d, uint64_t *s)
    6671 {
    6672     *d = *s;
     6613void helper_movq(void *d, void *s)
     6614{
     6615    *(uint64_t *)d = *(uint64_t *)s;
    66736616}
    66746617
     
    67406683}
    67416684
    6742 CCTable cc_table[CC_OP_NB] = {
    6743     [CC_OP_DYNAMIC] = { /* should never happen */ },
    6744 
    6745     [CC_OP_EFLAGS] = { compute_all_eflags, compute_c_eflags },
    6746 
    6747     [CC_OP_MULB] = { compute_all_mulb, compute_c_mull },
    6748     [CC_OP_MULW] = { compute_all_mulw, compute_c_mull },
    6749     [CC_OP_MULL] = { compute_all_mull, compute_c_mull },
    6750 
    6751     [CC_OP_ADDB] = { compute_all_addb, compute_c_addb },
    6752     [CC_OP_ADDW] = { compute_all_addw, compute_c_addw  },
    6753     [CC_OP_ADDL] = { compute_all_addl, compute_c_addl  },
    6754 
    6755     [CC_OP_ADCB] = { compute_all_adcb, compute_c_adcb },
    6756     [CC_OP_ADCW] = { compute_all_adcw, compute_c_adcw  },
    6757     [CC_OP_ADCL] = { compute_all_adcl, compute_c_adcl  },
    6758 
    6759     [CC_OP_SUBB] = { compute_all_subb, compute_c_subb  },
    6760     [CC_OP_SUBW] = { compute_all_subw, compute_c_subw  },
    6761     [CC_OP_SUBL] = { compute_all_subl, compute_c_subl  },
    6762 
    6763     [CC_OP_SBBB] = { compute_all_sbbb, compute_c_sbbb  },
    6764     [CC_OP_SBBW] = { compute_all_sbbw, compute_c_sbbw  },
    6765     [CC_OP_SBBL] = { compute_all_sbbl, compute_c_sbbl  },
    6766 
    6767     [CC_OP_LOGICB] = { compute_all_logicb, compute_c_logicb },
    6768     [CC_OP_LOGICW] = { compute_all_logicw, compute_c_logicw },
    6769     [CC_OP_LOGICL] = { compute_all_logicl, compute_c_logicl },
    6770 
    6771     [CC_OP_INCB] = { compute_all_incb, compute_c_incl },
    6772     [CC_OP_INCW] = { compute_all_incw, compute_c_incl },
    6773     [CC_OP_INCL] = { compute_all_incl, compute_c_incl },
    6774 
    6775     [CC_OP_DECB] = { compute_all_decb, compute_c_incl },
    6776     [CC_OP_DECW] = { compute_all_decw, compute_c_incl },
    6777     [CC_OP_DECL] = { compute_all_decl, compute_c_incl },
    6778 
    6779     [CC_OP_SHLB] = { compute_all_shlb, compute_c_shlb },
    6780     [CC_OP_SHLW] = { compute_all_shlw, compute_c_shlw },
    6781     [CC_OP_SHLL] = { compute_all_shll, compute_c_shll },
    6782 
    6783     [CC_OP_SARB] = { compute_all_sarb, compute_c_sarl },
    6784     [CC_OP_SARW] = { compute_all_sarw, compute_c_sarl },
    6785     [CC_OP_SARL] = { compute_all_sarl, compute_c_sarl },
     6685uint32_t helper_cc_compute_all(int op)
     6686{
     6687    switch (op) {
     6688    default: /* should never happen */ return 0;
     6689
     6690    case CC_OP_EFLAGS: return compute_all_eflags();
     6691
     6692    case CC_OP_MULB: return compute_all_mulb();
     6693    case CC_OP_MULW: return compute_all_mulw();
     6694    case CC_OP_MULL: return compute_all_mull();
     6695
     6696    case CC_OP_ADDB: return compute_all_addb();
     6697    case CC_OP_ADDW: return compute_all_addw();
     6698    case CC_OP_ADDL: return compute_all_addl();
     6699
     6700    case CC_OP_ADCB: return compute_all_adcb();
     6701    case CC_OP_ADCW: return compute_all_adcw();
     6702    case CC_OP_ADCL: return compute_all_adcl();
     6703
     6704    case CC_OP_SUBB: return compute_all_subb();
     6705    case CC_OP_SUBW: return compute_all_subw();
     6706    case CC_OP_SUBL: return compute_all_subl();
     6707
     6708    case CC_OP_SBBB: return compute_all_sbbb();
     6709    case CC_OP_SBBW: return compute_all_sbbw();
     6710    case CC_OP_SBBL: return compute_all_sbbl();
     6711
     6712    case CC_OP_LOGICB: return compute_all_logicb();
     6713    case CC_OP_LOGICW: return compute_all_logicw();
     6714    case CC_OP_LOGICL: return compute_all_logicl();
     6715
     6716    case CC_OP_INCB: return compute_all_incb();
     6717    case CC_OP_INCW: return compute_all_incw();
     6718    case CC_OP_INCL: return compute_all_incl();
     6719
     6720    case CC_OP_DECB: return compute_all_decb();
     6721    case CC_OP_DECW: return compute_all_decw();
     6722    case CC_OP_DECL: return compute_all_decl();
     6723
     6724    case CC_OP_SHLB: return compute_all_shlb();
     6725    case CC_OP_SHLW: return compute_all_shlw();
     6726    case CC_OP_SHLL: return compute_all_shll();
     6727
     6728    case CC_OP_SARB: return compute_all_sarb();
     6729    case CC_OP_SARW: return compute_all_sarw();
     6730    case CC_OP_SARL: return compute_all_sarl();
    67866731
    67876732#ifdef TARGET_X86_64
    6788     [CC_OP_MULQ] = { compute_all_mulq, compute_c_mull },
    6789 
    6790     [CC_OP_ADDQ] = { compute_all_addq, compute_c_addq  },
    6791 
    6792     [CC_OP_ADCQ] = { compute_all_adcq, compute_c_adcq  },
    6793 
    6794     [CC_OP_SUBQ] = { compute_all_subq, compute_c_subq  },
    6795 
    6796     [CC_OP_SBBQ] = { compute_all_sbbq, compute_c_sbbq  },
    6797 
    6798     [CC_OP_LOGICQ] = { compute_all_logicq, compute_c_logicq },
    6799 
    6800     [CC_OP_INCQ] = { compute_all_incq, compute_c_incl },
    6801 
    6802     [CC_OP_DECQ] = { compute_all_decq, compute_c_incl },
    6803 
    6804     [CC_OP_SHLQ] = { compute_all_shlq, compute_c_shlq },
    6805 
    6806     [CC_OP_SARQ] = { compute_all_sarq, compute_c_sarl },
    6807 #endif
    6808 };
    6809 
     6733    case CC_OP_MULQ: return compute_all_mulq();
     6734
     6735    case CC_OP_ADDQ: return compute_all_addq();
     6736
     6737    case CC_OP_ADCQ: return compute_all_adcq();
     6738
     6739    case CC_OP_SUBQ: return compute_all_subq();
     6740
     6741    case CC_OP_SBBQ: return compute_all_sbbq();
     6742
     6743    case CC_OP_LOGICQ: return compute_all_logicq();
     6744
     6745    case CC_OP_INCQ: return compute_all_incq();
     6746
     6747    case CC_OP_DECQ: return compute_all_decq();
     6748
     6749    case CC_OP_SHLQ: return compute_all_shlq();
     6750
     6751    case CC_OP_SARQ: return compute_all_sarq();
     6752#endif
     6753    }
     6754}
     6755
     6756uint32_t helper_cc_compute_c(int op)
     6757{
     6758    switch (op) {
     6759    default: /* should never happen */ return 0;
     6760
     6761    case CC_OP_EFLAGS: return compute_c_eflags();
     6762
     6763    case CC_OP_MULB: return compute_c_mull();
     6764    case CC_OP_MULW: return compute_c_mull();
     6765    case CC_OP_MULL: return compute_c_mull();
     6766
     6767    case CC_OP_ADDB: return compute_c_addb();
     6768    case CC_OP_ADDW: return compute_c_addw();
     6769    case CC_OP_ADDL: return compute_c_addl();
     6770
     6771    case CC_OP_ADCB: return compute_c_adcb();
     6772    case CC_OP_ADCW: return compute_c_adcw();
     6773    case CC_OP_ADCL: return compute_c_adcl();
     6774
     6775    case CC_OP_SUBB: return compute_c_subb();
     6776    case CC_OP_SUBW: return compute_c_subw();
     6777    case CC_OP_SUBL: return compute_c_subl();
     6778
     6779    case CC_OP_SBBB: return compute_c_sbbb();
     6780    case CC_OP_SBBW: return compute_c_sbbw();
     6781    case CC_OP_SBBL: return compute_c_sbbl();
     6782
     6783    case CC_OP_LOGICB: return compute_c_logicb();
     6784    case CC_OP_LOGICW: return compute_c_logicw();
     6785    case CC_OP_LOGICL: return compute_c_logicl();
     6786
     6787    case CC_OP_INCB: return compute_c_incl();
     6788    case CC_OP_INCW: return compute_c_incl();
     6789    case CC_OP_INCL: return compute_c_incl();
     6790
     6791    case CC_OP_DECB: return compute_c_incl();
     6792    case CC_OP_DECW: return compute_c_incl();
     6793    case CC_OP_DECL: return compute_c_incl();
     6794
     6795    case CC_OP_SHLB: return compute_c_shlb();
     6796    case CC_OP_SHLW: return compute_c_shlw();
     6797    case CC_OP_SHLL: return compute_c_shll();
     6798
     6799    case CC_OP_SARB: return compute_c_sarl();
     6800    case CC_OP_SARW: return compute_c_sarl();
     6801    case CC_OP_SARL: return compute_c_sarl();
     6802
     6803#ifdef TARGET_X86_64
     6804    case CC_OP_MULQ: return compute_c_mull();
     6805
     6806    case CC_OP_ADDQ: return compute_c_addq();
     6807
     6808    case CC_OP_ADCQ: return compute_c_adcq();
     6809
     6810    case CC_OP_SUBQ: return compute_c_subq();
     6811
     6812    case CC_OP_SBBQ: return compute_c_sbbq();
     6813
     6814    case CC_OP_LOGICQ: return compute_c_logicq();
     6815
     6816    case CC_OP_INCQ: return compute_c_incl();
     6817
     6818    case CC_OP_DECQ: return compute_c_incl();
     6819
     6820    case CC_OP_SHLQ: return compute_c_shlq();
     6821
     6822    case CC_OP_SARQ: return compute_c_sarl();
     6823#endif
     6824    }
     6825}
  • trunk/src/recompiler/target-i386/ops_sse.h

    r36140 r36170  
    1717 * You should have received a copy of the GNU Lesser General Public
    1818 * License along with this library; if not, write to the Free Software
    19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
    2020 */
    2121
     
    6969#endif
    7070    }
    71     FORCE_RET();
    7271}
    7372
     
    115114#endif
    116115    }
    117     FORCE_RET();
    118116}
    119117
     
    136134#endif
    137135    }
    138     FORCE_RET();
    139136}
    140137
     
    174171#endif
    175172    }
    176     FORCE_RET();
    177173}
    178174
     
    193189#endif
    194190    }
    195     FORCE_RET();
    196191}
    197192
     
    212207#endif
    213208    }
    214     FORCE_RET();
    215209}
    216210
     
    227221    for(i = 16 - shift; i < 16; i++)
    228222        d->B(i) = 0;
    229     FORCE_RET();
    230223}
    231224
     
    241234    for(i = 0; i < shift; i++)
    242235        d->B(i) = 0;
    243     FORCE_RET();
    244236}
    245237#endif
     
    443435            (int16_t)s->W(2*i+1) * (int16_t)d->W(2*i+1);
    444436    }
    445     FORCE_RET();
    446437}
    447438
     
    490481            stb(a0 + i, d->B(i));
    491482    }
    492     FORCE_RET();
    493483}
    494484
     
    928918    ret = float32_compare_quiet(s0, s1, &env->sse_status);
    929919    CC_SRC = comis_eflags[ret + 1];
    930     FORCE_RET();
    931920}
    932921
     
    940929    ret = float32_compare(s0, s1, &env->sse_status);
    941930    CC_SRC = comis_eflags[ret + 1];
    942     FORCE_RET();
    943931}
    944932
     
    952940    ret = float64_compare_quiet(d0, d1, &env->sse_status);
    953941    CC_SRC = comis_eflags[ret + 1];
    954     FORCE_RET();
    955942}
    956943
     
    964951    ret = float64_compare(d0, d1, &env->sse_status);
    965952    CC_SRC = comis_eflags[ret + 1];
    966     FORCE_RET();
    967953}
    968954
     
    991977    uint32_t val;
    992978    val = 0;
    993     val |= (s->XMM_B(0) >> 7);
    994     val |= (s->XMM_B(1) >> 6) & 0x02;
    995     val |= (s->XMM_B(2) >> 5) & 0x04;
    996     val |= (s->XMM_B(3) >> 4) & 0x08;
    997     val |= (s->XMM_B(4) >> 3) & 0x10;
    998     val |= (s->XMM_B(5) >> 2) & 0x20;
    999     val |= (s->XMM_B(6) >> 1) & 0x40;
    1000     val |= (s->XMM_B(7)) & 0x80;
    1001 #if SHIFT == 1
    1002     val |= (s->XMM_B(8) << 1) & 0x0100;
    1003     val |= (s->XMM_B(9) << 2) & 0x0200;
    1004     val |= (s->XMM_B(10) << 3) & 0x0400;
    1005     val |= (s->XMM_B(11) << 4) & 0x0800;
    1006     val |= (s->XMM_B(12) << 5) & 0x1000;
    1007     val |= (s->XMM_B(13) << 6) & 0x2000;
    1008     val |= (s->XMM_B(14) << 7) & 0x4000;
    1009     val |= (s->XMM_B(15) << 8) & 0x8000;
     979    val |= (s->B(0) >> 7);
     980    val |= (s->B(1) >> 6) & 0x02;
     981    val |= (s->B(2) >> 5) & 0x04;
     982    val |= (s->B(3) >> 4) & 0x08;
     983    val |= (s->B(4) >> 3) & 0x10;
     984    val |= (s->B(5) >> 2) & 0x20;
     985    val |= (s->B(6) >> 1) & 0x40;
     986    val |= (s->B(7)) & 0x80;
     987#if SHIFT == 1
     988    val |= (s->B(8) << 1) & 0x0100;
     989    val |= (s->B(9) << 2) & 0x0200;
     990    val |= (s->B(10) << 3) & 0x0400;
     991    val |= (s->B(11) << 4) & 0x0800;
     992    val |= (s->B(12) << 5) & 0x1000;
     993    val |= (s->B(13) << 6) & 0x2000;
     994    val |= (s->B(14) << 7) & 0x4000;
     995    val |= (s->B(15) << 8) & 0x8000;
    1010996#endif
    1011997    return val;
     
    15101496    d->elem(0) = F(0);\
    15111497    d->elem(1) = F(1);\
    1512     d->elem(2) = F(2);\
    1513     d->elem(3) = F(3);\
    1514     if (num > 3) {\
    1515         d->elem(4) = F(4);\
    1516         d->elem(5) = F(5);\
    1517         if (num > 5) {\
     1498    if (num > 2) {\
     1499        d->elem(2) = F(2);\
     1500        d->elem(3) = F(3);\
     1501        if (num > 4) {\
     1502            d->elem(4) = F(4);\
     1503            d->elem(5) = F(5);\
    15181504            d->elem(6) = F(6);\
    15191505            d->elem(7) = F(7);\
  • trunk/src/recompiler/target-i386/ops_sse_header.h

    r33656 r36170  
    1616 * You should have received a copy of the GNU Lesser General Public
    1717 * License along with this library; if not, write to the Free Software
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
    1919 */
    2020
     
    3636#endif
    3737
    38 DEF_HELPER(void, glue(helper_psrlw, SUFFIX), (Reg *d, Reg *s))
    39 DEF_HELPER(void, glue(helper_psraw, SUFFIX), (Reg *d, Reg *s))
    40 DEF_HELPER(void, glue(helper_psllw, SUFFIX), (Reg *d, Reg *s))
    41 DEF_HELPER(void, glue(helper_psrld, SUFFIX), (Reg *d, Reg *s))
    42 DEF_HELPER(void, glue(helper_psrad, SUFFIX), (Reg *d, Reg *s))
    43 DEF_HELPER(void, glue(helper_pslld, SUFFIX), (Reg *d, Reg *s))
    44 DEF_HELPER(void, glue(helper_psrlq, SUFFIX), (Reg *d, Reg *s))
    45 DEF_HELPER(void, glue(helper_psllq, SUFFIX), (Reg *d, Reg *s))
    46 
    47 #if SHIFT == 1
    48 DEF_HELPER(void, glue(helper_psrldq, SUFFIX), (Reg *d, Reg *s))
    49 DEF_HELPER(void, glue(helper_pslldq, SUFFIX), (Reg *d, Reg *s))
     38#define dh_alias_Reg ptr
     39#define dh_alias_XMMReg ptr
     40#define dh_alias_MMXReg ptr
     41#define dh_ctype_Reg Reg *
     42#define dh_ctype_XMMReg XMMReg *
     43#define dh_ctype_MMXReg MMXReg *
     44
     45DEF_HELPER_2(glue(psrlw, SUFFIX), void, Reg, Reg)
     46DEF_HELPER_2(glue(psraw, SUFFIX), void, Reg, Reg)
     47DEF_HELPER_2(glue(psllw, SUFFIX), void, Reg, Reg)
     48DEF_HELPER_2(glue(psrld, SUFFIX), void, Reg, Reg)
     49DEF_HELPER_2(glue(psrad, SUFFIX), void, Reg, Reg)
     50DEF_HELPER_2(glue(pslld, SUFFIX), void, Reg, Reg)
     51DEF_HELPER_2(glue(psrlq, SUFFIX), void, Reg, Reg)
     52DEF_HELPER_2(glue(psllq, SUFFIX), void, Reg, Reg)
     53
     54#if SHIFT == 1
     55DEF_HELPER_2(glue(psrldq, SUFFIX), void, Reg, Reg)
     56DEF_HELPER_2(glue(pslldq, SUFFIX), void, Reg, Reg)
    5057#endif
    5158
    5259#define SSE_HELPER_B(name, F)\
    53     DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
     60    DEF_HELPER_2(glue(name, SUFFIX), void, Reg, Reg)
    5461
    5562#define SSE_HELPER_W(name, F)\
    56     DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
     63    DEF_HELPER_2(glue(name, SUFFIX), void, Reg, Reg)
    5764
    5865#define SSE_HELPER_L(name, F)\
    59     DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
     66    DEF_HELPER_2(glue(name, SUFFIX), void, Reg, Reg)
    6067
    6168#define SSE_HELPER_Q(name, F)\
    62     DEF_HELPER(void, glue(name, SUFFIX), (Reg *d, Reg *s))
    63 
    64 SSE_HELPER_B(helper_paddb, FADD)
    65 SSE_HELPER_W(helper_paddw, FADD)
    66 SSE_HELPER_L(helper_paddl, FADD)
    67 SSE_HELPER_Q(helper_paddq, FADD)
    68 
    69 SSE_HELPER_B(helper_psubb, FSUB)
    70 SSE_HELPER_W(helper_psubw, FSUB)
    71 SSE_HELPER_L(helper_psubl, FSUB)
    72 SSE_HELPER_Q(helper_psubq, FSUB)
    73 
    74 SSE_HELPER_B(helper_paddusb, FADDUB)
    75 SSE_HELPER_B(helper_paddsb, FADDSB)
    76 SSE_HELPER_B(helper_psubusb, FSUBUB)
    77 SSE_HELPER_B(helper_psubsb, FSUBSB)
    78 
    79 SSE_HELPER_W(helper_paddusw, FADDUW)
    80 SSE_HELPER_W(helper_paddsw, FADDSW)
    81 SSE_HELPER_W(helper_psubusw, FSUBUW)
    82 SSE_HELPER_W(helper_psubsw, FSUBSW)
    83 
    84 SSE_HELPER_B(helper_pminub, FMINUB)
    85 SSE_HELPER_B(helper_pmaxub, FMAXUB)
    86 
    87 SSE_HELPER_W(helper_pminsw, FMINSW)
    88 SSE_HELPER_W(helper_pmaxsw, FMAXSW)
    89 
    90 SSE_HELPER_Q(helper_pand, FAND)
    91 SSE_HELPER_Q(helper_pandn, FANDN)
    92 SSE_HELPER_Q(helper_por, FOR)
    93 SSE_HELPER_Q(helper_pxor, FXOR)
    94 
    95 SSE_HELPER_B(helper_pcmpgtb, FCMPGTB)
    96 SSE_HELPER_W(helper_pcmpgtw, FCMPGTW)
    97 SSE_HELPER_L(helper_pcmpgtl, FCMPGTL)
    98 
    99 SSE_HELPER_B(helper_pcmpeqb, FCMPEQ)
    100 SSE_HELPER_W(helper_pcmpeqw, FCMPEQ)
    101 SSE_HELPER_L(helper_pcmpeql, FCMPEQ)
    102 
    103 SSE_HELPER_W(helper_pmullw, FMULLW)
     69    DEF_HELPER_2(glue(name, SUFFIX), void, Reg, Reg)
     70
     71SSE_HELPER_B(paddb, FADD)
     72SSE_HELPER_W(paddw, FADD)
     73SSE_HELPER_L(paddl, FADD)
     74SSE_HELPER_Q(paddq, FADD)
     75
     76SSE_HELPER_B(psubb, FSUB)
     77SSE_HELPER_W(psubw, FSUB)
     78SSE_HELPER_L(psubl, FSUB)
     79SSE_HELPER_Q(psubq, FSUB)
     80
     81SSE_HELPER_B(paddusb, FADDUB)
     82SSE_HELPER_B(paddsb, FADDSB)
     83SSE_HELPER_B(psubusb, FSUBUB)
     84SSE_HELPER_B(psubsb, FSUBSB)
     85
     86SSE_HELPER_W(paddusw, FADDUW)
     87SSE_HELPER_W(paddsw, FADDSW)
     88SSE_HELPER_W(psubusw, FSUBUW)
     89SSE_HELPER_W(psubsw, FSUBSW)
     90
     91SSE_HELPER_B(pminub, FMINUB)
     92SSE_HELPER_B(pmaxub, FMAXUB)
     93
     94SSE_HELPER_W(pminsw, FMINSW)
     95SSE_HELPER_W(pmaxsw, FMAXSW)
     96
     97SSE_HELPER_Q(pand, FAND)
     98SSE_HELPER_Q(pandn, FANDN)
     99SSE_HELPER_Q(por, FOR)
     100SSE_HELPER_Q(pxor, FXOR)
     101
     102SSE_HELPER_B(pcmpgtb, FCMPGTB)
     103SSE_HELPER_W(pcmpgtw, FCMPGTW)
     104SSE_HELPER_L(pcmpgtl, FCMPGTL)
     105
     106SSE_HELPER_B(pcmpeqb, FCMPEQ)
     107SSE_HELPER_W(pcmpeqw, FCMPEQ)
     108SSE_HELPER_L(pcmpeql, FCMPEQ)
     109
     110SSE_HELPER_W(pmullw, FMULLW)
    104111#if SHIFT == 0
    105 SSE_HELPER_W(helper_pmulhrw, FMULHRW)
    106 #endif
    107 SSE_HELPER_W(helper_pmulhuw, FMULHUW)
    108 SSE_HELPER_W(helper_pmulhw, FMULHW)
    109 
    110 SSE_HELPER_B(helper_pavgb, FAVG)
    111 SSE_HELPER_W(helper_pavgw, FAVG)
    112 
    113 DEF_HELPER(void, glue(helper_pmuludq, SUFFIX) , (Reg *d, Reg *s))
    114 DEF_HELPER(void, glue(helper_pmaddwd, SUFFIX) , (Reg *d, Reg *s))
    115 
    116 DEF_HELPER(void, glue(helper_psadbw, SUFFIX) , (Reg *d, Reg *s))
    117 DEF_HELPER(void, glue(helper_maskmov, SUFFIX) , (Reg *d, Reg *s, target_ulong a0))
    118 DEF_HELPER(void, glue(helper_movl_mm_T0, SUFFIX) , (Reg *d, uint32_t val))
     112SSE_HELPER_W(pmulhrw, FMULHRW)
     113#endif
     114SSE_HELPER_W(pmulhuw, FMULHUW)
     115SSE_HELPER_W(pmulhw, FMULHW)
     116
     117SSE_HELPER_B(pavgb, FAVG)
     118SSE_HELPER_W(pavgw, FAVG)
     119
     120DEF_HELPER_2(glue(pmuludq, SUFFIX), void, Reg, Reg)
     121DEF_HELPER_2(glue(pmaddwd, SUFFIX), void, Reg, Reg)
     122
     123DEF_HELPER_2(glue(psadbw, SUFFIX), void, Reg, Reg)
     124DEF_HELPER_3(glue(maskmov, SUFFIX), void, Reg, Reg, tl)
     125DEF_HELPER_2(glue(movl_mm_T0, SUFFIX), void, Reg, i32)
    119126#ifdef TARGET_X86_64
    120 DEF_HELPER(void, glue(helper_movq_mm_T0, SUFFIX) , (Reg *d, uint64_t val))
     127DEF_HELPER_2(glue(movq_mm_T0, SUFFIX), void, Reg, i64)
    121128#endif
    122129
    123130#if SHIFT == 0
    124 DEF_HELPER(void, glue(helper_pshufw, SUFFIX) , (Reg *d, Reg *s, int order))
     131DEF_HELPER_3(glue(pshufw, SUFFIX), void, Reg, Reg, int)
    125132#else
    126 DEF_HELPER(void, helper_shufps, (Reg *d, Reg *s, int order))
    127 DEF_HELPER(void, helper_shufpd, (Reg *d, Reg *s, int order))
    128 DEF_HELPER(void, glue(helper_pshufd, SUFFIX) , (Reg *d, Reg *s, int order))
    129 DEF_HELPER(void, glue(helper_pshuflw, SUFFIX) , (Reg *d, Reg *s, int order))
    130 DEF_HELPER(void, glue(helper_pshufhw, SUFFIX) , (Reg *d, Reg *s, int order))
     133DEF_HELPER_3(shufps, void, Reg, Reg, int)
     134DEF_HELPER_3(shufpd, void, Reg, Reg, int)
     135DEF_HELPER_3(glue(pshufd, SUFFIX), void, Reg, Reg, int)
     136DEF_HELPER_3(glue(pshuflw, SUFFIX), void, Reg, Reg, int)
     137DEF_HELPER_3(glue(pshufhw, SUFFIX), void, Reg, Reg, int)
    131138#endif
    132139
     
    136143
    137144#define SSE_HELPER_S(name, F)\
    138     DEF_HELPER(void, helper_ ## name ## ps , (Reg *d, Reg *s))        \
    139     DEF_HELPER(void, helper_ ## name ## ss , (Reg *d, Reg *s))        \
    140     DEF_HELPER(void, helper_ ## name ## pd , (Reg *d, Reg *s))        \
    141     DEF_HELPER(void, helper_ ## name ## sd , (Reg *d, Reg *s))
     145    DEF_HELPER_2(name ## ps , void, Reg, Reg)        \
     146    DEF_HELPER_2(name ## ss , void, Reg, Reg)        \
     147    DEF_HELPER_2(name ## pd , void, Reg, Reg)        \
     148    DEF_HELPER_2(name ## sd , void, Reg, Reg)
    142149
    143150SSE_HELPER_S(add, FPU_ADD)
     
    150157
    151158
    152 DEF_HELPER(void, helper_cvtps2pd, (Reg *d, Reg *s))
    153 DEF_HELPER(void, helper_cvtpd2ps, (Reg *d, Reg *s))
    154 DEF_HELPER(void, helper_cvtss2sd, (Reg *d, Reg *s))
    155 DEF_HELPER(void, helper_cvtsd2ss, (Reg *d, Reg *s))
    156 DEF_HELPER(void, helper_cvtdq2ps, (Reg *d, Reg *s))
    157 DEF_HELPER(void, helper_cvtdq2pd, (Reg *d, Reg *s))
    158 DEF_HELPER(void, helper_cvtpi2ps, (XMMReg *d, MMXReg *s))
    159 DEF_HELPER(void, helper_cvtpi2pd, (XMMReg *d, MMXReg *s))
    160 DEF_HELPER(void, helper_cvtsi2ss, (XMMReg *d, uint32_t val))
    161 DEF_HELPER(void, helper_cvtsi2sd, (XMMReg *d, uint32_t val))
     159DEF_HELPER_2(cvtps2pd, void, Reg, Reg)
     160DEF_HELPER_2(cvtpd2ps, void, Reg, Reg)
     161DEF_HELPER_2(cvtss2sd, void, Reg, Reg)
     162DEF_HELPER_2(cvtsd2ss, void, Reg, Reg)
     163DEF_HELPER_2(cvtdq2ps, void, Reg, Reg)
     164DEF_HELPER_2(cvtdq2pd, void, Reg, Reg)
     165DEF_HELPER_2(cvtpi2ps, void, XMMReg, MMXReg)
     166DEF_HELPER_2(cvtpi2pd, void, XMMReg, MMXReg)
     167DEF_HELPER_2(cvtsi2ss, void, XMMReg, i32)
     168DEF_HELPER_2(cvtsi2sd, void, XMMReg, i32)
    162169
    163170#ifdef TARGET_X86_64
    164 DEF_HELPER(void, helper_cvtsq2ss, (XMMReg *d, uint64_t val))
    165 DEF_HELPER(void, helper_cvtsq2sd, (XMMReg *d, uint64_t val))
    166 #endif
    167 
    168 DEF_HELPER(void, helper_cvtps2dq, (XMMReg *d, XMMReg *s))
    169 DEF_HELPER(void, helper_cvtpd2dq, (XMMReg *d, XMMReg *s))
    170 DEF_HELPER(void, helper_cvtps2pi, (MMXReg *d, XMMReg *s))
    171 DEF_HELPER(void, helper_cvtpd2pi, (MMXReg *d, XMMReg *s))
    172 DEF_HELPER(int32_t, helper_cvtss2si, (XMMReg *s))
    173 DEF_HELPER(int32_t, helper_cvtsd2si, (XMMReg *s))
     171DEF_HELPER_2(cvtsq2ss, void, XMMReg, i64)
     172DEF_HELPER_2(cvtsq2sd, void, XMMReg, i64)
     173#endif
     174
     175DEF_HELPER_2(cvtps2dq, void, XMMReg, XMMReg)
     176DEF_HELPER_2(cvtpd2dq, void, XMMReg, XMMReg)
     177DEF_HELPER_2(cvtps2pi, void, MMXReg, XMMReg)
     178DEF_HELPER_2(cvtpd2pi, void, MMXReg, XMMReg)
     179DEF_HELPER_1(cvtss2si, s32, XMMReg)
     180DEF_HELPER_1(cvtsd2si, s32, XMMReg)
    174181#ifdef TARGET_X86_64
    175 DEF_HELPER(int64_t, helper_cvtss2sq, (XMMReg *s))
    176 DEF_HELPER(int64_t, helper_cvtsd2sq, (XMMReg *s))
    177 #endif
    178 
    179 DEF_HELPER(void, helper_cvttps2dq, (XMMReg *d, XMMReg *s))
    180 DEF_HELPER(void, helper_cvttpd2dq, (XMMReg *d, XMMReg *s))
    181 DEF_HELPER(void, helper_cvttps2pi, (MMXReg *d, XMMReg *s))
    182 DEF_HELPER(void, helper_cvttpd2pi, (MMXReg *d, XMMReg *s))
    183 DEF_HELPER(int32_t, helper_cvttss2si, (XMMReg *s))
    184 DEF_HELPER(int32_t, helper_cvttsd2si, (XMMReg *s))
     182DEF_HELPER_1(cvtss2sq, s64, XMMReg)
     183DEF_HELPER_1(cvtsd2sq, s64, XMMReg)
     184#endif
     185
     186DEF_HELPER_2(cvttps2dq, void, XMMReg, XMMReg)
     187DEF_HELPER_2(cvttpd2dq, void, XMMReg, XMMReg)
     188DEF_HELPER_2(cvttps2pi, void, MMXReg, XMMReg)
     189DEF_HELPER_2(cvttpd2pi, void, MMXReg, XMMReg)
     190DEF_HELPER_1(cvttss2si, s32, XMMReg)
     191DEF_HELPER_1(cvttsd2si, s32, XMMReg)
    185192#ifdef TARGET_X86_64
    186 DEF_HELPER(int64_t, helper_cvttss2sq, (XMMReg *s))
    187 DEF_HELPER(int64_t, helper_cvttsd2sq, (XMMReg *s))
    188 #endif
    189 
    190 DEF_HELPER(void, helper_rsqrtps, (XMMReg *d, XMMReg *s))
    191 DEF_HELPER(void, helper_rsqrtss, (XMMReg *d, XMMReg *s))
    192 DEF_HELPER(void, helper_rcpps, (XMMReg *d, XMMReg *s))
    193 DEF_HELPER(void, helper_rcpss, (XMMReg *d, XMMReg *s))
    194 DEF_HELPER(void, helper_haddps, (XMMReg *d, XMMReg *s))
    195 DEF_HELPER(void, helper_haddpd, (XMMReg *d, XMMReg *s))
    196 DEF_HELPER(void, helper_hsubps, (XMMReg *d, XMMReg *s))
    197 DEF_HELPER(void, helper_hsubpd, (XMMReg *d, XMMReg *s))
    198 DEF_HELPER(void, helper_addsubps, (XMMReg *d, XMMReg *s))
    199 DEF_HELPER(void, helper_addsubpd, (XMMReg *d, XMMReg *s))
     193DEF_HELPER_1(cvttss2sq, s64, XMMReg)
     194DEF_HELPER_1(cvttsd2sq, s64, XMMReg)
     195#endif
     196
     197DEF_HELPER_2(rsqrtps, void, XMMReg, XMMReg)
     198DEF_HELPER_2(rsqrtss, void, XMMReg, XMMReg)
     199DEF_HELPER_2(rcpps, void, XMMReg, XMMReg)
     200DEF_HELPER_2(rcpss, void, XMMReg, XMMReg)
     201DEF_HELPER_2(haddps, void, XMMReg, XMMReg)
     202DEF_HELPER_2(haddpd, void, XMMReg, XMMReg)
     203DEF_HELPER_2(hsubps, void, XMMReg, XMMReg)
     204DEF_HELPER_2(hsubpd, void, XMMReg, XMMReg)
     205DEF_HELPER_2(addsubps, void, XMMReg, XMMReg)
     206DEF_HELPER_2(addsubpd, void, XMMReg, XMMReg)
    200207
    201208#define SSE_HELPER_CMP(name, F)\
    202     DEF_HELPER(void, helper_ ## name ## ps , (Reg *d, Reg *s))        \
    203     DEF_HELPER(void, helper_ ## name ## ss , (Reg *d, Reg *s))        \
    204     DEF_HELPER(void, helper_ ## name ## pd , (Reg *d, Reg *s))        \
    205     DEF_HELPER(void, helper_ ## name ## sd , (Reg *d, Reg *s))
     209    DEF_HELPER_2( name ## ps , void, Reg, Reg)        \
     210    DEF_HELPER_2( name ## ss , void, Reg, Reg)        \
     211    DEF_HELPER_2( name ## pd , void, Reg, Reg)        \
     212    DEF_HELPER_2( name ## sd , void, Reg, Reg)
    206213
    207214SSE_HELPER_CMP(cmpeq, FPU_CMPEQ)
     
    214221SSE_HELPER_CMP(cmpord, FPU_CMPORD)
    215222
    216 DEF_HELPER(void, helper_ucomiss, (Reg *d, Reg *s))
    217 DEF_HELPER(void, helper_comiss, (Reg *d, Reg *s))
    218 DEF_HELPER(void, helper_ucomisd, (Reg *d, Reg *s))
    219 DEF_HELPER(void, helper_comisd, (Reg *d, Reg *s))
    220 DEF_HELPER(uint32_t, helper_movmskps, (Reg *s))
    221 DEF_HELPER(uint32_t, helper_movmskpd, (Reg *s))
    222 #endif
    223 
    224 DEF_HELPER(uint32_t, glue(helper_pmovmskb, SUFFIX), (Reg *s))
    225 DEF_HELPER(void, glue(helper_packsswb, SUFFIX) , (Reg *d, Reg *s))
    226 DEF_HELPER(void, glue(helper_packuswb, SUFFIX) , (Reg *d, Reg *s))
    227 DEF_HELPER(void, glue(helper_packssdw, SUFFIX) , (Reg *d, Reg *s))
     223DEF_HELPER_2(ucomiss, void, Reg, Reg)
     224DEF_HELPER_2(comiss, void, Reg, Reg)
     225DEF_HELPER_2(ucomisd, void, Reg, Reg)
     226DEF_HELPER_2(comisd, void, Reg, Reg)
     227DEF_HELPER_1(movmskps, i32, Reg)
     228DEF_HELPER_1(movmskpd, i32, Reg)
     229#endif
     230
     231DEF_HELPER_1(glue(pmovmskb, SUFFIX), i32, Reg)
     232DEF_HELPER_2(glue(packsswb, SUFFIX), void, Reg, Reg)
     233DEF_HELPER_2(glue(packuswb, SUFFIX), void, Reg, Reg)
     234DEF_HELPER_2(glue(packssdw, SUFFIX), void, Reg, Reg)
    228235#define UNPCK_OP(base_name, base)                               \
    229     DEF_HELPER(void, glue(helper_punpck ## base_name ## bw, SUFFIX) , (Reg *d, Reg *s)) \
    230     DEF_HELPER(void, glue(helper_punpck ## base_name ## wd, SUFFIX) , (Reg *d, Reg *s)) \
    231     DEF_HELPER(void, glue(helper_punpck ## base_name ## dq, SUFFIX) , (Reg *d, Reg *s))
     236    DEF_HELPER_2(glue(punpck ## base_name ## bw, SUFFIX) , void, Reg, Reg) \
     237    DEF_HELPER_2(glue(punpck ## base_name ## wd, SUFFIX) , void, Reg, Reg) \
     238    DEF_HELPER_2(glue(punpck ## base_name ## dq, SUFFIX) , void, Reg, Reg)
    232239
    233240UNPCK_OP(l, 0)
     
    235242
    236243#if SHIFT == 1
    237 DEF_HELPER(void, glue(helper_punpcklqdq, SUFFIX) , (Reg *d, Reg *s))
    238 DEF_HELPER(void, glue(helper_punpckhqdq, SUFFIX) , (Reg *d, Reg *s))
     244DEF_HELPER_2(glue(punpcklqdq, SUFFIX), void, Reg, Reg)
     245DEF_HELPER_2(glue(punpckhqdq, SUFFIX), void, Reg, Reg)
    239246#endif
    240247
    241248/* 3DNow! float ops */
    242249#if SHIFT == 0
    243 DEF_HELPER(void, helper_pi2fd, (MMXReg *d, MMXReg *s))
    244 DEF_HELPER(void, helper_pi2fw, (MMXReg *d, MMXReg *s))
    245 DEF_HELPER(void, helper_pf2id, (MMXReg *d, MMXReg *s))
    246 DEF_HELPER(void, helper_pf2iw, (MMXReg *d, MMXReg *s))
    247 DEF_HELPER(void, helper_pfacc, (MMXReg *d, MMXReg *s))
    248 DEF_HELPER(void, helper_pfadd, (MMXReg *d, MMXReg *s))
    249 DEF_HELPER(void, helper_pfcmpeq, (MMXReg *d, MMXReg *s))
    250 DEF_HELPER(void, helper_pfcmpge, (MMXReg *d, MMXReg *s))
    251 DEF_HELPER(void, helper_pfcmpgt, (MMXReg *d, MMXReg *s))
    252 DEF_HELPER(void, helper_pfmax, (MMXReg *d, MMXReg *s))
    253 DEF_HELPER(void, helper_pfmin, (MMXReg *d, MMXReg *s))
    254 DEF_HELPER(void, helper_pfmul, (MMXReg *d, MMXReg *s))
    255 DEF_HELPER(void, helper_pfnacc, (MMXReg *d, MMXReg *s))
    256 DEF_HELPER(void, helper_pfpnacc, (MMXReg *d, MMXReg *s))
    257 DEF_HELPER(void, helper_pfrcp, (MMXReg *d, MMXReg *s))
    258 DEF_HELPER(void, helper_pfrsqrt, (MMXReg *d, MMXReg *s))
    259 DEF_HELPER(void, helper_pfsub, (MMXReg *d, MMXReg *s))
    260 DEF_HELPER(void, helper_pfsubr, (MMXReg *d, MMXReg *s))
    261 DEF_HELPER(void, helper_pswapd, (MMXReg *d, MMXReg *s))
     250DEF_HELPER_2(pi2fd, void, MMXReg, MMXReg)
     251DEF_HELPER_2(pi2fw, void, MMXReg, MMXReg)
     252DEF_HELPER_2(pf2id, void, MMXReg, MMXReg)
     253DEF_HELPER_2(pf2iw, void, MMXReg, MMXReg)
     254DEF_HELPER_2(pfacc, void, MMXReg, MMXReg)
     255DEF_HELPER_2(pfadd, void, MMXReg, MMXReg)
     256DEF_HELPER_2(pfcmpeq, void, MMXReg, MMXReg)
     257DEF_HELPER_2(pfcmpge, void, MMXReg, MMXReg)
     258DEF_HELPER_2(pfcmpgt, void, MMXReg, MMXReg)
     259DEF_HELPER_2(pfmax, void, MMXReg, MMXReg)
     260DEF_HELPER_2(pfmin, void, MMXReg, MMXReg)
     261DEF_HELPER_2(pfmul, void, MMXReg, MMXReg)
     262DEF_HELPER_2(pfnacc, void, MMXReg, MMXReg)
     263DEF_HELPER_2(pfpnacc, void, MMXReg, MMXReg)
     264DEF_HELPER_2(pfrcp, void, MMXReg, MMXReg)
     265DEF_HELPER_2(pfrsqrt, void, MMXReg, MMXReg)
     266DEF_HELPER_2(pfsub, void, MMXReg, MMXReg)
     267DEF_HELPER_2(pfsubr, void, MMXReg, MMXReg)
     268DEF_HELPER_2(pswapd, void, MMXReg, MMXReg)
    262269#endif
    263270
    264271/* SSSE3 op helpers */
    265 DEF_HELPER(void, glue(helper_phaddw, SUFFIX), (Reg *d, Reg *s))
    266 DEF_HELPER(void, glue(helper_phaddd, SUFFIX), (Reg *d, Reg *s))
    267 DEF_HELPER(void, glue(helper_phaddsw, SUFFIX), (Reg *d, Reg *s))
    268 DEF_HELPER(void, glue(helper_phsubw, SUFFIX), (Reg *d, Reg *s))
    269 DEF_HELPER(void, glue(helper_phsubd, SUFFIX), (Reg *d, Reg *s))
    270 DEF_HELPER(void, glue(helper_phsubsw, SUFFIX), (Reg *d, Reg *s))
    271 DEF_HELPER(void, glue(helper_pabsb, SUFFIX), (Reg *d, Reg *s))
    272 DEF_HELPER(void, glue(helper_pabsw, SUFFIX), (Reg *d, Reg *s))
    273 DEF_HELPER(void, glue(helper_pabsd, SUFFIX), (Reg *d, Reg *s))
    274 DEF_HELPER(void, glue(helper_pmaddubsw, SUFFIX), (Reg *d, Reg *s))
    275 DEF_HELPER(void, glue(helper_pmulhrsw, SUFFIX), (Reg *d, Reg *s))
    276 DEF_HELPER(void, glue(helper_pshufb, SUFFIX), (Reg *d, Reg *s))
    277 DEF_HELPER(void, glue(helper_psignb, SUFFIX), (Reg *d, Reg *s))
    278 DEF_HELPER(void, glue(helper_psignw, SUFFIX), (Reg *d, Reg *s))
    279 DEF_HELPER(void, glue(helper_psignd, SUFFIX), (Reg *d, Reg *s))
    280 DEF_HELPER(void, glue(helper_palignr, SUFFIX), (Reg *d, Reg *s, int32_t shift))
     272DEF_HELPER_2(glue(phaddw, SUFFIX), void, Reg, Reg)
     273DEF_HELPER_2(glue(phaddd, SUFFIX), void, Reg, Reg)
     274DEF_HELPER_2(glue(phaddsw, SUFFIX), void, Reg, Reg)
     275DEF_HELPER_2(glue(phsubw, SUFFIX), void, Reg, Reg)
     276DEF_HELPER_2(glue(phsubd, SUFFIX), void, Reg, Reg)
     277DEF_HELPER_2(glue(phsubsw, SUFFIX), void, Reg, Reg)
     278DEF_HELPER_2(glue(pabsb, SUFFIX), void, Reg, Reg)
     279DEF_HELPER_2(glue(pabsw, SUFFIX), void, Reg, Reg)
     280DEF_HELPER_2(glue(pabsd, SUFFIX), void, Reg, Reg)
     281DEF_HELPER_2(glue(pmaddubsw, SUFFIX), void, Reg, Reg)
     282DEF_HELPER_2(glue(pmulhrsw, SUFFIX), void, Reg, Reg)
     283DEF_HELPER_2(glue(pshufb, SUFFIX), void, Reg, Reg)
     284DEF_HELPER_2(glue(psignb, SUFFIX), void, Reg, Reg)
     285DEF_HELPER_2(glue(psignw, SUFFIX), void, Reg, Reg)
     286DEF_HELPER_2(glue(psignd, SUFFIX), void, Reg, Reg)
     287DEF_HELPER_3(glue(palignr, SUFFIX), void, Reg, Reg, s32)
    281288
    282289/* SSE4.1 op helpers */
    283290#if SHIFT == 1
    284 DEF_HELPER(void, glue(helper_pblendvb, SUFFIX), (Reg *d, Reg *s))
    285 DEF_HELPER(void, glue(helper_blendvps, SUFFIX), (Reg *d, Reg *s))
    286 DEF_HELPER(void, glue(helper_blendvpd, SUFFIX), (Reg *d, Reg *s))
    287 DEF_HELPER(void, glue(helper_ptest, SUFFIX), (Reg *d, Reg *s))
    288 DEF_HELPER(void, glue(helper_pmovsxbw, SUFFIX), (Reg *d, Reg *s))
    289 DEF_HELPER(void, glue(helper_pmovsxbd, SUFFIX), (Reg *d, Reg *s))
    290 DEF_HELPER(void, glue(helper_pmovsxbq, SUFFIX), (Reg *d, Reg *s))
    291 DEF_HELPER(void, glue(helper_pmovsxwd, SUFFIX), (Reg *d, Reg *s))
    292 DEF_HELPER(void, glue(helper_pmovsxwq, SUFFIX), (Reg *d, Reg *s))
    293 DEF_HELPER(void, glue(helper_pmovsxdq, SUFFIX), (Reg *d, Reg *s))
    294 DEF_HELPER(void, glue(helper_pmovzxbw, SUFFIX), (Reg *d, Reg *s))
    295 DEF_HELPER(void, glue(helper_pmovzxbd, SUFFIX), (Reg *d, Reg *s))
    296 DEF_HELPER(void, glue(helper_pmovzxbq, SUFFIX), (Reg *d, Reg *s))
    297 DEF_HELPER(void, glue(helper_pmovzxwd, SUFFIX), (Reg *d, Reg *s))
    298 DEF_HELPER(void, glue(helper_pmovzxwq, SUFFIX), (Reg *d, Reg *s))
    299 DEF_HELPER(void, glue(helper_pmovzxdq, SUFFIX), (Reg *d, Reg *s))
    300 DEF_HELPER(void, glue(helper_pmuldq, SUFFIX), (Reg *d, Reg *s))
    301 DEF_HELPER(void, glue(helper_pcmpeqq, SUFFIX), (Reg *d, Reg *s))
    302 DEF_HELPER(void, glue(helper_packusdw, SUFFIX), (Reg *d, Reg *s))
    303 DEF_HELPER(void, glue(helper_pminsb, SUFFIX), (Reg *d, Reg *s))
    304 DEF_HELPER(void, glue(helper_pminsd, SUFFIX), (Reg *d, Reg *s))
    305 DEF_HELPER(void, glue(helper_pminuw, SUFFIX), (Reg *d, Reg *s))
    306 DEF_HELPER(void, glue(helper_pminud, SUFFIX), (Reg *d, Reg *s))
    307 DEF_HELPER(void, glue(helper_pmaxsb, SUFFIX), (Reg *d, Reg *s))
    308 DEF_HELPER(void, glue(helper_pmaxsd, SUFFIX), (Reg *d, Reg *s))
    309 DEF_HELPER(void, glue(helper_pmaxuw, SUFFIX), (Reg *d, Reg *s))
    310 DEF_HELPER(void, glue(helper_pmaxud, SUFFIX), (Reg *d, Reg *s))
    311 DEF_HELPER(void, glue(helper_pmulld, SUFFIX), (Reg *d, Reg *s))
    312 DEF_HELPER(void, glue(helper_phminposuw, SUFFIX), (Reg *d, Reg *s))
    313 DEF_HELPER(void, glue(helper_roundps, SUFFIX), (Reg *d, Reg *s, uint32_t mode))
    314 DEF_HELPER(void, glue(helper_roundpd, SUFFIX), (Reg *d, Reg *s, uint32_t mode))
    315 DEF_HELPER(void, glue(helper_roundss, SUFFIX), (Reg *d, Reg *s, uint32_t mode))
    316 DEF_HELPER(void, glue(helper_roundsd, SUFFIX), (Reg *d, Reg *s, uint32_t mode))
    317 DEF_HELPER(void, glue(helper_blendps, SUFFIX), (Reg *d, Reg *s, uint32_t imm))
    318 DEF_HELPER(void, glue(helper_blendpd, SUFFIX), (Reg *d, Reg *s, uint32_t imm))
    319 DEF_HELPER(void, glue(helper_pblendw, SUFFIX), (Reg *d, Reg *s, uint32_t imm))
    320 DEF_HELPER(void, glue(helper_dpps, SUFFIX), (Reg *d, Reg *s, uint32_t mask))
    321 DEF_HELPER(void, glue(helper_dppd, SUFFIX), (Reg *d, Reg *s, uint32_t mask))
    322 DEF_HELPER(void, glue(helper_mpsadbw, SUFFIX), (Reg *d, Reg *s, uint32_t off))
     291DEF_HELPER_2(glue(pblendvb, SUFFIX), void, Reg, Reg)
     292DEF_HELPER_2(glue(blendvps, SUFFIX), void, Reg, Reg)
     293DEF_HELPER_2(glue(blendvpd, SUFFIX), void, Reg, Reg)
     294DEF_HELPER_2(glue(ptest, SUFFIX), void, Reg, Reg)
     295DEF_HELPER_2(glue(pmovsxbw, SUFFIX), void, Reg, Reg)
     296DEF_HELPER_2(glue(pmovsxbd, SUFFIX), void, Reg, Reg)
     297DEF_HELPER_2(glue(pmovsxbq, SUFFIX), void, Reg, Reg)
     298DEF_HELPER_2(glue(pmovsxwd, SUFFIX), void, Reg, Reg)
     299DEF_HELPER_2(glue(pmovsxwq, SUFFIX), void, Reg, Reg)
     300DEF_HELPER_2(glue(pmovsxdq, SUFFIX), void, Reg, Reg)
     301DEF_HELPER_2(glue(pmovzxbw, SUFFIX), void, Reg, Reg)
     302DEF_HELPER_2(glue(pmovzxbd, SUFFIX), void, Reg, Reg)
     303DEF_HELPER_2(glue(pmovzxbq, SUFFIX), void, Reg, Reg)
     304DEF_HELPER_2(glue(pmovzxwd, SUFFIX), void, Reg, Reg)
     305DEF_HELPER_2(glue(pmovzxwq, SUFFIX), void, Reg, Reg)
     306DEF_HELPER_2(glue(pmovzxdq, SUFFIX), void, Reg, Reg)
     307DEF_HELPER_2(glue(pmuldq, SUFFIX), void, Reg, Reg)
     308DEF_HELPER_2(glue(pcmpeqq, SUFFIX), void, Reg, Reg)
     309DEF_HELPER_2(glue(packusdw, SUFFIX), void, Reg, Reg)
     310DEF_HELPER_2(glue(pminsb, SUFFIX), void, Reg, Reg)
     311DEF_HELPER_2(glue(pminsd, SUFFIX), void, Reg, Reg)
     312DEF_HELPER_2(glue(pminuw, SUFFIX), void, Reg, Reg)
     313DEF_HELPER_2(glue(pminud, SUFFIX), void, Reg, Reg)
     314DEF_HELPER_2(glue(pmaxsb, SUFFIX), void, Reg, Reg)
     315DEF_HELPER_2(glue(pmaxsd, SUFFIX), void, Reg, Reg)
     316DEF_HELPER_2(glue(pmaxuw, SUFFIX), void, Reg, Reg)
     317DEF_HELPER_2(glue(pmaxud, SUFFIX), void, Reg, Reg)
     318DEF_HELPER_2(glue(pmulld, SUFFIX), void, Reg, Reg)
     319DEF_HELPER_2(glue(phminposuw, SUFFIX), void, Reg, Reg)
     320DEF_HELPER_3(glue(roundps, SUFFIX), void, Reg, Reg, i32)
     321DEF_HELPER_3(glue(roundpd, SUFFIX), void, Reg, Reg, i32)
     322DEF_HELPER_3(glue(roundss, SUFFIX), void, Reg, Reg, i32)
     323DEF_HELPER_3(glue(roundsd, SUFFIX), void, Reg, Reg, i32)
     324DEF_HELPER_3(glue(blendps, SUFFIX), void, Reg, Reg, i32)
     325DEF_HELPER_3(glue(blendpd, SUFFIX), void, Reg, Reg, i32)
     326DEF_HELPER_3(glue(pblendw, SUFFIX), void, Reg, Reg, i32)
     327DEF_HELPER_3(glue(dpps, SUFFIX), void, Reg, Reg, i32)
     328DEF_HELPER_3(glue(dppd, SUFFIX), void, Reg, Reg, i32)
     329DEF_HELPER_3(glue(mpsadbw, SUFFIX), void, Reg, Reg, i32)
    323330#endif
    324331
    325332/* SSE4.2 op helpers */
    326333#if SHIFT == 1
    327 DEF_HELPER(void, glue(helper_pcmpgtq, SUFFIX), (Reg *d, Reg *s))
    328 DEF_HELPER(void, glue(helper_pcmpestri, SUFFIX), (Reg *d, Reg *s, uint32_t ctl))
    329 DEF_HELPER(void, glue(helper_pcmpestrm, SUFFIX), (Reg *d, Reg *s, uint32_t ctl))
    330 DEF_HELPER(void, glue(helper_pcmpistri, SUFFIX), (Reg *d, Reg *s, uint32_t ctl))
    331 DEF_HELPER(void, glue(helper_pcmpistrm, SUFFIX), (Reg *d, Reg *s, uint32_t ctl))
    332 DEF_HELPER(target_ulong, helper_crc32,
    333                 (uint32_t crc1, target_ulong msg, uint32_t len))
    334 DEF_HELPER(target_ulong, helper_popcnt, (target_ulong n, uint32_t type))
     334DEF_HELPER_2(glue(pcmpgtq, SUFFIX), void, Reg, Reg)
     335DEF_HELPER_3(glue(pcmpestri, SUFFIX), void, Reg, Reg, i32)
     336DEF_HELPER_3(glue(pcmpestrm, SUFFIX), void, Reg, Reg, i32)
     337DEF_HELPER_3(glue(pcmpistri, SUFFIX), void, Reg, Reg, i32)
     338DEF_HELPER_3(glue(pcmpistrm, SUFFIX), void, Reg, Reg, i32)
     339DEF_HELPER_3(crc32, tl, i32, tl, i32)
     340DEF_HELPER_2(popcnt, tl, tl, i32)
    335341#endif
    336342
  • trunk/src/recompiler/target-i386/translate.c

    r36140 r36170  
    1616 * You should have received a copy of the GNU Lesser General Public
    1717 * License along with this library; if not, write to the Free Software
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
    1919 */
    2020
     
    3333#include <string.h>
    3434#ifndef VBOX
    35 # include <inttypes.h>
    36 # include <signal.h>
    37 # include <assert.h>
     35#include <inttypes.h>
     36#include <signal.h>
     37#include <assert.h>
    3838#endif /* !VBOX */
    3939
     
    4141#include "exec-all.h"
    4242#include "disas.h"
     43#include "tcg-op.h"
     44
    4345#include "helper.h"
    44 #include "tcg-op.h"
     46#define GEN_HELPER 1
     47#include "helper.h"
    4548
    4649#define PREFIX_REPZ   0x01
     
    7174
    7275/* global register indexes */
    73 static TCGv cpu_env, cpu_A0, cpu_cc_op, cpu_cc_src, cpu_cc_dst, cpu_cc_tmp;
     76static TCGv_ptr cpu_env;
     77static TCGv cpu_A0, cpu_cc_src, cpu_cc_dst, cpu_cc_tmp;
     78static TCGv_i32 cpu_cc_op;
    7479/* local temps */
    7580static TCGv cpu_T[2], cpu_T3;
    7681/* local register indexes (only used inside old micro ops) */
    77 static TCGv cpu_tmp0, cpu_tmp1_i64, cpu_tmp2_i32, cpu_tmp3_i32, cpu_tmp4, cpu_ptr0, cpu_ptr1;
     82static TCGv cpu_tmp0, cpu_tmp4;
     83static TCGv_ptr cpu_ptr0, cpu_ptr1;
     84static TCGv_i32 cpu_tmp2_i32, cpu_tmp3_i32;
     85static TCGv_i64 cpu_tmp1_i64;
    7886static TCGv cpu_tmp5, cpu_tmp6;
    7987
     
    658666    default:
    659667    case 3:
     668        /* Should never happen on 32-bit targets.  */
     669#ifdef TARGET_X86_64
    660670        tcg_gen_qemu_ld64(t0, a0, mem_index);
     671#endif
    661672        break;
    662673    }
     
    694705    default:
    695706    case 3:
     707        /* Should never happen on 32-bit targets.  */
     708#ifdef TARGET_X86_64
    696709        tcg_gen_qemu_st64(t0, a0, mem_index);
     710#endif
    697711        break;
    698712    }
     
    716730    /** @todo: once TCG codegen improves, we may want to use version
    717731        from else version */
    718     tcg_gen_helper_0_0(helper_check_external_event);
     732    gen_helper_check_external_event();
    719733# else
    720734    int skip_label;
     
    736750    tcg_temp_free(t0);
    737751
    738     tcg_gen_helper_0_0(helper_check_external_event);
     752    gen_helper_check_external_event();
    739753
    740754   gen_set_label(skip_label);
     
    745759static void gen_check_external_event2()
    746760{
    747     tcg_gen_helper_0_0(helper_check_external_event);
     761    gen_helper_check_external_event();
    748762}
    749763# endif
     
    762776    gen_jmp_im(pc);
    763777# ifdef VBOX_DUMP_STATE
    764     tcg_gen_helper_0_0(helper_dump_state);
     778    gen_helper_dump_state();
    765779# endif
    766780}
     
    877891}
    878892
    879 static void *helper_in_func[3] = {
    880     helper_inb,
    881     helper_inw,
    882     helper_inl,
    883 };
    884 
    885 static void *helper_out_func[3] = {
    886     helper_outb,
    887     helper_outw,
    888     helper_outl,
    889 };
    890 
    891 static void *gen_check_io_func[3] = {
    892     helper_check_iob,
    893     helper_check_iow,
    894     helper_check_iol,
    895 };
     893static void gen_helper_in_func(int ot, TCGv v, TCGv_i32 n)
     894{
     895    switch (ot) {
     896    case 0: gen_helper_inb(v, n); break;
     897    case 1: gen_helper_inw(v, n); break;
     898    case 2: gen_helper_inl(v, n); break;
     899    }
     900
     901}
     902
     903static void gen_helper_out_func(int ot, TCGv_i32 v, TCGv_i32 n)
     904{
     905    switch (ot) {
     906    case 0: gen_helper_outb(v, n); break;
     907    case 1: gen_helper_outw(v, n); break;
     908    case 2: gen_helper_outl(v, n); break;
     909    }
     910
     911}
    896912
    897913static void gen_check_io(DisasContext *s, int ot, target_ulong cur_eip,
     
    908924        state_saved = 1;
    909925        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    910         tcg_gen_helper_0_1(gen_check_io_func[ot],
    911                            cpu_tmp2_i32);
     926        switch (ot) {
     927        case 0: gen_helper_check_iob(cpu_tmp2_i32); break;
     928        case 1: gen_helper_check_iow(cpu_tmp2_i32); break;
     929        case 2: gen_helper_check_iol(cpu_tmp2_i32); break;
     930        }
    912931    }
    913932    if(s->flags & HF_SVMI_MASK) {
     
    921940        next_eip = s->pc - s->cs_base;
    922941        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    923         tcg_gen_helper_0_3(helper_svm_check_io,
    924                            cpu_tmp2_i32,
    925                            tcg_const_i32(svm_flags),
    926                            tcg_const_i32(next_eip - cur_eip));
     942        gen_helper_svm_check_io(cpu_tmp2_i32, tcg_const_i32(svm_flags),
     943                                tcg_const_i32(next_eip - cur_eip));
    927944    }
    928945}
     
    980997static void gen_compute_eflags_c(TCGv reg)
    981998{
    982 #if TCG_TARGET_REG_BITS == 32
    983     tcg_gen_shli_i32(cpu_tmp2_i32, cpu_cc_op, 3);
    984     tcg_gen_addi_i32(cpu_tmp2_i32, cpu_tmp2_i32,
    985                      (long)cc_table + offsetof(CCTable, compute_c));
    986     tcg_gen_ld_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0);
    987     tcg_gen_call(&tcg_ctx, cpu_tmp2_i32, TCG_CALL_PURE,
    988                  1, &cpu_tmp2_i32, 0, NULL);
    989 #else
    990     tcg_gen_extu_i32_tl(cpu_tmp1_i64, cpu_cc_op);
    991     tcg_gen_shli_i64(cpu_tmp1_i64, cpu_tmp1_i64, 4);
    992     tcg_gen_addi_i64(cpu_tmp1_i64, cpu_tmp1_i64,
    993                      (long)cc_table + offsetof(CCTable, compute_c));
    994     tcg_gen_ld_i64(cpu_tmp1_i64, cpu_tmp1_i64, 0);
    995     tcg_gen_call(&tcg_ctx, cpu_tmp1_i64, TCG_CALL_PURE,
    996                  1, &cpu_tmp2_i32, 0, NULL);
    997 #endif
     999    gen_helper_cc_compute_c(cpu_tmp2_i32, cpu_cc_op);
    9981000    tcg_gen_extu_i32_tl(reg, cpu_tmp2_i32);
    9991001}
     
    10021004static void gen_compute_eflags(TCGv reg)
    10031005{
    1004 #if TCG_TARGET_REG_BITS == 32
    1005     tcg_gen_shli_i32(cpu_tmp2_i32, cpu_cc_op, 3);
    1006     tcg_gen_addi_i32(cpu_tmp2_i32, cpu_tmp2_i32,
    1007                      (long)cc_table + offsetof(CCTable, compute_all));
    1008     tcg_gen_ld_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0);
    1009     tcg_gen_call(&tcg_ctx, cpu_tmp2_i32, TCG_CALL_PURE,
    1010                  1, &cpu_tmp2_i32, 0, NULL);
    1011 #else
    1012     tcg_gen_extu_i32_tl(cpu_tmp1_i64, cpu_cc_op);
    1013     tcg_gen_shli_i64(cpu_tmp1_i64, cpu_tmp1_i64, 4);
    1014     tcg_gen_addi_i64(cpu_tmp1_i64, cpu_tmp1_i64,
    1015                      (long)cc_table + offsetof(CCTable, compute_all));
    1016     tcg_gen_ld_i64(cpu_tmp1_i64, cpu_tmp1_i64, 0);
    1017     tcg_gen_call(&tcg_ctx, cpu_tmp1_i64, TCG_CALL_PURE,
    1018                  1, &cpu_tmp2_i32, 0, NULL);
    1019 #endif
     1006    gen_helper_cc_compute_all(cpu_tmp2_i32, cpu_cc_op);
    10201007    tcg_gen_extu_i32_tl(reg, cpu_tmp2_i32);
    10211008}
     
    13911378    tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[1]);
    13921379    tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
    1393     tcg_gen_helper_1_1(helper_in_func[ot], cpu_T[0], cpu_tmp2_i32);
     1380    gen_helper_in_func(ot, cpu_T[0], cpu_tmp2_i32);
    13941381    gen_op_st_T0_A0(ot + s->mem_index);
    13951382    gen_op_movl_T0_Dshift(ot);
     
    14101397    tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
    14111398    tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[0]);
    1412     tcg_gen_helper_0_2(helper_out_func[ot], cpu_tmp2_i32, cpu_tmp3_i32);
     1399    gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
    14131400
    14141401    gen_op_movl_T0_Dshift(ot);
     
    14621449GEN_REPZ2(cmps)
    14631450
    1464 static void *helper_fp_arith_ST0_FT0[8] = {
    1465     helper_fadd_ST0_FT0,
    1466     helper_fmul_ST0_FT0,
    1467     helper_fcom_ST0_FT0,
    1468     helper_fcom_ST0_FT0,
    1469     helper_fsub_ST0_FT0,
    1470     helper_fsubr_ST0_FT0,
    1471     helper_fdiv_ST0_FT0,
    1472     helper_fdivr_ST0_FT0,
    1473 };
     1451static void gen_helper_fp_arith_ST0_FT0(int op)
     1452{
     1453    switch (op) {
     1454    case 0: gen_helper_fadd_ST0_FT0(); break;
     1455    case 1: gen_helper_fmul_ST0_FT0(); break;
     1456    case 2: gen_helper_fcom_ST0_FT0(); break;
     1457    case 3: gen_helper_fcom_ST0_FT0(); break;
     1458    case 4: gen_helper_fsub_ST0_FT0(); break;
     1459    case 5: gen_helper_fsubr_ST0_FT0(); break;
     1460    case 6: gen_helper_fdiv_ST0_FT0(); break;
     1461    case 7: gen_helper_fdivr_ST0_FT0(); break;
     1462    }
     1463}
    14741464
    14751465/* NOTE the exception in "r" op ordering */
    1476 static void *helper_fp_arith_STN_ST0[8] = {
    1477     helper_fadd_STN_ST0,
    1478     helper_fmul_STN_ST0,
    1479     NULL,
    1480     NULL,
    1481     helper_fsubr_STN_ST0,
    1482     helper_fsub_STN_ST0,
    1483     helper_fdivr_STN_ST0,
    1484     helper_fdiv_STN_ST0,
    1485 };
     1466static void gen_helper_fp_arith_STN_ST0(int op, int opreg)
     1467{
     1468    TCGv_i32 tmp = tcg_const_i32(opreg);
     1469    switch (op) {
     1470    case 0: gen_helper_fadd_STN_ST0(tmp); break;
     1471    case 1: gen_helper_fmul_STN_ST0(tmp); break;
     1472    case 4: gen_helper_fsubr_STN_ST0(tmp); break;
     1473    case 5: gen_helper_fsub_STN_ST0(tmp); break;
     1474    case 6: gen_helper_fdivr_STN_ST0(tmp); break;
     1475    case 7: gen_helper_fdiv_STN_ST0(tmp); break;
     1476    }
     1477}
    14861478
    14871479/* if d == OR_TMP0, it means memory operand (address in A0) */
     
    16531645
    16541646    /* XXX: inefficient */
    1655     t0 = tcg_temp_local_new(TCG_TYPE_TL);
    1656     t1 = tcg_temp_local_new(TCG_TYPE_TL);
     1647    t0 = tcg_temp_local_new();
     1648    t1 = tcg_temp_local_new();
    16571649
    16581650    tcg_gen_mov_tl(t0, cpu_T[0]);
     
    17441736
    17451737    /* XXX: inefficient, but we must use local temps */
    1746     t0 = tcg_temp_local_new(TCG_TYPE_TL);
    1747     t1 = tcg_temp_local_new(TCG_TYPE_TL);
    1748     t2 = tcg_temp_local_new(TCG_TYPE_TL);
    1749     a0 = tcg_temp_local_new(TCG_TYPE_TL);
     1738    t0 = tcg_temp_local_new();
     1739    t1 = tcg_temp_local_new();
     1740    t2 = tcg_temp_local_new();
     1741    a0 = tcg_temp_local_new();
    17501742
    17511743    if (ot == OT_QUAD)
     
    18321824}
    18331825
    1834 static void *helper_rotc[8] = {
    1835     helper_rclb,
    1836     helper_rclw,
    1837     helper_rcll,
    1838     X86_64_ONLY(helper_rclq),
    1839     helper_rcrb,
    1840     helper_rcrw,
    1841     helper_rcrl,
    1842     X86_64_ONLY(helper_rcrq),
    1843 };
    1844 
    18451826/* XXX: add faster immediate = 1 case */
    18461827static void gen_rotc_rm_T1(DisasContext *s, int ot, int op1,
     
    18581839        gen_op_mov_TN_reg(ot, 0, op1);
    18591840
    1860     tcg_gen_helper_1_2(helper_rotc[ot + (is_right * 4)],
    1861                        cpu_T[0], cpu_T[0], cpu_T[1]);
     1841    if (is_right) {
     1842        switch (ot) {
     1843        case 0: gen_helper_rcrb(cpu_T[0], cpu_T[0], cpu_T[1]); break;
     1844        case 1: gen_helper_rcrw(cpu_T[0], cpu_T[0], cpu_T[1]); break;
     1845        case 2: gen_helper_rcrl(cpu_T[0], cpu_T[0], cpu_T[1]); break;
     1846#ifdef TARGET_X86_64
     1847        case 3: gen_helper_rcrq(cpu_T[0], cpu_T[0], cpu_T[1]); break;
     1848#endif
     1849        }
     1850    } else {
     1851        switch (ot) {
     1852        case 0: gen_helper_rclb(cpu_T[0], cpu_T[0], cpu_T[1]); break;
     1853        case 1: gen_helper_rclw(cpu_T[0], cpu_T[0], cpu_T[1]); break;
     1854        case 2: gen_helper_rcll(cpu_T[0], cpu_T[0], cpu_T[1]); break;
     1855#ifdef TARGET_X86_64
     1856        case 3: gen_helper_rclq(cpu_T[0], cpu_T[0], cpu_T[1]); break;
     1857#endif
     1858        }
     1859    }
    18621860    /* store */
    18631861    if (op1 == OR_TMP0)
     
    18861884    TCGv t0, t1, t2, a0;
    18871885
    1888     t0 = tcg_temp_local_new(TCG_TYPE_TL);
    1889     t1 = tcg_temp_local_new(TCG_TYPE_TL);
    1890     t2 = tcg_temp_local_new(TCG_TYPE_TL);
    1891     a0 = tcg_temp_local_new(TCG_TYPE_TL);
     1886    t0 = tcg_temp_local_new();
     1887    t1 = tcg_temp_local_new();
     1888    t2 = tcg_temp_local_new();
     1889    a0 = tcg_temp_local_new();
    18921890
    18931891    if (ot == OT_QUAD)
     
    24492447        /* nominal case: we use a jump */
    24502448        /* XXX: make it faster by adding new instructions in TCG */
    2451         t0 = tcg_temp_local_new(TCG_TYPE_TL);
     2449        t0 = tcg_temp_local_new();
    24522450        tcg_gen_movi_tl(t0, 0);
    24532451        l1 = gen_new_label();
     
    25072505        gen_jmp_im(cur_eip);
    25082506        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    2509         tcg_gen_helper_0_2(helper_load_seg, tcg_const_i32(seg_reg), cpu_tmp2_i32);
     2507        gen_helper_load_seg(tcg_const_i32(seg_reg), cpu_tmp2_i32);
    25102508        /* abort translation because the addseg value may change or
    25112509           because ss32 may change. For R_SS, translation must always
     
    25362534        gen_op_set_cc_op(s->cc_op);
    25372535    gen_jmp_im(pc_start - s->cs_base);
    2538     tcg_gen_helper_0_2(helper_svm_check_intercept_param,
    2539                        tcg_const_i32(type), tcg_const_i64(param));
     2536    gen_helper_svm_check_intercept_param(tcg_const_i32(type),
     2537                                         tcg_const_i64(param));
    25402538}
    25412539
     
    27442742        if (level) {
    27452743            /* XXX: must save state */
    2746             tcg_gen_helper_0_3(helper_enter64_level,
    2747                                tcg_const_i32(level),
    2748                                tcg_const_i32((ot == OT_QUAD)),
    2749                                cpu_T[1]);
     2744            gen_helper_enter64_level(tcg_const_i32(level),
     2745                                     tcg_const_i32((ot == OT_QUAD)),
     2746                                     cpu_T[1]);
    27502747        }
    27512748        gen_op_mov_reg_T1(ot, R_EBP);
     
    27702767        if (level) {
    27712768            /* XXX: must save state */
    2772             tcg_gen_helper_0_3(helper_enter_level,
    2773                                tcg_const_i32(level),
    2774                                tcg_const_i32(s->dflag),
    2775                                cpu_T[1]);
     2769            gen_helper_enter_level(tcg_const_i32(level),
     2770                                   tcg_const_i32(s->dflag),
     2771                                   cpu_T[1]);
    27762772        }
    27772773        gen_op_mov_reg_T1(ot, R_EBP);
     
    27862782        gen_op_set_cc_op(s->cc_op);
    27872783    gen_jmp_im(cur_eip);
    2788     tcg_gen_helper_0_1(helper_raise_exception, tcg_const_i32(trapno));
     2784    gen_helper_raise_exception(tcg_const_i32(trapno));
    27892785    s->is_jmp = 3;
    27902786}
     
    27982794        gen_op_set_cc_op(s->cc_op);
    27992795    gen_jmp_im(cur_eip);
    2800     tcg_gen_helper_0_2(helper_raise_interrupt,
    2801                        tcg_const_i32(intno),
    2802                        tcg_const_i32(next_eip - cur_eip));
     2796    gen_helper_raise_interrupt(tcg_const_i32(intno),
     2797                               tcg_const_i32(next_eip - cur_eip));
    28032798    s->is_jmp = 3;
    28042799}
     
    28092804        gen_op_set_cc_op(s->cc_op);
    28102805    gen_jmp_im(cur_eip);
    2811     tcg_gen_helper_0_0(helper_debug);
     2806    gen_helper_debug();
    28122807    s->is_jmp = 3;
    28132808}
     
    28202815        gen_op_set_cc_op(s->cc_op);
    28212816    if (s->tb->flags & HF_INHIBIT_IRQ_MASK) {
    2822         tcg_gen_helper_0_0(helper_reset_inhibit_irq);
     2817        gen_helper_reset_inhibit_irq();
    28232818    }
    2824 
    2825 #ifdef VBOX
    2826     gen_check_external_event();
    2827 #endif /* VBOX */
    2828 
    28292819    if (   s->singlestep_enabled
    28302820#ifdef VBOX
     
    28332823#endif
    28342824       ) {
    2835         tcg_gen_helper_0_0(helper_debug);
     2825        gen_helper_debug();
    28362826    } else if (s->tf) {
    2837         tcg_gen_helper_0_0(helper_single_step);
     2827        gen_helper_single_step();
    28382828    } else {
    28392829        tcg_gen_exit_tb(0);
     
    29272917#define SSE_DUMMY ((void *)2)
    29282918
    2929 #define MMX_OP2(x) { helper_ ## x ## _mmx, helper_ ## x ## _xmm }
    2930 #define SSE_FOP(x) { helper_ ## x ## ps, helper_ ## x ## pd, \
    2931                      helper_ ## x ## ss, helper_ ## x ## sd, }
     2919#define MMX_OP2(x) { gen_helper_ ## x ## _mmx, gen_helper_ ## x ## _xmm }
     2920#define SSE_FOP(x) { gen_helper_ ## x ## ps, gen_helper_ ## x ## pd, \
     2921                     gen_helper_ ## x ## ss, gen_helper_ ## x ## sd, }
    29322922
    29332923static void *sse_op_table1[256][4] = {
     
    29402930    [0x12] = { SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL }, /* movlps, movlpd, movsldup, movddup */
    29412931    [0x13] = { SSE_SPECIAL, SSE_SPECIAL },  /* movlps, movlpd */
    2942     [0x14] = { helper_punpckldq_xmm, helper_punpcklqdq_xmm },
    2943     [0x15] = { helper_punpckhdq_xmm, helper_punpckhqdq_xmm },
     2932    [0x14] = { gen_helper_punpckldq_xmm, gen_helper_punpcklqdq_xmm },
     2933    [0x15] = { gen_helper_punpckhdq_xmm, gen_helper_punpckhqdq_xmm },
    29442934    [0x16] = { SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL },  /* movhps, movhpd, movshdup */
    29452935    [0x17] = { SSE_SPECIAL, SSE_SPECIAL },  /* movhps, movhpd */
     
    29512941    [0x2c] = { SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL }, /* cvttps2pi, cvttpd2pi, cvttsd2si, cvttss2si */
    29522942    [0x2d] = { SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL }, /* cvtps2pi, cvtpd2pi, cvtsd2si, cvtss2si */
    2953     [0x2e] = { helper_ucomiss, helper_ucomisd },
    2954     [0x2f] = { helper_comiss, helper_comisd },
     2943    [0x2e] = { gen_helper_ucomiss, gen_helper_ucomisd },
     2944    [0x2f] = { gen_helper_comiss, gen_helper_comisd },
    29552945    [0x50] = { SSE_SPECIAL, SSE_SPECIAL }, /* movmskps, movmskpd */
    29562946    [0x51] = SSE_FOP(sqrt),
    2957     [0x52] = { helper_rsqrtps, NULL, helper_rsqrtss, NULL },
    2958     [0x53] = { helper_rcpps, NULL, helper_rcpss, NULL },
    2959     [0x54] = { helper_pand_xmm, helper_pand_xmm }, /* andps, andpd */
    2960     [0x55] = { helper_pandn_xmm, helper_pandn_xmm }, /* andnps, andnpd */
    2961     [0x56] = { helper_por_xmm, helper_por_xmm }, /* orps, orpd */
    2962     [0x57] = { helper_pxor_xmm, helper_pxor_xmm }, /* xorps, xorpd */
     2947    [0x52] = { gen_helper_rsqrtps, NULL, gen_helper_rsqrtss, NULL },
     2948    [0x53] = { gen_helper_rcpps, NULL, gen_helper_rcpss, NULL },
     2949    [0x54] = { gen_helper_pand_xmm, gen_helper_pand_xmm }, /* andps, andpd */
     2950    [0x55] = { gen_helper_pandn_xmm, gen_helper_pandn_xmm }, /* andnps, andnpd */
     2951    [0x56] = { gen_helper_por_xmm, gen_helper_por_xmm }, /* orps, orpd */
     2952    [0x57] = { gen_helper_pxor_xmm, gen_helper_pxor_xmm }, /* xorps, xorpd */
    29632953    [0x58] = SSE_FOP(add),
    29642954    [0x59] = SSE_FOP(mul),
    2965     [0x5a] = { helper_cvtps2pd, helper_cvtpd2ps,
    2966                helper_cvtss2sd, helper_cvtsd2ss },
    2967     [0x5b] = { helper_cvtdq2ps, helper_cvtps2dq, helper_cvttps2dq },
     2955    [0x5a] = { gen_helper_cvtps2pd, gen_helper_cvtpd2ps,
     2956               gen_helper_cvtss2sd, gen_helper_cvtsd2ss },
     2957    [0x5b] = { gen_helper_cvtdq2ps, gen_helper_cvtps2dq, gen_helper_cvttps2dq },
    29682958    [0x5c] = SSE_FOP(sub),
    29692959    [0x5d] = SSE_FOP(min),
     
    29722962
    29732963    [0xc2] = SSE_FOP(cmpeq),
    2974     [0xc6] = { helper_shufps, helper_shufpd },
     2964    [0xc6] = { gen_helper_shufps, gen_helper_shufpd },
    29752965
    29762966    [0x38] = { SSE_SPECIAL, SSE_SPECIAL, NULL, SSE_SPECIAL }, /* SSSE3/SSE4 */
     
    29902980    [0x6a] = MMX_OP2(punpckhdq),
    29912981    [0x6b] = MMX_OP2(packssdw),
    2992     [0x6c] = { NULL, helper_punpcklqdq_xmm },
    2993     [0x6d] = { NULL, helper_punpckhqdq_xmm },
     2982    [0x6c] = { NULL, gen_helper_punpcklqdq_xmm },
     2983    [0x6d] = { NULL, gen_helper_punpckhqdq_xmm },
    29942984    [0x6e] = { SSE_SPECIAL, SSE_SPECIAL }, /* movd mm, ea */
    29952985    [0x6f] = { SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL }, /* movq, movdqa, , movqdu */
    2996     [0x70] = { helper_pshufw_mmx,
    2997                helper_pshufd_xmm,
    2998                helper_pshufhw_xmm,
    2999                helper_pshuflw_xmm },
     2986    [0x70] = { gen_helper_pshufw_mmx,
     2987               gen_helper_pshufd_xmm,
     2988               gen_helper_pshufhw_xmm,
     2989               gen_helper_pshuflw_xmm },
    30002990    [0x71] = { SSE_SPECIAL, SSE_SPECIAL }, /* shiftw */
    30012991    [0x72] = { SSE_SPECIAL, SSE_SPECIAL }, /* shiftd */
     
    30052995    [0x76] = MMX_OP2(pcmpeql),
    30062996    [0x77] = { SSE_DUMMY }, /* emms */
    3007     [0x7c] = { NULL, helper_haddpd, NULL, helper_haddps },
    3008     [0x7d] = { NULL, helper_hsubpd, NULL, helper_hsubps },
     2997    [0x7c] = { NULL, gen_helper_haddpd, NULL, gen_helper_haddps },
     2998    [0x7d] = { NULL, gen_helper_hsubpd, NULL, gen_helper_hsubps },
    30092999    [0x7e] = { SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL }, /* movd, movd, , movq */
    30103000    [0x7f] = { SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL }, /* movq, movdqa, movdqu */
    30113001    [0xc4] = { SSE_SPECIAL, SSE_SPECIAL }, /* pinsrw */
    30123002    [0xc5] = { SSE_SPECIAL, SSE_SPECIAL }, /* pextrw */
    3013     [0xd0] = { NULL, helper_addsubpd, NULL, helper_addsubps },
     3003    [0xd0] = { NULL, gen_helper_addsubpd, NULL, gen_helper_addsubps },
    30143004    [0xd1] = MMX_OP2(psrlw),
    30153005    [0xd2] = MMX_OP2(psrld),
     
    30333023    [0xe4] = MMX_OP2(pmulhuw),
    30343024    [0xe5] = MMX_OP2(pmulhw),
    3035     [0xe6] = { NULL, helper_cvttpd2dq, helper_cvtdq2pd, helper_cvtpd2dq },
     3025    [0xe6] = { NULL, gen_helper_cvttpd2dq, gen_helper_cvtdq2pd, gen_helper_cvtpd2dq },
    30363026    [0xe7] = { SSE_SPECIAL , SSE_SPECIAL },  /* movntq, movntq */
    30373027    [0xe8] = MMX_OP2(psubsb),
     
    30683058    [8 + 6] = MMX_OP2(pslld),
    30693059    [16 + 2] = MMX_OP2(psrlq),
    3070     [16 + 3] = { NULL, helper_psrldq_xmm },
     3060    [16 + 3] = { NULL, gen_helper_psrldq_xmm },
    30713061    [16 + 6] = MMX_OP2(psllq),
    3072     [16 + 7] = { NULL, helper_pslldq_xmm },
     3062    [16 + 7] = { NULL, gen_helper_pslldq_xmm },
    30733063};
    30743064
    30753065static void *sse_op_table3[4 * 3] = {
    3076     helper_cvtsi2ss,
    3077     helper_cvtsi2sd,
    3078     X86_64_ONLY(helper_cvtsq2ss),
    3079     X86_64_ONLY(helper_cvtsq2sd),
    3080 
    3081     helper_cvttss2si,
    3082     helper_cvttsd2si,
    3083     X86_64_ONLY(helper_cvttss2sq),
    3084     X86_64_ONLY(helper_cvttsd2sq),
    3085 
    3086     helper_cvtss2si,
    3087     helper_cvtsd2si,
    3088     X86_64_ONLY(helper_cvtss2sq),
    3089     X86_64_ONLY(helper_cvtsd2sq),
     3066    gen_helper_cvtsi2ss,
     3067    gen_helper_cvtsi2sd,
     3068    X86_64_ONLY(gen_helper_cvtsq2ss),
     3069    X86_64_ONLY(gen_helper_cvtsq2sd),
     3070
     3071    gen_helper_cvttss2si,
     3072    gen_helper_cvttsd2si,
     3073    X86_64_ONLY(gen_helper_cvttss2sq),
     3074    X86_64_ONLY(gen_helper_cvttsd2sq),
     3075
     3076    gen_helper_cvtss2si,
     3077    gen_helper_cvtsd2si,
     3078    X86_64_ONLY(gen_helper_cvtss2sq),
     3079    X86_64_ONLY(gen_helper_cvtsd2sq),
    30903080};
    30913081
     
    31023092
    31033093static void *sse_op_table5[256] = {
    3104     [0x0c] = helper_pi2fw,
    3105     [0x0d] = helper_pi2fd,
    3106     [0x1c] = helper_pf2iw,
    3107     [0x1d] = helper_pf2id,
    3108     [0x8a] = helper_pfnacc,
    3109     [0x8e] = helper_pfpnacc,
    3110     [0x90] = helper_pfcmpge,
    3111     [0x94] = helper_pfmin,
    3112     [0x96] = helper_pfrcp,
    3113     [0x97] = helper_pfrsqrt,
    3114     [0x9a] = helper_pfsub,
    3115     [0x9e] = helper_pfadd,
    3116     [0xa0] = helper_pfcmpgt,
    3117     [0xa4] = helper_pfmax,
    3118     [0xa6] = helper_movq, /* pfrcpit1; no need to actually increase precision */
    3119     [0xa7] = helper_movq, /* pfrsqit1 */
    3120     [0xaa] = helper_pfsubr,
    3121     [0xae] = helper_pfacc,
    3122     [0xb0] = helper_pfcmpeq,
    3123     [0xb4] = helper_pfmul,
    3124     [0xb6] = helper_movq, /* pfrcpit2 */
    3125     [0xb7] = helper_pmulhrw_mmx,
    3126     [0xbb] = helper_pswapd,
    3127     [0xbf] = helper_pavgb_mmx /* pavgusb */
     3094    [0x0c] = gen_helper_pi2fw,
     3095    [0x0d] = gen_helper_pi2fd,
     3096    [0x1c] = gen_helper_pf2iw,
     3097    [0x1d] = gen_helper_pf2id,
     3098    [0x8a] = gen_helper_pfnacc,
     3099    [0x8e] = gen_helper_pfpnacc,
     3100    [0x90] = gen_helper_pfcmpge,
     3101    [0x94] = gen_helper_pfmin,
     3102    [0x96] = gen_helper_pfrcp,
     3103    [0x97] = gen_helper_pfrsqrt,
     3104    [0x9a] = gen_helper_pfsub,
     3105    [0x9e] = gen_helper_pfadd,
     3106    [0xa0] = gen_helper_pfcmpgt,
     3107    [0xa4] = gen_helper_pfmax,
     3108    [0xa6] = gen_helper_movq, /* pfrcpit1; no need to actually increase precision */
     3109    [0xa7] = gen_helper_movq, /* pfrsqit1 */
     3110    [0xaa] = gen_helper_pfsubr,
     3111    [0xae] = gen_helper_pfacc,
     3112    [0xb0] = gen_helper_pfcmpeq,
     3113    [0xb4] = gen_helper_pfmul,
     3114    [0xb6] = gen_helper_movq, /* pfrcpit2 */
     3115    [0xb7] = gen_helper_pmulhrw_mmx,
     3116    [0xbb] = gen_helper_pswapd,
     3117    [0xbf] = gen_helper_pavgb_mmx /* pavgusb */
    31283118};
    31293119
     
    31323122};
    31333123#define SSSE3_OP(x) { MMX_OP2(x), CPUID_EXT_SSSE3 }
    3134 #define SSE41_OP(x) { { NULL, helper_ ## x ## _xmm }, CPUID_EXT_SSE41 }
    3135 #define SSE42_OP(x) { { NULL, helper_ ## x ## _xmm }, CPUID_EXT_SSE42 }
     3124#define SSE41_OP(x) { { NULL, gen_helper_ ## x ## _xmm }, CPUID_EXT_SSE41 }
     3125#define SSE42_OP(x) { { NULL, gen_helper_ ## x ## _xmm }, CPUID_EXT_SSE42 }
    31363126#define SSE41_SPECIAL { { NULL, SSE_SPECIAL }, CPUID_EXT_SSE41 }
    31373127static struct sse_op_helper_s sse_op_table6[256] = {
     
    32543244            goto illegal_op;
    32553245        /* femms */
    3256         tcg_gen_helper_0_0(helper_emms);
     3246        gen_helper_emms();
    32573247        return;
    32583248    }
    32593249    if (b == 0x77) {
    32603250        /* emms */
    3261         tcg_gen_helper_0_0(helper_emms);
     3251        gen_helper_emms();
    32623252        return;
    32633253    }
     
    32653255       the static cpu state) */
    32663256    if (!is_xmm) {
    3267         tcg_gen_helper_0_0(helper_enter_mmx);
     3257        gen_helper_enter_mmx();
    32683258    }
    32693259
     
    33023292                tcg_gen_addi_ptr(cpu_ptr0, cpu_env,
    33033293                                 offsetof(CPUX86State,fpregs[reg].mmx));
    3304                 tcg_gen_helper_0_2(helper_movl_mm_T0_mmx, cpu_ptr0, cpu_T[0]);
     3294                tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
     3295                gen_helper_movl_mm_T0_mmx(cpu_ptr0, cpu_tmp2_i32);
    33053296            }
    33063297            break;
     
    33113302                tcg_gen_addi_ptr(cpu_ptr0, cpu_env,
    33123303                                 offsetof(CPUX86State,xmm_regs[reg]));
    3313                 tcg_gen_helper_0_2(helper_movq_mm_T0_xmm, cpu_ptr0, cpu_T[0]);
     3304                gen_helper_movq_mm_T0_xmm(cpu_ptr0, cpu_T[0]);
    33143305            } else
    33153306#endif
     
    33193310                                 offsetof(CPUX86State,xmm_regs[reg]));
    33203311                tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    3321                 tcg_gen_helper_0_2(helper_movl_mm_T0_xmm, cpu_ptr0, cpu_tmp2_i32);
     3312                gen_helper_movl_mm_T0_xmm(cpu_ptr0, cpu_tmp2_i32);
    33223313            }
    33233314            break;
     
    35803571            tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op2_offset);
    35813572            tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op1_offset);
    3582             tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1);
     3573            ((void (*)(TCGv_ptr, TCGv_ptr))sse_op2)(cpu_ptr0, cpu_ptr1);
    35833574            break;
    35843575        case 0x050: /* movmskps */
     
    35863577            tcg_gen_addi_ptr(cpu_ptr0, cpu_env,
    35873578                             offsetof(CPUX86State,xmm_regs[rm]));
    3588             tcg_gen_helper_1_1(helper_movmskps, cpu_tmp2_i32, cpu_ptr0);
     3579            gen_helper_movmskps(cpu_tmp2_i32, cpu_ptr0);
    35893580            tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    35903581            gen_op_mov_reg_T0(OT_LONG, reg);
     
    35943585            tcg_gen_addi_ptr(cpu_ptr0, cpu_env,
    35953586                             offsetof(CPUX86State,xmm_regs[rm]));
    3596             tcg_gen_helper_1_1(helper_movmskpd, cpu_tmp2_i32, cpu_ptr0);
     3587            gen_helper_movmskpd(cpu_tmp2_i32, cpu_ptr0);
    35973588            tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    35983589            gen_op_mov_reg_T0(OT_LONG, reg);
     
    36003591        case 0x02a: /* cvtpi2ps */
    36013592        case 0x12a: /* cvtpi2pd */
    3602             tcg_gen_helper_0_0(helper_enter_mmx);
     3593            gen_helper_enter_mmx();
    36033594            if (mod != 3) {
    36043595                gen_lea_modrm(s, modrm, &reg_addr, &offset_addr);
     
    36143605            switch(b >> 8) {
    36153606            case 0x0:
    3616                 tcg_gen_helper_0_2(helper_cvtpi2ps, cpu_ptr0, cpu_ptr1);
     3607                gen_helper_cvtpi2ps(cpu_ptr0, cpu_ptr1);
    36173608                break;
    36183609            default:
    36193610            case 0x1:
    3620                 tcg_gen_helper_0_2(helper_cvtpi2pd, cpu_ptr0, cpu_ptr1);
     3611                gen_helper_cvtpi2pd(cpu_ptr0, cpu_ptr1);
    36213612                break;
    36223613            }
     
    36313622            if (ot == OT_LONG) {
    36323623                tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    3633                 tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_tmp2_i32);
     3624                ((void (*)(TCGv_ptr, TCGv_i32))sse_op2)(cpu_ptr0, cpu_tmp2_i32);
    36343625            } else {
    3635                 tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_T[0]);
     3626                ((void (*)(TCGv_ptr, TCGv))sse_op2)(cpu_ptr0, cpu_T[0]);
    36363627            }
    36373628            break;
     
    36403631        case 0x02d: /* cvtps2pi */
    36413632        case 0x12d: /* cvtpd2pi */
    3642             tcg_gen_helper_0_0(helper_enter_mmx);
     3633            gen_helper_enter_mmx();
    36433634            if (mod != 3) {
    36443635                gen_lea_modrm(s, modrm, &reg_addr, &offset_addr);
     
    36543645            switch(b) {
    36553646            case 0x02c:
    3656                 tcg_gen_helper_0_2(helper_cvttps2pi, cpu_ptr0, cpu_ptr1);
     3647                gen_helper_cvttps2pi(cpu_ptr0, cpu_ptr1);
    36573648                break;
    36583649            case 0x12c:
    3659                 tcg_gen_helper_0_2(helper_cvttpd2pi, cpu_ptr0, cpu_ptr1);
     3650                gen_helper_cvttpd2pi(cpu_ptr0, cpu_ptr1);
    36603651                break;
    36613652            case 0x02d:
    3662                 tcg_gen_helper_0_2(helper_cvtps2pi, cpu_ptr0, cpu_ptr1);
     3653                gen_helper_cvtps2pi(cpu_ptr0, cpu_ptr1);
    36633654                break;
    36643655            case 0x12d:
    3665                 tcg_gen_helper_0_2(helper_cvtpd2pi, cpu_ptr0, cpu_ptr1);
     3656                gen_helper_cvtpd2pi(cpu_ptr0, cpu_ptr1);
    36663657                break;
    36673658            }
     
    36893680            tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op2_offset);
    36903681            if (ot == OT_LONG) {
    3691                 tcg_gen_helper_1_1(sse_op2, cpu_tmp2_i32, cpu_ptr0);
     3682                ((void (*)(TCGv_i32, TCGv_ptr))sse_op2)(cpu_tmp2_i32, cpu_ptr0);
    36923683                tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    36933684            } else {
    3694                 tcg_gen_helper_1_1(sse_op2, cpu_T[0], cpu_ptr0);
     3685                ((void (*)(TCGv, TCGv_ptr))sse_op2)(cpu_T[0], cpu_ptr0);
    36953686            }
    36963687            gen_op_mov_reg_T0(ot, reg);
     
    37433734            break;
    37443735        case 0x2d6: /* movq2dq */
    3745             tcg_gen_helper_0_0(helper_enter_mmx);
     3736            gen_helper_enter_mmx();
    37463737            rm = (modrm & 7);
    37473738            gen_op_movq(offsetof(CPUX86State,xmm_regs[reg].XMM_Q(0)),
     
    37503741            break;
    37513742        case 0x3d6: /* movdq2q */
    3752             tcg_gen_helper_0_0(helper_enter_mmx);
     3743            gen_helper_enter_mmx();
    37533744            rm = (modrm & 7) | REX_B(s);
    37543745            gen_op_movq(offsetof(CPUX86State,fpregs[reg & 7].mmx),
     
    37623753                rm = (modrm & 7) | REX_B(s);
    37633754                tcg_gen_addi_ptr(cpu_ptr0, cpu_env, offsetof(CPUX86State,xmm_regs[rm]));
    3764                 tcg_gen_helper_1_1(helper_pmovmskb_xmm, cpu_tmp2_i32, cpu_ptr0);
     3755                gen_helper_pmovmskb_xmm(cpu_tmp2_i32, cpu_ptr0);
    37653756            } else {
    37663757                rm = (modrm & 7);
    37673758                tcg_gen_addi_ptr(cpu_ptr0, cpu_env, offsetof(CPUX86State,fpregs[rm].mmx));
    3768                 tcg_gen_helper_1_1(helper_pmovmskb_mmx, cpu_tmp2_i32, cpu_ptr0);
     3759                gen_helper_pmovmskb_mmx(cpu_tmp2_i32, cpu_ptr0);
    37693760            }
    37703761            tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
     
    38043795                    case 0x21: case 0x31: /* pmovsxbd, pmovzxbd */
    38053796                    case 0x24: case 0x34: /* pmovsxwq, pmovzxwq */
    3806                         tcg_gen_qemu_ld32u(cpu_tmp2_i32, cpu_A0,
     3797                        tcg_gen_qemu_ld32u(cpu_tmp0, cpu_A0,
    38073798                                          (s->mem_index >> 2) - 1);
     3799                        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_tmp0);
    38083800                        tcg_gen_st_i32(cpu_tmp2_i32, cpu_env, op2_offset +
    38093801                                        offsetof(XMMReg, XMM_L(0)));
     
    38373829            tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset);
    38383830            tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset);
    3839             tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1);
     3831            ((void (*)(TCGv_ptr, TCGv_ptr))sse_op2)(cpu_ptr0, cpu_ptr1);
    38403832
    38413833            if (b == 0x17)
     
    38663858            tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    38673859            gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
    3868             tcg_gen_helper_1_3(helper_crc32, cpu_T[0], cpu_tmp2_i32,
    3869                             cpu_T[0], tcg_const_i32(8 << ot));
     3860            gen_helper_crc32(cpu_T[0], cpu_tmp2_i32,
     3861                             cpu_T[0], tcg_const_i32(8 << ot));
    38703862
    38713863            ot = (s->dflag == 2) ? OT_QUAD : OT_LONG;
     
    39173909                                        offsetof(CPUX86State,
    39183910                                                xmm_regs[reg].XMM_L(val & 3)));
     3911                        tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    39193912                        if (mod == 3)
    3920                             gen_op_mov_reg_v(ot, rm, cpu_tmp2_i32);
     3913                            gen_op_mov_reg_v(ot, rm, cpu_T[0]);
    39213914                        else
    3922                             tcg_gen_qemu_st32(cpu_tmp2_i32, cpu_A0,
     3915                            tcg_gen_qemu_st32(cpu_T[0], cpu_A0,
    39233916                                            (s->mem_index >> 2) - 1);
    39243917                    } else { /* pextrq */
     3918#ifdef TARGET_X86_64
    39253919                        tcg_gen_ld_i64(cpu_tmp1_i64, cpu_env,
    39263920                                        offsetof(CPUX86State,
     
    39313925                            tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
    39323926                                            (s->mem_index >> 2) - 1);
     3927#else
     3928                        goto illegal_op;
     3929#endif
    39333930                    }
    39343931                    break;
     
    39463943                        gen_op_mov_TN_reg(OT_LONG, 0, rm);
    39473944                    else
    3948                         tcg_gen_qemu_ld8u(cpu_T[0], cpu_A0,
     3945                        tcg_gen_qemu_ld8u(cpu_tmp0, cpu_A0,
    39493946                                        (s->mem_index >> 2) - 1);
    3950                     tcg_gen_st8_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,
     3947                    tcg_gen_st8_tl(cpu_tmp0, cpu_env, offsetof(CPUX86State,
    39513948                                            xmm_regs[reg].XMM_B(val & 15)));
    39523949                    break;
    39533950                case 0x21: /* insertps */
    3954                     if (mod == 3)
     3951                    if (mod == 3) {
    39553952                        tcg_gen_ld_i32(cpu_tmp2_i32, cpu_env,
    39563953                                        offsetof(CPUX86State,xmm_regs[rm]
    39573954                                                .XMM_L((val >> 6) & 3)));
    3958                     else
    3959                         tcg_gen_qemu_ld32u(cpu_tmp2_i32, cpu_A0,
     3955                    } else {
     3956                        tcg_gen_qemu_ld32u(cpu_tmp0, cpu_A0,
    39603957                                        (s->mem_index >> 2) - 1);
     3958                        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_tmp0);
     3959                    }
    39613960                    tcg_gen_st_i32(cpu_tmp2_i32, cpu_env,
    39623961                                    offsetof(CPUX86State,xmm_regs[reg]
     
    39823981                    if (ot == OT_LONG) { /* pinsrd */
    39833982                        if (mod == 3)
    3984                             gen_op_mov_v_reg(ot, cpu_tmp2_i32, rm);
     3983                            gen_op_mov_v_reg(ot, cpu_tmp0, rm);
    39853984                        else
    3986                             tcg_gen_qemu_ld32u(cpu_tmp2_i32, cpu_A0,
     3985                            tcg_gen_qemu_ld32u(cpu_tmp0, cpu_A0,
    39873986                                            (s->mem_index >> 2) - 1);
     3987                        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_tmp0);
    39883988                        tcg_gen_st_i32(cpu_tmp2_i32, cpu_env,
    39893989                                        offsetof(CPUX86State,
    39903990                                                xmm_regs[reg].XMM_L(val & 3)));
    39913991                    } else { /* pinsrq */
     3992#ifdef TARGET_X86_64
    39923993                        if (mod == 3)
    39933994                            gen_op_mov_v_reg(ot, cpu_tmp1_i64, rm);
     
    39983999                                        offsetof(CPUX86State,
    39994000                                                xmm_regs[reg].XMM_Q(val & 1)));
     4001#else
     4002                        goto illegal_op;
     4003#endif
    40004004                    }
    40014005                    break;
     
    40354039            tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset);
    40364040            tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset);
    4037             tcg_gen_helper_0_3(sse_op2, cpu_ptr0, cpu_ptr1, tcg_const_i32(val));
     4041            ((void (*)(TCGv_ptr, TCGv_ptr, TCGv_i32))sse_op2)(cpu_ptr0, cpu_ptr1, tcg_const_i32(val));
    40384042            break;
    40394043        default:
     
    40954099            tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset);
    40964100            tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset);
    4097             tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1);
     4101            ((void (*)(TCGv_ptr, TCGv_ptr))sse_op2)(cpu_ptr0, cpu_ptr1);
    40984102            break;
    40994103        case 0x70: /* pshufx insn */
     
    41024106            tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset);
    41034107            tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset);
    4104             tcg_gen_helper_0_3(sse_op2, cpu_ptr0, cpu_ptr1, tcg_const_i32(val));
     4108            ((void (*)(TCGv_ptr, TCGv_ptr, TCGv_i32))sse_op2)(cpu_ptr0, cpu_ptr1, tcg_const_i32(val));
    41054109            break;
    41064110        case 0xc2:
     
    41124116            tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset);
    41134117            tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset);
    4114             tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1);
     4118            ((void (*)(TCGv_ptr, TCGv_ptr))sse_op2)(cpu_ptr0, cpu_ptr1);
    41154119            break;
    41164120        case 0xf7:
     
    41324136            tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset);
    41334137            tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset);
    4134             tcg_gen_helper_0_3(sse_op2, cpu_ptr0, cpu_ptr1, cpu_A0);
     4138            ((void (*)(TCGv_ptr, TCGv_ptr, TCGv))sse_op2)(cpu_ptr0, cpu_ptr1, cpu_A0);
    41354139            break;
    41364140        default:
    41374141            tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset);
    41384142            tcg_gen_addi_ptr(cpu_ptr1, cpu_env, op2_offset);
    4139             tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_ptr1);
     4143            ((void (*)(TCGv_ptr, TCGv_ptr))sse_op2)(cpu_ptr0, cpu_ptr1);
    41404144            break;
    41414145        }
     
    42984302    int rex_w, rex_r;
    42994303
    4300     if (unlikely(loglevel & CPU_LOG_TB_OP))
     4304    if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)))
    43014305        tcg_gen_debug_insn_start(pc_start);
    43024306    s->pc = pc_start;
     
    44314435#ifndef VBOX
    44324436    if (prefixes & PREFIX_LOCK)
    4433         tcg_gen_helper_0_0(helper_lock);
     4437        gen_helper_lock();
    44344438#else /* VBOX */
    44354439    if (prefixes & PREFIX_LOCK) {
     
    44384442            return s->pc;
    44394443        }
    4440         tcg_gen_helper_0_0(helper_lock);
     4444        gen_helper_lock();
    44414445    }
    44424446#endif /* VBOX */
     
    46594663#else
    46604664                {
    4661                     TCGv t0, t1;
    4662                     t0 = tcg_temp_new(TCG_TYPE_I64);
    4663                     t1 = tcg_temp_new(TCG_TYPE_I64);
     4665                    TCGv_i64 t0, t1;
     4666                    t0 = tcg_temp_new_i64();
     4667                    t1 = tcg_temp_new_i64();
    46644668                    gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
    46654669                    tcg_gen_extu_i32_i64(t0, cpu_T[0]);
     
    46794683#ifdef TARGET_X86_64
    46804684            case OT_QUAD:
    4681                 tcg_gen_helper_0_1(helper_mulq_EAX_T0, cpu_T[0]);
     4685                gen_helper_mulq_EAX_T0(cpu_T[0]);
    46824686                s->cc_op = CC_OP_MULQ;
    46834687                break;
     
    47284732#else
    47294733                {
    4730                     TCGv t0, t1;
    4731                     t0 = tcg_temp_new(TCG_TYPE_I64);
    4732                     t1 = tcg_temp_new(TCG_TYPE_I64);
     4734                    TCGv_i64 t0, t1;
     4735                    t0 = tcg_temp_new_i64();
     4736                    t1 = tcg_temp_new_i64();
    47334737                    gen_op_mov_TN_reg(OT_LONG, 1, R_EAX);
    47344738                    tcg_gen_ext_i32_i64(t0, cpu_T[0]);
     
    47494753#ifdef TARGET_X86_64
    47504754            case OT_QUAD:
    4751                 tcg_gen_helper_0_1(helper_imulq_EAX_T0, cpu_T[0]);
     4755                gen_helper_imulq_EAX_T0(cpu_T[0]);
    47524756                s->cc_op = CC_OP_MULQ;
    47534757                break;
     
    47594763            case OT_BYTE:
    47604764                gen_jmp_im(pc_start - s->cs_base);
    4761                 tcg_gen_helper_0_1(helper_divb_AL, cpu_T[0]);
     4765                gen_helper_divb_AL(cpu_T[0]);
    47624766                break;
    47634767            case OT_WORD:
    47644768                gen_jmp_im(pc_start - s->cs_base);
    4765                 tcg_gen_helper_0_1(helper_divw_AX, cpu_T[0]);
     4769                gen_helper_divw_AX(cpu_T[0]);
    47664770                break;
    47674771            default:
    47684772            case OT_LONG:
    47694773                gen_jmp_im(pc_start - s->cs_base);
    4770                 tcg_gen_helper_0_1(helper_divl_EAX, cpu_T[0]);
     4774                gen_helper_divl_EAX(cpu_T[0]);
    47714775                break;
    47724776#ifdef TARGET_X86_64
    47734777            case OT_QUAD:
    47744778                gen_jmp_im(pc_start - s->cs_base);
    4775                 tcg_gen_helper_0_1(helper_divq_EAX, cpu_T[0]);
     4779                gen_helper_divq_EAX(cpu_T[0]);
    47764780                break;
    47774781#endif
     
    47824786            case OT_BYTE:
    47834787                gen_jmp_im(pc_start - s->cs_base);
    4784                 tcg_gen_helper_0_1(helper_idivb_AL, cpu_T[0]);
     4788                gen_helper_idivb_AL(cpu_T[0]);
    47854789                break;
    47864790            case OT_WORD:
    47874791                gen_jmp_im(pc_start - s->cs_base);
    4788                 tcg_gen_helper_0_1(helper_idivw_AX, cpu_T[0]);
     4792                gen_helper_idivw_AX(cpu_T[0]);
    47894793                break;
    47904794            default:
    47914795            case OT_LONG:
    47924796                gen_jmp_im(pc_start - s->cs_base);
    4793                 tcg_gen_helper_0_1(helper_idivl_EAX, cpu_T[0]);
     4797                gen_helper_idivl_EAX(cpu_T[0]);
    47944798                break;
    47954799#ifdef TARGET_X86_64
    47964800            case OT_QUAD:
    47974801                gen_jmp_im(pc_start - s->cs_base);
    4798                 tcg_gen_helper_0_1(helper_idivq_EAX, cpu_T[0]);
     4802                gen_helper_idivq_EAX(cpu_T[0]);
    47994803                break;
    48004804#endif
     
    48804884                gen_jmp_im(pc_start - s->cs_base);
    48814885                tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    4882                 tcg_gen_helper_0_4(helper_lcall_protected,
    4883                                    cpu_tmp2_i32, cpu_T[1],
    4884                                    tcg_const_i32(dflag),
    4885                                    tcg_const_i32(s->pc - pc_start));
     4886                gen_helper_lcall_protected(cpu_tmp2_i32, cpu_T[1],
     4887                                           tcg_const_i32(dflag),
     4888                                           tcg_const_i32(s->pc - pc_start));
    48864889            } else {
    48874890                tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    4888                 tcg_gen_helper_0_4(helper_lcall_real,
    4889                                    cpu_tmp2_i32, cpu_T[1],
    4890                                    tcg_const_i32(dflag),
    4891                                    tcg_const_i32(s->pc - s->cs_base));
     4891                gen_helper_lcall_real(cpu_tmp2_i32, cpu_T[1],
     4892                                      tcg_const_i32(dflag),
     4893                                      tcg_const_i32(s->pc - s->cs_base));
    48924894            }
    48934895            gen_eob(s);
     
    49094911                gen_jmp_im(pc_start - s->cs_base);
    49104912                tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    4911                 tcg_gen_helper_0_3(helper_ljmp_protected,
    4912                                    cpu_tmp2_i32,
    4913                                    cpu_T[1],
    4914                                    tcg_const_i32(s->pc - pc_start));
     4913                gen_helper_ljmp_protected(cpu_tmp2_i32, cpu_T[1],
     4914                                          tcg_const_i32(s->pc - pc_start));
    49154915            } else {
    49164916                gen_op_movl_seg_T0_vm(R_CS);
     
    50215021#ifdef TARGET_X86_64
    50225022        if (ot == OT_QUAD) {
    5023             tcg_gen_helper_1_2(helper_imulq_T0_T1, cpu_T[0], cpu_T[0], cpu_T[1]);
     5023            gen_helper_imulq_T0_T1(cpu_T[0], cpu_T[0], cpu_T[1]);
    50245024        } else
    50255025#endif
     
    50345034#else
    50355035                {
    5036                     TCGv t0, t1;
    5037                     t0 = tcg_temp_new(TCG_TYPE_I64);
    5038                     t1 = tcg_temp_new(TCG_TYPE_I64);
     5036                    TCGv_i64 t0, t1;
     5037                    t0 = tcg_temp_new_i64();
     5038                    t1 = tcg_temp_new_i64();
    50395039                    tcg_gen_ext_i32_i64(t0, cpu_T[0]);
    50405040                    tcg_gen_ext_i32_i64(t1, cpu_T[1]);
     
    51005100            reg = ((modrm >> 3) & 7) | rex_r;
    51015101            mod = (modrm >> 6) & 3;
    5102             t0 = tcg_temp_local_new(TCG_TYPE_TL);
    5103             t1 = tcg_temp_local_new(TCG_TYPE_TL);
    5104             t2 = tcg_temp_local_new(TCG_TYPE_TL);
    5105             a0 = tcg_temp_local_new(TCG_TYPE_TL);
     5102            t0 = tcg_temp_local_new();
     5103            t1 = tcg_temp_local_new();
     5104            t2 = tcg_temp_local_new();
     5105            a0 = tcg_temp_local_new();
    51065106            gen_op_mov_v_reg(ot, t1, reg);
    51075107            if (mod == 3) {
     
    51555155                gen_op_set_cc_op(s->cc_op);
    51565156            gen_lea_modrm(s, modrm, &reg_addr, &offset_addr);
    5157             tcg_gen_helper_0_1(helper_cmpxchg16b, cpu_A0);
     5157            gen_helper_cmpxchg16b(cpu_A0);
    51585158        } else
    51595159#endif
     
    51655165                gen_op_set_cc_op(s->cc_op);
    51665166            gen_lea_modrm(s, modrm, &reg_addr, &offset_addr);
    5167             tcg_gen_helper_0_1(helper_cmpxchg8b, cpu_A0);
     5167            gen_helper_cmpxchg8b(cpu_A0);
    51685168        }
    51695169        s->cc_op = CC_OP_EFLAGS;
     
    52915291               _first_ does it */
    52925292            if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
    5293                 tcg_gen_helper_0_0(helper_set_inhibit_irq);
     5293                gen_helper_set_inhibit_irq();
    52945294            s->tf = 0;
    52955295        }
     
    53715371               _first_ does it */
    53725372            if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
    5373                 tcg_gen_helper_0_0(helper_set_inhibit_irq);
     5373                gen_helper_set_inhibit_irq();
    53745374            s->tf = 0;
    53755375        }
     
    55655565            /* for xchg, lock is implicit */
    55665566            if (!(prefixes & PREFIX_LOCK))
    5567                 tcg_gen_helper_0_0(helper_lock);
     5567                gen_helper_lock();
    55685568            gen_op_ld_T1_A0(ot + s->mem_index);
    55695569            gen_op_st_T0_A0(ot + s->mem_index);
    55705570            if (!(prefixes & PREFIX_LOCK))
    5571                 tcg_gen_helper_0_0(helper_unlock);
     5571                gen_helper_unlock();
    55725572            gen_op_mov_reg_T1(ot, reg);
    55735573        }
     
    57285728                        gen_op_ld_T0_A0(OT_LONG + s->mem_index);
    57295729                        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    5730                         tcg_gen_helper_0_1(helper_flds_FT0, cpu_tmp2_i32);
     5730                        gen_helper_flds_FT0(cpu_tmp2_i32);
    57315731                        break;
    57325732                    case 1:
    57335733                        gen_op_ld_T0_A0(OT_LONG + s->mem_index);
    57345734                        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    5735                         tcg_gen_helper_0_1(helper_fildl_FT0, cpu_tmp2_i32);
     5735                        gen_helper_fildl_FT0(cpu_tmp2_i32);
    57365736                        break;
    57375737                    case 2:
    57385738                        tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
    57395739                                          (s->mem_index >> 2) - 1);
    5740                         tcg_gen_helper_0_1(helper_fldl_FT0, cpu_tmp1_i64);
     5740                        gen_helper_fldl_FT0(cpu_tmp1_i64);
    57415741                        break;
    57425742                    case 3:
     
    57445744                        gen_op_lds_T0_A0(OT_WORD + s->mem_index);
    57455745                        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    5746                         tcg_gen_helper_0_1(helper_fildl_FT0, cpu_tmp2_i32);
     5746                        gen_helper_fildl_FT0(cpu_tmp2_i32);
    57475747                        break;
    57485748                    }
    57495749
    5750                     tcg_gen_helper_0_0(helper_fp_arith_ST0_FT0[op1]);
     5750                    gen_helper_fp_arith_ST0_FT0(op1);
    57515751                    if (op1 == 3) {
    57525752                        /* fcomp needs pop */
    5753                         tcg_gen_helper_0_0(helper_fpop);
     5753                        gen_helper_fpop();
    57545754                    }
    57555755                }
     
    57675767                        gen_op_ld_T0_A0(OT_LONG + s->mem_index);
    57685768                        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    5769                         tcg_gen_helper_0_1(helper_flds_ST0, cpu_tmp2_i32);
     5769                        gen_helper_flds_ST0(cpu_tmp2_i32);
    57705770                        break;
    57715771                    case 1:
    57725772                        gen_op_ld_T0_A0(OT_LONG + s->mem_index);
    57735773                        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    5774                         tcg_gen_helper_0_1(helper_fildl_ST0, cpu_tmp2_i32);
     5774                        gen_helper_fildl_ST0(cpu_tmp2_i32);
    57755775                        break;
    57765776                    case 2:
    57775777                        tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
    57785778                                          (s->mem_index >> 2) - 1);
    5779                         tcg_gen_helper_0_1(helper_fldl_ST0, cpu_tmp1_i64);
     5779                        gen_helper_fldl_ST0(cpu_tmp1_i64);
    57805780                        break;
    57815781                    case 3:
     
    57835783                        gen_op_lds_T0_A0(OT_WORD + s->mem_index);
    57845784                        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    5785                         tcg_gen_helper_0_1(helper_fildl_ST0, cpu_tmp2_i32);
     5785                        gen_helper_fildl_ST0(cpu_tmp2_i32);
    57865786                        break;
    57875787                    }
     
    57915791                    switch(op >> 4) {
    57925792                    case 1:
    5793                         tcg_gen_helper_1_0(helper_fisttl_ST0, cpu_tmp2_i32);
     5793                        gen_helper_fisttl_ST0(cpu_tmp2_i32);
    57945794                        tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    57955795                        gen_op_st_T0_A0(OT_LONG + s->mem_index);
    57965796                        break;
    57975797                    case 2:
    5798                         tcg_gen_helper_1_0(helper_fisttll_ST0, cpu_tmp1_i64);
     5798                        gen_helper_fisttll_ST0(cpu_tmp1_i64);
    57995799                        tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
    58005800                                          (s->mem_index >> 2) - 1);
     
    58025802                    case 3:
    58035803                    default:
    5804                         tcg_gen_helper_1_0(helper_fistt_ST0, cpu_tmp2_i32);
     5804                        gen_helper_fistt_ST0(cpu_tmp2_i32);
    58055805                        tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    58065806                        gen_op_st_T0_A0(OT_WORD + s->mem_index);
    58075807                        break;
    58085808                    }
    5809                     tcg_gen_helper_0_0(helper_fpop);
     5809                    gen_helper_fpop();
    58105810                    break;
    58115811                default:
    58125812                    switch(op >> 4) {
    58135813                    case 0:
    5814                         tcg_gen_helper_1_0(helper_fsts_ST0, cpu_tmp2_i32);
     5814                        gen_helper_fsts_ST0(cpu_tmp2_i32);
    58155815                        tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    58165816                        gen_op_st_T0_A0(OT_LONG + s->mem_index);
    58175817                        break;
    58185818                    case 1:
    5819                         tcg_gen_helper_1_0(helper_fistl_ST0, cpu_tmp2_i32);
     5819                        gen_helper_fistl_ST0(cpu_tmp2_i32);
    58205820                        tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    58215821                        gen_op_st_T0_A0(OT_LONG + s->mem_index);
    58225822                        break;
    58235823                    case 2:
    5824                         tcg_gen_helper_1_0(helper_fstl_ST0, cpu_tmp1_i64);
     5824                        gen_helper_fstl_ST0(cpu_tmp1_i64);
    58255825                        tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
    58265826                                          (s->mem_index >> 2) - 1);
     
    58285828                    case 3:
    58295829                    default:
    5830                         tcg_gen_helper_1_0(helper_fist_ST0, cpu_tmp2_i32);
     5830                        gen_helper_fist_ST0(cpu_tmp2_i32);
    58315831                        tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    58325832                        gen_op_st_T0_A0(OT_WORD + s->mem_index);
     
    58345834                    }
    58355835                    if ((op & 7) == 3)
    5836                         tcg_gen_helper_0_0(helper_fpop);
     5836                        gen_helper_fpop();
    58375837                    break;
    58385838                }
     
    58425842                    gen_op_set_cc_op(s->cc_op);
    58435843                gen_jmp_im(pc_start - s->cs_base);
    5844                 tcg_gen_helper_0_2(helper_fldenv,
     5844                gen_helper_fldenv(
    58455845                                   cpu_A0, tcg_const_i32(s->dflag));
    58465846                break;
     
    58485848                gen_op_ld_T0_A0(OT_WORD + s->mem_index);
    58495849                tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    5850                 tcg_gen_helper_0_1(helper_fldcw, cpu_tmp2_i32);
     5850                gen_helper_fldcw(cpu_tmp2_i32);
    58515851                break;
    58525852            case 0x0e: /* fnstenv mem */
     
    58545854                    gen_op_set_cc_op(s->cc_op);
    58555855                gen_jmp_im(pc_start - s->cs_base);
    5856                 tcg_gen_helper_0_2(helper_fstenv,
    5857                                    cpu_A0, tcg_const_i32(s->dflag));
     5856                gen_helper_fstenv(cpu_A0, tcg_const_i32(s->dflag));
    58585857                break;
    58595858            case 0x0f: /* fnstcw mem */
    5860                 tcg_gen_helper_1_0(helper_fnstcw, cpu_tmp2_i32);
     5859                gen_helper_fnstcw(cpu_tmp2_i32);
    58615860                tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    58625861                gen_op_st_T0_A0(OT_WORD + s->mem_index);
     
    58665865                    gen_op_set_cc_op(s->cc_op);
    58675866                gen_jmp_im(pc_start - s->cs_base);
    5868                 tcg_gen_helper_0_1(helper_fldt_ST0, cpu_A0);
     5867                gen_helper_fldt_ST0(cpu_A0);
    58695868                break;
    58705869            case 0x1f: /* fstpt mem */
     
    58725871                    gen_op_set_cc_op(s->cc_op);
    58735872                gen_jmp_im(pc_start - s->cs_base);
    5874                 tcg_gen_helper_0_1(helper_fstt_ST0, cpu_A0);
    5875                 tcg_gen_helper_0_0(helper_fpop);
     5873                gen_helper_fstt_ST0(cpu_A0);
     5874                gen_helper_fpop();
    58765875                break;
    58775876            case 0x2c: /* frstor mem */
     
    58795878                    gen_op_set_cc_op(s->cc_op);
    58805879                gen_jmp_im(pc_start - s->cs_base);
    5881                 tcg_gen_helper_0_2(helper_frstor,
    5882                                    cpu_A0, tcg_const_i32(s->dflag));
     5880                gen_helper_frstor(cpu_A0, tcg_const_i32(s->dflag));
    58835881                break;
    58845882            case 0x2e: /* fnsave mem */
     
    58865884                    gen_op_set_cc_op(s->cc_op);
    58875885                gen_jmp_im(pc_start - s->cs_base);
    5888                 tcg_gen_helper_0_2(helper_fsave,
    5889                                    cpu_A0, tcg_const_i32(s->dflag));
     5886                gen_helper_fsave(cpu_A0, tcg_const_i32(s->dflag));
    58905887                break;
    58915888            case 0x2f: /* fnstsw mem */
    5892                 tcg_gen_helper_1_0(helper_fnstsw, cpu_tmp2_i32);
     5889                gen_helper_fnstsw(cpu_tmp2_i32);
    58935890                tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    58945891                gen_op_st_T0_A0(OT_WORD + s->mem_index);
     
    58985895                    gen_op_set_cc_op(s->cc_op);
    58995896                gen_jmp_im(pc_start - s->cs_base);
    5900                 tcg_gen_helper_0_1(helper_fbld_ST0, cpu_A0);
     5897                gen_helper_fbld_ST0(cpu_A0);
    59015898                break;
    59025899            case 0x3e: /* fbstp */
     
    59045901                    gen_op_set_cc_op(s->cc_op);
    59055902                gen_jmp_im(pc_start - s->cs_base);
    5906                 tcg_gen_helper_0_1(helper_fbst_ST0, cpu_A0);
    5907                 tcg_gen_helper_0_0(helper_fpop);
     5903                gen_helper_fbst_ST0(cpu_A0);
     5904                gen_helper_fpop();
    59085905                break;
    59095906            case 0x3d: /* fildll */
    59105907                tcg_gen_qemu_ld64(cpu_tmp1_i64, cpu_A0,
    59115908                                  (s->mem_index >> 2) - 1);
    5912                 tcg_gen_helper_0_1(helper_fildll_ST0, cpu_tmp1_i64);
     5909                gen_helper_fildll_ST0(cpu_tmp1_i64);
    59135910                break;
    59145911            case 0x3f: /* fistpll */
    5915                 tcg_gen_helper_1_0(helper_fistll_ST0, cpu_tmp1_i64);
     5912                gen_helper_fistll_ST0(cpu_tmp1_i64);
    59165913                tcg_gen_qemu_st64(cpu_tmp1_i64, cpu_A0,
    59175914                                  (s->mem_index >> 2) - 1);
    5918                 tcg_gen_helper_0_0(helper_fpop);
     5915                gen_helper_fpop();
    59195916                break;
    59205917            default:
     
    59275924            switch(op) {
    59285925            case 0x08: /* fld sti */
    5929                 tcg_gen_helper_0_0(helper_fpush);
    5930                 tcg_gen_helper_0_1(helper_fmov_ST0_STN, tcg_const_i32((opreg + 1) & 7));
     5926                gen_helper_fpush();
     5927                gen_helper_fmov_ST0_STN(tcg_const_i32((opreg + 1) & 7));
    59315928                break;
    59325929            case 0x09: /* fxchg sti */
    59335930            case 0x29: /* fxchg4 sti, undocumented op */
    59345931            case 0x39: /* fxchg7 sti, undocumented op */
    5935                 tcg_gen_helper_0_1(helper_fxchg_ST0_STN, tcg_const_i32(opreg));
     5932                gen_helper_fxchg_ST0_STN(tcg_const_i32(opreg));
    59365933                break;
    59375934            case 0x0a: /* grp d9/2 */
     
    59425939                        gen_op_set_cc_op(s->cc_op);
    59435940                    gen_jmp_im(pc_start - s->cs_base);
    5944                     tcg_gen_helper_0_0(helper_fwait);
     5941                    gen_helper_fwait();
    59455942                    break;
    59465943                default:
     
    59515948                switch(rm) {
    59525949                case 0: /* fchs */
    5953                     tcg_gen_helper_0_0(helper_fchs_ST0);
     5950                    gen_helper_fchs_ST0();
    59545951                    break;
    59555952                case 1: /* fabs */
    5956                     tcg_gen_helper_0_0(helper_fabs_ST0);
     5953                    gen_helper_fabs_ST0();
    59575954                    break;
    59585955                case 4: /* ftst */
    5959                     tcg_gen_helper_0_0(helper_fldz_FT0);
    5960                     tcg_gen_helper_0_0(helper_fcom_ST0_FT0);
     5956                    gen_helper_fldz_FT0();
     5957                    gen_helper_fcom_ST0_FT0();
    59615958                    break;
    59625959                case 5: /* fxam */
    5963                     tcg_gen_helper_0_0(helper_fxam_ST0);
     5960                    gen_helper_fxam_ST0();
    59645961                    break;
    59655962                default:
     
    59715968                    switch(rm) {
    59725969                    case 0:
    5973                         tcg_gen_helper_0_0(helper_fpush);
    5974                         tcg_gen_helper_0_0(helper_fld1_ST0);
     5970                        gen_helper_fpush();
     5971                        gen_helper_fld1_ST0();
    59755972                        break;
    59765973                    case 1:
    5977                         tcg_gen_helper_0_0(helper_fpush);
    5978                         tcg_gen_helper_0_0(helper_fldl2t_ST0);
     5974                        gen_helper_fpush();
     5975                        gen_helper_fldl2t_ST0();
    59795976                        break;
    59805977                    case 2:
    5981                         tcg_gen_helper_0_0(helper_fpush);
    5982                         tcg_gen_helper_0_0(helper_fldl2e_ST0);
     5978                        gen_helper_fpush();
     5979                        gen_helper_fldl2e_ST0();
    59835980                        break;
    59845981                    case 3:
    5985                         tcg_gen_helper_0_0(helper_fpush);
    5986                         tcg_gen_helper_0_0(helper_fldpi_ST0);
     5982                        gen_helper_fpush();
     5983                        gen_helper_fldpi_ST0();
    59875984                        break;
    59885985                    case 4:
    5989                         tcg_gen_helper_0_0(helper_fpush);
    5990                         tcg_gen_helper_0_0(helper_fldlg2_ST0);
     5986                        gen_helper_fpush();
     5987                        gen_helper_fldlg2_ST0();
    59915988                        break;
    59925989                    case 5:
    5993                         tcg_gen_helper_0_0(helper_fpush);
    5994                         tcg_gen_helper_0_0(helper_fldln2_ST0);
     5990                        gen_helper_fpush();
     5991                        gen_helper_fldln2_ST0();
    59955992                        break;
    59965993                    case 6:
    5997                         tcg_gen_helper_0_0(helper_fpush);
    5998                         tcg_gen_helper_0_0(helper_fldz_ST0);
     5994                        gen_helper_fpush();
     5995                        gen_helper_fldz_ST0();
    59995996                        break;
    60005997                    default:
     
    60066003                switch(rm) {
    60076004                case 0: /* f2xm1 */
    6008                     tcg_gen_helper_0_0(helper_f2xm1);
     6005                    gen_helper_f2xm1();
    60096006                    break;
    60106007                case 1: /* fyl2x */
    6011                     tcg_gen_helper_0_0(helper_fyl2x);
     6008                    gen_helper_fyl2x();
    60126009                    break;
    60136010                case 2: /* fptan */
    6014                     tcg_gen_helper_0_0(helper_fptan);
     6011                    gen_helper_fptan();
    60156012                    break;
    60166013                case 3: /* fpatan */
    6017                     tcg_gen_helper_0_0(helper_fpatan);
     6014                    gen_helper_fpatan();
    60186015                    break;
    60196016                case 4: /* fxtract */
    6020                     tcg_gen_helper_0_0(helper_fxtract);
     6017                    gen_helper_fxtract();
    60216018                    break;
    60226019                case 5: /* fprem1 */
    6023                     tcg_gen_helper_0_0(helper_fprem1);
     6020                    gen_helper_fprem1();
    60246021                    break;
    60256022                case 6: /* fdecstp */
    6026                     tcg_gen_helper_0_0(helper_fdecstp);
     6023                    gen_helper_fdecstp();
    60276024                    break;
    60286025                default:
    60296026                case 7: /* fincstp */
    6030                     tcg_gen_helper_0_0(helper_fincstp);
     6027                    gen_helper_fincstp();
    60316028                    break;
    60326029                }
     
    60356032                switch(rm) {
    60366033                case 0: /* fprem */
    6037                     tcg_gen_helper_0_0(helper_fprem);
     6034                    gen_helper_fprem();
    60386035                    break;
    60396036                case 1: /* fyl2xp1 */
    6040                     tcg_gen_helper_0_0(helper_fyl2xp1);
     6037                    gen_helper_fyl2xp1();
    60416038                    break;
    60426039                case 2: /* fsqrt */
    6043                     tcg_gen_helper_0_0(helper_fsqrt);
     6040                    gen_helper_fsqrt();
    60446041                    break;
    60456042                case 3: /* fsincos */
    6046                     tcg_gen_helper_0_0(helper_fsincos);
     6043                    gen_helper_fsincos();
    60476044                    break;
    60486045                case 5: /* fscale */
    6049                     tcg_gen_helper_0_0(helper_fscale);
     6046                    gen_helper_fscale();
    60506047                    break;
    60516048                case 4: /* frndint */
    6052                     tcg_gen_helper_0_0(helper_frndint);
     6049                    gen_helper_frndint();
    60536050                    break;
    60546051                case 6: /* fsin */
    6055                     tcg_gen_helper_0_0(helper_fsin);
     6052                    gen_helper_fsin();
    60566053                    break;
    60576054                default:
    60586055                case 7: /* fcos */
    6059                     tcg_gen_helper_0_0(helper_fcos);
     6056                    gen_helper_fcos();
    60606057                    break;
    60616058                }
     
    60696066                    op1 = op & 7;
    60706067                    if (op >= 0x20) {
    6071                         tcg_gen_helper_0_1(helper_fp_arith_STN_ST0[op1], tcg_const_i32(opreg));
     6068                        gen_helper_fp_arith_STN_ST0(op1, opreg);
    60726069                        if (op >= 0x30)
    6073                             tcg_gen_helper_0_0(helper_fpop);
     6070                            gen_helper_fpop();
    60746071                    } else {
    6075                         tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(opreg));
    6076                         tcg_gen_helper_0_0(helper_fp_arith_ST0_FT0[op1]);
     6072                        gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
     6073                        gen_helper_fp_arith_ST0_FT0(op1);
    60776074                    }
    60786075                }
     
    60806077            case 0x02: /* fcom */
    60816078            case 0x22: /* fcom2, undocumented op */
    6082                 tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(opreg));
    6083                 tcg_gen_helper_0_0(helper_fcom_ST0_FT0);
     6079                gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
     6080                gen_helper_fcom_ST0_FT0();
    60846081                break;
    60856082            case 0x03: /* fcomp */
    60866083            case 0x23: /* fcomp3, undocumented op */
    60876084            case 0x32: /* fcomp5, undocumented op */
    6088                 tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(opreg));
    6089                 tcg_gen_helper_0_0(helper_fcom_ST0_FT0);
    6090                 tcg_gen_helper_0_0(helper_fpop);
     6085                gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
     6086                gen_helper_fcom_ST0_FT0();
     6087                gen_helper_fpop();
    60916088                break;
    60926089            case 0x15: /* da/5 */
    60936090                switch(rm) {
    60946091                case 1: /* fucompp */
    6095                     tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(1));
    6096                     tcg_gen_helper_0_0(helper_fucom_ST0_FT0);
    6097                     tcg_gen_helper_0_0(helper_fpop);
    6098                     tcg_gen_helper_0_0(helper_fpop);
     6092                    gen_helper_fmov_FT0_STN(tcg_const_i32(1));
     6093                    gen_helper_fucom_ST0_FT0();
     6094                    gen_helper_fpop();
     6095                    gen_helper_fpop();
    60996096                    break;
    61006097                default:
     
    61096106                    break;
    61106107                case 2: /* fclex */
    6111                     tcg_gen_helper_0_0(helper_fclex);
     6108                    gen_helper_fclex();
    61126109                    break;
    61136110                case 3: /* fninit */
    6114                     tcg_gen_helper_0_0(helper_fninit);
     6111                    gen_helper_fninit();
    61156112                    break;
    61166113                case 4: /* fsetpm (287 only, just do nop here) */
     
    61236120                if (s->cc_op != CC_OP_DYNAMIC)
    61246121                    gen_op_set_cc_op(s->cc_op);
    6125                 tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(opreg));
    6126                 tcg_gen_helper_0_0(helper_fucomi_ST0_FT0);
     6122                gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
     6123                gen_helper_fucomi_ST0_FT0();
    61276124                s->cc_op = CC_OP_EFLAGS;
    61286125                break;
     
    61306127                if (s->cc_op != CC_OP_DYNAMIC)
    61316128                    gen_op_set_cc_op(s->cc_op);
    6132                 tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(opreg));
    6133                 tcg_gen_helper_0_0(helper_fcomi_ST0_FT0);
     6129                gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
     6130                gen_helper_fcomi_ST0_FT0();
    61346131                s->cc_op = CC_OP_EFLAGS;
    61356132                break;
    61366133            case 0x28: /* ffree sti */
    6137                 tcg_gen_helper_0_1(helper_ffree_STN, tcg_const_i32(opreg));
     6134                gen_helper_ffree_STN(tcg_const_i32(opreg));
    61386135                break;
    61396136            case 0x2a: /* fst sti */
    6140                 tcg_gen_helper_0_1(helper_fmov_STN_ST0, tcg_const_i32(opreg));
     6137                gen_helper_fmov_STN_ST0(tcg_const_i32(opreg));
    61416138                break;
    61426139            case 0x2b: /* fstp sti */
     
    61446141            case 0x3a: /* fstp8 sti, undocumented op */
    61456142            case 0x3b: /* fstp9 sti, undocumented op */
    6146                 tcg_gen_helper_0_1(helper_fmov_STN_ST0, tcg_const_i32(opreg));
    6147                 tcg_gen_helper_0_0(helper_fpop);
     6143                gen_helper_fmov_STN_ST0(tcg_const_i32(opreg));
     6144                gen_helper_fpop();
    61486145                break;
    61496146            case 0x2c: /* fucom st(i) */
    6150                 tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(opreg));
    6151                 tcg_gen_helper_0_0(helper_fucom_ST0_FT0);
     6147                gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
     6148                gen_helper_fucom_ST0_FT0();
    61526149                break;
    61536150            case 0x2d: /* fucomp st(i) */
    6154                 tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(opreg));
    6155                 tcg_gen_helper_0_0(helper_fucom_ST0_FT0);
    6156                 tcg_gen_helper_0_0(helper_fpop);
     6151                gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
     6152                gen_helper_fucom_ST0_FT0();
     6153                gen_helper_fpop();
    61576154                break;
    61586155            case 0x33: /* de/3 */
    61596156                switch(rm) {
    61606157                case 1: /* fcompp */
    6161                     tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(1));
    6162                     tcg_gen_helper_0_0(helper_fcom_ST0_FT0);
    6163                     tcg_gen_helper_0_0(helper_fpop);
    6164                     tcg_gen_helper_0_0(helper_fpop);
     6158                    gen_helper_fmov_FT0_STN(tcg_const_i32(1));
     6159                    gen_helper_fcom_ST0_FT0();
     6160                    gen_helper_fpop();
     6161                    gen_helper_fpop();
    61656162                    break;
    61666163                default:
     
    61696166                break;
    61706167            case 0x38: /* ffreep sti, undocumented op */
    6171                 tcg_gen_helper_0_1(helper_ffree_STN, tcg_const_i32(opreg));
    6172                 tcg_gen_helper_0_0(helper_fpop);
     6168                gen_helper_ffree_STN(tcg_const_i32(opreg));
     6169                gen_helper_fpop();
    61736170                break;
    61746171            case 0x3c: /* df/4 */
    61756172                switch(rm) {
    61766173                case 0:
    6177                     tcg_gen_helper_1_0(helper_fnstsw, cpu_tmp2_i32);
     6174                    gen_helper_fnstsw(cpu_tmp2_i32);
    61786175                    tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32);
    61796176                    gen_op_mov_reg_T0(OT_WORD, R_EAX);
     
    61866183                if (s->cc_op != CC_OP_DYNAMIC)
    61876184                    gen_op_set_cc_op(s->cc_op);
    6188                 tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(opreg));
    6189                 tcg_gen_helper_0_0(helper_fucomi_ST0_FT0);
    6190                 tcg_gen_helper_0_0(helper_fpop);
     6185                gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
     6186                gen_helper_fucomi_ST0_FT0();
     6187                gen_helper_fpop();
    61916188                s->cc_op = CC_OP_EFLAGS;
    61926189                break;
     
    61946191                if (s->cc_op != CC_OP_DYNAMIC)
    61956192                    gen_op_set_cc_op(s->cc_op);
    6196                 tcg_gen_helper_0_1(helper_fmov_FT0_STN, tcg_const_i32(opreg));
    6197                 tcg_gen_helper_0_0(helper_fcomi_ST0_FT0);
    6198                 tcg_gen_helper_0_0(helper_fpop);
     6193                gen_helper_fmov_FT0_STN(tcg_const_i32(opreg));
     6194                gen_helper_fcomi_ST0_FT0();
     6195                gen_helper_fpop();
    61996196                s->cc_op = CC_OP_EFLAGS;
    62006197                break;
     
    62126209                    l1 = gen_new_label();
    62136210                    gen_jcc1(s, s->cc_op, op1, l1);
    6214                     tcg_gen_helper_0_1(helper_fmov_ST0_STN, tcg_const_i32(opreg));
     6211                    gen_helper_fmov_ST0_STN(tcg_const_i32(opreg));
    62156212                    gen_set_label(l1);
    62166213                }
     
    63496346            gen_io_start();
    63506347        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    6351         tcg_gen_helper_1_1(helper_in_func[ot], cpu_T[1], cpu_tmp2_i32);
     6348        gen_helper_in_func(ot, cpu_T[1], cpu_tmp2_i32);
    63526349        gen_op_mov_reg_T1(ot, R_EAX);
    63536350        if (use_icount) {
     
    63666363        gen_check_io(s, ot, pc_start - s->cs_base,
    63676364                     svm_is_rep(prefixes));
    6368 #ifdef VBOX /* bird: linux is writing to this port for delaying I/O. */ /** @todo this breaks AIX, remove. */
     6365#ifdef VBOX /* bird: linux is writing to this port for delaying I/O. */ /** @todo YYY: this breaks AIX, remove. */
    63696366        if (val == 0x80)
    63706367            break;
     
    63776374        tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
    63786375        tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
    6379         tcg_gen_helper_0_2(helper_out_func[ot], cpu_tmp2_i32, cpu_tmp3_i32);
     6376        gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
    63806377        if (use_icount) {
    63816378            gen_io_end();
     
    63966393            gen_io_start();
    63976394        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    6398         tcg_gen_helper_1_1(helper_in_func[ot], cpu_T[1], cpu_tmp2_i32);
     6395        gen_helper_in_func(ot, cpu_T[1], cpu_tmp2_i32);
    63996396        gen_op_mov_reg_T1(ot, R_EAX);
    64006397        if (use_icount) {
     
    64206417        tcg_gen_andi_i32(cpu_tmp2_i32, cpu_tmp2_i32, 0xffff);
    64216418        tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T[1]);
    6422         tcg_gen_helper_0_2(helper_out_func[ot], cpu_tmp2_i32, cpu_tmp3_i32);
     6419        gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32);
    64236420        if (use_icount) {
    64246421            gen_io_end();
     
    64576454                gen_op_set_cc_op(s->cc_op);
    64586455            gen_jmp_im(pc_start - s->cs_base);
    6459             tcg_gen_helper_0_2(helper_lret_protected,
    6460                                tcg_const_i32(s->dflag),
    6461                                tcg_const_i32(val));
     6456            gen_helper_lret_protected(tcg_const_i32(s->dflag),
     6457                                      tcg_const_i32(val));
    64626458        } else {
    64636459            gen_stack_A0(s);
     
    64856481        if (!s->pe) {
    64866482            /* real mode */
    6487             tcg_gen_helper_0_1(helper_iret_real, tcg_const_i32(s->dflag));
     6483            gen_helper_iret_real(tcg_const_i32(s->dflag));
    64886484            s->cc_op = CC_OP_EFLAGS;
    64896485        } else if (s->vm86) {
     
    64956491                gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
    64966492            } else {
    6497                 tcg_gen_helper_0_1(helper_iret_real, tcg_const_i32(s->dflag));
     6493                gen_helper_iret_real(tcg_const_i32(s->dflag));
    64986494                s->cc_op = CC_OP_EFLAGS;
    64996495            }
     
    65026498                gen_op_set_cc_op(s->cc_op);
    65036499            gen_jmp_im(pc_start - s->cs_base);
    6504             tcg_gen_helper_0_2(helper_iret_protected,
    6505                                tcg_const_i32(s->dflag),
    6506                                tcg_const_i32(s->pc - s->cs_base));
     6500            gen_helper_iret_protected(tcg_const_i32(s->dflag),
     6501                                      tcg_const_i32(s->pc - s->cs_base));
    65076502            s->cc_op = CC_OP_EFLAGS;
    65086503        }
     
    65196514            if (s->dflag == 0)
    65206515                tval &= 0xffff;
     6516#ifdef VBOX /* upstream fix */
    65216517            else if (!CODE64(s))
    65226518                tval &= 0xffffffff;
     6519#endif
    65236520            gen_movtl_T0_im(next_eip);
    65246521            gen_push_T0(s);
     
    66046601            reg = ((modrm >> 3) & 7) | rex_r;
    66056602            mod = (modrm >> 6) & 3;
    6606             t0 = tcg_temp_local_new(TCG_TYPE_TL);
     6603            t0 = tcg_temp_local_new();
    66076604            if (mod != 3) {
    66086605                gen_lea_modrm(s, modrm, &reg_addr, &offset_addr);
     
    66486645#ifdef VBOX
    66496646            if (s->vm86 && s->vme && s->iopl != 3)
    6650                 tcg_gen_helper_1_0(helper_read_eflags_vme, cpu_T[0]);
     6647                gen_helper_read_eflags_vme(cpu_T[0]);
    66516648            else
    66526649#endif
    6653                 tcg_gen_helper_1_0(helper_read_eflags, cpu_T[0]);
     6650            gen_helper_read_eflags(cpu_T[0]);
    66546651            gen_push_T0(s);
    66556652        }
     
    66676664            if (s->cpl == 0) {
    66686665                if (s->dflag) {
    6669                     tcg_gen_helper_0_2(helper_write_eflags, cpu_T[0],
     6666                    gen_helper_write_eflags(cpu_T[0],
    66706667                                       tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK)));
    66716668                } else {
    6672                     tcg_gen_helper_0_2(helper_write_eflags, cpu_T[0],
     6669                    gen_helper_write_eflags(cpu_T[0],
    66736670                                       tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK) & 0xffff));
    66746671                }
     
    66766673                if (s->cpl <= s->iopl) {
    66776674                    if (s->dflag) {
    6678                         tcg_gen_helper_0_2(helper_write_eflags, cpu_T[0],
     6675                        gen_helper_write_eflags(cpu_T[0],
    66796676                                           tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK)));
    66806677                    } else {
    6681                         tcg_gen_helper_0_2(helper_write_eflags, cpu_T[0],
     6678                        gen_helper_write_eflags(cpu_T[0],
    66826679                                           tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK) & 0xffff));
    66836680                    }
    66846681                } else {
    66856682                    if (s->dflag) {
    6686                         tcg_gen_helper_0_2(helper_write_eflags, cpu_T[0],
     6683                        gen_helper_write_eflags(cpu_T[0],
    66876684                                           tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK)));
    66886685                    } else {
    66896686#ifdef VBOX
    66906687                        if (s->vm86 && s->vme)
    6691                             tcg_gen_helper_0_1(helper_write_eflags_vme, cpu_T[0]);
     6688                            gen_helper_write_eflags_vme(cpu_T[0]);
    66926689                        else
    66936690#endif
    6694                             tcg_gen_helper_0_2(helper_write_eflags, cpu_T[0],
     6691                            gen_helper_write_eflags(cpu_T[0],
    66956692                                               tcg_const_i32((TF_MASK | AC_MASK | ID_MASK | NT_MASK) & 0xffff));
    66966693                    }
     
    68586855            label1 = gen_new_label();
    68596856            tcg_gen_movi_tl(cpu_cc_dst, 0);
    6860             t0 = tcg_temp_local_new(TCG_TYPE_TL);
     6857            t0 = tcg_temp_local_new();
    68616858            tcg_gen_mov_tl(t0, cpu_T[0]);
    68626859            tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, label1);
    68636860            if (b & 1) {
    6864                 tcg_gen_helper_1_1(helper_bsr, cpu_T[0], t0);
     6861                gen_helper_bsr(cpu_T[0], t0);
    68656862            } else {
    6866                 tcg_gen_helper_1_1(helper_bsf, cpu_T[0], t0);
     6863                gen_helper_bsf(cpu_T[0], t0);
    68676864            }
    68686865            gen_op_mov_reg_T0(ot, reg);
     
    68816878        if (s->cc_op != CC_OP_DYNAMIC)
    68826879            gen_op_set_cc_op(s->cc_op);
    6883         tcg_gen_helper_0_0(helper_daa);
     6880        gen_helper_daa();
    68846881        s->cc_op = CC_OP_EFLAGS;
    68856882        break;
     
    68896886        if (s->cc_op != CC_OP_DYNAMIC)
    68906887            gen_op_set_cc_op(s->cc_op);
    6891         tcg_gen_helper_0_0(helper_das);
     6888        gen_helper_das();
    68926889        s->cc_op = CC_OP_EFLAGS;
    68936890        break;
     
    68976894        if (s->cc_op != CC_OP_DYNAMIC)
    68986895            gen_op_set_cc_op(s->cc_op);
    6899         tcg_gen_helper_0_0(helper_aaa);
     6896        gen_helper_aaa();
    69006897        s->cc_op = CC_OP_EFLAGS;
    69016898        break;
     
    69056902        if (s->cc_op != CC_OP_DYNAMIC)
    69066903            gen_op_set_cc_op(s->cc_op);
    6907         tcg_gen_helper_0_0(helper_aas);
     6904        gen_helper_aas();
    69086905        s->cc_op = CC_OP_EFLAGS;
    69096906        break;
     
    69156912            gen_exception(s, EXCP00_DIVZ, pc_start - s->cs_base);
    69166913        } else {
    6917             tcg_gen_helper_0_1(helper_aam, tcg_const_i32(val));
     6914            gen_helper_aam(tcg_const_i32(val));
    69186915            s->cc_op = CC_OP_LOGICB;
    69196916        }
     
    69236920            goto illegal_op;
    69246921        val = ldub_code(s->pc++);
    6925         tcg_gen_helper_0_1(helper_aad, tcg_const_i32(val));
     6922        gen_helper_aad(tcg_const_i32(val));
    69266923        s->cc_op = CC_OP_LOGICB;
    69276924        break;
     
    69456942                gen_op_set_cc_op(s->cc_op);
    69466943            gen_jmp_im(pc_start - s->cs_base);
    6947             tcg_gen_helper_0_0(helper_fwait);
     6944            gen_helper_fwait();
    69486945        }
    69496946        break;
     
    69746971            gen_op_set_cc_op(s->cc_op);
    69756972        gen_jmp_im(pc_start - s->cs_base);
    6976         tcg_gen_helper_0_1(helper_into, tcg_const_i32(s->pc - pc_start));
    6977         break;
     6973        gen_helper_into(tcg_const_i32(s->pc - pc_start));
     6974        break;
     6975#ifdef WANT_ICEBP
    69786976    case 0xf1: /* icebp (undocumented, exits to external debugger) */
    69796977        gen_svm_check_intercept(s, pc_start, SVM_EXIT_ICEBP);
     
    69866984#endif
    69876985        break;
     6986#endif
    69886987    case 0xfa: /* cli */
    69896988        if (!s->vm86) {
    69906989            if (s->cpl <= s->iopl) {
    6991                 tcg_gen_helper_0_0(helper_cli);
     6990                gen_helper_cli();
    69926991            } else {
    69936992                gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
     
    69956994        } else {
    69966995            if (s->iopl == 3) {
    6997                 tcg_gen_helper_0_0(helper_cli);
     6996                gen_helper_cli();
    69986997#ifdef VBOX
    69996998            } else if (s->iopl != 3 && s->vme) {
    7000                 tcg_gen_helper_0_0(helper_cli_vme);
     6999                gen_helper_cli_vme();
    70017000#endif
    70027001            } else {
     
    70097008            if (s->cpl <= s->iopl) {
    70107009            gen_sti:
    7011                 tcg_gen_helper_0_0(helper_sti);
     7010                gen_helper_sti();
    70127011                /* interruptions are enabled only the first insn after sti */
    70137012                /* If several instructions disable interrupts, only the
    70147013                   _first_ does it */
    70157014                if (!(s->tb->flags & HF_INHIBIT_IRQ_MASK))
    7016                     tcg_gen_helper_0_0(helper_set_inhibit_irq);
     7015                    gen_helper_set_inhibit_irq();
    70177016                /* give a chance to handle pending irqs */
    70187017                gen_jmp_im(s->pc - s->cs_base);
     
    70267025#ifdef VBOX
    70277026            } else if (s->iopl != 3 && s->vme) {
    7028                 tcg_gen_helper_0_0(helper_sti_vme);
     7027                gen_helper_sti_vme();
    70297028                /* give a chance to handle pending irqs */
    70307029                gen_jmp_im(s->pc - s->cs_base);
     
    70507049        tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    70517050        if (ot == OT_WORD)
    7052             tcg_gen_helper_0_2(helper_boundw, cpu_A0, cpu_tmp2_i32);
     7051            gen_helper_boundw(cpu_A0, cpu_tmp2_i32);
    70537052        else
    7054             tcg_gen_helper_0_2(helper_boundl, cpu_A0, cpu_tmp2_i32);
     7053            gen_helper_boundl(cpu_A0, cpu_tmp2_i32);
    70557054        break;
    70567055    case 0x1c8 ... 0x1cf: /* bswap reg */
     
    70637062        } else
    70647063        {
    7065             TCGv tmp0;
     7064            TCGv_i32 tmp0;
    70667065            gen_op_mov_TN_reg(OT_LONG, 0, reg);
    70677066
    7068             tmp0 = tcg_temp_new(TCG_TYPE_I32);
     7067            tmp0 = tcg_temp_new_i32();
    70697068            tcg_gen_trunc_i64_i32(tmp0, cpu_T[0]);
    70707069            tcg_gen_bswap_i32(tmp0, tmp0);
     
    71507149            gen_jmp_im(pc_start - s->cs_base);
    71517150            if (b & 2) {
    7152                 tcg_gen_helper_0_0(helper_rdmsr);
     7151                gen_helper_rdmsr();
    71537152            } else {
    7154                 tcg_gen_helper_0_0(helper_wrmsr);
     7153                gen_helper_wrmsr();
    71557154            }
    71567155        }
     
    71627161        if (use_icount)
    71637162            gen_io_start();
    7164         tcg_gen_helper_0_0(helper_rdtsc);
     7163        gen_helper_rdtsc();
    71657164        if (use_icount) {
    71667165            gen_io_end();
     
    71727171            gen_op_set_cc_op(s->cc_op);
    71737172        gen_jmp_im(pc_start - s->cs_base);
    7174         tcg_gen_helper_0_0(helper_rdpmc);
     7173        gen_helper_rdpmc();
    71757174        break;
    71767175    case 0x134: /* sysenter */
     
    71917190            }
    71927191            gen_jmp_im(pc_start - s->cs_base);
    7193             tcg_gen_helper_0_0(helper_sysenter);
     7192            gen_helper_sysenter();
    71947193            gen_eob(s);
    71957194        }
     
    72127211            }
    72137212            gen_jmp_im(pc_start - s->cs_base);
    7214             tcg_gen_helper_0_1(helper_sysexit, tcg_const_i32(dflag));
     7213            gen_helper_sysexit(tcg_const_i32(dflag));
    72157214            gen_eob(s);
    72167215        }
     
    72247223        }
    72257224        gen_jmp_im(pc_start - s->cs_base);
    7226         tcg_gen_helper_0_1(helper_syscall, tcg_const_i32(s->pc - pc_start));
     7225        gen_helper_syscall(tcg_const_i32(s->pc - pc_start));
    72277226        gen_eob(s);
    72287227        break;
     
    72367235            }
    72377236            gen_jmp_im(pc_start - s->cs_base);
    7238             tcg_gen_helper_0_1(helper_sysret, tcg_const_i32(s->dflag));
     7237            gen_helper_sysret(tcg_const_i32(s->dflag));
    72397238            /* condition codes are modified only in long mode */
    72407239            if (s->lma)
     
    72487247            gen_op_set_cc_op(s->cc_op);
    72497248        gen_jmp_im(pc_start - s->cs_base);
    7250         tcg_gen_helper_0_0(helper_cpuid);
     7249        gen_helper_cpuid();
    72517250        break;
    72527251    case 0xf4: /* hlt */
     
    72577256                gen_op_set_cc_op(s->cc_op);
    72587257            gen_jmp_im(pc_start - s->cs_base);
    7259             tcg_gen_helper_0_1(helper_hlt, tcg_const_i32(s->pc - pc_start));
     7258            gen_helper_hlt(tcg_const_i32(s->pc - pc_start));
    72607259            s->is_jmp = 3;
    72617260        }
     
    72867285                gen_jmp_im(pc_start - s->cs_base);
    72877286                tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    7288                 tcg_gen_helper_0_1(helper_lldt, cpu_tmp2_i32);
     7287                gen_helper_lldt(cpu_tmp2_i32);
    72897288            }
    72907289            break;
     
    73097308                gen_jmp_im(pc_start - s->cs_base);
    73107309                tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]);
    7311                 tcg_gen_helper_0_1(helper_ltr, cpu_tmp2_i32);
     7310                gen_helper_ltr(cpu_tmp2_i32);
    73127311            }
    73137312            break;
     
    73207319                gen_op_set_cc_op(s->cc_op);
    73217320            if (op == 4)
    7322                 tcg_gen_helper_0_1(helper_verr, cpu_T[0]);
     7321                gen_helper_verr(cpu_T[0]);
    73237322            else
    7324                 tcg_gen_helper_0_1(helper_verw, cpu_T[0]);
     7323                gen_helper_verw(cpu_T[0]);
    73257324            s->cc_op = CC_OP_EFLAGS;
    73267325            break;
     
    73417340                goto illegal_op;
    73427341            gen_jmp_im(pc_start - s->cs_base);
    7343             tcg_gen_helper_0_0(helper_rdtscp);
     7342            gen_helper_rdtscp();
    73447343            break;
    73457344        }
     
    73807379                    }
    73817380                    gen_add_A0_ds_seg(s);
    7382                     tcg_gen_helper_0_1(helper_monitor, cpu_A0);
     7381                    gen_helper_monitor(cpu_A0);
    73837382                    break;
    73847383                case 1: /* mwait */
     
    73917390                    }
    73927391                    gen_jmp_im(pc_start - s->cs_base);
    7393                     tcg_gen_helper_0_1(helper_mwait, tcg_const_i32(s->pc - pc_start));
     7392                    gen_helper_mwait(tcg_const_i32(s->pc - pc_start));
    73947393                    gen_eob(s);
    73957394                    break;
     
    74237422                        break;
    74247423                    } else {
    7425                         tcg_gen_helper_0_2(helper_vmrun,
    7426                                            tcg_const_i32(s->aflag),
    7427                                            tcg_const_i32(s->pc - pc_start));
     7424                        gen_helper_vmrun(tcg_const_i32(s->aflag),
     7425                                         tcg_const_i32(s->pc - pc_start));
    74287426                        tcg_gen_exit_tb(0);
    74297427                        s->is_jmp = 3;
     
    74337431                    if (!(s->flags & HF_SVME_MASK))
    74347432                        goto illegal_op;
    7435                     tcg_gen_helper_0_0(helper_vmmcall);
     7433                    gen_helper_vmmcall();
    74367434                    break;
    74377435                case 2: /* VMLOAD */
     
    74427440                        break;
    74437441                    } else {
    7444                         tcg_gen_helper_0_1(helper_vmload,
    7445                                            tcg_const_i32(s->aflag));
     7442                        gen_helper_vmload(tcg_const_i32(s->aflag));
    74467443                    }
    74477444                    break;
     
    74537450                        break;
    74547451                    } else {
    7455                         tcg_gen_helper_0_1(helper_vmsave,
    7456                                            tcg_const_i32(s->aflag));
     7452                        gen_helper_vmsave(tcg_const_i32(s->aflag));
    74577453                    }
    74587454                    break;
     
    74667462                        break;
    74677463                    } else {
    7468                         tcg_gen_helper_0_0(helper_stgi);
     7464                        gen_helper_stgi();
    74697465                    }
    74707466                    break;
     
    74767472                        break;
    74777473                    } else {
    7478                         tcg_gen_helper_0_0(helper_clgi);
     7474                        gen_helper_clgi();
    74797475                    }
    74807476                    break;
     
    74847480                        !s->pe)
    74857481                        goto illegal_op;
    7486                     tcg_gen_helper_0_0(helper_skinit);
     7482                    gen_helper_skinit();
    74877483                    break;
    74887484                case 7: /* INVLPGA */
     
    74937489                        break;
    74947490                    } else {
    7495                         tcg_gen_helper_0_1(helper_invlpga,
    7496                                            tcg_const_i32(s->aflag));
     7491                        gen_helper_invlpga(tcg_const_i32(s->aflag));
    74977492                    }
    74987493                    break;
     
    75227517        case 4: /* smsw */
    75237518            gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_CR0);
     7519#if defined TARGET_X86_64 && defined WORDS_BIGENDIAN
     7520            tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,cr[0]) + 4);
     7521#else
    75247522            tcg_gen_ld32u_tl(cpu_T[0], cpu_env, offsetof(CPUX86State,cr[0]));
     7523#endif
    75257524            gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 1);
    75267525            break;
     
    75317530                gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
    75327531                gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
    7533                 tcg_gen_helper_0_1(helper_lmsw, cpu_T[0]);
     7532                gen_helper_lmsw(cpu_T[0]);
    75347533                gen_jmp_im(s->pc - s->cs_base);
    75357534                gen_eob(s);
     
    75587557                    gen_jmp_im(pc_start - s->cs_base);
    75597558                    gen_lea_modrm(s, modrm, &reg_addr, &offset_addr);
    7560                     tcg_gen_helper_0_1(helper_invlpg, cpu_A0);
     7559                    gen_helper_invlpg(cpu_A0);
    75617560                    gen_jmp_im(s->pc - s->cs_base);
    75627561                    gen_eob(s);
     
    76157614            if (!s->pe || s->vm86)
    76167615                goto illegal_op;
    7617             t0 = tcg_temp_local_new(TCG_TYPE_TL);
    7618             t1 = tcg_temp_local_new(TCG_TYPE_TL);
    7619             t2 = tcg_temp_local_new(TCG_TYPE_TL);
     7616            t0 = tcg_temp_local_new();
     7617            t1 = tcg_temp_local_new();
     7618            t2 = tcg_temp_local_new();
    76207619#ifdef VBOX
    7621             a0 = tcg_temp_local_new(TCG_TYPE_TL);
     7620            a0 = tcg_temp_local_new();
    76227621#endif
    76237622            ot = OT_WORD;
     
    76807679            reg = ((modrm >> 3) & 7) | rex_r;
    76817680            gen_ldst_modrm(s, modrm, OT_WORD, OR_TMP0, 0);
    7682             t0 = tcg_temp_local_new(TCG_TYPE_TL);
     7681            t0 = tcg_temp_local_new();
    76837682            if (s->cc_op != CC_OP_DYNAMIC)
    76847683                gen_op_set_cc_op(s->cc_op);
    76857684            if (b == 0x102)
    7686                 tcg_gen_helper_1_1(helper_lar, t0, cpu_T[0]);
     7685                gen_helper_lar(t0, cpu_T[0]);
    76877686            else
    7688                 tcg_gen_helper_1_1(helper_lsl, t0, cpu_T[0]);
     7687                gen_helper_lsl(t0, cpu_T[0]);
    76897688            tcg_gen_andi_tl(cpu_tmp0, cpu_cc_src, CC_Z);
    76907689            label1 = gen_new_label();
     
    77467745                if (b & 2) {
    77477746                    gen_op_mov_TN_reg(ot, 0, rm);
    7748                     tcg_gen_helper_0_2(helper_write_crN,
    7749                                        tcg_const_i32(reg), cpu_T[0]);
     7747                    gen_helper_write_crN(tcg_const_i32(reg), cpu_T[0]);
    77507748                    gen_jmp_im(s->pc - s->cs_base);
    77517749                    gen_eob(s);
    77527750                } else {
    7753                     tcg_gen_helper_1_1(helper_read_crN,
    7754                                        cpu_T[0], tcg_const_i32(reg));
     7751                    gen_helper_read_crN(cpu_T[0], tcg_const_i32(reg));
    77557752                    gen_op_mov_reg_T0(ot, rm);
    77567753                }
     
    77837780                gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_DR0 + reg);
    77847781                gen_op_mov_TN_reg(ot, 0, rm);
    7785                 tcg_gen_helper_0_2(helper_movl_drN_T0,
    7786                                    tcg_const_i32(reg), cpu_T[0]);
     7782                gen_helper_movl_drN_T0(tcg_const_i32(reg), cpu_T[0]);
    77877783                gen_jmp_im(s->pc - s->cs_base);
    77887784                gen_eob(s);
     
    77997795        } else {
    78007796            gen_svm_check_intercept(s, pc_start, SVM_EXIT_WRITE_CR0);
    7801             tcg_gen_helper_0_0(helper_clts);
     7797            gen_helper_clts();
    78027798            /* abort block because static cpu state changed */
    78037799            gen_jmp_im(s->pc - s->cs_base);
     
    78357831                gen_op_set_cc_op(s->cc_op);
    78367832            gen_jmp_im(pc_start - s->cs_base);
    7837             tcg_gen_helper_0_2(helper_fxsave,
    7838                                cpu_A0, tcg_const_i32((s->dflag == 2)));
     7833            gen_helper_fxsave(cpu_A0, tcg_const_i32((s->dflag == 2)));
    78397834            break;
    78407835        case 1: /* fxrstor */
     
    78507845                gen_op_set_cc_op(s->cc_op);
    78517846            gen_jmp_im(pc_start - s->cs_base);
    7852             tcg_gen_helper_0_2(helper_fxrstor,
    7853                                cpu_A0, tcg_const_i32((s->dflag == 2)));
     7847            gen_helper_fxrstor(cpu_A0, tcg_const_i32((s->dflag == 2)));
    78547848            break;
    78557849        case 2: /* ldmxcsr */
     
    79107904        }
    79117905        gen_jmp_im(s->pc - s->cs_base);
    7912         tcg_gen_helper_0_0(helper_rsm);
     7906        gen_helper_rsm();
    79137907        gen_eob(s);
    79147908        break;
     
    79317925
    79327926        gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
    7933         tcg_gen_helper_1_2(helper_popcnt,
    7934                 cpu_T[0], cpu_T[0], tcg_const_i32(ot));
     7927        gen_helper_popcnt(cpu_T[0], cpu_T[0], tcg_const_i32(ot));
    79357928        gen_op_mov_reg_T0(ot, reg);
    79367929
     
    79557948    /* lock generation */
    79567949    if (s->prefix & PREFIX_LOCK)
    7957         tcg_gen_helper_0_0(helper_unlock);
     7950        gen_helper_unlock();
    79587951    return s->pc;
    79597952 illegal_op:
    79607953    if (s->prefix & PREFIX_LOCK)
    7961         tcg_gen_helper_0_0(helper_unlock);
     7954        gen_helper_unlock();
    79627955    /* XXX: ensure that no lock was generated */
    79637956    gen_exception(s, EXCP06_ILLOP, pc_start - s->cs_base);
     
    79727965    assert(sizeof(CCTable) == (1 << 4));
    79737966#endif
    7974     cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
    7975     cpu_cc_op = tcg_global_mem_new(TCG_TYPE_I32,
    7976                                    TCG_AREG0, offsetof(CPUState, cc_op), "cc_op");
    7977     cpu_cc_src = tcg_global_mem_new(TCG_TYPE_TL,
    7978                                     TCG_AREG0, offsetof(CPUState, cc_src), "cc_src");
    7979     cpu_cc_dst = tcg_global_mem_new(TCG_TYPE_TL,
    7980                                     TCG_AREG0, offsetof(CPUState, cc_dst), "cc_dst");
    7981     cpu_cc_tmp = tcg_global_mem_new(TCG_TYPE_TL,
    7982                                     TCG_AREG0, offsetof(CPUState, cc_tmp), "cc_tmp");
     7967    cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
     7968    cpu_cc_op = tcg_global_mem_new_i32(TCG_AREG0,
     7969                                       offsetof(CPUState, cc_op), "cc_op");
     7970    cpu_cc_src = tcg_global_mem_new(TCG_AREG0, offsetof(CPUState, cc_src),
     7971                                    "cc_src");
     7972    cpu_cc_dst = tcg_global_mem_new(TCG_AREG0, offsetof(CPUState, cc_dst),
     7973                                    "cc_dst");
     7974    cpu_cc_tmp = tcg_global_mem_new(TCG_AREG0, offsetof(CPUState, cc_tmp),
     7975                                    "cc_tmp");
    79837976
    79847977    /* register helpers */
    7985 
    7986 #define DEF_HELPER(ret, name, params) tcg_register_helper(name, #name);
     7978#define GEN_HELPER 2
    79877979#include "helper.h"
    79887980}
     
    79987990    target_ulong pc_ptr;
    79997991    uint16_t *gen_opc_end;
     7992    CPUBreakpoint *bp;
    80007993    int j, lj, cflags;
    80017994    uint64_t flags;
     
    80298022        dc->record_call = 0;
    80308023# endif
    8031 #endif
     8024#endif /* VBOX */
    80328025    dc->cpl = (flags >> HF_CPL_SHIFT) & 3;
    80338026    dc->iopl = (flags >> IOPL_SHIFT) & 3;
     
    80678060#endif
    80688061
    8069     cpu_T[0] = tcg_temp_new(TCG_TYPE_TL);
    8070     cpu_T[1] = tcg_temp_new(TCG_TYPE_TL);
    8071     cpu_A0 = tcg_temp_new(TCG_TYPE_TL);
    8072     cpu_T3 = tcg_temp_new(TCG_TYPE_TL);
    8073 
    8074     cpu_tmp0 = tcg_temp_new(TCG_TYPE_TL);
    8075     cpu_tmp1_i64 = tcg_temp_new(TCG_TYPE_I64);
    8076     cpu_tmp2_i32 = tcg_temp_new(TCG_TYPE_I32);
    8077     cpu_tmp3_i32 = tcg_temp_new(TCG_TYPE_I32);
    8078     cpu_tmp4 = tcg_temp_new(TCG_TYPE_TL);
    8079     cpu_tmp5 = tcg_temp_new(TCG_TYPE_TL);
    8080     cpu_tmp6 = tcg_temp_new(TCG_TYPE_TL);
    8081     cpu_ptr0 = tcg_temp_new(TCG_TYPE_PTR);
    8082     cpu_ptr1 = tcg_temp_new(TCG_TYPE_PTR);
     8062    cpu_T[0] = tcg_temp_new();
     8063    cpu_T[1] = tcg_temp_new();
     8064    cpu_A0 = tcg_temp_new();
     8065    cpu_T3 = tcg_temp_new();
     8066
     8067    cpu_tmp0 = tcg_temp_new();
     8068    cpu_tmp1_i64 = tcg_temp_new_i64();
     8069    cpu_tmp2_i32 = tcg_temp_new_i32();
     8070    cpu_tmp3_i32 = tcg_temp_new_i32();
     8071    cpu_tmp4 = tcg_temp_new();
     8072    cpu_tmp5 = tcg_temp_new();
     8073    cpu_tmp6 = tcg_temp_new();
     8074    cpu_ptr0 = tcg_temp_new_ptr();
     8075    cpu_ptr1 = tcg_temp_new_ptr();
    80838076
    80848077    gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
     
    80948087    gen_icount_start();
    80958088    for(;;) {
    8096         if (env->nb_breakpoints > 0) {
    8097             for(j = 0; j < env->nb_breakpoints; j++) {
    8098                 if (env->breakpoints[j] == pc_ptr) {
     8089        if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
     8090            TAILQ_FOREACH(bp, &env->breakpoints, entry) {
     8091                if (bp->pc == pc_ptr) {
    80998092                    gen_debug(dc, pc_ptr - dc->cs_base);
    81008093                    break;
     
    81748167
    81758168#ifdef DEBUG_DISAS
    8176     if (loglevel & CPU_LOG_TB_CPU) {
    8177         cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
    8178     }
    8179     if (loglevel & CPU_LOG_TB_IN_ASM) {
     8169    log_cpu_state_mask(CPU_LOG_TB_CPU, env, X86_DUMP_CCOP);
     8170    if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
    81808171        int disas_flags;
    8181         fprintf(logfile, "----------------\n");
    8182         fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
     8172        qemu_log("----------------\n");
     8173        qemu_log("IN: %s\n", lookup_symbol(pc_start));
    81838174#ifdef TARGET_X86_64
    81848175        if (dc->code64)
     
    81878178#endif
    81888179            disas_flags = !dc->code32;
    8189         target_disas(logfile, pc_start, pc_ptr - pc_start, disas_flags);
    8190         fprintf(logfile, "\n");
     8180        log_target_disas(pc_start, pc_ptr - pc_start, disas_flags);
     8181        qemu_log("\n");
    81918182    }
    81928183#endif
     
    82138204    int cc_op;
    82148205#ifdef DEBUG_DISAS
    8215     if (loglevel & CPU_LOG_TB_OP) {
     8206    if (qemu_loglevel_mask(CPU_LOG_TB_OP)) {
    82168207        int i;
    8217         fprintf(logfile, "RESTORE:\n");
     8208        qemu_log("RESTORE:\n");
    82188209        for(i = 0;i <= pc_pos; i++) {
    82198210            if (gen_opc_instr_start[i]) {
    8220                 fprintf(logfile, "0x%04x: " TARGET_FMT_lx "\n", i, gen_opc_pc[i]);
    8221             }
    8222         }
    8223         fprintf(logfile, "spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx " cs_base=%x\n",
     8211                qemu_log("0x%04x: " TARGET_FMT_lx "\n", i, gen_opc_pc[i]);
     8212            }
     8213        }
     8214        qemu_log("spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx " cs_base=%x\n",
    82248215                searched_pc, pc_pos, gen_opc_pc[pc_pos] - tb->cs_base,
    82258216                (uint32_t)tb->cs_base);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette