aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-sem_inst.ads
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-05-05 07:18:49 +0200
committerTristan Gingold <tgingold@free.fr>2019-05-05 08:05:10 +0200
commit53fcf00d88d1a3b34c7833aa4c421ea52f3e03dd (patch)
tree1d54f41e948b16a5ff6ad0cedafccf978a13bd89 /src/vhdl/vhdl-sem_inst.ads
parentd1f0fedf7882cf1b15ea6450da5bbd878d007a98 (diff)
downloadghdl-53fcf00d88d1a3b34c7833aa4c421ea52f3e03dd.tar.gz
ghdl-53fcf00d88d1a3b34c7833aa4c421ea52f3e03dd.tar.bz2
ghdl-53fcf00d88d1a3b34c7833aa4c421ea52f3e03dd.zip
vhdl: move sem* packages to vhdl children.
Diffstat (limited to 'src/vhdl/vhdl-sem_inst.ads')
-rw-r--r--src/vhdl/vhdl-sem_inst.ads36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-sem_inst.ads b/src/vhdl/vhdl-sem_inst.ads
new file mode 100644
index 000000000..48d72b770
--- /dev/null
+++ b/src/vhdl/vhdl-sem_inst.ads
@@ -0,0 +1,36 @@
+-- Package (and subprograms) instantiations
+
+-- When a package is instantiated, we need to 'duplicate' its declaration.
+-- This looks useless for analysis but it isn't: a type from a package
+-- instantiated twice declares two different types. Without duplication, we
+-- need to attach to each declaration its instance, which looks more expansive
+-- that duplicating the declaration.
+--
+-- Furthermore, for generic type interface, it looks a good idea to duplicate
+-- the body (macro expansion).
+--
+-- Duplicating is not trivial: internal links must be kept and external
+-- links preserved. A table is used to map nodes from the uninstantiated
+-- package to its duplicated node. Links from instantiated declaration to
+-- the original declaration are also stored in that table.
+
+with Iirs; use Iirs;
+
+package Vhdl.Sem_Inst is
+ -- Return the origin of node N, the node from which N was instantiated.
+ -- If N is not an instance, this function returns Null_Iir.
+ function Get_Origin (N : Iir) return Iir;
+
+ -- Create declaration chain and generic declarations for INST from PKG.
+ procedure Instantiate_Package_Declaration (Inst : Iir; Pkg : Iir);
+
+ -- Return the instantiation of the body for INST, ie macro-expand the
+ -- body. INST has the form of a generic-mapped package.
+ function Instantiate_Package_Body (Inst : Iir) return Iir;
+
+ -- In CHAIN, substitute all references to E by REP.
+ procedure Substitute_On_Chain (Chain : Iir; E : Iir; Rep : Iir);
+
+ -- Deep copy of ORIG. Doesn't change location.
+ function Copy_Tree (Orig : Iir) return Iir;
+end Vhdl.Sem_Inst;