aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/xoscons.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2012-08-06 10:35:47 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2012-08-06 10:35:47 +0200
commitcc6c4d6288d286bfd45dbc82b011f5cb6bc269a5 (patch)
tree63a411a3cf6a846e49f7e994420974199304592a /gcc/ada/xoscons.adb
parentaa24a99beeeef149925c540f5f252a2e9b41b493 (diff)
downloadgcc-cc6c4d6288d286bfd45dbc82b011f5cb6bc269a5.zip
gcc-cc6c4d6288d286bfd45dbc82b011f5cb6bc269a5.tar.gz
gcc-cc6c4d6288d286bfd45dbc82b011f5cb6bc269a5.tar.bz2
[multiple changes]
2012-08-06 Thomas Quinot <quinot@adacore.com> * sem_ch4.adb: Minor reformatting. 2012-08-06 Thomas Quinot <quinot@adacore.com> * s-oscons-tmplt.c, xoscons.adb: Per the Single UNIX Specification, types cc_t, speed_t, and tcflag_t defined in <termios.h> all are unsigned types. Add required special handling to have their correct unsigned values in s-oscons.ads. 2012-08-06 Thomas Quinot <quinot@adacore.com> * par-ch13.adb: Minor reformatting. 2012-08-06 Thomas Quinot <quinot@adacore.com> * g-sercom.adb, g-sercom.ads, g-sercom-mingw.adb, g-sercom-linux.adb (Set): Add Local and Flow_Control settings. 2012-08-06 Ed Schonberg <schonberg@adacore.com> * exp_attr.adb: Suppress saving of 'Old if assertions are not enabled. From-SVN: r190170
Diffstat (limited to 'gcc/ada/xoscons.adb')
-rw-r--r--gcc/ada/xoscons.adb62
1 files changed, 47 insertions, 15 deletions
diff --git a/gcc/ada/xoscons.adb b/gcc/ada/xoscons.adb
index 56ea8a8..73e3322 100644
--- a/gcc/ada/xoscons.adb
+++ b/gcc/ada/xoscons.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2008-2009, Free Software Foundation, Inc. --
+-- Copyright (C) 2008-2012, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -73,13 +73,18 @@ procedure XOSCons is
type Asm_Info_Kind is
(CND, -- Named number (decimal)
+ CNU, -- Named number (decimal, unsigned)
CNS, -- Named number (freeform text)
C, -- Constant object
TXT); -- Literal text
-- Recognized markers found in assembly file. These markers are produced by
-- the same-named macros from the C template.
+ subtype Asm_Int_Kind is Asm_Info_Kind range CND .. CNU;
+ -- Asm_Info_Kind values with int values in input
+
subtype Named_Number is Asm_Info_Kind range CND .. CNS;
+ -- Asm_Info_Kind values with named numbers in output
type Asm_Info (Kind : Asm_Info_Kind := TXT) is record
Line_Number : Integer;
@@ -98,7 +103,7 @@ procedure XOSCons is
-- Value for CNS / C constant
Int_Value : Int_Value_Type;
- -- Value for CND constant
+ -- Value for CND / CNU constant
Comment : String_Access;
-- Additional descriptive comment for constant, or free-form text (TXT)
@@ -116,6 +121,9 @@ procedure XOSCons is
Max_Constant_Type_Len : Natural := 0;
-- Lengths of longest name and longest value
+ Size_Of_Unsigned_Int : Integer := 0;
+ -- Size of unsigned int on target
+
type Language is (Lang_Ada, Lang_C);
procedure Output_Info
@@ -195,11 +203,12 @@ procedure XOSCons is
- Info.Constant_Name'Length));
end case;
- if Info.Kind = CND then
+ if Info.Kind in Asm_Int_Kind then
if not Info.Int_Value.Positive then
Put ("-");
end if;
Put (Trim (Info.Int_Value.Abs_Value'Img, Side => Left));
+
else
declare
Is_String : constant Boolean :=
@@ -246,7 +255,7 @@ procedure XOSCons is
procedure Find_Colon (Index : in out Integer);
-- Increment Index until the next colon in Line
- function Parse_Int (S : String) return Int_Value_Type;
+ function Parse_Int (S : String; K : Asm_Int_Kind) return Int_Value_Type;
-- Parse a decimal number, preceded by an optional '$' or '#' character,
-- and return its value.
@@ -275,9 +284,12 @@ procedure XOSCons is
-- Parse_Int --
---------------
- function Parse_Int (S : String) return Int_Value_Type is
+ function Parse_Int
+ (S : String;
+ K : Asm_Int_Kind) return Int_Value_Type
+ is
First : Integer := S'First;
- Positive : Boolean;
+ Result : Int_Value_Type;
begin
-- On some platforms, immediate integer values are prefixed with
-- a $ or # character in assembly output.
@@ -287,14 +299,25 @@ procedure XOSCons is
end if;
if S (First) = '-' then
- Positive := False;
+ Result.Positive := False;
First := First + 1;
else
- Positive := True;
+ Result.Positive := True;
+ end if;
+
+ Result.Abs_Value := Long_Unsigned'Value (S (First .. S'Last));
+
+ if not Result.Positive and then K = CNU then
+ -- Negative value, but unsigned expected: take 2's complement
+ -- reciprocical value.
+
+ Result.Abs_Value := ((not Result.Abs_Value) + 1)
+ and
+ (Shift_Left (1, Size_Of_Unsigned_Int) - 1);
+ Result.Positive := True;
end if;
- return (Positive => Positive,
- Abs_Value => Long_Unsigned'Value (S (First .. S'Last)));
+ return Result;
exception
when E : others =>
@@ -315,10 +338,10 @@ procedure XOSCons is
Find_Colon (Index2);
Info.Line_Number :=
- Integer (Parse_Int (Line (Index1 .. Index2 - 1)).Abs_Value);
+ Integer (Parse_Int (Line (Index1 .. Index2 - 1), CNU).Abs_Value);
case Info.Kind is
- when CND | CNS | C =>
+ when CND | CNU | CNS | C =>
Index1 := Index2 + 1;
Find_Colon (Index2);
@@ -340,15 +363,24 @@ procedure XOSCons is
Find_Colon (Index2);
end if;
- if Info.Kind = CND then
- Info.Int_Value := Parse_Int (Line (Index1 .. Index2 - 1));
- Info.Value_Len := Index2 - Index1 - 1;
+ if Info.Kind = CND or else Info.Kind = CNU then
+ Info.Int_Value :=
+ Parse_Int (Line (Index1 .. Index2 - 1), Info.Kind);
+ Info.Value_Len := Info.Int_Value.Abs_Value'Img'Length - 1;
+ if not Info.Int_Value.Positive then
+ Info.Value_Len := Info.Value_Len + 1;
+ end if;
else
Info.Text_Value := Field_Alloc;
Info.Value_Len := Info.Text_Value'Length;
end if;
+ if Info.Constant_Name.all = "sizeof_unsigned_int" then
+ Size_Of_Unsigned_Int :=
+ 8 * Integer (Info.Int_Value.Abs_Value);
+ end if;
+
when others =>
null;
end case;