From f4083f86cabfa4b314ef6fb3e1f3df96e5dbd794 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 18 May 2025 23:01:12 +0300 Subject: initial full matrix multiplication --- include/berg/vm.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/berg/vm.h b/include/berg/vm.h index 0f87452..66a7f06 100644 --- a/include/berg/vm.h +++ b/include/berg/vm.h @@ -15,13 +15,22 @@ enum berg_envcall { enum berg_op { BERG_LABEL, - BERG_LD32, - BERG_ST32, + BERG_LDXR_I32, + BERG_STXR_32, BERG_CALL, BERG_RET, BERG_ECALL, BERG_MOVI, BERG_MOVR, + + BERG_ADDR, + BERG_ADDI, + BERG_LSHI, + + BERG_MULR, + + BERG_BGER, + BERG_JMP, }; const char *berg_op_str(enum berg_op op); @@ -55,6 +64,14 @@ struct berg_operand { struct berg_gpr gpr; }; +struct berg_reloc { + size_t r; +}; + +struct berg_label { + size_t l; +}; + static inline struct berg_operand berg_operand_gpr(struct berg_gpr gpr, enum berg_type type) { return (struct berg_operand){.type = type, .gpr = gpr}; @@ -99,6 +116,48 @@ long berg_movr(struct berg_func *f, struct berg_gpr ra, struct berg_gpr rb); +long berg_mulr(struct berg_func *f, + struct berg_gpr ra, + struct berg_gpr rb, + struct berg_gpr rc); + +long berg_addr(struct berg_func *f, + struct berg_gpr ra, + struct berg_gpr rb, + struct berg_gpr rc); + +long berg_stxr_32(struct berg_func *f, + struct berg_gpr rb, + struct berg_gpr rc, + struct berg_gpr rd); + +long berg_ldxr_i32(struct berg_func *f, + struct berg_gpr rb, + struct berg_gpr rc, + struct berg_gpr rd); + +long berg_addi(struct berg_func *f, + struct berg_gpr ra, + struct berg_gpr rb, + int64_t imm); + +long berg_lshi(struct berg_func *f, + struct berg_gpr ra, + struct berg_gpr rb, + int64_t imm); + +void berg_patch(struct berg_func *f, + struct berg_reloc r, + struct berg_label l); + +struct berg_reloc berg_bger(struct berg_func *f, + struct berg_gpr rb, + struct berg_gpr rc); + +struct berg_reloc berg_jmp(struct berg_func *f); + +struct berg_label berg_label(struct berg_func *f); + long berg_ret(struct berg_func *f); #endif /* BERG_VM_H */ -- cgit v1.2.3