peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0029-target-m68k-avoid-using-cpu_single_env.patch

5544c1
From 5560cd783146734a60c446f43227044cbb580edd Mon Sep 17 00:00:00 2001
5544c1
From: Blue Swirl <blauwirbel@gmail.com>
5544c1
Date: Sat, 8 Sep 2012 10:48:20 +0000
5544c1
Subject: [PATCH] target-m68k: avoid using cpu_single_env
5544c1
5544c1
Pass around CPUState instead of using global cpu_single_env.
5544c1
5544c1
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 target-m68k/translate.c | 270 +++++++++++++++++++++++++-----------------------
5544c1
 1 file changed, 140 insertions(+), 130 deletions(-)
5544c1
5544c1
diff --git a/target-m68k/translate.c b/target-m68k/translate.c
5544c1
index 10bb303..fb707f2 100644
5544c1
--- a/target-m68k/translate.c
5544c1
+++ b/target-m68k/translate.c
5544c1
@@ -150,18 +150,24 @@ static void *gen_throws_exception;
5544c1
 #define OS_SINGLE 4
5544c1
 #define OS_DOUBLE 5
5544c1
 
5544c1
-typedef void (*disas_proc)(DisasContext *, uint16_t);
5544c1
+typedef void (*disas_proc)(CPUM68KState *env, DisasContext *s, uint16_t insn);
5544c1
 
5544c1
 #ifdef DEBUG_DISPATCH
5544c1
-#define DISAS_INSN(name) \
5544c1
-  static void real_disas_##name (DisasContext *s, uint16_t insn); \
5544c1
-  static void disas_##name (DisasContext *s, uint16_t insn) { \
5544c1
-    qemu_log("Dispatch " #name "\n"); \
5544c1
-    real_disas_##name(s, insn); } \
5544c1
-  static void real_disas_##name (DisasContext *s, uint16_t insn)
5544c1
+#define DISAS_INSN(name)                                                \
5544c1
+    static void real_disas_##name(CPUM68KState *env, DisasContext *s,   \
5544c1
+                                  uint16_t insn);                       \
5544c1
+    static void disas_##name(CPUM68KState *env, DisasContext *s,        \
5544c1
+                             uint16_t insn)                             \
5544c1
+    {                                                                   \
5544c1
+        qemu_log("Dispatch " #name "\n");                               \
5544c1
+        real_disas_##name(s, env, insn);                                \
5544c1
+    }                                                                   \
5544c1
+    static void real_disas_##name(CPUM68KState *env, DisasContext *s,   \
5544c1
+                                  uint16_t insn)
5544c1
 #else
5544c1
-#define DISAS_INSN(name) \
5544c1
-  static void disas_##name (DisasContext *s, uint16_t insn)
5544c1
+#define DISAS_INSN(name)                                                \
5544c1
+    static void disas_##name(CPUM68KState *env, DisasContext *s,        \
5544c1
+                             uint16_t insn)
5544c1
 #endif
5544c1
 
5544c1
 /* Generate a load from the specified address.  Narrow values are
5544c1
@@ -257,12 +263,12 @@ static TCGv gen_ldst(DisasContext *s, int opsize, TCGv addr, TCGv val,
5544c1
 }
5544c1
 
5544c1
 /* Read a 32-bit immediate constant.  */
5544c1
-static inline uint32_t read_im32(DisasContext *s)
5544c1
+static inline uint32_t read_im32(CPUM68KState *env, DisasContext *s)
5544c1
 {
5544c1
     uint32_t im;
5544c1
-    im = ((uint32_t)cpu_lduw_code(cpu_single_env, s->pc)) << 16;
5544c1
+    im = ((uint32_t)cpu_lduw_code(env, s->pc)) << 16;
5544c1
     s->pc += 2;
5544c1
-    im |= cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    im |= cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
     return im;
5544c1
 }
5544c1
@@ -288,7 +294,8 @@ static TCGv gen_addr_index(uint16_t ext, TCGv tmp)
5544c1
 
5544c1
 /* Handle a base + index + displacement effective addresss.
5544c1
    A NULL_QREG base means pc-relative.  */
5544c1
-static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base)
5544c1
+static TCGv gen_lea_indexed(CPUM68KState *env, DisasContext *s, int opsize,
5544c1
+                            TCGv base)
5544c1
 {
5544c1
     uint32_t offset;
5544c1
     uint16_t ext;
5544c1
@@ -297,7 +304,7 @@ static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base)
5544c1
     uint32_t bd, od;
5544c1
 
5544c1
     offset = s->pc;
5544c1
-    ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    ext = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
 
5544c1
     if ((ext & 0x800) == 0 && !m68k_feature(s->env, M68K_FEATURE_WORD_INDEX))
