Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
a6700260
Commit
a6700260
authored
Oct 24, 2011
by
Matthias Braun
Browse files
remove old+broken ieee754 tests
parent
b7bf9774
Changes
16
Hide whitespace changes
Inline
Side-by-side
ir/tv/IeeeCC754/BasicOp/fltcalc/BasicOptest.cc
deleted
100644 → 0
View file @
b7bf9774
/*
##########################################################################
# #
# Program: IeeeCC754 #
# #
# Description: #
# IeeeCC754 or IEEE 754 Compliance Checker is a precision and range #
# independent tool to test whether an implementation of #
# floating-point arithmetic (in hardware or software) is compliant #
# with the principles of the IEEE 754-854 floating-point standards. #
# You can find out more about the testing tool IeeeCC754 at #
# #
# http://win-www.uia.ac.be/u/cant/ieeecc754.html #
# #
# This tool is in parts based on and greatly benefited from the #
# the program FPTEST developed by Jerome Coonen. For a full #
# description of the extensions to FPTEST and a reference to #
# the original Coonen program, please refer to the URL given above. #
# For the options available with the program IeeeCC754 and its #
# compatibility with David Hough's hexadecimal UCB format, we #
# also refer to the file readme.usage. #
# #
# Usage: see readme.usage #
# #
# Responsible authors: #
# Brigitte Verdonk #
# Annie Cuyt #
# #
# Contributors: #
# Johan Bogo (1998-1999) #
# Tim Gevers (10-12/2000) #
# Debby Ooms (1996-1997) #
# Geert Vermuyten (1996-1997) #
# Dennis Verschaeren (09/1996-06/2000) #
# #
# Copyright (C) 2000 University of Antwerp #
# #
# This program can be obtained from the authors, free, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. #
# #
# Contact: #
# Brigitte.Verdonk@uia.ua.ac.be #
# Department of Mathematics and Computer Science #
# University of Antwerp (UIA) #
# Universiteitsplein 1 #
# B2610 Antwerp, BELGIUM #
# #
##########################################################################
Filename:
$RCSfile$
Last updated:
$Date$
*/
#include <math.h>
#include <DriverFloatRepr.h>
extern
"C"
{
#include <fltcalc.h>
}
DriverFloatRepr
DriverFloatRepr
::
operator
+
(
DriverFloatRepr
&
fl
)
{
void
*
res
=
alloca
(
::
fc_get_buffer_length
());
void
*
op1
=
alloca
(
::
fc_get_buffer_length
());
void
*
op2
=
alloca
(
::
fc_get_buffer_length
());
to
(
op1
);
fl
.
to
(
op2
);
SetLibRound
();
// cout << "op1 : " << endl << op1 << endl << flush;
// cout << "op2 : " << endl << op2 << endl << flush;
GetLibExceptions
();
::
fc_add
(
op1
,
op2
,
res
);
// cout << "res: " << res << endl << flush; // debug
GetLibExceptions
();
DriverFloatRepr
r
(
res
);
return
r
;
}
DriverFloatRepr
DriverFloatRepr
::
operator
-
(
DriverFloatRepr
&
fl
)
{
void
*
res
=
alloca
(
::
fc_get_buffer_length
());
void
*
op1
=
alloca
(
::
fc_get_buffer_length
());
void
*
op2
=
alloca
(
::
fc_get_buffer_length
());
to
(
op1
);
fl
.
to
(
op2
);
SetLibRound
();
// cout << "op1 : " << endl << op1 << endl << flush;
// cout << "op2 : " << endl << op2 << endl << flush;
::
fc_sub
(
op1
,
op2
,
res
);
// cout << "res: " << res << endl << flush; // debug
GetLibExceptions
();
DriverFloatRepr
r
(
res
);
return
r
;
}
DriverFloatRepr
DriverFloatRepr
::
operator
*
(
DriverFloatRepr
&
fl
)
{
void
*
res
=
alloca
(
::
fc_get_buffer_length
());
void
*
op1
=
alloca
(
::
fc_get_buffer_length
());
void
*
op2
=
alloca
(
::
fc_get_buffer_length
());
to
(
op1
);
fl
.
to
(
op2
);
SetLibRound
();
// cout << "op1 : " << endl << op1 << endl << flush;
// cout << "op2 : " << endl << op2 << endl << flush;
::
fc_mul
(
op1
,
op2
,
res
);
// cout << "res: " << res << endl << flush; // debug
GetLibExceptions
();
DriverFloatRepr
r
(
res
);
return
r
;
}
DriverFloatRepr
DriverFloatRepr
::
operator
/
(
DriverFloatRepr
&
fl
)
{
void
*
res
=
alloca
(
::
fc_get_buffer_length
());
void
*
op1
=
alloca
(
::
fc_get_buffer_length
());
void
*
op2
=
alloca
(
::
fc_get_buffer_length
());
to
(
op1
);
fl
.
to
(
op2
);
SetLibRound
();
// cout << "op1 : " << endl << op1 << endl << flush;
// cout << "op2 : " << endl << op2 << endl << flush;
::
fc_div
(
op1
,
op2
,
res
);
// cout << "res: " << res << endl << flush; // debug
GetLibExceptions
();
DriverFloatRepr
r
(
res
);
// DriverFloatRepr r(op1); // debug
return
r
;
}
DriverFloatRepr
DriverFloatRepr
::
operator
%
(
DriverFloatRepr
&
fl
)
{
DriverFloatRepr
r
(
0l
);
return
r
;
}
DriverFloatRepr
DriverFloatRepr
::
sqrt
()
{
DriverFloatRepr
r
(
0l
);
return
r
;
}
ir/tv/IeeeCC754/BasicOp/fltcalc/fpenv_fltcalc.cc
deleted
100644 → 0
View file @
b7bf9774
/*
##########################################################################
# #
# Program: IeeeCC754 #
# #
# Description: #
# IeeeCC754 or IEEE 754 Compliance Checker is a precision and range #
# independent tool to test whether an implementation of #
# floating-point arithmetic (in hardware or software) is compliant #
# with the principles of the IEEE 754-854 floating-point standards. #
# You can find out more about the testing tool IeeeCC754 at #
# #
# http://win-www.uia.ac.be/u/cant/ieeecc754.html #
# #
# This tool is in parts based on and greatly benefited from the #
# the program FPTEST developed by Jerome Coonen. For a full #
# description of the extensions to FPTEST and a reference to #
# the original Coonen program, please refer to the URL given above. #
# For the options available with the program IeeeCC754 and its #
# compatibility with David Hough's hexadecimal UCB format, we #
# also refer to the file readme.usage. #
# #
# Usage: see readme.usage #
# #
# Responsible authors: #
# Brigitte Verdonk #
# Annie Cuyt #
# #
# Contributors: #
# Johan Bogo (1998-1999) #
# Tim Gevers (10-12/2000) #
# Debby Ooms (1996-1997) #
# Geert Vermuyten (1996-1997) #
# Dennis Verschaeren (09/1996-06/2000) #
# #
# Copyright (C) 2000 University of Antwerp #
# #
# This program can be obtained from the authors, free, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. #
# #
# Contact: #
# Brigitte.Verdonk@uia.ua.ac.be #
# Department of Mathematics and Computer Science #
# University of Antwerp (UIA) #
# Universiteitsplein 1 #
# B2610 Antwerp, BELGIUM #
# #
##########################################################################
Filename:
$RCSfile$
Last updated:
$Date$
*/
#include <math.h>
#include <DriverFloatRepr.h>
extern
"C"
{
#include <fltcalc.h>
}
#ifndef DOUBLE
#define DOUBLE
#endif
/*
By default, all functions in this file are declared in the header file
DriverFloatRepr.h
except for two functions
DriverFloatRepr::DriverFloatRepr(<MyDatatype &D>)
<MyDatatype> DriverFloatRepr::to()
These two functions, for conversion between the floating-point
data type of your target implementation and DriverFloatRepr, the
floating-point data type of the driver program, should be declared
explicitly in the header file DriverFloatRepr.h, with MyDatatype
replaced by the appropriate identifier. */
void
DriverFloatRepr
::
SetLibRound
()
{
/* Make your library calls for changing the rounding mode */
switch
(
GetFPRound
())
{
case
RM_NEAR
:
// change rounding mode to round to nearest break;
fc_set_rounding_mode
(
FC_TONEAREST
);
break
;
case
RM_ZERO
:
// change rounding mode to round to zero break;
fc_set_rounding_mode
(
FC_TOZERO
);
break
;
case
RM_UP
:
// change rounding mode to round up break;
fc_set_rounding_mode
(
FC_TOPOSITIVE
);
break
;
case
RM_DOWN
:
// change rounding mode to round down break;
fc_set_rounding_mode
(
FC_TONEGATIVE
);
break
;
}
}
void
DriverFloatRepr
::
SetLibEnvironment
()
{
// clear all floating-point exceptions
}
void
DriverFloatRepr
::
GetLibExceptions
()
{
// do nothing, exceptions are unsupported
}
DriverFloatRepr
::
DriverFloatRepr
(
void
*
val
)
{
// convert your floating-point data type to the floating-point
// representation of the driver program
// replace MyDatatype by the appropriate identifier
int
exponent
;
unsigned
int
mantissa0
;
unsigned
int
mantissa1
;
#ifdef DOUBLE
sizeExp
=
11
;
sizeMant
=
52
;
#else
sizeExp
=
8
;
sizeMant
=
23
;
#endif
mant
=
Bitstring
(
sizeMant
);
exp
=
Bitstring
(
sizeExp
);
if
(
fc_is_negative
(
val
))
sign
=
1
;
else
sign
=
0
;
#ifdef DOUBLE
// convert exponent
exponent
=
((
int
)(
fc_sub_bits
(
val
,
64
,
7
)
&
0x7F
))
<<
4
;
exponent
|=
((
fc_sub_bits
(
NULL
,
64
,
6
)
&
0xF0
)
>>
4
);
for
(
int
i
=
sizeExp
-
1
;
i
>=
0
;
i
--
)
{
exp
.
PutBit
(
i
,
exponent
%
2
);
exponent
/=
2
;
}
// convert mantissa
mantissa0
=
((
int
)(
fc_sub_bits
(
NULL
,
64
,
6
)
&
0x0F
))
<<
16
;
mantissa0
|=
((
int
)
fc_sub_bits
(
NULL
,
64
,
5
))
<<
8
;
mantissa0
|=
(
int
)
fc_sub_bits
(
NULL
,
64
,
4
);
mantissa1
=
((
int
)
fc_sub_bits
(
NULL
,
64
,
3
))
<<
24
;
mantissa1
|=
((
int
)
fc_sub_bits
(
NULL
,
64
,
2
))
<<
16
;
mantissa1
|=
((
int
)
fc_sub_bits
(
NULL
,
64
,
1
))
<<
8
;
mantissa1
|=
((
int
)
fc_sub_bits
(
NULL
,
64
,
0
));
for
(
int
i
=
19
;
i
>=
0
;
i
--
)
{
mant
.
PutBit
(
i
,
mantissa0
%
2
);
mantissa0
/=
2
;
}
for
(
int
i
=
31
;
i
>=
0
;
i
--
)
{
mant
.
PutBit
(
20
+
i
,
mantissa1
%
2
);
mantissa1
/=
2
;
}
#else
// convert exponent
exponent
=
((
int
)(
fc_sub_bits
(
val
,
32
,
3
)
&
0x7F
))
<<
1
;
exponent
|=
((
fc_sub_bits
(
NULL
,
32
,
2
)
&
0x80
)
>>
7
);
for
(
int
i
=
sizeExp
-
1
;
i
>=
0
;
i
--
)
{
exp
.
PutBit
(
i
,
exponent
%
2
);
exponent
/=
2
;
}
// convert mantissa
mantissa0
=
((
int
)(
fc_sub_bits
(
NULL
,
32
,
2
)
&
0x7F
))
<<
16
;
mantissa0
|=
((
int
)
fc_sub_bits
(
NULL
,
32
,
1
))
<<
8
;
mantissa0
|=
(
int
)
fc_sub_bits
(
NULL
,
32
,
0
);
for
(
int
i
=
22
;
i
>=
0
;
i
--
)
{
mant
.
PutBit
(
i
,
mantissa0
%
2
);
mantissa0
/=
2
;
}
#endif
}
void
*
DriverFloatRepr
::
to
(
void
*
buf
)
// convert the the floating-point representation of the driver program
// to the floating-point data type of your implementation
{
unsigned
int
upper
=
0
;
unsigned
int
lower
=
0
;
#ifdef DOUBLE
double
im_val
;
#else
float
im_val
;
#endif
if
(
sign
!=
0
)
{
upper
|=
0x80000000
;
}
for
(
int
i
=
0
;
i
<
sizeExp
;
i
++
)
{
if
(
exp
.
GetBit
(
i
)
==
1
)
upper
|=
1
<<
(
30
-
i
);
}
#ifdef DOUBLE
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
if
(
mant
.
GetBit
(
i
)
==
1
)
upper
|=
1
<<
(
19
-
i
);
}
for
(
int
i
=
20
;
i
<
sizeMant
;
i
++
)
{
if
(
mant
.
GetBit
(
i
)
==
1
)
lower
|=
1
<<
(
51
-
i
);
}
if
(
Endian
==
MYLITTLE_ENDIAN
)
{
((
unsigned
int
*
)
&
im_val
)[
0
]
=
lower
;
((
unsigned
int
*
)
&
im_val
)[
1
]
=
upper
;
}
else
{
((
unsigned
int
*
)
&
im_val
)[
1
]
=
lower
;
((
unsigned
int
*
)
&
im_val
)[
0
]
=
upper
;
}
fc_val_from_float
(
im_val
,
11
,
52
,
(
char
*
)
buf
);
#else
for
(
int
i
=
0
;
i
<
sizeMant
;
i
++
)
{
if
(
mant
.
GetBit
(
i
)
==
1
)
upper
|=
1
<<
(
22
-
i
);
}
*
((
unsigned
int
*
)
&
im_val
)
=
upper
;
fc_val_from_float
(
im_val
,
8
,
23
,
(
char
*
)
buf
);
#endif
return
buf
;
}
// conversions between DriverFloatRepr and hardware integer
// data types; implementation should not be modified !
DriverFloatRepr
::
DriverFloatRepr
(
long
i
)
{
Bitstring
temp
(
32
);
hidden
=
0
;
sizeMant
=
32
;
sizeExp
=
0
;
temp
[
0
]
=
(
unsigned
long
)
i
;
temp
.
SubBitstring
(
0
,
mant
);
}
DriverFloatRepr
::
DriverFloatRepr
(
unsigned
long
i
)
{
Bitstring
temp
(
32
);
hidden
=
0
;
sizeMant
=
32
;
sizeExp
=
0
;
temp
[
0
]
=
(
unsigned
long
)
i
;
temp
.
SubBitstring
(
0
,
mant
);
}
DriverFloatRepr
::
DriverFloatRepr
(
long
long
i
)
{
unsigned
long
*
tmparray
=
new
unsigned
long
[
2
];
tmparray
=
(
unsigned
long
*
)
&
i
;
Bitstring
temp
(
64
);
if
(
Endian
==
MYLITTLE_ENDIAN
)
{
temp
[
0
]
=
tmparray
[
0
];
temp
[
1
]
=
tmparray
[
1
];
}
else
{
temp
[
0
]
=
tmparray
[
1
];
temp
[
1
]
=
tmparray
[
0
];
}
hidden
=
0
;
sizeMant
=
64
;
sizeExp
=
0
;
temp
.
SubBitstring
(
0
,
mant
);
}
DriverFloatRepr
::
DriverFloatRepr
(
unsigned
long
long
i
)
{
unsigned
long
*
tmparray
=
new
unsigned
long
[
2
];
tmparray
=
(
unsigned
long
*
)
&
i
;
Bitstring
temp
(
64
);
if
(
Endian
==
MYLITTLE_ENDIAN
)
{
temp
[
0
]
=
tmparray
[
0
];
temp
[
1
]
=
tmparray
[
1
];
}
else
{
temp
[
0
]
=
tmparray
[
1
];
temp
[
1
]
=
tmparray
[
0
];
}
hidden
=
0
;
sizeMant
=
64
;
sizeExp
=
0
;
temp
.
SubBitstring
(
0
,
mant
);
}
int
DriverFloatRepr
::
toint
()
{
return
(
int
&
)
mant
[
0
];
}
unsigned
int
DriverFloatRepr
::
touint
()
{
return
(
unsigned
int
&
)
mant
[
0
];
}
long
long
int
DriverFloatRepr
::
tolonglong
()
{
unsigned
long
tmparray
[
2
];
if
(
Endian
==
MYLITTLE_ENDIAN
)
{
tmparray
[
0
]
=
mant
[
0
];
tmparray
[
1
]
=
mant
[
1
];
}
else
{
tmparray
[
0
]
=
mant
[
1
];
tmparray
[
1
]
=
mant
[
0
];
}
return
(
long
long
int
&
)
*
tmparray
;
}
unsigned
long
long
int
DriverFloatRepr
::
toulonglong
()
{
unsigned
long
tmparray
[
2
];
if
(
Endian
==
MYLITTLE_ENDIAN
)
{
tmparray
[
0
]
=
mant
[
0
];
tmparray
[
1
]
=
mant
[
1
];
}
else
{
tmparray
[
0
]
=
mant
[
1
];
tmparray
[
1
]
=
mant
[
0
];
}
return
(
unsigned
long
long
int
&
)
*
tmparray
;
}
ir/tv/IeeeCC754/BasicOp/testsets/add
deleted
100644 → 0
View file @
b7bf9774
!! This file contains precision and range independent test vectors for
!! the operation addition/subtraction (+). The first character in each
!! test vector refers to the origin of the test vector
!!
!! 2: Jerome Coonen Version <2>
!! 3: Jerome Coonen Version <3>
!! @Phdthesis{
!! author = {Coonen, J.T.},
!! title = {Contributions to a proposed standard for binary
!! floating-point arithmetic},
!! school = {University of California, Berkeley},
!! year = {1984}}
!!
!! H: precision independent encoding of UCB/<H>ough test vector
!! @Unpublished{
!! author = {David G. Hough and others},
!! title = {{UCBTEST}, a suite of programs for testing certain
!! difficult cases of {IEEE} 754 floating-point arithmetic},
!! year = {1988},
!! note = {Restricted public domain software from
!! http://netlib.bell-labs.com/netlib/fp/index.html}}
!!
!! A: Verdonk-Cuyt-Verschaeren (University of <A>ntwerp)
!! @Article{
!! author = {Verdonk, B. and Cuyt, A. and Verschaeren, D.},
!! title = {A precision- and range-independent tool for testing
!! floating-point arithmetic {I}: basic operations,
!! square root and remainder},
!! journal = {ACM TOMS},
!! volume = {27},
!! number = {1},
!! pages = {92-118},
!! year = {2001}}
!! note = {Under revision}}
!!
!! This file is part of the tool IeeeCC754 or IEEE 754 Compliance Checker.
!! It is a precision and range independent tool to test whether
!! an implementation of floating-point arithmetic (in hardware or
!! software) is compliant with the principles of the IEEE 754-854
!! floating-point standards. You can find out more about the testing
!! tool IeeeCC754 and the syntax and semantics of the test vectors
!! at
!! http://win-www.uia.ac.be/u/cant/ieeecc754.html
!!
!! Last updated:
!! $Date$
!!
!! Contact:
!! Brigitte.Verdonk@ua.ac.be
!! Department of Mathematics and Computer Science
!! University of Antwerp (UIA)
!! Universiteitsplein 1
!! B2610 Antwerp, BELGIUM
!!!! first some easy cases
2+ ALL 1 1 OK 2
!! c0a00000 00000000 c0a00000 00000000 c0b00000 00000000
H+ ALL -1 -1 OK -2
2+ ALL 1 2 OK 3
!! c0a00000 00000000 c0b00000 00000000 c0b80000 00000000
H+ ALL -1 -2 OK -3
2+ ALL 2 2 OK 4
2+ ALL 1 7 OK 8
A+ ALL -1 -7 OK -8
2+ ALL 5 -1 OK 4
A+ ALL -5 1 OK -4
2+ ALL 2 -5 OK -3
A+ ALL -2 5 OK 3
!! 40a00000 00000000 c0b00000 00000000 c0a00000 00000000
H+ ALL 2 -4 OK -2
!! 40b00000 00000000 c0a00000 00000000 40a00000 00000000
H+ ALL 4 -2 OK 2
!! c0a00000 00000000 40b00000 00000000 40a00000 00000000
!! c0b00000 00000000 40a00000 00000000 c0a00000 00000000
!! Special representations
! Zero vs Zero -- watch signs and rounding modes.
2+ =0> 0 -0 OK 0
2+ < 0 -0 OK -0
2+ ALL 0 0 OK 0
2+ ALL -0 -0 OK -0
!! Zero vs denormalized
2+ ALL 0 Td1 OK Td1
2+ ALL -0 Td1 OK Td1
2+ ALL 0 -Td1 OK -Td1
2+ ALL -0 -Td1 OK -Td1
2+ ALL 0i3 0 OK 0i3
2+ ALL 0i3 -0 OK 0i3
2+ ALL -0i3 0 OK -0i3
2+ ALL -0i3 -0 OK -0i3
!! Zero vs normal -- watch that sign of 0 is meaningless
2+ ALL -0 -T OK -T
2+ ALL T 0 OK T
2+ ALL 0 -T OK -T
2+ ALL 0 Hm1 OK Hm1
2+ ALL -0 Hm1 OK Hm1
2+ ALL -Hm1 0 OK -Hm1
2+ ALL -Hm1 -0 OK -Hm1
2+ ALL 1 -0 OK 1
2+ ALL -1 -0 OK -1
2+ ALL 0 1 OK 1
2+ ALL 5 -0 OK 5
2+ ALL 5 +0 OK 5
! Infinity vs 0.
2+ ALL H 0 OK H
2+ ALL H -0 OK H