summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-01-24 15:18:46 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-01-24 15:18:46 +0000
commite9185b9db30b857c3906b4000cac94f6ab85f292 (patch)
treef64632f4ed17e9fcf165d2add6a0ad9ad98bc2c0
parent4d4bdb21ae4132a3bbf62df48c4584cb689ad14e (diff)
downloadgcc-e9185b9db30b857c3906b4000cac94f6ab85f292.tar.gz
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 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207045 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog16
-rw-r--r--gcc/ada/back_end.adb16
-rw-r--r--gcc/ada/freeze.adb4
-rw-r--r--gcc/ada/get_targ.adb13
-rw-r--r--gcc/ada/get_targ.ads7
-rw-r--r--gcc/ada/opt.ads15
-rw-r--r--gcc/ada/sem_ch13.adb2
-rwxr-xr-xgcc/ada/set_targ.adb3
-rwxr-xr-xgcc/ada/set_targ.ads1
-rw-r--r--gcc/ada/targparm.adb4
-rw-r--r--gcc/ada/targparm.ads18
-rw-r--r--gcc/ada/ttypes.ads7
12 files changed, 60 insertions, 46 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index ba0945f1f65..686e96e7b8e 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,19 @@
+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.
diff --git a/gcc/ada/back_end.adb b/gcc/ada/back_end.adb
index 6c3e9a80e0c..a466686527e 100644
--- a/gcc/ada/back_end.adb
+++ b/gcc/ada/back_end.adb
@@ -40,7 +40,6 @@ with Switch; use Switch;
with Switch.C; use Switch.C;
with System; use System;
with Types; use Types;
-with Targparm;
with System.OS_Lib; use System.OS_Lib;
@@ -54,10 +53,6 @@ package body Back_End is
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
@@ -263,16 +258,13 @@ package body Back_End is
-- 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
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index ece601f2598..4dd7347eebc 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -5278,7 +5278,7 @@ package body Freeze is
-- 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));
@@ -5301,7 +5301,7 @@ package body Freeze is
-- 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));
diff --git a/gcc/ada/get_targ.adb b/gcc/ada/get_targ.adb
index a2f7370f8e5..661f95b5ab3 100644
--- a/gcc/ada/get_targ.adb
+++ b/gcc/ada/get_targ.adb
@@ -23,6 +23,8 @@
-- --
------------------------------------------------------------------------------
+-- Version for use with gcc
+
package body Get_Targ is
-- Functions returning individual runtime. For the standard (GCC) back
@@ -232,6 +234,17 @@ package body Get_Targ is
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 --
--------------------------
diff --git a/gcc/ada/get_targ.ads b/gcc/ada/get_targ.ads
index 08af7f33855..19f5385e12f 100644
--- a/gcc/ada/get_targ.ads
+++ b/gcc/ada/get_targ.ads
@@ -108,6 +108,13 @@ package Get_Targ is
-- 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;
diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads
index 568d025c4c8..28d12207677 100644
--- a/gcc/ada/opt.ads
+++ b/gcc/ada/opt.ads
@@ -1290,17 +1290,14 @@ package Opt is
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
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 1a0aa522284..61db885924c 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -10793,7 +10793,7 @@ package body Sem_Ch13 is
-- 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
diff --git a/gcc/ada/set_targ.adb b/gcc/ada/set_targ.adb
index db08f0d4e7b..0dc9b839b25 100755
--- a/gcc/ada/set_targ.adb
+++ b/gcc/ada/set_targ.adb
@@ -60,6 +60,7 @@ package body Set_Targ is
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";
@@ -88,6 +89,7 @@ package body Set_Targ is
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,
@@ -114,6 +116,7 @@ package body Set_Targ is
Maximum_Alignment 'Address,
Max_Unaligned_Field 'Address,
Pointer_Size 'Address,
+ Short_Enums 'Address,
Short_Size 'Address,
Strict_Alignment 'Address,
System_Allocator_Alignment 'Address,
diff --git a/gcc/ada/set_targ.ads b/gcc/ada/set_targ.ads
index a14fbcbce3e..62008cd5b4e 100755
--- a/gcc/ada/set_targ.ads
+++ b/gcc/ada/set_targ.ads
@@ -75,6 +75,7 @@ package Set_Targ is
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
diff --git a/gcc/ada/targparm.adb b/gcc/ada/targparm.adb
index b59f58b79f0..3357c5dfe0e 100644
--- a/gcc/ada/targparm.adb
+++ b/gcc/ada/targparm.adb
@@ -63,7 +63,6 @@ package body Targparm is
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
@@ -102,7 +101,6 @@ package body Targparm is
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";
@@ -141,7 +139,6 @@ package body Targparm is
SCD_Str'Access,
SCL_Str'Access,
SCP_Str'Access,
- SHE_Str'Access,
SLS_Str'Access,
SNZ_Str'Access,
SSL_Str'Access,
@@ -612,7 +609,6 @@ package body Targparm is
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;
diff --git a/gcc/ada/targparm.ads b/gcc/ada/targparm.ads
index f89ebfe97cc..11c7a7edfb3 100644
--- a/gcc/ada/targparm.ads
+++ b/gcc/ada/targparm.ads
@@ -605,24 +605,6 @@ package Targparm is
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 --
-----------------
diff --git a/gcc/ada/ttypes.ads b/gcc/ada/ttypes.ads
index 5e27cbd2e58..efeea41965d 100644
--- a/gcc/ada/ttypes.ads
+++ b/gcc/ada/ttypes.ads
@@ -224,6 +224,13 @@ package Ttypes is
-- 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