5544c1
@@ -311,10 +318,10 @@ static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base)
5544c1
         if ((ext & 0x30) > 0x10) {
5544c1
             /* base displacement */
5544c1
             if ((ext & 0x30) == 0x20) {
5544c1
-                bd = (int16_t)cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+                bd = (int16_t)cpu_lduw_code(env, s->pc);
5544c1
                 s->pc += 2;
5544c1
             } else {
5544c1
-                bd = read_im32(s);
5544c1
+                bd = read_im32(env, s);
5544c1
             }
5544c1
         } else {
5544c1
             bd = 0;
5544c1
@@ -360,10 +367,10 @@ static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base)
5544c1
             if ((ext & 3) > 1) {
5544c1
                 /* outer displacement */
5544c1
                 if ((ext & 3) == 2) {
5544c1
-                    od = (int16_t)cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+                    od = (int16_t)cpu_lduw_code(env, s->pc);
5544c1
                     s->pc += 2;
5544c1
                 } else {
5544c1
-                    od = read_im32(s);
5544c1
+                    od = read_im32(env, s);
5544c1
                 }
5544c1
             } else {
5544c1
                 od = 0;
5544c1
@@ -492,7 +499,8 @@ static inline TCGv gen_extend(TCGv val, int opsize, int sign)
5544c1
 
5544c1
 /* Generate code for an "effective address".  Does not adjust the base
5544c1
    register for autoincrement addressing modes.  */
5544c1
-static TCGv gen_lea(DisasContext *s, uint16_t insn, int opsize)
5544c1
+static TCGv gen_lea(CPUM68KState *env, DisasContext *s, uint16_t insn,
5544c1
+                    int opsize)
5544c1
 {
5544c1
     TCGv reg;
5544c1
     TCGv tmp;
5544c1
@@ -514,29 +522,29 @@ static TCGv gen_lea(DisasContext *s, uint16_t insn, int opsize)
5544c1
     case 5: /* Indirect displacement.  */
5544c1
         reg = AREG(insn, 0);
5544c1
         tmp = tcg_temp_new();
5544c1
-        ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+        ext = cpu_lduw_code(env, s->pc);
5544c1
         s->pc += 2;
5544c1
         tcg_gen_addi_i32(tmp, reg, (int16_t)ext);
5544c1
         return tmp;
5544c1
     case 6: /* Indirect index + displacement.  */
5544c1
         reg = AREG(insn, 0);
5544c1
-        return gen_lea_indexed(s, opsize, reg);
5544c1
+        return gen_lea_indexed(env, s, opsize, reg);
5544c1
     case 7: /* Other */
5544c1
         switch (insn & 7) {
5544c1
         case 0: /* Absolute short.  */
5544c1
-            offset = cpu_ldsw_code(cpu_single_env, s->pc);
5544c1
+            offset = cpu_ldsw_code(env, s->pc);
5544c1
             s->pc += 2;
5544c1
             return tcg_const_i32(offset);
5544c1
         case 1: /* Absolute long.  */
5544c1
-            offset = read_im32(s);
5544c1
+            offset = read_im32(env, s);
5544c1
             return tcg_const_i32(offset);
5544c1
         case 2: /* pc displacement  */
5544c1
             offset = s->pc;
5544c1
-            offset += cpu_ldsw_code(cpu_single_env, s->pc);
5544c1
+            offset += cpu_ldsw_code(env, s->pc);
5544c1
             s->pc += 2;
5544c1
             return tcg_const_i32(offset);
5544c1
         case 3: /* pc index+displacement.  */
5544c1
-            return gen_lea_indexed(s, opsize, NULL_QREG);
5544c1
+            return gen_lea_indexed(env, s, opsize, NULL_QREG);
5544c1
         case 4: /* Immediate.  */
5544c1
         default:
5544c1
             return NULL_QREG;
5544c1
@@ -548,15 +556,16 @@ static TCGv gen_lea(DisasContext *s, uint16_t insn, int opsize)
5544c1
 
5544c1
 /* Helper function for gen_ea. Reuse the computed address between the
5544c1
    for read/write operands.  */
5544c1
-static inline TCGv gen_ea_once(DisasContext *s, uint16_t insn, int opsize,
5544c1
-                              TCGv val, TCGv *addrp, ea_what what)
5544c1
+static inline TCGv gen_ea_once(CPUM68KState *env, DisasContext *s,
5544c1
+                               uint16_t insn, int opsize, TCGv val,
5544c1
+                               TCGv *addrp, ea_what what)
5544c1
 {
5544c1
     TCGv tmp;
5544c1
 
5544c1
     if (addrp && what == EA_STORE) {
5544c1
         tmp = *addrp;
5544c1
     } else {
5544c1
-        tmp = gen_lea(s, insn, opsize);
5544c1
+        tmp = gen_lea(env, s, insn, opsize);
5544c1
         if (IS_NULL_QREG(tmp))
5544c1
             return tmp;
5544c1
         if (addrp)
5544c1
@@ -568,8 +577,8 @@ static inline TCGv gen_ea_once(DisasContext *s, uint16_t insn, int opsize,
5544c1
 /* Generate code to load/store a value ito/from an EA.  If VAL > 0 this is
5544c1
    a write otherwise it is a read (0 == sign extend, -1 == zero extend).
5544c1
    ADDRP is non-null for readwrite operands.  */
5544c1
-static TCGv gen_ea(DisasContext *s, uint16_t insn, int opsize, TCGv val,
5544c1
-                   TCGv *addrp, ea_what what)
5544c1
+static TCGv gen_ea(CPUM68KState *env, DisasContext *s, uint16_t insn,
5544c1
+                   int opsize, TCGv val, TCGv *addrp, ea_what what)
5544c1
 {
5544c1
     TCGv reg;
5544c1
     TCGv result;
5544c1
@@ -609,7 +618,7 @@ static TCGv gen_ea(DisasContext *s, uint16_t insn, int opsize, TCGv val,
5544c1
             if (addrp && what == EA_STORE) {
5544c1
                 tmp = *addrp;
5544c1
             } else {
5544c1
-                tmp = gen_lea(s, insn, opsize);
5544c1
+                tmp = gen_lea(env, s, insn, opsize);
5544c1
                 if (IS_NULL_QREG(tmp))
5544c1
                     return tmp;
5544c1
                 if (addrp)
5544c1
@@ -626,35 +635,35 @@ static TCGv gen_ea(DisasContext *s, uint16_t insn, int opsize, TCGv val,
5544c1
         return result;
5544c1
     case 5: /* Indirect displacement.  */
5544c1
     case 6: /* Indirect index + displacement.  */
5544c1
-        return gen_ea_once(s, insn, opsize, val, addrp, what);
5544c1
+        return gen_ea_once(env, s, insn, opsize, val, addrp, what);
5544c1
     case 7: /* Other */
5544c1
         switch (insn & 7) {
5544c1
         case 0: /* Absolute short.  */
5544c1
         case 1: /* Absolute long.  */
5544c1
         case 2: /* pc displacement  */
5544c1
         case 3: /* pc index+displacement.  */
5544c1
-            return gen_ea_once(s, insn, opsize, val, addrp, what);
5544c1
+            return gen_ea_once(env, s, insn, opsize, val, addrp, what);
5544c1
         case 4: /* Immediate.  */
5544c1
             /* Sign extend values for consistency.  */
5544c1
             switch (opsize) {
5544c1
             case OS_BYTE:
5544c1
                 if (what == EA_LOADS) {
5544c1
-                    offset = cpu_ldsb_code(cpu_single_env, s->pc + 1);
5544c1
+                    offset = cpu_ldsb_code(env, s->pc + 1);
5544c1
                 } else {
5544c1
-                    offset = cpu_ldub_code(cpu_single_env, s->pc + 1);
5544c1
+                    offset = cpu_ldub_code(env, s->pc + 1);
5544c1
                 }
5544c1
                 s->pc += 2;
5544c1
                 break;
5544c1
             case OS_WORD:
5544c1
                 if (what == EA_LOADS) {
5544c1
-                    offset = cpu_ldsw_code(cpu_single_env, s->pc);
5544c1
+                    offset = cpu_ldsw_code(env, s->pc);
5544c1
                 } else {
5544c1
-                    offset = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+                    offset = cpu_lduw_code(env, s->pc);
5544c1
                 }
5544c1
                 s->pc += 2;
5544c1
                 break;
5544c1
             case OS_LONG:
5544c1
-                offset = read_im32(s);
5544c1
+                offset = read_im32(env, s);
5544c1
                 break;
5544c1
             default:
5544c1
                 qemu_assert(0, "Bad immediate operand");
5544c1
@@ -825,20 +834,21 @@ static inline void gen_addr_fault(DisasContext *s)
5544c1
     gen_exception(s, s->insn_pc, EXCP_ADDRESS);
5544c1
 }
5544c1
 
5544c1
-#define SRC_EA(result, opsize, op_sign, addrp) do { \
5544c1
-    result = gen_ea(s, insn, opsize, NULL_QREG, addrp, op_sign ? EA_LOADS : EA_LOADU); \
5544c1
-    if (IS_NULL_QREG(result)) { \
5544c1
-        gen_addr_fault(s); \
5544c1
-        return; \
5544c1
-    } \
5544c1
+#define SRC_EA(env, result, opsize, op_sign, addrp) do {                \
5544c1
+        result = gen_ea(env, s, insn, opsize, NULL_QREG, addrp,         \
5544c1
+                        op_sign ? EA_LOADS : EA_LOADU);                 \
5544c1
+        if (IS_NULL_QREG(result)) {                                     \
5544c1
+            gen_addr_fault(s);                                          \
5544c1
+            return;                                                     \
5544c1
+        }                                                               \
5544c1
     } while (0)
5544c1
 
5544c1
-#define DEST_EA(insn, opsize, val, addrp) do { \
5544c1
-    TCGv ea_result = gen_ea(s, insn, opsize, val, addrp, EA_STORE); \
5544c1
-    if (IS_NULL_QREG(ea_result)) { \
5544c1
-        gen_addr_fault(s); \
5544c1
-        return; \
5544c1
-    } \
5544c1
+#define DEST_EA(env, insn, opsize, val, addrp) do {                     \
5544c1
+        TCGv ea_result = gen_ea(env, s, insn, opsize, val, addrp, EA_STORE); \
5544c1
+        if (IS_NULL_QREG(ea_result)) {                                  \
5544c1
+            gen_addr_fault(s);                                          \
5544c1
+            return;                                                     \
5544c1
+        }                                                               \
5544c1
     } while (0)
5544c1
 
5544c1
 /* Generate a jump to an immediate address.  */
5544c1
@@ -874,8 +884,7 @@ DISAS_INSN(undef_fpu)
5544c1
 DISAS_INSN(undef)
5544c1
 {
5544c1
     gen_exception(s, s->pc - 2, EXCP_UNSUPPORTED);
5544c1
-    cpu_abort(cpu_single_env, "Illegal instruction: %04x @ %08x",
5544c1
-              insn, s->pc - 2);
5544c1
+    cpu_abort(env, "Illegal instruction: %04x @ %08x", insn, s->pc - 2);
5544c1
 }
5544c1
 
5544c1
 DISAS_INSN(mulw)
5544c1
@@ -892,7 +901,7 @@ DISAS_INSN(mulw)
5544c1
         tcg_gen_ext16s_i32(tmp, reg);
5544c1
     else
5544c1
         tcg_gen_ext16u_i32(tmp, reg);
5544c1
-    SRC_EA(src, OS_WORD, sign, NULL);
5544c1
+    SRC_EA(env, src, OS_WORD, sign, NULL);
5544c1
     tcg_gen_mul_i32(tmp, tmp, src);
5544c1
     tcg_gen_mov_i32(reg, tmp);
5544c1
     /* Unlike m68k, coldfire always clears the overflow bit.  */
5544c1
@@ -913,7 +922,7 @@ DISAS_INSN(divw)
5544c1
     } else {
5544c1
         tcg_gen_ext16u_i32(QREG_DIV1, reg);
5544c1
     }
5544c1
-    SRC_EA(src, OS_WORD, sign, NULL);
5544c1
+    SRC_EA(env, src, OS_WORD, sign, NULL);
5544c1
     tcg_gen_mov_i32(QREG_DIV2, src);
5544c1
     if (sign) {
5544c1
         gen_helper_divs(cpu_env, tcg_const_i32(1));
5544c1
@@ -936,7 +945,7 @@ DISAS_INSN(divl)
5544c1
     TCGv reg;
5544c1
     uint16_t ext;
5544c1
 
5544c1
-    ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    ext = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
     if (ext & 0x87f8) {
5544c1
         gen_exception(s, s->pc - 4, EXCP_UNSUPPORTED);
5544c1
@@ -945,7 +954,7 @@ DISAS_INSN(divl)
5544c1
     num = DREG(ext, 12);
5544c1
     reg = DREG(ext, 0);
5544c1
     tcg_gen_mov_i32(QREG_DIV1, num);
5544c1
-    SRC_EA(den, OS_LONG, 0, NULL);
5544c1
+    SRC_EA(env, den, OS_LONG, 0, NULL);
5544c1
     tcg_gen_mov_i32(QREG_DIV2, den);
5544c1
     if (ext & 0x0800) {
5544c1
         gen_helper_divs(cpu_env, tcg_const_i32(0));
5544c1
@@ -975,11 +984,11 @@ DISAS_INSN(addsub)
5544c1
     reg = DREG(insn, 9);
5544c1
     dest = tcg_temp_new();
5544c1
     if (insn & 0x100) {
5544c1
-        SRC_EA(tmp, OS_LONG, 0, &addr);
5544c1
+        SRC_EA(env, tmp, OS_LONG, 0, &addr);
5544c1
         src = reg;
5544c1
     } else {
5544c1
         tmp = reg;
5544c1
-        SRC_EA(src, OS_LONG, 0, NULL);
5544c1
+        SRC_EA(env, src, OS_LONG, 0, NULL);
5544c1
     }
5544c1
     if (add) {
5544c1
         tcg_gen_add_i32(dest, tmp, src);
5544c1
@@ -992,7 +1001,7 @@ DISAS_INSN(addsub)
5544c1
     }
5544c1
     gen_update_cc_add(dest, src);
5544c1
     if (insn & 0x100) {
5544c1
-        DEST_EA(insn, OS_LONG, dest, &addr);
5544c1
+        DEST_EA(env, insn, OS_LONG, dest, &addr);
5544c1
     } else {
5544c1
         tcg_gen_mov_i32(reg, dest);
5544c1
     }
5544c1
@@ -1022,7 +1031,7 @@ DISAS_INSN(bitop_reg)
5544c1
     else
5544c1
         opsize = OS_LONG;
5544c1
     op = (insn >> 6) & 3;
5544c1
-    SRC_EA(src1, opsize, 0, op ? &addr: NULL);
5544c1
+    SRC_EA(env, src1, opsize, 0, op ? &addr: NULL);
5544c1
     src2 = DREG(insn, 9);
5544c1
     dest = tcg_temp_new();
5544c1
 
5544c1
@@ -1057,7 +1066,7 @@ DISAS_INSN(bitop_reg)
5544c1
         break;
5544c1
     }
5544c1
     if (op)
5544c1
-        DEST_EA(insn, opsize, dest, &addr);
5544c1
+        DEST_EA(env, insn, opsize, dest, &addr);
5544c1
 }
5544c1
 
5544c1
 DISAS_INSN(sats)
5544c1
@@ -1088,9 +1097,9 @@ DISAS_INSN(movem)
5544c1
     TCGv tmp;
5544c1
     int is_load;
5544c1
 
5544c1
-    mask = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    mask = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
-    tmp = gen_lea(s, insn, OS_LONG);
5544c1
+    tmp = gen_lea(env, s, insn, OS_LONG);
5544c1
     if (IS_NULL_QREG(tmp)) {
5544c1
         gen_addr_fault(s);
5544c1
         return;
5544c1
@@ -1132,14 +1141,14 @@ DISAS_INSN(bitop_im)
5544c1
         opsize = OS_LONG;
5544c1
     op = (insn >> 6) & 3;
5544c1
 
5544c1
-    bitnum = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    bitnum = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
     if (bitnum & 0xff00) {
5544c1
-        disas_undef(s, insn);
5544c1
+        disas_undef(env, s, insn);
5544c1
         return;
5544c1
     }
5544c1
 
5544c1
-    SRC_EA(src1, opsize, 0, op ? &addr: NULL);
5544c1
+    SRC_EA(env, src1, opsize, 0, op ? &addr: NULL);
5544c1
 
5544c1
     gen_flush_flags(s);
5544c1
     if (opsize == OS_BYTE)
5544c1
@@ -1174,7 +1183,7 @@ DISAS_INSN(bitop_im)
5544c1
         default: /* btst */
5544c1
             break;
5544c1
         }
5544c1
-        DEST_EA(insn, opsize, tmp, &addr);
5544c1
+        DEST_EA(env, insn, opsize, tmp, &addr);
5544c1
     }
5544c1
 }
5544c1
 
5544c1
@@ -1187,8 +1196,8 @@ DISAS_INSN(arith_im)
5544c1
     TCGv addr;
5544c1
 
5544c1
     op = (insn >> 9) & 7;
5544c1
-    SRC_EA(src1, OS_LONG, 0, (op == 6) ? NULL : &addr);
5544c1
-    im = read_im32(s);
5544c1
+    SRC_EA(env, src1, OS_LONG, 0, (op == 6) ? NULL : &addr);
5544c1
+    im = read_im32(env, s);
5544c1
     dest = tcg_temp_new();
5544c1
     switch (op) {
5544c1
     case 0: /* ori */
5544c1
@@ -1227,7 +1236,7 @@ DISAS_INSN(arith_im)
5544c1
         abort();
5544c1
     }
5544c1
     if (op != 6) {
5544c1
-        DEST_EA(insn, OS_LONG, dest, &addr);
5544c1
+        DEST_EA(env, insn, OS_LONG, dest, &addr);
5544c1
     }
5544c1
 }
5544c1
 
5544c1
@@ -1259,7 +1268,7 @@ DISAS_INSN(move)
5544c1
     default:
5544c1
         abort();
5544c1
     }
5544c1
-    SRC_EA(src, opsize, 1, NULL);
5544c1
+    SRC_EA(env, src, opsize, 1, NULL);
5544c1
     op = (insn >> 6) & 7;
5544c1
     if (op == 1) {
5544c1
         /* movea */
5544c1
@@ -1270,7 +1279,7 @@ DISAS_INSN(move)
5544c1
         /* normal move */
5544c1
         uint16_t dest_ea;
5544c1
         dest_ea = ((insn >> 9) & 7) | (op << 3);
5544c1
-        DEST_EA(dest_ea, opsize, src, NULL);
5544c1
+        DEST_EA(env, dest_ea, opsize, src, NULL);
5544c1
         /* This will be correct because loads sign extend.  */
5544c1
         gen_logic_cc(s, src);
5544c1
     }
5544c1
@@ -1291,7 +1300,7 @@ DISAS_INSN(lea)
5544c1
     TCGv tmp;
5544c1
 
5544c1
     reg = AREG(insn, 9);
5544c1
-    tmp = gen_lea(s, insn, OS_LONG);
5544c1
+    tmp = gen_lea(env, s, insn, OS_LONG);
5544c1
     if (IS_NULL_QREG(tmp)) {
5544c1
         gen_addr_fault(s);
5544c1
         return;
5544c1
@@ -1316,7 +1325,7 @@ DISAS_INSN(clr)
5544c1
     default:
5544c1
         abort();
5544c1
     }
5544c1
-    DEST_EA(insn, opsize, tcg_const_i32(0), NULL);
5544c1
+    DEST_EA(env, insn, opsize, tcg_const_i32(0), NULL);
5544c1
     gen_logic_cc(s, tcg_const_i32(0));
5544c1
 }
5544c1
 
5544c1
@@ -1365,7 +1374,8 @@ static void gen_set_sr_im(DisasContext *s, uint16_t val, int ccr_only)
5544c1
     }
5544c1
 }
5544c1
 
5544c1
-static void gen_set_sr(DisasContext *s, uint16_t insn, int ccr_only)
5544c1
+static void gen_set_sr(CPUM68KState *env, DisasContext *s, uint16_t insn,
5544c1
+                       int ccr_only)
5544c1
 {
5544c1
     TCGv tmp;
5544c1
     TCGv reg;
5544c1
@@ -1385,17 +1395,17 @@ static void gen_set_sr(DisasContext *s, uint16_t insn, int ccr_only)
5544c1
     else if ((insn & 0x3f) == 0x3c)
5544c1
       {
5544c1
         uint16_t val;
5544c1
-        val = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+        val = cpu_lduw_code(env, s->pc);
5544c1
         s->pc += 2;
5544c1
         gen_set_sr_im(s, val, ccr_only);
5544c1
       }
5544c1
     else
5544c1
-        disas_undef(s, insn);
5544c1
+        disas_undef(env, s, insn);
5544c1
 }
5544c1
 
5544c1
 DISAS_INSN(move_to_ccr)
5544c1
 {
5544c1
-    gen_set_sr(s, insn, 1);
5544c1
+    gen_set_sr(env, s, insn, 1);
5544c1
 }
5544c1
 
5544c1
 DISAS_INSN(not)
5544c1
@@ -1426,7 +1436,7 @@ DISAS_INSN(pea)
5544c1
 {
5544c1
     TCGv tmp;
5544c1
 
5544c1
-    tmp = gen_lea(s, insn, OS_LONG);
5544c1
+    tmp = gen_lea(env, s, insn, OS_LONG);
5544c1
     if (IS_NULL_QREG(tmp)) {
5544c1
         gen_addr_fault(s);
5544c1
         return;
5544c1
@@ -1472,7 +1482,7 @@ DISAS_INSN(tst)
5544c1
     default:
5544c1
         abort();
5544c1
     }
5544c1
-    SRC_EA(tmp, opsize, 1, NULL);
5544c1
+    SRC_EA(env, tmp, opsize, 1, NULL);
5544c1
     gen_logic_cc(s, tmp);
5544c1
 }
5544c1
 
5544c1
@@ -1494,10 +1504,10 @@ DISAS_INSN(tas)
5544c1
     TCGv addr;
5544c1
 
5544c1
     dest = tcg_temp_new();
5544c1
-    SRC_EA(src1, OS_BYTE, 1, &addr);
5544c1
+    SRC_EA(env, src1, OS_BYTE, 1, &addr);
5544c1
     gen_logic_cc(s, src1);
5544c1
     tcg_gen_ori_i32(dest, src1, 0x80);
5544c1
-    DEST_EA(insn, OS_BYTE, dest, &addr);
5544c1
+    DEST_EA(env, insn, OS_BYTE, dest, &addr);
5544c1
 }
5544c1
 
5544c1
 DISAS_INSN(mull)
5544c1
@@ -1509,14 +1519,14 @@ DISAS_INSN(mull)
5544c1
 
5544c1
     /* The upper 32 bits of the product are discarded, so
5544c1
        muls.l and mulu.l are functionally equivalent.  */
5544c1
-    ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    ext = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
     if (ext & 0x87ff) {
5544c1
         gen_exception(s, s->pc - 4, EXCP_UNSUPPORTED);
5544c1
         return;
5544c1
     }
5544c1
     reg = DREG(ext, 12);
5544c1
-    SRC_EA(src1, OS_LONG, 0, NULL);
5544c1
+    SRC_EA(env, src1, OS_LONG, 0, NULL);
5544c1
     dest = tcg_temp_new();
5544c1
     tcg_gen_mul_i32(dest, src1, reg);
5544c1
     tcg_gen_mov_i32(reg, dest);
5544c1
@@ -1530,7 +1540,7 @@ DISAS_INSN(link)
5544c1
     TCGv reg;
5544c1
     TCGv tmp;
5544c1
 
5544c1
-    offset = cpu_ldsw_code(cpu_single_env, s->pc);
5544c1
+    offset = cpu_ldsw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
     reg = AREG(insn, 0);
5544c1
     tmp = tcg_temp_new();
5544c1
@@ -1574,7 +1584,7 @@ DISAS_INSN(jump)
5544c1
 
5544c1
     /* Load the target address first to ensure correct exception
5544c1
        behavior.  */
5544c1
-    tmp = gen_lea(s, insn, OS_LONG);
5544c1
+    tmp = gen_lea(env, s, insn, OS_LONG);
5544c1
     if (IS_NULL_QREG(tmp)) {
5544c1
         gen_addr_fault(s);
5544c1
         return;
5544c1
@@ -1594,7 +1604,7 @@ DISAS_INSN(addsubq)
5544c1
     int val;
5544c1
     TCGv addr;
5544c1
 
5544c1
-    SRC_EA(src1, OS_LONG, 0, &addr);
5544c1
+    SRC_EA(env, src1, OS_LONG, 0, &addr);
5544c1
     val = (insn >> 9) & 7;
5544c1
     if (val == 0)
5544c1
         val = 8;
5544c1
@@ -1621,7 +1631,7 @@ DISAS_INSN(addsubq)
5544c1
         }
5544c1
         gen_update_cc_add(dest, src2);
5544c1
     }
