#include <inttypes.h>
#include "config.h"
+
#define IN_OP_I386
-#include "cpu-" TARGET_ARCH ".h"
+#if defined(TARGET_I386)
+#include "cpu-i386.h"
+#define OPC_CPU_H "opc-i386.h"
+#elif defined(TARGET_ARM)
+#include "cpu-arm.h"
+#define OPC_CPU_H "opc-arm.h"
+#else
+#error unsupported target CPU
+#endif
+
#include "exec.h"
#include "disas.h"
enum {
#define DEF(s, n, copy_size) INDEX_op_ ## s,
-#include "opc-" TARGET_ARCH ".h"
+#include OPC_CPU_H
#undef DEF
NB_OPS,
};
#include "dyngen.h"
-#include "op-" TARGET_ARCH ".h"
+#if defined(TARGET_I386)
+#include "op-i386.h"
+#elif defined(TARGET_ARM)
+#include "op-arm.h"
+#else
+#error unsupported target CPU
+#endif
uint16_t gen_opc_buf[OPC_BUF_SIZE];
uint32_t gen_opparam_buf[OPPARAM_BUF_SIZE];
uint32_t gen_opc_pc[OPC_BUF_SIZE];
uint8_t gen_opc_instr_start[OPC_BUF_SIZE];
-
+#if defined(TARGET_I386)
+uint8_t gen_opc_cc_op[OPC_BUF_SIZE];
+#endif
#ifdef DEBUG_DISAS
static const char *op_str[] = {
#define DEF(s, n, copy_size) #s,
-#include "opc-" TARGET_ARCH ".h"
+#include OPC_CPU_H
#undef DEF
};
static uint8_t op_nb_args[] = {
#define DEF(s, n, copy_size) n,
-#include "opc-" TARGET_ARCH ".h"
+#include OPC_CPU_H
#undef DEF
};
'*gen_code_size_ptr' contains the size of the generated code (host
code).
*/
-int cpu_gen_code(TranslationBlock *tb,
+int cpu_gen_code(CPUState *env, TranslationBlock *tb,
int max_code_size, int *gen_code_size_ptr)
{
uint8_t *gen_code_buf;
int gen_code_size;
- if (gen_intermediate_code(tb, 0) < 0)
+ if (gen_intermediate_code(env, tb) < 0)
return -1;
/* generate machine code */
static const unsigned short opc_copy_size[] = {
#define DEF(s, n, copy_size) copy_size,
-#include "opc-i386.h"
+#include OPC_CPU_H
#undef DEF
};
-/* The simulated PC corresponding to
- 'searched_pc' in the generated code is searched. 0 is returned if
- found. *found_pc contains the found PC.
+/* The cpu state corresponding to 'searched_pc' is restored.
*/
-int cpu_search_pc(TranslationBlock *tb,
- uint32_t *found_pc, unsigned long searched_pc)
+int cpu_restore_state(TranslationBlock *tb,
+ CPUState *env, unsigned long searched_pc)
{
int j, c;
unsigned long tc_ptr;
uint16_t *opc_ptr;
- if (gen_intermediate_code(tb, 1) < 0)
+ if (gen_intermediate_code_pc(env, tb) < 0)
return -1;
/* find opc index corresponding to search_pc */
/* now find start of instruction before */
while (gen_opc_instr_start[j] == 0)
j--;
- *found_pc = gen_opc_pc[j];
+#if defined(TARGET_I386)
+ {
+ int cc_op;
+#ifdef DEBUG_DISAS
+ if (loglevel) {
+ int i;
+ fprintf(logfile, "RESTORE:\n");
+ for(i=0;i<=j; i++) {
+ if (gen_opc_instr_start[i]) {
+ fprintf(logfile, "0x%04x: 0x%08x\n", i, gen_opc_pc[i]);
+ }
+ }
+ fprintf(logfile, "spc=0x%08lx j=0x%x eip=0x%lx cs_base=%lx\n",
+ searched_pc, j, gen_opc_pc[j] - tb->cs_base, tb->cs_base);
+ }
+#endif
+ env->eip = gen_opc_pc[j] - tb->cs_base;
+ cc_op = gen_opc_cc_op[j];
+ if (cc_op != CC_OP_DYNAMIC)
+ env->cc_op = cc_op;
+ }
+#elif defined(TARGET_ARM)
+ env->regs[15] = gen_opc_pc[j];
+#endif
return 0;
}