diff options
author | gingold <gingold@b72b5c32-5f01-0410-b925-b5c7b92870f7> | 2008-04-09 04:01:16 +0000 |
---|---|---|
committer | gingold <gingold@b72b5c32-5f01-0410-b925-b5c7b92870f7> | 2008-04-09 04:01:16 +0000 |
commit | f63038518ec0b89eb6170e372a2ad5d0a24d30d3 (patch) | |
tree | c2155355116acf3f90a2ff0079423cba36b6050d /ortho | |
parent | eb4d862a6b8ac3991dac9a8bc2fb0b9d9830e951 (diff) | |
download | ghdl-f63038518ec0b89eb6170e372a2ad5d0a24d30d3.tar.gz ghdl-f63038518ec0b89eb6170e372a2ad5d0a24d30d3.tar.bz2 ghdl-f63038518ec0b89eb6170e372a2ad5d0a24d30d3.zip |
Improve macosX support.
Fix crashes in error handling.
Diffstat (limited to 'ortho')
-rw-r--r-- | ortho/mcode/memsegs_c.c | 4 | ||||
-rw-r--r-- | ortho/mcode/ortho_code-x86-abi.ads | 2 | ||||
-rw-r--r-- | ortho/mcode/ortho_code-x86-emits.adb | 10 | ||||
-rw-r--r-- | ortho/mcode/ortho_code-x86-flags_linux.ads (renamed from ortho/mcode/ortho_code-x86-flags.ads) | 8 | ||||
-rw-r--r-- | ortho/mcode/ortho_code-x86-flags_macosx.ads | 28 | ||||
-rw-r--r-- | ortho/mcode/ortho_code-x86-flags_windows.ads | 28 |
6 files changed, 73 insertions, 7 deletions
diff --git a/ortho/mcode/memsegs_c.c b/ortho/mcode/memsegs_c.c index c3114230b..f0a0e27d5 100644 --- a/ortho/mcode/memsegs_c.c +++ b/ortho/mcode/memsegs_c.c @@ -34,6 +34,10 @@ #define HAVE_MREMAP #endif +#ifndef HAVE_MREMAP +#include <string.h> +#endif + void * mmap_malloc (int size) { diff --git a/ortho/mcode/ortho_code-x86-abi.ads b/ortho/mcode/ortho_code-x86-abi.ads index d13004295..613e37b2c 100644 --- a/ortho/mcode/ortho_code-x86-abi.ads +++ b/ortho/mcode/ortho_code-x86-abi.ads @@ -34,7 +34,7 @@ package Ortho_Code.X86.Abi is Mode_B2 => 0); Mode_Ptr : constant Mode_Type := Mode_P32; - + -- Procedures to layout a subprogram declaration. procedure Start_Subprogram (Subprg : O_Dnode; Abi : out O_Abi_Subprg); procedure New_Interface (Inter : O_Dnode; Abi : in out O_Abi_Subprg); diff --git a/ortho/mcode/ortho_code-x86-emits.adb b/ortho/mcode/ortho_code-x86-emits.adb index 3f71f8709..d64d0967b 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 diff --git a/ortho/mcode/ortho_code-x86-flags.ads b/ortho/mcode/ortho_code-x86-flags_linux.ads index 699a38c9e..624c27985 100644 --- a/ortho/mcode/ortho_code-x86-flags.ads +++ b/ortho/mcode/ortho_code-x86-flags_linux.ads @@ -17,12 +17,12 @@ -- 02111-1307, USA. with Interfaces; use Interfaces; -package Ortho_Code.X86.Flags is +package Ortho_Code.X86.Flags_Linux is -- If true, OE_Alloca calls __chkstk (Windows), otherwise OE_Alloc -- modifies ESP directly. - Flag_Alloca_Call : Boolean := False; + Flag_Alloca_Call : constant Boolean := False; -- Prefered stack alignment. -- Must be a power of 2. - Stack_Boundary : Unsigned_32 := 2 ** 3; -- 4 for MacOSX, 3 for Linux -end Ortho_Code.X86.Flags; + Stack_Boundary : constant Unsigned_32 := 2 ** 3; +end Ortho_Code.X86.Flags_Linux; diff --git a/ortho/mcode/ortho_code-x86-flags_macosx.ads b/ortho/mcode/ortho_code-x86-flags_macosx.ads new file mode 100644 index 000000000..c7531065a --- /dev/null +++ b/ortho/mcode/ortho_code-x86-flags_macosx.ads @@ -0,0 +1,28 @@ +-- X86 ABI flags. +-- Copyright (C) 2006 Tristan Gingold +-- +-- GHDL is free software; you can redistribute it and/or modify it under +-- the terms of the GNU General Public License as published by the Free +-- Software Foundation; either version 2, or (at your option) any later +-- version. +-- +-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or +-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-- for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +with Interfaces; use Interfaces; + +package Ortho_Code.X86.Flags_Macosx is + -- If true, OE_Alloca calls __chkstk (Windows), otherwise OE_Alloc + -- modifies ESP directly. + Flag_Alloca_Call : constant Boolean := False; + + -- Prefered stack alignment. + -- Must be a power of 2. + Stack_Boundary : constant Unsigned_32 := 2 ** 4; +end Ortho_Code.X86.Flags_Macosx; diff --git a/ortho/mcode/ortho_code-x86-flags_windows.ads b/ortho/mcode/ortho_code-x86-flags_windows.ads new file mode 100644 index 000000000..a5ba57957 --- /dev/null +++ b/ortho/mcode/ortho_code-x86-flags_windows.ads @@ -0,0 +1,28 @@ +-- X86 ABI flags. +-- Copyright (C) 2006 Tristan Gingold +-- +-- GHDL is free software; you can redistribute it and/or modify it under +-- the terms of the GNU General Public License as published by the Free +-- Software Foundation; either version 2, or (at your option) any later +-- version. +-- +-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or +-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-- for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +with Interfaces; use Interfaces; + +package Ortho_Code.X86.Flags_Windows is + -- If true, OE_Alloca calls __chkstk (Windows), otherwise OE_Alloc + -- modifies ESP directly. + Flag_Alloca_Call : constant Boolean := True; + + -- Prefered stack alignment. + -- Must be a power of 2. + Stack_Boundary : constant Unsigned_32 := 2 ** 3; +end Ortho_Code.X86.Flags_Windows; |