Commit b2a44c6c authored by Julian Kranz's avatar Julian Kranz
Browse files

Gdrr

- Continued to implement gdrr
parent 863fa6ee
......@@ -20,102 +20,110 @@ typedef void gdrr_sem_stmt_t;
typedef void gdrr_sem_stmts_t;
struct gdrr_sem_id_callbacks {
gdrr_sem_id_t *(*virt_eq)(void);
gdrr_sem_id_t *(*virt_neq)(void);
gdrr_sem_id_t *(*virt_les)(void);
gdrr_sem_id_t *(*virt_leu)(void);
gdrr_sem_id_t *(*virt_lts)(void);
gdrr_sem_id_t *(*virt_ltu)(void);
gdrr_sem_id_t *(*virt_t)(__word this);
gdrr_sem_id_t *(*virt_eq)(void *closure);
gdrr_sem_id_t *(*virt_neq)(void *closure);
gdrr_sem_id_t *(*virt_les)(void *closure);
gdrr_sem_id_t *(*virt_leu)(void *closure);
gdrr_sem_id_t *(*virt_lts)(void *closure);
gdrr_sem_id_t *(*virt_ltu)(void *closure);
gdrr_sem_id_t *(*virt_t)(void *closure, __word this);
};
struct gdrr_sem_address_callbacks {
gdrr_sem_address_t *(*sem_address)(__word size, gdrr_sem_linear_t *address);
gdrr_sem_address_t *(*sem_address)(void *closure, __word size,
gdrr_sem_linear_t *address);
};
struct gdrr_sem_var_callbacks {
gdrr_sem_var_t *(*sem_var)(gdrr_sem_id_t *id, __word offset);
gdrr_sem_var_t *(*sem_var)(void *closure, gdrr_sem_id_t *id, __word offset);
};
struct gdrr_sem_linear_callbacks {
gdrr_sem_linear_t *(*sem_lin_var)(gdrr_sem_var_t *this);
gdrr_sem_linear_t *(*sem_lin_imm)(__word imm);
gdrr_sem_linear_t *(*sem_lin_add)(gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *(*sem_lin_var)(void *closure, gdrr_sem_var_t *this);
gdrr_sem_linear_t *(*sem_lin_imm)(void *closure, __word imm);
gdrr_sem_linear_t *(*sem_lin_add)(void *closure, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_linear_t *(*sem_lin_sub)(gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *(*sem_lin_sub)(void *closure, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_linear_t *(*sem_lin_scale)(__word imm, gdrr_sem_linear_t *opnd);
gdrr_sem_linear_t *(*sem_lin_scale)(void *closure, __word imm,
gdrr_sem_linear_t *opnd);
};
struct gdrr_sem_op_callbacks {
gdrr_sem_op_t *(*sem_lin)(__word size, gdrr_sem_linear_t *opnd1);
gdrr_sem_op_t *(*sem_mul)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_div)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_divs)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_mod)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_shl)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_shr)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_shrs)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_and)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_or)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_xor)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_sx)(__word size, __word fromsize,
gdrr_sem_op_t *(*sem_lin)(void *closure, __word size,
gdrr_sem_linear_t *opnd1);
gdrr_sem_op_t *(*sem_zx)(__word size, __word fromsize,
gdrr_sem_op_t *(*sem_mul)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_div)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_divs)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_mod)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_shl)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_shr)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_shrs)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_and)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_or)(void *closure, __word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_xor)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_sx)(void *closure, __word size, __word fromsize,
gdrr_sem_linear_t *opnd1);
gdrr_sem_op_t *(*sem_cmpeq)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmpneq)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmples)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmpleu)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmplts)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmpltu)(__word size, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_arb)(__word size);
gdrr_sem_op_t *(*sem_zx)(void *closure, __word size, __word fromsize,
gdrr_sem_linear_t *opnd1);
gdrr_sem_op_t *(*sem_cmpeq)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmpneq)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmples)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmpleu)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmplts)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_cmpltu)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
gdrr_sem_op_t *(*sem_arb)(void *closure, __word size);
};
struct gdrr_sem_stmt_callbacks {
gdrr_sem_stmt_t *(*sem_assign)(gdrr_sem_var_t *lhs, gdrr_sem_op_t *rhs);
gdrr_sem_stmt_t *(*sem_load)(gdrr_sem_var_t *lhs, __word size,
gdrr_sem_stmt_t *(*sem_assign)(void *closure, gdrr_sem_var_t *lhs,
gdrr_sem_op_t *rhs);
gdrr_sem_stmt_t *(*sem_load)(void *closure, gdrr_sem_var_t *lhs, __word size,
gdrr_sem_address_t *address);
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_store)(void *closure, gdrr_sem_var_t *lhs,
gdrr_sem_op_t *rhs);
gdrr_sem_stmt_t *(*sem_ite)(void *closure, gdrr_sem_linear_t *cond,
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_stmt_t *(*sem_while)(void *closure, gdrr_sem_linear_t *cond,
gdrr_sem_stmts_t *body);
gdrr_sem_stmt_t *(*sem_cbranch)(void *closure, gdrr_sem_linear_t *cond,
gdrr_sem_address_t *target_true, gdrr_sem_address_t *target_false);
gdrr_sem_stmt_t *(*sem_branch)(gdrr_sem_branch_hint *branch_hint,
gdrr_sem_address_t *target);
gdrr_sem_stmt_t *(*sem_branch)(void *closure,
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);
gdrr_sem_branch_hint *(*hint_jump)(void *closure);
gdrr_sem_branch_hint *(*hint_call)(void *closure);
gdrr_sem_branch_hint *(*hint_ret)(void *closure);
};
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);
gdrr_sem_stmts_t *(*sem_cons)(void *closure, gdrr_sem_stmt_t *hd,
gdrr_sem_stmts_t *tl);
gdrr_sem_stmts_t *(*sem_nil)(void *closure);
};
struct gdrr_sem_stmts_list_callbacks {
gdrr_sem_stmts_t *(*list_next)(gdrr_sem_stmt_t *next, gdrr_sem_stmts_t *list);
gdrr_sem_stmts_t *(*list_init)(void);
gdrr_sem_stmts_t *(*list_next)(void *closure, gdrr_sem_stmt_t *next,
gdrr_sem_stmts_t *list);
gdrr_sem_stmts_t *(*list_init)(void *closure);
};
enum gdrr_config_stmts_handling {
......@@ -137,6 +145,7 @@ struct gdrr_config {
};
} callbacks;
enum gdrr_config_stmts_handling gdrr_config_stmts_handling;
void *closure;
};
gdrr_sem_stmts_t *gdrr_convert(__obj semantics, struct gdrr_config *config);
......
......@@ -38,32 +38,33 @@ static gdrr_sem_id_t *gdrr_convert_sem_id(__obj sem_id_obj,
switch(__CASETAGCON(sem_id_obj)) {
case __VIRT_EQ: {
sem_id = config->callbacks.sem_id.virt_eq();
sem_id = config->callbacks.sem_id.virt_eq(config->closure);
break;
}
case __VIRT_NEQ: {
sem_id = config->callbacks.sem_id.virt_neq();
sem_id = config->callbacks.sem_id.virt_neq(config->closure);
break;
}
case __VIRT_LES: {
sem_id = config->callbacks.sem_id.virt_les();
sem_id = config->callbacks.sem_id.virt_les(config->closure);
break;
}
case __VIRT_LEU: {
sem_id = config->callbacks.sem_id.virt_leu();
sem_id = config->callbacks.sem_id.virt_leu(config->closure);
break;
}
case __VIRT_LTS: {
sem_id = config->callbacks.sem_id.virt_lts();
sem_id = config->callbacks.sem_id.virt_lts(config->closure);
break;
}
case __VIRT_LTU: {
sem_id = config->callbacks.sem_id.virt_ltu();
sem_id = config->callbacks.sem_id.virt_ltu(config->closure);
break;
}
case __VIRT_T: {
__obj this = __DECON(sem_id_obj);
sem_id = config->callbacks.sem_id.virt_t(__CASETAGINT(this));
sem_id = config->callbacks.sem_id.virt_t(config->closure,
__CASETAGINT(this));
break;
}
}
......@@ -78,8 +79,8 @@ static gdrr_sem_var_t *gdrr_convert_sem_address(__obj sem_address_obj,
__obj size = __RECORD_SELECT(rec, ___id);
__obj address = __RECORD_SELECT(rec, ___offset);
return config->callbacks.sem_address.sem_address(__CASETAGINT(size),
gdrr_convert_sem_linear(address, config));
return config->callbacks.sem_address.sem_address(config->closure,
__CASETAGINT(size), gdrr_convert_sem_linear(address, config));
}
static gdrr_sem_var_t *gdrr_convert_sem_var(__obj sem_var_obj,
......@@ -89,8 +90,8 @@ static gdrr_sem_var_t *gdrr_convert_sem_var(__obj sem_var_obj,
__obj id = __RECORD_SELECT(rec, ___id);
__obj offset = __RECORD_SELECT(rec, ___offset);
return config->callbacks.sem_var.sem_var(gdrr_convert_sem_id(id, config),
__CASETAGINT(offset));
return config->callbacks.sem_var.sem_var(config->closure,
gdrr_convert_sem_id(id, config), __CASETAGINT(offset));
}
static gdrr_sem_id_t *gdrr_convert_sem_linear(__obj sem_linear_obj,
......@@ -102,19 +103,20 @@ static gdrr_sem_id_t *gdrr_convert_sem_linear(__obj sem_linear_obj,
switch(__CASETAGCON(sem_linear_obj)) {
case __SEM_LIN_VAR: {
sem_linear = config->callbacks.sem_linear.sem_lin_var(
sem_linear = config->callbacks.sem_linear.sem_lin_var(config->closure,
gdrr_convert_sem_var(payload, config));
break;
}
case __SEM_LIN_IMM: {
__obj imm = __RECORD_SELECT(payload, ___imm);
sem_linear = config->callbacks.sem_linear.sem_lin_imm(__CASETAGINT(imm));
sem_linear = config->callbacks.sem_linear.sem_lin_imm(config->closure,
__CASETAGINT(imm));
break;
}
case __SEM_LIN_ADD: {
__obj opnd1 = __RECORD_SELECT(payload, ___opnd1);
__obj opnd2 = __RECORD_SELECT(payload, ___opnd2);
sem_linear = config->callbacks.sem_linear.sem_lin_add(
sem_linear = config->callbacks.sem_linear.sem_lin_add(config->closure,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -122,7 +124,7 @@ static gdrr_sem_id_t *gdrr_convert_sem_linear(__obj sem_linear_obj,
case __SEM_LIN_SUB: {
__obj opnd1 = __RECORD_SELECT(payload, ___opnd1);
__obj opnd2 = __RECORD_SELECT(payload, ___opnd2);
sem_linear = config->callbacks.sem_linear.sem_lin_sub(
sem_linear = config->callbacks.sem_linear.sem_lin_sub(config->closure,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -130,8 +132,8 @@ static gdrr_sem_id_t *gdrr_convert_sem_linear(__obj sem_linear_obj,
case __SEM_LIN_SCALE: {
__obj imm = __RECORD_SELECT(payload, ___imm);
__obj opnd = __RECORD_SELECT(payload, ___opnd);
sem_linear = config->callbacks.sem_linear.sem_lin_scale(__CASETAGINT(imm),
gdrr_convert_sem_linear(opnd, config));
sem_linear = config->callbacks.sem_linear.sem_lin_scale(config->closure,
__CASETAGINT(imm), gdrr_convert_sem_linear(opnd, config));
break;
}
}
......@@ -151,14 +153,14 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
switch(__CASETAGCON(sem_op_obj)) {
case __SEM_LIN: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
sem_op = config->callbacks.sem_op.sem_lin(size_word,
sem_op = config->callbacks.sem_op.sem_lin(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config));
break;
}
case __SEM_MUL: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_mul(size_word,
sem_op = config->callbacks.sem_op.sem_mul(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -166,7 +168,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_DIV: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_div(size_word,
sem_op = config->callbacks.sem_op.sem_div(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -174,7 +176,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_DIVS: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_divs(size_word,
sem_op = config->callbacks.sem_op.sem_divs(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -182,7 +184,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_MOD: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_mod(size_word,
sem_op = config->callbacks.sem_op.sem_mod(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -190,7 +192,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_SHL: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_shl(size_word,
sem_op = config->callbacks.sem_op.sem_shl(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -198,7 +200,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_SHR: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_shr(size_word,
sem_op = config->callbacks.sem_op.sem_shr(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -206,7 +208,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_SHRS: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_shrs(size_word,
sem_op = config->callbacks.sem_op.sem_shrs(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -214,7 +216,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_AND: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_and(size_word,
sem_op = config->callbacks.sem_op.sem_and(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -222,7 +224,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_OR: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_or(size_word,
sem_op = config->callbacks.sem_op.sem_or(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -230,7 +232,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_XOR: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_xor(size_word,
sem_op = config->callbacks.sem_op.sem_xor(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -238,21 +240,21 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_SX: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj fromsize = __RECORD_SELECT(rec, ___fromsize);
sem_op = config->callbacks.sem_op.sem_sx(size_word,
sem_op = config->callbacks.sem_op.sem_sx(config->closure, size_word,
__CASETAGINT(fromsize), gdrr_convert_sem_linear(opnd1, config));
break;
}
case __SEM_ZX: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj fromsize = __RECORD_SELECT(rec, ___fromsize);
sem_op = config->callbacks.sem_op.sem_zx(size_word,
sem_op = config->callbacks.sem_op.sem_zx(config->closure, size_word,
__CASETAGINT(fromsize), gdrr_convert_sem_linear(opnd1, config));
break;
}
case __SEM_CMPEQ: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_cmpeq(size_word,
sem_op = config->callbacks.sem_op.sem_cmpeq(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -260,7 +262,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_CMPNEQ: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_cmpneq(size_word,
sem_op = config->callbacks.sem_op.sem_cmpneq(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -268,7 +270,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_CMPLES: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_cmples(size_word,
sem_op = config->callbacks.sem_op.sem_cmples(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -276,7 +278,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_CMPLEU: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_cmpleu(size_word,
sem_op = config->callbacks.sem_op.sem_cmpleu(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -284,7 +286,7 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_CMPLTS: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_cmplts(size_word,
sem_op = config->callbacks.sem_op.sem_cmplts(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
......@@ -292,13 +294,13 @@ static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
case __SEM_CMPLTU: {
__obj opnd1 = __RECORD_SELECT(rec, ___opnd1);
__obj opnd2 = __RECORD_SELECT(rec, ___opnd2);
sem_op = config->callbacks.sem_op.sem_cmpltu(size_word,
sem_op = config->callbacks.sem_op.sem_cmpltu(config->closure, size_word,
gdrr_convert_sem_linear(opnd1, config),
gdrr_convert_sem_linear(opnd2, config));
break;
}
case __SEM_ARB: {
sem_op = config->callbacks.sem_op.sem_arb(size_word);
sem_op = config->callbacks.sem_op.sem_arb(config->closure, size_word);
break;
}
}
......@@ -312,15 +314,18 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_branch_hint(__obj sem_branch_hint_obj,
switch(__CASETAGCON(sem_branch_hint_obj)) {
case __HINT_JUMP: {
sem_branch_hint = config->callbacks.sem_branch_hint.hint_jump();
sem_branch_hint = config->callbacks.sem_branch_hint.hint_jump(
config->closure);
break;
}
case __HINT_CALL: {
sem_branch_hint = config->callbacks.sem_branch_hint.hint_call();
sem_branch_hint = config->callbacks.sem_branch_hint.hint_call(
config->closure);
break;
}
case __HINT_RET: {
sem_branch_hint = config->callbacks.sem_branch_hint.hint_ret();
sem_branch_hint = config->callbacks.sem_branch_hint.hint_ret(
config->closure);
break;
}
}
......@@ -337,7 +342,7 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
case __SEM_ASSIGN: {
__obj lhs = __RECORD_SELECT(rec, ___lhs);
__obj rhs = __RECORD_SELECT(rec, ___rhs);
sem_stmt = config->callbacks.sem_stmt.sem_assign(
sem_stmt = config->callbacks.sem_stmt.sem_assign(config->closure,
gdrr_convert_sem_var(lhs, config), gdrr_convert_sem_op(rhs, config));
break;
}
......@@ -345,7 +350,7 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
__obj lhs = __RECORD_SELECT(rec, ___lhs);
__obj size = __RECORD_SELECT(rec, ___size);
__obj address = __RECORD_SELECT(rec, ___address);
sem_stmt = config->callbacks.sem_stmt.sem_load(
sem_stmt = config->callbacks.sem_stmt.sem_load(config->closure,
gdrr_convert_sem_var(lhs, config), __CASETAGINT(size),
gdrr_convert_sem_address(address, config));
break;
......@@ -353,7 +358,7 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
case __SEM_STORE: {
__obj address = __RECORD_SELECT(rec, ___address);
__obj rhs = __RECORD_SELECT(rec, ___rhs);
sem_stmt = config->callbacks.sem_stmt.sem_store(
sem_stmt = config->callbacks.sem_stmt.sem_store(config->closure,
gdrr_convert_sem_address(address, config),
gdrr_convert_sem_op(rhs, config));
break;
......@@ -362,7 +367,7 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
__obj cond = __RECORD_SELECT(rec, ___cond);
__obj then_branch = __RECORD_SELECT(rec, ___then_branch);
__obj else_branch = __RECORD_SELECT(rec, ___else_branch);
sem_stmt = config->callbacks.sem_stmt.sem_ite(
sem_stmt = config->callbacks.sem_stmt.sem_ite(config->closure,
gdrr_convert_sem_linear(cond, config),
gdrr_convert_sem_stmts_with_config(then_branch, config),
gdrr_convert_sem_stmts_with_config(else_branch, config));
......@@ -371,7 +376,7 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
case __SEM_WHILE: {
__obj cond = __RECORD_SELECT(rec, ___cond);
__obj body = __RECORD_SELECT(rec, ___body);
sem_stmt = config->callbacks.sem_stmt.sem_while(
sem_stmt = config->callbacks.sem_stmt.sem_while(config->closure,
gdrr_convert_sem_linear(cond, config),
gdrr_convert_sem_stmts_with_config(body, config));
break;
......@@ -380,7 +385,7 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
__obj cond = __RECORD_SELECT(rec, ___cond);
__obj target_true = __RECORD_SELECT(rec, ___target_true);
__obj target_false = __RECORD_SELECT(rec, ___target_false);
sem_stmt = config->callbacks.sem_stmt.sem_cbranch(
sem_stmt = config->callbacks.sem_stmt.sem_cbranch(config->closure,
gdrr_convert_sem_linear(cond, config),
gdrr_convert_sem_address(target_true, config),
gdrr_convert_sem_address(target_false, config));
......@@ -389,7 +394,7 @@ 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(
sem_stmt = config->callbacks.sem_stmt.sem_branch(config->closure,
gdrr_convert_sem_branch_hint(hint, config),
gdrr_convert_sem_address(target, config));
break;
......@@ -411,16 +416,17 @@ static gdrr_sem_stmts_t *gdrr_convert_sem_stmts(__obj sem_stmts_obj,
gdrr_sem_stmts_t *tl = gdrr_convert_sem_stmts(tl_obj, config);
gdrr_sem_stmt_t *hd = gdrr_convert_sem_stmt(instr, config);
sem_stmts = config->callbacks.sem_stmts.sem_cons(hd, tl);
sem_stmts = config->callbacks.sem_stmts.sem_cons(config->closure, hd, tl);
} else
sem_stmts = config->callbacks.sem_stmts.sem_nil();
sem_stmts = config->callbacks.sem_stmts.sem_nil(config->closure);
return sem_stmts;
}
static gdrr_sem_stmts_t *gdrr_convert_sem_stmts_list(__obj sem_stmts_obj,
struct gdrr_config *config) {
gdrr_sem_stmts_t *list = config->callbacks.sem_stmts_list.list_init();
gdrr_sem_stmts_t *list = config->callbacks.sem_stmts_list.list_init(
config->closure);
while(__CASETAGCON(sem_stmts_obj) == __SEM_CONS) {
__obj rec = __DECON(sem_stmts_obj);
......@@ -428,7 +434,8 @@ static gdrr_sem_stmts_t *gdrr_convert_sem_stmts_list(__obj sem_stmts_obj,
__obj tl_obj = __RECORD_SELECT(rec, ___tl);
gdrr_sem_stmt_t *next = gdrr_convert_sem_stmt(instr, config);
list = config->callbacks.sem_stmts_list.list_next(next, list);
list = config->callbacks.sem_stmts_list.list_next(config->closure, next,
list);
sem_stmts_obj = tl_obj;
}
......
......@@ -7,221 +7,221 @@
#include <gdrr.h>
// sem_id
static gdrr_sem_id_t *virt_eq(void) {
static gdrr_sem_id_t *virt_eq(void *closure) {
printf("=> virt_eq\n");
return NULL;
}
static gdrr_sem_id_t *virt_neq(void) {
static gdrr_sem_id_t *virt_neq(void *closure) {
printf("=> virt_neq\n");
return NULL;
}
static gdrr_sem_id_t *virt_les(void) {
static gdrr_sem_id_t *virt_les(void *closure) {
printf("=> virt_les\n");
return NULL;
}
static gdrr_sem_id_t *virt_leu(void) {
static gdrr_sem_id_t *virt_leu(void *closure) {
printf("=> virt_leu\n");
return NULL;
}
static gdrr_sem_id_t *virt_lts(void) {
static gdrr_sem_id_t *virt_lts(void *closure) {
printf("=> virt_lts\n");
return NULL;
}
static gdrr_sem_id_t *virt_ltu(void) {
static gdrr_sem_id_t *virt_ltu(void *closure) {
printf("=> virt_ltu\n");
return NULL;
}