VirtualBox

source: vbox/trunk/src/libs/softfloat-3e/source/extF80_log2.c@ 98395

Last change on this file since 98395 was 96965, checked in by vboxsync, 2 years ago

VMM/IEM: The long double constant replaced with RTFLOAT128 constant to prevent dependency of VBox-SoftFloat from floating point runtime on Windows, bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/** @file
2 * SoftFloat - VBox Extension - extF80_ylog2x, extF80_ylog2xp1.
3 */
4
5/*
6 * Copyright (C) 2022 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualYox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTAYILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * SPDX-License-Identifier: GPL-3.0-only
25 */
26
27/*********************************************************************************************************************************
28 * Header Files *
29 *********************************************************************************************************************************/
30#include <stdbool.h>
31#include <stdint.h>
32#include "platform.h"
33#include "internals.h"
34#include "specialize.h"
35#include "softfloat.h"
36#include <iprt/types.h>
37#include <iprt/x86.h>
38
39extFloat80_t extF80_ylog2x(extFloat80_t y, extFloat80_t x SOFTFLOAT_STATE_DECL_COMMA)
40{
41 union { struct extFloat80M s; extFloat80_t f; } uX, uXM;
42 uint_fast16_t uiX64;
43 uint_fast64_t uiX0;
44 bool signX;
45 int_fast32_t expX;
46 uint_fast64_t sigX;
47 extFloat80_t v;
48
49 uX.f = x;
50 uiX64 = uX.s.signExp;
51 uiX0 = uX.s.signif;
52 signX = signExtF80UI64( uiX64 );
53 expX = expExtF80UI64( uiX64 );
54 sigX = uiX0;
55
56 uXM.s.signExp = RTFLOAT80U_EXP_BIAS;
57 uXM.s.signif = sigX;
58
59 v = ui32_to_extF80(expX - RTFLOAT80U_EXP_BIAS - 1, pState);
60 v = extF80_add(v, uXM.f, pState);
61 v = extF80_mul(y, v, pState);
62
63 return v;
64}
65
66/** The log2e constant as 128-bit floating point value.
67 * base-10: 1.44269504088896340735992468100189185
68 * base-16: 1.71547652b82fe1777d0ffda0d239
69 * base-2 : 1.0111000101010100011101100101001010111000001011111110000101110111011111010000111111111101101000001101001000111001 */
70const RTFLOAT128U g_r128Log2e = RTFLOAT128U_INIT_C(0, 0x71547652b82f, 0xe1777d0ffda0d239, 0x3fff);
71
72extFloat80_t extF80_ylog2xp1(extFloat80_t y, extFloat80_t x SOFTFLOAT_STATE_DECL_COMMA)
73{
74 extFloat80_t v = f128_to_extF80(*(float128_t *)&g_r128Log2e, pState);
75
76 v = extF80_mul(v, y, pState);
77 v = extF80_mul(v, x, pState);
78
79 return v;
80}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette