aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-ieee-numeric.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-09-16 21:14:31 +0200
committerTristan Gingold <tgingold@free.fr>2020-09-16 21:14:31 +0200
commit970afd54338ed04440c23a7b625f5c660e858cb2 (patch)
tree65d1d80d3cc07874ab75435dc1e94d59d906914f /src/vhdl/vhdl-ieee-numeric.adb
parent63fd2ca7ce387c914668f8393962751a55ac4138 (diff)
downloadghdl-970afd54338ed04440c23a7b625f5c660e858cb2.tar.gz
ghdl-970afd54338ed04440c23a7b625f5c660e858cb2.tar.bz2
ghdl-970afd54338ed04440c23a7b625f5c660e858cb2.zip
vhdl: recognize find_leftmost/find_rightmost. For #1460
Diffstat (limited to 'src/vhdl/vhdl-ieee-numeric.adb')
-rw-r--r--src/vhdl/vhdl-ieee-numeric.adb30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-ieee-numeric.adb b/src/vhdl/vhdl-ieee-numeric.adb
index fae624d78..b7fb3975d 100644
--- a/src/vhdl/vhdl-ieee-numeric.adb
+++ b/src/vhdl/vhdl-ieee-numeric.adb
@@ -568,6 +568,14 @@ package body Vhdl.Ieee.Numeric is
(Type_Signed => Iir_Predefined_Ieee_Numeric_Std_Sra_Sgn_Int,
Type_Unsigned => Iir_Predefined_Ieee_Numeric_Std_Sra_Uns_Int);
+ Leftmost_Patterns : constant Shift_Pattern_Type :=
+ (Type_Signed => Iir_Predefined_Ieee_Numeric_Std_Find_Leftmost_Sgn,
+ Type_Unsigned => Iir_Predefined_Ieee_Numeric_Std_Find_Leftmost_Uns);
+
+ Rightmost_Patterns : constant Shift_Pattern_Type :=
+ (Type_Signed => Iir_Predefined_Ieee_Numeric_Std_Find_Rightmost_Sgn,
+ Type_Unsigned => Iir_Predefined_Ieee_Numeric_Std_Find_Rightmost_Uns);
+
Error : exception;
procedure Extract_Declarations (Pkg_Decl : Iir_Package_Declaration;
@@ -801,6 +809,24 @@ package body Vhdl.Ieee.Numeric is
Set_Implicit_Definition (Decl, Res);
end if;
end Handle_Shift;
+
+ procedure Handle_Find (Pats : Shift_Pattern_Type)
+ is
+ Res : Iir_Predefined_Functions;
+ begin
+ if Arg1_Kind = Arg_Vect
+ and then Arg2_Kind = Arg_Scal
+ and then Arg2_Sign = Type_Log
+ then
+ case Arg1_Sign is
+ when Type_Signed | Type_Unsigned =>
+ Res := Pats (Arg1_Sign);
+ when others =>
+ Res := Iir_Predefined_None;
+ end case;
+ Set_Implicit_Definition (Decl, Res);
+ end if;
+ end Handle_Find;
begin
Decl := Get_Declaration_Chain (Pkg_Decl);
@@ -951,6 +977,10 @@ package body Vhdl.Ieee.Numeric is
Handle_Shift (Rol_Patterns, Type_Unsigned);
when Name_Rotate_Right =>
Handle_Shift (Ror_Patterns, Type_Unsigned);
+ when Name_Find_Leftmost =>
+ Handle_Find (Leftmost_Patterns);
+ when Name_Find_Rightmost =>
+ Handle_Find (Rightmost_Patterns);
when Name_To_01 =>
Handle_To_01;
when others =>