Commit 41e77a52 authored by Julian Kranz's avatar Julian Kranz

RReil: sem_op => sem_expr

parent c7e0a3d1
......@@ -221,7 +221,7 @@ static obj_t sem_cmpltu(state_t state, int_t size,
return (obj_t)comparator;
}
// sem_op
// sem_expr
static obj_t sem_lin(state_t state, int_t size,
obj_t opnd1) {
struct rreil_op *op = (struct rreil_op*)malloc(sizeof(struct rreil_op));
......@@ -575,7 +575,7 @@ callbacks_t rreil_gdrr_builder_callbacks_get(state_t state) {
.sem_cmpltu = &sem_cmpltu
};
unboxed_sem_op_callbacks_t sem_op_callbacks = {
unboxed_sem_expr_callbacks_t sem_expr_callbacks = {
.sem_lin = &sem_lin,
.sem_mul = &sem_mul,
.sem_div = &sem_div,
......@@ -645,7 +645,7 @@ callbacks_t rreil_gdrr_builder_callbacks_get(state_t state) {
unboxed_sem_linear_callbacks_t sem_linear_callbacks;
unboxed_sem_sexpr_callbacks_t sem_sexpr_callbacks;
unboxed_sem_op_cmp_callbacks_t sem_op_cmp_callbacks;
unboxed_sem_op_callbacks_t sem_op_callbacks;
unboxed_sem_expr_callbacks_t sem_expr_callbacks;
unboxed_sem_varl_callbacks_t sem_varl_callbacks;
unboxed_sem_varls_callbacks_t sem_varls_callbacks;
unboxed_sem_flop_callbacks_t sem_flop_callbacks;
......@@ -662,7 +662,7 @@ callbacks_t rreil_gdrr_builder_callbacks_get(state_t state) {
callbacks_heap->sem_linear_callbacks = sem_linear_callbacks;
callbacks_heap->sem_sexpr_callbacks = sem_sexpr_callbacks;
callbacks_heap->sem_op_cmp_callbacks = sem_op_cmp_callbacks;
callbacks_heap->sem_op_callbacks = sem_op_callbacks;
callbacks_heap->sem_expr_callbacks = sem_expr_callbacks;
callbacks_heap->sem_varl_callbacks = sem_varl_callbacks;
callbacks_heap->sem_varls_callbacks = sem_varls_callbacks;
callbacks_heap->sem_flop_callbacks = sem_flop_callbacks;
......@@ -678,7 +678,7 @@ callbacks_t rreil_gdrr_builder_callbacks_get(state_t state) {
.sem_linear = &callbacks_heap->sem_linear_callbacks,
.sem_sexpr = &callbacks_heap->sem_sexpr_callbacks,
.sem_op_cmp = &callbacks_heap->sem_op_cmp_callbacks,
.sem_op = &callbacks_heap->sem_op_callbacks,
.sem_expr = &callbacks_heap->sem_expr_callbacks,
.sem_varl = &callbacks_heap->sem_varl_callbacks,
.sem_varls = &callbacks_heap->sem_varls_callbacks,
.sem_flop = &callbacks_heap->sem_flop_callbacks,
......
......@@ -2,8 +2,8 @@ export = rreil-sem-stmts-head rreil-sem-stmts-tail rreil-sem-stmts-has-more
rreil-sem-varls-head rreil-sem-varls-tail rreil-sem-varls-has-more
rreil-cif-userdata-set rreil-cif-userdata-get{userdata}
rreil-convert-sem-varl{sem_varl, sem_id, offset, size, id}
rreil-convert-sem-stmt-manual{branch_hint, sem_stmt, sem_flop, sem_varl, sem_op, sem_op_cmp, sem_sexpr, sem_linear, sem_var, sem_address, sem_id, sem_prim}
rreil-convert-sem-stmts{sem_stmts, branch_hint, sem_stmt, sem_flop, sem_varls, sem_varl, sem_op, sem_op_cmp, sem_sexpr, sem_linear, sem_var, sem_address, sem_id, sem_prim}
rreil-convert-sem-stmt-manual{branch_hint, sem_stmt, sem_flop, sem_varl, sem_expr, sem_op_cmp, sem_sexpr, sem_linear, sem_var, sem_address, sem_id, sem_prim}
rreil-convert-sem-stmts{sem_stmts, branch_hint, sem_stmt, sem_flop, sem_varls, sem_varl, sem_expr, sem_op_cmp, sem_sexpr, sem_linear, sem_var, sem_address, sem_id, sem_prim}
#type callbacks =
# SEM_ID_CBS of {virt_na:string_, virt_t:string_}
......@@ -14,7 +14,7 @@ type sem_var_callbacks = {sem_var_:int}
type sem_linear_callbacks = {sem_lin_var:int, sem_lin_imm:int, sem_lin_add:int, sem_lin_sub:int, sem_lin_scale:int}
type sem_sexpr_callbacks = {sem_sexpr_lin:int, sem_sexpr_cmp:int}
type sem_op_cmp_callbacks = {sem_cmpeq:int, sem_cmpneq:int, sem_cmples:int, sem_cmpleu:int, sem_cmplts:int, sem_cmpltu:int}
type sem_op_callbacks = {sem_lin:int, sem_mul:int, sem_div:int, sem_divs:int, sem_mod:int, sem_shl:int, sem_shr:int, sem_shrs:int, sem_and:int, sem_or:int, sem_xor:int, sem_sx:int, sem_zx:int, sem_cmp:int, sem_arb:int}
type sem_expr_callbacks = {sem_lin:int, sem_mul:int, sem_div:int, sem_divs:int, sem_mod:int, sem_shl:int, sem_shr:int, sem_shrs:int, sem_and:int, sem_or:int, sem_xor:int, sem_sx:int, sem_zx:int, sem_cmp:int, sem_arb:int}
type sem_varl_callbacks = {sem_varl_:int}
type sem_varls_callbacks = {sem_varls_next:int, sem_varls_init:int}
type sem_flop_callbacks = {sem_flop_:int}
......@@ -31,7 +31,7 @@ type callbacks = {
sem_linear:sem_linear_callbacks,
sem_sexpr:sem_sexpr_callbacks,
sem_op_cmp:sem_op_cmp_callbacks,
sem_op:sem_op_callbacks,
sem_expr:sem_expr_callbacks,
sem_varl:sem_varl_callbacks,
sem_varls:sem_varls_callbacks,
sem_flop:sem_flop_callbacks,
......@@ -55,7 +55,7 @@ val rreil-cif-userdata-get = query $userdata
#val rreil-callbacks-branch-hint branch_hint = {branch_hint_=branch_hint}
#val rreil-callbacks-sem-stmts sem_cons sem_nil = {sem_cons=sem_cons, sem_nil=sem_nil}
#val rreil-callbacks-sem-stmts-list list_next list_init = {list_next=list_next, list_init=list_init}
#val rreil-callbacks sem_id sem_address sem_var sem_linear sem_sexpr sem_op_cmp sem_op sem_stmt branch_hint sem_stmts sem_stmts_list = {sem_id=sem_id, sem_address=sem_address, sem_var=sem_var, sem_linear=sem_linear, sem_sexpr=sem_sexpr, sem_op_cmp=sem_op_cmp, sem_op=sem_op, sem_stmt=sem_stmt, branch_hint=branch_hint, sem_stmts=sem_stmts, sem_stmts_list=sem_stmts_list}
#val rreil-callbacks sem_id sem_address sem_var sem_linear sem_sexpr sem_op_cmp sem_expr sem_stmt branch_hint sem_stmts sem_stmts_list = {sem_id=sem_id, sem_address=sem_address, sem_var=sem_var, sem_linear=sem_linear, sem_sexpr=sem_sexpr, sem_op_cmp=sem_op_cmp, sem_expr=sem_expr, sem_stmt=sem_stmt, branch_hint=branch_hint, sem_stmts=sem_stmts, sem_stmts_list=sem_stmts_list}
val rreil-convert-sem-id cbs id = case id of
# VIRT_EQ: cbs.sem_id.virt_na (index id)
......@@ -95,22 +95,22 @@ val rreil-convert-sem-op-cmp cbs op-cmp = case op-cmp of
| SEM_CMPLTU c: cbs.sem_op_cmp.sem_cmpltu c.size (rreil-convert-sem-linear cbs c.opnd1) (rreil-convert-sem-linear cbs c.opnd2)
end
val rreil-convert-sem-op cbs op = case op of
SEM_LIN l: cbs.sem_op.sem_lin l.size (rreil-convert-sem-linear cbs l.opnd1)
| SEM_MUL m: cbs.sem_op.sem_mul m.size (rreil-convert-sem-linear cbs m.opnd1) (rreil-convert-sem-linear cbs m.opnd2)
| SEM_DIV d: cbs.sem_op.sem_div d.size (rreil-convert-sem-linear cbs d.opnd1) (rreil-convert-sem-linear cbs d.opnd2)
| SEM_DIVS d: cbs.sem_op.sem_divs d.size (rreil-convert-sem-linear cbs d.opnd1) (rreil-convert-sem-linear cbs d.opnd2)
| SEM_MOD m: cbs.sem_op.sem_mod m.size (rreil-convert-sem-linear cbs m.opnd1) (rreil-convert-sem-linear cbs m.opnd2)
| SEM_SHL s: cbs.sem_op.sem_shl s.size (rreil-convert-sem-linear cbs s.opnd1) (rreil-convert-sem-linear cbs s.opnd2)
| SEM_SHR s: cbs.sem_op.sem_shr s.size (rreil-convert-sem-linear cbs s.opnd1) (rreil-convert-sem-linear cbs s.opnd2)
| SEM_SHRS s: cbs.sem_op.sem_shrs s.size (rreil-convert-sem-linear cbs s.opnd1) (rreil-convert-sem-linear cbs s.opnd2)
| SEM_AND a: cbs.sem_op.sem_and a.size (rreil-convert-sem-linear cbs a.opnd1) (rreil-convert-sem-linear cbs a.opnd2)
| SEM_OR o: cbs.sem_op.sem_or o.size (rreil-convert-sem-linear cbs o.opnd1) (rreil-convert-sem-linear cbs o.opnd2)
| SEM_XOR x: cbs.sem_op.sem_xor x.size (rreil-convert-sem-linear cbs x.opnd1) (rreil-convert-sem-linear cbs x.opnd2)
| SEM_SX s: cbs.sem_op.sem_sx s.size s.fromsize (rreil-convert-sem-linear cbs s.opnd1)
| SEM_ZX s: cbs.sem_op.sem_zx s.size s.fromsize (rreil-convert-sem-linear cbs s.opnd1)
| SEM_CMP c: cbs.sem_op.sem_cmp (rreil-convert-sem-op-cmp cbs c)
| SEM_ARB a: cbs.sem_op.sem_arb a.size
val rreil-convert-sem-expr cbs op = case op of
SEM_LIN l: cbs.sem_expr.sem_lin l.size (rreil-convert-sem-linear cbs l.opnd1)
| SEM_MUL m: cbs.sem_expr.sem_mul m.size (rreil-convert-sem-linear cbs m.opnd1) (rreil-convert-sem-linear cbs m.opnd2)
| SEM_DIV d: cbs.sem_expr.sem_div d.size (rreil-convert-sem-linear cbs d.opnd1) (rreil-convert-sem-linear cbs d.opnd2)
| SEM_DIVS d: cbs.sem_expr.sem_divs d.size (rreil-convert-sem-linear cbs d.opnd1) (rreil-convert-sem-linear cbs d.opnd2)
| SEM_MOD m: cbs.sem_expr.sem_mod m.size (rreil-convert-sem-linear cbs m.opnd1) (rreil-convert-sem-linear cbs m.opnd2)
| SEM_SHL s: cbs.sem_expr.sem_shl s.size (rreil-convert-sem-linear cbs s.opnd1) (rreil-convert-sem-linear cbs s.opnd2)
| SEM_SHR s: cbs.sem_expr.sem_shr s.size (rreil-convert-sem-linear cbs s.opnd1) (rreil-convert-sem-linear cbs s.opnd2)
| SEM_SHRS s: cbs.sem_expr.sem_shrs s.size (rreil-convert-sem-linear cbs s.opnd1) (rreil-convert-sem-linear cbs s.opnd2)
| SEM_AND a: cbs.sem_expr.sem_and a.size (rreil-convert-sem-linear cbs a.opnd1) (rreil-convert-sem-linear cbs a.opnd2)
| SEM_OR o: cbs.sem_expr.sem_or o.size (rreil-convert-sem-linear cbs o.opnd1) (rreil-convert-sem-linear cbs o.opnd2)
| SEM_XOR x: cbs.sem_expr.sem_xor x.size (rreil-convert-sem-linear cbs x.opnd1) (rreil-convert-sem-linear cbs x.opnd2)
| SEM_SX s: cbs.sem_expr.sem_sx s.size s.fromsize (rreil-convert-sem-linear cbs s.opnd1)
| SEM_ZX s: cbs.sem_expr.sem_zx s.size s.fromsize (rreil-convert-sem-linear cbs s.opnd1)
| SEM_CMP c: cbs.sem_expr.sem_cmp (rreil-convert-sem-op-cmp cbs c)
| SEM_ARB a: cbs.sem_expr.sem_arb a.size
end
val rreil-convert-branch-hint cbs hint = cbs.branch_hint.branch_hint_ (index hint)
......@@ -152,9 +152,9 @@ val rreil-convert-sem-prim-manual cbs prim = case prim of
end
val rreil-convert-sem-stmt cbs stmt = case stmt of
SEM_ASSIGN s: cbs.sem_stmt.sem_assign (rreil-convert-sem-var cbs s.lhs) (rreil-convert-sem-op cbs s.rhs)
SEM_ASSIGN s: cbs.sem_stmt.sem_assign (rreil-convert-sem-var cbs s.lhs) (rreil-convert-sem-expr cbs s.rhs)
| SEM_LOAD l: cbs.sem_stmt.sem_load (rreil-convert-sem-var cbs l.lhs) l.size (rreil-convert-sem-address cbs l.address)
| SEM_STORE s: cbs.sem_stmt.sem_store (rreil-convert-sem-address cbs s.address) (rreil-convert-sem-op cbs s.rhs)
| SEM_STORE s: cbs.sem_stmt.sem_store (rreil-convert-sem-address cbs s.address) (rreil-convert-sem-expr cbs s.rhs)
| SEM_ITE i: cbs.sem_stmt.sem_ite (rreil-convert-sem-sexpr cbs i.cond) (rreil-convert-sem-stmts cbs i.then_branch) (rreil-convert-sem-stmts cbs i.else_branch)
| SEM_WHILE w: cbs.sem_stmt.sem_while (rreil-convert-sem-sexpr cbs w.cond) (rreil-convert-sem-stmts cbs w.body)
| SEM_CBRANCH c: cbs.sem_stmt.sem_cbranch (rreil-convert-sem-sexpr cbs c.cond) (rreil-convert-sem-address cbs c.target-true) (rreil-convert-sem-address cbs c.target-false)
......@@ -163,9 +163,9 @@ val rreil-convert-sem-stmt cbs stmt = case stmt of
end
val rreil-convert-sem-stmt-manual cbs stmt = case stmt of
SEM_ASSIGN s: cbs.sem_stmt.sem_assign (rreil-convert-sem-var cbs s.lhs) (rreil-convert-sem-op cbs s.rhs)
SEM_ASSIGN s: cbs.sem_stmt.sem_assign (rreil-convert-sem-var cbs s.lhs) (rreil-convert-sem-expr cbs s.rhs)
| SEM_LOAD l: cbs.sem_stmt.sem_load (rreil-convert-sem-var cbs l.lhs) l.size (rreil-convert-sem-address cbs l.address)
| SEM_STORE s: cbs.sem_stmt.sem_store (rreil-convert-sem-address cbs s.address) (rreil-convert-sem-op cbs s.rhs)
| SEM_STORE s: cbs.sem_stmt.sem_store (rreil-convert-sem-address cbs s.address) (rreil-convert-sem-expr cbs s.rhs)
| SEM_ITE i: cbs.sem_stmt.sem_ite (rreil-convert-sem-sexpr cbs i.cond) i.then_branch i.else_branch
| SEM_WHILE w: cbs.sem_stmt.sem_while (rreil-convert-sem-sexpr cbs w.cond) w.body
| SEM_CBRANCH c: cbs.sem_stmt.sem_cbranch (rreil-convert-sem-sexpr cbs c.cond) (rreil-convert-sem-address cbs c.target-true) (rreil-convert-sem-address cbs c.target-false)
......
......@@ -48,9 +48,9 @@ val rreil-show-prim p =
val rreil-show-stmt s =
case s of
SEM_ASSIGN x: rreil-show-var x.lhs +++ " = " +++ rreil-show-op x.rhs
SEM_ASSIGN x: rreil-show-var x.lhs +++ " = " +++ rreil-show-expr x.rhs
| SEM_LOAD x: rreil-show-var x.lhs +++ " = " +++ rreil-show-ptrderef x.size x.address
| SEM_STORE x: "*" +++ rreil-show-address x.address +++ " = " +++ rreil-show-op x.rhs
| SEM_STORE x: "*" +++ rreil-show-address x.address +++ " = " +++ rreil-show-expr x.rhs
| SEM_ITE x: "if (" +++ rreil-show-sexpr x.cond +++ ") {\n" +++ rreil-show-stmts x.then_branch +++ "} else {\n" +++ rreil-show-stmts x.else_branch +++ "}"
| SEM_WHILE x: "while (" +++ rreil-show-sexpr x.cond +++ ") {\n" +++ rreil-show-stmts x.body +++ "}"
| SEM_CBRANCH x: "if (" +++ rreil-show-sexpr x.cond +++ ") goto " +++ rreil-show-address x.target-true +++ " else goto " +++ rreil-show-address x.target-false
......@@ -77,8 +77,8 @@ val rreil-show-op-cmp cmp =
| SEM_CMPLTU x: "<u" +++ rreil-show-cmp x
end
val rreil-show-op op =
case op of
val rreil-show-expr expr =
case expr of
SEM_LIN x: rreil-show-arity1 x
| SEM_MUL x: "mul" +++ rreil-show-arity2 x
| SEM_DIV x: "div" +++ rreil-show-arity2 x
......
......@@ -31,7 +31,7 @@ type sem_op_cmp =
| SEM_CMPLTS of sem_cmp
| SEM_CMPLTU of sem_cmp
type sem_op =
type sem_expr =
SEM_LIN of sem_arity1
| SEM_MUL of sem_arity2
| SEM_DIV of sem_arity2
......@@ -64,9 +64,9 @@ type sem_prim =
| SEM_PRIM_FLOP of {op:sem_flop, flags:sem_var, res:sem_varl, args:sem_varls}
type sem_stmt =
SEM_ASSIGN of {lhs:sem_var, rhs:sem_op}
SEM_ASSIGN of {lhs:sem_var, rhs:sem_expr}
| SEM_LOAD of {lhs:sem_var, size:int, address:sem_address}
| SEM_STORE of {address:sem_address, rhs:sem_op}
| SEM_STORE of {address:sem_address, rhs:sem_expr}
| SEM_ITE of {cond:sem_sexpr, then_branch:sem_stmts, else_branch:sem_stmts}
| SEM_WHILE of {cond:sem_sexpr, body:sem_stmts}
| SEM_CBRANCH of {cond:sem_sexpr, target-true:sem_address, target-false:sem_address}
......
......@@ -366,7 +366,7 @@ static obj_t sem_cmpltu(state_t state, int_t size,
return NULL ;
}
// sem_op
// sem_expr
static obj_t sem_lin(state_t state, int_t size,
obj_t opnd1) {
printf("=> lin {size=%lu}\n", size);
......@@ -612,7 +612,7 @@ int main(int argc, char** argv) {
.sem_cmpltu = &sem_cmpltu
};
unboxed_sem_op_callbacks_t sem_op_callbacks = {
unboxed_sem_expr_callbacks_t sem_expr_callbacks = {
.sem_lin = &sem_lin,
.sem_mul = &sem_mul,
.sem_div = &sem_div,
......@@ -680,7 +680,7 @@ int main(int argc, char** argv) {
.sem_linear = &sem_linear_callbacks,
.sem_sexpr = &sem_sexpr_callbacks,
.sem_op_cmp = &sem_op_cmp_callbacks,
.sem_op = &sem_op_callbacks,
.sem_expr = &sem_expr_callbacks,
.sem_varl = &sem_varl_callbacks,
.sem_varls = &sem_varls_callbacks,
.sem_flop = &sem_flop_callbacks,
......
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