projects
/
libfirm
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6a6ae77
)
Implemented get_tarval_bitpattern()
author
Sebastian Hack
<hack@ipd.info.uni-karlsruhe.de>
Mon, 4 Oct 2004 12:05:23 +0000
(12:05 +0000)
committer
Sebastian Hack
<hack@ipd.info.uni-karlsruhe.de>
Mon, 4 Oct 2004 12:05:23 +0000
(12:05 +0000)
[r4027]
ir/tv/tv.c
patch
|
blob
|
history
diff --git
a/ir/tv/tv.c
b/ir/tv/tv.c
index
80af061
..
d348ce2
100644
(file)
--- a/
ir/tv/tv.c
+++ b/
ir/tv/tv.c
@@
-1479,7
+1479,22
@@
int tarval_printf(tarval *tv) {
char *get_tarval_bitpattern(tarval *tv)
{
- return NULL;
+ int i, j, pos = 0;
+ int n = get_mode_size_bits(tv->mode);
+ int bytes = n / 8 + ((n & 7) != 0);
+ char *res = malloc((n + 1) * sizeof(char));
+ unsigned char byte;
+
+ for(i = 0; i < bytes; i++) {
+ byte = get_tarval_sub_bits(tv, i);
+ for(j = 1; j < 256; j <<= 1)
+ if(pos < n)
+ res[pos++] = j & byte ? '1' : '0';
+ }
+
+ res[n] = '\0';
+
+ return res;
}
/*