From 52f11023c80d9b0116246c5c9f1a279361276710 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Mon, 9 Dec 2024 13:28:58 +0000 Subject: [PATCH] common: add instruction and opcode definitions; interface for manipulating selectors --- common/include/ivy/opcode.h | 97 +++++++++++++++++++++++++++++++++++ common/include/ivy/selector.h | 23 +++++++++ common/selector.c | 0 3 files changed, 120 insertions(+) create mode 100644 common/include/ivy/opcode.h create mode 100644 common/include/ivy/selector.h create mode 100644 common/selector.c diff --git a/common/include/ivy/opcode.h b/common/include/ivy/opcode.h new file mode 100644 index 0000000..fec7415 --- /dev/null +++ b/common/include/ivy/opcode.h @@ -0,0 +1,97 @@ +#ifndef IVY_OPCODE_H_ +#define IVY_OPCODE_H_ + +enum ivy_instr_id { + IVY_INSTR_NONE = 0, + IVY_INSTR_LDR, + IVY_INSTR_STR, + IVY_INSTR_PUSH, + IVY_INSTR_POP, + IVY_INSTR_MSG, + IVY_INSTR_ADD, + IVY_INSTR_SUB, + IVY_INSTR_MUL, + IVY_INSTR_DIV, + IVY_INSTR_CMP, + IVY_INSTR_C_EQ, + IVY_INSTR_C_NE, + IVY_INSTR_C_LT, + IVY_INSTR_C_LE, + IVY_INSTR_C_GT, + IVY_INSTR_C_GE, + IVY_INSTR_BR, + IVY_INSTR_B_Z, + IVY_INSTR_B_NZ, + IVY_INSTR_B_EQ, + IVY_INSTR_B_NE, + IVY_INSTR_B_LT, + IVY_INSTR_B_LE, + IVY_INSTR_B_GT, + IVY_INSTR_B_GE, + IVY_INSTR_OB_C, + IVY_INSTR_OB_E, + IVY_INSTR_LAM_C, + IVY_INSTR_IT_G, + IVY_INSTR_IT_N, + IVY_INSTR_IT_V, + IVY_INSTR_RET, + IVY_INSTR_RET_N, +}; + +enum ivy_opcode { + IVY_OP_NONE = 0, + + IVY_OP_LDR_SP, + IVY_OP_LDR_BP, + IVY_OP_LDR_SELF, + IVY_OP_LDR_IMM, + IVY_OP_LDR_POOL, + + IVY_OP_STR_SP, + IVY_OP_STR_BP, + IVY_OP_STR_SELF, + + IVY_OP_PUSH, + IVY_OP_POP, + + IVY_OP_MSG_R, + IVY_OP_MSG_I, + + IVY_OP_ADD, + IVY_OP_SUB, + IVY_OP_MUL, + IVY_OP_DIV, + + IVY_OP_CMP, + + IVY_OP_C_EQ, + IVY_OP_C_NE, + IVY_OP_C_LT, + IVY_OP_C_LE, + IVY_OP_C_GT, + IVY_OP_C_GE, + + IVY_OP_BR, + IVY_OP_B_Z, + IVY_OP_B_NZ, + IVY_OP_B_EQ, + IVY_OP_B_NE, + IVY_OP_B_LT, + IVY_OP_B_LE, + IVY_OP_B_GT, + IVY_OP_B_GE, + + IVY_OP_OB_C, + IVY_OP_OB_E, + + IVY_OP_LAM_C, + + IVY_OP_IT_G, + IVY_OP_IT_N, + IVY_OP_IT_V, + + IVY_OP_RET, + IVY_OP_RET_N, +}; + +#endif diff --git a/common/include/ivy/selector.h b/common/include/ivy/selector.h new file mode 100644 index 0000000..d307c54 --- /dev/null +++ b/common/include/ivy/selector.h @@ -0,0 +1,23 @@ +#ifndef IVY_SELECTOR_H_ +#define IVY_SELECTOR_H_ + +#include + +enum ivy_selector_recipient { + IVY_SEL_NONE = 0, + IVY_SEL_CLASS, + IVY_SEL_OBJECT, +}; + +struct ivy_selector; + +extern enum ivy_status ivy_selector_create(struct ivy_selector **sel); +extern void ivy_selector_destroy(struct ivy_selector *sel); + +extern void ivy_selector_set_recipient( + struct ivy_selector *sel, enum ivy_selector_recipient r); +extern void ivy_selector_set_name(struct ivy_selector *sel, const char *name); +extern void ivy_selector_add_arg( + struct ivy_selector *sel, const char *label, const char *name); + +#endif diff --git a/common/selector.c b/common/selector.c new file mode 100644 index 0000000..e69de29