aboutsummaryrefslogtreecommitdiff
path: root/include/ssa
diff options
context:
space:
mode:
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 */