Commit e4d5434c3a9c7eacadad431fcd03c277c6d2777d
1 parent
30aa5c0d
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
Showing
4 changed files
with
25 additions
and
19 deletions
tcg/i386/tcg-target.c
... | ... | @@ -255,15 +255,15 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type, |
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | -static inline void tcg_out_ld(TCGContext *s, int ret, | |
259 | - int arg1, int32_t arg2) | |
258 | +static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, | |
259 | + int arg1, tcg_target_long arg2) | |
260 | 260 | { |
261 | 261 | /* movl */ |
262 | 262 | tcg_out_modrm_offset(s, 0x8b, ret, arg1, arg2); |
263 | 263 | } |
264 | 264 | |
265 | -static inline void tcg_out_st(TCGContext *s, int arg, | |
266 | - int arg1, int32_t arg2) | |
265 | +static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, | |
266 | + int arg1, tcg_target_long arg2) | |
267 | 267 | { |
268 | 268 | /* movl */ |
269 | 269 | tcg_out_modrm_offset(s, 0x89, arg, arg1, arg2); | ... | ... |
tcg/sparc/tcg-target.c
... | ... | @@ -262,13 +262,13 @@ static inline void tcg_out_ldst(TCGContext *s, int ret, int addr, int offset, in |
262 | 262 | fprintf(stderr, "unimplemented %s with offset %d\n", __func__, offset); |
263 | 263 | } |
264 | 264 | |
265 | -static inline void tcg_out_ld(TCGContext *s, int ret, | |
265 | +static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, | |
266 | 266 | int arg1, tcg_target_long arg2) |
267 | 267 | { |
268 | 268 | fprintf(stderr, "unimplemented %s\n", __func__); |
269 | 269 | } |
270 | 270 | |
271 | -static inline void tcg_out_st(TCGContext *s, int arg, | |
271 | +static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, | |
272 | 272 | int arg1, tcg_target_long arg2) |
273 | 273 | { |
274 | 274 | fprintf(stderr, "unimplemented %s\n", __func__); | ... | ... |
tcg/tcg.c
... | ... | @@ -1196,7 +1196,7 @@ static void tcg_reg_free(TCGContext *s, int reg) |
1196 | 1196 | if (!ts->mem_coherent) { |
1197 | 1197 | if (!ts->mem_allocated) |
1198 | 1198 | temp_allocate_frame(s, temp); |
1199 | - tcg_out_st(s, reg, ts->mem_reg, ts->mem_offset); | |
1199 | + tcg_out_st(s, ts->type, reg, ts->mem_reg, ts->mem_offset); | |
1200 | 1200 | } |
1201 | 1201 | ts->val_type = TEMP_VAL_MEM; |
1202 | 1202 | s->reg_to_temp[reg] = -1; |
... | ... | @@ -1296,7 +1296,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, |
1296 | 1296 | } else { |
1297 | 1297 | reg = tcg_reg_alloc(s, arg_ct->u.regs, s->reserved_regs); |
1298 | 1298 | } |
1299 | - tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); | |
1299 | + tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset); | |
1300 | 1300 | } else if (ts->val_type == TEMP_VAL_CONST) { |
1301 | 1301 | if (ots->val_type == TEMP_VAL_REG) { |
1302 | 1302 | reg = ots->reg; |
... | ... | @@ -1343,7 +1343,7 @@ static void tcg_reg_alloc_op(TCGContext *s, |
1343 | 1343 | ts = &s->temps[arg]; |
1344 | 1344 | if (ts->val_type == TEMP_VAL_MEM) { |
1345 | 1345 | reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); |
1346 | - tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); | |
1346 | + tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset); | |
1347 | 1347 | ts->val_type = TEMP_VAL_REG; |
1348 | 1348 | ts->reg = reg; |
1349 | 1349 | ts->mem_coherent = 1; |
... | ... | @@ -1501,19 +1501,19 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def, |
1501 | 1501 | arg = args[nb_oargs + i]; |
1502 | 1502 | ts = &s->temps[arg]; |
1503 | 1503 | if (ts->val_type == TEMP_VAL_REG) { |
1504 | - tcg_out_st(s, ts->reg, TCG_REG_CALL_STACK, stack_offset); | |
1504 | + tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, stack_offset); | |
1505 | 1505 | } else if (ts->val_type == TEMP_VAL_MEM) { |
1506 | 1506 | reg = tcg_reg_alloc(s, tcg_target_available_regs[ts->type], |
1507 | 1507 | s->reserved_regs); |
1508 | 1508 | /* XXX: not correct if reading values from the stack */ |
1509 | - tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); | |
1510 | - tcg_out_st(s, reg, TCG_REG_CALL_STACK, stack_offset); | |
1509 | + tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset); | |
1510 | + tcg_out_st(s, ts->type, reg, TCG_REG_CALL_STACK, stack_offset); | |
1511 | 1511 | } else if (ts->val_type == TEMP_VAL_CONST) { |
1512 | 1512 | reg = tcg_reg_alloc(s, tcg_target_available_regs[ts->type], |
1513 | 1513 | s->reserved_regs); |
1514 | 1514 | /* XXX: sign extend may be needed on some targets */ |
1515 | 1515 | tcg_out_movi(s, ts->type, reg, ts->val); |
1516 | - tcg_out_st(s, reg, TCG_REG_CALL_STACK, stack_offset); | |
1516 | + tcg_out_st(s, ts->type, reg, TCG_REG_CALL_STACK, stack_offset); | |
1517 | 1517 | } else { |
1518 | 1518 | tcg_abort(); |
1519 | 1519 | } |
... | ... | @@ -1532,7 +1532,7 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def, |
1532 | 1532 | tcg_out_mov(s, reg, ts->reg); |
1533 | 1533 | } |
1534 | 1534 | } else if (ts->val_type == TEMP_VAL_MEM) { |
1535 | - tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); | |
1535 | + tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset); | |
1536 | 1536 | } else if (ts->val_type == TEMP_VAL_CONST) { |
1537 | 1537 | /* XXX: sign extend ? */ |
1538 | 1538 | tcg_out_movi(s, ts->type, reg, ts->val); |
... | ... | @@ -1549,7 +1549,7 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def, |
1549 | 1549 | const_func_arg = 0; |
1550 | 1550 | if (ts->val_type == TEMP_VAL_MEM) { |
1551 | 1551 | reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); |
1552 | - tcg_out_ld(s, reg, ts->mem_reg, ts->mem_offset); | |
1552 | + tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset); | |
1553 | 1553 | func_arg = reg; |
1554 | 1554 | } else if (ts->val_type == TEMP_VAL_REG) { |
1555 | 1555 | reg = ts->reg; | ... | ... |
tcg/x86_64/tcg-target.c
... | ... | @@ -356,16 +356,22 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type, |
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | -static inline void tcg_out_ld(TCGContext *s, int ret, | |
359 | +static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, | |
360 | 360 | int arg1, tcg_target_long arg2) |
361 | 361 | { |
362 | - tcg_out_modrm_offset(s, 0x8b | P_REXW, ret, arg1, arg2); /* movq */ | |
362 | + if (type == TCG_TYPE_I32) | |
363 | + tcg_out_modrm_offset(s, 0x8b, ret, arg1, arg2); /* movl */ | |
364 | + else | |
365 | + tcg_out_modrm_offset(s, 0x8b | P_REXW, ret, arg1, arg2); /* movq */ | |
363 | 366 | } |
364 | 367 | |
365 | -static inline void tcg_out_st(TCGContext *s, int arg, | |
368 | +static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, | |
366 | 369 | int arg1, tcg_target_long arg2) |
367 | 370 | { |
368 | - tcg_out_modrm_offset(s, 0x89 | P_REXW, arg, arg1, arg2); /* movq */ | |
371 | + if (type == TCG_TYPE_I32) | |
372 | + tcg_out_modrm_offset(s, 0x89, arg, arg1, arg2); /* movl */ | |
373 | + else | |
374 | + tcg_out_modrm_offset(s, 0x89 | P_REXW, arg, arg1, arg2); /* movq */ | |
369 | 375 | } |
370 | 376 | |
371 | 377 | static inline void tgen_arithi32(TCGContext *s, int c, int r0, int32_t val) | ... | ... |