aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-26 20:06:46 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-26 20:07:53 +0200
commit2bdc1cdc3afc8350fb5bb1ba7a438055704a6ed9 (patch)
tree69ce5d8df99977b0dcac613c7068d863d67a7fd3
parentf73b474036e2b91370de0696a14c2faf0a106097 (diff)
downloadghdl-2bdc1cdc3afc8350fb5bb1ba7a438055704a6ed9.tar.gz
ghdl-2bdc1cdc3afc8350fb5bb1ba7a438055704a6ed9.tar.bz2
ghdl-2bdc1cdc3afc8350fb5bb1ba7a438055704a6ed9.zip
psl: keep locations.
-rw-r--r--src/psl/psl-build.adb46
-rw-r--r--src/psl/psl-hash.adb5
-rw-r--r--src/psl/psl-hash.ads2
-rw-r--r--src/psl/psl-nodes.adb4
-rw-r--r--src/psl/psl-nodes.adb.in4
-rw-r--r--src/psl/psl-nodes.ads1
-rw-r--r--src/vhdl/vhdl-sem_psl.adb10
7 files changed, 52 insertions, 20 deletions
diff --git a/src/psl/psl-build.adb b/src/psl/psl-build.adb
index 18262f32e..687a65bc2 100644
--- a/src/psl/psl-build.adb
+++ b/src/psl/psl-build.adb
@@ -97,6 +97,7 @@ package body PSL.Build is
Res : NFA;
Start : NFA_State;
Extra_L, Extra_R : NFA_Edge;
+ T : Node;
begin
Start_L := Get_Start_State (L);
Start_R := Get_Start_State (R);
@@ -142,12 +143,14 @@ package body PSL.Build is
E_R := Get_First_Src_Edge (S_R);
while E_R /= No_Edge loop
if not (E_L = Extra_L and E_R = Extra_R) then
+ T := Build_Bool_And (Get_Edge_Expr (E_L),
+ Get_Edge_Expr (E_R));
+ Copy_Location (T, Get_Edge_Expr (E_L));
Add_Edge (Get_State (Res, S_L, S_R),
Get_State (Res,
Get_Edge_Dest (E_L),
Get_Edge_Dest (E_R)),
- Build_Bool_And (Get_Edge_Expr (E_L),
- Get_Edge_Expr (E_R)));
+ T);
end if;
E_R := Get_Next_Src_Edge (E_R);
end loop;
@@ -364,6 +367,7 @@ package body PSL.Build is
E_R := Get_First_Src_Edge (Start_R);
while E_R /= No_Edge loop
Expr := Build_Bool_And (N_L, Get_Edge_Expr (E_R));
+ Copy_Location (Expr, N_L);
Expr := PSL.QM.Reduce (Expr);
if Expr /= False_Node then
Add_Edge (S_L, Get_Edge_Dest (E_R), Expr);
@@ -720,6 +724,7 @@ package body PSL.Build is
Expr : Node;
V : Bool_Vector)
is
+ T : Node;
begin
if Expr = False_Node then
return;
@@ -759,13 +764,19 @@ package body PSL.Build is
N_V (S) := True;
if Expr = Null_Node then
Build_Arcs (N, State, N_States, Exprs, E, N_V);
- Build_Arcs (N, State, N_States, Exprs,
- Build_Bool_Not (E), V);
+ T := Build_Bool_Not (E);
+ Copy_Location (T, E);
+ Build_Arcs (N, State, N_States, Exprs, T, V);
else
- Build_Arcs (N, State, N_States, Exprs,
- Build_Bool_And (E, Expr), N_V);
- Build_Arcs (N, State, N_States, Exprs,
- Build_Bool_And (Build_Bool_Not (E), Expr), V);
+ T := Build_Bool_And (E, Expr);
+ Copy_Location (T, Expr);
+
+ Build_Arcs (N, State, N_States, Exprs, T, N_V);
+ T := Build_Bool_Not (E);
+ Copy_Location (T, E);
+ T := Build_Bool_And (T, Expr);
+ Copy_Location (T, Expr);
+ Build_Arcs (N, State, N_States, Exprs, T, V);
end if;
end;
end if;
@@ -785,6 +796,7 @@ package body PSL.Build is
States : State_Vector (0 .. Nbr_States - 1);
Res : NFA;
State : NFA_State;
+ R : Node;
begin
Final := Natural (Get_State_Label (Get_Final_State (N)));
@@ -841,11 +853,13 @@ package body PSL.Build is
end if;
if D = Final then
- Edge_Expr := Build_Bool_Not (Edge_Expr);
+ R := Build_Bool_Not (Edge_Expr);
+ Copy_Location (R, Edge_Expr);
if Expr = Null_Node then
- Expr := Edge_Expr;
+ Expr := R;
else
- Expr := Build_Bool_And (Expr, Edge_Expr);
+ Expr := Build_Bool_And (Expr, R);
+ Copy_Location (Expr, R);
end if;
else
if Exprs (D) = Null_Node then
@@ -853,8 +867,8 @@ package body PSL.Build is
States (Nbr_Dest) := D;
Nbr_Dest := Nbr_Dest + 1;
else
- Exprs (D) := Build_Bool_Or (Exprs (D),
- Edge_Expr);
+ Exprs (D) := Build_Bool_Or (Exprs (D), Edge_Expr);
+ Copy_Location (Exprs (D), Edge_Expr);
end if;
end if;
E := Get_Next_Src_Edge (E);
@@ -932,13 +946,17 @@ package body PSL.Build is
S : NFA_State;
E : NFA_Edge;
Not_Expr : Node;
+ T : Node;
begin
Not_Expr := Build_Bool_Not (Expr);
+ Copy_Location (Not_Expr, Expr);
S := Get_First_State (N);
while S /= No_State loop
E := Get_First_Src_Edge (S);
while E /= No_Edge loop
- Set_Edge_Expr (E, Build_Bool_And (Not_Expr, Get_Edge_Expr (E)));
+ T := Build_Bool_And (Not_Expr, Get_Edge_Expr (E));
+ Copy_Location (T, Not_Expr);
+ Set_Edge_Expr (E, T);
E := Get_Next_Src_Edge (E);
end loop;
S := Get_Next_State (S);
diff --git a/src/psl/psl-hash.adb b/src/psl/psl-hash.adb
index 89394c97d..2e36602d9 100644
--- a/src/psl/psl-hash.adb
+++ b/src/psl/psl-hash.adb
@@ -45,7 +45,8 @@ package body PSL.Hash is
end loop;
end Init;
- function Get_PSL_Node (Hdl : Int32) return Node is
+ function Get_PSL_Node (Hdl : Int32; Loc : Location_Type) return Node
+ is
Idx : Index_Type := Index_Type (Hdl mod Int32 (Hash_Size));
N_Idx : Index_Type;
Res : Node;
@@ -55,6 +56,7 @@ package body PSL.Hash is
if Res = Null_Node then
Res := Create_Node (N_HDL_Bool);
Set_HDL_Node (Res, Hdl);
+ Set_Location (Res, Loc);
Cells.Table (Idx).Res := Res;
return Res;
end if;
@@ -71,6 +73,7 @@ package body PSL.Hash is
end loop;
Res := Create_Node (N_HDL_Bool);
Set_HDL_Node (Res, Hdl);
+ Set_Location (Res, Loc);
Cells.Append ((Res => Res, Next => No_Index));
Cells.Table (Idx).Next := Cells.Last;
return Res;
diff --git a/src/psl/psl-hash.ads b/src/psl/psl-hash.ads
index a464ebd6b..fa71f1f26 100644
--- a/src/psl/psl-hash.ads
+++ b/src/psl/psl-hash.ads
@@ -25,5 +25,5 @@ package PSL.Hash is
-- Get the PSL node for node HDL.
-- Only one PSL node is created for an HDL node.
- function Get_PSL_Node (Hdl : Int32) return Node;
+ function Get_PSL_Node (Hdl : Int32; Loc : Location_Type) return Node;
end PSL.Hash;
diff --git a/src/psl/psl-nodes.adb b/src/psl/psl-nodes.adb
index 629041a73..3b3dac4be 100644
--- a/src/psl/psl-nodes.adb
+++ b/src/psl/psl-nodes.adb
@@ -200,6 +200,10 @@ package body PSL.Nodes is
Nodet.Table (N).Location := Int32 (Loc);
end Set_Location;
+ procedure Copy_Location (N : Node; Src : Node) is
+ begin
+ Set_Location (N, Get_Location (Src));
+ end Copy_Location;
procedure Set_Field1 (N : Node; V : Node) is
begin
diff --git a/src/psl/psl-nodes.adb.in b/src/psl/psl-nodes.adb.in
index a7d34b64a..4294140c1 100644
--- a/src/psl/psl-nodes.adb.in
+++ b/src/psl/psl-nodes.adb.in
@@ -200,6 +200,10 @@ package body PSL.Nodes is
Nodet.Table (N).Location := Int32 (Loc);
end Set_Location;
+ procedure Copy_Location (N : Node; Src : Node) is
+ begin
+ Set_Location (N, Get_Location (Src));
+ end Copy_Location;
procedure Set_Field1 (N : Node; V : Node) is
begin
diff --git a/src/psl/psl-nodes.ads b/src/psl/psl-nodes.ads
index d5d3b93f5..eb0ad4cb3 100644
--- a/src/psl/psl-nodes.ads
+++ b/src/psl/psl-nodes.ads
@@ -477,6 +477,7 @@ package PSL.Nodes is
-- Note: use field Location
function Get_Location (N : Node) return Location_Type;
procedure Set_Location (N : Node; Loc : Location_Type);
+ procedure Copy_Location (N : Node; Src : Node);
function Get_Kind (N : Node) return Nkind;
pragma Inline (Get_Kind);
diff --git a/src/vhdl/vhdl-sem_psl.adb b/src/vhdl/vhdl-sem_psl.adb
index f82299f44..a34552215 100644
--- a/src/vhdl/vhdl-sem_psl.adb
+++ b/src/vhdl/vhdl-sem_psl.adb
@@ -135,7 +135,8 @@ package body Vhdl.Sem_Psl is
begin
Name := Get_Named_Entity (Expr);
if Name /= Null_Iir then
- Hnode := PSL.Hash.Get_PSL_Node (HDL_Node (Name));
+ Hnode := PSL.Hash.Get_PSL_Node
+ (HDL_Node (Name), Get_Location (Name));
N := Create_Node (N_HDL_Expr);
Set_Location (N, Get_Location (Expr));
Set_HDL_Node (N, HDL_Node (Expr));
@@ -148,7 +149,7 @@ package body Vhdl.Sem_Psl is
end case;
-- Default.
- return PSL.Hash.Get_PSL_Node (HDL_Node (Expr));
+ return PSL.Hash.Get_PSL_Node (HDL_Node (Expr), Get_Location (Expr));
end Convert_Bool;
-- Analyze an HDL expression. This may mostly a wrapper except in the
@@ -230,7 +231,7 @@ package body Vhdl.Sem_Psl is
Free_Node (N);
if not Is_Psl_Bool_Expr (Expr) then
Error_Msg_Sem (+Expr, "type of expression must be boolean");
- return PSL.Hash.Get_PSL_Node (HDL_Node (Expr));
+ return PSL.Hash.Get_PSL_Node (HDL_Node (Expr), Get_Location (Expr));
else
return Convert_Bool (Expr);
end if;
@@ -880,7 +881,8 @@ package body Vhdl.Sem_Psl is
if Get_Kind (Actual) in Iir_Kinds_Name then
Actual := Get_Named_Entity (Actual);
end if;
- Psl_Actual := PSL.Hash.Get_PSL_Node (HDL_Node (Actual));
+ Psl_Actual := PSL.Hash.Get_PSL_Node
+ (HDL_Node (Actual), Get_Location (Actual));
end if;
Assoc2 := Create_Node (N_Actual);