diff options
Diffstat (limited to 'include/ssa')
-rw-r--r-- | include/ssa/ssa.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/include/ssa/ssa.h b/include/ssa/ssa.h index 21d7f40..b2c8065 100644 --- a/include/ssa/ssa.h +++ b/include/ssa/ssa.h @@ -8,6 +8,8 @@ #include <setjmp.h> +#define SSA_ERR_EXTERN_FUNC_SIG_MISMATCH -20 + typedef enum { SSA_ASSIGN_INTER, SSA_ASSIGN_STRING, @@ -23,6 +25,7 @@ typedef enum { SSA_FUNC_END, SSA_PUSH, SSA_CALL, + SSA_CALL_EXTERN, SSA_JUMP_ZERO, SSA_JUMP, SSA_RET @@ -41,10 +44,16 @@ typedef struct { SsaNumberType type; } SsaNumber; +typedef struct { + FunctionSignature *func_sig; + BufferView name; +} SsaExternFunc; + typedef i16 JumpOffset; -typedef u16 SsaRegister; +typedef i16 SsaRegister; typedef u16 SsaIntermediateIndex; typedef u16 SsaStringIndex; +typedef u16 SsaExternFuncIndex; typedef u16 SsaFuncIndex; typedef struct { @@ -53,10 +62,15 @@ typedef struct { Buffer/*SsaNumber*/ intermediates; HashMapType(BufferView, SsaStringIndex) strings_map; Buffer/*BufferView*/ strings; + HashMapType(BufferView, SsaExternFuncIndex) extern_funcs_map; + Buffer/*SsaExternFunc*/ extern_funcs; SsaIntermediateIndex intermediate_counter; SsaStringIndex string_counter; + SsaExternFuncIndex extern_func_counter; SsaRegister reg_counter; + SsaRegister param_counter; SsaFuncIndex func_counter; + Parser *parser; /* Borrowed */ } Ssa; typedef struct { @@ -72,7 +86,8 @@ typedef struct { typedef struct { SsaFuncIndex func_index; - u16 num_registers; + u16 num_params_regs; + u16 num_local_vars_regs; } SsaInsFuncStart; typedef struct { @@ -82,6 +97,12 @@ typedef struct { } SsaInsFuncCall; typedef struct { + u8 num_args; + SsaRegister result; + SsaExternFuncIndex extern_func_index; +} SsaInsFuncCallExtern; + +typedef struct { SsaRegister condition_reg; JumpOffset jump_offset; } SsaInsJumpZero; @@ -97,7 +118,7 @@ SsaNumber create_ssa_float(f64 value); SsaNumber ssa_get_intermediate(Ssa *self, SsaIntermediateIndex index); BufferView ssa_get_string(Ssa *self, SsaStringIndex index); -CHECK_RESULT int ssa_init(Ssa *self, ArenaAllocator *allocator); +CHECK_RESULT int ssa_init(Ssa *self, Parser *parser); typedef struct { jmp_buf env; |