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
6d4b5329
Commit
6d4b5329
authored
Feb 25, 2016
by
Christoph Mallon
Browse files
tv: Add get_tarval_magnitude().
parent
fa7eb6ee
Changes
2
Show whitespace changes
Inline
Side-by-side
ir/tv/tv.c
View file @
6d4b5329
...
...
@@ -1229,6 +1229,23 @@ int get_tarval_highest_bit(ir_tarval const *tv)
return
-
1
;
}
unsigned
get_tarval_magnitude
(
ir_tarval
const
*
tv
)
{
assert
(
get_mode_arithmetic
(
tv
->
mode
)
==
irma_twos_complement
);
unsigned
const
size
=
get_mode_size_bits
(
tv
->
mode
);
unsigned
const
neg
=
tarval_get_bit
(
tv
,
size
-
1
);
unsigned
const
ext
=
neg
?
(
1U
<<
SC_BITS
)
-
1
:
0
;
unsigned
l
=
get_mode_size_bytes
(
tv
->
mode
);
for
(
unsigned
i
=
l
;
i
--
!=
0
;)
{
unsigned
char
const
v
=
get_tarval_sub_bits
(
tv
,
i
);
if
(
v
!=
ext
)
return
i
*
SC_BITS
+
(
32
-
nlz
(
v
^
ext
))
+
1
;
}
return
1
;
}
int
tarval_zero_mantissa
(
ir_tarval
const
*
tv
)
{
assert
(
get_mode_arithmetic
(
tv
->
mode
)
==
irma_ieee754
...
...
ir/tv/tv_t.h
View file @
6d4b5329
...
...
@@ -135,6 +135,11 @@ ir_tarval *get_tarval_small(ir_mode *mode);
ir_tarval
*
get_tarval_epsilon
(
ir_mode
*
mode
);
/**
* Get the number of bits required to reconstruct this tarval by sign extension.
*/
unsigned
get_tarval_magnitude
(
ir_tarval
const
*
tv
);
/**
* Get the @p idx'th bit of the internal representation of the given tarval
* @p tv.
...
...
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