aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2023-01-31 19:01:49 +0100
committerTristan Gingold <tgingold@free.fr>2023-01-31 20:27:02 +0100
commit2b465653949cfa20e198a10e261307e7842acd1a (patch)
treee5edb1afd6703a417abc773a425258b9d41dd99a /src
parentf6711c34b332f3c3f6076fe8dec64f64638428dc (diff)
downloadghdl-2b465653949cfa20e198a10e261307e7842acd1a.tar.gz
ghdl-2b465653949cfa20e198a10e261307e7842acd1a.tar.bz2
ghdl-2b465653949cfa20e198a10e261307e7842acd1a.zip
translate: add a flag to disable elaboration
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/translate/trans-chap1.adb222
-rw-r--r--src/vhdl/translate/trans-chap9.adb6
-rw-r--r--src/vhdl/translate/translation.ads3
3 files changed, 125 insertions, 106 deletions
diff --git a/src/vhdl/translate/trans-chap1.adb b/src/vhdl/translate/trans-chap1.adb
index 8991f70a0..c3d727295 100644
--- a/src/vhdl/translate/trans-chap1.adb
+++ b/src/vhdl/translate/trans-chap1.adb
@@ -143,17 +143,21 @@ package body Trans.Chap1 is
Prev_Subprg_Instance);
-- Entity elaborator.
- for K in Elab_Kind loop
- Start_Procedure_Decl
- (Interface_List, Create_Elab_Identifier (K), Global_Storage);
- Subprgs.Add_Subprg_Instance_Interfaces (Interface_List, Instance (K));
- Finish_Subprogram_Decl (Interface_List, Info.Block_Elab_Subprg (K));
- end loop;
+ if Flag_Elaboration then
+ for K in Elab_Kind loop
+ Start_Procedure_Decl
+ (Interface_List, Create_Elab_Identifier (K), Global_Storage);
+ Subprgs.Add_Subprg_Instance_Interfaces
+ (Interface_List, Instance (K));
+ Finish_Subprogram_Decl
+ (Interface_List, Info.Block_Elab_Subprg (K));
+ end loop;
- -- Entity dependences elaborator.
- Start_Procedure_Decl (Interface_List, Create_Identifier ("PKG_ELAB"),
- Global_Storage);
- Finish_Subprogram_Decl (Interface_List, Info.Block_Elab_Pkg_Subprg);
+ -- Entity dependences elaborator.
+ Start_Procedure_Decl (Interface_List, Create_Identifier ("PKG_ELAB"),
+ Global_Storage);
+ Finish_Subprogram_Decl (Interface_List, Info.Block_Elab_Pkg_Subprg);
+ end if;
-- Generate RTI.
if Flag_Rti then
@@ -169,31 +173,33 @@ package body Trans.Chap1 is
-- Entity declaration and process subprograms.
Chap9.Translate_Block_Subprograms (Entity, Entity);
- -- Package elaborator Body.
- Start_Subprogram_Body (Info.Block_Elab_Pkg_Subprg);
- Push_Local_Factory;
- New_Debug_Line_Stmt (Get_Line_Number (Entity));
- Chap2.Elab_Dependence (Get_Design_Unit (Entity));
- Pop_Local_Factory;
- Finish_Subprogram_Body;
-
- -- Elaborator Body.
- for K in Elab_Kind loop
- Start_Subprogram_Body (Info.Block_Elab_Subprg (K));
+ if Flag_Elaboration then
+ -- Package elaborator Body.
+ Start_Subprogram_Body (Info.Block_Elab_Pkg_Subprg);
Push_Local_Factory;
- Subprgs.Start_Subprg_Instance_Use (Instance (K));
New_Debug_Line_Stmt (Get_Line_Number (Entity));
-
- case K is
- when Elab_Decls =>
- Chap9.Elab_Block_Declarations (Entity, Entity);
- when Elab_Stmts =>
- Chap9.Elab_Block_Statements (Entity, Entity);
- end case;
- Subprgs.Finish_Subprg_Instance_Use (Instance (K));
+ Chap2.Elab_Dependence (Get_Design_Unit (Entity));
Pop_Local_Factory;
Finish_Subprogram_Body;
- end loop;
+
+ -- Elaborator Body.
+ for K in Elab_Kind loop
+ Start_Subprogram_Body (Info.Block_Elab_Subprg (K));
+ Push_Local_Factory;
+ Subprgs.Start_Subprg_Instance_Use (Instance (K));
+ New_Debug_Line_Stmt (Get_Line_Number (Entity));
+
+ case K is
+ when Elab_Decls =>
+ Chap9.Elab_Block_Declarations (Entity, Entity);
+ when Elab_Stmts =>
+ Chap9.Elab_Block_Statements (Entity, Entity);
+ end case;
+ Subprgs.Finish_Subprg_Instance_Use (Instance (K));
+ Pop_Local_Factory;
+ Finish_Subprogram_Body;
+ end loop;
+ end if;
end if;
Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance);
end Translate_Entity_Declaration;
@@ -263,14 +269,17 @@ package body Trans.Chap1 is
end if;
-- Elaborator.
- for K in Elab_Kind loop
- Start_Procedure_Decl
- (Interface_List, Create_Elab_Identifier (K), Global_Storage);
- New_Interface_Decl
- (Interface_List, Instance (K), Wki_Instance,
- Entity_Info.Block_Decls_Ptr_Type);
- Finish_Subprogram_Decl (Interface_List, Info.Block_Elab_Subprg (K));
- end loop;
+ if Flag_Elaboration then
+ for K in Elab_Kind loop
+ Start_Procedure_Decl
+ (Interface_List, Create_Elab_Identifier (K), Global_Storage);
+ New_Interface_Decl
+ (Interface_List, Instance (K), Wki_Instance,
+ Entity_Info.Block_Decls_Ptr_Type);
+ Finish_Subprogram_Decl
+ (Interface_List, Info.Block_Elab_Subprg (K));
+ end loop;
+ end if;
-- Generate RTI.
if Flag_Rti then
@@ -278,26 +287,28 @@ package body Trans.Chap1 is
end if;
-- Default configuration
- declare
- Default_Config : constant Iir :=
- Get_Default_Configuration_Declaration (Arch);
- Config_Mark : Id_Mark_Type;
- begin
- -- In case of direct and recursive instantiation, the default
- -- configuration may be needed while translating the architecture.
- -- So translate the declarations of the default configuration before
- -- translating the architecture.
- if Default_Config /= Null_Iir
- and then Get_Configuration_Done_Flag (Default_Config)
- then
- Push_Identifier_Prefix
- (Config_Mark, Name_Table.Get_Identifier ("DEFAULT_CONFIG"));
- Translate_Configuration_Declaration_Decl
- (Get_Library_Unit
- (Get_Default_Configuration_Declaration (Arch)));
- Pop_Identifier_Prefix (Config_Mark);
- end if;
- end;
+ if Flag_Elaboration then
+ declare
+ Default_Config : constant Iir :=
+ Get_Default_Configuration_Declaration (Arch);
+ Config_Mark : Id_Mark_Type;
+ begin
+ -- In case of direct and recursive instantiation, the default
+ -- configuration may be needed while translating the architecture.
+ -- So translate the declarations of the default configuration
+ -- before translating the architecture.
+ if Default_Config /= Null_Iir
+ and then Get_Configuration_Done_Flag (Default_Config)
+ then
+ Push_Identifier_Prefix
+ (Config_Mark, Name_Table.Get_Identifier ("DEFAULT_CONFIG"));
+ Translate_Configuration_Declaration_Decl
+ (Get_Library_Unit
+ (Get_Default_Configuration_Declaration (Arch)));
+ Pop_Identifier_Prefix (Config_Mark);
+ end if;
+ end;
+ end if;
if Global_Storage = O_Storage_External then
return;
@@ -318,57 +329,60 @@ package body Trans.Chap1 is
Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance);
-- Elaborator body.
- for K in Elab_Kind loop
- Start_Subprogram_Body (Info.Block_Elab_Subprg (K));
- Push_Local_Factory;
-
- -- Create a variable for the architecture instance (with the right
- -- type, instead of the entity instance type).
- New_Var_Decl (Var_Arch_Instance, Wki_Arch_Instance,
- O_Storage_Local, Info.Block_Decls_Ptr_Type);
- New_Assign_Stmt
- (New_Obj (Var_Arch_Instance),
- New_Convert_Ov (New_Value (New_Obj (Instance (K))),
- Info.Block_Decls_Ptr_Type));
-
- case K is
- when Elab_Decls =>
- -- Set RTI.
- if Flag_Rti then
- New_Assign_Stmt
- (New_Selected_Element
- (New_Selected_Acc_Value (New_Obj (Instance (K)),
- Entity_Info.Block_Link_Field),
- Rtis.Ghdl_Entity_Link_Rti),
- New_Unchecked_Address (New_Obj (Info.Block_Rti_Const),
- Rtis.Ghdl_Rti_Access));
- end if;
- when Elab_Stmts =>
- null;
- end case;
+ if Flag_Elaboration then
+ for K in Elab_Kind loop
+ Start_Subprogram_Body (Info.Block_Elab_Subprg (K));
+ Push_Local_Factory;
+
+ -- Create a variable for the architecture instance (with the right
+ -- type, instead of the entity instance type).
+ New_Var_Decl (Var_Arch_Instance, Wki_Arch_Instance,
+ O_Storage_Local, Info.Block_Decls_Ptr_Type);
+ New_Assign_Stmt
+ (New_Obj (Var_Arch_Instance),
+ New_Convert_Ov (New_Value (New_Obj (Instance (K))),
+ Info.Block_Decls_Ptr_Type));
+
+ case K is
+ when Elab_Decls =>
+ -- Set RTI.
+ if Flag_Rti then
+ New_Assign_Stmt
+ (New_Selected_Element
+ (New_Selected_Acc_Value
+ (New_Obj (Instance (K)),
+ Entity_Info.Block_Link_Field),
+ Rtis.Ghdl_Entity_Link_Rti),
+ New_Unchecked_Address (New_Obj (Info.Block_Rti_Const),
+ Rtis.Ghdl_Rti_Access));
+ end if;
+ when Elab_Stmts =>
+ null;
+ end case;
- -- Call entity elaborators.
- Start_Association (Constr, Entity_Info.Block_Elab_Subprg (K));
- New_Association (Constr, New_Value (New_Obj (Instance (K))));
- New_Procedure_Call (Constr);
+ -- Call entity elaborators.
+ Start_Association (Constr, Entity_Info.Block_Elab_Subprg (K));
+ New_Association (Constr, New_Value (New_Obj (Instance (K))));
+ New_Procedure_Call (Constr);
- Push_Architecture_Scope (Arch, Var_Arch_Instance);
+ Push_Architecture_Scope (Arch, Var_Arch_Instance);
- New_Debug_Line_Stmt (Get_Line_Number (Arch));
+ New_Debug_Line_Stmt (Get_Line_Number (Arch));
- case K is
- when Elab_Decls =>
- Chap2.Elab_Dependence (Get_Design_Unit (Arch));
- Chap9.Elab_Block_Declarations (Arch, Arch);
- when Elab_Stmts =>
- Chap9.Elab_Block_Statements (Arch, Arch);
- end case;
+ case K is
+ when Elab_Decls =>
+ Chap2.Elab_Dependence (Get_Design_Unit (Arch));
+ Chap9.Elab_Block_Declarations (Arch, Arch);
+ when Elab_Stmts =>
+ Chap9.Elab_Block_Statements (Arch, Arch);
+ end case;
- Pop_Architecture_Scope (Arch);
+ Pop_Architecture_Scope (Arch);
- Pop_Local_Factory;
- Finish_Subprogram_Body;
- end loop;
+ Pop_Local_Factory;
+ Finish_Subprogram_Body;
+ end loop;
+ end if;
end Translate_Architecture_Body;
procedure Translate_Component_Configuration_Decl
diff --git a/src/vhdl/translate/trans-chap9.adb b/src/vhdl/translate/trans-chap9.adb
index 95c8db11c..b1c7205a7 100644
--- a/src/vhdl/translate/trans-chap9.adb
+++ b/src/vhdl/translate/trans-chap9.adb
@@ -1325,8 +1325,10 @@ package body Trans.Chap9 is
(Stmt, Block, Base_Block,
Get_Entity_From_Entity_Aspect
(Get_Instantiated_Unit (Stmt)));
- Translate_Component_Instantiation_Subprogram
- (Stmt, Base_Info);
+ if Flag_Elaboration then
+ Translate_Component_Instantiation_Subprogram
+ (Stmt, Base_Info);
+ end if;
when Iir_Kind_Block_Statement =>
declare
Guard : constant Iir := Get_Guard_Decl (Stmt);
diff --git a/src/vhdl/translate/translation.ads b/src/vhdl/translate/translation.ads
index 376060dfd..9f85a616d 100644
--- a/src/vhdl/translate/translation.ads
+++ b/src/vhdl/translate/translation.ads
@@ -78,6 +78,9 @@ package Translation is
-- defined by the value.
Flag_Check_Stack_Allocation : Natural := 32 * 1024;
+ -- If true, generate subprograms for design elaboration.
+ Flag_Elaboration : Boolean := True;
+
procedure Register_Translation_Back_End;
-- If not null, this procedure is called when a foreign subprogram is