Fix i32 memory backed variables on 64-bit host

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4044 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
blueswir1 2008-03-13 17:34:19 +00:00
parent 30aa5c0d30
commit e4d5434c3a
4 changed files with 25 additions and 19 deletions

View File

@ -255,15 +255,15 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type,
} }
} }
static inline void tcg_out_ld(TCGContext *s, int ret, static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret,
int arg1, int32_t arg2) int arg1, tcg_target_long arg2)
{ {
/* movl */ /* movl */
tcg_out_modrm_offset(s, 0x8b, ret, arg1, arg2); tcg_out_modrm_offset(s, 0x8b, ret, arg1, arg2);
} }
static inline void tcg_out_st(TCGContext *s, int arg, static inline void tcg_out_st(TCGContext *s, TCGType type, int arg,
int arg1, int32_t arg2) int arg1, tcg_target_long arg2)
{ {
/* movl */ /* movl */
tcg_out_modrm_offset(s, 0x89, arg, arg1, arg2); tcg_out_modrm_offset(s, 0x89, arg, arg1, arg2);

View File

@ -262,13 +262,13 @@ static inline void tcg_out_ldst(TCGContext *s, int ret, int addr, int offset, in
fprintf(stderr, "unimplemented %s with offset %d\n", __func__, offset); fprintf(stderr, "unimplemented %s with offset %d\n", __func__, offset);
} }
static inline void tcg_out_ld(TCGContext *s, int ret, static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret,
int arg1, tcg_target_long arg2) int arg1, tcg_target_long arg2)
{ {
fprintf(stderr, "unimplemented %s\n", __func__); fprintf(stderr, "unimplemented %s\n", __func__);
} }
static inline void tcg_out_st(TCGContext *s, int arg, static inline void tcg_out_st(TCGContext *s, TCGType type, int arg,
int arg1, tcg_target_long arg2) int arg1, tcg_target_long arg2)
{ {
fprintf(stderr, "unimplemented %s\n", __func__); fprintf(stderr, "unimplemented %s\n", __func__);

View File

@ -1196,7 +1196,7 @@ static void tcg_reg_free(TCGContext *s, int reg)
if (!ts->mem_coherent) { if (!ts->mem_coherent) {
if (!ts->mem_allocated) if (!ts->mem_allocated)
temp_allocate_frame(s, temp); temp_allocate_frame(s, temp);
tcg_out_st(s, reg, ts->mem_reg, ts->mem_offset); tcg_out_st(s, ts->type, reg, ts->mem_reg, ts->mem_offset);
} }
ts->val_type = TEMP_VAL_MEM; ts->val_type = TEMP_VAL_MEM;
s->reg_to_temp[reg] = -1; s->reg_to_temp[reg] = -1;
@ -1296,7 +1296,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
} else { } else {
reg = tcg_reg_alloc(s, arg_ct->u.regs, s->reserved_regs); reg = tcg_reg_alloc(s, arg_ct->u.regs, s->reserved_regs);
} }
tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset);
} else if (ts->val_type == TEMP_VAL_CONST) { } else if (ts->val_type == TEMP_VAL_CONST) {
if (ots->val_type == TEMP_VAL_REG) { if (ots->val_type == TEMP_VAL_REG) {
reg = ots->reg; reg = ots->reg;
@ -1343,7 +1343,7 @@ static void tcg_reg_alloc_op(TCGContext *s,
ts = &s->temps[arg]; ts = &s->temps[arg];
if (ts->val_type == TEMP_VAL_MEM) { if (ts->val_type == TEMP_VAL_MEM) {
reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs);
tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset);
ts->val_type = TEMP_VAL_REG; ts->val_type = TEMP_VAL_REG;
ts->reg = reg; ts->reg = reg;
ts->mem_coherent = 1; ts->mem_coherent = 1;
@ -1501,19 +1501,19 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
arg = args[nb_oargs + i]; arg = args[nb_oargs + i];
ts = &s->temps[arg]; ts = &s->temps[arg];
if (ts->val_type == TEMP_VAL_REG) { if (ts->val_type == TEMP_VAL_REG) {
tcg_out_st(s, ts->reg, TCG_REG_CALL_STACK, stack_offset); tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, stack_offset);
} else if (ts->val_type == TEMP_VAL_MEM) { } else if (ts->val_type == TEMP_VAL_MEM) {
reg = tcg_reg_alloc(s, tcg_target_available_regs[ts->type], reg = tcg_reg_alloc(s, tcg_target_available_regs[ts->type],
s->reserved_regs); s->reserved_regs);
/* XXX: not correct if reading values from the stack */ /* XXX: not correct if reading values from the stack */
tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset);
tcg_out_st(s, reg, TCG_REG_CALL_STACK, stack_offset); tcg_out_st(s, ts->type, reg, TCG_REG_CALL_STACK, stack_offset);
} else if (ts->val_type == TEMP_VAL_CONST) { } else if (ts->val_type == TEMP_VAL_CONST) {
reg = tcg_reg_alloc(s, tcg_target_available_regs[ts->type], reg = tcg_reg_alloc(s, tcg_target_available_regs[ts->type],
s->reserved_regs); s->reserved_regs);
/* XXX: sign extend may be needed on some targets */ /* XXX: sign extend may be needed on some targets */
tcg_out_movi(s, ts->type, reg, ts->val); tcg_out_movi(s, ts->type, reg, ts->val);
tcg_out_st(s, reg, TCG_REG_CALL_STACK, stack_offset); tcg_out_st(s, ts->type, reg, TCG_REG_CALL_STACK, stack_offset);
} else { } else {
tcg_abort(); tcg_abort();
} }
@ -1532,7 +1532,7 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
tcg_out_mov(s, reg, ts->reg); tcg_out_mov(s, reg, ts->reg);
} }
} else if (ts->val_type == TEMP_VAL_MEM) { } else if (ts->val_type == TEMP_VAL_MEM) {
tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset);
} else if (ts->val_type == TEMP_VAL_CONST) { } else if (ts->val_type == TEMP_VAL_CONST) {
/* XXX: sign extend ? */ /* XXX: sign extend ? */
tcg_out_movi(s, ts->type, reg, ts->val); tcg_out_movi(s, ts->type, reg, ts->val);
@ -1549,7 +1549,7 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
const_func_arg = 0; const_func_arg = 0;
if (ts->val_type == TEMP_VAL_MEM) { if (ts->val_type == TEMP_VAL_MEM) {
reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs);
tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset);
func_arg = reg; func_arg = reg;
} else if (ts->val_type == TEMP_VAL_REG) { } else if (ts->val_type == TEMP_VAL_REG) {
reg = ts->reg; reg = ts->reg;

View File

@ -356,16 +356,22 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type,
} }
} }
static inline void tcg_out_ld(TCGContext *s, int ret, static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret,
int arg1, tcg_target_long arg2) int arg1, tcg_target_long arg2)
{ {
tcg_out_modrm_offset(s, 0x8b | P_REXW, ret, arg1, arg2); /* movq */ if (type == TCG_TYPE_I32)
tcg_out_modrm_offset(s, 0x8b, ret, arg1, arg2); /* movl */
else
tcg_out_modrm_offset(s, 0x8b | P_REXW, ret, arg1, arg2); /* movq */
} }
static inline void tcg_out_st(TCGContext *s, int arg, static inline void tcg_out_st(TCGContext *s, TCGType type, int arg,
int arg1, tcg_target_long arg2) int arg1, tcg_target_long arg2)
{ {
tcg_out_modrm_offset(s, 0x89 | P_REXW, arg, arg1, arg2); /* movq */ if (type == TCG_TYPE_I32)
tcg_out_modrm_offset(s, 0x89, arg, arg1, arg2); /* movl */
else
tcg_out_modrm_offset(s, 0x89 | P_REXW, arg, arg1, arg2); /* movq */
} }
static inline void tgen_arithi32(TCGContext *s, int c, int r0, int32_t val) static inline void tgen_arithi32(TCGContext *s, int c, int r0, int32_t val)