gimplify: Handle void expression as asm input [PR100501, PR100792]
[gcc.git] / libgcc / config / rs6000 / _powikf2.c
blobf54c7c15ab1eda0c0e4db819961c8ab5cf6343e2
1 /* Copyright (C) 1989-2024 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3, or (at your option) any later
8 version.
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
24 #include "soft-fp.h"
25 #include "quad-float128.h"
27 /* __powikf3 can be compiled 3 different ways:
29 1) If the assembler does not have support for the IEEE 128-bit insns
30 (xsaddqp, etc.) it is just compiled as __powikf2.
32 2) If the assembler has IEEE 128-bit floating point support, and __powikf2
33 is not previously defined, it is defined as __powikf2_sw.
35 3) If the assembler has IEEE 128-bit floating point support, and __powikf2
36 is included by _powikf2-hw.c, which defines __powikf2 as __powikf2_hw. The
37 __powikf2_hw.c is compiled with -mcpu=power9 and it automatically uses the
38 IEEE 128-bit instructions.
40 For #2/#3, float128-ifunc.c defines an ifunc function for __powikf2, that
41 will use the software version on power7/power8 systems, and the hardware
42 version on power9 systems.
44 The code is cloned from the code in libgcc2.c (which handles the standard
45 SF, DF, TF, and XF types). */
47 #if defined(FLOAT128_HW_INSNS) && !defined(__powikf2)
48 #define __powikf2 __powikf2_sw
49 #endif
51 TFtype
52 __powikf2 (TFtype x, SItype_ppc m)
54 unsigned int n = m < 0 ? -m : m;
55 TFtype y = n % 2 ? x : 1;
56 while (n >>= 1)
58 x = x * x;
59 if (n % 2)
60 y = y * x;
62 return m < 0 ? 1/y : y;