Commit f2ec411f authored by Julian Kranz's avatar Julian Kranz

X86 RREIL Translator

- Added semantics of: SHLD
parent d9cf590a
......@@ -126,6 +126,15 @@ __obj __zx (__obj x) {
return (y);
}
/* FIXME */
__obj __ipget (__obj x) {
__LOCAL0(y);
__INT_BEGIN(y);
__INT_INIT(42);
__INT_END(y);
return (y);
}
__obj __concat (__obj A, __obj B) {
__word a = A->bv.vec;
__word b = B->bv.vec;
......
......@@ -41,6 +41,9 @@ structure Primitives = struct
val stateK' = newFlow stateK
val stateL = freshVar ()
val stateL' = newFlow stateL
(*val stateI = freshVar ()
val stateI' = newFlow stateI*)
val a = freshVar ()
val a = freshVar ()
val a' = newFlow a
val b = freshVar ()
......@@ -118,11 +121,14 @@ structure Primitives = struct
flow = BD.meetVarImpliesVar (bvar stateC', bvar stateC)},
{name="raise", ty=MONAD (freshVar (),stateD, stateD'),
flow = noFlow},
(*{name="ipget", ty=MONAD (ZENO, stateI, stateI'),
flow = BD.meetVarImpliesVar (bvar stateI', bvar stateI)},*)
{name="%raise", ty=UNIT, flow = noFlow},
{name="%and", ty=UNIT, flow = noFlow},
{name="%or", ty=UNIT, flow = noFlow},
{name="%sx", ty=UNIT, flow = noFlow},
{name="%zx", ty=UNIT, flow = noFlow},
(* {name="%ipget", ty=UNIT, flow = noFlow},*)
{name="%addi", ty=UNIT, flow = noFlow},
{name="%subi", ty=UNIT, flow = noFlow},
{name="%eqi", ty=UNIT, flow = noFlow},
......@@ -206,6 +212,8 @@ structure Primitives = struct
flow = BD.meetVarZero (bvar s12)},
{name="zx", ty=func (VEC s13, ZENO),
flow = BD.meetVarZero (bvar s13)},
(* {name="ipget", ty=FUN([ZENO], ZENO),
flow = noFlow},*)
{name="prefix", ty=func (VEC s14, VEC s15),
flow = BD.meetVarZero (bvar s14) o
BD.meetVarZero (bvar s15) o
......@@ -231,6 +239,7 @@ structure Primitives = struct
flow = BD.meetVarImpliesVar (bvar stateK', bvar stateK)},
{name="%slice", ty=MONAD (freshVar (),stateL, stateL'),
flow = BD.meetVarImpliesVar (bvar stateL', bvar stateL)},
(*{name="%ipget", ty=UNIT, flow = noFlow},*)
{name="vcase", ty=FUN ([VEC inp, content',
FUN ([content'', VEC out], content''')], content''''),
flow = BD.meetVarImpliesVar (bvar content'''', bvar content') o
......
......@@ -464,9 +464,13 @@ main:
#rcr %cl, %rax
#rcr $1, %eax
and $12, %al
and (%rax), %rax
and %ebx, %ecx
#and $12, %al
#and (%rax), %rax
#and %ebx, %ecx
shld $42, %ax, %bx
shld $99, %ecx, %edx
shld %cl, %rax, %rbx
#vmovd %xmm5, %ebx
......
......@@ -2420,6 +2420,51 @@ val sem-setcc x cond = do
write dst-sz dst (var temp)
end
val sem-shld x = do
size <- sizeof1 x.opnd1;
dst <- lval size x.opnd1;
src1 <- read size x.opnd1;
src2 <- read size x.opnd2;
count <- read size x.opnd3;
mask <- return (
if size === 64 then
0x3f
else
0x1f
);
temp-count <- mktemp;
andb size temp-count count (imm mask);
cf <- fCF;
ov <- fOF;
sf <- fSF;
zf <- fZF;
af <- fAF;
pf <- fPF;
temp-dst <- mktemp;
_if (/gtu size (var temp-count) (imm size)) _then do
undef 1 cf;
undef 1 ov;
undef 1 sf;
undef 1 zf;
undef 1 af;
undef 1 pf
end _else do
shl size temp-dst src1 (var temp-count);
temp <- mktemp;
sub size temp (imm size) (var temp-count);
shr size temp src2 (var temp);
orb size temp-dst (var temp-dst) (var temp)
end;
write size dst (var temp-dst)
end
val sem-stc = do
cf <- fCF;
mov 1 cf (imm 1)
......
......@@ -12,6 +12,7 @@ val runtime-stack-address-size = do
end
val ip-get = do
#k <- ipget;
return (imm 0)
end
......@@ -1539,7 +1540,7 @@ val semantics insn =
| SFENCE x: sem-undef-arity0 x
| SGDT x: sem-undef-arity1 x
| SHL x: sem-sal-shl x
| SHLD x: sem-undef-arity3 x
| SHLD x: sem-shld x
| SHR x: sem-shr-sar x '0'
| SHRD x: sem-undef-arity3 x
| SHUFPD x: sem-undef-arity3 x
......
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