aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-06-28 18:30:30 +0200
committerTristan Gingold <tgingold@free.fr>2019-06-28 18:30:30 +0200
commit48546422b50cdc7847e537fa8aca249d9cbe3677 (patch)
treeb2cfd29193128ee7e1be3b592e38f82a52f74d1d
parent12e5e54325111f11d7bb6283eed7fd4a3760a899 (diff)
downloadghdl-48546422b50cdc7847e537fa8aca249d9cbe3677.tar.gz
ghdl-48546422b50cdc7847e537fa8aca249d9cbe3677.tar.bz2
ghdl-48546422b50cdc7847e537fa8aca249d9cbe3677.zip
vhdl: recognize some functions of math_real.
-rw-r--r--src/vhdl/vhdl-ieee-math_real.adb58
-rw-r--r--src/vhdl/vhdl-ieee-math_real.ads24
-rw-r--r--src/vhdl/vhdl-ieee.adb3
-rw-r--r--src/vhdl/vhdl-nodes.ads6
-rw-r--r--src/vhdl/vhdl-post_sems.adb3
5 files changed, 91 insertions, 3 deletions
diff --git a/src/vhdl/vhdl-ieee-math_real.adb b/src/vhdl/vhdl-ieee-math_real.adb
new file mode 100644
index 000000000..d62e4c246
--- /dev/null
+++ b/src/vhdl/vhdl-ieee-math_real.adb
@@ -0,0 +1,58 @@
+-- Nodes recognizer for ieee.math_real.
+-- Copyright (C) 2019 Tristan Gingold
+--
+-- GHDL is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU General Public License as published by the Free
+-- Software Foundation; either version 2, or (at your option) any later
+-- version.
+--
+-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or
+-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+-- for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with GHDL; see the file COPYING. If not, write to the Free
+-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+-- 02111-1307, USA.
+
+with Std_Names; use Std_Names;
+
+package body Vhdl.Ieee.Math_Real is
+ procedure Extract_Declarations (Pkg : Iir_Package_Declaration)
+ is
+ Decl : Iir;
+ Predef : Iir_Predefined_Functions;
+ begin
+ Math_Real_Pkg := Pkg;
+
+ Decl := Get_Declaration_Chain (Pkg);
+
+ -- Skip a potential copyright constant.
+ Decl := Skip_Copyright_Notice (Decl);
+
+ -- Skip any declarations but functions.
+ loop
+ Decl := Get_Chain (Decl);
+ exit when Decl = Null_Iir;
+
+ case Get_Kind (Decl) is
+ when Iir_Kind_Function_Declaration =>
+ Predef := Iir_Predefined_None;
+ case Get_Identifier (Decl) is
+ when Name_Ceil =>
+ Predef := Iir_Predefined_Ieee_Math_Real_Ceil;
+ when Name_Log2 =>
+ Predef := Iir_Predefined_Ieee_Math_Real_Log2;
+ when others =>
+ null;
+ end case;
+ Set_Implicit_Definition (Decl, Predef);
+ when Iir_Kind_Constant_Declaration =>
+ null;
+ when others =>
+ null;
+ end case;
+ end loop;
+ end Extract_Declarations;
+end Vhdl.Ieee.Math_Real;
diff --git a/src/vhdl/vhdl-ieee-math_real.ads b/src/vhdl/vhdl-ieee-math_real.ads
new file mode 100644
index 000000000..7ba1e33e8
--- /dev/null
+++ b/src/vhdl/vhdl-ieee-math_real.ads
@@ -0,0 +1,24 @@
+-- Nodes recognizer for ieee.math_real.
+-- Copyright (C) 2019 Tristan Gingold
+--
+-- GHDL is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU General Public License as published by the Free
+-- Software Foundation; either version 2, or (at your option) any later
+-- version.
+--
+-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or
+-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+-- for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with GHDL; see the file COPYING. If not, write to the Free
+-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+-- 02111-1307, USA.
+
+package Vhdl.Ieee.Math_Real is
+ Math_Real_Pkg : Iir_Package_Declaration := Null_Iir;
+
+ -- Extract declarations from PKG (ieee.math_real).
+ procedure Extract_Declarations (Pkg : Iir_Package_Declaration);
+end Vhdl.Ieee.Math_Real;
diff --git a/src/vhdl/vhdl-ieee.adb b/src/vhdl/vhdl-ieee.adb
index 69d5196f0..9e861f378 100644
--- a/src/vhdl/vhdl-ieee.adb
+++ b/src/vhdl/vhdl-ieee.adb
@@ -20,8 +20,7 @@ with Vhdl.Utils; use Vhdl.Utils;
with Vhdl.Std_Package;
package body Vhdl.Ieee is
- function Skip_Copyright_Notice (Decl : Iir) return Iir
- is
+ function Skip_Copyright_Notice (Decl : Iir) return Iir is
begin
if Decl /= Null_Iir
and then Get_Kind (Decl) = Iir_Kind_Constant_Declaration
diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads
index 807069d2e..aa151c4d8 100644
--- a/src/vhdl/vhdl-nodes.ads
+++ b/src/vhdl/vhdl-nodes.ads
@@ -4873,7 +4873,11 @@ package Vhdl.Nodes is
-- Unary functions for numeric_std
Iir_Predefined_Ieee_Numeric_Std_Neg_Uns,
- Iir_Predefined_Ieee_Numeric_Std_Neg_Sgn
+ Iir_Predefined_Ieee_Numeric_Std_Neg_Sgn,
+
+ -- Math_Real
+ Iir_Predefined_Ieee_Math_Real_Ceil,
+ Iir_Predefined_Ieee_Math_Real_Log2
);
-- Return TRUE iff FUNC is a short-cut predefined function.
diff --git a/src/vhdl/vhdl-post_sems.adb b/src/vhdl/vhdl-post_sems.adb
index 4a8c96697..bcee6c47b 100644
--- a/src/vhdl/vhdl-post_sems.adb
+++ b/src/vhdl/vhdl-post_sems.adb
@@ -21,6 +21,7 @@ with Vhdl.Sem_Specs;
with Vhdl.Ieee.Std_Logic_1164;
with Vhdl.Ieee.Vital_Timing;
with Vhdl.Ieee.Numeric;
+with Vhdl.Ieee.Math_Real;
with Flags; use Flags;
package body Vhdl.Post_Sems is
@@ -56,6 +57,8 @@ package body Vhdl.Post_Sems is
Vhdl.Ieee.Vital_Timing.Extract_Declarations (Lib_Unit);
when Name_Numeric_Std =>
Vhdl.Ieee.Numeric.Extract_Std_Declarations (Lib_Unit);
+ when Name_Math_Real =>
+ Vhdl.Ieee.Math_Real.Extract_Declarations (Lib_Unit);
when others =>
null;
end case;