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
360daec7
Commit
360daec7
authored
Jun 06, 2013
by
Matthias Braun
Browse files
add tarval_to_uint64(), tarval_is_uint64()
parent
af6fbbfe
Changes
4
Hide whitespace changes
Inline
Side-by-side
ir/tv/strcalc.c
View file @
360daec7
...
...
@@ -664,6 +664,14 @@ long sc_val_to_long(const void *val)
return
l
;
}
uint64_t
sc_val_to_uint64
(
const
void
*
val
)
{
uint64_t
res
=
0
;
for
(
int
i
=
calc_buffer_size
-
1
;
i
>=
0
;
i
--
)
{
res
=
(
res
<<
4
)
+
_val
(((
char
*
)
val
)[
i
]);
}
}
void
sc_min_from_bits
(
unsigned
int
num_bits
,
unsigned
int
sign
,
void
*
buffer
)
{
if
(
buffer
==
NULL
)
buffer
=
calc_buffer
;
...
...
ir/tv/strcalc.h
View file @
360daec7
...
...
@@ -19,6 +19,7 @@
#ifndef FIRM_TV_STRCALC_H
#define FIRM_TV_STRCALC_H
#include
<stdint.h>
#include
"irmode.h"
#ifdef STRCALC_DEBUG_ALL
/* switch on all debug options */
...
...
@@ -191,6 +192,7 @@ void sc_val_from_ulong(unsigned long l, void *buffer);
/** converts a value to a long */
long
sc_val_to_long
(
const
void
*
val
);
uint64_t
sc_val_to_uint64
(
const
void
*
val
);
void
sc_min_from_bits
(
unsigned
int
num_bits
,
unsigned
int
sign
,
void
*
buffer
);
void
sc_max_from_bits
(
unsigned
int
num_bits
,
unsigned
int
sign
,
void
*
buffer
);
...
...
ir/tv/tv.c
View file @
360daec7
...
...
@@ -393,11 +393,32 @@ int tarval_is_long(ir_tarval *tv)
long
get_tarval_long
(
ir_tarval
*
tv
)
{
assert
(
tarval_is_long
(
tv
)
&&
"tarval too big to fit in long"
);
assert
(
tarval_is_long
(
tv
));
return
sc_val_to_long
(
tv
->
value
);
}
bool
tarval_is_uint64
(
ir_tarval
*
tv
)
{
if
(
!
mode_is_int
(
tv
->
mode
)
&&
!
mode_is_reference
(
tv
->
mode
))
return
false
;
if
(
get_mode_size_bits
(
tv
->
mode
)
>
(
int
)
(
sizeof
(
uint64_t
)
<<
3
))
{
/* the value might be too big to fit in a long */
sc_max_from_bits
(
sizeof
(
uint64_t
)
<<
3
,
0
,
NULL
);
if
(
sc_comp
(
sc_get_buffer
(),
tv
->
value
)
==
ir_relation_less
)
{
/* really doesn't fit */
return
false
;
}
}
return
true
;
}
uint64_t
get_tarval_uint64
(
ir_tarval
*
tv
)
{
assert
(
tarval_is_uint64
(
tv
));
return
sc_val_to_uint64
(
tv
->
value
);
}
ir_tarval
*
new_tarval_from_long_double
(
long
double
d
,
ir_mode
*
mode
)
{
const
float_descriptor_t
*
desc
;
...
...
ir/tv/tv_t.h
View file @
360daec7
...
...
@@ -16,6 +16,8 @@
#include
"firm_common.h"
#include
"irmode.h"
#include
"tv.h"
#include
<stdint.h>
#include
<stdbool.h>
#define get_tarval_mode(tv) _get_tarval_mode(tv)
#define get_tarval_bad() _get_tarval_bad()
...
...
@@ -114,4 +116,8 @@ static inline int _is_tarval(const void *thing)
return
get_kind
(
thing
)
==
k_tarval
;
}
uint64_t
get_tarval_uint64
(
ir_tarval
*
tv
);
bool
tarval_is_uint64
(
ir_tarval
*
tv
);
#endif
/* FIRM_TV_TV_T_H */
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