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