diff options
-rw-r--r-- | ortho/debug/ortho_debug.private.ads | 3 | ||||
-rw-r--r-- | ortho/gcc/ortho_gcc.ads | 5 | ||||
-rw-r--r-- | ortho/gcc/ortho_gcc.private.ads | 3 | ||||
-rw-r--r-- | ortho/llvm/Makefile | 6 | ||||
-rw-r--r-- | ortho/llvm/ortho_llvm.ads | 5 | ||||
-rw-r--r-- | ortho/llvm/ortho_llvm.private.ads | 3 | ||||
-rw-r--r-- | ortho/mcode/Makefile | 2 | ||||
-rw-r--r-- | ortho/mcode/ortho_mcode.ads | 6 | ||||
-rw-r--r-- | ortho/mcode/ortho_mcode.private.ads | 4 | ||||
-rw-r--r-- | ortho/ortho_nodes.common.ads | 2 | ||||
-rw-r--r-- | translate/translation.adb | 10 | ||||
-rw-r--r-- | translate/translation.ads | 2 |
12 files changed, 43 insertions, 8 deletions
diff --git a/ortho/debug/ortho_debug.private.ads b/ortho/debug/ortho_debug.private.ads index 98424ef..69ee16c 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 6e46b6d..0afdc08 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 2752651..cc2f556 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 2a4d7bd..135dbdf 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 30245b8..206188f 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 976de00..30b86a4 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 2970d60..19d5d26 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 1ee9d7e..45e8036 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 5d3f70e..1b41477 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 bd573c0..1781874 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 908d819..0d9e8bf 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 bcaec62..e779685 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, |