aboutsummaryrefslogtreecommitdiff
path: root/include/ssa
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-09-09 01:08:34 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit16aaaa19a3ef4220726007d3e644ced0c9e06513 (patch)
tree6a7c2fc91bc362559b079afbb10dc247d7bcbae0 /include/ssa
parentde48503aef098d855754ab6f85558402130188d7 (diff)
Allow referencing code in imported file (right now for function calls, allow calling a function in another file)
Diffstat (limited to 'include/ssa')
-rw-r--r--include/ssa/ssa.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/ssa/ssa.h b/include/ssa/ssa.h
index 9d6949d..0b6501b 100644
--- a/include/ssa/ssa.h
+++ b/include/ssa/ssa.h
@@ -10,6 +10,7 @@
#define SSA_ERR_EXTERN_FUNC_SIG_MISMATCH -20
+/* Important: The number of fields in this enum can't exceed 255 */
typedef enum {
SSA_ASSIGN_INTER,
SSA_ASSIGN_STRING,
@@ -24,6 +25,7 @@ typedef enum {
SSA_FUNC_START,
SSA_FUNC_END,
SSA_PUSH,
+ SSA_PUSH_RET,
SSA_CALL,
SSA_CALL_EXTERN,
SSA_JUMP_ZERO,
@@ -55,6 +57,10 @@ typedef struct {
BufferView name;
} SsaExportFunc;
+typedef struct {
+ FunctionSignature *func_sig;
+} SsaFunc;
+
typedef i16 JumpOffset;
typedef i16 SsaRegister;
typedef u16 SsaIntermediateIndex;
@@ -73,13 +79,15 @@ typedef struct {
HashMapType(BufferView, SsaExternFuncIndex) extern_funcs_map;
Buffer/*SsaExternFunc*/ extern_funcs;
Buffer/*SsaExportFunc*/ export_funcs;
+ Buffer/*SsaFunc*/ funcs;
+
SsaIntermediateIndex intermediate_counter;
SsaStringIndex string_counter;
SsaExternFuncIndex extern_func_counter;
SsaExportFuncIndex export_func_counter;
+ SsaFuncIndex func_counter;
SsaRegister reg_counter;
SsaRegister param_counter;
- SsaFuncIndex func_counter;
SsaLabelIndex label_counter;
Parser *parser; /* Borrowed */
} Ssa;
@@ -102,14 +110,14 @@ typedef struct {
typedef struct {
u8 num_args;
- SsaRegister result;
FunctionDecl *func_decl;
+ u8 import_index;
} SsaInsFuncCall;
typedef struct {
u8 num_args;
- SsaRegister result;
- SsaExternFuncIndex extern_func_index;
+ LhsExpr *func_decl_lhs;
+ int import_index;
} SsaInsFuncCallExtern;
typedef struct {
@@ -134,6 +142,8 @@ typedef struct {
jmp_buf env;
Ssa *ssa;
amal_compiler *compiler;
+ /* 0 if the current scope belongs to the file, otherwise ParserFileScopeReference's import_index (the import file that contains the scope) */
+ u8 import_index;
} SsaCompilerContext;
/* longjump to context->env on failure */