diff options
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/vhdl-utils.adb | 29 | ||||
-rw-r--r-- | src/vhdl/vhdl-utils.ads | 4 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-utils.adb b/src/vhdl/vhdl-utils.adb index 6bd200cc3..e3e04cfe8 100644 --- a/src/vhdl/vhdl-utils.adb +++ b/src/vhdl/vhdl-utils.adb @@ -1323,6 +1323,35 @@ package body Vhdl.Utils is end case; end Get_Nature_Of_Subnature_Indication; + function Is_Owned_Subtype_Indication (Decl : Iir) return Boolean + is + Def : Iir; + begin + -- Subtype indication is shared with a previous declaration, like in: + -- signal a, b : std_logic_vector (7 downto 0); + if Get_Is_Ref (Decl) then + return False; + end if; + + Def := Get_Subtype_Indication (Decl); + -- Implicit functions don't have subtype indication. + -- TODO: make them regular ? + if Def = Null_Iir then + return False; + end if; + + case Get_Kind (Def) is + when Iir_Kinds_Subtype_Definition => + return True; + when Iir_Kinds_Denoting_Name + | Iir_Kind_Element_Attribute + | Iir_Kind_Subtype_Attribute => + return False; + when others => + Error_Kind ("is_owned_subtype_indication", Def); + end case; + end Is_Owned_Subtype_Indication; + function Get_Index_Type (Indexes : Iir_Flist; Idx : Natural) return Iir is Index : constant Iir := Get_Nth_Element (Indexes, Idx); diff --git a/src/vhdl/vhdl-utils.ads b/src/vhdl/vhdl-utils.ads index 8cce0eb14..5cdef0daa 100644 --- a/src/vhdl/vhdl-utils.ads +++ b/src/vhdl/vhdl-utils.ads @@ -258,6 +258,10 @@ package Vhdl.Utils is -- skip over denoting names. function Get_Type_Of_Subtype_Indication (Ind : Iir) return Iir; + -- Return True iff the subtype indication of DECL is defined/owned by + -- DECL. + function Is_Owned_Subtype_Indication (Decl : Iir) return Boolean; + -- Get the type of an index_subtype_definition or of a discrete_range from -- an index_constraint. function Get_Index_Type (Index_Type : Iir) return Iir |