aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho/mcode/ortho_code-x86-emits.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2015-01-12 05:04:08 +0100
committerTristan Gingold <tgingold@free.fr>2015-01-12 05:04:08 +0100
commit552d366f8ca84768a729d7295c4e5e5177a0a3cd (patch)
treedc6d733aed35d8697f5cdd46997b6bf020668a79 /src/ortho/mcode/ortho_code-x86-emits.adb
parent4d24c422cc4a3f84bf0aa81fa26e777355b7265c (diff)
downloadghdl-552d366f8ca84768a729d7295c4e5e5177a0a3cd.tar.gz
ghdl-552d366f8ca84768a729d7295c4e5e5177a0a3cd.tar.bz2
ghdl-552d366f8ca84768a729d7295c4e5e5177a0a3cd.zip
ortho_mcode: handle u32->i64 conversion.
Diffstat (limited to 'src/ortho/mcode/ortho_code-x86-emits.adb')
-rw-r--r--src/ortho/mcode/ortho_code-x86-emits.adb21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/ortho/mcode/ortho_code-x86-emits.adb b/src/ortho/mcode/ortho_code-x86-emits.adb
index ad1ef559b..27f78ef47 100644
--- a/src/ortho/mcode/ortho_code-x86-emits.adb
+++ b/src/ortho/mcode/ortho_code-x86-emits.adb
@@ -467,6 +467,15 @@ package body Ortho_Code.X86.Emits is
End_Insn;
end Gen_Cdq;
+ procedure Gen_Clear_Edx is
+ begin
+ -- Xorl edx, edx
+ Start_Insn;
+ Gen_B8 (2#0011_0001#);
+ Gen_B8 (2#11_010_010#);
+ End_Insn;
+ end Gen_Clear_Edx;
+
procedure Gen_Mono_Op (Op : Byte; Val : O_Enode; Sz : Insn_Size) is
begin
Start_Insn;
@@ -1131,6 +1140,12 @@ package body Ortho_Code.X86.Emits is
end if;
Emit_Tst (Reg_Res, Sz_32l);
Gen_Ov_Check (R_Sge);
+ when Mode_I64 =>
+ if Reg_Res /= R_Edx_Eax or Reg_Op /= R_Ax then
+ raise Program_Error;
+ end if;
+ -- Clear edx.
+ Gen_Clear_Edx;
when Mode_U8
| Mode_B2 =>
if Reg_Res not in Regs_R32 then
@@ -1562,11 +1577,7 @@ package body Ortho_Code.X86.Emits is
| OE_Div_Ov =>
case Mode is
when Mode_U32 =>
- -- Xorl edx, edx
- Start_Insn;
- Gen_B8 (2#0011_0001#);
- Gen_B8 (2#11_010_010#);
- End_Insn;
+ Gen_Clear_Edx;
Gen_Mono_Op (2#110_000#, Get_Expr_Right (Stmt), Sz_32l);
when Mode_I32 =>
if Kind = OE_Mod then