vfp.hh (7386:23065556d48e) vfp.hh (7388:293878a9d220)
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
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, uint8_t imm)
312vfpFpSToFixed(float val, bool isSigned, bool half,
313 uint8_t imm, bool rzero = true)
313{
314{
314 fesetround(FeRoundZero);
315 int rmode = fegetround();
316 fesetround(FeRoundNearest);
315 val = val * powf(2.0, imm);
316 __asm__ __volatile__("" : "=m" (val) : "m" (val));
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);
317 feclearexcept(FeAllExceptions);
318 __asm__ __volatile__("" : "=m" (val) : "m" (val));
319 float origVal = val;
320 val = rintf(val);
321 int fpType = std::fpclassify(val);
322 if (fpType == FP_SUBNORMAL || fpType == FP_NAN) {
323 if (fpType == FP_NAN) {
324 feraiseexcept(FeInvalid);

--- 80 unchanged lines hidden (view full) ---

405 float scale = powf(2.0, imm);
406 __asm__ __volatile__("" : "=m" (scale) : "m" (scale));
407 feclearexcept(FeAllExceptions);
408 __asm__ __volatile__("" : "=m" (scale) : "m" (scale));
409 return fixDivDest(fpscr, val / scale, (float)val, scale);
410}
411
412static inline uint64_t
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
413vfpFpDToFixed(double val, bool isSigned, bool half, uint8_t imm)
419vfpFpDToFixed(double val, bool isSigned, bool half,
420 uint8_t imm, bool rzero = true)
414{
421{
422 int rmode = fegetround();
415 fesetround(FeRoundNearest);
416 val = val * pow(2.0, imm);
417 __asm__ __volatile__("" : "=m" (val) : "m" (val));
423 fesetround(FeRoundNearest);
424 val = val * pow(2.0, imm);
425 __asm__ __volatile__("" : "=m" (val) : "m" (val));
418 fesetround(FeRoundZero);
426 if (rzero)
427 fesetround(FeRoundZero);
428 else
429 fesetround(rmode);
419 feclearexcept(FeAllExceptions);
420 __asm__ __volatile__("" : "=m" (val) : "m" (val));
421 double origVal = val;
422 val = rint(val);
423 int fpType = std::fpclassify(val);
424 if (fpType == FP_SUBNORMAL || fpType == FP_NAN) {
425 if (fpType == FP_NAN) {
426 feraiseexcept(FeInvalid);

--- 246 unchanged lines hidden ---
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 ---