The GCC low-level runtime library
*********************************

GCC provides a low-level runtime library, libgcc.a or libgcc_s.so.1 on some platforms.  GCC generates calls to routines in this library automatically, whenever it needs to perform some operation that is too complicated to emit inline code for.

Most of the routines in libgcc handle arithmetic operations that the target processor cannot perform directly.  This includes integer multiply and divide on some machines, and all floating-point operations on other machines.  libgcc also includes routines for exception handling, and a handful of miscellaneous operations.

Some of these routines can be defined in mostly machine-independent C. Others must be hand-written in assembly language for each processor that needs them.

GCC will also generate calls to C library routines, such as memcpy and memset, in some cases.  The set of routines that GCC may possibly use is documented in Other Builtins (Using the GNU Compiler Collection (GCC)).

Routines for integer arithmetic
===============================

document me!

       __absvsi2
       __addvsi3
       __ashlsi3
       __ashrsi3
       __divsi3
       __lshrsi3
       __modsi3
       __mulsi3
       __mulvsi3
       __negvsi2
       __subvsi3
       __udivsi3
       __umodsi3

       __absvdi2
       __addvdi3
       __ashldi3
       __ashrdi3
       __cmpdi2
       __divdi3
       __ffsdi2
       __fixdfdi
       __fixsfdi
       __fixtfdi
       __fixxfdi
       __fixunsdfdi
       __fixunsdfsi
       __fixunssfsi
       __fixunssfdi
       __fixunstfdi
       __fixunstfsi
       __fixunsxfdi
       __fixunsxfsi
       __floatdidf
       __floatdisf
       __floatdixf
       __floatditf
       __lshrdi3
       __moddi3
       __muldi3
       __mulvdi3
       __negdi2
       __negvdi2
       __subvdi3
       __ucmpdi2
       __udivdi3
       __udivmoddi4
       __umoddi3

       __ashlti3
       __ashrti3
       __cmpti2
       __divti3
       __ffsti2
       __fixdfti
       __fixsfti
       __fixtfti
       __fixxfti
       __lshrti3
       __modti3
       __multi3
       __negti2
       __ucmpti2
       __udivmodti4
       __udivti3
       __umodti3
       __fixunsdfti
       __fixunssfti
       __fixunstfti
       __fixunsxfti
       __floattidf
       __floattisf
       __floattixf
       __floattitf

       __clzsi2
       __clzdi2
       __clzti2
       __ctzsi2
       __ctzdi2
       __ctzti2
       __popcountsi2
       __popcountdi2
       __popcountti2
       __paritysi2
       __paritydi2
       __parityti2

Routines for floating point emulation
=====================================

The software floating point library is used on machines which do not have hardware support for floating point.  It is also used whenever -msoft-float is used to disable generation of floating point instructions.  (Not all targets support this switch.)

For compatibility with other compilers, the floating point emulation routines can be renamed with the DECLARE_LIBRARY_RENAMES macro (see Library Calls).  In this section, the default names are used.

These routines take arguments and return values of a specific machine mode, not a specific C type.  See Machine Modes, for an explanation of this concept.  For illustrative purposes, in this section float is assumed to correspond to SFmode; double to DFmode; long double to TFmode; and int to SImode.  This is a common mapping, but not the only possibility.

Presently the library does not support XFmode, which is used for long double on some architectures.

Arithmetic functions
--------------------

 -- Runtime Function: float __addsf3 (float A, float B)
 -- Runtime Function: double __adddf3 (double A, double B)
 -- Runtime Function: long double __addtf3 (long double A, long double B)
     These functions return the sum of A and B.

 -- Runtime Function: float __subsf3 (float A, float B)
 -- Runtime Function: double __subdf3 (double A, double B)
 -- Runtime Function: long double __subtf3 (long double A, long double B)
     These functions return the difference between B and A; that is, A - B.

 -- Runtime Function: float __mulsf3 (float A, float B)
 -- Runtime Function: double __muldf3 (double A, double B)
 -- Runtime Function: long double __multf3 (long double A, long double B)
     These functions return the product of A and B.

 -- Runtime Function: float __divsf3 (float A, float B)
 -- Runtime Function: double __divdf3 (double A, double B)
 -- Runtime Function: long double __divtf3 (long double A, long double B)
     These functions return the quotient of A and B; that is, A / B.

 -- Runtime Function: double __negdf2 (double A)
 -- Runtime Function: long double __negtf2 (long double A)
 -- Runtime Function: float __negsf2 (float A)
     These functions return the negation of A.  They simply flip the sign bit, so they can produce negative zero and negative NaN.

