This is the mail archive of the 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]

[Ada] Implement pragma Optimize_Alignment

Tested on i686-linux, committed on trunk

This new pragma has three settings, Space/Time/Off. Off corresponds
to the current choice of default alignments which is a balance
between space and time. Space causes alignments to be chosen so
that space is favored, as seen in the example below, and Time
causes alignments to be generally larger.

Here is a test program:

package Pkg is
   type Rec is record
      A, B, C : Integer;
      T : Boolean;
   end record;
   for Rec use record
     A at 0 range 0 .. 31;
     B at 4 range 0 .. 31;
     C at 8 range 0 .. 31;
     T at 12 range 0 .. 7;
   end record;
   pragma Pack (Rec);
   type Recs is array (Boolean) of Rec;
   pragma Pack (Recs);
end Pkg;

In default mode, Rec has an alignment of 4, in optimize space mode,
it has an alignment of 1.

Here is another test:

package VMS_Align is
   type r is record
      a, b : character;
      c    : boolean;
   end record;
   pragma Pack (r);
   for R'size use 17;
end VMS_Align;

In default mode, r has an alignment of 1, in Optimize time mode
it has an alignment of 4.

2008-03-26  Robert Dewar  <>

	*, ali.adb (Optimize_Alignment_Setting): New field in ALI record

	* bcheck.adb (Check_Consistent_Optimize_Alignment): New procedure

	* debug.adb: Add debug flags d.r and d.v
	Add debug flag .T (Optimize_Alignment (Time))
	Add debug flag .S (Optimize_Alignment (Space))

	* freeze.adb (Freeze_Record_Type): Set OK_To_Reorder_Components
	depending on setting of relevant debug flags.
	Replace use of Warnings_Off by Has_Warnings_Off
	(Freeze_Entity): In circuit for warning on suspicious convention
	actuals, do not give warning if subprogram has same entity as formal
	type, or if subprogram does not come from source.
	(Freeze_Entity): Don't reset Is_Packed for fully rep speced record
	if Optimize_Alignment set to Space.

	* frontend.adb: Add call to Sem_Warn.Initialize
	Add call to Sem_Warn.Output_Unused_Warnings_Off_Warnings
	Reset Optimize_Alignment mode from debug switches .S and .T

	* layout.adb (Layout_Composite_Object): Rewritten for
	Optimize_Aligment pragma.

	*, lib-writ.adb: New Ox parameter for Optimize_Alignment

	*, opt.adb: (Optimize_Alignment): New global switch

	* par-prag.adb (N_Pragma): Chars field removed, use Chars
	(Pragma_Identifier (..  instead, adjustments throughout to accomodate
	this change. Add entry for pragma Optimize_Alignment

	* sem_prag.adb (N_Pragma): Chars field removed, use Chars
	(Pragma_Identifier (..
	instead, adjustments throughout to accomodate this change.
	(Process_Compile_Time_Warning_Or_Error): Use !! for generated msg
	(Favor_Top_Level): Use new function Is_Access_Subprogram_Type
	Add implementation of pragma Optimize_Alignment

Attachment: difs
Description: Text document

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