Revision c4687878 translate-all.c

b/translate-all.c
42 42

  
43 43
uint16_t gen_opc_buf[OPC_BUF_SIZE];
44 44
uint32_t gen_opparam_buf[OPPARAM_BUF_SIZE];
45
uint32_t gen_opc_pc[OPC_BUF_SIZE];
45
long gen_labels[OPC_BUF_SIZE];
46
int nb_gen_labels;
47

  
48
target_ulong gen_opc_pc[OPC_BUF_SIZE];
46 49
uint8_t gen_opc_instr_start[OPC_BUF_SIZE];
47 50
#if defined(TARGET_I386)
48 51
uint8_t gen_opc_cc_op[OPC_BUF_SIZE];
49 52
#elif defined(TARGET_SPARC)
50
uint32_t gen_opc_npc[OPC_BUF_SIZE];
53
target_ulong gen_opc_npc[OPC_BUF_SIZE];
51 54
#endif
52 55

  
53 56
int code_copy_enabled = 1;
......
65 68
#undef DEF
66 69
};
67 70

  
71
static const unsigned short opc_copy_size[] = {
72
#define DEF(s, n, copy_size) copy_size,
73
#include "opc.h"
74
#undef DEF
75
};
76

  
68 77
void dump_ops(const uint16_t *opc_buf, const uint32_t *opparam_buf)
69 78
{
70 79
    const uint16_t *opc_ptr;
......
90 99

  
91 100
#endif
92 101

  
102
/* compute label info */
103
static void dyngen_labels(long *gen_labels, int nb_gen_labels,
104
                          uint8_t *gen_code_buf, const uint16_t *opc_buf)
105
{
106
    uint8_t *gen_code_ptr;
107
    int c, i;
108
    unsigned long gen_code_addr[OPC_BUF_SIZE];
109
    
110
    if (nb_gen_labels == 0)
111
        return;
112
    /* compute the address of each op code */
113
    
114
    gen_code_ptr = gen_code_buf;
115
    i = 0;
116
    for(;;) {
117
        c = opc_buf[i];
118
        gen_code_addr[i] =(unsigned long)gen_code_ptr;
119
        if (c == INDEX_op_end)
120
            break;
121
        gen_code_ptr += opc_copy_size[c];
122
        i++;
123
    }
124
    
125
    /* compute the address of each label */
126
    for(i = 0; i < nb_gen_labels; i++) {
127
        gen_labels[i] = gen_code_addr[gen_labels[i]];
128
    }
129
}
130

  
93 131
/* return non zero if the very first instruction is invalid so that
94 132
   the virtual CPU can trigger an exception. 
95 133

  
......
121 159
        tb->tb_jmp_offset[2] = 0xffff;
122 160
        tb->tb_jmp_offset[3] = 0xffff;
123 161
#endif
162
        dyngen_labels(gen_labels, nb_gen_labels, gen_code_buf, gen_opc_buf);
163

  
124 164
        gen_code_size = dyngen_code(gen_code_buf, tb->tb_next_offset,
125 165
#ifdef USE_DIRECT_JUMP
126 166
                                    tb->tb_jmp_offset,
127 167
#else
128 168
                                    NULL,
129 169
#endif
130
                                    gen_opc_buf, gen_opparam_buf);
170
                                    gen_opc_buf, gen_opparam_buf, gen_labels);
131 171
    }
132 172
    *gen_code_size_ptr = gen_code_size;
133 173
#ifdef DEBUG_DISAS
134 174
    if (loglevel & CPU_LOG_TB_OUT_ASM) {
135 175
        fprintf(logfile, "OUT: [size=%d]\n", *gen_code_size_ptr);
136
        disas(logfile, tb->tc_ptr, *gen_code_size_ptr, 1, 0);
176
        disas(logfile, tb->tc_ptr, *gen_code_size_ptr);
137 177
        fprintf(logfile, "\n");
138 178
        fflush(logfile);
139 179
    }
......
141 181
    return 0;
142 182
}
143 183

  
144
static const unsigned short opc_copy_size[] = {
145
#define DEF(s, n, copy_size) copy_size,
146
#include "opc.h"
147
#undef DEF
148
};
149

  
150 184
/* The cpu state corresponding to 'searched_pc' is restored. 
151 185
 */
152 186
int cpu_restore_state(TranslationBlock *tb, 
......
193 227
            fprintf(logfile, "RESTORE:\n");
194 228
            for(i=0;i<=j; i++) {
195 229
                if (gen_opc_instr_start[i]) {
196
                    fprintf(logfile, "0x%04x: 0x%08x\n", i, gen_opc_pc[i]);
230
                    fprintf(logfile, "0x%04x: " TARGET_FMT_lx "\n", i, gen_opc_pc[i]);
197 231
                }
198 232
            }
199
            fprintf(logfile, "spc=0x%08lx j=0x%x eip=0x%x cs_base=%x\n", 
200
                    searched_pc, j, gen_opc_pc[j] - tb->cs_base, tb->cs_base);
233
            fprintf(logfile, "spc=0x%08lx j=0x%x eip=" TARGET_FMT_lx " cs_base=%x\n", 
234
                    searched_pc, j, gen_opc_pc[j] - tb->cs_base, 
235
                    (uint32_t)tb->cs_base);
201 236
        }
202 237
#endif
203 238
        env->eip = gen_opc_pc[j] - tb->cs_base;

Also available in: Unified diff