mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Compare commits
2 Commits
latest-pre
...
cbranch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
058d637407 | ||
|
|
01335f6862 |
@@ -371,6 +371,7 @@ endif()
|
||||
|
||||
if(C3_WITH_LLVM)
|
||||
target_sources(c3c PRIVATE
|
||||
src/compiler/c_codegen.c
|
||||
src/compiler/llvm_codegen.c
|
||||
src/compiler/llvm_codegen_debug_info.c
|
||||
src/compiler/llvm_codegen_expr.c
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BACKEND_LLVM = 1,
|
||||
BACKEND_TB = 2
|
||||
BACKEND_LLVM = 0,
|
||||
BACKEND_TB = 1,
|
||||
BACKEND_C = 2,
|
||||
} CompilerBackend;
|
||||
|
||||
typedef enum
|
||||
|
||||
@@ -88,6 +88,12 @@ static const char *optlevels[4] = {
|
||||
[OPTIMIZATION_AGGRESSIVE] = "max",
|
||||
};
|
||||
|
||||
static const char *backends[3] = {
|
||||
[BACKEND_LLVM] = "llvm",
|
||||
[BACKEND_TB] = "tb",
|
||||
[BACKEND_C] = "c",
|
||||
};
|
||||
|
||||
static const char *backtrace_levels[2] = {
|
||||
[SHOW_BACKTRACE_OFF] = "off",
|
||||
[SHOW_BACKTRACE_ON] = "on",
|
||||
|
||||
@@ -654,6 +654,11 @@ static void parse_option(BuildOptions *options)
|
||||
print_version();
|
||||
exit_compiler(COMPILER_SUCCESS_EXIT);
|
||||
}
|
||||
if ((argopt = match_argopt("backend")))
|
||||
{
|
||||
options->backend = (CompilerBackend)parse_multi_option(argopt, 3, backends);
|
||||
return;
|
||||
}
|
||||
if (match_longopt("run-once"))
|
||||
{
|
||||
options->run_once = true;
|
||||
|
||||
1078
src/compiler/c_codegen.c
Normal file
1078
src/compiler/c_codegen.c
Normal file
File diff suppressed because it is too large
Load Diff
1
src/compiler/c_codegen_internal.h
Normal file
1
src/compiler/c_codegen_internal.h
Normal file
@@ -0,0 +1 @@
|
||||
#include "codegen_internal.h"
|
||||
@@ -468,6 +468,9 @@ void compiler_compile(void)
|
||||
|
||||
switch (compiler.build.backend)
|
||||
{
|
||||
case BACKEND_C:
|
||||
gen_contexts = c_gen(modules, module_count);
|
||||
error_exit("Unfinished C backend!");
|
||||
case BACKEND_LLVM:
|
||||
#if LLVM_AVAILABLE
|
||||
gen_contexts = llvm_gen(modules, module_count);
|
||||
|
||||
@@ -439,6 +439,7 @@ typedef struct VarDecl_
|
||||
{
|
||||
// Variable
|
||||
void *optional_ref;
|
||||
int optional_id;
|
||||
int tb_optional_reg;
|
||||
};
|
||||
};
|
||||
@@ -613,6 +614,7 @@ typedef struct Decl_
|
||||
union
|
||||
{
|
||||
void *backend_ref;
|
||||
int backend_id;
|
||||
int tb_register;
|
||||
void *backend_value;
|
||||
void *tb_symbol;
|
||||
@@ -2120,6 +2122,7 @@ CastKind cast_to_bool_kind(Type *type);
|
||||
|
||||
const char *llvm_codegen(void *context);
|
||||
const char *tilde_codegen(void *context);
|
||||
void **c_gen(Module** modules, unsigned module_count);
|
||||
void **llvm_gen(Module** modules, unsigned module_count);
|
||||
void **tilde_gen(Module** modules, unsigned module_count);
|
||||
|
||||
|
||||
@@ -347,7 +347,6 @@ static bool sema_analyse_union_members(SemaContext *context, Decl *decl)
|
||||
}
|
||||
AlignSize member_alignment;
|
||||
if (!sema_set_abi_alignment(context, member->type, &member_alignment)) return false;
|
||||
|
||||
if (!sema_check_struct_holes(context, decl, member)) return false;
|
||||
|
||||
ByteSize member_size = type_size(member->type);
|
||||
|
||||
@@ -208,15 +208,16 @@ static void register_generic_decls(CompilationUnit *unit, Decl **decls)
|
||||
decl->unit = unit;
|
||||
switch (decl->decl_kind)
|
||||
{
|
||||
case DECL_POISONED:
|
||||
case DECL_ENUM_CONSTANT:
|
||||
case DECL_FAULTVALUE:
|
||||
case DECL_IMPORT:
|
||||
case DECL_LABEL:
|
||||
case DECL_CT_ASSERT:
|
||||
case DECL_CT_ECHO:
|
||||
case DECL_DECLARRAY:
|
||||
case DECL_ERASED:
|
||||
case DECL_LABEL:
|
||||
UNREACHABLE
|
||||
case DECL_POISONED:
|
||||
case DECL_IMPORT:
|
||||
case DECL_CT_ASSERT:
|
||||
case DECL_CT_ECHO:
|
||||
case DECL_FNTYPE:
|
||||
case DECL_CT_INCLUDE:
|
||||
case DECL_CT_EXEC:
|
||||
|
||||
Reference in New Issue
Block a user