5544c1
-    DEST_EA(insn, OS_LONG, dest, &addr);
5544c1
+    DEST_EA(env, insn, OS_LONG, dest, &addr);
5544c1
 }
5544c1
 
5544c1
 DISAS_INSN(tpf)
5544c1
@@ -1636,7 +1646,7 @@ DISAS_INSN(tpf)
5544c1
     case 4: /* No extension words.  */
5544c1
         break;
5544c1
     default:
5544c1
-        disas_undef(s, insn);
5544c1
+        disas_undef(env, s, insn);
5544c1
     }
5544c1
 }
5544c1
 
5544c1
@@ -1651,10 +1661,10 @@ DISAS_INSN(branch)
5544c1
     op = (insn >> 8) & 0xf;
5544c1
     offset = (int8_t)insn;
5544c1
     if (offset == 0) {
5544c1
-        offset = cpu_ldsw_code(cpu_single_env, s->pc);
5544c1
+        offset = cpu_ldsw_code(env, s->pc);
5544c1
         s->pc += 2;
5544c1
     } else if (offset == -1) {
5544c1
-        offset = read_im32(s);
5544c1
+        offset = read_im32(env, s);
5544c1
     }
5544c1
     if (op == 1) {
5544c1
         /* bsr */
5544c1
@@ -1693,7 +1703,7 @@ DISAS_INSN(mvzs)
5544c1
         opsize = OS_WORD;
5544c1
     else
5544c1
         opsize = OS_BYTE;
5544c1
-    SRC_EA(src, opsize, (insn & 0x80) == 0, NULL);
5544c1
+    SRC_EA(env, src, opsize, (insn & 0x80) == 0, NULL);
5544c1
     reg = DREG(insn, 9);
5544c1
     tcg_gen_mov_i32(reg, src);
5544c1
     gen_logic_cc(s, src);
5544c1
@@ -1709,11 +1719,11 @@ DISAS_INSN(or)
5544c1
     reg = DREG(insn, 9);
5544c1
     dest = tcg_temp_new();
5544c1
     if (insn & 0x100) {
5544c1
-        SRC_EA(src, OS_LONG, 0, &addr);
5544c1
+        SRC_EA(env, src, OS_LONG, 0, &addr);
5544c1
         tcg_gen_or_i32(dest, src, reg);
5544c1
-        DEST_EA(insn, OS_LONG, dest, &addr);
5544c1
+        DEST_EA(env, insn, OS_LONG, dest, &addr);
5544c1
     } else {
5544c1
-        SRC_EA(src, OS_LONG, 0, NULL);
5544c1
+        SRC_EA(env, src, OS_LONG, 0, NULL);
5544c1
         tcg_gen_or_i32(dest, src, reg);
5544c1
         tcg_gen_mov_i32(reg, dest);
5544c1
     }
5544c1
@@ -1725,7 +1735,7 @@ DISAS_INSN(suba)
5544c1
     TCGv src;
5544c1
     TCGv reg;
5544c1
 
5544c1
-    SRC_EA(src, OS_LONG, 0, NULL);
5544c1
+    SRC_EA(env, src, OS_LONG, 0, NULL);
5544c1
     reg = AREG(insn, 9);
5544c1
     tcg_gen_sub_i32(reg, reg, src);
5544c1
 }
