moved module generation to backend parser

This commit is contained in:
Sven Vogel 2024-05-26 17:30:53 +02:00
parent d0cd74c697
commit 78e6310b05
3 changed files with 32 additions and 13 deletions

View File

@ -3,24 +3,14 @@
#include <sys/log.h> #include <sys/log.h>
#include <ast/ast.h> #include <ast/ast.h>
#include <llvm/backend.h> #include <llvm/backend.h>
#include <llvm-c/Types.h> #include <llvm/parser.h>
#include <llvm-c/Core.h>
typedef enum LLVMBackendError_t { typedef enum LLVMBackendError_t {
UnresolvedImport UnresolvedImport
} LLVMBackendError; } LLVMBackendError;
static BackendError llvm_backend_codegen(const Module* unit, void**) { static BackendError llvm_backend_codegen(const Module* unit, void** output) {
// we start with a LLVM module return parse_module(unit, output);
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_init(void) { static BackendError llvm_backend_codegen_init(void) {

17
src/llvm/parser.c Normal file
View File

@ -0,0 +1,17 @@
#include <llvm/parser.h>
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);
}

12
src/llvm/parser.h Normal file
View File

@ -0,0 +1,12 @@
#include "set/types.h"
#include <codegen/backend.h>
#include <llvm-c/Types.h>
#include <llvm-c/Core.h>
typedef struct LLVMBackendCompileUnit_t {
LLVMContextRef context;
LLVMModuleRef module;
} LLVMBackendCompileUnit;
BackendError parse_module(const Module* module, void**);