summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--evaluation.adb6
-rw-r--r--ortho/mcode/memsegs_c.c4
-rw-r--r--ortho/mcode/ortho_code-x86-abi.ads2
-rw-r--r--ortho/mcode/ortho_code-x86-emits.adb10
-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.ads28
-rw-r--r--ortho/mcode/ortho_code-x86-flags_windows.ads28
-rw-r--r--sem_expr.adb6
-rw-r--r--translate/ghdldrv/Makefile16
-rw-r--r--translate/grt/config/linux.c4
-rw-r--r--translate/grt/grt-processes.adb3
-rw-r--r--translate/translation.adb4
-rw-r--r--types.ads5
-rw-r--r--version.ads2
14 files changed, 115 insertions, 11 deletions
diff --git a/evaluation.adb b/evaluation.adb
index 44d7b4f..495e59a 100644
--- a/evaluation.adb
+++ b/evaluation.adb
@@ -2020,6 +2020,10 @@ package body Evaluation is
-- Should check L <= R or L >= R according to direction.
--return Eval_Is_In_Bound (Get_Left_Limit (A_Range), Sub_Type)
-- and then Eval_Is_In_Bound (Get_Right_Limit (A_Range), Sub_Type);
+ exception
+ when Node_Error =>
+ -- Avoid error storms.
+ return True;
end Eval_Is_Range_In_Bound;
procedure Eval_Check_Range
@@ -2091,6 +2095,8 @@ package body Evaluation is
return Get_Physical_Value (Expr);
when Iir_Kind_Unit_Declaration =>
return Get_Value (Get_Physical_Unit_Value (Expr));
+ when Iir_Kind_Error =>
+ raise Node_Error;
when others =>
Error_Kind ("eval_pos", Expr);
end case;
diff --git a/ortho/mcode/memsegs_c.c b/ortho/mcode/memsegs_c.c
index c311423..f0a0e27 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 d130042..613e37b 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 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
diff --git a/ortho/mcode/ortho_code-x86-flags.ads b/ortho/mcode/ortho_code-x86-flags_linux.ads
index 699a38c..624c279 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 0000000..c753106
--- /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 0000000..a5ba579
--- /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;
diff --git a/sem_expr.adb b/sem_expr.adb
index 9131776..a0d88ee 100644
--- a/sem_expr.adb
+++ b/sem_expr.adb
@@ -168,7 +168,8 @@ package body Sem_Expr is
| Iir_Kind_Library_Clause
| Iir_Kind_Component_Declaration
| Iir_Kinds_Procedure_Declaration
- | Iir_Kind_Range_Array_Attribute =>
+ | Iir_Kind_Range_Array_Attribute
+ | Iir_Kind_Element_Declaration =>
Error_Msg_Sem (Disp_Node (Expr)
& " not allowed in an expression", Loc);
return Null_Iir;
@@ -2739,7 +2740,8 @@ package body Sem_Expr is
when Iir_Kind_String_Literal
| Iir_Kind_Bit_String_Literal =>
- Len := Sem_String_Literal (Aggr, Get_Element_Subtype (A_Type));
+ Len := Sem_String_Literal
+ (Aggr, Get_Base_Type (Get_Element_Subtype (A_Type)));
Assoc_Chain := Null_Iir;
Info.Min_Length := Integer'Max (Info.Min_Length, Len);
Is_Positional := True;
diff --git a/translate/ghdldrv/Makefile b/translate/ghdldrv/Makefile
index 3838f5c..9e9e1e0 100644
--- a/translate/ghdldrv/Makefile
+++ b/translate/ghdldrv/Makefile
@@ -36,8 +36,22 @@ target=i686-pc-linux-gnu
GRTSRCDIR=../grt
include $(GRTSRCDIR)/Makefile.inc
+ifeq ($(filter-out i%86 linux,$(arch) $(osys)),)
+ ORTHO_X86_FLAGS=Flags_Linux
+endif
+ifeq ($(filter-out i%86 darwin%,$(arch) $(osys)),)
+ ORTHO_X86_FLAGS=Flags_Macosx
+endif
+ifdef ORTHO_X86_FLAGS
+ ORTHO_DEPS=ortho_code-x86-flags.ads
+endif
+
+ortho_code-x86-flags.ads:
+ echo "with Ortho_Code.X86.$(ORTHO_X86_FLAGS);" > $@
+ echo "package Ortho_Code.X86.Flags renames Ortho_Code.X86.$(ORTHO_X86_FLAGS);" >> $@
+
ghdl_mcode: GRT_FLAGS+=-DWITH_GNAT_RUN_TIME
-ghdl_mcode: default_pathes.ads $(GRT_ADD_OBJS) memsegs_c.o chkstk.o force
+ghdl_mcode: default_pathes.ads $(GRT_ADD_OBJS) $(ORTHO_DEPS) memsegs_c.o chkstk.o force
gnatmake -aI../../ortho/mcode $(GNATFLAGS) ghdl_mcode $(GNAT_BARGS) -largs memsegs_c.o chkstk.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB))
memsegs_c.o: ../../ortho/mcode/memsegs_c.c
diff --git a/translate/grt/config/linux.c b/translate/grt/config/linux.c
index 6b73cb4..82df5b9 100644
--- a/translate/grt/config/linux.c
+++ b/translate/grt/config/linux.c
@@ -25,6 +25,10 @@
#include <stdlib.h>
//#include <stdint.h>
+#ifdef __APPLE__
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
/* On x86, the stack growns downward. */
#define STACK_GROWNS_DOWNWARD 1
diff --git a/translate/grt/grt-processes.adb b/translate/grt/grt-processes.adb
index d8d8a61..de76174 100644
--- a/translate/grt/grt-processes.adb
+++ b/translate/grt/grt-processes.adb
@@ -111,6 +111,9 @@ package body Grt.Processes is
begin
if State /= State_Sensitized then
Stack := Stack_Create (Proc, This);
+ if Stack = Null_Stack then
+ Internal_Error ("cannot allocate stack: memory exhausted");
+ end if;
else
Stack := Null_Stack;
end if;
diff --git a/translate/translation.adb b/translate/translation.adb
index 8ce7e0f..4a6d39a 100644
--- a/translate/translation.adb
+++ b/translate/translation.adb
@@ -11047,6 +11047,10 @@ package body Translation is
Push_Identifier_Prefix
(Mark3, Get_Identifier (Get_Base_Name (Formal)));
+ if Is_Anonymous_Type_Definition (In_Type) then
+ In_Type := Get_Base_Type (In_Type);
+ end if;
+
Out_Info := Get_Info (Out_Type);
In_Info := Get_Info (In_Type);
diff --git a/types.ads b/types.ads
index 9cfce90..191d30e 100644
--- a/types.ads
+++ b/types.ads
@@ -121,4 +121,9 @@ package Types is
-- Self-explaining: raised when an internal error (such as consistency)
-- is detected.
Internal_Error: exception;
+
+ -- In some case, a low level subprogram can't handle error
+ -- (e.g eval_pos). In this case it is easier to raise an exception and
+ -- let upper level subprograms handle the case.
+ Node_Error : exception;
end Types;
diff --git a/version.ads b/version.ads
index d71a40e..f8c6806 100644
--- a/version.ads
+++ b/version.ads
@@ -1,5 +1,5 @@
package Version is
Ghdl_Release : constant String :=
- "GHDL 0.26 (20070408) [Sokcho edition]";
+ "GHDL 0.26dev (20070408) [Sokcho edition]";
Ghdl_Ver : constant String := "0.26";
end Version;