Commit 9db3ba4db28bae33d053752819c004ad28680bcc
1 parent
13412c9d
TCG x86/x86-64: use move with zero-extend for loads/stores
Starting with version 4.3, gcc returns the result of a function in rax/eax/ax/al instead of rax/eax, depending of the return type. As a consequence we should use a zero extend moe in TCG loads/stores. See http://gcc.gnu.org/ml/gcc/2008-01/msg00052.html for more details. A big thanks to malc who founds the problem and wrote the x86 patch. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6011 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
12 additions
and
0 deletions
tcg/i386/tcg-target.c
@@ -525,7 +525,13 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, | @@ -525,7 +525,13 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, | ||
525 | tcg_out_modrm(s, 0xbf | P_EXT, data_reg, TCG_REG_EAX); | 525 | tcg_out_modrm(s, 0xbf | P_EXT, data_reg, TCG_REG_EAX); |
526 | break; | 526 | break; |
527 | case 0: | 527 | case 0: |
528 | + /* movzbl */ | ||
529 | + tcg_out_modrm(s, 0xb6 | P_EXT, data_reg, TCG_REG_EAX); | ||
530 | + break; | ||
528 | case 1: | 531 | case 1: |
532 | + /* movzwl */ | ||
533 | + tcg_out_modrm(s, 0xb7 | P_EXT, data_reg, TCG_REG_EAX); | ||
534 | + break; | ||
529 | case 2: | 535 | case 2: |
530 | default: | 536 | default: |
531 | tcg_out_mov(s, data_reg, TCG_REG_EAX); | 537 | tcg_out_mov(s, data_reg, TCG_REG_EAX); |
tcg/x86_64/tcg-target.c
@@ -575,7 +575,13 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, | @@ -575,7 +575,13 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, | ||
575 | tcg_out_modrm(s, 0x63 | P_REXW, data_reg, TCG_REG_RAX); | 575 | tcg_out_modrm(s, 0x63 | P_REXW, data_reg, TCG_REG_RAX); |
576 | break; | 576 | break; |
577 | case 0: | 577 | case 0: |
578 | + /* movzbq */ | ||
579 | + tcg_out_modrm(s, 0xb6 | P_EXT | P_REXW, data_reg, TCG_REG_RAX); | ||
580 | + break; | ||
578 | case 1: | 581 | case 1: |
582 | + /* movzwq */ | ||
583 | + tcg_out_modrm(s, 0xb7 | P_EXT | P_REXW, data_reg, TCG_REG_RAX); | ||
584 | + break; | ||
579 | case 2: | 585 | case 2: |
580 | default: | 586 | default: |
581 | /* movl */ | 587 | /* movl */ |