vfp.hh (7379:92ef7238d230) vfp.hh (7381:bc68c91e9814)
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

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

105vfpFpSToFixed(float val, bool isSigned, bool half, uint8_t imm)
106{
107 fesetround(FeRoundZero);
108 val = val * powf(2.0, imm);
109 __asm__ __volatile__("" : "=m" (val) : "m" (val));
110 feclearexcept(FeAllExceptions);
111 if (isSigned) {
112 if (half) {
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

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

105vfpFpSToFixed(float val, bool isSigned, bool half, uint8_t imm)
106{
107 fesetround(FeRoundZero);
108 val = val * powf(2.0, imm);
109 __asm__ __volatile__("" : "=m" (val) : "m" (val));
110 feclearexcept(FeAllExceptions);
111 if (isSigned) {
112 if (half) {
113 if (val < (int16_t)(1 << 15)) {
113 if ((double)val < (int16_t)(1 << 15)) {
114 feraiseexcept(FeInvalid);
115 return (int16_t)(1 << 15);
116 }
114 feraiseexcept(FeInvalid);
115 return (int16_t)(1 << 15);
116 }
117 if (val > (int16_t)mask(15)) {
117 if ((double)val > (int16_t)mask(15)) {
118 feraiseexcept(FeInvalid);
119 return (int16_t)mask(15);
120 }
121 return (int16_t)val;
122 } else {
118 feraiseexcept(FeInvalid);
119 return (int16_t)mask(15);
120 }
121 return (int16_t)val;
122 } else {
123 if (val < (int32_t)(1 << 31)) {
123 if ((double)val < (int32_t)(1 << 31)) {
124 feraiseexcept(FeInvalid);
125 return (int32_t)(1 << 31);
126 }
124 feraiseexcept(FeInvalid);
125 return (int32_t)(1 << 31);
126 }
127 if (val > (int32_t)mask(31)) {
127 if ((double)val > (int32_t)mask(31)) {
128 feraiseexcept(FeInvalid);
129 return (int32_t)mask(31);
130 }
131 return (int32_t)val;
132 }
133 } else {
134 if (half) {
128 feraiseexcept(FeInvalid);
129 return (int32_t)mask(31);
130 }
131 return (int32_t)val;
132 }
133 } else {
134 if (half) {
135 if (val < 0) {
135 if ((double)val < 0) {
136 feraiseexcept(FeInvalid);
137 return 0;
138 }
136 feraiseexcept(FeInvalid);
137 return 0;
138 }
139 if (val > (mask(16))) {
139 if ((double)val > (mask(16))) {
140 feraiseexcept(FeInvalid);
141 return mask(16);
142 }
143 return (uint16_t)val;
144 } else {
140 feraiseexcept(FeInvalid);
141 return mask(16);
142 }
143 return (uint16_t)val;
144 } else {
145 if (val < 0) {
145 if ((double)val < 0) {
146 feraiseexcept(FeInvalid);
147 return 0;
148 }
146 feraiseexcept(FeInvalid);
147 return 0;
148 }
149 if (val > (mask(32))) {
149 if ((double)val > (mask(32))) {
150 feraiseexcept(FeInvalid);
151 return mask(32);
152 }
153 return (uint32_t)val;
154 }
155 }
156}
157

--- 248 unchanged lines hidden ---
150 feraiseexcept(FeInvalid);
151 return mask(32);
152 }
153 return (uint32_t)val;
154 }
155 }
156}
157

--- 248 unchanged lines hidden ---