5544c1
@@ -1751,7 +1761,7 @@ DISAS_INSN(mov3q)
5544c1
         val = -1;
5544c1
     src = tcg_const_i32(val);
5544c1
     gen_logic_cc(s, src);
5544c1
-    DEST_EA(insn, OS_LONG, src, NULL);
5544c1
+    DEST_EA(env, insn, OS_LONG, src, NULL);
5544c1
 }
5544c1
 
5544c1
 DISAS_INSN(cmp)
5544c1
@@ -1779,7 +1789,7 @@ DISAS_INSN(cmp)
5544c1
     default:
5544c1
         abort();
5544c1
     }
5544c1
-    SRC_EA(src, opsize, 1, NULL);
5544c1
+    SRC_EA(env, src, opsize, 1, NULL);
5544c1
     reg = DREG(insn, 9);
5544c1
     dest = tcg_temp_new();
5544c1
     tcg_gen_sub_i32(dest, reg, src);
5544c1
@@ -1798,7 +1808,7 @@ DISAS_INSN(cmpa)
5544c1
     } else {
5544c1
         opsize = OS_WORD;
5544c1
     }
5544c1
-    SRC_EA(src, opsize, 1, NULL);
5544c1
+    SRC_EA(env, src, opsize, 1, NULL);
5544c1
     reg = AREG(insn, 9);
