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
8fb3ce50
Commit
8fb3ce50
authored
Sep 12, 2006
by
Michael Beck
Browse files
decimal output is now always unsigned for unsigned tarvals
[r8217]
parent
bccc4cbb
Changes
4
Hide whitespace changes
Inline
Side-by-side
ir/tv/fltcalc.c
View file @
8fb3ce50
...
...
@@ -1528,7 +1528,7 @@ char *fc_print(const void *a, char *buf, int buflen, unsigned base)
case
FC_PACKED
:
default:
snprintf
(
buf
,
buflen
,
"%s"
,
sc_print
(
_pack
(
val
,
mul_1
),
value_size
*
4
,
SC_HEX
));
snprintf
(
buf
,
buflen
,
"%s"
,
sc_print
(
_pack
(
val
,
mul_1
),
value_size
*
4
,
SC_HEX
,
0
));
buf
[
buflen
-
1
]
=
'\0'
;
break
;
}
...
...
ir/tv/strcalc.c
View file @
8fb3ce50
...
...
@@ -45,10 +45,10 @@
#define fail_char(a, b, c, d) _fail_char((a), (b), (c), (d), __FILE__, __LINE__)
/* shortcut output for debugging */
# define sc_print_hex(a) sc_print((a), 0, SC_HEX)
# define sc_print_dec(a) sc_print((a), 0, SC_DEC)
# define sc_print_oct(a) sc_print((a), 0, SC_OCT)
# define sc_print_bin(a) sc_print((a), 0, SC_BIN)
# define sc_print_hex(a) sc_print((a), 0, SC_HEX
, 0
)
# define sc_print_dec(a) sc_print((a), 0, SC_DEC
, 1
)
# define sc_print_oct(a) sc_print((a), 0, SC_OCT
, 0
)
# define sc_print_bin(a) sc_print((a), 0, SC_BIN
, 0
)
#ifdef STRCALC_DEBUG_PRINTCOMP
# define DEBUGPRINTF_COMPUTATION(x) printf x
...
...
@@ -1444,7 +1444,7 @@ unsigned char sc_sub_bits(const void *value, int len, unsigned byte_ofs)
* convert to a string
* FIXME: Doesn't check buffer bounds
*/
const
char
*
sc_print
(
const
void
*
value
,
unsigned
bits
,
enum
base_t
base
)
const
char
*
sc_print
(
const
void
*
value
,
unsigned
bits
,
enum
base_t
base
,
int
signed_mode
)
{
static
const
char
big_digits
[]
=
"0123456789ABCDEF"
;
static
const
char
small_digits
[]
=
"0123456789abcdef"
;
...
...
@@ -1462,7 +1462,7 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base)
base_val
=
alloca
(
calc_buffer_size
);
div1_res
=
alloca
(
calc_buffer_size
);
div2_res
=
alloca
(
calc_buffer_size
);
rem_res
=
alloca
(
calc_buffer_size
);
rem_res
=
alloca
(
calc_buffer_size
);
pos
=
output_buffer
+
bit_pattern_size
;
*
(
--
pos
)
=
'\0'
;
...
...
@@ -1539,7 +1539,7 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base)
p
=
val
;
sign
=
0
;
if
(
base
==
SC_DEC
)
{
if
(
signed_mode
&&
base
==
SC_DEC
)
{
/* check for negative values */
if
(
_bit
(
val
,
bits
-
1
))
{
_negate
(
val
,
div2_res
);
...
...
ir/tv/strcalc.h
View file @
8fb3ce50
...
...
@@ -150,11 +150,12 @@ unsigned char sc_sub_bits(const void *value, int len, unsigned byte_ofs);
/**
* Converts a tarval into a string.
*
* @param val1 the value pointer
* @param bits number of valid bits in this value
* @param base output base
* @param val1 the value pointer
* @param bits number of valid bits in this value
* @param base output base
* @param signed_mode print it signed (only decimal mode supported
*/
const
char
*
sc_print
(
const
void
*
val1
,
unsigned
bits
,
enum
base_t
base
);
const
char
*
sc_print
(
const
void
*
val1
,
unsigned
bits
,
enum
base_t
base
,
int
signed_mode
);
/** Initialize the strcalc module.
* Sets up internal data structures and constants
...
...
ir/tv/tv.c
View file @
8fb3ce50
...
...
@@ -923,7 +923,7 @@ tarval *tarval_convert_to(tarval *src, ir_mode *m)
/* decimal string representation because hexadecimal output is
* interpreted unsigned by fc_val_from_str, so this is a HACK */
snprintf
(
buffer
,
100
,
"%s"
,
sc_print
(
src
->
value
,
get_mode_size_bits
(
src
->
mode
),
SC_DEC
));
sc_print
(
src
->
value
,
get_mode_size_bits
(
src
->
mode
),
SC_DEC
,
mode_is_signed
(
src
->
mode
)
));
buffer
[
100
-
1
]
=
'\0'
;
switch
(
get_mode_size_bits
(
m
))
{
...
...
@@ -1485,17 +1485,17 @@ int tarval_snprintf(char *buf, size_t len, tarval *tv)
switch
(
mode_info
->
mode_output
)
{
case
TVO_DECIMAL
:
str
=
sc_print
(
tv
->
value
,
get_mode_size_bits
(
tv
->
mode
),
SC_DEC
);
str
=
sc_print
(
tv
->
value
,
get_mode_size_bits
(
tv
->
mode
),
SC_DEC
,
mode_is_signed
(
tv
->
mode
)
);
break
;
case
TVO_OCTAL
:
str
=
sc_print
(
tv
->
value
,
get_mode_size_bits
(
tv
->
mode
),
SC_OCT
);
str
=
sc_print
(
tv
->
value
,
get_mode_size_bits
(
tv
->
mode
),
SC_OCT
,
0
);
break
;
case
TVO_HEX
:
case
TVO_NATIVE
:
default:
str
=
sc_print
(
tv
->
value
,
get_mode_size_bits
(
tv
->
mode
),
SC_HEX
);
str
=
sc_print
(
tv
->
value
,
get_mode_size_bits
(
tv
->
mode
),
SC_HEX
,
0
);
break
;
}
return
snprintf
(
buf
,
len
,
"%s%s%s"
,
prefix
,
str
,
suffix
);
...
...
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