1276789Sdim/* ===-- powitf2.cpp - Implement __powitf2 ---------------------------------=== 2276789Sdim * 3276789Sdim * The LLVM Compiler Infrastructure 4276789Sdim * 5276789Sdim * This file is dual licensed under the MIT and the University of Illinois Open 6276789Sdim * Source Licenses. See LICENSE.TXT for details. 7276789Sdim * 8276789Sdim * ===----------------------------------------------------------------------=== 9276789Sdim * 10276789Sdim * This file implements __powitf2 for the compiler_rt library. 11276789Sdim * 12276789Sdim * ===----------------------------------------------------------------------=== 13276789Sdim */ 14276789Sdim 15276789Sdim#include "int_lib.h" 16276789Sdim 17276789Sdim#if _ARCH_PPC 18276789Sdim 19276789Sdim/* Returns: a ^ b */ 20276789Sdim 21276789SdimCOMPILER_RT_ABI long double 22276789Sdim__powitf2(long double a, si_int b) 23276789Sdim{ 24276789Sdim const int recip = b < 0; 25276789Sdim long double r = 1; 26276789Sdim while (1) 27276789Sdim { 28276789Sdim if (b & 1) 29276789Sdim r *= a; 30276789Sdim b /= 2; 31276789Sdim if (b == 0) 32276789Sdim break; 33276789Sdim a *= a; 34276789Sdim } 35276789Sdim return recip ? 1/r : r; 36276789Sdim} 37276789Sdim 38276789Sdim#endif 39