Skip to content

Commit

Permalink
C backend work.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Dec 28, 2024
1 parent d20d957 commit b7082f3
Show file tree
Hide file tree
Showing 10 changed files with 1,106 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ add_executable(c3c
src/utils/whereami.c
src/utils/cpus.c
src/utils/unzipper.c
src/compiler/c_codegen.c
src/compiler/decltable.c
src/compiler/mac_support.c
src/compiler/windows_support.c
Expand Down
5 changes: 3 additions & 2 deletions src/build/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

typedef enum
{
BACKEND_LLVM = 1,
BACKEND_TB = 2
BACKEND_LLVM = 0,
BACKEND_TB = 1,
BACKEND_C = 2,
} CompilerBackend;

typedef enum
Expand Down
6 changes: 6 additions & 0 deletions src/build/build_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/build/build_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit b7082f3

Please sign in to comment.