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 --- 295 unchanged lines hidden (view full) --- 304 feraiseexcept(FeUnderflow); 305 } 306 __asm__ __volatile__("" :: "m" (temp)); 307 } 308 return mid; 309} 310 311static inline uint64_t |
312vfpFpSToFixed(float val, bool isSigned, bool half, 313 uint8_t imm, bool rzero = true) |
314{ |
315 int rmode = fegetround(); 316 fesetround(FeRoundNearest); |
317 val = val * powf(2.0, imm); 318 __asm__ __volatile__("" : "=m" (val) : "m" (val)); |
319 if (rzero) 320 fesetround(FeRoundZero); 321 else 322 fesetround(rmode); |
323 feclearexcept(FeAllExceptions); 324 __asm__ __volatile__("" : "=m" (val) : "m" (val)); 325 float origVal = val; 326 val = rintf(val); 327 int fpType = std::fpclassify(val); 328 if (fpType == FP_SUBNORMAL || fpType == FP_NAN) { 329 if (fpType == FP_NAN) { 330 feraiseexcept(FeInvalid); --- 80 unchanged lines hidden (view full) --- 411 float scale = powf(2.0, imm); 412 __asm__ __volatile__("" : "=m" (scale) : "m" (scale)); 413 feclearexcept(FeAllExceptions); 414 __asm__ __volatile__("" : "=m" (scale) : "m" (scale)); 415 return fixDivDest(fpscr, val / scale, (float)val, scale); 416} 417 418static inline uint64_t |
419vfpFpDToFixed(double val, bool isSigned, bool half, 420 uint8_t imm, bool rzero = true) |
421{ |
422 int rmode = fegetround(); |
423 fesetround(FeRoundNearest); 424 val = val * pow(2.0, imm); 425 __asm__ __volatile__("" : "=m" (val) : "m" (val)); |
426 if (rzero) 427 fesetround(FeRoundZero); 428 else 429 fesetround(rmode); |
430 feclearexcept(FeAllExceptions); 431 __asm__ __volatile__("" : "=m" (val) : "m" (val)); 432 double origVal = val; 433 val = rint(val); 434 int fpType = std::fpclassify(val); 435 if (fpType == FP_SUBNORMAL || fpType == FP_NAN) { 436 if (fpType == FP_NAN) { 437 feraiseexcept(FeInvalid); --- 246 unchanged lines hidden --- |