From 17a27d445295bbaf7c7c470b1e4648635af2f0a3 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 19 Nov 2023 19:59:53 +0200 Subject: first runnable test program + tests/pointer_literal.ek compiles down to very simple assembly that tasm can assemble and triscv run with correct results. Whopee + Did notice that void return functions should still have implicit return statements added --- include/ek/ops.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/ek/ops.h b/include/ek/ops.h index 330de0c..e913d37 100644 --- a/include/ek/ops.h +++ b/include/ek/ops.h @@ -3,12 +3,56 @@ #include -struct ops; +enum loc_kind { + LOC_NONE, LOC_REG, LOC_MEM +}; + +struct loc { + enum loc_kind kind; + struct loc *next; + size_t start; + size_t end; + size_t reg; + long long off; + size_t width; +}; + +enum opcode { + /* small subset for now */ + OP_LI, + OP_LA, + OP_ADD, + OP_ADDI, + OP_STT, + OP_LDT, + OP_STW, + OP_LDW, + OP_MV, /* kind of meta op, will be realized as either load/store or register move */ + OP_LABEL, + OP_COMMENT, +}; + +struct op { + enum opcode opcode; + struct loc inputs; + struct loc outputs; + size_t loc; + union { + long long constant; + const char *string; + }; + struct op *next; +}; + +struct ops { + struct op *base; + struct op *head; +}; struct ops *create_ops(); void destroy_ops(struct ops *ops); int lower_ops(struct scope *root, struct ops *ops); -int analyze_lifetime(struct ops *ops); +int alloc_regs(struct ops *ops); int print_asm(struct ops *ops, const char *output); #endif /* EK_OPS_H */ -- cgit v1.3