aboutsummaryrefslogtreecommitdiff
path: root/include/ssa
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-06-07 10:47:47 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit53a331bc8b2fc33bd2b7e25a23b4128f89ee0b52 (patch)
tree2e5c0f4cda85b2afdb6142145fa7ded61d100f02 /include/ssa
parent1b68fdcf5aebf2bc53bbd9234c77aea243c0decd (diff)
Add assignment, while, extern, function signature type, start on bytecode
Diffstat (limited to 'include/ssa')
-rw-r--r--include/ssa/ssa.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/include/ssa/ssa.h b/include/ssa/ssa.h
index e1e2d01..15a9f78 100644
--- a/include/ssa/ssa.h
+++ b/include/ssa/ssa.h
@@ -16,10 +16,13 @@ typedef enum {
SSA_SUB,
SSA_MUL,
SSA_DIV,
+ SSA_EQUALS,
SSA_FUNC_START,
SSA_FUNC_END,
SSA_PUSH,
- SSA_CALL
+ SSA_CALL,
+ SSA_JUMP_ZERO,
+ SSA_JUMP
} SsaInstruction;
typedef enum {
@@ -35,10 +38,11 @@ typedef struct {
SsaNumberType type;
} SsaNumber;
+typedef i16 JumpOffset;
typedef u16 SsaRegister;
typedef u16 SsaIntermediateIndex;
typedef u16 SsaStringIndex;
-typedef usize SsaFuncIndex;
+typedef u16 SsaFuncIndex;
typedef struct {
Buffer/*instruction data*/ instructions;
@@ -73,6 +77,15 @@ typedef struct {
FunctionDecl *func_decl;
} SsaInsFuncCall;
+typedef struct {
+ SsaRegister condition_reg;
+ JumpOffset jump_offset;
+} SsaInsJumpZero;
+
+typedef struct {
+ JumpOffset jump_offset;
+} SsaInsJump;
+
/* None of these functions are thread-safe */
SsaNumber create_ssa_integer(i64 value);
SsaNumber create_ssa_float(f64 value);
@@ -81,20 +94,11 @@ SsaNumber ssa_get_intermediate(Ssa *self, SsaIntermediateIndex index);
BufferView ssa_get_string(Ssa *self, SsaStringIndex index);
CHECK_RESULT int ssa_init(Ssa *self, ScopedAllocator *allocator);
-CHECK_RESULT int ssa_get_unique_reg(Ssa *self, SsaRegister *result);
-CHECK_RESULT int ssa_ins_assign_inter(Ssa *self, SsaRegister dest, SsaNumber number);
-CHECK_RESULT int ssa_ins_assign_string(Ssa *self, SsaRegister dest, BufferView str);
-CHECK_RESULT int ssa_ins_assign_reg(Ssa *self, SsaRegister dest, SsaRegister src);
-CHECK_RESULT int ssa_ins_binop(Ssa *self, SsaInstruction binop_type, SsaRegister lhs, SsaRegister rhs, SsaRegister *result);
-CHECK_RESULT int ssa_ins_func_start(Ssa *self, u8 num_args, SsaFuncIndex *result);
-CHECK_RESULT int ssa_ins_func_end(Ssa *self);
-CHECK_RESULT int ssa_ins_push(Ssa *self, SsaRegister reg);
-CHECK_RESULT int ssa_ins_call(Ssa *self, FunctionDecl *func_decl, SsaRegister *result);
-
typedef struct {
jmp_buf env;
Ssa *ssa;
+ amal_compiler *compiler;
} SsaCompilerContext;
/* longjump to context->env on failure */