<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>3.9. Using VFP Floating Point</title><link rel="stylesheet" href="cs.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="Sourcery G++ Lite"><link rel="up" href="chap-target.html" title="Chapter 3. Sourcery G++ Lite for ARM GNU/Linux"><link rel="prev" href="sec-backtrace.html" title="3.8. GLIBC Backtrace Support"><link rel="next" href="sec-arm-fixed-point.html" title="3.10. Fixed-Point Arithmetic"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.9. Using VFP Floating Point</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-backtrace.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Sourcery G++ Lite for ARM GNU/Linux</th><td width="20%" align="right"> <a accesskey="n" href="sec-arm-fixed-point.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-armfloat"></a>3.9. Using VFP Floating Point</h2></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sec-armfloat-abi"></a>3.9.1. Enabling Hardware Floating Point</h3></div></div></div><p> | |
GCC provides three basic options for compiling floating-point code: | |
</p><div class="itemizedlist"><ul type="disc"><li> | |
Software floating point emulation, which is the default. | |
In this case, the compiler implements floating-point arithmetic | |
by means of library calls. | |
</li><li> | |
VFP hardware floating-point support using the soft-float ABI. | |
This is selected by the <code class="option">-mfloat-abi=softfp</code> option. | |
When you select this variant, | |
the compiler generates VFP floating-point instructions, but the | |
resulting code uses the same call and return conventions as | |
code compiled with software floating point. | |
</li><li> | |
VFP hardware floating-point support using the VFP ABI, which | |
is the VFP variant of the Procedure Call Standard for | |
the <span class="trademark">ARM</span>® | |
Architecture (AAPCS). This ABI uses VFP registers to | |
pass function arguments and return values, resulting in | |
faster floating-point code. To use this variant, compile | |
with <code class="option">-mfloat-abi=hard</code>. | |
</li></ul></div><p> | |
</p><p> | |
You can freely mix code compiled with either of the first two variants | |
in the same program, as they both use the same soft-float ABI. | |
However, code compiled with the VFP ABI is not link-compatible with | |
either of the other two options. | |
If you use the VFP ABI, you must use this option to compile your | |
entire program, and link with libraries that have also been compiled | |
with the VFP ABI. | |
For example, you may need to use the VFP ABI in order to link your | |
program with other code compiled by the ARM | |
<span class="trademark">RealView</span>® compiler, | |
which uses this ABI. | |
</p><p> | |
Sourcery G++ Lite for ARM GNU/Linux includes libraries built with | |
software floating point, | |
which are compatible with VFP code compiled using the soft-float ABI. | |
<span> | |
While the compiler is capable of generating code using the VFP ABI, | |
no compatible runtime libraries are provided in Sourcery G++ Lite. | |
However, VFP hard-float libraries built with both ABIs are available | |
to Sourcery G++ Standard and Professional Edition subscribers. | |
</span> | |
</p><p> | |
Note that, in addition to selecting hard/soft float and the ABI | |
via the <code class="option">-mfloat-abi</code> option, | |
you can also compile for a particular FPU using | |
the <code class="option">-mfpu</code> option. | |
For example, <code class="option">-mfpu=neon</code> selects VFPv3 with NEON | |
coprocessor extensions. | |
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id278736"></a>3.9.2. NEON SIMD Code</h3></div></div></div><p> | |
Sourcery G++ includes support for automatic generation of NEON | |
SIMD vector code. Autovectorization is a compiler optimization | |
in which loops involving normal integer or floating-point code are | |
transformed to use NEON SIMD instructions to process several data | |
elements at once. | |
</p><p> | |
To enable generation of NEON vector code, use the command-line options | |
<code class="option">-ftree-vectorize -mfpu=neon -mfloat-abi=softfp</code>. | |
The <code class="option">-mfpu=neon</code> option | |
also enables generation of VFPv3 scalar floating-point code. | |
</p><p> | |
Sourcery G++ also includes support for manual generation | |
of NEON SIMD code using C intrinsic functions. These intrinsics, | |
the same as those supported by the ARM | |
<span class="trademark">RealView</span>® compiler, are defined | |
in the <code class="filename">arm_neon.h</code> header | |
and are documented in the 'ARM NEON Intrinsics' section of the GCC | |
manual. The command-line options <code class="option">-mfpu=neon | |
-mfloat-abi=softfp</code> must be specified to use these | |
intrinsics; <code class="option">-ftree-vectorize</code> is not required. | |
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sec-arm-fp16"></a>3.9.3. Half-Precision Floating Point</h3></div></div></div><p> | |
Sourcery G++ for ARM GNU/Linux includes support for half-precision | |
(16-bit) floating point, including the new <code class="type">__fp16</code> data | |
type in C and C++, support for generating conversion instructions when | |
compiling for processors that support them, and library functions for | |
use in other cases. | |
</p><p> | |
To use half-precision floating point, you must explicitly enable it | |
via the <code class="option">-mfp16-format</code> command-line option to the | |
compiler. For more information about <code class="type">__fp16</code> representations | |
and usage from C and C++, refer to the GCC manual. | |
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-backtrace.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="chap-target.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-arm-fixed-point.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.8. GLIBC Backtrace Support </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 3.10. Fixed-Point Arithmetic</td></tr></table></div></body></html> |