5544c1
     dest = tcg_temp_new();
5544c1
     tcg_gen_sub_i32(dest, reg, src);
5544c1
@@ -1813,12 +1823,12 @@ DISAS_INSN(eor)
5544c1
     TCGv dest;
5544c1
     TCGv addr;
5544c1
 
5544c1
-    SRC_EA(src, OS_LONG, 0, &addr);
5544c1
+    SRC_EA(env, src, OS_LONG, 0, &addr);
5544c1
     reg = DREG(insn, 9);
5544c1
     dest = tcg_temp_new();
5544c1
     tcg_gen_xor_i32(dest, src, reg);
5544c1
     gen_logic_cc(s, dest);
5544c1
-    DEST_EA(insn, OS_LONG, dest, &addr);
5544c1
+    DEST_EA(env, insn, OS_LONG, dest, &addr);
5544c1
 }
5544c1
 
5544c1
 DISAS_INSN(and)
5544c1
@@ -1831,11 +1841,11 @@ DISAS_INSN(and)
5544c1
     reg = DREG(insn, 9);
5544c1
     dest = tcg_temp_new();
5544c1
     if (insn & 0x100) {
5544c1
-        SRC_EA(src, OS_LONG, 0, &addr);
5544c1
+        SRC_EA(env, src, OS_LONG, 0, &addr);
5544c1
         tcg_gen_and_i32(dest, src, reg);
5544c1
-        DEST_EA(insn, OS_LONG, dest, &addr);
5544c1
+        DEST_EA(env, insn, OS_LONG, dest, &addr);
5544c1
     } else {
5544c1
-        SRC_EA(src, OS_LONG, 0, NULL);
5544c1
+        SRC_EA(env, src, OS_LONG, 0, NULL);
5544c1
         tcg_gen_and_i32(dest, src, reg);
5544c1
         tcg_gen_mov_i32(reg, dest);
5544c1
     }
