aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler.c')
-rw-r--r--src/compiler.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/compiler.c b/src/compiler.c
index 46d20a8..48ba71e 100644
--- a/src/compiler.c
+++ b/src/compiler.c
@@ -1,6 +1,6 @@
#include "../include/compiler.h"
#include "../include/parser.h"
-#include "../include/ssa/ssa.h"
+#include "../include/ir/ir.h"
#include "../include/bytecode/bytecode.h"
#include "../include/std/log.h"
#include "../include/std/mem.h"
@@ -169,7 +169,7 @@ void amal_compiler_deinit(amal_compiler *self) {
typedef enum {
THREAD_WORK_PARSE,
THREAD_WORK_RESOLVE_AST,
- THREAD_WORK_GENERATE_SSA,
+ THREAD_WORK_GENERATE_IR,
THREAD_WORK_GENERATE_BYTECODE
} ThreadWorkType;
@@ -254,20 +254,20 @@ static CHECK_RESULT int thread_resolve_ast(amal_compiler *compiler, Parser *pars
return result;
}
-static CHECK_RESULT int thread_generate_ssa(Parser *parser) {
- SsaCompilerContext compiler_context;
+static CHECK_RESULT int thread_generate_ir(Parser *parser) {
+ IrCompilerContext compiler_context;
int result;
- return_if_error(arena_allocator_alloc(parser->allocator, sizeof(Ssa), (void**)&compiler_context.ssa));
- return_if_error(ssa_init(compiler_context.ssa, parser));
+ return_if_error(arena_allocator_alloc(parser->allocator, sizeof(Ir), (void**)&compiler_context.ir));
+ return_if_error(ir_init(compiler_context.ir, parser));
compiler_context.compiler = parser->compiler;
compiler_context.import_index = 0;
- parser->ssa = compiler_context.ssa;
- amal_log_debug("Generating SSA for file: %.*s", parser->tokenizer.code_name.size, parser->tokenizer.code_name.data);
+ parser->ir = compiler_context.ir;
+ amal_log_debug("Generating IR for file: %.*s", parser->tokenizer.code_name.size, parser->tokenizer.code_name.data);
result = setjmp(compiler_context.env);
if(result == 0)
- scope_generate_ssa(&parser->struct_decl.body, &compiler_context);
+ scope_generate_ir(&parser->struct_decl.body, &compiler_context);
return result;
}
@@ -283,7 +283,7 @@ static CHECK_RESULT int thread_generate_bytecode(Parser *parser) {
result = setjmp(compiler_context.env);
if(result == 0) {
- generate_bytecode_from_ssa(&compiler_context);
+ generate_bytecode_from_ir(&compiler_context);
parser->bytecode = compiler_context.bytecode;
}
@@ -301,8 +301,8 @@ static int thread_callback_generic(void *userdata) {
case THREAD_WORK_RESOLVE_AST:
result = thread_resolve_ast(compiler_userdata->compiler, compiler_userdata->parser);
break;
- case THREAD_WORK_GENERATE_SSA:
- result = thread_generate_ssa(compiler_userdata->parser);
+ case THREAD_WORK_GENERATE_IR:
+ result = thread_generate_ir(compiler_userdata->parser);
break;
case THREAD_WORK_GENERATE_BYTECODE:
result = thread_generate_bytecode(compiler_userdata->parser);
@@ -327,7 +327,7 @@ static CHECK_RESULT int amal_compiler_add_task(amal_compiler *self, ThreadWorkDa
break;
}
case THREAD_WORK_RESOLVE_AST:
- case THREAD_WORK_GENERATE_SSA:
+ case THREAD_WORK_GENERATE_IR:
case THREAD_WORK_GENERATE_BYTECODE: {
CompilerGenericThreadUserData *userdata;
cleanup_if_error(am_malloc(sizeof(CompilerGenericThreadUserData), (void**)&userdata));
@@ -521,7 +521,7 @@ int amal_compiler_internal_load_file(amal_compiler *self, const char *filepath,
if(main_job) {
/*doc(Compiler flow)
- (Tokenize&parse -> Resolve AST -> Generate SSA -> Generate bytecode) -> Generate program\
+ (Tokenize&parse -> Resolve AST -> Generate IR -> Generate bytecode) -> Generate program\
Each step except the last is done using multiple threads in parallel and the output of each step is used
in the next step. The last step is not done in parallel because the last step is combining all bytecode
and writing it to a file, which is an IO bottlenecked operation and it won't benefit from multithreading
@@ -542,10 +542,10 @@ int amal_compiler_internal_load_file(amal_compiler *self, const char *filepath,
main_func->decl_flags |= DECL_FLAG_EXPORT;
return_if_error(amal_compiler_dispatch_generic(self, THREAD_WORK_RESOLVE_AST));
- amal_log_info("Finished resolving AST, generating SSA");
+ amal_log_info("Finished resolving AST, generating IR");
- return_if_error(amal_compiler_dispatch_generic(self, THREAD_WORK_GENERATE_SSA));
- amal_log_info("Finished generating SSA");
+ return_if_error(amal_compiler_dispatch_generic(self, THREAD_WORK_GENERATE_IR));
+ amal_log_info("Finished generating IR");
return_if_error(amal_compiler_dispatch_generic(self, THREAD_WORK_GENERATE_BYTECODE));
amal_compiler_update_import_references(self);