2 /*---------------------------------------------------------------*/
3 /*--- begin guest_generic_x87.h ---*/
4 /*---------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2004-2010 OpenWorks LLP
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 The GNU General Public License is contained in the file COPYING.
30 Neither the names of the U.S. Department of Energy nor the
31 University of California nor the names of its contributors may be
32 used to endorse or promote products derived from this software
33 without prior written permission.
36 /* This file contains functions for doing some x87-specific
37 operations. Both the amd64 and x86 front ends (guests) indirectly
38 call these functions via guest helper calls. By putting them here,
39 code duplication is avoided. Some of these functions are tricky
40 and hard to verify, so there is much to be said for only having one
44 #ifndef __VEX_GUEST_GENERIC_X87_H
45 #define __VEX_GUEST_GENERIC_X87_H
47 #include "libvex_basictypes.h"
50 /* Convert an IEEE754 double (64-bit) into an x87 extended double
51 (80-bit), mimicing the hardware fairly closely. Both numbers are
52 stored little-endian. Limitations, all of which could be fixed,
53 given some level of hassle:
55 * Identity of NaNs is not preserved.
57 See comments in the code for more details.
60 void convert_f64le_to_f80le ( /*IN*/UChar* f64, /*OUT*/UChar* f80 );
63 /* Convert an x87 extended double (80-bit) into an IEEE 754 double
64 (64-bit), mimicking the hardware fairly closely. Both numbers are
65 stored little-endian. Limitations, both of which could be fixed,
66 given some level of hassle:
68 * Rounding following truncation could be a bit better.
70 * Identity of NaNs is not preserved.
72 See comments in the code for more details.
75 void convert_f80le_to_f64le ( /*IN*/UChar* f80, /*OUT*/UChar* f64 );
78 /* Layout of the real x87 state. */
86 /* Offsets, in 16-bit ints, into the FPU environment (env) area. */
90 #define FP_ENV_IP 6 /* and 7 */
92 #define FP_ENV_OPOFF 10 /* and 11 */
93 #define FP_ENV_OPSEL 12
94 #define FP_REG(ii) (10*(7-(ii)))
97 /* Do the computations for x86/amd64 FXTRACT */
98 extern ULong x86amd64g_calculate_FXTRACT ( ULong arg, HWord getExp );
102 #endif /* ndef __VEX_GUEST_GENERIC_X87_H */
104 /*---------------------------------------------------------------*/
105 /*--- end guest_generic_x87.h ---*/
106 /*---------------------------------------------------------------*/