5544c1
@@ -1847,7 +1857,7 @@ DISAS_INSN(adda)
5544c1
     TCGv src;
5544c1
     TCGv reg;
5544c1
 
5544c1
-    SRC_EA(src, OS_LONG, 0, NULL);
5544c1
+    SRC_EA(env, src, OS_LONG, 0, NULL);
5544c1
     reg = AREG(insn, 9);
5544c1
     tcg_gen_add_i32(reg, reg, src);
5544c1
 }
5544c1
@@ -1936,13 +1946,13 @@ DISAS_INSN(strldsr)
5544c1
     uint32_t addr;
5544c1
 
5544c1
     addr = s->pc - 2;
5544c1
-    ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    ext = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
     if (ext != 0x46FC) {
5544c1
         gen_exception(s, addr, EXCP_UNSUPPORTED);
5544c1
         return;
5544c1
     }
5544c1
-    ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    ext = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
     if (IS_USER(s) || (ext & SR_S) == 0) {
5544c1
         gen_exception(s, addr, EXCP_PRIVILEGE);
5544c1
@@ -1972,7 +1982,7 @@ DISAS_INSN(move_to_sr)
5544c1
         gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
5544c1
         return;
5544c1
     }
5544c1
-    gen_set_sr(s, insn, 0);
5544c1
+    gen_set_sr(env, s, insn, 0);
5544c1
     gen_lookup_tb(s);
