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
2fc3fe45
Commit
2fc3fe45
authored
Sep 09, 2008
by
Michael Beck
Browse files
tarval_ieee754_get_mantissa_size() implemented
[r21772]
parent
4d808298
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/libfirm/tv.h
View file @
2fc3fe45
...
...
@@ -788,6 +788,12 @@ unsigned tarval_ieee754_set_immediate_precision(unsigned bits);
*/
unsigned
tarval_ieee754_get_exact
(
void
);
/**
* Return the size of the mantissa in bits (including possible
* implicit bits) for the given mode.
*/
unsigned
tarval_ieee754_get_mantissa_size
(
const
ir_mode
*
mode
);
/**
* Enable/Disable floating point constant folding.
*/
...
...
ir/ir/iropt.c
View file @
2fc3fe45
...
...
@@ -1262,14 +1262,8 @@ restart:
if
(
mode_is_int
(
n_mode
)
&&
mode_is_float
(
a_mode
))
{
/* ConvI(ConvF(I)) -> I, iff float mantissa >= int mode */
size_t
int_mantissa
=
get_mode_size_bits
(
n_mode
)
-
(
mode_is_signed
(
n_mode
)
?
1
:
0
);
size_t
float_mantissa
;
/* FIXME There is no way to get the mantissa size of a mode */
switch
(
get_mode_size_bits
(
a_mode
))
{
case
32
:
float_mantissa
=
23
+
1
;
break
;
// + 1 for implicit 1
case
64
:
float_mantissa
=
52
+
1
;
break
;
case
80
:
float_mantissa
=
64
;
break
;
default:
float_mantissa
=
0
;
break
;
}
size_t
float_mantissa
=
tarval_ieee754_get_mantissa_size
(
a_mode
);
if
(
float_mantissa
>=
int_mantissa
)
{
n
=
b
;
DBG_OPT_ALGSIM1
(
oldn
,
a
,
b
,
n
,
FS_OPT_CONV
);
...
...
ir/tv/tv.c
View file @
2fc3fe45
...
...
@@ -176,17 +176,17 @@ static int cmp_tv(const void *p1, const void *p2, size_t n) {
assert
(
tv1
->
kind
==
k_tarval
);
assert
(
tv2
->
kind
==
k_tarval
);
if
(
tv1
->
mode
<
tv2
->
mode
)
if
(
tv1
->
mode
<
tv2
->
mode
)
return
-
1
;
if
(
tv1
->
mode
>
tv2
->
mode
)
if
(
tv1
->
mode
>
tv2
->
mode
)
return
1
;
if
(
tv1
->
length
<
tv2
->
length
)
if
(
tv1
->
length
<
tv2
->
length
)
return
-
1
;
if
(
tv1
->
length
>
tv2
->
length
)
if
(
tv1
->
length
>
tv2
->
length
)
return
1
;
if
(
tv1
->
value
<
tv2
->
value
)
if
(
tv1
->
value
<
tv2
->
value
)
return
-
1
;
if
(
tv1
->
value
>
tv2
->
value
)
if
(
tv1
->
value
>
tv2
->
value
)
return
1
;
return
0
;
...
...
@@ -1696,6 +1696,17 @@ unsigned tarval_ieee754_get_exact(void) {
return
fc_is_exact
();
}
/* Return the size of the mantissa in bits (including possible
implicit bits) for the given mode. */
unsigned
tarval_ieee754_get_mantissa_size
(
const
ir_mode
*
mode
)
{
const
ieee_descriptor_t
*
desc
;
assert
(
get_mode_arithmetic
(
mode
)
==
irma_ieee754
);
desc
=
get_descriptor
(
mode
);
return
desc
->
mantissa_size
+
desc
->
explicit_one
;
}
/* check if its the a floating point NaN */
int
tarval_is_NaN
(
tarval
*
tv
)
{
if
(
!
mode_is_float
(
tv
->
mode
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment