aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-03-09 07:05:34 +0100
committerTristan Gingold <tgingold@free.fr>2014-03-09 07:05:34 +0100
commit6a8dd0ee9bd3ec2ffe6ff7fa821af92968008e55 (patch)
tree4dacb60b5a1e11f29a7fd1c279471ac2be6a0698
parentf1cbfa0165ced1fc75f8fea817b0e8e3bcfe6b47 (diff)
downloadghdl-6a8dd0ee9bd3ec2ffe6ff7fa821af92968008e55.tar.gz
ghdl-6a8dd0ee9bd3ec2ffe6ff7fa821af92968008e55.tar.bz2
ghdl-6a8dd0ee9bd3ec2ffe6ff7fa821af92968008e55.zip
Automatically unnest subprograms for llvm.
-rw-r--r--ortho/debug/ortho_debug.private.ads3
-rw-r--r--ortho/gcc/ortho_gcc.ads5
-rw-r--r--ortho/gcc/ortho_gcc.private.ads3
-rw-r--r--ortho/llvm/Makefile6
-rw-r--r--ortho/llvm/ortho_llvm.ads5
-rw-r--r--ortho/llvm/ortho_llvm.private.ads3
-rw-r--r--ortho/mcode/Makefile2
-rw-r--r--ortho/mcode/ortho_mcode.ads6
-rw-r--r--ortho/mcode/ortho_mcode.private.ads4
-rw-r--r--ortho/ortho_nodes.common.ads2
-rw-r--r--translate/translation.adb10
-rw-r--r--translate/translation.ads2
12 files changed, 43 insertions, 8 deletions
diff --git a/ortho/debug/ortho_debug.private.ads b/ortho/debug/ortho_debug.private.ads
index 98424efdf..69ee16cf7 100644
--- a/ortho/debug/ortho_debug.private.ads
+++ b/ortho/debug/ortho_debug.private.ads
@@ -26,6 +26,9 @@ package Ortho_Debug is
procedure Finish;
private
+ -- This back-end supports nested subprograms.
+ Has_Nested_Subprograms : constant Boolean := True;
+
-- A node for a type.
type O_Tnode_Type (<>);
type O_Tnode is access O_Tnode_Type;
diff --git a/ortho/gcc/ortho_gcc.ads b/ortho/gcc/ortho_gcc.ads
index 6e46b6ddf..0afdc0887 100644
--- a/ortho/gcc/ortho_gcc.ads
+++ b/ortho/gcc/ortho_gcc.ads
@@ -44,6 +44,8 @@ package Ortho_Gcc is
O_Snode_Null : constant O_Snode;
O_Tnode_Null : constant O_Tnode;
+ -- True if the code generated supports nested subprograms.
+ Has_Nested_Subprograms : constant Boolean;
------------------------
-- Type definitions --
@@ -454,6 +456,9 @@ package Ortho_Gcc is
-- End of common part
private
+ -- GCC supports nested subprograms.
+ Has_Nested_Subprograms : constant Boolean := True;
+
pragma Convention (C, O_Storage);
-- pragma Convention (C, ON_Op_Kind);
diff --git a/ortho/gcc/ortho_gcc.private.ads b/ortho/gcc/ortho_gcc.private.ads
index 27526517a..cc2f556f0 100644
--- a/ortho/gcc/ortho_gcc.private.ads
+++ b/ortho/gcc/ortho_gcc.private.ads
@@ -24,6 +24,9 @@ use Ortho_Ident;
package Ortho_Gcc is
private
+ -- GCC supports nested subprograms.
+ Has_Nested_Subprograms : constant Boolean := True;
+
pragma Convention (C, O_Storage);
-- pragma Convention (C, ON_Op_Kind);
diff --git a/ortho/llvm/Makefile b/ortho/llvm/Makefile
index 2a4d7bd21..135dbdf4b 100644
--- a/ortho/llvm/Makefile
+++ b/ortho/llvm/Makefile
@@ -1,6 +1,6 @@
ortho_srcdir=..
-GNAT_FLAGS=-gnaty3befhkmr -gnata -gnatf -gnatwael
-CC=clang
+GNAT_FLAGS=-gnaty3befhkmr -gnata -gnatf -gnatwael -gnat05
+CXX=clang++ --std=c++11
LLVM_CONFIG=llvm-config
SED=sed
BE=llvm
@@ -13,7 +13,7 @@ $(ortho_exec): $(ortho_srcdir)/llvm/ortho_llvm.ads force llvm-cbindings.o
-largs llvm-cbindings.o `$(LLVM_CONFIG) --ldflags --libs --system-libs` -lc++ #-static
llvm-cbindings.o: $(ortho_srcdir)/llvm/llvm-cbindings.cpp
- $(CC) -c -I`$(LLVM_CONFIG) --includedir --cflags` -g -o $@ $<
+ $(CXX) -c -I`$(LLVM_CONFIG) --includedir --cflags` -g -o $@ $<
clean:
$(RM) -f *.o *.ali ortho_code_main
diff --git a/ortho/llvm/ortho_llvm.ads b/ortho/llvm/ortho_llvm.ads
index 30245b833..206188fb6 100644
--- a/ortho/llvm/ortho_llvm.ads
+++ b/ortho/llvm/ortho_llvm.ads
@@ -47,6 +47,8 @@ package Ortho_LLVM is
O_Snode_Null : constant O_Snode;
O_Tnode_Null : constant O_Tnode;
+ -- True if the code generated supports nested subprograms.
+ Has_Nested_Subprograms : constant Boolean;
------------------------
-- Type definitions --
@@ -457,6 +459,9 @@ package Ortho_LLVM is
-- End of common part
private
+ -- No support for nested subprograms in LLVM.
+ Has_Nested_Subprograms : constant Boolean := False;
+
use LLVM.Core;
type O_Tnode_Type (<>);
diff --git a/ortho/llvm/ortho_llvm.private.ads b/ortho/llvm/ortho_llvm.private.ads
index 976de00e1..30b86a447 100644
--- a/ortho/llvm/ortho_llvm.private.ads
+++ b/ortho/llvm/ortho_llvm.private.ads
@@ -27,6 +27,9 @@ package Ortho_LLVM is
procedure Finish_Debug;
private
+ -- No support for nested subprograms in LLVM.
+ Has_Nested_Subprograms : constant Boolean := False;
+
use LLVM.Core;
type O_Tnode_Type (<>);
diff --git a/ortho/mcode/Makefile b/ortho/mcode/Makefile
index 2970d600a..19d5d26aa 100644
--- a/ortho/mcode/Makefile
+++ b/ortho/mcode/Makefile
@@ -1,5 +1,5 @@
ortho_srcdir=..
-GNAT_FLAGS=-gnaty3befhkmr -gnata -gnatf -gnatwlcru
+GNAT_FLAGS=-gnaty3befhkmr -gnata -gnatf -gnatwlcru -gnat05
CC=gcc
BE=mcode
SED=sed
diff --git a/ortho/mcode/ortho_mcode.ads b/ortho/mcode/ortho_mcode.ads
index 1ee9d7e50..45e803690 100644
--- a/ortho/mcode/ortho_mcode.ads
+++ b/ortho/mcode/ortho_mcode.ads
@@ -51,6 +51,8 @@ package Ortho_Mcode is
O_Snode_Null : constant O_Snode;
O_Tnode_Null : constant O_Tnode;
+ -- True if the code generated supports nested subprograms.
+ Has_Nested_Subprograms : constant Boolean;
------------------------
-- Type definitions --
@@ -461,7 +463,9 @@ package Ortho_Mcode is
-- End of common part
private
- --- PUBLIC DECLARATIONS
+ -- MCode supports nested subprograms.
+ Has_Nested_Subprograms : constant Boolean := True;
+
type O_Tnode is new Ortho_Code.O_Tnode;
type O_Cnode is new Ortho_Code.O_Cnode;
type O_Dnode is new Ortho_Code.O_Dnode;
diff --git a/ortho/mcode/ortho_mcode.private.ads b/ortho/mcode/ortho_mcode.private.ads
index 5d3f70efc..1b414773f 100644
--- a/ortho/mcode/ortho_mcode.private.ads
+++ b/ortho/mcode/ortho_mcode.private.ads
@@ -31,7 +31,9 @@ package Ortho_Mcode is
procedure Free_All;
private
- --- PUBLIC DECLARATIONS
+ -- MCode supports nested subprograms.
+ Has_Nested_Subprograms : constant Boolean := True;
+
type O_Tnode is new Ortho_Code.O_Tnode;
type O_Cnode is new Ortho_Code.O_Cnode;
type O_Dnode is new Ortho_Code.O_Dnode;
diff --git a/ortho/ortho_nodes.common.ads b/ortho/ortho_nodes.common.ads
index bd573c0e9..178187482 100644
--- a/ortho/ortho_nodes.common.ads
+++ b/ortho/ortho_nodes.common.ads
@@ -38,6 +38,8 @@ package ORTHO_NODES is
O_Snode_Null : constant O_Snode;
O_Tnode_Null : constant O_Tnode;
+ -- True if the code generated supports nested subprograms.
+ Has_Nested_Subprograms : constant Boolean;
------------------------
-- Type definitions --
diff --git a/translate/translation.adb b/translate/translation.adb
index 908d8199d..0d9e8bf32 100644
--- a/translate/translation.adb
+++ b/translate/translation.adb
@@ -28201,12 +28201,18 @@ package body Translation is
Interfaces : O_Inter_List;
Param : O_Dnode;
begin
+ -- Create the node extension for translate.
Node_Infos.Init;
Node_Infos.Set_Last (4);
Node_Infos.Table (0 .. 4) := (others => null);
+
+ -- Force to unnest subprograms is the code generator doesn't support
+ -- nested subprograms.
+ if not Ortho_Nodes.Has_Nested_Subprograms then
+ Flag_Unnest_Subprograms := True;
+ end if;
+
New_Debug_Comment_Decl ("internal declarations, part 1");
- -- Give a name to sizetype.
- --Finish_Type_Decl (Sizetype, Get_Identifier ("__ghdl_size_t"));
-- Create well known identifiers.
Wki_This := Get_Identifier ("this");
diff --git a/translate/translation.ads b/translate/translation.ads
index bcaec623a..e779685f2 100644
--- a/translate/translation.ads
+++ b/translate/translation.ads
@@ -77,6 +77,8 @@ package Translation is
Flag_Discard_Identifiers : Boolean := False;
-- If true, do not create nested subprograms.
+ -- This flag is forced during initialization if the code generated doesn't
+ -- support nested subprograms.
Flag_Unnest_Subprograms : Boolean := False;
type Foreign_Kind_Type is (Foreign_Unknown,