summaryrefslogtreecommitdiff
path: root/ortho/mcode/ortho_code-x86-emits.adb
diff options
context:
space:
mode:
authorgingold2008-04-09 04:01:16 +0000
committergingold2008-04-09 04:01:16 +0000
commitf63038518ec0b89eb6170e372a2ad5d0a24d30d3 (patch)
treec2155355116acf3f90a2ff0079423cba36b6050d /ortho/mcode/ortho_code-x86-emits.adb
parenteb4d862a6b8ac3991dac9a8bc2fb0b9d9830e951 (diff)
downloadghdl-f63038518ec0b89eb6170e372a2ad5d0a24d30d3.tar.gz
ghdl-f63038518ec0b89eb6170e372a2ad5d0a24d30d3.tar.bz2
ghdl-f63038518ec0b89eb6170e372a2ad5d0a24d30d3.zip
Improve macosX support.
Fix crashes in error handling.
Diffstat (limited to 'ortho/mcode/ortho_code-x86-emits.adb')
-rw-r--r--ortho/mcode/ortho_code-x86-emits.adb10
1 files changed, 8 insertions, 2 deletions
diff --git a/ortho/mcode/ortho_code-x86-emits.adb b/ortho/mcode/ortho_code-x86-emits.adb
index 3f71f87..d64d096 100644
--- a/ortho/mcode/ortho_code-x86-emits.adb
+++ b/ortho/mcode/ortho_code-x86-emits.adb
@@ -1988,10 +1988,12 @@ package body Ortho_Code.X86.Emits is
use Binary_File;
use Interfaces;
use Ortho_Code.Flags;
+ use Ortho_Code.X86.Insns;
Sym : Symbol;
Subprg_Decl : O_Dnode;
Is_Global : Boolean;
Frame_Size : Unsigned_32;
+ Saved_Regs_Size : Unsigned_32;
begin
Set_Current_Section (Sect_Text);
Subprg_Decl := Subprg.D_Decl;
@@ -2007,14 +2009,18 @@ package body Ortho_Code.X86.Emits is
Set_Symbol_Pc (Sym, Is_Global);
Subprg_Pc := Get_Current_Pc;
+ Saved_Regs_Size := Boolean'Pos(Reg_Used (R_Di)) * 4
+ + Boolean'Pos(Reg_Used (R_Si)) * 4
+ + Boolean'Pos(Reg_Used (R_Bx)) * 4;
+
-- Compute frame size.
-- 8 bytes are used by return address and saved frame pointer.
- Frame_Size := Unsigned_32 (Subprg.Stack_Max) + 8;
+ Frame_Size := Unsigned_32 (Subprg.Stack_Max) + 8 + Saved_Regs_Size;
-- Align.
Frame_Size := (Frame_Size + X86.Flags.Stack_Boundary - 1)
and not (X86.Flags.Stack_Boundary - 1);
-- The 8 bytes are already allocated.
- Frame_Size := Frame_Size - 8;
+ Frame_Size := Frame_Size - 8 - Saved_Regs_Size;
-- Emit prolog.
-- push %ebp