Commit 16da3c60 authored by Axel Simon's avatar Axel Simon

Merge branch 'experimental' of versioncontrolseidl.in.tum.de:jucs/gdsl-toolkit

parents 903db8f5 c0d44bb6
......@@ -202,3 +202,7 @@ tools/xed-cmp/build/
*~
*.swp
*.swo
*.o
*.la
*.lo
......@@ -50,6 +50,6 @@ class Frontend : IReferable {
}
unittest {
Frontend f = new Frontend("x86");
Frontend f = new Frontend("current");
clear(f);
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ class Gdsl : IReferable {
unittest {
for(uint i = 0; i < 10; i++) {
Frontend f = new Frontend("x86");
Frontend f = new Frontend("current");
Gdsl gdsl = new Gdsl(f);
}
import core.memory;
......
......@@ -23,23 +23,25 @@ struct _generic {
};
struct _decoder {
int_t function (state_t) config_default;
obj_t function (state_t) decoder_config;
int_t function (state_t, obj_t) has_conf;
obj_t function (state_t, obj_t) conf_next;
string_t function (state_t, obj_t) conf_short;
string_t function (state_t, obj_t) conf_long;
int_t function (state_t, obj_t) conf_data;
obj_t function (state_t, int_t) decode;
int_t function (state_t, obj_t) insn_length;
int_t function (state_t, obj_t) operands;
obj_t function (state_t, obj_t) generalize;
obj_t function (state_t, obj_t) asm_convert_insn;
obj_t* function (state_t, obj_t) pretty;
obj_t* function (state_t, obj_t, int_t) pretty_operand;
obj_t* function (state_t, obj_t) pretty_mnemonic;
int_t function (state_t, obj_t, int) typeof_opnd;
}
struct _translator {
obj_t function (state_t, obj_t) translate;
obj_t* function (state_t, obj_t) pretty;
obj_t* function (state_t, obj_t) pretty_arch_id;
obj_t* function (state_t, obj_t) pretty_arch_exception;
void function (state_t, obj_t) rreil_cif_userdata_set;
obj_t function (state_t) rreil_cif_userdata_get;
obj_t function (state_t, callbacks_t, obj_t) rreil_convert_sem_stmts;
obj_t function (state_t, int_t, int_t, int_t, obj_t, obj_t function (state_t, obj_t, obj_t)) decode_translate_block_optimized_int;
obj_t function (state_t, callbacks_t, obj_t) rreil_convert_sem_stmt_list;
opt_result_t function (state_t, int_t, int_t, int_t, obj_t,
obj_t function (state_t, obj_t, obj_t)) decode_translate_block_optimized_insncb;
}
struct frontend {
......
......@@ -34,7 +34,6 @@ class Extension : Expression {
}
public override string toString() {
//return "[" ~ to!string(fromSize) ~ "->" ~ cast(string)_op ~ "]" ~ _opnd.toString();
return "[" ~ to!string(_fromSize) ~ "->" ~ cast(string)_op ~ "]" ~ _opnd.toString();
}
}
......
module gdsl.rreil.expr.sexpr;
import gdsl.rreil.expr.expr;
import sexpr = gdsl.rreil.sexpr.sexpr;
class Sexpr : Expression {
private sexpr.Sexpr _inner;
@property public sexpr.Sexpr inner() {
return _inner;
}
public this(sexpr.Sexpr inner) {
_inner = inner;
}
public override string toString() {
return _inner.toString();
}
}
unittest {
import gdsl.rreil.sexpr.arbitrary;
Sexpr s = new Sexpr(new Arbitrary());
assert(s.toString == "arbitrary");
}
\ No newline at end of file
module gdsl.rreil.expr_cmp;
class CompareExpression {
public abstract string toString();
}
\ No newline at end of file
module gdsl.rreil.sexpr.arbitrary;
import gdsl.rreil.sexpr.sexpr;
class Arbitrary : Sexpr {
public override string toString() {
return "arbitrary";
}
}
unittest {
Arbitrary a = new Arbitrary();
assert(a.toString == "arbitrary");
}
\ No newline at end of file
module gdsl.rreil.sexpr.expr_cmp;
import gdsl.rreil.sexpr.sexpr;
import expr_cmp = gdsl.rreil.expr_cmp.expr_cmp;
class CompareExpression : Sexpr {
private expr_cmp.CompareExpression _inner;
@property public expr_cmp.CompareExpression inner() {
return _inner;
}
public this(expr_cmp.CompareExpression inner) {
this._inner = inner;
}
public override string toString() {
return _inner.toString();
}
}
unittest {
import gdsl.rreil.linear.immediate;
Linear l = new Linear(new Immediate(99));
assert(l.toString() == "99");
}
\ No newline at end of file
module gdsl.rreil.sexpr.linear;
import gdsl.rreil.sexpr.sexpr;
import linear = gdsl.rreil.linear.linear;
class Linear : Sexpr {
private linear.Linear _inner;
@property public linear.Linear inner() {
return _inner;
}
public this(linear.Linear inner) {
this._inner = inner;
}
public override string toString() {
return _inner.toString();
}
}
unittest {
import gdsl.rreil.linear.immediate;
Linear l = new Linear(new Immediate(99));
assert(l.toString() == "99");
}
\ No newline at end of file
module gdsl.rreil.sexpr.sexpr;
class Sexpr {
public abstract override string toString();
}
\ No newline at end of file
This diff is collapsed.
export generalize : (insndata) -> asm-insn-flags
export generalize : (insndata) -> asm-insn
val generalize insn = let
val recordify mnemonic ua = {mnemonic=mnemonic, ua=ua}
......
......@@ -36,6 +36,41 @@ val arch-show-id r =
| Sem_SP: "sp"
| Sem_S8: "s8"
| Sem_RA: "ra"
| Sem_HI: "HI"
| Sem_LO: "LO"
| Sem_F0: "f0"
| Sem_F1: "f1"
| Sem_F2: "f2"
| Sem_F3: "f3"
| Sem_F4: "f4"
| Sem_F5: "f5"
| Sem_F6: "f6"
| Sem_F7: "f7"
| Sem_F8: "f8"
| Sem_F9: "f9"
| Sem_F10: "f10"
| Sem_F11: "f11"
| Sem_F12: "f12"
| Sem_F13: "f13"
| Sem_F14: "f14"
| Sem_F15: "f15"
| Sem_F16: "f16"
| Sem_F17: "f17"
| Sem_F18: "f18"
| Sem_F19: "f19"
| Sem_F20: "f20"
| Sem_F21: "f21"
| Sem_F22: "f22"
| Sem_F23: "f23"
| Sem_F24: "f24"
| Sem_F25: "f25"
| Sem_F26: "f26"
| Sem_F27: "f27"
| Sem_F28: "f28"
| Sem_F29: "f29"
| Sem_F30: "f30"
| Sem_F31: "f31"
| Sem_SREG: "SREG"
end
val pretty-arch-id r = arch-show-id r
......
type sem_id =
Sem_PC
| Sem_SREG
type sem_id =
Sem_ZERO
......@@ -34,6 +35,51 @@ type sem_id =
| Sem_SP
| Sem_S8
| Sem_RA
| Sem_HI
| Sem_LO
type sem_id =
Sem_F0
| Sem_F1
| Sem_F2
| Sem_F3
| Sem_F4
| Sem_F5
| Sem_F6
| Sem_F7
| Sem_F8
| Sem_F9
| Sem_F10
| Sem_F11
| Sem_F12
| Sem_F13
| Sem_F14
| Sem_F15
| Sem_F16
| Sem_F17
| Sem_F18
| Sem_F19
| Sem_F20
| Sem_F21
| Sem_F22
| Sem_F23
| Sem_F24
| Sem_F25
| Sem_F26
| Sem_F27
| Sem_F28
| Sem_F29
| Sem_F30
| Sem_F31
val fRE = sem-reg-offset (sreg-get) 25
val sem-reg-offset r o = @{offset=r.offset + o}r
val ip-get = {id=Sem_PC,offset=0,size=32}
val hi-get = {id=Sem_HI,offset=0,size=32}
val lo-get = {id=Sem_LO,offset=0,size=32}
val sreg-get = {id=Sem_SREG,offset=0,size=32}
val semantic-gpr-of r =
case r of
......@@ -70,3 +116,39 @@ val semantic-gpr-of r =
| S8 : {id=Sem_S8 ,offset=0,size=32}
| RA : {id=Sem_RA ,offset=0,size=32}
end
val semantic-fpr-of f =
case f of
F0 : {id=Sem_F0 ,offset=0,size=32}
| F1 : {id=Sem_F1 ,offset=0,size=32}
| F2 : {id=Sem_F2 ,offset=0,size=32}
| F3 : {id=Sem_F3 ,offset=0,size=32}
| F4 : {id=Sem_F4 ,offset=0,size=32}
| F5 : {id=Sem_F5 ,offset=0,size=32}
| F6 : {id=Sem_F6 ,offset=0,size=32}
| F7 : {id=Sem_F7 ,offset=0,size=32}
| F8 : {id=Sem_F8 ,offset=0,size=32}
| F9 : {id=Sem_F9 ,offset=0,size=32}
| F10 : {id=Sem_F10 ,offset=0,size=32}
| F11 : {id=Sem_F11 ,offset=0,size=32}
| F12 : {id=Sem_F12 ,offset=0,size=32}
| F13 : {id=Sem_F13 ,offset=0,size=32}
| F14 : {id=Sem_F14 ,offset=0,size=32}
| F15 : {id=Sem_F15 ,offset=0,size=32}
| F16 : {id=Sem_F16 ,offset=0,size=32}
| F17 : {id=Sem_F17 ,offset=0,size=32}
| F18 : {id=Sem_F18 ,offset=0,size=32}
| F19 : {id=Sem_F19 ,offset=0,size=32}
| F20 : {id=Sem_F20 ,offset=0,size=32}
| F21 : {id=Sem_F21 ,offset=0,size=32}
| F22 : {id=Sem_F22 ,offset=0,size=32}
| F23 : {id=Sem_F23 ,offset=0,size=32}
| F24 : {id=Sem_F24 ,offset=0,size=32}
| F25 : {id=Sem_F25 ,offset=0,size=32}
| F26 : {id=Sem_F26 ,offset=0,size=32}
| F27 : {id=Sem_F27 ,offset=0,size=32}
| F28 : {id=Sem_F28 ,offset=0,size=32}
| F29 : {id=Sem_F29 ,offset=0,size=32}
| F30 : {id=Sem_F30 ,offset=0,size=32}
| F31 : {id=Sem_F31 ,offset=0,size=32}
end
......@@ -4,6 +4,12 @@ in
traverse f insn
end
val mnemonic-of insn = let
val f a b = a
in
traverse f insn
end
# -> sftl
type uarity =
NULLOP
......
......@@ -1510,9 +1510,12 @@ type register =
| SP
| S8
| RA
| HI
type register =
HI
| LO
| PC
| SREG
type register =
F0
......
......@@ -7,12 +7,10 @@ export succ-pretty: (stmts_option, string) -> rope
val insn-append-default a b = a
type insndataD = INSNDATA of insndata
val decode-translate-block-headless config limit insn-append = do
insn <- decode config;
insns <- query $insns;
update @{insns=insn-append insns (case INSNDATA insn of INSNDATA insn : insn end)};
update @{insns=insn-append insns insn};
translate-block-single insn;
jmp <- query $foundJump;
idx <- idxget;
......
......@@ -396,6 +396,13 @@ val /geu sz a b = do
return (var t)
end
val /ges sz a b = do
t <- mktemp;
cmplts sz t a b;
xorb 1 t (var t) (imm 1);
return (var t)
end
val /lts sz a b = do
t <- mktemp;
cmplts sz t a b;
......@@ -414,6 +421,12 @@ val /leu sz a b = do
return (var t)
end
val /les sz a b = do
t <- mktemp;
cmples sz t a b;
return (var t)
end
val const i = return (SEM_LIN_IMM{const=i})
val imm i = SEM_LIN_IMM{const=i}
......
......@@ -974,11 +974,6 @@ end
val sub-unsigned-saturating size dst src1 src2 = binop-unsigned-saturating sub /gtu 0 size dst src1 src2
val flow_semantics = do
hugo <- decode config-default;
semantics hugo
end
val semantics insn = let
val comb x = @{features=insn.features,opnd-sz=insn.opnd-sz,addr-sz=insn.addr-sz,rep=insn.rep,repne=insn.repne,lock=insn.lock} x
in
......@@ -2309,7 +2304,7 @@ val translate-block-single insn = do
ic <- query $ins_count;
update@{tmp=0,ins_count=ic+1};
translate-x86 insn
translate-x86 {features=insn.features,opnd-sz=insn.opnd-sz,addr-sz=insn.addr-sz,rep=insn.rep,repne=insn.repne,lock=insn.lock,insn=insn.insn,config=insn.config,length=insn.length}
end
val relative-next stmts = let
......
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