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 20 COMPILER_RT_ABI fp_t __powitf2(fp_t a, int b) { 21 const int recip = b < 0; 22 fp_t r = 1; 23 while (1) { 24 if (b & 1) 25 r *= a; 26 b /= 2; 27 if (b == 0) 28 break; 29 a *= a; 30 } 31 return recip ? 1 / r : r; 32 } 33 34 #endif 35