]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/VEX/priv/guest_generic_x87.h
dc6b066e561c39be2f4c64c404f54436e7ebc943
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / VEX / priv / guest_generic_x87.h
1
2 /*---------------------------------------------------------------*/
3 /*--- begin                               guest_generic_x87.h ---*/
4 /*---------------------------------------------------------------*/
5
6 /*
7    This file is part of Valgrind, a dynamic binary instrumentation
8    framework.
9
10    Copyright (C) 2004-2010 OpenWorks LLP
11       info@open-works.net
12
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.
17
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.
22
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
26    02110-1301, USA.
27
28    The GNU General Public License is contained in the file COPYING.
29
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.
34 */
35
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
41    copy thereof.
42 */
43
44 #ifndef __VEX_GUEST_GENERIC_X87_H
45 #define __VEX_GUEST_GENERIC_X87_H
46
47 #include "libvex_basictypes.h"
48
49
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:
54
55    * Identity of NaNs is not preserved.
56
57    See comments in the code for more details.
58 */
59 extern
60 void convert_f64le_to_f80le ( /*IN*/UChar* f64, /*OUT*/UChar* f80 );
61
62
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:
67
68    * Rounding following truncation could be a bit better.
69
70    * Identity of NaNs is not preserved.
71
72    See comments in the code for more details.
73 */
74 extern
75 void convert_f80le_to_f64le ( /*IN*/UChar* f80, /*OUT*/UChar* f64 );
76
77
78 /* Layout of the real x87 state. */
79 typedef
80    struct {
81       UShort env[14];
82       UChar  reg[80];
83    }
84    Fpu_State;
85
86 /* Offsets, in 16-bit ints, into the FPU environment (env) area. */
87 #define FP_ENV_CTRL   0
88 #define FP_ENV_STAT   2
89 #define FP_ENV_TAG    4
90 #define FP_ENV_IP     6 /* and 7 */
91 #define FP_ENV_CS     8
92 #define FP_ENV_OPOFF  10 /* and 11 */
93 #define FP_ENV_OPSEL  12
94 #define FP_REG(ii)    (10*(7-(ii)))
95
96
97 /* Do the computations for x86/amd64 FXTRACT */
98 extern ULong x86amd64g_calculate_FXTRACT ( ULong arg, HWord getExp );
99
100
101
102 #endif /* ndef __VEX_GUEST_GENERIC_X87_H */
103
104 /*---------------------------------------------------------------*/
105 /*--- end                                 guest_generic_x87.h ---*/
106 /*---------------------------------------------------------------*/