Re: r352221 - Disable _Float16 for non ARM/SPIR Targets

2019-01-28 Thread Hans Wennborg via cfe-commits
Merged together with r35 to 8.0 in r352363.

On Fri, Jan 25, 2019 at 9:27 AM Erich Keane via cfe-commits
 wrote:
>
> Author: erichkeane
> Date: Fri Jan 25 09:27:57 2019
> New Revision: 352221
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352221=rev
> Log:
> Disable _Float16 for non ARM/SPIR Targets
>
> As Discussed here:
> http://lists.llvm.org/pipermail/llvm-dev/2019-January/129543.html
>
> There are problems exposing the _Float16 type on architectures that
> haven't defined the ABI/ISel for the type yet, so we're temporarily
> disabling the type and making it opt-in.
>
> Differential Revision: https://reviews.llvm.org/D57188
>
> Change-Id: I5db7366dedf1deb9485adb8948b1deb7e612a736
>
> Added:
> cfe/trunk/test/Sema/Float16.c   (with props)
> Modified:
> cfe/trunk/docs/LanguageExtensions.rst
> cfe/trunk/include/clang/Basic/TargetInfo.h
> cfe/trunk/lib/Basic/TargetInfo.cpp
> cfe/trunk/lib/Basic/Targets/AArch64.cpp
> cfe/trunk/lib/Basic/Targets/ARM.cpp
> cfe/trunk/lib/Basic/Targets/SPIR.h
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/test/AST/float16.cpp
> cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
> cfe/trunk/test/Lexer/half-literal.cpp
>
> Modified: cfe/trunk/docs/LanguageExtensions.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=352221=352220=352221=diff
> ==
> --- cfe/trunk/docs/LanguageExtensions.rst (original)
> +++ cfe/trunk/docs/LanguageExtensions.rst Fri Jan 25 09:27:57 2019
> @@ -474,44 +474,58 @@ Half-Precision Floating Point
>  =
>
>  Clang supports two half-precision (16-bit) floating point types: ``__fp16`` 
> and
> -``_Float16``. ``__fp16`` is defined in the ARM C Language Extensions (`ACLE
> -`_)
> -and ``_Float16`` in ISO/IEC TS 18661-3:2015.
> -
> -``__fp16`` is a storage and interchange format only. This means that values 
> of
> -``__fp16`` promote to (at least) float when used in arithmetic operations.
> -There are two ``__fp16`` formats. Clang supports the IEEE 754-2008 format and
> -not the ARM alternative format.
> -
> -ISO/IEC TS 18661-3:2015 defines C support for additional floating point 
> types.
> -``_FloatN`` is defined as a binary floating type, where the N suffix denotes
> -the number of bits and is 16, 32, 64, or greater and equal to 128 and a
> -multiple of 32. Clang supports ``_Float16``. The difference from ``__fp16`` 
> is
> -that arithmetic on ``_Float16`` is performed in half-precision, thus it is 
> not
> -a storage-only format. ``_Float16`` is available as a source language type in
> -both C and C++ mode.
> -
> -It is recommended that portable code use the ``_Float16`` type because
> -``__fp16`` is an ARM C-Language Extension (ACLE), whereas ``_Float16`` is
> -defined by the C standards committee, so using ``_Float16`` will not prevent
> -code from being ported to architectures other than Arm.  Also, ``_Float16``
> -arithmetic and operations will directly map on half-precision instructions 
> when
> -they are available (e.g. Armv8.2-A), avoiding conversions to/from
> -single-precision, and thus will result in more performant code. If
> -half-precision instructions are unavailable, values will be promoted to
> -single-precision, similar to the semantics of ``__fp16`` except that the
> -results will be stored in single-precision.
> -
> -In an arithmetic operation where one operand is of ``__fp16`` type and the
> -other is of ``_Float16`` type, the ``_Float16`` type is first converted to
> -``__fp16`` type and then the operation is completed as if both operands were 
> of
> -``__fp16`` type.
> -
> -To define a ``_Float16`` literal, suffix ``f16`` can be appended to the 
> compile-time
> -constant declaration. There is no default argument promotion for 
> ``_Float16``; this
> -applies to the standard floating types only. As a consequence, for example, 
> an
> -explicit cast is required for printing a ``_Float16`` value (there is no 
> string
> -format specifier for ``_Float16``).
> +``_Float16``.  These types are supported in all language modes.
> +
> +``__fp16`` is supported on every target, as it is purely a storage format; 
> see below.
> +``_Float16`` is currently only supported on the following targets, with 
> further
> +targets pending ABI standardization:
> +- 32-bit ARM
> +- 64-bit ARM (AArch64)
> +- SPIR
> +``_Float16`` will be supported on more targets as they define ABIs for it.
> +
> +``__fp16`` is a storage and interchange format only.  This means that values 
> of
> +``__fp16`` are immediately promoted to (at least) ``float`` when used in 
> arithmetic
> +operations, so that e.g. the result of adding two ``__fp16`` values has type 
> ``float``.
> +The behavior of ``__fp16`` is specified by the ARM C Language Extensions 
> (`ACLE 

r352221 - Disable _Float16 for non ARM/SPIR Targets

2019-01-25 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jan 25 09:27:57 2019
New Revision: 352221

URL: http://llvm.org/viewvc/llvm-project?rev=352221=rev
Log:
Disable _Float16 for non ARM/SPIR Targets

As Discussed here:
http://lists.llvm.org/pipermail/llvm-dev/2019-January/129543.html

There are problems exposing the _Float16 type on architectures that
haven't defined the ABI/ISel for the type yet, so we're temporarily
disabling the type and making it opt-in.

Differential Revision: https://reviews.llvm.org/D57188

Change-Id: I5db7366dedf1deb9485adb8948b1deb7e612a736

Added:
cfe/trunk/test/Sema/Float16.c   (with props)
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Basic/Targets/SPIR.h
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/AST/float16.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
cfe/trunk/test/Lexer/half-literal.cpp

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=352221=352220=352221=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Fri Jan 25 09:27:57 2019
@@ -474,44 +474,58 @@ Half-Precision Floating Point
 =
 
 Clang supports two half-precision (16-bit) floating point types: ``__fp16`` and
-``_Float16``. ``__fp16`` is defined in the ARM C Language Extensions (`ACLE
-`_)
-and ``_Float16`` in ISO/IEC TS 18661-3:2015.
-
-``__fp16`` is a storage and interchange format only. This means that values of
-``__fp16`` promote to (at least) float when used in arithmetic operations.
-There are two ``__fp16`` formats. Clang supports the IEEE 754-2008 format and
-not the ARM alternative format.
-
-ISO/IEC TS 18661-3:2015 defines C support for additional floating point types.
-``_FloatN`` is defined as a binary floating type, where the N suffix denotes
-the number of bits and is 16, 32, 64, or greater and equal to 128 and a
-multiple of 32. Clang supports ``_Float16``. The difference from ``__fp16`` is
-that arithmetic on ``_Float16`` is performed in half-precision, thus it is not
-a storage-only format. ``_Float16`` is available as a source language type in
-both C and C++ mode.
-
-It is recommended that portable code use the ``_Float16`` type because
-``__fp16`` is an ARM C-Language Extension (ACLE), whereas ``_Float16`` is
-defined by the C standards committee, so using ``_Float16`` will not prevent
-code from being ported to architectures other than Arm.  Also, ``_Float16``
-arithmetic and operations will directly map on half-precision instructions when
-they are available (e.g. Armv8.2-A), avoiding conversions to/from
-single-precision, and thus will result in more performant code. If
-half-precision instructions are unavailable, values will be promoted to
-single-precision, similar to the semantics of ``__fp16`` except that the
-results will be stored in single-precision.
-
-In an arithmetic operation where one operand is of ``__fp16`` type and the
-other is of ``_Float16`` type, the ``_Float16`` type is first converted to
-``__fp16`` type and then the operation is completed as if both operands were of
-``__fp16`` type.
-
-To define a ``_Float16`` literal, suffix ``f16`` can be appended to the 
compile-time
-constant declaration. There is no default argument promotion for ``_Float16``; 
this
-applies to the standard floating types only. As a consequence, for example, an
-explicit cast is required for printing a ``_Float16`` value (there is no string
-format specifier for ``_Float16``).
+``_Float16``.  These types are supported in all language modes.
+
+``__fp16`` is supported on every target, as it is purely a storage format; see 
below.
+``_Float16`` is currently only supported on the following targets, with further
+targets pending ABI standardization:
+- 32-bit ARM
+- 64-bit ARM (AArch64)
+- SPIR
+``_Float16`` will be supported on more targets as they define ABIs for it.
+
+``__fp16`` is a storage and interchange format only.  This means that values of
+``__fp16`` are immediately promoted to (at least) ``float`` when used in 
arithmetic
+operations, so that e.g. the result of adding two ``__fp16`` values has type 
``float``.
+The behavior of ``__fp16`` is specified by the ARM C Language Extensions 
(`ACLE 
`_).
+Clang uses the ``binary16`` format from IEEE 754-2008 for ``__fp16``, not the 
ARM
+alternative format.
+
+``_Float16`` is an extended floating-point type.  This means that, just like 
arithmetic on
+``float`` or ``double``, arithmetic on ``_Float16``