diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-07-16 12:07:34 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-07-18 19:19:58 +0200 |
commit | a889a32c0eb359bbb8b3d941226b1129106e5510 (patch) | |
tree | f01ea0f157b499391fa3bf1adee3f6ab646462c5 /src | |
parent | 1850acf59aa47419c79736ab77e17918b4677faf (diff) | |
download | ghdl-a889a32c0eb359bbb8b3d941226b1129106e5510.tar.gz ghdl-a889a32c0eb359bbb8b3d941226b1129106e5510.tar.bz2 ghdl-a889a32c0eb359bbb8b3d941226b1129106e5510.zip |
vhdl/translate: clarify meaning of Mstate_E for Mnode.
Split into Mstate_Ev (for values) and Mstate_Ep (for pointers).
Also fix stabilize calls for Ev.
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/translate/trans-chap6.adb | 4 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap8.adb | 2 | ||||
-rw-r--r-- | src/vhdl/translate/trans.adb | 88 | ||||
-rw-r--r-- | src/vhdl/translate/trans.ads | 15 |
4 files changed, 62 insertions, 47 deletions
diff --git a/src/vhdl/translate/trans-chap6.adb b/src/vhdl/translate/trans-chap6.adb index e558cb726..f0ee207ad 100644 --- a/src/vhdl/translate/trans-chap6.adb +++ b/src/vhdl/translate/trans-chap6.adb @@ -240,7 +240,7 @@ package body Trans.Chap6 is Deep_Rng : Iir; Deep_Reverse : Boolean; begin - Index1 := Stabilize (Index); + Index1 := Stabilize (Index, True); pragma Unreferenced (Index); if Index_Expr = Null_Iir then @@ -367,7 +367,7 @@ package body Trans.Chap6 is Index_Base_Type := Get_Base_Type (Index_Type); Index := Chap7.Translate_Expression (Expr, Index_Base_Type); - Stabilize (Index); + Index := Stabilize (Index, True); if Get_Direction (Index_Range) = Dir_To then -- Direction TO: INDEX - LEFT. diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb index 7283b9bd0..0b9dbce3b 100644 --- a/src/vhdl/translate/trans-chap8.adb +++ b/src/vhdl/translate/trans-chap8.adb @@ -4660,7 +4660,7 @@ package body Trans.Chap8 is else Translate_Waveform_Expression (Value, Target_Type, Var_Targ, Val); - Stabilize (Val); + Val := Stabilize (Val, True); Chap3.Check_Composite_Match (Target_Type, Var_Targ, Get_Type (Value), Val, We); end if; diff --git a/src/vhdl/translate/trans.adb b/src/vhdl/translate/trans.adb index 9b0029205..37972318e 100644 --- a/src/vhdl/translate/trans.adb +++ b/src/vhdl/translate/trans.adb @@ -1224,20 +1224,21 @@ package body Trans is D : O_Dnode; begin case M.M1.State is - when Mstate_E => - if Is_Composite (M.M1.T) then - -- Create a pointer variable. - D := Create_Temp_Init (M.M1.Ptype, M.M1.E); - return Mnode'(M1 => (State => Mstate_Dp, - K => K, T => M.M1.T, Dp => D, - Vtype => M.M1.Vtype, Ptype => M.M1.Ptype)); - else - -- Create a scalar variable. - D := Create_Temp_Init (M.M1.Vtype, M.M1.E); - return Mnode'(M1 => (State => Mstate_Dv, - K => K, T => M.M1.T, Dv => D, - Vtype => M.M1.Vtype, Ptype => M.M1.Ptype)); + when Mstate_Ep => + -- Create a pointer variable. + D := Create_Temp_Init (M.M1.Ptype, M.M1.Ep); + return Mnode'(M1 => (State => Mstate_Dp, + K => K, T => M.M1.T, Dp => D, + Vtype => M.M1.Vtype, Ptype => M.M1.Ptype)); + when Mstate_Ev => + if not Can_Copy then + raise Internal_Error; end if; + -- Create a scalar variable. + D := Create_Temp_Init (M.M1.Vtype, M.M1.Ev); + return Mnode'(M1 => (State => Mstate_Dv, + K => K, T => M.M1.T, Dv => D, + Vtype => M.M1.Vtype, Ptype => M.M1.Ptype)); when Mstate_Lp => D := Create_Temp_Init (M.M1.Ptype, New_Value (M.M1.Lp)); return Mnode'(M1 => (State => Mstate_Dp, @@ -1281,8 +1282,10 @@ package body Trans is -- M must be scalar or access. pragma Assert (not Is_Composite (M.M1.T)); case M.M1.State is - when Mstate_E => - E := M.M1.E; + when Mstate_Ev => + E := M.M1.Ev; + when Mstate_Ep => + raise Internal_Error; when Mstate_Lp => E := New_Value (New_Acc_Value (M.M1.Lp)); when Mstate_Lv => @@ -1533,10 +1536,17 @@ package body Trans is function E2M (E : O_Enode; T : Type_Info_Acc; Kind : Object_Kind_Type) return Mnode is begin - return Mnode'(M1 => (State => Mstate_E, - K => Kind, T => T, E => E, - Vtype => T.Ortho_Type (Kind), - Ptype => T.Ortho_Ptr_Type (Kind))); + if Is_Composite (T) then + return Mnode'(M1 => (State => Mstate_Ep, + K => Kind, T => T, Ep => E, + Vtype => T.Ortho_Type (Kind), + Ptype => T.Ortho_Ptr_Type (Kind))); + else + return Mnode'(M1 => (State => Mstate_Ev, + K => Kind, T => T, Ev => E, + Vtype => T.Ortho_Type (Kind), + Ptype => T.Ortho_Ptr_Type (Kind))); + end if; end E2M; function E2M (E : O_Enode; @@ -1546,8 +1556,9 @@ package body Trans is Ptype : O_Tnode) return Mnode is begin - return Mnode'(M1 => (State => Mstate_E, - K => Kind, T => T, E => E, + pragma Assert (Is_Composite (T)); + return Mnode'(M1 => (State => Mstate_Ep, + K => Kind, T => T, Ep => E, Vtype => Vtype, Ptype => Ptype)); end E2M; @@ -1643,18 +1654,13 @@ package body Trans is function M2Lv (M : Mnode) return O_Lnode is begin case M.M1.State is - when Mstate_E => - case Get_Type_Info (M).Type_Mode is - when Type_Mode_Thin => - -- Scalar to var is not possible. - -- FIXME: This is not coherent with the fact that this - -- conversion is possible when M is stabilized. - raise Internal_Error; - when Type_Mode_Fat => - return New_Access_Element (M.M1.E); - when Type_Mode_Unknown => - raise Internal_Error; - end case; + when Mstate_Ev => + -- Scalar to var is not possible. + -- FIXME: This is not coherent with the fact that this + -- conversion is possible when M is stabilized. + raise Internal_Error; + when Mstate_Ep => + return New_Access_Element (M.M1.Ep); when Mstate_Lp => return New_Acc_Value (M.M1.Lp); when Mstate_Lv => @@ -1672,7 +1678,8 @@ package body Trans is function M2Lp (M : Mnode) return O_Lnode is begin case M.M1.State is - when Mstate_E => + when Mstate_Ev + | Mstate_Ep => raise Internal_Error; when Mstate_Lp => return M.M1.Lp; @@ -1731,8 +1738,10 @@ package body Trans is function M2E (M : Mnode) return O_Enode is begin case M.M1.State is - when Mstate_E => - return M.M1.E; + when Mstate_Ev => + return M.M1.Ev; + when Mstate_Ep => + return M.M1.Ep; when Mstate_Lp => case M.M1.T.Type_Mode is when Type_Mode_Unknown => @@ -1786,11 +1795,12 @@ package body Trans is return New_Address (M.M1.Lv, M.M1.Ptype); when Mstate_Dv => return New_Address (New_Obj (M.M1.Dv), M.M1.Ptype); - when Mstate_E => + when Mstate_Ep => + return M.M1.Ep; + when Mstate_Ev => -- For scalar, M contains the value so there is no lvalue from -- which the address can be taken. - pragma Assert (Is_Composite (M.M1.T)); - return M.M1.E; + raise Internal_Error; when Mstate_Bad | Mstate_Null => raise Internal_Error; diff --git a/src/vhdl/translate/trans.ads b/src/vhdl/translate/trans.ads index 7f66809be..9546521e4 100644 --- a/src/vhdl/translate/trans.ads +++ b/src/vhdl/translate/trans.ads @@ -1466,10 +1466,13 @@ package Trans is -- State of an Mmode. type Mstate is ( - -- The Mnode contains an Enode, which can be either a value or a - -- pointer. + -- The Mnode contains an Enode for a value. -- This Mnode can be used only once. - Mstate_E, + Mstate_Ev, + + -- The Mnode contains an Enode for a pointer. + -- This Mnode can be used only once. + Mstate_Ep, -- The Mnode contains an Lnode representing a value. -- This Lnode can be used only once. @@ -1505,8 +1508,10 @@ package Trans is Ptype : O_Tnode; case State is - when Mstate_E => - E : O_Enode; + when Mstate_Ev => + Ev : O_Enode; + when Mstate_Ep => + Ep : O_Enode; when Mstate_Lv => Lv : O_Lnode; when Mstate_Lp => |