This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Proposed AAPCS update - parameter passing types with modified alignments


Since it may take some time before an official update to the ARM AAPCS
document can be made, I'm publishing a proposed change here for advanced
notice.  Alan will follow up with some GCC patches shortly to implement
these changes.

The proposed changes should deal with types that have been either
under-aligned (packed) or over-aligned by language extensions or
language defined alignment modifiers.  They work by assuming that the
values passed to a procedure are *copies* of values and that these
copies can safely have alignments that differ from both the source of
the copy and also from the target use inside the called procedure (in
the latter case a second copy to suitably aligned memory might be
necessary).

Since the ABI has not previously defined rules for parameter passing of
values with alignment modifiers it is possible that existing
implementations will not be 100% compatible with all these rules.
Modifying the compiler to conform may result in a silent code-generation
change.  (There should be no change for types that are naturally
aligned).  We believe this should be very rare and because the ABI has
not previously sanctioned such types they are unlikely to appear at
shared library boundaries.  It may help if compilers could emit a
warning should they detect that a parameter may cause such change in
behaviour.

R.

Definitions used in this description:


'Alignment-Adjusted'

An Alignment-Adjusted type is a type to which a language alignment
modifier has been applied.


'Member Alignment'

The Member Alignment of an element of an aggregate type is the
alignment of that member /after/ the application of any language
alignment modifiers to that member.


'Natural Alignment'

The Natural Alignment of an aggregate type is the maximum of each of
the Member Alignments of the 'top-level' members of the aggregate
type (ie before any alignment adjustment of the entire aggregate is
applied).

The Natural Alignment of all fundamental data types is that specified
in Table 1 of the AAPCS.





For the purposes of passing alignment-adjusted types as parameters,
the following rules are proposed as additions to Stage B of Section
5.5 of the AAPCS:



* Values of alignment-adjusted types passed as parameters are /copies/
  of the actual values used in the call list.

* The copies have alignments defined as follows:

 - For fundamental types, the alignment is the natural alignment of
   that type (after any promotions).

 - For aggregate types the copy of the aggregate type has 4-byte
   alignment if its natural alignment is <= 4 and 8-byte alignment if
   its natural alignment is >=8.

* The alignment of the copy is used for applying the argument
  marshalling rules.


------

Similar changes will be published for AArch64, except that the lower and
upper bounds for the natural alignment checks are are changed from (4,8)
to (8, 16) bytes.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]