Conversion functions
--------------------

 -- Runtime Function: double __extendsfdf2 (float A)
 -- Runtime Function: long double __extendsftf2 (float A)
 -- Runtime Function: long double __extenddftf2 (double A)
     These functions extend A to the wider mode of their return type.

 -- Runtime Function: double __trunctfdf2 (long double A)
 -- Runtime Function: float __trunctfsf2 (long double A)
 -- Runtime Function: float __truncdfsf2 (double A)
     These functions truncate A to the narrower mode of their return type, rounding toward zero.

 -- Runtime Function: int __fixsfsi (float A)
 -- Runtime Function: int __fixdfsi (double A)
 -- Runtime Function: int __fixtfsi (long double A)
     These functions convert A to a signed integer, rounding toward zero.

 -- Runtime Function: unsigned int __fixunssfsi (float A)
 -- Runtime Function: unsigned int __fixunsdfsi (double A)
 -- Runtime Function: unsigned int __fixunstfsi (long double A)
     These functions convert A to an unsigned integer, rounding toward zero.  Negative values all become zero.

 -- Runtime Function: float __floatsisf (int I)
 -- Runtime Function: double __floatsidf (int I)
 -- Runtime Function: long double __floatsitf (int I)
     These functions convert I, a signed integer, to floating point.

 -- Runtime Function: float __floatunsisf (unsigned int N)
 -- Runtime Function: double __floatunsidf (unsigned int N)
 -- Runtime Function: long double __floatunsitf (unsigned int N)
     These functions convert N, an unsigned integer, to floating point.

There are no functions to convert DImode integers to or from floating point; this reflects the fact that such conversions are rare, and processors with native 64-bit arithmetic tend to have hardware floating point support.  If such routines ever get added, they will be named __fixsfdi, __floatdisf, and so on.

Comparison functions
--------------------

There are two sets of basic comparison functions.

 -- Runtime Function: int __cmpsf2 (float A, float B)
 -- Runtime Function: int __cmpdf2 (double A, double B)
 -- Runtime Function: int __cmptf2 (long double A, long double B)
     These functions calculate a <=> b.  That is, if A is less than B, they return -1; if A is greater than B, they return 1; and if A and B are equal they return 0.  If either argument is NaN they return 1, but you should not rely on this; if NaN is a possibility, use one of the higher-level comparison functions.

 -- Runtime Function: int __unordsf2 (float A, float B)
 -- Runtime Function: int __unorddf2 (double A, double B)
 -- Runtime Function: int __unordtf2 (long double A, long double B)
     These functions return 1 if either argument is NaN, otherwise 0.

There is also a complete group of higher level functions which correspond directly to comparison operators.  They implement the ISO C semantics for floating-point comparisons, taking NaN into account. Pay careful attention to the return values defined for each set. Under the hood, all of these routines are implemented as

       if (__unordXf2 (a, b))
         return E;
       return __cmpXf2 (a, b);

where E is a constant chosen to give the proper behavior for NaN.  Thus, the meaning of the return value is different for each set. Do not rely on this implementation; only the semantics documented below are guaranteed.

 -- Runtime Function: int __eqsf2 (float A, float B)
 -- Runtime Function: int __eqdf2 (double A, double B)
 -- Runtime Function: int __eqtf2 (long double A, long double B)
     These functions return zero if neither argument is NaN, and A and B are equal.

 -- Runtime Function: int __nesf2 (float A, float B)
 -- Runtime Function: int __nedf2 (double A, double B)
 -- Runtime Function: int __netf2 (long double A, long double B)
     These functions return a nonzero value if either argument is NaN, or if A and B are unequal.

 -- Runtime Function: int __gesf2 (float A, float B)
 -- Runtime Function: int __gedf2 (double A, double B)
 -- Runtime Function: int __getf2 (long double A, long double B)
     These functions return a value greater than or equal to zero if neither argument is NaN, and A is greater than or equal to B.

 -- Runtime Function: int __ltsf2 (float A, float B)
 -- Runtime Function: int __ltdf2 (double A, double B)
 -- Runtime Function: int __lttf2 (long double A, long double B)
     These functions return a value less than zero if neither argument is NaN, and A is strictly less than B.

 -- Runtime Function: int __lesf2 (float A, float B)
 -- Runtime Function: int __ledf2 (double A, double B)
 -- Runtime Function: int __letf2 (long double A, long double B)
     These functions return a value less than or equal to zero if neither argument is NaN, and A is less than or equal to B.

 -- Runtime Function: int __gtsf2 (float A, float B)
 -- Runtime Function: int __gtdf2 (double A, double B)
 -- Runtime Function: int __gttf2 (long double A, long double B)
     These functions return a value greater than zero if neither argument is NaN, and A is strictly greater than B.

Language-independent routines for exception handling
====================================================

document me!

       _Unwind_DeleteException
       _Unwind_Find_FDE
       _Unwind_ForcedUnwind
       _Unwind_GetGR
       _Unwind_GetIP
       _Unwind_GetLanguageSpecificData
       _Unwind_GetRegionStart
       _Unwind_GetTextRelBase
       _Unwind_GetDataRelBase
       _Unwind_RaiseException
       _Unwind_Resume
       _Unwind_SetGR
       _Unwind_SetIP
       _Unwind_FindEnclosingFunction
       _Unwind_SjLj_Register
       _Unwind_SjLj_Unregister
       _Unwind_SjLj_RaiseException
       _Unwind_SjLj_ForcedUnwind
       _Unwind_SjLj_Resume
       __deregister_frame
       __deregister_frame_info
       __deregister_frame_info_bases
       __register_frame
       __register_frame_info
       __register_frame_info_bases
       __register_frame_info_table
       __register_frame_info_table_bases
       __register_frame_table

Miscellaneous runtime library routines
======================================

document me!

       __clear_cache

any others?