diff options
author | hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-01 22:22:57 +0000 |
---|---|---|
committer | hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-01 22:22:57 +0000 |
commit | 9e169c4bf36a38689550c059570c57efbf00a6fb (patch) | |
tree | 95e6800f7ac2a49ff7f799d96f04172320e70ac0 /gcc/ada/uintp.adb | |
parent | 6170dfb6edfb7b19f8ae5209b8f948fe0076a4ad (diff) | |
download | gcc-vect256.tar.gz |
Merged trunk at revision 161680 into branch.vect256
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/vect256@161681 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/uintp.adb')
-rw-r--r-- | gcc/ada/uintp.adb | 86 |
1 files changed, 28 insertions, 58 deletions
diff --git a/gcc/ada/uintp.adb b/gcc/ada/uintp.adb index 3b72d154c10..29ffe235aad 100644 --- a/gcc/ada/uintp.adb +++ b/gcc/ada/uintp.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2010, 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- -- @@ -168,13 +168,15 @@ package body Uintp is (Left, Right : Uint; Quotient : out Uint; Remainder : out Uint; - Discard_Quotient : Boolean; - Discard_Remainder : Boolean); - -- Compute Euclidean division of Left by Right, and return Quotient and - -- signed Remainder (Left rem Right). + Discard_Quotient : Boolean := False; + Discard_Remainder : Boolean := False); + -- Compute Euclidean division of Left by Right. If Discard_Quotient is + -- False then the quotient is returned in Quotient (otherwise Quotient is + -- set to No_Uint). If Discard_Remainder is False, then the remainder is + -- returned in Remainder (otherwise Remainder is set to No_Uint). -- - -- If Discard_Quotient is True, Quotient is left unchanged. - -- If Discard_Remainder is True, Remainder is left unchanged. + -- If Discard_Quotient is True, Quotient is set to No_Uint + -- If Discard_Remainder is True, Remainder is set to No_Uint function Vector_To_Uint (In_Vec : UI_Vector; @@ -239,7 +241,7 @@ package body Uintp is function Hash_Num (F : Int) return Hnum is begin - return Standard."mod" (F, Hnum'Range_Length); + return Types."mod" (F, Hnum'Range_Length); end Hash_Num; --------------- @@ -1253,7 +1255,6 @@ package body Uintp is UI_Div_Rem (Left, Right, Quotient, Remainder, - Discard_Quotient => False, Discard_Remainder => True); return Quotient; end UI_Div; @@ -1266,14 +1267,17 @@ package body Uintp is (Left, Right : Uint; Quotient : out Uint; Remainder : out Uint; - Discard_Quotient : Boolean; - Discard_Remainder : Boolean) + Discard_Quotient : Boolean := False; + Discard_Remainder : Boolean := False) is pragma Warnings (Off, Quotient); pragma Warnings (Off, Remainder); begin pragma Assert (Right /= Uint_0); + Quotient := No_Uint; + Remainder := No_Uint; + -- Cases where both operands are represented directly if Direct (Left) and then Direct (Right) then @@ -1345,9 +1349,11 @@ package body Uintp is if not Discard_Quotient then Quotient := Uint_0; end if; + if not Discard_Remainder then Remainder := Left; end if; + return; end if; @@ -1377,6 +1383,7 @@ package body Uintp is if not Discard_Remainder then Remainder := UI_From_Int (Remainder_I); end if; + return; end; end if; @@ -1679,43 +1686,9 @@ package body Uintp is function UI_From_CC (Input : Char_Code) return Uint is begin - return UI_From_Dint (Dint (Input)); + return UI_From_Int (Int (Input)); end UI_From_CC; - ------------------ - -- UI_From_Dint -- - ------------------ - - function UI_From_Dint (Input : Dint) return Uint is - begin - - if Dint (Min_Direct) <= Input and then Input <= Dint (Max_Direct) then - return Uint (Dint (Uint_Direct_Bias) + Input); - - -- For values of larger magnitude, compute digits into a vector and call - -- Vector_To_Uint. - - else - declare - Max_For_Dint : constant := 5; - -- Base is defined so that 5 Uint digits is sufficient to hold the - -- largest possible Dint value. - - V : UI_Vector (1 .. Max_For_Dint); - - Temp_Integer : Dint := Input; - - begin - for J in reverse V'Range loop - V (J) := Int (abs (Temp_Integer rem Dint (Base))); - Temp_Integer := Temp_Integer / Dint (Base); - end loop; - - return Vector_To_Uint (V, Input < Dint'(0)); - end; - end if; - end UI_From_Dint; - ----------------- -- UI_From_Int -- ----------------- @@ -2188,11 +2161,7 @@ package body Uintp is Y := Uint_0; loop - UI_Div_Rem - (U, V, - Quotient => Q, Remainder => R, - Discard_Quotient => False, - Discard_Remainder => False); + UI_Div_Rem (U, V, Quotient => Q, Remainder => R); U := V; V := R; @@ -2229,12 +2198,15 @@ package body Uintp is function UI_Mul (Left : Uint; Right : Uint) return Uint is begin - -- Simple case of single length operands + -- Case where product fits in the range of a 32-bit integer - if Direct (Left) and then Direct (Right) then + if Int (Left) <= Int (Uint_Max_Simple_Mul) + and then + Int (Right) <= Int (Uint_Max_Simple_Mul) + then return - UI_From_Dint - (Dint (Direct_Val (Left)) * Dint (Direct_Val (Right))); + UI_From_Int + (Int (Direct_Val (Left)) * Int (Direct_Val (Right))); end if; -- Otherwise we have the general case (Algorithm M in Knuth) @@ -2557,9 +2529,7 @@ package body Uintp is pragma Warnings (Off, Quotient); begin UI_Div_Rem - (Left, Right, Quotient, Remainder, - Discard_Quotient => True, - Discard_Remainder => False); + (Left, Right, Quotient, Remainder, Discard_Quotient => True); return Remainder; end; end UI_Rem; |