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 <ast/ast.h>
#include <llvm/backend.h>
#include <llvm-c/Types.h>
#include <llvm-c/Core.h>
#include <llvm/parser.h>
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) {

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**);