summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-05-18 23:01:12 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2025-05-18 23:01:12 +0300
commitf4083f86cabfa4b314ef6fb3e1f3df96e5dbd794 (patch)
tree094e97ae68aa3102b86d5d51dd99c38d968888ff /include
parent0e6bc60ceb3d2676fae166308668680a2f675d17 (diff)
downloadberg-f4083f86cabfa4b314ef6fb3e1f3df96e5dbd794.tar.gz
berg-f4083f86cabfa4b314ef6fb3e1f3df96e5dbd794.zip
initial full matrix multiplication
Diffstat (limited to 'include')
-rw-r--r--include/berg/vm.h63
1 files changed, 61 insertions, 2 deletions
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 */