+2014-01-24 Robert Dewar <dewar@adacore.com>
+
+ * back_end.adb: Remove Short_Enums handling (handled in
+ Ttypes/Get_Targ now) Minor added comments.
+ * freeze.adb: Change name Short_Enums_On_Target to
+ Target_Short_Enums.
+ * get_targ.ads, get_targ.adb (Get_Short_Enums): New function.
+ * opt.ads: Minor comment updates.
+ * sem_ch13.adb: Change name Short_Enums_On_Target to
+ Target_Short_Enums.
+ * set_targ.adb: Set Short_Enums from gcc back end.
+ * set_targ.ads (Short_Enums): New variable.
+ * targparm.ads, targparm.adb: Remove Short_Enums entries (handled in
+ Ttypes/Get_Targ now).
+ * ttypes.ads (Target_Short_Enums): New constant boolean switch
+
2014-01-24 Pascal Obry <obry@adacore.com>
* g-sercom-mingw.adb: Fix serial port name for port number > 10.
with Switch.C; use Switch.C;
with System; use System;
with Types; use Types;
-with Targparm;
with System.OS_Lib; use System.OS_Lib;
pragma Import (C, flag_stack_check);
-- Indicates if stack checking is enabled, imported from misc.c
- flag_short_enums : Int;
- pragma Import (C, flag_short_enums);
- -- Indicates if C enumerations are packed, imported from misc.c
-
save_argc : Nat;
pragma Import (C, save_argc);
-- Saved value of argc (number of arguments), imported from misc.c
-- Start of processing for Scan_Compiler_Arguments
begin
- -- Acquire stack checking mode directly from GCC
+ -- Acquire stack checking mode directly from GCC. The reason we do this
+ -- is to make sure that the indication of stack checking being enabled
+ -- is the same in the front end and the back end. This status obtained
+ -- from gcc is affected by more than just the switch -fstack-check.
Opt.Stack_Checking_Enabled := (flag_stack_check /= 0);
- -- Acquire short enums flag directly from GCC
- -- This needs documentation in the spec ???
- -- So does the one above! ???
-
- Targparm.Short_Enums_On_Target := (flag_short_enums /= 0);
-
-- Put the arguments in Args
for Arg in Pos range 1 .. save_argc - 1 loop
-- Don't do this if Short_Enums on target
- and then not Short_Enums_On_Target
+ and then not Target_Short_Enums
then
Init_Esize (Typ, Standard_Integer_Size);
Set_Alignment (Typ, Alignment (Standard_Integer));
-- Don't do this if Short_Enums on target
- and then not Short_Enums_On_Target
+ and then not Target_Short_Enums
then
Error_Msg_N
("C enum types have the size of a C int??", Size_Clause (Typ));
-- --
------------------------------------------------------------------------------
+-- Version for use with gcc
+
package body Get_Targ is
-- Functions returning individual runtime. For the standard (GCC) back
return C_Get_Bits_BE;
end Get_Bits_BE;
+ ---------------------
+ -- Get_Short_Enums --
+ ---------------------
+
+ function Get_Short_Enums return Int is
+ flag_short_enums : Int;
+ pragma Import (C, flag_short_enums);
+ begin
+ return flag_short_enums;
+ end Get_Short_Enums;
+
--------------------------
-- Get_Strict_Alignment --
--------------------------
-- Alignment required for Long_Long_Integer or larger integer types
-- or 0 if no special requirement.
+ function Get_Short_Enums return Int;
+ -- Returns non-zero if we are in short enums mode, where foreign convention
+ -- (in particular C and C++) enumeration types will be sized as in Ada,
+ -- using the shortest possibility from 8,16,32 bits, signed or unsigned.
+ -- A zero value means Short_Enums are not in use, and in this case all
+ -- foreign convention enumeration types are given the same size as c int.
+
-- Other subprograms
function Get_Max_Unaligned_Field return Pos;
Sprint_Line_Limit : Nat := 72;
-- GNAT
- -- Limit values for chopping long lines in Sprint output, can be reset
- -- by use of NNN parameter with -gnatG or -gnatD switches.
+ -- Limit values for chopping long lines in Sprint output, can be reset by
+ -- use of NNN parameter with -gnatG or -gnatD switches.
- Stack_Checking_Enabled : Boolean;
+ Stack_Checking_Enabled : Boolean := False;
-- GNAT
- -- Set to indicate if -fstack-check switch is set for the compilation. True
- -- means that the switch is set, so that stack checking is enabled. False
- -- means that the switch is not set (no stack checking). This value is
- -- obtained from the external imported value flag_stack_check in the gcc
- -- backend (see Frontend) and may be referenced throughout the compilation
- -- phases.
+ -- Set to indicate if stack checking is enabled for the compilation. This
+ -- is set directly from the value in the gcc back end in the body of the
+ -- gcc version of back_end.adb.
Style_Check : Boolean := False;
-- GNAT
-- Don't do this if Short_Enums on target
- and then not Short_Enums_On_Target
+ and then not Target_Short_Enums
then
Init_Esize (T, Standard_Integer_Size);
else
S_Maximum_Alignment : constant Str := "Maximum_Alignment";
S_Max_Unaligned_Field : constant Str := "Max_Unaligned_Field";
S_Pointer_Size : constant Str := "Pointer_Size";
+ S_Short_Enums : constant Str := "Short_Enums";
S_Short_Size : constant Str := "Short_Size";
S_Strict_Alignment : constant Str := "Strict_Alignment";
S_System_Allocator_Alignment : constant Str := "System_Allocator_Alignment";
S_Maximum_Alignment 'Unrestricted_Access,
S_Max_Unaligned_Field 'Unrestricted_Access,
S_Pointer_Size 'Unrestricted_Access,
+ S_Short_Enums 'Unrestricted_Access,
S_Short_Size 'Unrestricted_Access,
S_Strict_Alignment 'Unrestricted_Access,
S_System_Allocator_Alignment 'Unrestricted_Access,
Maximum_Alignment 'Address,
Max_Unaligned_Field 'Address,
Pointer_Size 'Address,
+ Short_Enums 'Address,
Short_Size 'Address,
Strict_Alignment 'Address,
System_Allocator_Alignment 'Address,
Maximum_Alignment : Pos; -- Maximum permitted alignment
Max_Unaligned_Field : Pos; -- Maximum size for unaligned bit field
Pointer_Size : Pos; -- System.Address'Size
+ Short_Enums : Nat; -- Foreign enums use short size?
Short_Size : Pos; -- Standard.Short_Integer'Size
Strict_Alignment : Nat; -- Strict alignment?
System_Allocator_Alignment : Nat; -- Alignment for malloc calls
SCD, -- Stack_Check_Default
SCL, -- Stack_Check_Limits
SCP, -- Stack_Check_Probes
- SHE, -- Short_Enums
SLS, -- Support_Long_Shifts
SNZ, -- Signed_Zeros
SSL, -- Suppress_Standard_Library
SCD_Str : aliased constant Source_Buffer := "Stack_Check_Default";
SCL_Str : aliased constant Source_Buffer := "Stack_Check_Limits";
SCP_Str : aliased constant Source_Buffer := "Stack_Check_Probes";
- SHE_Str : aliased constant Source_Buffer := "Short_Enums";
SLS_Str : aliased constant Source_Buffer := "Support_Long_Shifts";
SNZ_Str : aliased constant Source_Buffer := "Signed_Zeros";
SSL_Str : aliased constant Source_Buffer := "Suppress_Standard_Library";
SCD_Str'Access,
SCL_Str'Access,
SCP_Str'Access,
- SHE_Str'Access,
SLS_Str'Access,
SNZ_Str'Access,
SSL_Str'Access,
when SCD => Stack_Check_Default_On_Target := Result;
when SCL => Stack_Check_Limits_On_Target := Result;
when SCP => Stack_Check_Probes_On_Target := Result;
- when SHE => Short_Enums_On_Target := Result;
when SLS => Support_Long_Shifts_On_Target := Result;
when SSL => Suppress_Standard_Library_On_Target := Result;
when SNZ => Signed_Zeros_On_Target := Result;
Frontend_Layout_On_Target : Boolean := False;
-- Set True if front end does layout
- Short_Enums_On_Target : Boolean := False;
- -- In most C ABI's, enumeration types always have int size. If this switch
- -- is False, which is the default, that's what the front end implements for
- -- enumeration types with a foreign convention (includ C and C++). However
- -- on some ABI's (notably the ARM-EABI), enumeration types have sizes that
- -- are minimal for the range of values. For such cases this switch is set
- -- True (in the appropriate System file), and the front-end uses the normal
- -- Ada rules for sizing enumeration types (which correspond to this method
- -- of selecting the shortest signed or unsigned integer representation that
- -- can accomodate the number of items in the type, or the range of values
- -- if an enumeration representation clause is used.
- -- the same size as C int, or Ada Integer. That's the most common case, but
- -- there are targets (most notably those following the ARM-EABI) where the
- -- size for enumeration types is the same as in Ada (i.e. the smallest
- -- integer type that accomodates the number of enumeration choices, or the
- -- range of values in an enumeration-representation clause). For such cases
- -- this switch is set to False in the corresponding System file.
-
-----------------
-- Subprograms --
-----------------
-- and thus relevant only to the back end. Note that this is a variable
-- rather than a constant, since it can be modified (flipped) by -gnatd8.
+ Target_Short_Enums : constant Boolean := Set_Targ.Short_Enums /= 0;
+ -- True if we are in short enums mode, where foreign convention
+ -- (in particular C and C++) enumeration types will be sized as in Ada,
+ -- using the shortest possibility from 8,16,32 bits, signed or unsigned.
+ -- A zero value means Short_Enums are not in use, and in this case all
+ -- foreign convention enumeration types are given the same size as c int.
+
Target_Strict_Alignment : Boolean :=
Set_Targ.Strict_Alignment /= 0;
-- True if instructions will fail if data is misaligned. Note that this