1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>3.4.�Using VFP Floating Point</title><link rel="stylesheet" type="text/css" href="cs.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.0"><link rel="home" href="index.html" title="Sourcery CodeBench Lite"><link rel="up" href="chap-target.html" title="Chapter�3.�Sourcery CodeBench Lite for ARM EABI"><link rel="prev" href="sec-using-flash.html" title="3.3.�Using Flash Memory"><link rel="next" href="sec-arm-fixed-point.html" title="3.5.�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.4.�Using VFP Floating Point</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-using-flash.html">Prev</a>�</td><th width="60%" align="center">Chapter�3.�Sourcery CodeBench Lite for ARM EABI</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"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-armfloat"></a>3.4.�Using VFP Floating Point</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="sec-armfloat-abi"></a>3.4.1.�Enabling Hardware Floating Point</h3></div></div></div><p> 2 GCC provides three basic options for compiling floating-point code: 3 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> 4 Software floating point emulation, which is the default. 5 In this case, the compiler implements floating-point arithmetic 6 by means of library calls. 7 </li><li class="listitem"> 8 VFP hardware floating-point support using the soft-float ABI. 9 This is selected by the <code class="option">-mfloat-abi=softfp</code> option. 10 When you select this variant, 11 the compiler generates VFP floating-point instructions, but the 12 resulting code uses the same call and return conventions as 13 code compiled with software floating point. 14 </li><li class="listitem"> 15 VFP hardware floating-point support using the VFP ABI, which 16 is the VFP variant of the Procedure Call Standard for 17 the <span class="trademark">ARM</span>� 18 Architecture (AAPCS). This ABI uses VFP registers to 19 pass function arguments and return values, resulting in 20 faster floating-point code. To use this variant, compile 21 with <code class="option">-mfloat-abi=hard</code>. 22 </li></ul></div><p> 23 </p><p> 24 You can freely mix code compiled with either of the first two variants 25 in the same program, as they both use the same soft-float ABI. 26 However, code compiled with the VFP ABI is not link-compatible with 27 either of the other two options. 28 If you use the VFP ABI, you must use this option to compile your 29 entire program, and link with libraries that have also been compiled 30 with the VFP ABI. 31 For example, you may need to use the VFP ABI in order to link your 32 program with other code compiled by the ARM 33 <span class="trademark">RealView</span>� compiler, 34 which uses this ABI. 35 </p><p> 36 Sourcery CodeBench Lite for ARM EABI includes libraries built with 37 software floating point, 38 which are compatible with VFP code compiled using the soft-float ABI. 39 40 <span class="phrase"> 41 While the compiler is capable of generating code using the VFP ABI, 42 no compatible runtime libraries are provided in Sourcery CodeBench Lite. 43 However, VFP hard-float libraries built with both ABIs are available 44 to Sourcery CodeBench Standard and Professional Edition subscribers. 45 </span> 46 47 </p><p> 48 Note that, in addition to selecting hard/soft float and the ABI 49 via the <code class="option">-mfloat-abi</code> option, 50 you can also compile for a particular FPU using 51 the <code class="option">-mfpu</code> option. 52 For example, <code class="option">-mfpu=neon</code> selects VFPv3 with NEON 53 coprocessor extensions. 54 </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="idm46915333748160"></a>3.4.2.�NEON SIMD Code</h3></div></div></div><p> 55 Sourcery CodeBench includes support for automatic generation of NEON 56 SIMD vector code. Autovectorization is a compiler optimization 57 in which loops involving normal integer or floating-point code are 58 transformed to use NEON SIMD instructions to process several data 59 elements at once. 60 </p><p> 61 To enable generation of NEON vector code, use the command-line options 62 <code class="option">-ftree-vectorize -mfpu=neon -mfloat-abi=softfp</code>. 63 The <code class="option">-mfpu=neon</code> option 64 also enables generation of VFPv3 scalar floating-point code. 65 </p><p> 66 Sourcery CodeBench also includes support for manual generation 67 of NEON SIMD code using C intrinsic functions. These intrinsics, 68 the same as those supported by the ARM 69 <span class="trademark">RealView</span>� compiler, are defined 70 in the <code class="filename">arm_neon.h</code> header 71 and are documented in the 'ARM NEON Intrinsics' section of the GCC 72 manual. The command-line options <code class="option">-mfpu=neon 73 -mfloat-abi=softfp</code> must be specified to use these 74 intrinsics; <code class="option">-ftree-vectorize</code> is not required. 75 </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="sec-arm-fp16"></a>3.4.3.�Half-Precision Floating Point</h3></div></div></div><p> 76 Sourcery CodeBench for ARM EABI includes support for half-precision 77 (16-bit) floating point, including the new <code class="type">__fp16</code> data 78 type in C and C++, support for generating conversion instructions when 79 compiling for processors that support them, and library functions for 80 use in other cases. 81 82 </p><p> 83 To use half-precision floating point, you must explicitly enable it 84 via the <code class="option">-mfp16-format</code> command-line option to the 85 compiler. For more information about <code class="type">__fp16</code> representations 86 and usage from C and C++, refer to the GCC manual. 87 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-using-flash.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.3.�Using Flash Memory�</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">�3.5.�Fixed-Point Arithmetic</td></tr></table></div></body></html> 88