fixed the type of the entity number
[libfirm] / ir / tv / IeeeCC754 / include / DriverFloatRepr.h
1 /*
2 ##########################################################################
3 #                                                                        #
4 # Program: IeeeCC754                                                     #
5 #                                                                        #
6 # Description:                                                           #
7 #   IeeeCC754 or IEEE 754 Compliance Checker is a precision and range    #
8 #   independent tool to test whether an implementation of                #
9 #   floating-point arithmetic (in hardware or software) is compliant     #
10 #   with the principles of the IEEE 754-854 floating-point standards.    #
11 #   You can find out more about the testing tool IeeeCC754 at            #
12 #                                                                        #
13 #         http:/* win-www.uia.ac.be/u/cant/ieeecc754.html                 # */
14 #                                                                        #
15 #   This tool is in parts based on and greatly benefited from the        #
16 #   the program FPTEST developed by Jerome Coonen. For a full            #
17 #   description of the extensions to FPTEST and a reference to           #
18 #   the original Coonen program, please refer to the URL given above.    #
19 #   For the options available with the program IeeeCC754 and its         #
20 #   compatibility with David Hough's hexadecimal UCB format, we          #
21 #   also refer to the file readme.usage.                                 #
22 #                                                                        #
23 #  Usage: see readme.usage                                               #
24 #                                                                        #
25 #  Responsible authors:                                                  #
26 #         Brigitte Verdonk                                               #
27 #         Annie Cuyt                                                     #
28 #                                                                        #
29 #  Contributors:                                                         #
30 #         Johan Bogo (1998-1999)                                         #
31 #         Tim Gevers (10-12/2000)                                        #
32 #         Debby Ooms (1996-1997)                                         #
33 #         Geert Vermuyten (1996-1997)                                    #
34 #         Dennis Verschaeren (09/1996-06/2000)                           #
35 #                                                                        #
36 #  Copyright (C) 2000  University of Antwerp                             #
37 #                                                                        #
38 #  This program can be obtained from the authors, free, but WITHOUT ANY  #
39 #  WARRANTY; without even the implied warranty of MERCHANTABILITY or     #
40 #  FITNESS FOR A PARTICULAR PURPOSE.                                     #
41 #                                                                        #
42 #  Contact:                                                              #
43 #       Brigitte.Verdonk@uia.ua.ac.be                                    #
44 #       Department of Mathematics and Computer Science                   #
45 #       University of Antwerp (UIA)                                      #
46 #       Universiteitsplein 1                                             #
47 #       B2610 Antwerp, BELGIUM                                           #
48 #                                                                        #
49 ##########################################################################
50
51 Filename:
52        $RCSfile$
53
54 Last updated:
55        $Date$
56
57 */
58
59
60 /*  MORE INFORMATION ON THE FUNCTIONS IN  THIS HEADER FILE CAN BE FOUND  */
61 /*  ON THE WEBPAGE */
62 /*           http://win-www.uia.ac.be/u/cant/ieeecc754.html */
63 /*   ``Adapt IeeeCC754 to test your floating-point implementation'' */
64
65 /*  ---- */
66 /*  Includes */
67 /*  ---- */
68
69 #include <Fp.h>
70 #include <Bitstring.h>
71
72 /*  ---- */
73 /*  Includes and Defines specificly for  testing MpIeee */
74 /*  ---- */
75 #ifdef MPIEEE_TEST
76 #include <MpIeee.hh>
77 #endif
78
79 /*  ---- */
80 /*  Includes and Defines specificly for testing FMLib */
81 /*  ---- */
82 #ifdef FMLIB_TEST
83 #include <Sdefs.h>
84 #endif
85
86 /*  ---- */
87 /*  CLASS DEFINITION : DriverFloatRepr */
88 /*  ---- */
89
90
91 class DriverFloatRepr: public FP
92 {
93 protected:
94
95 void SetLibRound( );
96 /*  call the appropriate functions to set the rounding mode */
97 /*  on the target platform - see item (a) on webpage */
98
99 void SetLibEnvironment( );
100 /*  call the appropriate functions to clear all floating-point */
101 /*  exceptions on the target platform - see item (b) on webpage */
102
103 void GetLibExceptions( );
104 /*  call the appropriate functions to read out exceptions generated */
105 /*  by the target platform - see item (b) on webpage */
106
107 public:
108
109 #ifndef FMLIB_TEST
110 /*  For testing FMLib we use other definitions */
111 /*  -- */
112 DriverFloatRepr::DriverFloatRepr( ) :FP( )
113   {}
114
115 DriverFloatRepr::DriverFloatRepr( int m,int e,int h ) :FP( m,e,h )
116   {}
117
118 DriverFloatRepr::DriverFloatRepr( Bitstring  &fp,int m,int e,int h ) :FP( fp,m,e,h )
119   {}
120   ;
121 #endif
122
123 /*  If your target implementation is implemented in hardware, */
124 /*  provide an implementation of the functions listed below for */
125 /*  conversion between your hardware data types and DriverFloatRepr  */
126 /*  see item (c) on webpage and */
127 /*       ftp://win-ftp.uia.ac.be/pub/cant/IeeeCC754/converting.pdf */
128
129 DriverFloatRepr( float f );
130 DriverFloatRepr( double d );
131 DriverFloatRepr( long double l );
132 float tofloat( );
133 double todouble( );
134 long double tolongdouble( );
135
136
137 /*  If your target implementation is implemented in software, */
138 /*  provide an implementation of the functions listed below for */
139 /*  conversion between your floating-point datatype and */
140 // DriverFloatRepr (don't forget to replace MyDatatype by the
141 /*  appropriate identifier in this declaration) - see item (c) on */
142 /*  webpage and */
143 /*       ftp://win-ftp.uia.ac.be/pub/cant/IeeeCC754/converting.pdf */
144
145 DriverFloatRepr (void *val);
146 void* to(void *val);
147
148
149
150 /*  */
151 /*  Here is an example to test the multiprecision floating-point */
152 /*  implementation MpIeee: */
153
154 #ifdef MPIEEE_TEST
155 /*  Functions that Convert MpIeee to DriverFloatRepr and vice-versa */
156 /* -- */
157
158 DriverFloatRepr ( const MpIeee &M );
159 MpIeee to( );
160
161 #endif
162
163 #ifdef FMLIB_TEST
164 /*  Functions specifically for Testing FMLib */
165 /*  -- */
166
167 DriverFloatRepr::DriverFloatRepr( );
168 DriverFloatRepr::DriverFloatRepr( int m,int e,int h );
169 DriverFloatRepr::DriverFloatRepr( Bitstring  &fp,int m,int e,int h );
170 DriverFloatRepr::DriverFloatRepr( DriverFloatRepr& );
171 void DriverFloatRepr::fromDriverFloatRepr( Bitstring& m,Bitstring& e,int h );
172 void DriverFloatRepr::toDriverFloatRepr( Bitstring m,Bitstring e,int h, int signf );
173 FmNumber value;
174 long Length;
175 char* byteToStr( long );
176 void Reverse( Bitstring& );
177 void SetOperations( );
178
179 #endif
180
181 /*  provide implementaton of the functions listed below in the file */
182 /*       BasicOperations/$PLATFORM/BasicOperationstest.cc */
183 /*  see item (d) on webpage */
184 /*  -- */
185
186 DriverFloatRepr operator + ( DriverFloatRepr &T );
187 DriverFloatRepr operator - ( DriverFloatRepr &T );
188 DriverFloatRepr operator * ( DriverFloatRepr &T );
189 DriverFloatRepr operator / ( DriverFloatRepr &T );
190 DriverFloatRepr operator % ( DriverFloatRepr &T );
191 DriverFloatRepr sqrt( );
192
193 /*  provide implementation of the functions listed below in the file */
194 /*       Conversions/$PLATFORM/Conversionstest.cc */
195 /*  see item (d) on webpage */
196 /*  -- */
197
198 DriverFloatRepr roundto ( int, int, int );
199 DriverFloatRepr copyto ( int, int, int );
200 DriverFloatRepr rint ( );
201 DriverFloatRepr ri ( ) ;
202 DriverFloatRepr ru ( ) ;
203 DriverFloatRepr rI ( ) ;
204 DriverFloatRepr rU ( ) ;
205 DriverFloatRepr ci ( int, int, int );
206 DriverFloatRepr cu ( int, int, int );
207 DriverFloatRepr cI ( int, int, int );
208 DriverFloatRepr cU ( int, int, int );
209 DriverFloatRepr b2d ( int );
210 DriverFloatRepr d2b ( );
211
212 /*  conversions between DriverFloatRepr and hardware integer */
213 /*  data types; implementation is provided in the files */
214 /*     BasicOperations/$PLATFORM/fpenv_$PLATFORM.cc */
215 /*  and */
216 /*     Conversions/$PLATFORM/fpenv_$PLATFORM.cc */
217 /*  and should not be modified */
218 /*  -- */
219
220 DriverFloatRepr( long i );
221 DriverFloatRepr( unsigned long i );
222 DriverFloatRepr( long long int i );
223 DriverFloatRepr( unsigned long long int i );
224 int toint( );
225 unsigned int touint( );
226 long long int tolonglong( );
227 unsigned long long int toulonglong( );
228
229 };