Go to file
Joseph Myers 6dc198e3a5 Add minimal _FloatN, _FloatNx built-in functions.
This patch adds a minimal set of built-in functions for the new
_FloatN and _FloatNx types.

The functions added are __builtin_fabs*, __builtin_copysign*,
__builtin_huge_val*, __builtin_inf*, __builtin_nan* and
__builtin_nans* (where * = fN or fNx).  That is, 42 new entries are
added to the enum of built-in functions and the associated array of
decls, where not all of them are actually supported on any one target.

These functions are believed to be sufficient for libgcc (complex
multiplication and division use __builtin_huge_val*,
__builtin_copysign* and __builtin_fabs*) and for glibc (which also
depends on complex multiplication from libgcc, as well as using such
functions itself).  The basic target-independent support for folding /
expanding calls to these built-in functions is wired up, so those for
constants can be used in static initializers, and the fabs and
copysign built-ins can always be expanded to bit-manipulation inline
(for any format setting signbit_ro and signbit_rw, which covers all
formats supported for _FloatN and _FloatNx), although insn patterns
for fabs (abs<mode>2) and copysign (copysign<mode>3) will be used when
available and may result in more optimal code.

The complex multiplication and division functions in libgcc rely on
predefined macros (defined with -fbuilding-libgcc) to say what the
built-in function suffixes to use with a particular mode are.  This
patch updates that code accordingly, where previously it involved a
hack supposing that machine-specific suffixes for constants were also
suffixes for built-in functions.

As with the main _FloatN / _FloatNx patch, this patch does not update
code dealing only with optimizations that currently has cases only
covering float, double and long double, though some such cases are
straightforward and may be covered in a followup patch.

The functions are defined with DEF_GCC_BUILTIN, so calls to the TS
18661-3 functions such as fabsf128 and copysignf128, without the
__builtin_, will not be optimized.  As noted in the original _FloatN /
_FloatNx patch submission, in principle the bulk of the libm functions
that have built-in versions should have those versions extended to
cover the new types, but that would require more consideration of the
effects of increasing the size of the enum and initializing many more
functions at startup.

I don't know whether target-specific built-in functions can readily be
made into aliases for target-independent functions, but if they can,
it would make sense to do so for the x86, ia64 and rs6000 *q functions
corresponding to these, so that they can benefit from the
architecture-independent folding logic and from any optimizations
enabled for these functions in future, and so that less
target-specific code is needed to support them.

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc:
	* tree.h (CASE_FLT_FN_FLOATN_NX, float16_type_node)
	(float32_type_node, float64_type_node, float32x_type_node)
	(float128x_type_node): New macros.
	* builtin-types.def (BT_FLOAT16, BT_FLOAT32, BT_FLOAT64)
	(BT_FLOAT128, BT_FLOAT32X, BT_FLOAT64X, BT_FLOAT128X)
	(BT_FN_FLOAT16, BT_FN_FLOAT32, BT_FN_FLOAT64, BT_FN_FLOAT128)
	(BT_FN_FLOAT32X, BT_FN_FLOAT64X, BT_FN_FLOAT128X)
	(BT_FN_FLOAT16_FLOAT16, BT_FN_FLOAT32_FLOAT32)
	(BT_FN_FLOAT64_FLOAT64, BT_FN_FLOAT128_FLOAT128)
	(BT_FN_FLOAT32X_FLOAT32X, BT_FN_FLOAT64X_FLOAT64X)
	(BT_FN_FLOAT128X_FLOAT128X, BT_FN_FLOAT16_CONST_STRING)
	(BT_FN_FLOAT32_CONST_STRING, BT_FN_FLOAT64_CONST_STRING)
	(BT_FN_FLOAT128_CONST_STRING, BT_FN_FLOAT32X_CONST_STRING)
	(BT_FN_FLOAT64X_CONST_STRING, BT_FN_FLOAT128X_CONST_STRING)
	(BT_FN_FLOAT16_FLOAT16_FLOAT16, BT_FN_FLOAT32_FLOAT32_FLOAT32)
	(BT_FN_FLOAT64_FLOAT64_FLOAT64, BT_FN_FLOAT128_FLOAT128_FLOAT128)
	(BT_FN_FLOAT32X_FLOAT32X_FLOAT32X)
	(BT_FN_FLOAT64X_FLOAT64X_FLOAT64X)
	(BT_FN_FLOAT128X_FLOAT128X_FLOAT128X): New type definitions.
	* builtins.def (DEF_GCC_FLOATN_NX_BUILTINS): New macro.
	(copysign, fabs, huge_val, inf, nan, nans): Use it.
	* builtins.c (expand_builtin): Use CASE_FLT_FN_FLOATN_NX for fabs
	and copysign.
	(fold_builtin_0): Use CASE_FLT_FN_FLOATN_NX for inf and huge_val.
	(fold_builtin_1): Use CASE_FLT_FN_FLOATN_NX for fabs.
	* doc/extend.texi (Other Builtins): Document these built-in
	functions.
	* fold-const-call.c (fold_const_call): Use CASE_FLT_FN_FLOATN_NX
	for nan and nans.

gcc/c-family:
	* c-family/c-cppbuiltin.c (c_cpp_builtins): Check _FloatN and
	_FloatNx types for suffixes for built-in functions.

gcc/testsuite:
	* gcc.dg/torture/float128-builtin.c,
	gcc.dg/torture/float128-ieee-nan.c,
	gcc.dg/torture/float128x-builtin.c,
	gcc.dg/torture/float128x-nan.c, gcc.dg/torture/float16-builtin.c,
	gcc.dg/torture/float16-nan.c, gcc.dg/torture/float32-builtin.c,
	gcc.dg/torture/float32-nan.c, gcc.dg/torture/float32x-builtin.c,
	gcc.dg/torture/float32x-nan.c, gcc.dg/torture/float64-builtin.c,
	gcc.dg/torture/float64-nan.c, gcc.dg/torture/float64x-builtin.c,
	gcc.dg/torture/float64x-nan.c, gcc.dg/torture/floatn-builtin.h,
	gcc.dg/torture/floatn-nan.h: New tests.

From-SVN: r239658
2016-08-22 12:57:39 +01:00
boehm-gc [Hurd, kFreeBSD] boehm-gc: Use mmap instead of brk 2016-03-29 23:05:07 +02:00
config remove support for the interix target 2016-06-21 21:57:20 +00:00
contrib mark_spam.py: Mark as spam all comments done by a creator 2016-08-17 10:30:54 +00:00
fixincludes inclhack.def (hpux_longjmp): New fix. 2016-08-13 18:08:15 +00:00
gcc Add minimal _FloatN, _FloatNx built-in functions. 2016-08-22 12:57:39 +01:00
gnattools configure.ac: Add ACX_NONCANONICAL_HOST. 2016-05-16 08:55:12 +00:00
gotools Update copyright dates 2016-06-07 08:54:22 +00:00
include dwarf2.def (DW_AT_string_length_bit_size, [...]): New attributes. 2016-08-15 11:51:44 +02:00
INSTALL README: Do not mention CVS. 2014-10-12 15:05:28 +00:00
intl Makefile.def (libiconv): Define bootstrap=true. 2015-08-07 01:13:52 -04:00
libada config.guess: Remove SH5 support. 2016-04-30 09:11:03 +00:00
libatomic [libatomic] Add missing files for RTEMS support 2016-05-10 06:52:48 +00:00
libbacktrace re PR target/71161 (Lots of ASAN and libgo runtime FAILs after r236090) 2016-05-18 16:40:54 +02:00
libcc1 Update copyright dates 2016-06-07 08:54:22 +00:00
libcilkrts configure.ac: Move AC_USE_SYSTEM_EXTENSIONS behind AM_ENABLE_MULTILIB. 2016-05-10 16:44:19 +00:00
libcpp Reimplement removal fix-it hints in terms of replace 2016-08-19 21:18:05 +00:00
libdecnumber Update copyright years. 2016-01-04 15:30:50 +01:00
libffi [PR libffi/65567] libffi: Fix, and simply libffi_feature_test 2016-05-23 16:54:04 +02:00
libgcc Update soft-fp from glibc (PR libgcc/77265). 2016-08-16 22:30:56 +01:00
libgfortran Use a XOR cipher instead of byte shuffling to protect against bad seeds. 2016-08-19 17:19:51 +03:00
libgo cmd/go: ignore errors from go/build for standard packages 2016-08-15 18:05:24 +00:00
libgomp re PR fortran/71014 (associate statement inside omp parallel do appears to disable default private attribute for inner loop indices) 2016-08-19 17:30:33 +02:00
libiberty re PR c/7652 (-Wswitch-break : Warn if a switch case falls through) 2016-08-12 10:30:47 +00:00
libitm Allocate memory on cache line if requested 2016-04-19 10:01:11 -07:00
libjava Fix return type handling for Proxy classes 2016-07-13 21:34:52 +00:00
libmpx mpx_wrappers.c (move_bounds): Fix overflow bug. 2016-06-10 09:23:53 +00:00
libobjc Update copyright years. 2016-01-04 15:30:50 +01:00
liboffloadmic backport: Makefile.am (myo_inc_dir): Remove. 2016-07-21 18:41:27 +00:00
libquadmath gcc.c (process_command): Update copyright notice dates. 2016-01-04 14:03:35 +01:00
libsanitizer re PR sanitizer/71042 (libtsan requires __pointer_chk_guard@GLIBC_PRIVATE (6)) 2016-08-12 10:53:07 +02:00
libssp re PR target/65867 (bootstrap fails for mingw32 due to missing header in ssp.c) 2016-02-09 12:16:30 -07:00
libstdc++-v3 Simplify dg-options for tests using pthreads 2016-08-19 17:36:07 +01:00
libvtv Don't install libvtv without --enable-vtable-verify 2016-05-02 18:10:17 +00:00
lto-plugin re PR driver/68463 (Offloading fails when some objects are compiled with LTO and some without) 2016-02-25 12:23:52 +00:00
maintainer-scripts Document branch_changer.py script 2016-08-17 10:30:37 +00:00
zlib 2015-11-23 Matthias Klose <doko@ubuntu.com> 2015-11-23 20:27:57 +00:00
.dir-locals.el
.gitattributes add basic .gitattributes files to notice whitespace issues 2016-04-23 02:37:43 +00:00
.gitignore Add clang-format config to contrib folder 2015-11-19 12:32:09 +00:00
ABOUT-NLS
ChangeLog configure.ac (nds32*-*-*): Remove entry to enable gdb. 2016-07-20 08:09:25 +00:00
ChangeLog.jit Merger of dmalcolm/jit branch from git 2014-11-11 21:55:52 +00:00
ChangeLog.tree-ssa
compile Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
config-ml.in re PR other/66259 (Combined gcc and binutils build from git-master fails, with gas/as-new not existing) 2015-07-24 12:20:44 -06:00
config.guess config.guess: Import version 2016-04-02 (newest). 2016-05-16 16:13:37 -06:00
config.rpath
config.sub config.guess: Import version 2016-04-02 (newest). 2016-05-16 16:13:37 -06:00
configure configure.ac (nds32*-*-*): Remove entry to enable gdb. 2016-07-20 08:09:25 +00:00
configure.ac configure.ac (nds32*-*-*): Remove entry to enable gdb. 2016-07-20 08:09:25 +00:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
install-sh Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
libtool-ldflags re PR sanitizer/56781 (boostrap-asan failure: fixincl fails to link (missing -lasan)) 2014-04-17 14:23:28 +02:00
libtool.m4 * libtool.m4 (export_symbols_cmds) [AIX]: Add global TLS "L" symbols. 2015-11-26 08:20:59 -05:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS MAINTAINERS (Write After Approval): Add myself. 2016-07-19 10:39:19 +00:00
Makefile.def Add make autoprofiledbootstrap 2016-06-23 14:34:16 +00:00
Makefile.in Add make autoprofiledbootstrap 2016-06-23 14:34:16 +00:00
Makefile.tpl Add make autoprofiledbootstrap 2016-06-23 14:34:16 +00:00
missing Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
mkdep
mkinstalldirs Update from upstream Automake files. 2014-11-16 14:07:13 +00:00
move-if-change Update move-if-change from gnulib 2014-11-16 16:12:44 +00:00
README
symlink-tree
ylwrap Update from upstream Automake files. 2014-11-16 14:07:13 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.