From 78e6310b05a9da54bd9a939137af686c5f456086 Mon Sep 17 00:00:00 2001 From: servostar Date: Sun, 26 May 2024 17:30:53 +0200 Subject: [PATCH] moved module generation to backend parser --- src/llvm/backend.c | 16 +++------------- src/llvm/parser.c | 17 +++++++++++++++++ src/llvm/parser.h | 12 ++++++++++++ 3 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 src/llvm/parser.c create mode 100644 src/llvm/parser.h diff --git a/src/llvm/backend.c b/src/llvm/backend.c index 5bf2b21..5abcb95 100644 --- a/src/llvm/backend.c +++ b/src/llvm/backend.c @@ -3,24 +3,14 @@ #include #include #include -#include -#include +#include typedef enum LLVMBackendError_t { UnresolvedImport } LLVMBackendError; -static BackendError llvm_backend_codegen(const Module* unit, void**) { - // we start with a LLVM module - LLVMContextRef context = LLVMContextCreate(); - LLVMModuleRef module = LLVMModuleCreateWithNameInContext("gemstone application", context); - - BackendError err; - - LLVMDisposeModule(module); - LLVMContextDispose(context); - - return new_backend_error(Success); +static BackendError llvm_backend_codegen(const Module* unit, void** output) { + return parse_module(unit, output); } static BackendError llvm_backend_codegen_init(void) { diff --git a/src/llvm/parser.c b/src/llvm/parser.c new file mode 100644 index 0000000..7a6fd55 --- /dev/null +++ b/src/llvm/parser.c @@ -0,0 +1,17 @@ + +#include + +BackendError parse_module(const Module* module, void**) { + LLVMBackendCompileUnit* unit = malloc(sizeof(LLVMBackendCompileUnit)); + + // we start with a LLVM module + unit->context = LLVMContextCreate(); + unit->module = LLVMModuleCreateWithNameInContext("gemstone application", unit->context); + + + + LLVMDisposeModule(unit->module); + LLVMContextDispose(unit->context); + + return new_backend_error(Success); +} diff --git a/src/llvm/parser.h b/src/llvm/parser.h new file mode 100644 index 0000000..ceb908c --- /dev/null +++ b/src/llvm/parser.h @@ -0,0 +1,12 @@ + +#include "set/types.h" +#include +#include +#include + +typedef struct LLVMBackendCompileUnit_t { + LLVMContextRef context; + LLVMModuleRef module; +} LLVMBackendCompileUnit; + +BackendError parse_module(const Module* module, void**);