Commit fba9fcae by Eric Botcazou Committed by Pierre-Marie de Rodat

[Ada] Small comment tweaks for 3 predicates on bit-aligned references

They fix a few glitches left and right.  No functional changes.

2019-08-12  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* exp_util.ads (Component_May_Be_Bit_Aligned): Small comment
	tweaks.
	(Possible_Bit_Aligned_Component): Likewise.
	(Type_May_Have_Bit_Aligned_Components): Likewise.
	* exp_util.adb (Component_May_Be_Bit_Aligned): Likewise.
	(Possible_Bit_Aligned_Component): Likewise.
	(Type_May_Have_Bit_Aligned_Components): Likewise.

From-SVN: r274304
parent 00907026
2019-08-12 Eric Botcazou <ebotcazou@adacore.com> 2019-08-12 Eric Botcazou <ebotcazou@adacore.com>
* exp_util.ads (Component_May_Be_Bit_Aligned): Small comment
tweaks.
(Possible_Bit_Aligned_Component): Likewise.
(Type_May_Have_Bit_Aligned_Components): Likewise.
* exp_util.adb (Component_May_Be_Bit_Aligned): Likewise.
(Possible_Bit_Aligned_Component): Likewise.
(Type_May_Have_Bit_Aligned_Components): Likewise.
2019-08-12 Eric Botcazou <ebotcazou@adacore.com>
* exp_ch4.adb (Expand_N_Op_Eq): Expand the array equality if * exp_ch4.adb (Expand_N_Op_Eq): Expand the array equality if
either operand is a possibly unaligned slice. either operand is a possibly unaligned slice.
* exp_ch6.adb (Expand_Simple_Function_Return): Do not generate a * exp_ch6.adb (Expand_Simple_Function_Return): Do not generate a
......
...@@ -4444,8 +4444,8 @@ package body Exp_Util is ...@@ -4444,8 +4444,8 @@ package body Exp_Util is
begin begin
-- If no component clause, then everything is fine, since the back end -- If no component clause, then everything is fine, since the back end
-- never bit-misaligns by default, even if there is a pragma Packed for -- never misaligns from byte boundaries by default, even if there is a
-- the record. -- pragma Pack for the record.
if No (Comp) or else No (Component_Clause (Comp)) then if No (Comp) or else No (Component_Clause (Comp)) then
return False; return False;
...@@ -10707,9 +10707,9 @@ package body Exp_Util is ...@@ -10707,9 +10707,9 @@ package body Exp_Util is
Ptyp : constant Entity_Id := Etype (P); Ptyp : constant Entity_Id := Etype (P);
begin begin
-- If we know the component size and it is less than 64, then -- If we know the component size and it is not larger than 64,
-- we are definitely OK. The back end always does assignment of -- then we are definitely OK. The back end does the assignment
-- misaligned small objects correctly. -- of misaligned small objects correctly.
if Known_Static_Component_Size (Ptyp) if Known_Static_Component_Size (Ptyp)
and then Component_Size (Ptyp) <= 64 and then Component_Size (Ptyp) <= 64
...@@ -10732,13 +10732,15 @@ package body Exp_Util is ...@@ -10732,13 +10732,15 @@ package body Exp_Util is
Comp : constant Entity_Id := Entity (Selector_Name (N)); Comp : constant Entity_Id := Entity (Selector_Name (N));
begin begin
-- If there is no component clause, then we are in the clear -- This is the crucial test: if the component itself causes
-- since the back end will never misalign a large component -- trouble, then we can stop and return True.
-- unless it is forced to do so. In the clear means we need
-- only the recursive test on the prefix.
if Component_May_Be_Bit_Aligned (Comp) then if Component_May_Be_Bit_Aligned (Comp) then
return True; return True;
-- Otherwise, we need to test the prefix, to see if we are
-- selecting from a possibly unaligned component.
else else
return Possible_Bit_Aligned_Component (P); return Possible_Bit_Aligned_Component (P);
end if; end if;
...@@ -10751,7 +10753,7 @@ package body Exp_Util is ...@@ -10751,7 +10753,7 @@ package body Exp_Util is
return Possible_Bit_Aligned_Component (Prefix (N)); return Possible_Bit_Aligned_Component (Prefix (N));
-- For an unchecked conversion, check whether the expression may -- For an unchecked conversion, check whether the expression may
-- be bit-aligned. -- be bit aligned.
when N_Unchecked_Type_Conversion => when N_Unchecked_Type_Conversion =>
return Possible_Bit_Aligned_Component (Expression (N)); return Possible_Bit_Aligned_Component (Expression (N));
...@@ -13505,9 +13507,17 @@ package body Exp_Util is ...@@ -13505,9 +13507,17 @@ package body Exp_Util is
begin begin
E := First_Component_Or_Discriminant (Typ); E := First_Component_Or_Discriminant (Typ);
while Present (E) loop while Present (E) loop
if Component_May_Be_Bit_Aligned (E) -- This is the crucial test: if the component itself causes
or else Type_May_Have_Bit_Aligned_Components (Etype (E)) -- trouble, then we can stop and return True.
then
if Component_May_Be_Bit_Aligned (E) then
return True;
end if;
-- Otherwise, we need to test its type, to see if it may
-- itself contain a troublesome component.
if Type_May_Have_Bit_Aligned_Components (Etype (E)) then
return True; return True;
end if; end if;
......
...@@ -401,32 +401,27 @@ package Exp_Util is ...@@ -401,32 +401,27 @@ package Exp_Util is
-- case overflow. -- case overflow.
function Component_May_Be_Bit_Aligned (Comp : Entity_Id) return Boolean; function Component_May_Be_Bit_Aligned (Comp : Entity_Id) return Boolean;
-- This function is in charge of detecting record components that may -- This function is in charge of detecting record components that may cause
-- cause trouble in the back end if an attempt is made to assign the -- trouble for the back end if an attempt is made to access the component
-- component. The back end can handle such assignments with no problem if -- as a whole. The back end can handle such accesses with no problem if the
-- the components involved are small (64-bits or less) records or scalar -- components involved are small (64 bits or less) records or scalar items
-- items (including bit-packed arrays represented with modular types) or -- (including bit-packed arrays represented with a modular type), or else
-- are both aligned on a byte boundary (starting on a byte boundary, and -- if they are aligned on byte boundaries (i.e. starting on a byte boundary
-- occupying an integral number of bytes). -- and occupying an integral number of bytes).
-- --
-- However, problems arise for records larger than 64 bits, or for arrays -- However, problems arise for records larger than 64 bits, or for arrays
-- (other than bit-packed arrays represented with a modular type) if the -- (other than bit-packed arrays represented with a modular type) if the
-- component starts on a non-byte boundary, or does not occupy an integral -- component either does not start on a byte boundary or does not occupy an
-- number of bytes (i.e. there are some bits possibly shared with fields -- integral number of bytes (i.e. there are some bits possibly shared with
-- at the start or beginning of the component). The back end cannot handle -- other components at the start or the end of the component). The back end
-- loading and storing such components in a single operation. -- cannot handle loading from or storing to such components as a whole.
-- --
-- This function is used to detect the troublesome situation. it is -- This function is used to detect the troublesome situation. It is meant
-- conservative in the sense that it produces True unless it knows for -- to be conservative in the sense that it produces True unless it knows
-- sure that the component is safe (as outlined in the first paragraph -- for sure that the component is safe (as outlined in the first paragraph
-- above). The code generation for record and array assignment checks for -- above). The processing for record and array assignment indirectly checks
-- trouble using this function, and if so the assignment is generated -- for trouble using this function and, if so, the assignment is expanded
-- component-wise, which the back end is required to handle correctly. -- component-wise, which the back end is required to handle correctly.
--
-- Note that in GNAT 3, the back end will reject such components anyway,
-- so the hard work in checking for this case is wasted in GNAT 3, but
-- it is harmless, so it is easier to do it in all cases, rather than
-- conditionalize it in GNAT 5 or beyond.
function Containing_Package_With_Ext_Axioms function Containing_Package_With_Ext_Axioms
(E : Entity_Id) return Entity_Id; (E : Entity_Id) return Entity_Id;
...@@ -962,12 +957,12 @@ package Exp_Util is ...@@ -962,12 +957,12 @@ package Exp_Util is
-- returned only if the replacement is safe. -- returned only if the replacement is safe.
function Possible_Bit_Aligned_Component (N : Node_Id) return Boolean; function Possible_Bit_Aligned_Component (N : Node_Id) return Boolean;
-- This function is used during processing the assignment of a record or -- This function is used during processing the assignment of a record or an
-- indexed component. The argument N is either the left hand or right hand -- array, or the construction of an aggregate. The argument N is either the
-- side of an assignment, and this function determines if there is a record -- left or the right hand side of an assignment and the function determines
-- component reference where the record may be bit aligned in a manner that -- whether there is a record component reference where the component may be
-- causes trouble for the back end (see Component_May_Be_Bit_Aligned for -- bit aligned in a manner that causes trouble for the back end (see also
-- further details). -- Component_May_Be_Bit_Aligned for further details).
function Power_Of_Two (N : Node_Id) return Nat; function Power_Of_Two (N : Node_Id) return Nat;
-- Determines if N is a known at compile time value which is of the form -- Determines if N is a known at compile time value which is of the form
...@@ -1170,8 +1165,9 @@ package Exp_Util is ...@@ -1170,8 +1165,9 @@ package Exp_Util is
function Type_May_Have_Bit_Aligned_Components function Type_May_Have_Bit_Aligned_Components
(Typ : Entity_Id) return Boolean; (Typ : Entity_Id) return Boolean;
-- Determines if Typ is a composite type that has within it (looking down -- Determines if Typ is a composite type that has within it (looking down
-- recursively at any subcomponents), a record type which has component -- recursively at subcomponents) a record which contains a component that
-- that may be bit aligned (see Possible_Bit_Aligned_Component). The result -- may be bit aligned in a manner that causes trouble for the back end
-- (see also Component_May_Be_Bit_Aligned for further details). The result
-- is conservative, in that a result of False is decisive. A result of True -- is conservative, in that a result of False is decisive. A result of True
-- means that such a component may or may not be present. -- means that such a component may or may not be present.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment