From 6cf81cebeca2ec84463eb0b783186109a483ba2e Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Sat, 2 Nov 2024 14:54:02 -0600 Subject: [PATCH] Rename after our recently deceased little dog --- .gitignore | 2 +- CMakeLists.txt | 10 +++--- bootstrap/{nest => bloat-buster}/llvm.cpp | 2 +- bootstrap/{nest => bloat-buster}/main.c | 22 ++++++------ bootstrap/{nest => bloat-buster}/pdb_image.c | 2 +- .../include/{nest => bloat-buster}/base.h | 12 ++++--- .../include/{nest => bloat-buster}/llvm.h | 2 +- .../{nest => bloat-buster}/pdb_image.h | 0 bootstrap/include/std/base.h | 8 ++--- bootstrap/runner/runner.c | 16 ++++----- bootstrap/std/base.c | 36 +++++++++---------- 11 files changed, 57 insertions(+), 55 deletions(-) rename bootstrap/{nest => bloat-buster}/llvm.cpp (99%) rename bootstrap/{nest => bloat-buster}/main.c (99%) rename bootstrap/{nest => bloat-buster}/pdb_image.c (99%) rename bootstrap/include/{nest => bloat-buster}/base.h (96%) rename bootstrap/include/{nest => bloat-buster}/llvm.h (73%) rename bootstrap/include/{nest => bloat-buster}/pdb_image.h (100%) diff --git a/.gitignore b/.gitignore index 4162f5e..95f6481 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /build/ -/nest/ +/bb/ /*.data /perf.data* project diff --git a/CMakeLists.txt b/CMakeLists.txt index 8011d8c..07287a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(nest) +project(bloat-buster) include(CMakePrintHelpers) cmake_print_variables("Build type: ${CMAKE_BUILD_TYPE}") @@ -106,7 +106,7 @@ link_directories("${LLVM_LIBDIRS}") set(LIBRARY_NAME "std") set(RUNNER_NAME "runner") -set(COMPILER_NAME "nest") +set(COMPILER_NAME "bb") add_library("${LIBRARY_NAME}" "bootstrap/std/base.c" @@ -121,9 +121,9 @@ add_executable("${RUNNER_NAME}" "bootstrap/runner/runner.c") target_link_libraries(${RUNNER_NAME} PRIVATE ${LIBRARY_NAME}) add_executable("${COMPILER_NAME}" - "bootstrap/nest/main.c" - "bootstrap/nest/pdb_image.c" - "bootstrap/nest/llvm.cpp" + "bootstrap/bloat-buster/main.c" + "bootstrap/bloat-buster/pdb_image.c" + "bootstrap/bloat-buster/llvm.cpp" ) target_compile_definitions(${COMPILER_NAME} PRIVATE ${LLVM_DEFINITIONS}) diff --git a/bootstrap/nest/llvm.cpp b/bootstrap/bloat-buster/llvm.cpp similarity index 99% rename from bootstrap/nest/llvm.cpp rename to bootstrap/bloat-buster/llvm.cpp index 2041b77..01162d7 100644 --- a/bootstrap/nest/llvm.cpp +++ b/bootstrap/bloat-buster/llvm.cpp @@ -1,7 +1,7 @@ #define unreachable() __builtin_unreachable() #include #include -#include +#include #include #include diff --git a/bootstrap/nest/main.c b/bootstrap/bloat-buster/main.c similarity index 99% rename from bootstrap/nest/main.c rename to bootstrap/bloat-buster/main.c index 10bbf2b..aa9e5b8 100644 --- a/bootstrap/nest/main.c +++ b/bootstrap/bloat-buster/main.c @@ -5,9 +5,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __APPLE__ #define clang_path "/opt/homebrew/opt/llvm/bin/clang" @@ -36,7 +36,7 @@ STRUCT(GetOrPut(T)) \ u8 existing;\ } -auto compiler_name = strlit("nest"); +auto compiler_name = strlit("bb"); fn void print_string(String message) { @@ -9502,7 +9502,7 @@ may_be_unused fn String write_elf(Thread* thread, ObjectOptions options) // comp_dir: strx1 { - auto string = strlit("/home/david/dev/nest/tests"); + auto string = strlit("/home/david/dev/bb/tests"); auto string_offset = debug_str.length; vb_copy_string_zero_terminated(&debug_str, string); auto string_offset_index = debug_str_offsets.length; @@ -9763,7 +9763,7 @@ may_be_unused fn String write_elf(Thread* thread, ObjectOptions options) u8 directory_index = 0; auto directory_string_offset = debug_line_str.length; { - auto string = strlit("/home/david/dev/nest/tests"); + auto string = strlit("/home/david/dev/bloat-buster/tests"); vb_copy_string_zero_terminated(&debug_line_str, string); } u32 paths[] = { directory_string_offset }; @@ -9800,7 +9800,7 @@ may_be_unused fn String write_elf(Thread* thread, ObjectOptions options) MD5Result hash; }; // MD5Result md5_hash = { { 0x05, 0xAB, 0x89, 0xF5, 0x48, 0x1B, 0xC9, 0xF2, 0xD0, 0x37, 0xE7, 0x88, 0x66, 0x41, 0xE9, 0x19 } }; - String dummy_file = file_read(thread->arena, strlit("/home/david/dev/nest/tests/first.nat")); + String dummy_file = file_read(thread->arena, strlit("/home/david/dev/bloat-buster/tests/first.nat")); auto md5_hash = md5_string(dummy_file); auto filename_string_offset = debug_line_str.length; @@ -23577,7 +23577,7 @@ fn void code_generation(Thread* restrict thread, CodegenOptions options) VirtualBuffer(u8) code = {}; auto object_path = binary_path_from_options(thread->arena, (BinaryPathOptions) { - .build_directory = strlit("nest"), + .build_directory = strlit(cache_dir), .name = options.test_name, .target = options.target, .backend = options.backend, @@ -23585,7 +23585,7 @@ fn void code_generation(Thread* restrict thread, CodegenOptions options) }); auto exe_path = binary_path_from_options(thread->arena, (BinaryPathOptions) { - .build_directory = strlit("nest"), + .build_directory = strlit(cache_dir), .name = options.test_name, .target = options.target, .backend = options.backend, @@ -24329,7 +24329,7 @@ fn void code_generation(Thread* restrict thread, CodegenOptions options) // TODO: delete, this is testing llvm_codegen(options, object_path); } break; - case COMPILER_BACKEND_NEST: + case COMPILER_BACKEND_BB: { auto code_slice = (Slice(u8)) { .pointer = code.pointer, .length = code.length, }; auto object_options = (ObjectOptions) { @@ -24794,7 +24794,7 @@ void entry_point(int argc, char* argv[], char* envp[]) Target target = native_target_get(); - os_directory_make(strlit("nest")); + os_directory_make(strlit(cache_dir)); File file = { .path = source_file_path, diff --git a/bootstrap/nest/pdb_image.c b/bootstrap/bloat-buster/pdb_image.c similarity index 99% rename from bootstrap/nest/pdb_image.c rename to bootstrap/bloat-buster/pdb_image.c index a923466..28599f1 100644 --- a/bootstrap/nest/pdb_image.c +++ b/bootstrap/bloat-buster/pdb_image.c @@ -1,4 +1,4 @@ -#include +#include u8 pdb_image[143360] = { 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, 0x74, 0x20, 0x43, 0x2F, 0x43, 0x2B, 0x2B, 0x20, diff --git a/bootstrap/include/nest/base.h b/bootstrap/include/bloat-buster/base.h similarity index 96% rename from bootstrap/include/nest/base.h rename to bootstrap/include/bloat-buster/base.h index 456371d..813c0fb 100644 --- a/bootstrap/include/nest/base.h +++ b/bootstrap/include/bloat-buster/base.h @@ -3,6 +3,8 @@ #include #include +#define cache_dir "bb" + typedef enum CpuArchitecture : u8 { CPU_ARCH_X86_64, @@ -48,7 +50,7 @@ STRUCT(Target) typedef enum CompilerBackend : u8 { - COMPILER_BACKEND_NEST, + COMPILER_BACKEND_BB, COMPILER_BACKEND_LLVM, COMPILER_BACKEND_COUNT, } CompilerBackend; @@ -57,8 +59,8 @@ fn String compiler_backend_to_one_char_string(CompilerBackend backend) { switch (backend) { - case COMPILER_BACKEND_NEST: - return strlit("n"); + case COMPILER_BACKEND_BB: + return strlit("b"); case COMPILER_BACKEND_LLVM: return strlit("l"); case COMPILER_BACKEND_COUNT: @@ -70,8 +72,8 @@ fn String compiler_backend_to_string(CompilerBackend backend) { switch (backend) { - case COMPILER_BACKEND_NEST: - return strlit("nest"); + case COMPILER_BACKEND_BB: + return strlit("bb"); case COMPILER_BACKEND_LLVM: return strlit("llvm"); case COMPILER_BACKEND_COUNT: diff --git a/bootstrap/include/nest/llvm.h b/bootstrap/include/bloat-buster/llvm.h similarity index 73% rename from bootstrap/include/nest/llvm.h rename to bootstrap/include/bloat-buster/llvm.h index 6e3f6b8..63b1a26 100644 --- a/bootstrap/include/nest/llvm.h +++ b/bootstrap/include/bloat-buster/llvm.h @@ -1,5 +1,5 @@ #pragma once -#include +#include EXPORT void llvm_codegen(CodegenOptions options, String object_path); diff --git a/bootstrap/include/nest/pdb_image.h b/bootstrap/include/bloat-buster/pdb_image.h similarity index 100% rename from bootstrap/include/nest/pdb_image.h rename to bootstrap/include/bloat-buster/pdb_image.h diff --git a/bootstrap/include/std/base.h b/bootstrap/include/std/base.h index 999bc04..899d0cb 100644 --- a/bootstrap/include/std/base.h +++ b/bootstrap/include/std/base.h @@ -1,9 +1,9 @@ #pragma once #ifdef NDEBUG -#define NEST_DEBUG 0 +#define BB_DEBUG 0 #else -#define NEST_DEBUG 1 +#define BB_DEBUG 1 #endif #ifdef STATIC @@ -167,7 +167,7 @@ const may_be_unused global_variable u8 bracket_close = ']'; #define s_get_slice(T, s, start, end) (Slice(T)){ .pointer = ((s).pointer) + (start), .length = (end) - (start) } #define s_equal(a, b) ((a).length == (b).length && memcmp((a).pointer, (b).pointer, sizeof(*((a).pointer)) * (a).length) == 0) -#if NEST_DEBUG +#if BB_DEBUG #define assert(x) if (unlikely(!(x))) { bad_exit("Assert failed: \"" # x "\"", __FILE__, __LINE__); } #else #define assert(x) unlikely(!(x)) @@ -178,7 +178,7 @@ const may_be_unused global_variable u8 bracket_close = ']'; #ifdef unreachable #undef unreachable #endif -#if NEST_DEBUG +#if BB_DEBUG #define unreachable() bad_exit("Unreachable triggered", __FILE__, __LINE__) #else #define unreachable() __builtin_unreachable() diff --git a/bootstrap/runner/runner.c b/bootstrap/runner/runner.c index 584d384..d77d750 100644 --- a/bootstrap/runner/runner.c +++ b/bootstrap/runner/runner.c @@ -4,9 +4,9 @@ #include #include -#include +#include -#define nest_dir "nest" +#define bb_dir "bb" declare_slice(CompilerBackend); @@ -19,14 +19,14 @@ typedef enum CMakeBuildType CMAKE_BUILD_TYPE_COUNT, } CMakeBuildType; -fn void run(Arena* arena, char** envp, String compiler_path, CompilerBackend compiler_backend, u8 debug, char* nest_source_path) +fn void run(Arena* arena, char** envp, String compiler_path, CompilerBackend compiler_backend, u8 debug, char* bb_source_path) { CStringSlice args = {}; auto compiler_backend_string = compiler_backend_to_one_char_string(compiler_backend); #define common_compile_and_run_args \ string_to_c(compiler_path), \ - nest_source_path, \ + bb_source_path, \ string_to_c(compiler_backend_string), \ 0, @@ -113,7 +113,7 @@ fn void run_tests(Arena* arena, String compiler_path, TestOptions const * const // if (compiler_backend != COMPILER_BACKEND_INTERPRETER) { auto executable = binary_path_from_options(arena, (BinaryPathOptions) { - .build_directory = strlit(nest_dir), + .build_directory = strlit(bb_dir), .name = test_name, .target = target, .backend = compiler_backend, @@ -237,7 +237,7 @@ void entry_point(int argc, char* argv[], char* envp[]) { if (preferred_compiler_backend == COMPILER_BACKEND_COUNT) { - preferred_compiler_backend = COMPILER_BACKEND_NEST; + preferred_compiler_backend = COMPILER_BACKEND_BB; } } @@ -246,7 +246,7 @@ void entry_point(int argc, char* argv[], char* envp[]) build_type = CMAKE_BUILD_TYPE_DEBUG; } - String compiler_path = strlit("build/nest"); + String compiler_path = strlit("build/bb"); switch (command) { @@ -277,7 +277,7 @@ void entry_point(int argc, char* argv[], char* envp[]) // strlit("tests/comparison.nat"), }; CompilerBackend all_compiler_backends[] = { - COMPILER_BACKEND_NEST, + COMPILER_BACKEND_BB, COMPILER_BACKEND_LLVM, }; static_assert(array_length(all_compiler_backends) == COMPILER_BACKEND_COUNT); diff --git a/bootstrap/std/base.c b/bootstrap/std/base.c index 9ddb101..54a7726 100644 --- a/bootstrap/std/base.c +++ b/bootstrap/std/base.c @@ -3,7 +3,7 @@ u8 cast_u32_to_u8(u32 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > UINT8_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -19,7 +19,7 @@ u8 cast_u32_to_u8(u32 source, const char* name, int line) u16 cast_u32_to_u16(u32 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > UINT16_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -35,7 +35,7 @@ u16 cast_u32_to_u16(u32 source, const char* name, int line) s16 cast_u32_to_s16(u32 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > INT16_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -51,7 +51,7 @@ s16 cast_u32_to_s16(u32 source, const char* name, int line) s32 cast_u32_to_s32(u32 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > INT32_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -67,7 +67,7 @@ s32 cast_u32_to_s32(u32 source, const char* name, int line) u8 cast_u64_to_u8(u64 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > UINT8_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -83,7 +83,7 @@ u8 cast_u64_to_u8(u64 source, const char* name, int line) u16 cast_u64_to_u16(u64 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > UINT16_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -99,7 +99,7 @@ u16 cast_u64_to_u16(u64 source, const char* name, int line) u32 cast_u64_to_u32(u64 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > UINT32_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -115,7 +115,7 @@ u32 cast_u64_to_u32(u64 source, const char* name, int line) s32 cast_u64_to_s32(u64 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > INT32_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -131,7 +131,7 @@ s32 cast_u64_to_s32(u64 source, const char* name, int line) s64 cast_u64_to_s64(u64 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > INT64_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -147,7 +147,7 @@ s64 cast_u64_to_s64(u64 source, const char* name, int line) u8 cast_s32_to_u8(s32 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source < 0) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -168,7 +168,7 @@ u8 cast_s32_to_u8(s32 source, const char* name, int line) u16 cast_s32_to_u16(s32 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source < 0) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -189,7 +189,7 @@ u16 cast_s32_to_u16(s32 source, const char* name, int line) u32 cast_s32_to_u32(s32 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source < 0) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -205,7 +205,7 @@ u32 cast_s32_to_u32(s32 source, const char* name, int line) u64 cast_s32_to_u64(s32 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source < 0) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -221,7 +221,7 @@ u64 cast_s32_to_u64(s32 source, const char* name, int line) s16 cast_s32_to_s16(s32 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source > INT16_MAX) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -242,7 +242,7 @@ s16 cast_s32_to_s16(s32 source, const char* name, int line) u16 cast_s64_to_u16(s64 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source < 0) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -263,7 +263,7 @@ u16 cast_s64_to_u16(s64 source, const char* name, int line) u32 cast_s64_to_u32(s64 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source < 0) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -279,7 +279,7 @@ u32 cast_s64_to_u32(s64 source, const char* name, int line) u64 cast_s64_to_u64(s64 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source < 0) { print("Cast failed at {cstr}:{u32}\n", name, line); @@ -295,7 +295,7 @@ u64 cast_s64_to_u64(s64 source, const char* name, int line) s32 cast_s64_to_s32(s64 source, const char* name, int line) { -#if NEST_DEBUG +#if BB_DEBUG if (source < INT32_MIN) { print("Cast failed at {cstr}:{u32}\n", name, line);