Commit 46a9a839 authored by Julian Kranz's avatar Julian Kranz
Browse files

Gdrr

- Continued to implement gdrr
parent 1fa59081
...@@ -18,6 +18,8 @@ typedef void gdrr_sem_var_t; ...@@ -18,6 +18,8 @@ typedef void gdrr_sem_var_t;
typedef void gdrr_sem_op_t; typedef void gdrr_sem_op_t;
typedef void gdrr_sem_address_t; typedef void gdrr_sem_address_t;
typedef void gdrr_branch_hint;
struct gddr_sem_stmts_callbacks { struct gddr_sem_stmts_callbacks {
gdrr_sem_stmts_t *(*sem_cons)(gdrr_sem_stmt_t *hd, gdrr_sem_stmts_t *tl); gdrr_sem_stmts_t *(*sem_cons)(gdrr_sem_stmt_t *hd, gdrr_sem_stmts_t *tl);
gdrr_sem_stmts_t *(*sem_nil)(void); gdrr_sem_stmts_t *(*sem_nil)(void);
...@@ -35,6 +37,11 @@ struct gddr_sem_stmt_callbacks { ...@@ -35,6 +37,11 @@ struct gddr_sem_stmt_callbacks {
gdrr_sem_stmt_t *(*sem_store)(gdrr_sem_var_t *lhs, gdrr_sem_op_t *rhs); gdrr_sem_stmt_t *(*sem_store)(gdrr_sem_var_t *lhs, gdrr_sem_op_t *rhs);
gdrr_sem_stmt_t *(*sem_ite)(gdrr_sem_linear_t *cond, gdrr_sem_stmt_t *(*sem_ite)(gdrr_sem_linear_t *cond,
gdrr_sem_stmts_t *then_branch, gdrr_sem_stmts_t *else_branch); gdrr_sem_stmts_t *then_branch, gdrr_sem_stmts_t *else_branch);
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_address_t *target);
}; };
struct gddr_callbacks { struct gddr_callbacks {
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
#include <dis.h> #include <dis.h>
#include "gdrr.h" #include "gdrr.h"
static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj, struct gddr_callbacks *callbacks) { static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
struct gddr_callbacks *callbacks) {
gdrr_sem_stmt_t *sem_stmt = NULL; gdrr_sem_stmt_t *sem_stmt = NULL;
switch(__CASETAGCON(sem_stmt_obj)) { switch(__CASETAGCON(sem_stmt_obj)) {
...@@ -27,15 +28,20 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj, struct gddr_ca ...@@ -27,15 +28,20 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj, struct gddr_ca
sem_stmt = callbacks->sem_stmt.sem_store(NULL, NULL); sem_stmt = callbacks->sem_stmt.sem_store(NULL, NULL);
break; break;
} }
case __SEM_XOR: {
break;
}
case __SEM_ITE: { case __SEM_ITE: {
sem_stmt = callbacks->sem_stmt.sem_ite(NULL, NULL, NULL); sem_stmt = callbacks->sem_stmt.sem_ite(NULL, NULL, NULL);
break; break;
} }
default: { case __SEM_WHILE: {
// printf("%d\n", __CASETAGCON(instr)); sem_stmt = callbacks->sem_stmt.sem_while(NULL, NULL);
break;
}
case __SEM_CBRANCH: {
sem_stmt = callbacks->sem_stmt.sem_cbranch(NULL, NULL, NULL);
break;
}
case __SEM_BRANCH: {
sem_stmt = callbacks->sem_stmt.sem_branch(NULL, NULL);
break; break;
} }
} }
...@@ -43,7 +49,8 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj, struct gddr_ca ...@@ -43,7 +49,8 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj, struct gddr_ca
return sem_stmt; return sem_stmt;
} }
static gdrr_sem_stmts_t *gdrr_convert_sem_stmts(__obj sem_stmts_obj, struct gddr_callbacks *callbacks) { static gdrr_sem_stmts_t *gdrr_convert_sem_stmts(__obj sem_stmts_obj,
struct gddr_callbacks *callbacks) {
gdrr_sem_stmts_t *sem_stmts = NULL; gdrr_sem_stmts_t *sem_stmts = NULL;
if(__CASETAGCON(sem_stmts_obj) == __SEM_CONS) { if(__CASETAGCON(sem_stmts_obj) == __SEM_CONS) {
...@@ -61,7 +68,8 @@ static gdrr_sem_stmts_t *gdrr_convert_sem_stmts(__obj sem_stmts_obj, struct gddr ...@@ -61,7 +68,8 @@ static gdrr_sem_stmts_t *gdrr_convert_sem_stmts(__obj sem_stmts_obj, struct gddr
return sem_stmts; return sem_stmts;
} }
static gdrr_sem_stmts_t *gdrr_convert_sem_stmts_list(__obj sem_stmts_obj, struct gddr_callbacks *callbacks) { static gdrr_sem_stmts_t *gdrr_convert_sem_stmts_list(__obj sem_stmts_obj,
struct gddr_callbacks *callbacks) {
gdrr_sem_stmts_t *list = callbacks->sem_stmts_list.list_init(); gdrr_sem_stmts_t *list = callbacks->sem_stmts_list.list_init();
while(__CASETAGCON(sem_stmts_obj) == __SEM_CONS) { while(__CASETAGCON(sem_stmts_obj) == __SEM_CONS) {
...@@ -82,6 +90,7 @@ gdrr_sem_stmt_t *gdrr_convert(__obj semantics, struct gddr_callbacks *callbacks) ...@@ -82,6 +90,7 @@ gdrr_sem_stmt_t *gdrr_convert(__obj semantics, struct gddr_callbacks *callbacks)
return gdrr_convert_sem_stmts(semantics, callbacks); return gdrr_convert_sem_stmts(semantics, callbacks);
} }
gdrr_sem_stmt_t *gdrr_convert_list(__obj semantics, struct gddr_callbacks *callbacks) { gdrr_sem_stmt_t *gdrr_convert_list(__obj semantics,
struct gddr_callbacks *callbacks) {
return gdrr_convert_sem_stmts_list(semantics, callbacks); return gdrr_convert_sem_stmts_list(semantics, callbacks);
} }
...@@ -42,6 +42,26 @@ gdrr_sem_stmt_t *sem_ite(gdrr_sem_linear_t *cond, gdrr_sem_stmts_t *then_branch, ...@@ -42,6 +42,26 @@ gdrr_sem_stmt_t *sem_ite(gdrr_sem_linear_t *cond, gdrr_sem_stmts_t *then_branch,
return NULL; return NULL;
} }
gdrr_sem_stmt_t *sem_while(gdrr_sem_linear_t *cond, gdrr_sem_stmts_t *body) {
printf("while\n");
return NULL;
}
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;
}
gdrr_sem_stmt_t *sem_branch(gdrr_branch_hint *branch_hint,
gdrr_sem_address_t *target) {
printf("branch\n");
return NULL;
}
int main (int argc, char** argv) { int main (int argc, char** argv) {
__char blob[15]; __char blob[15];
char fmt[1024]; char fmt[1024];
...@@ -83,6 +103,9 @@ done: ...@@ -83,6 +103,9 @@ done:
callbacks.sem_stmt.sem_load = &sem_load; callbacks.sem_stmt.sem_load = &sem_load;
callbacks.sem_stmt.sem_store = &sem_store; callbacks.sem_stmt.sem_store = &sem_store;
callbacks.sem_stmt.sem_ite = &sem_ite; callbacks.sem_stmt.sem_ite = &sem_ite;
callbacks.sem_stmt.sem_while = &sem_while;
callbacks.sem_stmt.sem_cbranch = &sem_cbranch;
callbacks.sem_stmt.sem_branch = &sem_branch;
gdrr_convert(r, &callbacks); gdrr_convert(r, &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