Commit 4e837607 authored by Julian Kranz's avatar Julian Kranz

Gdrr

X86 Specification

- Continued to implement gdrr
- Cleanup
parent ea4f0504
/*
* gdrr.h
*
* Created on: Feb 22, 2013
* Author: jucs
*/
#ifndef GDRR_CALLBACKS_H_
#define GDRR_CALLBACKS_H_
#include <gdrr_types.h>
struct gdrr_sem_id_callbacks {
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)(void *closure, __word size,
gdrr_sem_linear_t *address);
};
struct gdrr_sem_var_callbacks {
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)(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)(void *closure, gdrr_sem_linear_t *opnd1,
gdrr_sem_linear_t *opnd2);
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)(void *closure, __word size,
gdrr_sem_linear_t *opnd1);
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_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)(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)(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)(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)(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 *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)(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)(void *closure, gdrr_sem_stmt_t *next,
gdrr_sem_stmts_t *list);
gdrr_sem_stmts_t *(*list_init)(void *closure);
};
#endif /* GDRR_CALLBACKS_H_ */
/*
* gdrr_config.h
*
* Created on: Mar 10, 2013
* Author: jucs
*/
#ifndef GDRR_CONFIG_H_
#define GDRR_CONFIG_H_
#include "gdrr_callbacks.h"
#include "x86_callbacks.h"
enum gdrr_config_stmts_handling {
GDRR_CONFIG_STMTS_HANDLING_RECURSIVE, GDRR_CONFIG_STMTS_HANDLING_LIST
};
struct gdrr_config {
struct {
struct gdrr_sem_id_callbacks sem_id;
struct gdrr_sem_address_callbacks sem_address;
struct gdrr_sem_var_callbacks sem_var;
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;
};
union {
struct gdrr_x86_callbacks x86;
} arch;
} callbacks;
enum gdrr_config_stmts_handling gdrr_config_stmts_handling;
void *closure;
};
#endif /* GDRR_CONFIG_H_ */
/*
* gdrr_types.h
*
* Created on: Mar 10, 2013
* Author: jucs
*/
#ifndef GDRR_TYPES_H_
#define GDRR_TYPES_H_
typedef void gdrr_sem_id_t;
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_sem_stmts_t;
#endif /* GDRR_TYPES_H_ */
/*
* x86.h
*
* Created on: Mar 10, 2013
* Author: jucs
*/
#ifndef X86_H_
#define X86_H_
#include "gdrr.h"
gdrr_sem_id_t *gdrr_convert_sem_id_x86(__obj sem_id_obj,
struct gdrr_config *config);
#endif /* X86_H_ */
/*
* x86.h
*
* Created on: Mar 10, 2013
* Author: jucs
*/
#ifndef X86_CALLBACKS_H_
#define X86_CALLBACKS_H_
#include <gdrr_types.h>
struct gdrr_sem_id_x86_callbacks {
gdrr_sem_id_t *(*sem_ip)(void *closure);
gdrr_sem_id_t *(*sem_flags)(void *closure);
gdrr_sem_id_t *(*sem_mxcsr)(void *closure);
gdrr_sem_id_t *(*sem_ax)(void *closure);
gdrr_sem_id_t *(*sem_bx)(void *closure);
gdrr_sem_id_t *(*sem_cx)(void *closure);
gdrr_sem_id_t *(*sem_dx)(void *closure);
gdrr_sem_id_t *(*sem_si)(void *closure);
gdrr_sem_id_t *(*sem_di)(void *closure);
gdrr_sem_id_t *(*sem_sp)(void *closure);
gdrr_sem_id_t *(*sem_bp)(void *closure);
gdrr_sem_id_t *(*sem_r8)(void *closure);
gdrr_sem_id_t *(*sem_r9)(void *closure);
gdrr_sem_id_t *(*sem_r10)(void *closure);
gdrr_sem_id_t *(*sem_r11)(void *closure);
gdrr_sem_id_t *(*sem_r12)(void *closure);
gdrr_sem_id_t *(*sem_r13)(void *closure);
gdrr_sem_id_t *(*sem_r14)(void *closure);
gdrr_sem_id_t *(*sem_r15)(void *closure);
gdrr_sem_id_t *(*sem_cs)(void *closure);
gdrr_sem_id_t *(*sem_ds)(void *closure);
gdrr_sem_id_t *(*sem_ss)(void *closure);
gdrr_sem_id_t *(*sem_es)(void *closure);
gdrr_sem_id_t *(*sem_fs)(void *closure);
gdrr_sem_id_t *(*sem_gs)(void *closure);
gdrr_sem_id_t *(*sem_st0)(void *closure);
gdrr_sem_id_t *(*sem_st1)(void *closure);
gdrr_sem_id_t *(*sem_st2)(void *closure);
gdrr_sem_id_t *(*sem_st3)(void *closure);
gdrr_sem_id_t *(*sem_st4)(void *closure);
gdrr_sem_id_t *(*sem_st5)(void *closure);
gdrr_sem_id_t *(*sem_st6)(void *closure);
gdrr_sem_id_t *(*sem_st7)(void *closure);
gdrr_sem_id_t *(*sem_mm0)(void *closure);
gdrr_sem_id_t *(*sem_mm1)(void *closure);
gdrr_sem_id_t *(*sem_mm2)(void *closure);
gdrr_sem_id_t *(*sem_mm3)(void *closure);
gdrr_sem_id_t *(*sem_mm4)(void *closure);
gdrr_sem_id_t *(*sem_mm5)(void *closure);
gdrr_sem_id_t *(*sem_mm6)(void *closure);
gdrr_sem_id_t *(*sem_mm7)(void *closure);
gdrr_sem_id_t *(*sem_xmm0)(void *closure);
gdrr_sem_id_t *(*sem_xmm1)(void *closure);
gdrr_sem_id_t *(*sem_xmm2)(void *closure);
gdrr_sem_id_t *(*sem_xmm3)(void *closure);
gdrr_sem_id_t *(*sem_xmm4)(void *closure);
gdrr_sem_id_t *(*sem_xmm5)(void *closure);
gdrr_sem_id_t *(*sem_xmm6)(void *closure);
gdrr_sem_id_t *(*sem_xmm7)(void *closure);
gdrr_sem_id_t *(*sem_xmm8)(void *closure);
gdrr_sem_id_t *(*sem_xmm9)(void *closure);
gdrr_sem_id_t *(*sem_xmm10)(void *closure);
gdrr_sem_id_t *(*sem_xmm11)(void *closure);
gdrr_sem_id_t *(*sem_xmm12)(void *closure);
gdrr_sem_id_t *(*sem_xmm13)(void *closure);
gdrr_sem_id_t *(*sem_xmm14)(void *closure);
gdrr_sem_id_t *(*sem_xmm15)(void *closure);
};
struct gdrr_x86_callbacks {
struct gdrr_sem_id_x86_callbacks sem_id;
};
#endif /* X86_CALLBACKS_H_ */
......@@ -17,10 +17,234 @@ gdrr_sem_id_t *gdrr_convert_sem_id_x86(__obj sem_id_obj,
gdrr_sem_id_t *sem_id = NULL;
switch(__CASETAGCON(sem_id_obj)) {
case __Sem_IP: {
sem_id = config->callbacks.arch.x86.sem_id.sem_ip(config->closure);
break;
}
case __Sem_FLAGS: {
sem_id = config->callbacks.arch.x86.sem_id.sem_flags(config->closure);
break;
}
case __Sem_MXCSR: {
sem_id = config->callbacks.arch.x86.sem_id.sem_mxcsr(config->closure);
break;
}
case __Sem_AX: {
sem_id = config->callbacks.arch.x86.sem_id.sem_ax(config->closure);
break;
}
case __Sem_BX: {
sem_id = config->callbacks.arch.x86.sem_id.sem_bx(config->closure);
break;
}
case __Sem_CX: {
sem_id = config->callbacks.arch.x86.sem_id.sem_cx(config->closure);
break;
}
case __Sem_DX: {
sem_id = config->callbacks.arch.x86.sem_id.sem_dx(config->closure);
break;
}
case __Sem_SI: {
sem_id = config->callbacks.arch.x86.sem_id.sem_si(config->closure);
break;
}
case __Sem_DI: {
sem_id = config->callbacks.arch.x86.sem_id.sem_di(config->closure);
break;
}
case __Sem_SP: {
sem_id = config->callbacks.arch.x86.sem_id.sem_sp(config->closure);
break;
}
case __Sem_BP: {
sem_id = config->callbacks.arch.x86.sem_id.sem_bp(config->closure);
break;
}
case __Sem_R8: {
sem_id = config->callbacks.arch.x86.sem_id.sem_r8(config->closure);
break;
}
case __Sem_R9: {
sem_id = config->callbacks.arch.x86.sem_id.sem_r9(config->closure);
break;
}
case __Sem_R10: {
sem_id = config->callbacks.arch.x86.sem_id.sem_r10(config->closure);
break;
}
case __Sem_R11: {
sem_id = config->callbacks.arch.x86.sem_id.sem_r11(config->closure);
break;
}
case __Sem_R12: {
sem_id = config->callbacks.arch.x86.sem_id.sem_r12(config->closure);
break;
}
case __Sem_R13: {
sem_id = config->callbacks.arch.x86.sem_id.sem_r13(config->closure);
break;
}
case __Sem_R14: {
sem_id = config->callbacks.arch.x86.sem_id.sem_r14(config->closure);
break;
}
case __Sem_R15: {
sem_id = config->callbacks.arch.x86.sem_id.sem_r15(config->closure);
break;
}
case __Sem_CS: {
sem_id = config->callbacks.arch.x86.sem_id.sem_cs(config->closure);
break;
}
case __Sem_DS: {
sem_id = config->callbacks.arch.x86.sem_id.sem_ds(config->closure);
break;
}
case __Sem_SS: {
sem_id = config->callbacks.arch.x86.sem_id.sem_ss(config->closure);
break;
}
case __Sem_ES: {
sem_id = config->callbacks.arch.x86.sem_id.sem_es(config->closure);
break;
}
case __Sem_FS: {
sem_id = config->callbacks.arch.x86.sem_id.sem_fs(config->closure);
break;
}
case __Sem_GS: {
sem_id = config->callbacks.arch.x86.sem_id.sem_gs(config->closure);
break;
}
case __Sem_ST0: {
sem_id = config->callbacks.arch.x86.sem_id.sem_st0(config->closure);
break;
}
case __Sem_ST1: {
sem_id = config->callbacks.arch.x86.sem_id.sem_st1(config->closure);
break;
}
case __Sem_ST2: {
sem_id = config->callbacks.arch.x86.sem_id.sem_st2(config->closure);
break;
}
case __Sem_ST3: {
sem_id = config->callbacks.arch.x86.sem_id.sem_st3(config->closure);
break;
}
case __Sem_ST4: {
sem_id = config->callbacks.arch.x86.sem_id.sem_st4(config->closure);
break;
}
case __Sem_ST5: {
sem_id = config->callbacks.arch.x86.sem_id.sem_st5(config->closure);
break;
}
case __Sem_ST6: {
sem_id = config->callbacks.arch.x86.sem_id.sem_st6(config->closure);
break;
}
case __Sem_ST7: {
sem_id = config->callbacks.arch.x86.sem_id.sem_st7(config->closure);
break;
}
case __Sem_MM0: {
sem_id = config->callbacks.arch.x86.sem_id.sem_mm0(config->closure);
break;
}
case __Sem_MM1: {
sem_id = config->callbacks.arch.x86.sem_id.sem_mm1(config->closure);
break;
}
case __Sem_MM2: {
sem_id = config->callbacks.arch.x86.sem_id.sem_mm2(config->closure);
break;
}
case __Sem_MM3: {
sem_id = config->callbacks.arch.x86.sem_id.sem_mm3(config->closure);
break;
}
case __Sem_MM4: {
sem_id = config->callbacks.arch.x86.sem_id.sem_mm4(config->closure);
break;
}
case __Sem_MM5: {
sem_id = config->callbacks.arch.x86.sem_id.sem_mm5(config->closure);
break;
}
case __Sem_MM6: {
sem_id = config->callbacks.arch.x86.sem_id.sem_mm6(config->closure);
break;
}
case __Sem_MM7: {
sem_id = config->callbacks.arch.x86.sem_id.sem_mm7(config->closure);
break;
}
case __Sem_XMM0: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm0(config->closure);
break;
}
case __Sem_XMM1: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm1(config->closure);
break;
}
case __Sem_XMM2: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm2(config->closure);
break;
}
case __Sem_XMM3: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm3(config->closure);
break;
}
case __Sem_XMM4: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm4(config->closure);
break;
}
case __Sem_XMM5: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm5(config->closure);
break;
}
case __Sem_XMM6: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm6(config->closure);
break;
}
case __Sem_XMM7: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm7(config->closure);
break;
}
case __Sem_XMM8: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm8(config->closure);
break;
}
case __Sem_XMM9: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm9(config->closure);
break;
}
case __Sem_XMM10: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm10(config->closure);
break;
}
case __Sem_XMM11: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm11(config->closure);
break;
}
case __Sem_XMM12: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm12(config->closure);
break;
}
case __Sem_XMM13: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm13(config->closure);
break;
}
case __Sem_XMM14: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm14(config->closure);
break;
}
case __Sem_XMM15: {
sem_id = config->callbacks.arch.x86.sem_id.sem_xmm15(config->closure);
break;
}
}
return sem_id;
......
......@@ -257,7 +257,6 @@ val arch-show-id r = case r of
| Sem_MM5 : "MM5"
| Sem_MM6 : "MM6"
| Sem_MM7 : "MM7"
| Sem_MM8 : "MM8"
| Sem_XMM0 : "XMM0"
| Sem_XMM1 : "XMM1"
| Sem_XMM2 : "XMM2"
......
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