From d4ca9de33906972fa06bd2b7e38cbc2b4d3574c2 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 14 Mar 2019 21:24:44 +0100 Subject: Add ssa string --- include/ast.h | 2 ++ include/ssa/ssa.h | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/ast.h b/include/ast.h index b63dab5..ae9b6b3 100644 --- a/include/ast.h +++ b/include/ast.h @@ -8,6 +8,7 @@ #include "std/scoped_allocator.h" #include "std/hash_map.h" #include "binop_type.h" +#include "ssa/ssa.h" #include @@ -67,6 +68,7 @@ struct Scope { struct FunctionDecl { Scope body; + SsaFuncIndex ssa_func_index; }; struct FunctionCall { diff --git a/include/ssa/ssa.h b/include/ssa/ssa.h index 5411259..c374ffb 100644 --- a/include/ssa/ssa.h +++ b/include/ssa/ssa.h @@ -10,6 +10,7 @@ typedef enum { SSA_ASSIGN_INTER, + SSA_ASSIGN_STRING, SSA_ASSIGN_REG, SSA_ADD, SSA_SUB, @@ -36,12 +37,15 @@ typedef struct { typedef u16 SsaRegister; typedef u16 SsaIntermediateIndex; +typedef u16 SsaStringIndex; typedef u32 SsaFuncIndex; typedef struct { Buffer/*instruction data*/ instructions; - HashMap/**/ intermediates; + HashMap/**/ intermediates; + HashMap/**/ strings; SsaIntermediateIndex intermediate_counter; + SsaStringIndex string_counter; SsaRegister reg_counter; SsaFuncIndex func_counter; } Ssa; @@ -53,6 +57,7 @@ SsaNumber create_ssa_float(f64 value); 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_func_start(Ssa *self, u8 num_args, SsaFuncIndex *result); -- cgit v1.2.3