aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat/a-numaux.ads
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2020-10-18 17:19:53 -0300
committerAlexandre Oliva <oliva@gnu.org>2020-10-18 17:19:53 -0300
commit1e70b1a358b6ce3b894f284d88fbb90518d45cc0 (patch)
treec944e5cf3eb433dcea8fbc2ad4a850c7d38846cc /gcc/ada/libgnat/a-numaux.ads
parent476036b35c5e9203735b19b9967ff0e9932c8c31 (diff)
downloadgcc-1e70b1a358b6ce3b894f284d88fbb90518d45cc0.zip
gcc-1e70b1a358b6ce3b894f284d88fbb90518d45cc0.tar.gz
gcc-1e70b1a358b6ce3b894f284d88fbb90518d45cc0.tar.bz2
revamp ada.numerics.aux
Instead of mapping elementary functions for all types to a single type, use the intrinsics available for the various base types. A new Ada.Numerics.Aux_Generic_Float is introduced to explicitly dispatch, based on the 'Digits attribute of the base type, to the various newly-added Aux_Short_Float, Aux_Float, Aux_Long_Float, or Aux_Long_Long_Float. The Aux_Short_Float unit is implemented in terms of the Aux_Float one, and the others rely on the elementary functions from the C Math library for float, double and long double types, respectively. An Aux_Linker_Options is added, and units that import intrinsics from libm/libc depend on it to provide the "-lm" linker option if needed. The option is provided by default, but there is an alternate version that doesn't, that is used for vxworks targets. The Aux variant that used to open-code Sin and Cos for the ancient ppc-darwin, because of insufficient precision in libc, is dropped, along with the alternate dummy body for Aux. Both are presumed no longer needed. The original Ada.Numerics.Aux is retained, for backward compatibility, as a wrapper for a newly-added Aux_Compat, that renames Aux_Long_Float, except on x86, in which an alternate version renames Aux_Long_Long_Float. Generic_Elementary_Functions and Generic_Complex_Types are adjusted to use Aux_Generic_Float, avoiding the type conversions and inefficiencies of computing results in higher precision than requested. Generic_Complex_Elementary_Functions is adjusted to enable an additional instance of the sincos optimization, even without -gnatn. for gcc/ada/ChangeLog * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Compile Ada.Numerics child units Aux_Generic_Float, Aux_Long_Long_Float, Aux_Long_Float, Aux_Float, Aux_Short_Float, Aux_Compat, and Aux_Linker_Options. (X86_TARGET_PAIRS): Drop dummy body for Aux. Use x86 version of Aux_Compat. (X86_64_TARGET_PAIRS): Likewise. (LIBGNAT_TARGET_PAIRS): On VxWorks, select the nolibm variants. Drop the darwin version of Aux. Drop the redundant libc-x86 numaux variants on x86* kfreebsd variants. * libgnat/a-nagefl.ads: New Aux_Generic_Float. * libgnat/a-naliop.ads: New Aux_Linker_Options. * libgnat/a-naliop__nolibm.ads: New. * libgnat/a-nallfl.ads: New Aux_Long_Long_Float. * libgnat/a-nalofl.ads: New Aux_Long_Float. * libgnat/a-nuaufl.ads: New Aux_Float. * libgnat/a-nashfl.ads: New Aux_Short_Float. * libgnat/a-ngcefu.adb (Exp): Factor out the Im (X) passed to Sin and Cos in the Complex variant too. * libgnat/a-ngcoty.adb: Switch to Aux_Generic_Float. Drop redundant conversions. * libgnat/a-ngelfu.adb: Likewise. * libgnat/a-nuauco.ads: New Aux_Compat. * libgnat/a-nuauco__x86.ads: New. * libgnat/a-numaux.ads: Replace with Compat wrapper. * libgnat/a-numaux__darwin.adb: Remove. * libgnat/a-numaux__darwin.ads: Remove. * libgnat/a-numaux__dummy.adb: Remove. * libgnat/a-numaux__libc-x86.ads: Remove. * libgnat/a-numaux__vxworks.ads: Remove.
Diffstat (limited to 'gcc/ada/libgnat/a-numaux.ads')
-rw-r--r--gcc/ada/libgnat/a-numaux.ads94
1 files changed, 35 insertions, 59 deletions
diff --git a/gcc/ada/libgnat/a-numaux.ads b/gcc/ada/libgnat/a-numaux.ads
index 4154e1a..42ed336 100644
--- a/gcc/ada/libgnat/a-numaux.ads
+++ b/gcc/ada/libgnat/a-numaux.ads
@@ -5,7 +5,6 @@
-- A D A . N U M E R I C S . A U X --
-- --
-- S p e c --
--- (C Library Version, non-x86) --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
@@ -30,83 +29,60 @@
-- --
------------------------------------------------------------------------------
--- This package provides the basic computational interface for the generic
--- elementary functions. The C library version interfaces with the routines
--- in the C mathematical library, and is thus quite portable, although it may
--- not necessarily meet the requirements for accuracy in the numerics annex.
--- One advantage of using this package is that it will interface directly to
--- hardware instructions, such as the those provided on the Intel x86.
+-- This is a backward-compatibility unit, for users of this internal
+-- package before the introduction of Aux.Generic_Float.
--- This version here is for use with normal Unix math functions. Alternative
--- versions are provided for special situations:
-
--- a-numaux-darwin For PowerPC/Darwin (special handling of sin/cos)
--- a-numaux-libc-x86 For the x86, using 80-bit long double format
--- a-numaux-x86 For the x86, using 80-bit long double format with
--- inline asm statements
--- a-numaux-vxworks For use on VxWorks (where we have no libm.a library)
+with Ada.Numerics.Aux_Compat;
package Ada.Numerics.Aux is
pragma Pure;
- pragma Linker_Options ("-lm");
+ package Aux renames Aux_Compat;
+
+ type Double is new Aux.T;
- type Double is new Long_Float;
- -- Type Double is the type used to call the C routines
+ subtype T is Double;
+ subtype W is Aux.T;
- -- We import these functions directly from C. Note that we label them
- -- all as pure functions, because indeed all of them are in fact pure.
+ -- Use the Aux implementation.
- function Sin (X : Double) return Double;
- pragma Import (Intrinsic, Sin, "sin");
- pragma Pure_Function (Sin);
+ function Sin (X : T) return T
+ is (T (Aux.Sin (W (X))));
- function Cos (X : Double) return Double;
- pragma Import (Intrinsic, Cos, "cos");
- pragma Pure_Function (Cos);
+ function Cos (X : T) return T
+ is (T (Aux.Cos (W (X))));
- function Tan (X : Double) return Double;
- pragma Import (Intrinsic, Tan, "tan");
- pragma Pure_Function (Tan);
+ function Tan (X : T) return T
+ is (T (Aux.Tan (W (X))));
- function Exp (X : Double) return Double;
- pragma Import (Intrinsic, Exp, "exp");
- pragma Pure_Function (Exp);
+ function Exp (X : T) return T
+ is (T (Aux.Exp (W (X))));
- function Sqrt (X : Double) return Double;
- pragma Import (Intrinsic, Sqrt, "sqrt");
- pragma Pure_Function (Sqrt);
+ function Sqrt (X : T) return T
+ is (T (Aux.Sqrt (W (X))));
- function Log (X : Double) return Double;
- pragma Import (Intrinsic, Log, "log");
- pragma Pure_Function (Log);
+ function Log (X : T) return T
+ is (T (Aux.Log (W (X))));
- function Acos (X : Double) return Double;
- pragma Import (Intrinsic, Acos, "acos");
- pragma Pure_Function (Acos);
+ function Acos (X : T) return T
+ is (T (Aux.Acos (W (X))));
- function Asin (X : Double) return Double;
- pragma Import (Intrinsic, Asin, "asin");
- pragma Pure_Function (Asin);
+ function Asin (X : T) return T
+ is (T (Aux.Asin (W (X))));
- function Atan (X : Double) return Double;
- pragma Import (Intrinsic, Atan, "atan");
- pragma Pure_Function (Atan);
+ function Atan (X : T) return T
+ is (T (Aux.Atan (W (X))));
- function Sinh (X : Double) return Double;
- pragma Import (Intrinsic, Sinh, "sinh");
- pragma Pure_Function (Sinh);
+ function Sinh (X : T) return T
+ is (T (Aux.Sinh (W (X))));
- function Cosh (X : Double) return Double;
- pragma Import (Intrinsic, Cosh, "cosh");
- pragma Pure_Function (Cosh);
+ function Cosh (X : T) return T
+ is (T (Aux.Cosh (W (X))));
- function Tanh (X : Double) return Double;
- pragma Import (Intrinsic, Tanh, "tanh");
- pragma Pure_Function (Tanh);
+ function Tanh (X : T) return T
+ is (T (Aux.Tanh (W (X))));
- function Pow (X, Y : Double) return Double;
- pragma Import (Intrinsic, Pow, "pow");
- pragma Pure_Function (Pow);
+ function Pow (X, Y : T) return T
+ is (T (Aux.Pow (W (X), W (Y))));
end Ada.Numerics.Aux;