Commit caa6cf3b authored by Julian Kranz's avatar Julian Kranz

Gdrr

- Continued to implement gdrr
parent e5c5950f
......@@ -15,8 +15,8 @@ typedef void gdrr_sem_address_t;
typedef void gdrr_sem_var_t;
typedef void gdrr_sem_linear_t;
typedef void gdrr_sem_op_t;
typedef void gdrr_sem_branch_hint;
typedef void gdrr_sem_stmt_t;
typedef void gdrr_branch_hint;
typedef void gdrr_sem_stmts_t;
struct gdrr_sem_id_callbacks {
......@@ -98,10 +98,16 @@ struct gdrr_sem_stmt_callbacks {
gdrr_sem_stmt_t *(*sem_while)(gdrr_sem_linear_t *cond, gdrr_sem_stmts_t *body);
gdrr_sem_stmt_t *(*sem_cbranch)(gdrr_sem_linear_t *cond,
gdrr_sem_address_t *target_true, gdrr_sem_address_t *target_false);
gdrr_sem_stmt_t *(*sem_branch)(gdrr_branch_hint *branch_hint,
gdrr_sem_stmt_t *(*sem_branch)(gdrr_sem_branch_hint *branch_hint,
gdrr_sem_address_t *target);
};
struct gdrr_sem_branch_hint_callbacks {
gdrr_sem_branch_hint *(*hint_jump)(void);
gdrr_sem_branch_hint *(*hint_call)(void);
gdrr_sem_branch_hint *(*hint_ret)(void);
};
struct gdrr_sem_stmts_callbacks {
gdrr_sem_stmts_t *(*sem_cons)(gdrr_sem_stmt_t *hd, gdrr_sem_stmts_t *tl);
gdrr_sem_stmts_t *(*sem_nil)(void);
......@@ -124,6 +130,7 @@ struct gdrr_config {
struct gdrr_sem_linear_callbacks sem_linear;
struct gdrr_sem_op_callbacks sem_op;
struct gdrr_sem_stmt_callbacks sem_stmt;
struct gdrr_sem_branch_hint_callbacks sem_branch_hint;
union {
struct gdrr_sem_stmts_callbacks sem_stmts;
struct gdrr_sem_stmts_list_callbacks sem_stmts_list;
......
......@@ -11,6 +11,9 @@
#include <dis.h>
#include "gdrr.h"
/*
* Todo: Cleanup ordering
*/
static gdrr_sem_stmts_t *gdrr_convert_sem_stmts_with_config(__obj sem_stmts_obj,
struct gdrr_config *config);
static gdrr_sem_id_t *gdrr_convert_sem_linear(__obj sem_linear_obj,
......@@ -290,6 +293,28 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
return sem_op;
}
static gdrr_sem_stmt_t *gdrr_convert_sem_branch_hint(__obj sem_branch_hint_obj,
struct gdrr_config *config) {
gdrr_sem_stmt_t *sem_branch_hint = NULL;
switch(__CASETAGCON(sem_branch_hint_obj)) {
case __HINT_JUMP: {
sem_branch_hint = config->callbacks.sem_branch_hint.hint_jump();
break;
}
case __HINT_CALL: {
sem_branch_hint = config->callbacks.sem_branch_hint.hint_call();
break;
}
case __HINT_RET: {
sem_branch_hint = config->callbacks.sem_branch_hint.hint_ret();
break;
}
}
return sem_branch_hint;
}
static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
struct gdrr_config *config) {
gdrr_sem_stmt_t *sem_stmt = NULL;
......@@ -351,7 +376,8 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
case __SEM_BRANCH: {
__obj hint = __RECORD_SELECT(rec, ___hint);
__obj target = __RECORD_SELECT(rec, ___target);
sem_stmt = config->callbacks.sem_stmt.sem_branch(NULL,
sem_stmt = config->callbacks.sem_stmt.sem_branch(
gdrr_convert_sem_branch_hint(hint, config),
gdrr_convert_sem_address(target, config));
break;
}
......
......@@ -54,7 +54,7 @@ type sem_stmt =
| SEM_CBRANCH of {cond:sem_linear, target-true:sem_address, target-false:sem_address}
| SEM_BRANCH of {hint:branch_hint, target:sem_address}
type branch_hint =
type branch_hint =
HINT_JUMP
| HINT_CALL
| HINT_RET
......
......@@ -6,237 +6,223 @@
#include <dis.h>
#include <gdrr.h>
static gdrr_sem_stmts_t *list_next(gdrr_sem_stmt_t *next, gdrr_sem_stmts_t *list) {
printf("next statement\n\n");
// sem_id
static gdrr_sem_id_t *virt_eq(void) {
printf("=> virt_eq\n");
return NULL;
}
static gdrr_sem_stmts_t *list_init() {
printf("init\n");
static gdrr_sem_id_t *virt_neq(void) {
printf("=> virt_neq\n");
return NULL;
}
static gdrr_sem_stmt_t *sem_assign(gdrr_sem_var_t *lhs, gdrr_sem_op_t *rhs) {
printf("assign\n");
static gdrr_sem_id_t *virt_les(void) {
printf("=> virt_les\n");
return NULL;
}
static gdrr_sem_stmt_t *sem_load(gdrr_sem_var_t *lhs, __word size, gdrr_sem_address_t *address) {
printf("load\n");
static gdrr_sem_id_t *virt_leu(void) {
printf("=> virt_leu\n");
return NULL;
}
static gdrr_sem_stmt_t *sem_store(gdrr_sem_var_t *lhs, gdrr_sem_op_t *rhs) {
printf("store\n");
static gdrr_sem_id_t *virt_lts(void) {
printf("=> virt_lts\n");
return NULL;
}
static gdrr_sem_stmt_t *sem_ite(gdrr_sem_linear_t *cond, gdrr_sem_stmts_t *then_branch, gdrr_sem_stmts_t *else_branch) {
printf("ite\n");
static gdrr_sem_id_t *virt_ltu(void) {
printf("=> virt_ltu\n");
return NULL;
}
static gdrr_sem_id_t *virt_t(__word t) {
printf("=> id {t=%lu}\n", t);
return NULL;
}
static gdrr_sem_stmt_t *sem_while(gdrr_sem_linear_t *cond, gdrr_sem_stmts_t *body) {
printf("while\n");
// sem_address
static gdrr_sem_address_t *sem_address(__word size, gdrr_sem_linear_t *address) {
printf("==> sem_address {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_stmt_t *sem_cbranch(gdrr_sem_linear_t *cond,
gdrr_sem_address_t *target_true, gdrr_sem_address_t *target_false) {
printf("cbranch\n");
// sem_var
static gdrr_sem_var_t *sem_var(gdrr_sem_id_t *id, __word offset) {
printf("==> var {offset=%lu}\n", offset);
return NULL;
}
static gdrr_sem_stmt_t *sem_branch(gdrr_branch_hint *branch_hint,
gdrr_sem_address_t *target) {
printf("branch\n");
// sem_linear
static gdrr_sem_linear_t *sem_lin_var(gdrr_sem_var_t *this) {
printf("==> sem_lin_var\n");
return NULL;
}
static gdrr_sem_linear_t *sem_lin_imm(__word imm) {
printf("==> sem_lin_imm {imm=%lu}\n", imm);
return NULL;
}
static gdrr_sem_linear_t *sem_lin_add(gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("==> sem_lin_add\n");
return NULL;
}
static gdrr_sem_linear_t *sem_lin_sub(gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("==> sem_lin_sub\n");
return NULL;
}
static gdrr_sem_linear_t *sem_lin_scale(__word imm, gdrr_sem_linear_t *opnd) {
printf("==> sem_lin_scale {imm=%lu}\n", imm);
return NULL;
}
// sem_op
static gdrr_sem_op_t *sem_lin(__word size, gdrr_sem_linear_t *opnd1) {
printf("=> lin {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_mul(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> mul {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_div(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> div {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_divs(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> divs {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_mod(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> mod {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_shl(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> shl {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_shr(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> shr {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_shrs(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> shrs {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_and(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> and {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_or(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> or {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_xor(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> xor {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_sx(__word size, __word fromsize,
gdrr_sem_linear_t *opnd1) {
printf("=> sx {size=%lu, fromsize=%lu}\n", size, fromsize);
return NULL;
}
static gdrr_sem_op_t *sem_zx(__word size, __word fromsize,
gdrr_sem_linear_t *opnd1) {
printf("=> zx {size=%lu, fromsize=%lu}\n", size, fromsize);
return NULL;
}
static gdrr_sem_op_t *sem_cmpeq(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> cmpeq {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_cmpneq(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> cmpneq {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_cmples(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> cmples {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_cmpleu(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> cmpleu {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_cmplts(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> cmplts {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_cmpltu(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2) {
printf("=> cmpltu {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_op_t *sem_arb(__word size) {
printf("=> arb {size=%lu}\n", size);
return NULL;
}
static gdrr_sem_id_t *virt_eq(void) {
printf("=> virt_eq\n");
return NULL;
}
static gdrr_sem_id_t *virt_neq(void) {
printf("=> virt_neq\n");
return NULL;
}
static gdrr_sem_id_t *virt_les(void) {
printf("=> virt_les\n");
// sem_branch_hint
static gdrr_sem_branch_hint *hint_jump(void) {
printf("==> branch_hint_jump\n");
return NULL;
}
static gdrr_sem_id_t *virt_leu(void) {
printf("=> virt_leu\n");
static gdrr_sem_branch_hint *hint_call(void) {
printf("==> branch_hint_call\n");
return NULL;
}
static gdrr_sem_id_t *virt_lts(void) {
printf("=> virt_lts\n");
static gdrr_sem_branch_hint *hint_ret(void) {
printf("==> branch_hint_ret\n");
return NULL;
}
static gdrr_sem_id_t *virt_ltu(void) {
printf("=> virt_ltu\n");
// sem_stmt
static gdrr_sem_stmt_t *sem_assign(gdrr_sem_var_t *lhs, gdrr_sem_op_t *rhs) {
printf("assign\n");
return NULL;
}
static gdrr_sem_id_t *virt_t(__word t) {
printf("=> id {t=%lu}\n", t);
static gdrr_sem_stmt_t *sem_load(gdrr_sem_var_t *lhs, __word size, gdrr_sem_address_t *address) {
printf("load\n");
return NULL;
}
static gdrr_sem_var_t *sem_var(gdrr_sem_id_t *id, __word offset) {
printf("==> var {offset=%lu}\n", offset);
static gdrr_sem_stmt_t *sem_store(gdrr_sem_var_t *lhs, gdrr_sem_op_t *rhs) {
printf("store\n");
return NULL;
}
static gdrr_sem_linear_t *sem_lin_var(gdrr_sem_var_t *this) {
printf("==> sem_lin_var\n");
static gdrr_sem_stmt_t *sem_ite(gdrr_sem_linear_t *cond, gdrr_sem_stmts_t *then_branch, gdrr_sem_stmts_t *else_branch) {
printf("ite\n");
return NULL;
}
static gdrr_sem_linear_t *sem_lin_imm(__word imm) {
printf("==> sem_lin_imm {imm=%lu}\n", imm);
static gdrr_sem_stmt_t *sem_while(gdrr_sem_linear_t *cond, gdrr_sem_stmts_t *body) {
printf("while\n");
return NULL;
}
static gdrr_sem_linear_t *sem_lin_add(gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("==> sem_lin_add\n");
static gdrr_sem_stmt_t *sem_cbranch(gdrr_sem_linear_t *cond,
gdrr_sem_address_t *target_true, gdrr_sem_address_t *target_false) {
printf("cbranch\n");
return NULL;
}
static gdrr_sem_linear_t *sem_lin_sub(gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("==> sem_lin_sub\n");
static gdrr_sem_stmt_t *sem_branch(gdrr_sem_branch_hint *branch_hint,
gdrr_sem_address_t *target) {
printf("branch\n");
return NULL;
}
static gdrr_sem_linear_t *sem_lin_scale(__word imm, gdrr_sem_linear_t *opnd) {
printf("==> sem_lin_scale {imm=%lu}\n", imm);
// sem_stmts
static gdrr_sem_stmts_t *list_next(gdrr_sem_stmt_t *next, gdrr_sem_stmts_t *list) {
printf("next statement\n\n");
return NULL;
}
static gdrr_sem_address_t *sem_address(__word size, gdrr_sem_linear_t *address) {
printf("==> sem_address {size=%lu}\n", size);
static gdrr_sem_stmts_t *list_init() {
printf("init\n");
return NULL;
}
......@@ -314,6 +300,10 @@ done:
config.callbacks.sem_op.sem_cmpltu = &sem_cmpltu;
config.callbacks.sem_op.sem_arb = &sem_arb;
config.callbacks.sem_branch_hint.hint_jump = &hint_jump;
config.callbacks.sem_branch_hint.hint_call = &hint_call;
config.callbacks.sem_branch_hint.hint_ret = &hint_ret;
config.callbacks.sem_stmt.sem_assign = &sem_assign;
config.callbacks.sem_stmt.sem_load = &sem_load;
config.callbacks.sem_stmt.sem_store = &sem_store;
......
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