summaryrefslogtreecommitdiff
path: root/target-cris
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-01-19 23:55:42 +0100
committerAndreas Färber <afaerber@suse.de>2013-02-16 14:50:58 +0100
commitd1a94fec3d8d70009fd5ac27ade5539fe58cd702 (patch)
tree1e2254e77b37ba4ae7f53b682a1172e5920e3a91 /target-cris
parent79614b781df5096ffecf531992314781dbab54af (diff)
target-cris: Move TCG initialization to CRISCPU initfn
Split out TCG initialization from cpu_cris_init(). Avoid CPUCRISState dependency for v10-specific initialization and for non-v10 by inlining the decision into the initfn as well. Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'target-cris')
-rw-r--r--target-cris/cpu.c10
-rw-r--r--target-cris/cpu.h3
-rw-r--r--target-cris/translate.c19
-rw-r--r--target-cris/translate_v10.c5
4 files changed, 19 insertions, 18 deletions
diff --git a/target-cris/cpu.c b/target-cris/cpu.c
index 34c4f75a44..fedf64191d 100644
--- a/target-cris/cpu.c
+++ b/target-cris/cpu.c
@@ -70,8 +70,18 @@ static void cris_cpu_initfn(Object *obj)
{
CRISCPU *cpu = CRIS_CPU(obj);
CPUCRISState *env = &cpu->env;
+ static bool tcg_initialized;
cpu_exec_init(env);
+
+ if (tcg_enabled() && !tcg_initialized) {
+ tcg_initialized = true;
+ if (env->pregs[PR_VR] < 32) {
+ cris_initialize_crisv10_tcg();
+ } else {
+ cris_initialize_tcg();
+ }
+ }
}
static void cris_cpu_class_init(ObjectClass *oc, void *data)
diff --git a/target-cris/cpu.h b/target-cris/cpu.h
index 257cb52be2..ebf2d4027f 100644
--- a/target-cris/cpu.h
+++ b/target-cris/cpu.h
@@ -182,6 +182,9 @@ void do_interrupt(CPUCRISState *env);
int cpu_cris_signal_handler(int host_signum, void *pinfo,
void *puc);
+void cris_initialize_tcg(void);
+void cris_initialize_crisv10_tcg(void);
+
enum {
CC_OP_DYNAMIC, /* Use env->cc_op */
CC_OP_FLAGS,
diff --git a/target-cris/translate.c b/target-cris/translate.c
index 25ff490399..25a43faf35 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -3550,8 +3550,6 @@ CRISCPU *cpu_cris_init(const char *cpu_model)
{
CRISCPU *cpu;
CPUCRISState *env;
- static int tcg_initialized = 0;
- int i;
cpu = CRIS_CPU(object_new(TYPE_CRIS_CPU));
env = &cpu->env;
@@ -3560,21 +3558,16 @@ CRISCPU *cpu_cris_init(const char *cpu_model)
object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
- if (tcg_initialized) {
- return cpu;
- }
+ return cpu;
+}
- tcg_initialized = 1;
+void cris_initialize_tcg(void)
+{
+ int i;
#define GEN_HELPER 2
#include "helper.h"
- if (env->pregs[PR_VR] < 32) {
- cpu_crisv10_init(env);
- return cpu;
- }
-
-
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
cc_x = tcg_global_mem_new(TCG_AREG0,
offsetof(CPUCRISState, cc_x), "cc_x");
@@ -3614,8 +3607,6 @@ CRISCPU *cpu_cris_init(const char *cpu_model)
offsetof(CPUCRISState, pregs[i]),
pregnames[i]);
}
-
- return cpu;
}
void restore_state_to_opc(CPUCRISState *env, TranslationBlock *tb, int pc_pos)
diff --git a/target-cris/translate_v10.c b/target-cris/translate_v10.c
index d2cca892e0..d6ef084483 100644
--- a/target-cris/translate_v10.c
+++ b/target-cris/translate_v10.c
@@ -1257,7 +1257,7 @@ static unsigned int crisv10_decoder(CPUCRISState *env, DisasContext *dc)
return insn_len;
}
-static CPUCRISState *cpu_crisv10_init (CPUCRISState *env)
+void cris_initialize_crisv10_tcg(void)
{
int i;
@@ -1300,7 +1300,4 @@ static CPUCRISState *cpu_crisv10_init (CPUCRISState *env)
offsetof(CPUCRISState, pregs[i]),
pregnames_v10[i]);
}
-
- return env;
}
-