llvm-project
34 строки · 840.0 Байт
1//===-- powitf2.cpp - Implement __powitf2 ---------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements __powitf2 for the compiler_rt library.
10//
11//===----------------------------------------------------------------------===//
12
13#define QUAD_PRECISION
14#include "fp_lib.h"
15
16#if defined(CRT_HAS_TF_MODE)
17
18// Returns: a ^ b
19
20COMPILER_RT_ABI fp_t __powitf2(fp_t a, int b) {
21const int recip = b < 0;
22fp_t r = 1;
23while (1) {
24if (b & 1)
25r *= a;
26b /= 2;
27if (b == 0)
28break;
29a *= a;
30}
31return recip ? 1 / r : r;
32}
33
34#endif
35