1/* 2 * Copyright (c) 2010 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 92 unchanged lines hidden (view full) --- 101{ 102 VfpRoundNearest = 0, 103 VfpRoundUpward = 1, 104 VfpRoundDown = 2, 105 VfpRoundZero = 3 106}; 107 108template <class fpType> |
109static inline bool 110flushToZero(fpType &op) 111{ 112 fpType junk = 0.0; 113 if (std::fpclassify(op) == FP_SUBNORMAL) { 114 uint64_t bitMask = ULL(0x1) << (sizeof(fpType) * 8 - 1); 115 op = bitsToFp(fpToBits(op) & bitMask, junk); 116 return true; --- 5 unchanged lines hidden (view full) --- 122static inline bool 123flushToZero(fpType &op1, fpType &op2) 124{ 125 bool flush1 = flushToZero(op1); 126 bool flush2 = flushToZero(op2); 127 return flush1 || flush2; 128} 129 |
130template <class fpType> 131static inline void 132vfpFlushToZero(FPSCR &fpscr, fpType &op) 133{ 134 if (fpscr.fz == 1 && flushToZero(op)) { 135 fpscr.idc = 1; 136 } 137} 138 139template <class fpType> 140static inline void 141vfpFlushToZero(FPSCR &fpscr, fpType &op1, fpType &op2) 142{ 143 vfpFlushToZero(fpscr, op1); 144 vfpFlushToZero(fpscr, op2); 145} 146 |
147static inline uint32_t 148fpToBits(float fp) 149{ 150 union 151 { 152 float fp; 153 uint32_t bits; 154 } val; --- 35 unchanged lines hidden (view full) --- 190 } val; 191 val.bits = bits; 192 return val.fp; 193} 194 195typedef int VfpSavedState; 196 197static inline VfpSavedState |
198prepFpState(uint32_t rMode) 199{ 200 int roundingMode = fegetround(); 201 feclearexcept(FeAllExceptions); 202 switch (rMode) { 203 case VfpRoundNearest: 204 fesetround(FeRoundNearest); 205 break; --- 5 unchanged lines hidden (view full) --- 211 break; 212 case VfpRoundZero: 213 fesetround(FeRoundZero); 214 break; 215 } 216 return roundingMode; 217} 218 |
219static inline void 220finishVfp(FPSCR &fpscr, VfpSavedState state) 221{ 222 int exceptions = fetestexcept(FeAllExceptions); 223 bool underflow = false; 224 if (exceptions & FeInvalid) { 225 fpscr.ioc = 1; 226 } --- 783 unchanged lines hidden --- |