diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-06-24 04:42:09 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-24 04:42:09 +0200 |
commit | 578a597b942eaf3c79854b09062001f6fc169abb (patch) | |
tree | 1f31f45dac633ec0f9becd3b61964529f91cd840 /src | |
parent | f60b661a1cc22d6e89972cc99014984d211447c4 (diff) |
Make int and uint word sized
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/codegen.c b/src/codegen.c index 665f071..9ba4c2d 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -30,10 +30,11 @@ struct cgctx { aux_t aux; lexemes_t toks; - LLVMContextRef ctx; - LLVMModuleRef mod; - LLVMBuilderRef bob; - LLVMValueRef func; + LLVMBuilderRef bob; + LLVMContextRef ctx; + LLVMModuleRef mod; + LLVMTargetDataRef td; + LLVMValueRef func; idx_t scpi; strview_t namespace; @@ -49,6 +50,7 @@ codegen(const char *file, mpq_t *folds, scope_t *scps, type_t *types, { char *triple = LLVMGetDefaultTargetTriple(); LLVMContextRef llctx = LLVMContextCreate(); + LLVMModuleRef llmod = LLVMModuleCreateWithNameInContext("oryx", llctx); struct cgctx ctx = { .a = &(arena_t){0}, @@ -62,12 +64,14 @@ codegen(const char *file, mpq_t *folds, scope_t *scps, type_t *types, .toks = toks, .ctx = llctx, - .mod = LLVMModuleCreateWithNameInContext("oryx", llctx), + .mod = llmod, .bob = LLVMCreateBuilderInContext(llctx), + .td = LLVMGetModuleDataLayout(llmod), }; - LLVMSetSourceFileName(ctx.mod, file, strlen(file)); LLVMSetTarget(ctx.mod, triple); + LLVMSetModuleDataLayout(ctx.mod, ctx.td); + LLVMSetSourceFileName(ctx.mod, file, strlen(file)); LLVMDisposeMessage(triple); codegenast(ctx); @@ -303,9 +307,8 @@ type2llvm(struct cgctx ctx, type_t t) default: __builtin_unreachable(); } } - /* TODO: Arbitrary precision */ if (t.size == 0) - return LLVMInt64TypeInContext(ctx.ctx); + return LLVMIntPtrTypeInContext(ctx.ctx, ctx.td); assert((unsigned)t.size * 8 <= UINT8_MAX); return LLVMIntTypeInContext(ctx.ctx, t.size * 8); default: |