Commit 5c531820 authored by Julian Kranz's avatar Julian Kranz

X86 RREIL Translator

- Started to implement the use of sub scopes
parent 545c8ebe
......@@ -119,20 +119,27 @@ val temp_id x =
end
val mktemp = do
#t <- query $tmp;
#t' <- return (t + 1);
#update @{tmp=t'};
#return {id=VIRT_T t,offset=0}
l <- query $tmp;
t' <- return (
case l of
TLIST_CONS x: _var (VIRT_T ((temp_id x.hd.id) + 1))
| TLIST_NIL: _var (VIRT_T 0)
end
);
l' <- return (TLIST_CONS {hd=t', tl=l});
update @{tmp=l'};
return t'
#t <- query $tmp;
#t' <- return (t + 1);
#update @{tmp=t'};
#return {id=VIRT_T t,offset=0}
l <- query $tmp;
t' <- return (
case l of
TLIST_CONS x: _var (VIRT_T ((temp_id x.hd.id) + 1))
| TLIST_NIL: _var (VIRT_T 0)
end
);
l' <- return (TLIST_CONS {hd=t', tl=l});
update @{tmp=l'};
return t'
end
val with-subscope m = do
l <- query $tmp;
ret <- m;
update @{tmp=l};
return ret
end
val mklabel = do
......
......@@ -201,7 +201,7 @@ main:
#pblendw $42, %xmm1, %xmm2
#vpblendw $42, %xmm1, %xmm2, %xmm3
#pclmulqdq $1, %xmm1, %xmm2
pclmulqdq $1, %xmm1, %xmm2
#vpclmulqdq $0, %xmm1, %xmm2, %xmm3
#pclmulqdq $17, %xmm1, %xmm2
#vpclmulqdq $16, %xmm1, %xmm2, %xmm3
......
......@@ -359,12 +359,12 @@ val fLTU = return (_var VIRT_LTU)
val zero = return (SEM_LIN_IMM{imm=0})
val _if c _then a _else b = do
c <- c;
c <- with-subscope c;
stack <- pop-all;
a;
with-subscope a;
t <- pop-all;
t <- return (rreil-stmts-rev t);
b;
with-subscope b;
e <- pop-all;
e <- return (rreil-stmts-rev e);
stack-set stack;
......@@ -375,6 +375,26 @@ val _if c _then a = do
_if c _then a _else (return void)
end
val _while c __ b = let
val eval-cond ct = do
cc <- c;
mov 1 ct cc
end
in do
ct <- mktemp;
with-subscope (eval-cond ct);
stack <- pop-all;
with-subscope b;
with-subscope (eval-cond ct);
body <- pop-all;
body <- return (rreil-stmts-rev body);
stack-set stack;
while (var ct) body
end end
val /d cond = return cond
val /and a b = do
......@@ -450,22 +470,6 @@ val /leu sz a b = do
return (var t)
end
val _while c __ b = do
cc <- c;
ct <- mktemp;
mov 1 ct cc;
stack <- pop-all;
b;
cc <- c;
mov 1 ct cc;
body <- pop-all;
body <- return (rreil-stmts-rev body);
stack-set stack;
while (var ct) body
end
val sem-a sem-cc x = do
cf <- fCF;
zf <- fZF;
......@@ -865,7 +869,7 @@ val vector-apply size element-size monad = do
let
val f i = do
monad i;
with-subscope (monad i);
if (i < (limit - 1)) then
f (i + 1)
......
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