aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-11-19 19:59:53 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2023-11-19 19:59:53 +0200
commit17a27d445295bbaf7c7c470b1e4648635af2f0a3 (patch)
tree2749eacfe577afc1902826a99a4437bfc8419f05 /include
parent8f754f8b13e55e4bb92d72f105c5aaaba1754b7d (diff)
downloadek-17a27d445295bbaf7c7c470b1e4648635af2f0a3.tar.gz
ek-17a27d445295bbaf7c7c470b1e4648635af2f0a3.zip
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
Diffstat (limited to 'include')
-rw-r--r--include/ek/ops.h48
1 files changed, 46 insertions, 2 deletions
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 <ek/ast.h>
-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 */