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
7088053c
Commit
7088053c
authored
Nov 30, 2014
by
Christoph Mallon
Browse files
ir: Cleanup and correct comments of smaller_mode().
parent
8a165c89
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/libfirm/irmode.h
View file @
7088053c
...
...
@@ -291,7 +291,7 @@ FIRM_API int mode_is_data (const ir_mode *mode);
* Returns true if a value of mode @p sm can be converted to mode @p lm without
* loss.
*
* That is the interpretation of the numbers does not changes, so
you
a signed
* That is the interpretation of the numbers does not changes, so a signed
* integer mode is never smaller than an unsigned integer mode since the
* unsigned mode can't represent negative numbers in a way that they are
* interpreted as negative numbers.
...
...
@@ -304,7 +304,7 @@ FIRM_API int smaller_mode(const ir_mode *sm, const ir_mode *lm);
* Returns true if no information is lost when converting a value of mode @p sm
* into mode @p lm (and back to mode @p sm).
*
* So the interpretation of the values may change in the intermediate mode @p
s
m
* So the interpretation of the values may change in the intermediate mode @p
l
m
* (for example when converting negative signed integer numbers into unsigned
* integers) but after a conversion back they are exactly the same value.
*
...
...
ir/ir/irmode.c
View file @
7088053c
...
...
@@ -356,24 +356,18 @@ int smaller_mode(const ir_mode *sm, const ir_mode *lm)
assert
(
get_mode_arithmetic
(
sm
)
==
irma_twos_complement
);
/* integers are convertable if
* - both have the same sign and lm is the larger one
* - lm is the signed one and is at least two bits larger
* (one for the sign, one for the highest bit of sm)
* - sm & lm are two_complement and lm has greater or equal
* number of bits
*/
* - both have the same sign and lm is the larger one
* - lm is signed and is at least one bit larger (the sign) */
unsigned
sm_bits
=
get_mode_size_bits
(
sm
);
unsigned
lm_bits
=
get_mode_size_bits
(
lm
);
if
(
mode_is_signed
(
sm
))
{
if
(
!
mode_is_signed
(
lm
))
return
0
;
return
sm_bits
<=
lm_bits
;
return
false
;
}
else
{
if
(
mode_is_signed
(
lm
))
{
if
(
mode_is_signed
(
lm
))
return
sm_bits
<
lm_bits
;
}
return
sm_bits
<=
lm_bits
;
}
return
sm_bits
<=
lm_bits
;
case
irms_auxiliary
:
case
irms_data
:
...
...
Write
Preview
Markdown
is supported
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