5544c1
 }
5544c1
 
5544c1
@@ -2010,7 +2020,7 @@ DISAS_INSN(stop)
5544c1
         return;
5544c1
     }
5544c1
 
5544c1
-    ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    ext = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
 
5544c1
     gen_set_sr_im(s, ext, 0);
5544c1
@@ -2037,7 +2047,7 @@ DISAS_INSN(movec)
5544c1
         return;
5544c1
     }
5544c1
 
5544c1
-    ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    ext = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
 
5544c1
     if (ext & 0x8000) {
5544c1
@@ -2102,7 +2112,7 @@ DISAS_INSN(fpu)
5544c1
     int set_dest;
5544c1
     int opsize;
5544c1
 
5544c1
-    ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    ext = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
     opmode = ext & 0x7f;
5544c1
     switch ((ext >> 13) & 7) {
5544c1
@@ -2138,7 +2148,7 @@ DISAS_INSN(fpu)
5544c1
                 tcg_gen_addi_i32(tmp32, tmp32, -8);
5544c1
                 break;
5544c1
             case 5:
5544c1
-                offset = cpu_ldsw_code(cpu_single_env, s->pc);
5544c1
+                offset = cpu_ldsw_code(env, s->pc);
5544c1
                 s->pc += 2;
5544c1
                 tcg_gen_addi_i32(tmp32, tmp32, offset);
5544c1
                 break;
5544c1
@@ -2164,7 +2174,7 @@ DISAS_INSN(fpu)
5544c1
         default:
5544c1
             goto undef;
5544c1
         }
5544c1
-        DEST_EA(insn, opsize, tmp32, NULL);
5544c1
+        DEST_EA(env, insn, opsize, tmp32, NULL);
5544c1
         tcg_temp_free_i32(tmp32);
5544c1
         return;
5544c1
     case 4: /* fmove to control register.  */
5544c1
@@ -2192,7 +2202,7 @@ DISAS_INSN(fpu)
5544c1
                       (ext >> 10) & 7);
5544c1
             goto undef;
5544c1
         }
5544c1
-        DEST_EA(insn, OS_LONG, tmp32, NULL);
5544c1
+        DEST_EA(env, insn, OS_LONG, tmp32, NULL);
5544c1
         break;
5544c1
     case 6: /* fmovem */
5544c1
     case 7:
5544c1
@@ -2202,7 +2212,7 @@ DISAS_INSN(fpu)
5544c1
             int i;
5544c1
             if ((ext & 0x1f00) != 0x1000 || (ext & 0xff) == 0)
5544c1
                 goto undef;
5544c1
-            tmp32 = gen_lea(s, insn, OS_LONG);
5544c1
+            tmp32 = gen_lea(env, s, insn, OS_LONG);
5544c1
             if (IS_NULL_QREG(tmp32)) {
5544c1
                 gen_addr_fault(s);
5544c1
                 return;
5544c1
@@ -2252,12 +2262,12 @@ DISAS_INSN(fpu)
5544c1
                 tcg_gen_addi_i32(tmp32, tmp32, -8);
5544c1
                 break;
5544c1
             case 5:
5544c1
-                offset = cpu_ldsw_code(cpu_single_env, s->pc);
5544c1
+                offset = cpu_ldsw_code(env, s->pc);
5544c1
                 s->pc += 2;
5544c1
                 tcg_gen_addi_i32(tmp32, tmp32, offset);
5544c1
                 break;
5544c1
             case 7:
5544c1
-                offset = cpu_ldsw_code(cpu_single_env, s->pc);
5544c1
+                offset = cpu_ldsw_code(env, s->pc);
5544c1
                 offset += s->pc - 2;
5544c1
                 s->pc += 2;
5544c1
                 tcg_gen_addi_i32(tmp32, tmp32, offset);
5544c1
@@ -2277,7 +2287,7 @@ DISAS_INSN(fpu)
5544c1
             }
5544c1
             tcg_temp_free_i32(tmp32);
5544c1
         } else {
5544c1
-            SRC_EA(tmp32, opsize, 1, NULL);
5544c1
+            SRC_EA(env, tmp32, opsize, 1, NULL);
5544c1
             src = tcg_temp_new_i64();
5544c1
             switch (opsize) {
5544c1
             case OS_LONG:
5544c1
@@ -2372,7 +2382,7 @@ DISAS_INSN(fpu)
5544c1
 undef:
5544c1
     /* FIXME: Is this right for offset addressing modes?  */
5544c1
     s->pc -= 2;
5544c1
-    disas_undef_fpu(s, insn);
5544c1
+    disas_undef_fpu(env, s, insn);
5544c1
 }
5544c1
 
5544c1
 DISAS_INSN(fbcc)
5544c1
@@ -2383,10 +2393,10 @@ DISAS_INSN(fbcc)
5544c1
     int l1;
5544c1
 
5544c1
     addr = s->pc;
5544c1
-    offset = cpu_ldsw_code(cpu_single_env, s->pc);
5544c1
+    offset = cpu_ldsw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
     if (insn & (1 << 6)) {
5544c1
-        offset = (offset << 16) | cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+        offset = (offset << 16) | cpu_lduw_code(env, s->pc);
5544c1
         s->pc += 2;
5544c1
     }
5544c1
 
5544c1
@@ -2508,18 +2518,18 @@ DISAS_INSN(mac)
5544c1
         s->done_mac = 1;
5544c1
     }
5544c1
 
5544c1
-    ext = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    ext = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
 
5544c1
     acc = ((insn >> 7) & 1) | ((ext >> 3) & 2);
5544c1
     dual = ((insn & 0x30) != 0 && (ext & 3) != 0);
5544c1
     if (dual && !m68k_feature(s->env, M68K_FEATURE_CF_EMAC_B)) {
5544c1
-        disas_undef(s, insn);
5544c1
+        disas_undef(env, s, insn);
5544c1
         return;
5544c1
     }
5544c1
     if (insn & 0x30) {
5544c1
         /* MAC with load.  */
5544c1
-        tmp = gen_lea(s, insn, OS_LONG);
5544c1
+        tmp = gen_lea(env, s, insn, OS_LONG);
5544c1
         addr = tcg_temp_new();
5544c1
         tcg_gen_and_i32(addr, tmp, QREG_MAC_MASK);
5544c1
         /* Load the value now to ensure correct exception behavior.
5544c1
@@ -2733,7 +2743,7 @@ DISAS_INSN(to_mac)
5544c1
     int accnum;
5544c1
     accnum = (insn >> 9) & 3;
5544c1
     acc = MACREG(accnum);
5544c1
-    SRC_EA(val, OS_LONG, 0, NULL);
5544c1
+    SRC_EA(env, val, OS_LONG, 0, NULL);
5544c1
     if (s->env->macsr & MACSR_FI) {
5544c1
         tcg_gen_ext_i32_i64(acc, val);
5544c1
         tcg_gen_shli_i64(acc, acc, 8);
5544c1
@@ -2750,7 +2760,7 @@ DISAS_INSN(to_mac)
5544c1
 DISAS_INSN(to_macsr)
5544c1
 {
5544c1
     TCGv val;
5544c1
-    SRC_EA(val, OS_LONG, 0, NULL);
5544c1
+    SRC_EA(env, val, OS_LONG, 0, NULL);
5544c1
     gen_helper_set_macsr(cpu_env, val);
5544c1
     gen_lookup_tb(s);
5544c1
 }
5544c1
@@ -2758,7 +2768,7 @@ DISAS_INSN(to_macsr)
5544c1
 DISAS_INSN(to_mask)
5544c1
 {
5544c1
     TCGv val;
5544c1
-    SRC_EA(val, OS_LONG, 0, NULL);
5544c1
+    SRC_EA(env, val, OS_LONG, 0, NULL);
5544c1
     tcg_gen_ori_i32(QREG_MAC_MASK, val, 0xffff0000);
5544c1
 }
5544c1
 
5544c1
@@ -2766,7 +2776,7 @@ DISAS_INSN(to_mext)
5544c1
 {
5544c1
     TCGv val;
5544c1
     TCGv acc;
5544c1
-    SRC_EA(val, OS_LONG, 0, NULL);
5544c1
+    SRC_EA(env, val, OS_LONG, 0, NULL);
5544c1
     acc = tcg_const_i32((insn & 0x400) ? 2 : 0);
5544c1
     if (s->env->macsr & MACSR_FI)
5544c1
         gen_helper_set_mac_extf(cpu_env, val, acc);
5544c1
@@ -2943,10 +2953,10 @@ static void disas_m68k_insn(CPUM68KState * env, DisasContext *s)
5544c1
 {
5544c1
     uint16_t insn;
5544c1
 
5544c1
-    insn = cpu_lduw_code(cpu_single_env, s->pc);
5544c1
+    insn = cpu_lduw_code(env, s->pc);
5544c1
     s->pc += 2;
5544c1
 
5544c1
-    opcode_table[insn](s, insn);
5544c1
+    opcode_table[insn](env, s, insn);
5544c1
 }
5544c1
 
5544c1
 /* generate intermediate code for basic block 'tb'.  */
5544c1
-- 
5544c1
1.7.12.1
5544c1