aboutsummaryrefslogtreecommitdiff
path: root/include/ssa
diff options
context:
space:
mode:
Diffstat (limited to 'include/ssa')
-rw-r--r--include/ssa/ssa.h36
1 files changed, 30 insertions, 6 deletions
diff --git a/include/ssa/ssa.h b/include/ssa/ssa.h
index 16ceb25..32d1ba6 100644
--- a/include/ssa/ssa.h
+++ b/include/ssa/ssa.h
@@ -20,7 +20,7 @@ typedef enum {
SSA_FUNC_END,
SSA_PUSH,
SSA_CALL
-} SsaInstructionType;
+} SsaInstruction;
typedef enum {
SSA_NUMBER_TYPE_INTEGER,
@@ -42,7 +42,8 @@ typedef usize SsaFuncIndex;
typedef struct {
Buffer/*instruction data*/ instructions;
- HashMap/*<SsaNumberType, SsaIntermediateIndex>*/ intermediates;
+ HashMap/*<SsaNumber, SsaIntermediateIndex>*/ intermediates_map;
+ Buffer/*SsaNumber*/ intermediates;
HashMap/*<BufferView, SsaStringIndex>*/ strings;
SsaIntermediateIndex intermediate_counter;
SsaStringIndex string_counter;
@@ -50,28 +51,51 @@ typedef struct {
SsaFuncIndex func_counter;
} Ssa;
+typedef struct {
+ SsaRegister lhs;
+ u16 rhs;
+} SsaInsForm1;
+
+typedef struct {
+ SsaRegister result;
+ SsaRegister lhs;
+ SsaRegister rhs;
+} SsaInsForm2;
+
+typedef struct {
+ SsaFuncIndex func_index;
+ u8 num_args;
+} SsaInsFuncStart;
+
+typedef struct {
+ SsaRegister result;
+ FunctionDecl *func_decl;
+} SsaInsFuncCall;
+
/* None of these functions are thread-safe */
SsaNumber create_ssa_integer(i64 value);
SsaNumber create_ssa_float(f64 value);
+SsaNumber ssa_get_intermediate(Ssa *self, SsaIntermediateIndex 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, SsaInstructionType binop_type, SsaRegister lhs, SsaRegister rhs, SsaRegister *result);
+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, void *func, SsaRegister *result);
+CHECK_RESULT int ssa_ins_call(Ssa *self, FunctionDecl *func_decl, SsaRegister *result);
typedef struct {
jmp_buf env;
- Ssa ssa;
+ Ssa *ssa;
} SsaCompilerContext;
-/* longjump to compiler env on failure */
+/* longjump to context->env on failure */
void scope_generate_ssa(Scope *self, SsaCompilerContext *context);
#endif