asm: implement instruction assembly and emission

This commit is contained in:
2024-12-15 22:36:50 +00:00
parent 3ad355e58c
commit b67b861ecf
5 changed files with 397 additions and 65 deletions

View File

@@ -1,10 +1,21 @@
#ifndef IVY_ASM_INSTR_H_
#define IVY_ASM_INSTR_H_
#include <ivy/misc.h>
#include <ivy/opcode.h>
enum ivy_instr_layout {
IVY_INSTR_X = 0,
IVY_INSTR_D,
IVY_INSTR_R1,
IVY_INSTR_R1D,
IVY_INSTR_R2,
IVY_INSTR_R2D,
IVY_INSTR_R3,
};
enum ivy_instr_operand_type {
IVY_OPERAND_NONE = 0,
IVY_INSTR_OPERAND_NONE = 0,
IVY_INSTR_OPERAND_CONST,
IVY_INSTR_OPERAND_REGISTER,
IVY_INSTR_OPERAND_SELF_INDEX_REG,
@@ -19,15 +30,17 @@ enum ivy_instr_operand_type {
struct ivy_instr_definition {
enum ivy_instr_id i_id;
enum ivy_opcopde i_opcode;
enum ivy_instr_layout i_layout;
enum ivy_opcode i_opcode;
enum ivy_instr_operand_type i_operand[3];
};
struct ivy_instr {
enum ivy_opcode i_op;
long i_a0;
long i_a1;
long i_a2;
const struct ivy_instr_definition *i_op;
long i_arg[3];
};
IVY_API const struct ivy_instr_definition *ivy_instr_find(
enum ivy_instr_id id, const enum ivy_instr_operand_type operands[4]);
#endif