1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Atree
; use Atree
;
28 with Checks
; use Checks
;
29 with Einfo
; use Einfo
;
30 with Exp_Dbug
; use Exp_Dbug
;
31 with Exp_Util
; use Exp_Util
;
32 with Nlists
; use Nlists
;
33 with Nmake
; use Nmake
;
34 with Rtsfind
; use Rtsfind
;
36 with Sem_Ch3
; use Sem_Ch3
;
37 with Sem_Ch8
; use Sem_Ch8
;
38 with Sem_Ch13
; use Sem_Ch13
;
39 with Sem_Eval
; use Sem_Eval
;
40 with Sem_Res
; use Sem_Res
;
41 with Sem_Util
; use Sem_Util
;
42 with Sinfo
; use Sinfo
;
43 with Snames
; use Snames
;
44 with Stand
; use Stand
;
45 with Targparm
; use Targparm
;
46 with Tbuild
; use Tbuild
;
47 with Ttypes
; use Ttypes
;
48 with Uintp
; use Uintp
;
50 package body Exp_Pakd
is
52 ---------------------------
53 -- Endian Considerations --
54 ---------------------------
56 -- As described in the specification, bit numbering in a packed array
57 -- is consistent with bit numbering in a record representation clause,
58 -- and hence dependent on the endianness of the machine:
60 -- For little-endian machines, element zero is at the right hand end
61 -- (low order end) of a bit field.
63 -- For big-endian machines, element zero is at the left hand end
64 -- (high order end) of a bit field.
66 -- The shifts that are used to right justify a field therefore differ
67 -- in the two cases. For the little-endian case, we can simply use the
68 -- bit number (i.e. the element number * element size) as the count for
69 -- a right shift. For the big-endian case, we have to subtract the shift
70 -- count from an appropriate constant to use in the right shift. We use
71 -- rotates instead of shifts (which is necessary in the store case to
72 -- preserve other fields), and we expect that the backend will be able
73 -- to change the right rotate into a left rotate, avoiding the subtract,
74 -- if the architecture provides such an instruction.
76 ----------------------------------------------
77 -- Entity Tables for Packed Access Routines --
78 ----------------------------------------------
80 -- For the cases of component size = 3,5-7,9-15,17-31,33-63 we call
81 -- library routines. This table is used to obtain the entity for the
84 type E_Array
is array (Int
range 01 .. 63) of RE_Id
;
86 -- Array of Bits_nn entities. Note that we do not use library routines
87 -- for the 8-bit and 16-bit cases, but we still fill in the table, using
88 -- entries from System.Unsigned, because we also use this table for
89 -- certain special unchecked conversions in the big-endian case.
91 Bits_Id
: constant E_Array
:=
107 16 => RE_Unsigned_16
,
123 32 => RE_Unsigned_32
,
156 -- Array of Get routine entities. These are used to obtain an element
157 -- from a packed array. The N'th entry is used to obtain elements from
158 -- a packed array whose component size is N. RE_Null is used as a null
159 -- entry, for the cases where a library routine is not used.
161 Get_Id
: constant E_Array
:=
226 -- Array of Get routine entities to be used in the case where the packed
227 -- array is itself a component of a packed structure, and therefore may
228 -- not be fully aligned. This only affects the even sizes, since for the
229 -- odd sizes, we do not get any fixed alignment in any case.
231 GetU_Id
: constant E_Array
:=
296 -- Array of Set routine entities. These are used to assign an element
297 -- of a packed array. The N'th entry is used to assign elements for
298 -- a packed array whose component size is N. RE_Null is used as a null
299 -- entry, for the cases where a library routine is not used.
301 Set_Id
: constant E_Array
:=
366 -- Array of Set routine entities to be used in the case where the packed
367 -- array is itself a component of a packed structure, and therefore may
368 -- not be fully aligned. This only affects the even sizes, since for the
369 -- odd sizes, we do not get any fixed alignment in any case.
371 SetU_Id
: constant E_Array
:=
436 -----------------------
437 -- Local Subprograms --
438 -----------------------
440 procedure Compute_Linear_Subscript
443 Subscr
: out Node_Id
);
444 -- Given a constrained array type Atyp, and an indexed component node
445 -- N referencing an array object of this type, build an expression of
446 -- type Standard.Integer representing the zero-based linear subscript
447 -- value. This expression includes any required range checks.
449 procedure Convert_To_PAT_Type
(Aexp
: Node_Id
);
450 -- Given an expression of a packed array type, builds a corresponding
451 -- expression whose type is the implementation type used to represent
452 -- the packed array. Aexp is analyzed and resolved on entry and on exit.
454 function Known_Aligned_Enough
(Obj
: Node_Id
; Csiz
: Nat
) return Boolean;
455 -- There are two versions of the Set routines, the ones used when the
456 -- object is known to be sufficiently well aligned given the number of
457 -- bits, and the ones used when the object is not known to be aligned.
458 -- This routine is used to determine which set to use. Obj is a reference
459 -- to the object, and Csiz is the component size of the packed array.
460 -- True is returned if the alignment of object is known to be sufficient,
461 -- defined as 1 for odd bit sizes, 4 for bit sizes divisible by 4, and
464 function Make_Shift_Left
(N
: Node_Id
; S
: Node_Id
) return Node_Id
;
465 -- Build a left shift node, checking for the case of a shift count of zero
467 function Make_Shift_Right
(N
: Node_Id
; S
: Node_Id
) return Node_Id
;
468 -- Build a right shift node, checking for the case of a shift count of zero
470 function RJ_Unchecked_Convert_To
472 Expr
: Node_Id
) return Node_Id
;
473 -- The packed array code does unchecked conversions which in some cases
474 -- may involve non-discrete types with differing sizes. The semantics of
475 -- such conversions is potentially endian dependent, and the effect we
476 -- want here for such a conversion is to do the conversion in size as
477 -- though numeric items are involved, and we extend or truncate on the
478 -- left side. This happens naturally in the little-endian case, but in
479 -- the big endian case we can get left justification, when what we want
480 -- is right justification. This routine does the unchecked conversion in
481 -- a stepwise manner to ensure that it gives the expected result. Hence
482 -- the name (RJ = Right justified). The parameters Typ and Expr are as
483 -- for the case of a normal Unchecked_Convert_To call.
485 procedure Setup_Enumeration_Packed_Array_Reference
(N
: Node_Id
);
486 -- This routine is called in the Get and Set case for arrays that are
487 -- packed but not bit-packed, meaning that they have at least one
488 -- subscript that is of an enumeration type with a non-standard
489 -- representation. This routine modifies the given node to properly
490 -- reference the corresponding packed array type.
492 procedure Setup_Inline_Packed_Array_Reference
495 Obj
: in out Node_Id
;
497 Shift
: out Node_Id
);
498 -- This procedure performs common processing on the N_Indexed_Component
499 -- parameter given as N, whose prefix is a reference to a packed array.
500 -- This is used for the get and set when the component size is 1,2,4
501 -- or for other component sizes when the packed array type is a modular
502 -- type (i.e. the cases that are handled with inline code).
506 -- N is the N_Indexed_Component node for the packed array reference
508 -- Atyp is the constrained array type (the actual subtype has been
509 -- computed if necessary to obtain the constraints, but this is still
510 -- the original array type, not the Packed_Array_Type value).
512 -- Obj is the object which is to be indexed. It is always of type Atyp.
516 -- Obj is the object containing the desired bit field. It is of type
517 -- Unsigned, Long_Unsigned, or Long_Long_Unsigned, and is either the
518 -- entire value, for the small static case, or the proper selected byte
519 -- from the array in the large or dynamic case. This node is analyzed
520 -- and resolved on return.
522 -- Shift is a node representing the shift count to be used in the
523 -- rotate right instruction that positions the field for access.
524 -- This node is analyzed and resolved on return.
526 -- Cmask is a mask corresponding to the width of the component field.
527 -- Its value is 2 ** Csize - 1 (e.g. 2#1111# for component size of 4).
529 -- Note: in some cases the call to this routine may generate actions
530 -- (for handling multi-use references and the generation of the packed
531 -- array type on the fly). Such actions are inserted into the tree
532 -- directly using Insert_Action.
534 ------------------------------
535 -- Compute_Linear_Subcsript --
536 ------------------------------
538 procedure Compute_Linear_Subscript
541 Subscr
: out Node_Id
)
543 Loc
: constant Source_Ptr
:= Sloc
(N
);
552 -- Loop through dimensions
554 Indx
:= First_Index
(Atyp
);
555 Oldsub
:= First
(Expressions
(N
));
557 while Present
(Indx
) loop
558 Styp
:= Etype
(Indx
);
559 Newsub
:= Relocate_Node
(Oldsub
);
561 -- Get expression for the subscript value. First, if Do_Range_Check
562 -- is set on a subscript, then we must do a range check against the
563 -- original bounds (not the bounds of the packed array type). We do
564 -- this by introducing a subtype conversion.
566 if Do_Range_Check
(Newsub
)
567 and then Etype
(Newsub
) /= Styp
569 Newsub
:= Convert_To
(Styp
, Newsub
);
572 -- Now evolve the expression for the subscript. First convert
573 -- the subscript to be zero based and of an integer type.
575 -- Case of integer type, where we just subtract to get lower bound
577 if Is_Integer_Type
(Styp
) then
579 -- If length of integer type is smaller than standard integer,
580 -- then we convert to integer first, then do the subtract
582 -- Integer (subscript) - Integer (Styp'First)
584 if Esize
(Styp
) < Esize
(Standard_Integer
) then
586 Make_Op_Subtract
(Loc
,
587 Left_Opnd
=> Convert_To
(Standard_Integer
, Newsub
),
589 Convert_To
(Standard_Integer
,
590 Make_Attribute_Reference
(Loc
,
591 Prefix
=> New_Occurrence_Of
(Styp
, Loc
),
592 Attribute_Name
=> Name_First
)));
594 -- For larger integer types, subtract first, then convert to
595 -- integer, this deals with strange long long integer bounds.
597 -- Integer (subscript - Styp'First)
601 Convert_To
(Standard_Integer
,
602 Make_Op_Subtract
(Loc
,
605 Make_Attribute_Reference
(Loc
,
606 Prefix
=> New_Occurrence_Of
(Styp
, Loc
),
607 Attribute_Name
=> Name_First
)));
610 -- For the enumeration case, we have to use 'Pos to get the value
611 -- to work with before subtracting the lower bound.
613 -- Integer (Styp'Pos (subscr)) - Integer (Styp'Pos (Styp'First));
615 -- This is not quite right for bizarre cases where the size of the
616 -- enumeration type is > Integer'Size bits due to rep clause ???
619 pragma Assert
(Is_Enumeration_Type
(Styp
));
622 Make_Op_Subtract
(Loc
,
623 Left_Opnd
=> Convert_To
(Standard_Integer
,
624 Make_Attribute_Reference
(Loc
,
625 Prefix
=> New_Occurrence_Of
(Styp
, Loc
),
626 Attribute_Name
=> Name_Pos
,
627 Expressions
=> New_List
(Newsub
))),
630 Convert_To
(Standard_Integer
,
631 Make_Attribute_Reference
(Loc
,
632 Prefix
=> New_Occurrence_Of
(Styp
, Loc
),
633 Attribute_Name
=> Name_Pos
,
634 Expressions
=> New_List
(
635 Make_Attribute_Reference
(Loc
,
636 Prefix
=> New_Occurrence_Of
(Styp
, Loc
),
637 Attribute_Name
=> Name_First
)))));
640 Set_Paren_Count
(Newsub
, 1);
642 -- For the first subscript, we just copy that subscript value
647 -- Otherwise, we must multiply what we already have by the current
648 -- stride and then add in the new value to the evolving subscript.
654 Make_Op_Multiply
(Loc
,
657 Make_Attribute_Reference
(Loc
,
658 Attribute_Name
=> Name_Range_Length
,
659 Prefix
=> New_Occurrence_Of
(Styp
, Loc
))),
660 Right_Opnd
=> Newsub
);
663 -- Move to next subscript
668 end Compute_Linear_Subscript
;
670 -------------------------
671 -- Convert_To_PAT_Type --
672 -------------------------
674 -- The PAT is always obtained from the actual subtype
676 procedure Convert_To_PAT_Type
(Aexp
: Entity_Id
) is
680 Convert_To_Actual_Subtype
(Aexp
);
681 Act_ST
:= Underlying_Type
(Etype
(Aexp
));
682 Create_Packed_Array_Type
(Act_ST
);
684 -- Just replace the etype with the packed array type. This works
685 -- because the expression will not be further analyzed, and Gigi
686 -- considers the two types equivalent in any case.
688 -- This is not strictly the case ??? If the reference is an actual
689 -- in a call, the expansion of the prefix is delayed, and must be
690 -- reanalyzed, see Reset_Packed_Prefix. On the other hand, if the
691 -- prefix is a simple array reference, reanalysis can produce spurious
692 -- type errors when the PAT type is replaced again with the original
693 -- type of the array. The following is correct and minimal, but the
694 -- handling of more complex packed expressions in actuals is confused.
695 -- It is likely that the problem only remains for actuals in calls.
697 Set_Etype
(Aexp
, Packed_Array_Type
(Act_ST
));
699 if Is_Entity_Name
(Aexp
)
701 (Nkind
(Aexp
) = N_Indexed_Component
702 and then Is_Entity_Name
(Prefix
(Aexp
)))
706 end Convert_To_PAT_Type
;
708 ------------------------------
709 -- Create_Packed_Array_Type --
710 ------------------------------
712 procedure Create_Packed_Array_Type
(Typ
: Entity_Id
) is
713 Loc
: constant Source_Ptr
:= Sloc
(Typ
);
714 Ctyp
: constant Entity_Id
:= Component_Type
(Typ
);
715 Csize
: constant Uint
:= Component_Size
(Typ
);
730 procedure Install_PAT
;
731 -- This procedure is called with Decl set to the declaration for the
732 -- packed array type. It creates the type and installs it as required.
734 procedure Set_PB_Type
;
735 -- Sets PB_Type to Packed_Bytes{1,2,4} as required by the alignment
736 -- requirements (see documentation in the spec of this package).
742 procedure Install_PAT
is
743 Pushed_Scope
: Boolean := False;
746 -- We do not want to put the declaration we have created in the tree
747 -- since it is often hard, and sometimes impossible to find a proper
748 -- place for it (the impossible case arises for a packed array type
749 -- with bounds depending on the discriminant, a declaration cannot
750 -- be put inside the record, and the reference to the discriminant
751 -- cannot be outside the record).
753 -- The solution is to analyze the declaration while temporarily
754 -- attached to the tree at an appropriate point, and then we install
755 -- the resulting type as an Itype in the packed array type field of
756 -- the original type, so that no explicit declaration is required.
758 -- Note: the packed type is created in the scope of its parent
759 -- type. There are at least some cases where the current scope
760 -- is deeper, and so when this is the case, we temporarily reset
761 -- the scope for the definition. This is clearly safe, since the
762 -- first use of the packed array type will be the implicit
763 -- reference from the corresponding unpacked type when it is
766 if Is_Itype
(Typ
) then
767 Set_Parent
(Decl
, Associated_Node_For_Itype
(Typ
));
769 Set_Parent
(Decl
, Declaration_Node
(Typ
));
772 if Scope
(Typ
) /= Current_Scope
then
773 New_Scope
(Scope
(Typ
));
774 Pushed_Scope
:= True;
777 Set_Is_Itype
(PAT
, True);
778 Set_Packed_Array_Type
(Typ
, PAT
);
779 Analyze
(Decl
, Suppress
=> All_Checks
);
785 -- Set Esize and RM_Size to the actual size of the packed object
786 -- Do not reset RM_Size if already set, as happens in the case
787 -- of a modular type.
789 Set_Esize
(PAT
, PASize
);
791 if Unknown_RM_Size
(PAT
) then
792 Set_RM_Size
(PAT
, PASize
);
795 -- Set remaining fields of packed array type
797 Init_Alignment
(PAT
);
798 Set_Parent
(PAT
, Empty
);
799 Set_Associated_Node_For_Itype
(PAT
, Typ
);
800 Set_Is_Packed_Array_Type
(PAT
, True);
801 Set_Original_Array_Type
(PAT
, Typ
);
803 -- We definitely do not want to delay freezing for packed array
804 -- types. This is of particular importance for the itypes that
805 -- are generated for record components depending on discriminants
806 -- where there is no place to put the freeze node.
808 Set_Has_Delayed_Freeze
(PAT
, False);
809 Set_Has_Delayed_Freeze
(Etype
(PAT
), False);
811 -- If we did allocate a freeze node, then clear out the reference
812 -- since it is obsolete (should we delete the freeze node???)
814 Set_Freeze_Node
(PAT
, Empty
);
815 Set_Freeze_Node
(Etype
(PAT
), Empty
);
822 procedure Set_PB_Type
is
824 -- If the user has specified an explicit alignment for the
825 -- type or component, take it into account.
827 if Csize
<= 2 or else Csize
= 4 or else Csize
mod 2 /= 0
828 or else Alignment
(Typ
) = 1
829 or else Component_Alignment
(Typ
) = Calign_Storage_Unit
831 PB_Type
:= RTE
(RE_Packed_Bytes1
);
833 elsif Csize
mod 4 /= 0
834 or else Alignment
(Typ
) = 2
836 PB_Type
:= RTE
(RE_Packed_Bytes2
);
839 PB_Type
:= RTE
(RE_Packed_Bytes4
);
843 -- Start of processing for Create_Packed_Array_Type
846 -- If we already have a packed array type, nothing to do
848 if Present
(Packed_Array_Type
(Typ
)) then
852 -- If our immediate ancestor subtype is constrained, and it already
853 -- has a packed array type, then just share the same type, since the
854 -- bounds must be the same. If the ancestor is not an array type but
855 -- a private type, as can happen with multiple instantiations, create
856 -- a new packed type, to avoid privacy issues.
858 if Ekind
(Typ
) = E_Array_Subtype
then
859 Ancest
:= Ancestor_Subtype
(Typ
);
862 and then Is_Array_Type
(Ancest
)
863 and then Is_Constrained
(Ancest
)
864 and then Present
(Packed_Array_Type
(Ancest
))
866 Set_Packed_Array_Type
(Typ
, Packed_Array_Type
(Ancest
));
871 -- We preset the result type size from the size of the original array
872 -- type, since this size clearly belongs to the packed array type. The
873 -- size of the conceptual unpacked type is always set to unknown.
875 PASize
:= Esize
(Typ
);
877 -- Case of an array where at least one index is of an enumeration
878 -- type with a non-standard representation, but the component size
879 -- is not appropriate for bit packing. This is the case where we
880 -- have Is_Packed set (we would never be in this unit otherwise),
881 -- but Is_Bit_Packed_Array is false.
883 -- Note that if the component size is appropriate for bit packing,
884 -- then the circuit for the computation of the subscript properly
885 -- deals with the non-standard enumeration type case by taking the
888 if not Is_Bit_Packed_Array
(Typ
) then
890 -- Here we build a declaration:
892 -- type tttP is array (index1, index2, ...) of component_type
894 -- where index1, index2, are the index types. These are the same
895 -- as the index types of the original array, except for the non-
896 -- standard representation enumeration type case, where we have
899 -- For the unconstrained array case, we use
903 -- For the constrained case, we use
905 -- Natural range Enum_Type'Pos (Enum_Type'First) ..
906 -- Enum_Type'Pos (Enum_Type'Last);
909 Make_Defining_Identifier
(Loc
,
910 Chars
=> New_External_Name
(Chars
(Typ
), 'P'));
912 Set_Packed_Array_Type
(Typ
, PAT
);
915 Indexes
: constant List_Id
:= New_List
;
917 Indx_Typ
: Entity_Id
;
922 Indx
:= First_Index
(Typ
);
924 while Present
(Indx
) loop
925 Indx_Typ
:= Etype
(Indx
);
927 Enum_Case
:= Is_Enumeration_Type
(Indx_Typ
)
928 and then Has_Non_Standard_Rep
(Indx_Typ
);
930 -- Unconstrained case
932 if not Is_Constrained
(Typ
) then
934 Indx_Typ
:= Standard_Natural
;
937 Append_To
(Indexes
, New_Occurrence_Of
(Indx_Typ
, Loc
));
942 if not Enum_Case
then
943 Append_To
(Indexes
, New_Occurrence_Of
(Indx_Typ
, Loc
));
947 Make_Subtype_Indication
(Loc
,
949 New_Occurrence_Of
(Standard_Natural
, Loc
),
951 Make_Range_Constraint
(Loc
,
955 Make_Attribute_Reference
(Loc
,
957 New_Occurrence_Of
(Indx_Typ
, Loc
),
958 Attribute_Name
=> Name_Pos
,
959 Expressions
=> New_List
(
960 Make_Attribute_Reference
(Loc
,
962 New_Occurrence_Of
(Indx_Typ
, Loc
),
963 Attribute_Name
=> Name_First
))),
966 Make_Attribute_Reference
(Loc
,
968 New_Occurrence_Of
(Indx_Typ
, Loc
),
969 Attribute_Name
=> Name_Pos
,
970 Expressions
=> New_List
(
971 Make_Attribute_Reference
(Loc
,
973 New_Occurrence_Of
(Indx_Typ
, Loc
),
974 Attribute_Name
=> Name_Last
)))))));
982 if not Is_Constrained
(Typ
) then
984 Make_Unconstrained_Array_Definition
(Loc
,
985 Subtype_Marks
=> Indexes
,
986 Component_Definition
=>
987 Make_Component_Definition
(Loc
,
988 Aliased_Present
=> False,
989 Subtype_Indication
=>
990 New_Occurrence_Of
(Ctyp
, Loc
)));
994 Make_Constrained_Array_Definition
(Loc
,
995 Discrete_Subtype_Definitions
=> Indexes
,
996 Component_Definition
=>
997 Make_Component_Definition
(Loc
,
998 Aliased_Present
=> False,
999 Subtype_Indication
=>
1000 New_Occurrence_Of
(Ctyp
, Loc
)));
1004 Make_Full_Type_Declaration
(Loc
,
1005 Defining_Identifier
=> PAT
,
1006 Type_Definition
=> Typedef
);
1009 -- Set type as packed array type and install it
1011 Set_Is_Packed_Array_Type
(PAT
);
1015 -- Case of bit-packing required for unconstrained array. We create
1016 -- a subtype that is equivalent to use Packed_Bytes{1,2,4} as needed.
1018 elsif not Is_Constrained
(Typ
) then
1020 Make_Defining_Identifier
(Loc
,
1021 Chars
=> Make_Packed_Array_Type_Name
(Typ
, Csize
));
1023 Set_Packed_Array_Type
(Typ
, PAT
);
1027 Make_Subtype_Declaration
(Loc
,
1028 Defining_Identifier
=> PAT
,
1029 Subtype_Indication
=> New_Occurrence_Of
(PB_Type
, Loc
));
1033 -- Remaining code is for the case of bit-packing for constrained array
1035 -- The name of the packed array subtype is
1039 -- where sss is the component size in bits and ttt is the name of
1040 -- the parent packed type.
1044 Make_Defining_Identifier
(Loc
,
1045 Chars
=> Make_Packed_Array_Type_Name
(Typ
, Csize
));
1047 Set_Packed_Array_Type
(Typ
, PAT
);
1049 -- Build an expression for the length of the array in bits.
1050 -- This is the product of the length of each of the dimensions
1056 Len_Expr
:= Empty
; -- suppress junk warning
1060 Make_Attribute_Reference
(Loc
,
1061 Attribute_Name
=> Name_Length
,
1062 Prefix
=> New_Occurrence_Of
(Typ
, Loc
),
1063 Expressions
=> New_List
(
1064 Make_Integer_Literal
(Loc
, J
)));
1067 Len_Expr
:= Len_Dim
;
1071 Make_Op_Multiply
(Loc
,
1072 Left_Opnd
=> Len_Expr
,
1073 Right_Opnd
=> Len_Dim
);
1077 exit when J
> Number_Dimensions
(Typ
);
1081 -- Temporarily attach the length expression to the tree and analyze
1082 -- and resolve it, so that we can test its value. We assume that the
1083 -- total length fits in type Integer. This expression may involve
1084 -- discriminants, so we treat it as a default/per-object expression.
1086 Set_Parent
(Len_Expr
, Typ
);
1087 Analyze_Per_Use_Expression
(Len_Expr
, Standard_Integer
);
1089 -- Use a modular type if possible. We can do this if we have
1090 -- static bounds, and the length is small enough, and the length
1091 -- is not zero. We exclude the zero length case because the size
1092 -- of things is always at least one, and the zero length object
1093 -- would have an anomalous size.
1095 if Compile_Time_Known_Value
(Len_Expr
) then
1096 Len_Bits
:= Expr_Value
(Len_Expr
) * Csize
;
1098 -- We normally consider small enough to mean no larger than the
1099 -- value of System_Max_Binary_Modulus_Power, checking that in the
1100 -- case of values longer than word size, we have long shifts.
1104 (Len_Bits
<= System_Word_Size
1105 or else (Len_Bits
<= System_Max_Binary_Modulus_Power
1106 and then Support_Long_Shifts_On_Target
))
1108 -- Also test for alignment given. If an alignment is given which
1109 -- is smaller than the natural modular alignment, force the array
1110 -- of bytes representation to accommodate the alignment.
1113 (No
(Alignment_Clause
(Typ
))
1115 Alignment
(Typ
) >= ((Len_Bits
+ System_Storage_Unit
)
1116 / System_Storage_Unit
))
1118 -- We can use the modular type, it has the form:
1120 -- subtype tttPn is btyp
1121 -- range 0 .. 2 ** ((Typ'Length (1)
1122 -- * ... * Typ'Length (n)) * Csize) - 1;
1124 -- The bounds are statically known, and btyp is one
1125 -- of the unsigned types, depending on the length. If the
1126 -- type is its first subtype, i.e. it is a user-defined
1127 -- type, no object of the type will be larger, and it is
1128 -- worthwhile to use a small unsigned type.
1130 if Len_Bits
<= Standard_Short_Integer_Size
1131 and then First_Subtype
(Typ
) = Typ
1133 Btyp
:= RTE
(RE_Short_Unsigned
);
1135 elsif Len_Bits
<= Standard_Integer_Size
then
1136 Btyp
:= RTE
(RE_Unsigned
);
1138 elsif Len_Bits
<= Standard_Long_Integer_Size
then
1139 Btyp
:= RTE
(RE_Long_Unsigned
);
1142 Btyp
:= RTE
(RE_Long_Long_Unsigned
);
1145 Lit
:= Make_Integer_Literal
(Loc
, 2 ** Len_Bits
- 1);
1146 Set_Print_In_Hex
(Lit
);
1149 Make_Subtype_Declaration
(Loc
,
1150 Defining_Identifier
=> PAT
,
1151 Subtype_Indication
=>
1152 Make_Subtype_Indication
(Loc
,
1153 Subtype_Mark
=> New_Occurrence_Of
(Btyp
, Loc
),
1156 Make_Range_Constraint
(Loc
,
1160 Make_Integer_Literal
(Loc
, 0),
1161 High_Bound
=> Lit
))));
1163 if PASize
= Uint_0
then
1172 -- Could not use a modular type, for all other cases, we build
1173 -- a packed array subtype:
1176 -- System.Packed_Bytes{1,2,4} (0 .. (Bits + 7) / 8 - 1);
1178 -- Bits is the length of the array in bits
1185 Make_Op_Multiply
(Loc
,
1187 Make_Integer_Literal
(Loc
, Csize
),
1188 Right_Opnd
=> Len_Expr
),
1191 Make_Integer_Literal
(Loc
, 7));
1193 Set_Paren_Count
(Bits_U1
, 1);
1196 Make_Op_Subtract
(Loc
,
1198 Make_Op_Divide
(Loc
,
1199 Left_Opnd
=> Bits_U1
,
1200 Right_Opnd
=> Make_Integer_Literal
(Loc
, 8)),
1201 Right_Opnd
=> Make_Integer_Literal
(Loc
, 1));
1204 Make_Subtype_Declaration
(Loc
,
1205 Defining_Identifier
=> PAT
,
1206 Subtype_Indication
=>
1207 Make_Subtype_Indication
(Loc
,
1208 Subtype_Mark
=> New_Occurrence_Of
(PB_Type
, Loc
),
1211 Make_Index_Or_Discriminant_Constraint
(Loc
,
1212 Constraints
=> New_List
(
1215 Make_Integer_Literal
(Loc
, 0),
1216 High_Bound
=> PAT_High
)))));
1220 -- Currently the code in this unit requires that packed arrays
1221 -- represented by non-modular arrays of bytes be on a byte
1222 -- boundary for bit sizes handled by System.Pack_nn units.
1223 -- That's because these units assume the array being accessed
1224 -- starts on a byte boundary.
1226 if Get_Id
(UI_To_Int
(Csize
)) /= RE_Null
then
1227 Set_Must_Be_On_Byte_Boundary
(Typ
);
1230 end Create_Packed_Array_Type
;
1232 -----------------------------------
1233 -- Expand_Bit_Packed_Element_Set --
1234 -----------------------------------
1236 procedure Expand_Bit_Packed_Element_Set
(N
: Node_Id
) is
1237 Loc
: constant Source_Ptr
:= Sloc
(N
);
1238 Lhs
: constant Node_Id
:= Name
(N
);
1240 Ass_OK
: constant Boolean := Assignment_OK
(Lhs
);
1241 -- Used to preserve assignment OK status when assignment is rewritten
1243 Rhs
: Node_Id
:= Expression
(N
);
1244 -- Initially Rhs is the right hand side value, it will be replaced
1245 -- later by an appropriate unchecked conversion for the assignment.
1255 -- The expression for the shift value that is required
1257 Shift_Used
: Boolean := False;
1258 -- Set True if Shift has been used in the generated code at least
1259 -- once, so that it must be duplicated if used again
1264 Rhs_Val_Known
: Boolean;
1266 -- If the value of the right hand side as an integer constant is
1267 -- known at compile time, Rhs_Val_Known is set True, and Rhs_Val
1268 -- contains the value. Otherwise Rhs_Val_Known is set False, and
1269 -- the Rhs_Val is undefined.
1271 function Get_Shift
return Node_Id
;
1272 -- Function used to get the value of Shift, making sure that it
1273 -- gets duplicated if the function is called more than once.
1279 function Get_Shift
return Node_Id
is
1281 -- If we used the shift value already, then duplicate it. We
1282 -- set a temporary parent in case actions have to be inserted.
1285 Set_Parent
(Shift
, N
);
1286 return Duplicate_Subexpr_No_Checks
(Shift
);
1288 -- If first time, use Shift unchanged, and set flag for first use
1296 -- Start of processing for Expand_Bit_Packed_Element_Set
1299 pragma Assert
(Is_Bit_Packed_Array
(Etype
(Prefix
(Lhs
))));
1301 Obj
:= Relocate_Node
(Prefix
(Lhs
));
1302 Convert_To_Actual_Subtype
(Obj
);
1303 Atyp
:= Etype
(Obj
);
1304 PAT
:= Packed_Array_Type
(Atyp
);
1305 Ctyp
:= Component_Type
(Atyp
);
1306 Csiz
:= UI_To_Int
(Component_Size
(Atyp
));
1308 -- We convert the right hand side to the proper subtype to ensure
1309 -- that an appropriate range check is made (since the normal range
1310 -- check from assignment will be lost in the transformations). This
1311 -- conversion is analyzed immediately so that subsequent processing
1312 -- can work with an analyzed Rhs (and e.g. look at its Etype)
1314 -- If the right-hand side is a string literal, create a temporary for
1315 -- it, constant-folding is not ready to wrap the bit representation
1316 -- of a string literal.
1318 if Nkind
(Rhs
) = N_String_Literal
then
1323 Make_Object_Declaration
(Loc
,
1324 Defining_Identifier
=>
1325 Make_Defining_Identifier
(Loc
, New_Internal_Name
('T')),
1326 Object_Definition
=> New_Occurrence_Of
(Ctyp
, Loc
),
1327 Expression
=> New_Copy_Tree
(Rhs
));
1329 Insert_Actions
(N
, New_List
(Decl
));
1330 Rhs
:= New_Occurrence_Of
(Defining_Identifier
(Decl
), Loc
);
1334 Rhs
:= Convert_To
(Ctyp
, Rhs
);
1335 Set_Parent
(Rhs
, N
);
1336 Analyze_And_Resolve
(Rhs
, Ctyp
);
1338 -- Case of component size 1,2,4 or any component size for the modular
1339 -- case. These are the cases for which we can inline the code.
1341 if Csiz
= 1 or else Csiz
= 2 or else Csiz
= 4
1342 or else (Present
(PAT
) and then Is_Modular_Integer_Type
(PAT
))
1344 Setup_Inline_Packed_Array_Reference
(Lhs
, Atyp
, Obj
, Cmask
, Shift
);
1346 -- The statement to be generated is:
1348 -- Obj := atyp!((Obj and Mask1) or (shift_left (rhs, shift)))
1350 -- where mask1 is obtained by shifting Cmask left Shift bits
1351 -- and then complementing the result.
1353 -- the "and Mask1" is omitted if rhs is constant and all 1 bits
1355 -- the "or ..." is omitted if rhs is constant and all 0 bits
1357 -- rhs is converted to the appropriate type
1359 -- The result is converted back to the array type, since
1360 -- otherwise we lose knowledge of the packed nature.
1362 -- Determine if right side is all 0 bits or all 1 bits
1364 if Compile_Time_Known_Value
(Rhs
) then
1365 Rhs_Val
:= Expr_Rep_Value
(Rhs
);
1366 Rhs_Val_Known
:= True;
1368 -- The following test catches the case of an unchecked conversion
1369 -- of an integer literal. This results from optimizing aggregates
1372 elsif Nkind
(Rhs
) = N_Unchecked_Type_Conversion
1373 and then Compile_Time_Known_Value
(Expression
(Rhs
))
1375 Rhs_Val
:= Expr_Rep_Value
(Expression
(Rhs
));
1376 Rhs_Val_Known
:= True;
1380 Rhs_Val_Known
:= False;
1383 -- Some special checks for the case where the right hand value
1384 -- is known at compile time. Basically we have to take care of
1385 -- the implicit conversion to the subtype of the component object.
1387 if Rhs_Val_Known
then
1389 -- If we have a biased component type then we must manually do
1390 -- the biasing, since we are taking responsibility in this case
1391 -- for constructing the exact bit pattern to be used.
1393 if Has_Biased_Representation
(Ctyp
) then
1394 Rhs_Val
:= Rhs_Val
- Expr_Rep_Value
(Type_Low_Bound
(Ctyp
));
1397 -- For a negative value, we manually convert the twos complement
1398 -- value to a corresponding unsigned value, so that the proper
1399 -- field width is maintained. If we did not do this, we would
1400 -- get too many leading sign bits later on.
1403 Rhs_Val
:= 2 ** UI_From_Int
(Csiz
) + Rhs_Val
;
1407 New_Lhs
:= Duplicate_Subexpr
(Obj
, True);
1408 New_Rhs
:= Duplicate_Subexpr_No_Checks
(Obj
);
1410 -- First we deal with the "and"
1412 if not Rhs_Val_Known
or else Rhs_Val
/= Cmask
then
1418 if Compile_Time_Known_Value
(Shift
) then
1420 Make_Integer_Literal
(Loc
,
1421 Modulus
(Etype
(Obj
)) - 1 -
1422 (Cmask
* (2 ** Expr_Value
(Get_Shift
))));
1423 Set_Print_In_Hex
(Mask1
);
1426 Lit
:= Make_Integer_Literal
(Loc
, Cmask
);
1427 Set_Print_In_Hex
(Lit
);
1430 Right_Opnd
=> Make_Shift_Left
(Lit
, Get_Shift
));
1435 Left_Opnd
=> New_Rhs
,
1436 Right_Opnd
=> Mask1
);
1440 -- Then deal with the "or"
1442 if not Rhs_Val_Known
or else Rhs_Val
/= 0 then
1446 procedure Fixup_Rhs
;
1447 -- Adjust Rhs by bias if biased representation for components
1448 -- or remove extraneous high order sign bits if signed.
1450 procedure Fixup_Rhs
is
1451 Etyp
: constant Entity_Id
:= Etype
(Rhs
);
1454 -- For biased case, do the required biasing by simply
1455 -- converting to the biased subtype (the conversion
1456 -- will generate the required bias).
1458 if Has_Biased_Representation
(Ctyp
) then
1459 Rhs
:= Convert_To
(Ctyp
, Rhs
);
1461 -- For a signed integer type that is not biased, generate
1462 -- a conversion to unsigned to strip high order sign bits.
1464 elsif Is_Signed_Integer_Type
(Ctyp
) then
1465 Rhs
:= Unchecked_Convert_To
(RTE
(Bits_Id
(Csiz
)), Rhs
);
1468 -- Set Etype, since it can be referenced before the
1469 -- node is completely analyzed.
1471 Set_Etype
(Rhs
, Etyp
);
1473 -- We now need to do an unchecked conversion of the
1474 -- result to the target type, but it is important that
1475 -- this conversion be a right justified conversion and
1476 -- not a left justified conversion.
1478 Rhs
:= RJ_Unchecked_Convert_To
(Etype
(Obj
), Rhs
);
1484 and then Compile_Time_Known_Value
(Get_Shift
)
1487 Make_Integer_Literal
(Loc
,
1488 Rhs_Val
* (2 ** Expr_Value
(Get_Shift
)));
1489 Set_Print_In_Hex
(Or_Rhs
);
1492 -- We have to convert the right hand side to Etype (Obj).
1493 -- A special case case arises if what we have now is a Val
1494 -- attribute reference whose expression type is Etype (Obj).
1495 -- This happens for assignments of fields from the same
1496 -- array. In this case we get the required right hand side
1497 -- by simply removing the inner attribute reference.
1499 if Nkind
(Rhs
) = N_Attribute_Reference
1500 and then Attribute_Name
(Rhs
) = Name_Val
1501 and then Etype
(First
(Expressions
(Rhs
))) = Etype
(Obj
)
1503 Rhs
:= Relocate_Node
(First
(Expressions
(Rhs
)));
1506 -- If the value of the right hand side is a known integer
1507 -- value, then just replace it by an untyped constant,
1508 -- which will be properly retyped when we analyze and
1509 -- resolve the expression.
1511 elsif Rhs_Val_Known
then
1513 -- Note that Rhs_Val has already been normalized to
1514 -- be an unsigned value with the proper number of bits.
1517 Make_Integer_Literal
(Loc
, Rhs_Val
);
1519 -- Otherwise we need an unchecked conversion
1525 Or_Rhs
:= Make_Shift_Left
(Rhs
, Get_Shift
);
1528 if Nkind
(New_Rhs
) = N_Op_And
then
1529 Set_Paren_Count
(New_Rhs
, 1);
1534 Left_Opnd
=> New_Rhs
,
1535 Right_Opnd
=> Or_Rhs
);
1539 -- Now do the rewrite
1542 Make_Assignment_Statement
(Loc
,
1545 Unchecked_Convert_To
(Etype
(New_Lhs
), New_Rhs
)));
1546 Set_Assignment_OK
(Name
(N
), Ass_OK
);
1548 -- All other component sizes for non-modular case
1553 -- Set_nn (Arr'address, Subscr, Bits_nn!(Rhs))
1555 -- where Subscr is the computed linear subscript
1558 Bits_nn
: constant Entity_Id
:= RTE
(Bits_Id
(Csiz
));
1564 if No
(Bits_nn
) then
1566 -- Error, most likely High_Integrity_Mode restriction
1571 -- Acquire proper Set entity. We use the aligned or unaligned
1572 -- case as appropriate.
1574 if Known_Aligned_Enough
(Obj
, Csiz
) then
1575 Set_nn
:= RTE
(Set_Id
(Csiz
));
1577 Set_nn
:= RTE
(SetU_Id
(Csiz
));
1580 -- Now generate the set reference
1582 Obj
:= Relocate_Node
(Prefix
(Lhs
));
1583 Convert_To_Actual_Subtype
(Obj
);
1584 Atyp
:= Etype
(Obj
);
1585 Compute_Linear_Subscript
(Atyp
, Lhs
, Subscr
);
1587 -- Below we must make the assumption that Obj is
1588 -- at least byte aligned, since otherwise its address
1589 -- cannot be taken. The assumption holds since the
1590 -- only arrays that can be misaligned are small packed
1591 -- arrays which are implemented as a modular type, and
1592 -- that is not the case here.
1595 Make_Procedure_Call_Statement
(Loc
,
1596 Name
=> New_Occurrence_Of
(Set_nn
, Loc
),
1597 Parameter_Associations
=> New_List
(
1598 Make_Attribute_Reference
(Loc
,
1599 Attribute_Name
=> Name_Address
,
1602 Unchecked_Convert_To
(Bits_nn
,
1603 Convert_To
(Ctyp
, Rhs
)))));
1608 Analyze
(N
, Suppress
=> All_Checks
);
1609 end Expand_Bit_Packed_Element_Set
;
1611 -------------------------------------
1612 -- Expand_Packed_Address_Reference --
1613 -------------------------------------
1615 procedure Expand_Packed_Address_Reference
(N
: Node_Id
) is
1616 Loc
: constant Source_Ptr
:= Sloc
(N
);
1628 -- We build up an expression serially that has the form
1630 -- outer_object'Address
1631 -- + (linear-subscript * component_size for each array reference
1632 -- + field'Bit_Position for each record field
1634 -- + ...) / Storage_Unit;
1636 -- Some additional conversions are required to deal with the addition
1637 -- operation, which is not normally visible to generated code.
1640 Ploc
:= Sloc
(Pref
);
1642 if Nkind
(Pref
) = N_Indexed_Component
then
1643 Convert_To_Actual_Subtype
(Prefix
(Pref
));
1644 Atyp
:= Etype
(Prefix
(Pref
));
1645 Compute_Linear_Subscript
(Atyp
, Pref
, Subscr
);
1648 Make_Op_Multiply
(Ploc
,
1649 Left_Opnd
=> Subscr
,
1651 Make_Attribute_Reference
(Ploc
,
1652 Prefix
=> New_Occurrence_Of
(Atyp
, Ploc
),
1653 Attribute_Name
=> Name_Component_Size
));
1655 elsif Nkind
(Pref
) = N_Selected_Component
then
1657 Make_Attribute_Reference
(Ploc
,
1658 Prefix
=> Selector_Name
(Pref
),
1659 Attribute_Name
=> Name_Bit_Position
);
1665 Term
:= Convert_To
(RTE
(RE_Integer_Address
), Term
);
1674 Right_Opnd
=> Term
);
1677 Pref
:= Prefix
(Pref
);
1681 Unchecked_Convert_To
(RTE
(RE_Address
),
1684 Unchecked_Convert_To
(RTE
(RE_Integer_Address
),
1685 Make_Attribute_Reference
(Loc
,
1687 Attribute_Name
=> Name_Address
)),
1690 Make_Op_Divide
(Loc
,
1693 Make_Integer_Literal
(Loc
, System_Storage_Unit
)))));
1695 Analyze_And_Resolve
(N
, RTE
(RE_Address
));
1696 end Expand_Packed_Address_Reference
;
1698 ------------------------------------
1699 -- Expand_Packed_Boolean_Operator --
1700 ------------------------------------
1702 -- This routine expands "a op b" for the packed cases
1704 procedure Expand_Packed_Boolean_Operator
(N
: Node_Id
) is
1705 Loc
: constant Source_Ptr
:= Sloc
(N
);
1706 Typ
: constant Entity_Id
:= Etype
(N
);
1707 L
: constant Node_Id
:= Relocate_Node
(Left_Opnd
(N
));
1708 R
: constant Node_Id
:= Relocate_Node
(Right_Opnd
(N
));
1715 Convert_To_Actual_Subtype
(L
);
1716 Convert_To_Actual_Subtype
(R
);
1718 Ensure_Defined
(Etype
(L
), N
);
1719 Ensure_Defined
(Etype
(R
), N
);
1721 Apply_Length_Check
(R
, Etype
(L
));
1726 -- First an odd and silly test. We explicitly check for the XOR
1727 -- case where the component type is True .. True, since this will
1728 -- raise constraint error. A special check is required since CE
1729 -- will not be required other wise (cf Expand_Packed_Not).
1731 -- No such check is required for AND and OR, since for both these
1732 -- cases False op False = False, and True op True = True.
1734 if Nkind
(N
) = N_Op_Xor
then
1736 CT
: constant Entity_Id
:= Component_Type
(Rtyp
);
1737 BT
: constant Entity_Id
:= Base_Type
(CT
);
1741 Make_Raise_Constraint_Error
(Loc
,
1747 Make_Attribute_Reference
(Loc
,
1748 Prefix
=> New_Occurrence_Of
(CT
, Loc
),
1749 Attribute_Name
=> Name_First
),
1753 New_Occurrence_Of
(Standard_True
, Loc
))),
1758 Make_Attribute_Reference
(Loc
,
1759 Prefix
=> New_Occurrence_Of
(CT
, Loc
),
1760 Attribute_Name
=> Name_Last
),
1764 New_Occurrence_Of
(Standard_True
, Loc
)))),
1765 Reason
=> CE_Range_Check_Failed
));
1769 -- Now that that silliness is taken care of, get packed array type
1771 Convert_To_PAT_Type
(L
);
1772 Convert_To_PAT_Type
(R
);
1776 -- For the modular case, we expand a op b into
1778 -- rtyp!(pat!(a) op pat!(b))
1780 -- where rtyp is the Etype of the left operand. Note that we do not
1781 -- convert to the base type, since this would be unconstrained, and
1782 -- hence not have a corresponding packed array type set.
1784 -- Note that both operands must be modular for this code to be used
1786 if Is_Modular_Integer_Type
(PAT
)
1788 Is_Modular_Integer_Type
(Etype
(R
))
1794 if Nkind
(N
) = N_Op_And
then
1795 P
:= Make_Op_And
(Loc
, L
, R
);
1797 elsif Nkind
(N
) = N_Op_Or
then
1798 P
:= Make_Op_Or
(Loc
, L
, R
);
1800 else -- Nkind (N) = N_Op_Xor
1801 P
:= Make_Op_Xor
(Loc
, L
, R
);
1804 Rewrite
(N
, Unchecked_Convert_To
(Rtyp
, P
));
1807 -- For the array case, we insert the actions
1811 -- System.Bitops.Bit_And/Or/Xor
1813 -- Ltype'Length * Ltype'Component_Size;
1815 -- Rtype'Length * Rtype'Component_Size
1818 -- where Left and Right are the Packed_Bytes{1,2,4} operands and
1819 -- the second argument and fourth arguments are the lengths of the
1820 -- operands in bits. Then we replace the expression by a reference
1823 -- Note that if we are mixing a modular and array operand, everything
1824 -- works fine, since we ensure that the modular representation has the
1825 -- same physical layout as the array representation (that's what the
1826 -- left justified modular stuff in the big-endian case is about).
1830 Result_Ent
: constant Entity_Id
:=
1831 Make_Defining_Identifier
(Loc
,
1832 Chars
=> New_Internal_Name
('T'));
1837 if Nkind
(N
) = N_Op_And
then
1840 elsif Nkind
(N
) = N_Op_Or
then
1843 else -- Nkind (N) = N_Op_Xor
1847 Insert_Actions
(N
, New_List
(
1849 Make_Object_Declaration
(Loc
,
1850 Defining_Identifier
=> Result_Ent
,
1851 Object_Definition
=> New_Occurrence_Of
(Ltyp
, Loc
)),
1853 Make_Procedure_Call_Statement
(Loc
,
1854 Name
=> New_Occurrence_Of
(RTE
(E_Id
), Loc
),
1855 Parameter_Associations
=> New_List
(
1857 Make_Byte_Aligned_Attribute_Reference
(Loc
,
1858 Attribute_Name
=> Name_Address
,
1861 Make_Op_Multiply
(Loc
,
1863 Make_Attribute_Reference
(Loc
,
1866 (Etype
(First_Index
(Ltyp
)), Loc
),
1867 Attribute_Name
=> Name_Range_Length
),
1869 Make_Integer_Literal
(Loc
, Component_Size
(Ltyp
))),
1871 Make_Byte_Aligned_Attribute_Reference
(Loc
,
1872 Attribute_Name
=> Name_Address
,
1875 Make_Op_Multiply
(Loc
,
1877 Make_Attribute_Reference
(Loc
,
1880 (Etype
(First_Index
(Rtyp
)), Loc
),
1881 Attribute_Name
=> Name_Range_Length
),
1883 Make_Integer_Literal
(Loc
, Component_Size
(Rtyp
))),
1885 Make_Byte_Aligned_Attribute_Reference
(Loc
,
1886 Attribute_Name
=> Name_Address
,
1887 Prefix
=> New_Occurrence_Of
(Result_Ent
, Loc
))))));
1890 New_Occurrence_Of
(Result_Ent
, Loc
));
1894 Analyze_And_Resolve
(N
, Typ
, Suppress
=> All_Checks
);
1895 end Expand_Packed_Boolean_Operator
;
1897 -------------------------------------
1898 -- Expand_Packed_Element_Reference --
1899 -------------------------------------
1901 procedure Expand_Packed_Element_Reference
(N
: Node_Id
) is
1902 Loc
: constant Source_Ptr
:= Sloc
(N
);
1914 -- If not bit packed, we have the enumeration case, which is easily
1915 -- dealt with (just adjust the subscripts of the indexed component)
1917 -- Note: this leaves the result as an indexed component, which is
1918 -- still a variable, so can be used in the assignment case, as is
1919 -- required in the enumeration case.
1921 if not Is_Bit_Packed_Array
(Etype
(Prefix
(N
))) then
1922 Setup_Enumeration_Packed_Array_Reference
(N
);
1926 -- Remaining processing is for the bit-packed case
1928 Obj
:= Relocate_Node
(Prefix
(N
));
1929 Convert_To_Actual_Subtype
(Obj
);
1930 Atyp
:= Etype
(Obj
);
1931 PAT
:= Packed_Array_Type
(Atyp
);
1932 Ctyp
:= Component_Type
(Atyp
);
1933 Csiz
:= UI_To_Int
(Component_Size
(Atyp
));
1935 -- Case of component size 1,2,4 or any component size for the modular
1936 -- case. These are the cases for which we can inline the code.
1938 if Csiz
= 1 or else Csiz
= 2 or else Csiz
= 4
1939 or else (Present
(PAT
) and then Is_Modular_Integer_Type
(PAT
))
1941 Setup_Inline_Packed_Array_Reference
(N
, Atyp
, Obj
, Cmask
, Shift
);
1942 Lit
:= Make_Integer_Literal
(Loc
, Cmask
);
1943 Set_Print_In_Hex
(Lit
);
1945 -- We generate a shift right to position the field, followed by a
1946 -- masking operation to extract the bit field, and we finally do an
1947 -- unchecked conversion to convert the result to the required target.
1949 -- Note that the unchecked conversion automatically deals with the
1950 -- bias if we are dealing with a biased representation. What will
1951 -- happen is that we temporarily generate the biased representation,
1952 -- but almost immediately that will be converted to the original
1953 -- unbiased component type, and the bias will disappear.
1957 Left_Opnd
=> Make_Shift_Right
(Obj
, Shift
),
1960 -- We neded to analyze this before we do the unchecked convert
1961 -- below, but we need it temporarily attached to the tree for
1962 -- this analysis (hence the temporary Set_Parent call).
1964 Set_Parent
(Arg
, Parent
(N
));
1965 Analyze_And_Resolve
(Arg
);
1968 RJ_Unchecked_Convert_To
(Ctyp
, Arg
));
1970 -- All other component sizes for non-modular case
1975 -- Component_Type!(Get_nn (Arr'address, Subscr))
1977 -- where Subscr is the computed linear subscript
1984 -- Acquire proper Get entity. We use the aligned or unaligned
1985 -- case as appropriate.
1987 if Known_Aligned_Enough
(Obj
, Csiz
) then
1988 Get_nn
:= RTE
(Get_Id
(Csiz
));
1990 Get_nn
:= RTE
(GetU_Id
(Csiz
));
1993 -- Now generate the get reference
1995 Compute_Linear_Subscript
(Atyp
, N
, Subscr
);
1997 -- Below we make the assumption that Obj is at least byte
1998 -- aligned, since otherwise its address cannot be taken.
1999 -- The assumption holds since the only arrays that can be
2000 -- misaligned are small packed arrays which are implemented
2001 -- as a modular type, and that is not the case here.
2004 Unchecked_Convert_To
(Ctyp
,
2005 Make_Function_Call
(Loc
,
2006 Name
=> New_Occurrence_Of
(Get_nn
, Loc
),
2007 Parameter_Associations
=> New_List
(
2008 Make_Attribute_Reference
(Loc
,
2009 Attribute_Name
=> Name_Address
,
2015 Analyze_And_Resolve
(N
, Ctyp
, Suppress
=> All_Checks
);
2017 end Expand_Packed_Element_Reference
;
2019 ----------------------
2020 -- Expand_Packed_Eq --
2021 ----------------------
2023 -- Handles expansion of "=" on packed array types
2025 procedure Expand_Packed_Eq
(N
: Node_Id
) is
2026 Loc
: constant Source_Ptr
:= Sloc
(N
);
2027 L
: constant Node_Id
:= Relocate_Node
(Left_Opnd
(N
));
2028 R
: constant Node_Id
:= Relocate_Node
(Right_Opnd
(N
));
2038 Convert_To_Actual_Subtype
(L
);
2039 Convert_To_Actual_Subtype
(R
);
2040 Ltyp
:= Underlying_Type
(Etype
(L
));
2041 Rtyp
:= Underlying_Type
(Etype
(R
));
2043 Convert_To_PAT_Type
(L
);
2044 Convert_To_PAT_Type
(R
);
2048 Make_Op_Multiply
(Loc
,
2050 Make_Attribute_Reference
(Loc
,
2051 Attribute_Name
=> Name_Length
,
2052 Prefix
=> New_Occurrence_Of
(Ltyp
, Loc
)),
2054 Make_Integer_Literal
(Loc
, Component_Size
(Ltyp
)));
2057 Make_Op_Multiply
(Loc
,
2059 Make_Attribute_Reference
(Loc
,
2060 Attribute_Name
=> Name_Length
,
2061 Prefix
=> New_Occurrence_Of
(Rtyp
, Loc
)),
2063 Make_Integer_Literal
(Loc
, Component_Size
(Rtyp
)));
2065 -- For the modular case, we transform the comparison to:
2067 -- Ltyp'Length = Rtyp'Length and then PAT!(L) = PAT!(R)
2069 -- where PAT is the packed array type. This works fine, since in the
2070 -- modular case we guarantee that the unused bits are always zeroes.
2071 -- We do have to compare the lengths because we could be comparing
2072 -- two different subtypes of the same base type.
2074 if Is_Modular_Integer_Type
(PAT
) then
2079 Left_Opnd
=> LLexpr
,
2080 Right_Opnd
=> RLexpr
),
2087 -- For the non-modular case, we call a runtime routine
2089 -- System.Bit_Ops.Bit_Eq
2090 -- (L'Address, L_Length, R'Address, R_Length)
2092 -- where PAT is the packed array type, and the lengths are the lengths
2093 -- in bits of the original packed arrays. This routine takes care of
2094 -- not comparing the unused bits in the last byte.
2098 Make_Function_Call
(Loc
,
2099 Name
=> New_Occurrence_Of
(RTE
(RE_Bit_Eq
), Loc
),
2100 Parameter_Associations
=> New_List
(
2101 Make_Byte_Aligned_Attribute_Reference
(Loc
,
2102 Attribute_Name
=> Name_Address
,
2107 Make_Byte_Aligned_Attribute_Reference
(Loc
,
2108 Attribute_Name
=> Name_Address
,
2114 Analyze_And_Resolve
(N
, Standard_Boolean
, Suppress
=> All_Checks
);
2115 end Expand_Packed_Eq
;
2117 -----------------------
2118 -- Expand_Packed_Not --
2119 -----------------------
2121 -- Handles expansion of "not" on packed array types
2123 procedure Expand_Packed_Not
(N
: Node_Id
) is
2124 Loc
: constant Source_Ptr
:= Sloc
(N
);
2125 Typ
: constant Entity_Id
:= Etype
(N
);
2126 Opnd
: constant Node_Id
:= Relocate_Node
(Right_Opnd
(N
));
2133 Convert_To_Actual_Subtype
(Opnd
);
2134 Rtyp
:= Etype
(Opnd
);
2136 -- First an odd and silly test. We explicitly check for the case
2137 -- where the 'First of the component type is equal to the 'Last of
2138 -- this component type, and if this is the case, we make sure that
2139 -- constraint error is raised. The reason is that the NOT is bound
2140 -- to cause CE in this case, and we will not otherwise catch it.
2142 -- Believe it or not, this was reported as a bug. Note that nearly
2143 -- always, the test will evaluate statically to False, so the code
2144 -- will be statically removed, and no extra overhead caused.
2147 CT
: constant Entity_Id
:= Component_Type
(Rtyp
);
2151 Make_Raise_Constraint_Error
(Loc
,
2155 Make_Attribute_Reference
(Loc
,
2156 Prefix
=> New_Occurrence_Of
(CT
, Loc
),
2157 Attribute_Name
=> Name_First
),
2160 Make_Attribute_Reference
(Loc
,
2161 Prefix
=> New_Occurrence_Of
(CT
, Loc
),
2162 Attribute_Name
=> Name_Last
)),
2163 Reason
=> CE_Range_Check_Failed
));
2166 -- Now that that silliness is taken care of, get packed array type
2168 Convert_To_PAT_Type
(Opnd
);
2169 PAT
:= Etype
(Opnd
);
2171 -- For the case where the packed array type is a modular type,
2172 -- not A expands simply into:
2174 -- rtyp!(PAT!(A) xor mask)
2176 -- where PAT is the packed array type, and mask is a mask of all
2177 -- one bits of length equal to the size of this packed type and
2178 -- rtyp is the actual subtype of the operand
2180 Lit
:= Make_Integer_Literal
(Loc
, 2 ** Esize
(PAT
) - 1);
2181 Set_Print_In_Hex
(Lit
);
2183 if not Is_Array_Type
(PAT
) then
2185 Unchecked_Convert_To
(Rtyp
,
2188 Right_Opnd
=> Lit
)));
2190 -- For the array case, we insert the actions
2194 -- System.Bitops.Bit_Not
2196 -- Typ'Length * Typ'Component_Size;
2199 -- where Opnd is the Packed_Bytes{1,2,4} operand and the second
2200 -- argument is the length of the operand in bits. Then we replace
2201 -- the expression by a reference to Result.
2205 Result_Ent
: constant Entity_Id
:=
2206 Make_Defining_Identifier
(Loc
,
2207 Chars
=> New_Internal_Name
('T'));
2210 Insert_Actions
(N
, New_List
(
2212 Make_Object_Declaration
(Loc
,
2213 Defining_Identifier
=> Result_Ent
,
2214 Object_Definition
=> New_Occurrence_Of
(Rtyp
, Loc
)),
2216 Make_Procedure_Call_Statement
(Loc
,
2217 Name
=> New_Occurrence_Of
(RTE
(RE_Bit_Not
), Loc
),
2218 Parameter_Associations
=> New_List
(
2220 Make_Byte_Aligned_Attribute_Reference
(Loc
,
2221 Attribute_Name
=> Name_Address
,
2224 Make_Op_Multiply
(Loc
,
2226 Make_Attribute_Reference
(Loc
,
2229 (Etype
(First_Index
(Rtyp
)), Loc
),
2230 Attribute_Name
=> Name_Range_Length
),
2232 Make_Integer_Literal
(Loc
, Component_Size
(Rtyp
))),
2234 Make_Byte_Aligned_Attribute_Reference
(Loc
,
2235 Attribute_Name
=> Name_Address
,
2236 Prefix
=> New_Occurrence_Of
(Result_Ent
, Loc
))))));
2239 New_Occurrence_Of
(Result_Ent
, Loc
));
2243 Analyze_And_Resolve
(N
, Typ
, Suppress
=> All_Checks
);
2245 end Expand_Packed_Not
;
2247 -------------------------------------
2248 -- Involves_Packed_Array_Reference --
2249 -------------------------------------
2251 function Involves_Packed_Array_Reference
(N
: Node_Id
) return Boolean is
2253 if Nkind
(N
) = N_Indexed_Component
2254 and then Is_Bit_Packed_Array
(Etype
(Prefix
(N
)))
2258 elsif Nkind
(N
) = N_Selected_Component
then
2259 return Involves_Packed_Array_Reference
(Prefix
(N
));
2264 end Involves_Packed_Array_Reference
;
2266 --------------------------
2267 -- Known_Aligned_Enough --
2268 --------------------------
2270 function Known_Aligned_Enough
(Obj
: Node_Id
; Csiz
: Nat
) return Boolean is
2271 Typ
: constant Entity_Id
:= Etype
(Obj
);
2273 function In_Partially_Packed_Record
(Comp
: Entity_Id
) return Boolean;
2274 -- If the component is in a record that contains previous packed
2275 -- components, consider it unaligned because the back-end might
2276 -- choose to pack the rest of the record. Lead to less efficient code,
2277 -- but safer vis-a-vis of back-end choices.
2279 --------------------------------
2280 -- In_Partially_Packed_Record --
2281 --------------------------------
2283 function In_Partially_Packed_Record
(Comp
: Entity_Id
) return Boolean is
2284 Rec_Type
: constant Entity_Id
:= Scope
(Comp
);
2285 Prev_Comp
: Entity_Id
;
2288 Prev_Comp
:= First_Entity
(Rec_Type
);
2289 while Present
(Prev_Comp
) loop
2290 if Is_Packed
(Etype
(Prev_Comp
)) then
2293 elsif Prev_Comp
= Comp
then
2297 Next_Entity
(Prev_Comp
);
2301 end In_Partially_Packed_Record
;
2303 -- Start of processing for Known_Aligned_Enough
2306 -- Odd bit sizes don't need alignment anyway
2308 if Csiz
mod 2 = 1 then
2311 -- If we have a specified alignment, see if it is sufficient, if not
2312 -- then we can't possibly be aligned enough in any case.
2314 elsif Known_Alignment
(Etype
(Obj
)) then
2315 -- Alignment required is 4 if size is a multiple of 4, and
2316 -- 2 otherwise (e.g. 12 bits requires 4, 10 bits requires 2)
2318 if Alignment
(Etype
(Obj
)) < 4 - (Csiz
mod 4) then
2323 -- OK, alignment should be sufficient, if object is aligned
2325 -- If object is strictly aligned, then it is definitely aligned
2327 if Strict_Alignment
(Typ
) then
2330 -- Case of subscripted array reference
2332 elsif Nkind
(Obj
) = N_Indexed_Component
then
2334 -- If we have a pointer to an array, then this is definitely
2335 -- aligned, because pointers always point to aligned versions.
2337 if Is_Access_Type
(Etype
(Prefix
(Obj
))) then
2340 -- Otherwise, go look at the prefix
2343 return Known_Aligned_Enough
(Prefix
(Obj
), Csiz
);
2346 -- Case of record field
2348 elsif Nkind
(Obj
) = N_Selected_Component
then
2350 -- What is significant here is whether the record type is packed
2352 if Is_Record_Type
(Etype
(Prefix
(Obj
)))
2353 and then Is_Packed
(Etype
(Prefix
(Obj
)))
2357 -- Or the component has a component clause which might cause
2358 -- the component to become unaligned (we can't tell if the
2359 -- backend is doing alignment computations).
2361 elsif Present
(Component_Clause
(Entity
(Selector_Name
(Obj
)))) then
2364 elsif In_Partially_Packed_Record
(Entity
(Selector_Name
(Obj
))) then
2367 -- In all other cases, go look at prefix
2370 return Known_Aligned_Enough
(Prefix
(Obj
), Csiz
);
2373 elsif Nkind
(Obj
) = N_Type_Conversion
then
2374 return Known_Aligned_Enough
(Expression
(Obj
), Csiz
);
2376 -- For a formal parameter, it is safer to assume that it is not
2377 -- aligned, because the formal may be unconstrained while the actual
2378 -- is constrained. In this situation, a small constrained packed
2379 -- array, represented in modular form, may be unaligned.
2381 elsif Is_Entity_Name
(Obj
) then
2382 return not Is_Formal
(Entity
(Obj
));
2385 -- If none of the above, must be aligned
2388 end Known_Aligned_Enough
;
2390 ---------------------
2391 -- Make_Shift_Left --
2392 ---------------------
2394 function Make_Shift_Left
(N
: Node_Id
; S
: Node_Id
) return Node_Id
is
2398 if Compile_Time_Known_Value
(S
) and then Expr_Value
(S
) = 0 then
2402 Make_Op_Shift_Left
(Sloc
(N
),
2405 Set_Shift_Count_OK
(Nod
, True);
2408 end Make_Shift_Left
;
2410 ----------------------
2411 -- Make_Shift_Right --
2412 ----------------------
2414 function Make_Shift_Right
(N
: Node_Id
; S
: Node_Id
) return Node_Id
is
2418 if Compile_Time_Known_Value
(S
) and then Expr_Value
(S
) = 0 then
2422 Make_Op_Shift_Right
(Sloc
(N
),
2425 Set_Shift_Count_OK
(Nod
, True);
2428 end Make_Shift_Right
;
2430 -----------------------------
2431 -- RJ_Unchecked_Convert_To --
2432 -----------------------------
2434 function RJ_Unchecked_Convert_To
2436 Expr
: Node_Id
) return Node_Id
2438 Source_Typ
: constant Entity_Id
:= Etype
(Expr
);
2439 Target_Typ
: constant Entity_Id
:= Typ
;
2441 Src
: Node_Id
:= Expr
;
2447 Source_Siz
:= UI_To_Int
(RM_Size
(Source_Typ
));
2448 Target_Siz
:= UI_To_Int
(RM_Size
(Target_Typ
));
2450 -- First step, if the source type is not a discrete type, then we
2451 -- first convert to a modular type of the source length, since
2452 -- otherwise, on a big-endian machine, we get left-justification.
2453 -- We do it for little-endian machines as well, because there might
2454 -- be junk bits that are not cleared if the type is not numeric.
2456 if Source_Siz
/= Target_Siz
2457 and then not Is_Discrete_Type
(Source_Typ
)
2459 Src
:= Unchecked_Convert_To
(RTE
(Bits_Id
(Source_Siz
)), Src
);
2462 -- In the big endian case, if the lengths of the two types differ,
2463 -- then we must worry about possible left justification in the
2464 -- conversion, and avoiding that is what this is all about.
2466 if Bytes_Big_Endian
and then Source_Siz
/= Target_Siz
then
2468 -- Next step. If the target is not a discrete type, then we first
2469 -- convert to a modular type of the target length, since
2470 -- otherwise, on a big-endian machine, we get left-justification.
2472 if not Is_Discrete_Type
(Target_Typ
) then
2473 Src
:= Unchecked_Convert_To
(RTE
(Bits_Id
(Target_Siz
)), Src
);
2477 -- And now we can do the final conversion to the target type
2479 return Unchecked_Convert_To
(Target_Typ
, Src
);
2480 end RJ_Unchecked_Convert_To
;
2482 ----------------------------------------------
2483 -- Setup_Enumeration_Packed_Array_Reference --
2484 ----------------------------------------------
2486 -- All we have to do here is to find the subscripts that correspond
2487 -- to the index positions that have non-standard enumeration types
2488 -- and insert a Pos attribute to get the proper subscript value.
2490 -- Finally the prefix must be uncheck converted to the corresponding
2491 -- packed array type.
2493 -- Note that the component type is unchanged, so we do not need to
2494 -- fiddle with the types (Gigi always automatically takes the packed
2495 -- array type if it is set, as it will be in this case).
2497 procedure Setup_Enumeration_Packed_Array_Reference
(N
: Node_Id
) is
2498 Pfx
: constant Node_Id
:= Prefix
(N
);
2499 Typ
: constant Entity_Id
:= Etype
(N
);
2500 Exprs
: constant List_Id
:= Expressions
(N
);
2504 -- If the array is unconstrained, then we replace the array
2505 -- reference with its actual subtype. This actual subtype will
2506 -- have a packed array type with appropriate bounds.
2508 if not Is_Constrained
(Packed_Array_Type
(Etype
(Pfx
))) then
2509 Convert_To_Actual_Subtype
(Pfx
);
2512 Expr
:= First
(Exprs
);
2513 while Present
(Expr
) loop
2515 Loc
: constant Source_Ptr
:= Sloc
(Expr
);
2516 Expr_Typ
: constant Entity_Id
:= Etype
(Expr
);
2519 if Is_Enumeration_Type
(Expr_Typ
)
2520 and then Has_Non_Standard_Rep
(Expr_Typ
)
2523 Make_Attribute_Reference
(Loc
,
2524 Prefix
=> New_Occurrence_Of
(Expr_Typ
, Loc
),
2525 Attribute_Name
=> Name_Pos
,
2526 Expressions
=> New_List
(Relocate_Node
(Expr
))));
2527 Analyze_And_Resolve
(Expr
, Standard_Natural
);
2535 Make_Indexed_Component
(Sloc
(N
),
2537 Unchecked_Convert_To
(Packed_Array_Type
(Etype
(Pfx
)), Pfx
),
2538 Expressions
=> Exprs
));
2540 Analyze_And_Resolve
(N
, Typ
);
2542 end Setup_Enumeration_Packed_Array_Reference
;
2544 -----------------------------------------
2545 -- Setup_Inline_Packed_Array_Reference --
2546 -----------------------------------------
2548 procedure Setup_Inline_Packed_Array_Reference
2551 Obj
: in out Node_Id
;
2553 Shift
: out Node_Id
)
2555 Loc
: constant Source_Ptr
:= Sloc
(N
);
2562 Csiz
:= Component_Size
(Atyp
);
2564 Convert_To_PAT_Type
(Obj
);
2567 Cmask
:= 2 ** Csiz
- 1;
2569 if Is_Array_Type
(PAT
) then
2570 Otyp
:= Component_Type
(PAT
);
2571 Osiz
:= Component_Size
(PAT
);
2576 -- In the case where the PAT is a modular type, we want the actual
2577 -- size in bits of the modular value we use. This is neither the
2578 -- Object_Size nor the Value_Size, either of which may have been
2579 -- reset to strange values, but rather the minimum size. Note that
2580 -- since this is a modular type with full range, the issue of
2581 -- biased representation does not arise.
2583 Osiz
:= UI_From_Int
(Minimum_Size
(Otyp
));
2586 Compute_Linear_Subscript
(Atyp
, N
, Shift
);
2588 -- If the component size is not 1, then the subscript must be
2589 -- multiplied by the component size to get the shift count.
2593 Make_Op_Multiply
(Loc
,
2594 Left_Opnd
=> Make_Integer_Literal
(Loc
, Csiz
),
2595 Right_Opnd
=> Shift
);
2598 -- If we have the array case, then this shift count must be broken
2599 -- down into a byte subscript, and a shift within the byte.
2601 if Is_Array_Type
(PAT
) then
2604 New_Shift
: Node_Id
;
2607 -- We must analyze shift, since we will duplicate it
2609 Set_Parent
(Shift
, N
);
2611 (Shift
, Standard_Integer
, Suppress
=> All_Checks
);
2613 -- The shift count within the word is
2618 Left_Opnd
=> Duplicate_Subexpr
(Shift
),
2619 Right_Opnd
=> Make_Integer_Literal
(Loc
, Osiz
));
2621 -- The subscript to be used on the PAT array is
2625 Make_Indexed_Component
(Loc
,
2627 Expressions
=> New_List
(
2628 Make_Op_Divide
(Loc
,
2629 Left_Opnd
=> Duplicate_Subexpr
(Shift
),
2630 Right_Opnd
=> Make_Integer_Literal
(Loc
, Osiz
))));
2635 -- For the modular integer case, the object to be manipulated is
2636 -- the entire array, so Obj is unchanged. Note that we will reset
2637 -- its type to PAT before returning to the caller.
2643 -- The one remaining step is to modify the shift count for the
2644 -- big-endian case. Consider the following example in a byte:
2646 -- xxxxxxxx bits of byte
2647 -- vvvvvvvv bits of value
2648 -- 33221100 little-endian numbering
2649 -- 00112233 big-endian numbering
2651 -- Here we have the case of 2-bit fields
2653 -- For the little-endian case, we already have the proper shift
2654 -- count set, e.g. for element 2, the shift count is 2*2 = 4.
2656 -- For the big endian case, we have to adjust the shift count,
2657 -- computing it as (N - F) - shift, where N is the number of bits
2658 -- in an element of the array used to implement the packed array,
2659 -- F is the number of bits in a source level array element, and
2660 -- shift is the count so far computed.
2662 if Bytes_Big_Endian
then
2664 Make_Op_Subtract
(Loc
,
2665 Left_Opnd
=> Make_Integer_Literal
(Loc
, Osiz
- Csiz
),
2666 Right_Opnd
=> Shift
);
2669 Set_Parent
(Shift
, N
);
2670 Set_Parent
(Obj
, N
);
2671 Analyze_And_Resolve
(Obj
, Otyp
, Suppress
=> All_Checks
);
2672 Analyze_And_Resolve
(Shift
, Standard_Integer
, Suppress
=> All_Checks
);
2674 -- Make sure final type of object is the appropriate packed type
2676 Set_Etype
(Obj
, Otyp
);
2678 end Setup_Inline_Packed_Array_Reference
;