Changeset 97160 in vbox
- Timestamp:
- Oct 14, 2022 7:08:05 PM (2 years ago)
- Location:
- trunk/src/libs/softfloat-3e/source
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/softfloat-3e/source/extF80_sincos.c
r96666 r97160 1 1 /* $Id$ */ 2 2 /** @file 3 * SoftFloat - VBox Extension - extF80_sin, extF80_cos, extF80_sincos .3 * SoftFloat - VBox Extension - extF80_sin, extF80_cos, extF80_sincos, extF80_atan2. 4 4 */ 5 5 … … 86 86 } 87 87 88 static float128_t cordic_atan2( float128_t y, float128_t x SOFTFLOAT_STATE_DECL_COMMA ) 89 { 90 float128_t v1 = { { 0, 0 } }; /* MSC thinks it can be used uninitialized */ 91 float128_t v2 = { { 0, 0 } }; /* MSC thinks it can be used uninitialized */ 92 /** @todo TBD: CORDIC kernel should be easily implemented in assembly * */ 93 94 float128_t x1 = x, x2 = y; 95 float128_t z = ui32_to_f128(0, pState); 96 float128_t zero = ui32_to_f128(0, pState); 97 float128_t p2m = ui32_to_f128(1, pState); 98 float128_t two = ui32_to_f128(2, pState); 99 100 for (unsigned k = 0; k < RT_ELEMENTS(g_ar128FsincosCORDICConsts); k++) 101 { 102 float128_t atg = *(float128_t *)&g_ar128FsincosCORDICConsts[k]; 103 float128_t scale = *(float128_t *)&g_ar128FsincosCORDICConsts2[k]; 104 105 float128_t px1 = f128_mul(x1, p2m, pState); 106 float128_t px2 = f128_mul(x2, p2m, pState); 107 108 if (f128_le(x2, zero, pState)) 109 { 110 x1 = f128_sub(x1, px2, pState); 111 x2 = f128_add(x2, px1, pState); 112 z = f128_sub(z, atg, pState); 113 } 114 else 115 { 116 x1 = f128_add(x1, px2, pState); 117 x2 = f128_sub(x2, px1, pState); 118 z = f128_add(z, atg, pState); 119 } 120 121 p2m = f128_div(p2m, two, pState); 122 123 v1 = f128_mul(x1, scale, pState); 124 v2 = f128_mul(x2, scale, pState); 125 } 126 127 return z; 128 } 129 88 130 extFloat80_t extF80_sin( extFloat80_t x SOFTFLOAT_STATE_DECL_COMMA ) 89 131 { … … 242 284 *pSin = f128_to_extF80(vSin, pState); 243 285 } 286 287 extFloat80_t extF80_atan2( extFloat80_t f80y, extFloat80_t f80x SOFTFLOAT_STATE_DECL_COMMA ) 288 { 289 float128_t v; 290 int32_t fSignX = 0, fSignY = 0; 291 float128_t f128zero = ui32_to_f128(0, pState); 292 float128_t y = extF80_to_f128(f80y, pState); 293 float128_t x = extF80_to_f128(f80x, pState); 294 295 if (f128_le(x, f128zero, pState)) 296 { 297 x = f128_sub(f128zero, x, pState); 298 fSignX = 1; 299 } 300 301 if (f128_le(y, f128zero, pState)) 302 { 303 y = f128_sub(f128zero, y, pState); 304 fSignY = 1; 305 } 306 307 v = cordic_atan2(y, x, pState); 308 309 if (fSignX) 310 { 311 if (fSignY) 312 v = f128_sub(v, *(float128_t const *)&g_r128pi, pState); 313 else 314 v = f128_sub(*(float128_t const *)&g_r128pi, v, pState); 315 } 316 else 317 { 318 if (fSignY) 319 v = f128_sub(f128zero, v, pState); 320 } 321 322 return f128_to_extF80(v, pState); 323 } -
trunk/src/libs/softfloat-3e/source/extF80_sincos.h
r96665 r97160 31 31 # pragma once 32 32 #endif 33 34 /** The pi constant as 128-bit floating point value. 35 * base-10: 3.14159265358979323846264338327950279 36 * base-16: 3.243f6a8885a308d313198a2e0370 37 * base-2 : 1.1001001000011111101101010100010001000010110100011000010001101001100010011000110011000101000101110000000110111000e1 */ 38 const RTFLOAT128U g_r128pi = RTFLOAT128U_INIT_C(0, 0x921fb54442d1, 0x8469898cc51701b8, 0x4000); 33 39 34 40 /** The pi/2 constant as 128-bit floating point value. -
trunk/src/libs/softfloat-3e/source/include/softfloat.h
r96893 r97160 303 303 extFloat80_t extF80_cos( extFloat80_t SOFTFLOAT_STATE_DECL_COMMA ); 304 304 void extF80_sincos( extFloat80_t, extFloat80_t*, extFloat80_t* SOFTFLOAT_STATE_DECL_COMMA ); 305 extFloat80_t extF80_atan2( extFloat80_t y, extFloat80_t x SOFTFLOAT_STATE_DECL_COMMA ); 305 306 extFloat80_t extF80_ylog2x( extFloat80_t, extFloat80_t SOFTFLOAT_STATE_DECL_COMMA ); 306 307 extFloat80_t extF80_ylog2xp1( extFloat80_t, extFloat80_t SOFTFLOAT_STATE_DECL_COMMA );
Note:
See TracChangeset
for help on using the changeset viewer.