Commit 213f2395 authored by Julian Kranz's avatar Julian Kranz
Browse files

Liveness

parent ae62feee
......@@ -252,6 +252,7 @@ __obj __consume8 (__obj s) {
__RECORD_ADD(___1,v);
__RECORD_ADD(___2,ss);
__RECORD_END(a,2);
//printf("index: %lu\n", idx + 1);
return (a);
}
......@@ -273,6 +274,7 @@ __obj __unconsume8 (__obj s) {
__RECORD_ADD(___1,__UNIT);
__RECORD_ADD(___2,ss);
__RECORD_END(a,2);
//printf("index: %lu\n", idx - 1);
return (a);
}
......@@ -302,6 +304,7 @@ __obj __consume16 (__obj s) {
__RECORD_ADD(___1,v);
__RECORD_ADD(___2,ss);
__RECORD_END(a,2);
//printf("index: %lu\n", idx + 2);
return (a);
}
......@@ -323,6 +326,7 @@ __obj __unconsume16 (__obj s) {
__RECORD_ADD(___1,__UNIT);
__RECORD_ADD(___2,ss);
__RECORD_END(a,2);
//printf("index: %lu\n", idx - 2);
return (a);
}
......@@ -354,6 +358,7 @@ __obj __consume32 (__obj s) {
__RECORD_ADD(___1,v);
__RECORD_ADD(___2,ss);
__RECORD_END(a,2);
//printf("index: %lu\n", idx + 4);
return (a);
}
......@@ -375,6 +380,7 @@ __obj __unconsume32 (__obj s) {
__RECORD_ADD(___1,__UNIT);
__RECORD_ADD(___2,ss);
__RECORD_END(a,2);
//printf("index: %lu\n", idx - 4);
return (a);
}
......
val print o = update@{nothing=(println o)}
......@@ -13,8 +13,6 @@ export =
# lvstate-pretty
# lv-sweep-and-collect-upto-native-flow
val print o = update@{nothing=(println o)}
val lv-kill kills stmt =
let
val visit-semvar kills sz x = fmap-add-range kills x.id sz x.offset
......@@ -225,7 +223,8 @@ val lv-analyze initial-live stack =
val sweep stack state =
case stack of
SEM_NIL: return state
| SEM_CONS x: do print x.hd;
| SEM_CONS x:
# do print x.hd;
case x.hd of
# SEM_LABEL y:
# do lv-update-state y.label state;
......@@ -309,12 +308,8 @@ val lv-analyze initial-live stack =
lv-push-maybelive ite-conservative;
lv-push-live-only ite-greedy;
print "peter";
state-new <- return (lvstate-union then-state else-state);
print "hallo";
#sweep x.tl state-new
sweep x.tl (lv-eval-simple state-new x.hd)
end
......@@ -355,7 +350,7 @@ val lv-analyze initial-live stack =
in
cont (lv-kill1 x.hd) (lvstate-eval state x.hd)
end
end end
end# end
end
in do
# lv-sweep-and-collect-upto-native-flow;
......
......@@ -134,16 +134,17 @@ int main(int argc, char** argv) {
fclose(f);
//printf("size_max: %lu, buffer_length: %lu\n", size_max, buffer_length);
if(size_max && buffer_length > size_max)
buffer_length = size_max;
if(buffer_length == buffer_size) {
buffer_size++;
buffer = (unsigned char*)realloc(buffer, buffer_size);
}
buffer[buffer_length++] = 0xc3; //Last instruction should be a jump (ret) ;-).
if(buffer_length > size_max)
buffer_length = size_max;
size_t lines = 0;
size_t lines_greedy = 0;
......@@ -165,6 +166,10 @@ int main(int argc, char** argv) {
puts(fmt);
printf("\n");
for(size_t i = 0; fmt[i]; i++)
if(fmt[i] == '\n')
lines++;
__obj greedy_state = __runMonadicOneArg(__liveness__, &state,
rreil_instructions);
if(!__isNil(greedy_state)) {
......@@ -183,10 +188,6 @@ int main(int argc, char** argv) {
puts(fmt);
printf("\n");
for(size_t i = 0; fmt[i]; i++)
if(fmt[i] == '\n')
lines++;
printf("RREIL instructions after LV (greedy):\n");
__pretty(__rreil_pretty__, rreil_instructions_greedy, fmt, size);
puts(fmt);
......@@ -195,10 +196,11 @@ int main(int argc, char** argv) {
for(size_t i = 0; fmt[i]; i++)
if(fmt[i] == '\n')
lines_greedy++;
__resetHeap();
consumed += __getBlobIndex(state);
printf("consumed: %lu\n", consumed);
//printf("consumed: %lu, buffer_length: %lu\n", consumed, buffer_length);
}
printf("Statistics:\n");
......
......@@ -2357,26 +2357,30 @@ val moffs64 = do
end
val exception-rep arg = do
v <- query $rep;
case v of '0': arg end
# v <- query $rep;
# case v of '0': arg end
arg
end
val exception-repne arg = do
v <- query $repne;
case v of '0': arg end
# v <- query $repne;
# case v of '0': arg end
arg
end
val exception-lock arg = do
v <- query $lock;
case v of '0': arg end
# v <- query $lock;
# case v of '0': arg end
arg
end
val exception-lock-reg giveOp = do
v <- query $lock;
if v then do
op <- giveOp;
case op of MEM x: return op end
end else giveOp
# v <- query $lock;
# if v then do
# op <- giveOp;
# case op of MEM x: return op end
# end else giveOp
giveOp
end
val exception-rep-repne arg = exception-rep (exception-repne arg)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment