aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-03-14 21:24:44 +0100
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commitd4ca9de33906972fa06bd2b7e38cbc2b4d3574c2 (patch)
tree5e858b73db61a0f85ddfd02dd3076a8b3c8aa5af /include
parentad54d804fef1e1eb646d8ea4bd7ce65363e94fa8 (diff)
Add ssa string
Diffstat (limited to 'include')
-rw-r--r--include/ast.h2
-rw-r--r--include/ssa/ssa.h7
2 files changed, 8 insertions, 1 deletions
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 <setjmp.h>
@@ -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/*<SsaNumberType, IntermediateIndex>*/ intermediates;
+ HashMap/*<SsaNumberType, SsaIntermediateIndex>*/ intermediates;
+ HashMap/*<BufferView, SsaStringIndex>*/ 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);