diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..134b873f2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: CI build and test + +on: [push, pull_request] + +defaults: + run: + shell: bash + +jobs: + build-linux: + runs-on: ubuntu-latest + container: + image: fedora:latest + steps: + - uses: actions/checkout@v7 + - name: Install dependencies + run: sudo dnf install -y cmake gcc gcc-c++ git libstdc++-devel make ninja + - name: CMake configure + run: cmake -G Ninja -B bld -DUSE_LTO=OFF + - name: CMake build + run: cmake --build bld -j $(nproc) + - name: Setup Test suite dependencies + run: sudo dnf install -y emacs-nw libcxx libcxx-devel libcxxabi libcxxabi-devel mingw64-gcc mingw64-libstdc++ ucrt64-gcc ucrt64-libstdc++ + - name: Configure Test suite using CMake + working-directory: ./tst + run: cmake -G Ninja -B bld -DUSE_LTO=OFF -DLCC_TEST_NON_ZERO_EXIT_ON_FAILURE=ON + - name: Build Test suite + working-directory: ./tst + run: cmake --build bld + - name: Test + working-directory: ./tst + run: cmake --build bld -t test + build-windows: + runs-on: windows-latest + defaults: + run: + shell: pwsh + steps: + - uses: actions/checkout@v7 + - name: CMake configure + run: cmake -G Ninja -B bld -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_CXX_SCAN_FOR_MODULES=OFF -DFMT_MODULE=OFF -DUSE_LTO=OFF + - name: CMake build + run: cmake --build bld -j $(nproc) diff --git a/inc/lcc/ir/core.hh b/inc/lcc/ir/core.hh index 0d939887c..13592ce3d 100644 --- a/inc/lcc/ir/core.hh +++ b/inc/lcc/ir/core.hh @@ -26,7 +26,7 @@ #include namespace lcc { -class Parameter; +class Function; class PhiInst; namespace parser { @@ -605,6 +605,34 @@ public: static auto classof(const Value* v) -> bool { return v->kind() == Kind::Block; } }; +/// A parameter reference. +class Parameter : public UseTrackingValue { + /// Only the Function class should be able to create these. + friend Function; + // NOTE: For lowering + friend Module; + + /// The parameter index. + u32 i{}; + + Parameter(Type* ty, u32 idx) + : UseTrackingValue(Kind::Parameter, ty) + , i(idx) {} + +public: + /// Get the parameter index. + [[nodiscard]] + auto index() const -> u32 { return i; } + + /// NOTE: For lowering + [[nodiscard]] + auto index() -> u32& { return i; } + + /// RTTI. + [[nodiscard]] + static auto classof(const Value* v) -> bool { return v->kind() == Kind::Parameter; } +}; + /// An IR function. class Function : public UseTrackingValue { private: @@ -743,34 +771,6 @@ public: static auto classof(const Value* v) -> bool { return v->kind() == Kind::Function; } }; -/// A parameter reference. -class Parameter : public UseTrackingValue { - /// Only the Function class should be able to create these. - friend Function; - // NOTE: For lowering - friend Module; - - /// The parameter index. - u32 i{}; - - Parameter(Type* ty, u32 idx) - : UseTrackingValue(Kind::Parameter, ty) - , i(idx) {} - -public: - /// Get the parameter index. - [[nodiscard]] - auto index() const -> u32 { return i; } - - /// NOTE: For lowering - [[nodiscard]] - auto index() -> u32& { return i; } - - /// RTTI. - [[nodiscard]] - static auto classof(const Value* v) -> bool { return v->kind() == Kind::Parameter; } -}; - /// ============================================================================ /// Instructions /// ============================================================================ diff --git a/inc/lccbase/context.hh b/inc/lccbase/context.hh index f07b8bfa1..973503cc1 100644 --- a/inc/lccbase/context.hh +++ b/inc/lccbase/context.hh @@ -45,9 +45,9 @@ public: StopatSema = true, }; - enum OptionPrintMIR : bool { - DoNotPrintMIR, - PrintMIR = true, + enum OptionPrintMachineIR : bool { + DoNotPrintMachineIR, + PrintMachineIR = true, }; enum OptionStopatMIR : bool { DoNotStopatMIR, @@ -74,7 +74,7 @@ public: OptionStopatSyntax _stopat_syntax{}; OptionStopatSema _stopat_sema{}; - OptionPrintMIR _should_print_mir{}; + OptionPrintMachineIR _should_print_mir{}; OptionStopatMIR _stopat_mir{}; }; diff --git a/lib/lcc/lcc-c.cc b/lib/lcc/lcc-c.cc index 430125068..07c1e9375 100644 --- a/lib/lcc/lcc-c.cc +++ b/lib/lcc/lcc-c.cc @@ -41,7 +41,7 @@ LccContextRef lcc_context_create(LccTargetRef target, LccFormatRef format) { lcc::Context::DoNotStopatLex, lcc::Context::DoNotStopatSyntax, lcc::Context::DoNotStopatSema, - lcc::Context::DoNotPrintMIR, + lcc::Context::DoNotPrintMachineIR, lcc::Context::DoNotStopatMIR // } }); diff --git a/lib/lccjson/lccjson.cc b/lib/lccjson/lccjson.cc index a12e9005d..7502c55f9 100644 --- a/lib/lccjson/lccjson.cc +++ b/lib/lccjson/lccjson.cc @@ -4,6 +4,7 @@ #include #include +#include #include #include #include diff --git a/src/cli.cc b/src/cli.cc index 01acbb141..15f8c9963 100644 --- a/src/cli.cc +++ b/src/cli.cc @@ -143,7 +143,7 @@ auto parse(int argc, const char** argv) -> Options { else if (arg == "--stopat-ir") o.stopat_ir = true; else if (arg == "--mir") - o.mir = lcc::Context::PrintMIR; + o.mir = lcc::Context::PrintMachineIR; else if (arg == "--stopat-mir") o.stopat_mir = lcc::Context::StopatMIR; else if (arg == "--stats") diff --git a/src/cli.hh b/src/cli.hh index 808f28d5d..d2f7f1acf 100644 --- a/src/cli.hh +++ b/src/cli.hh @@ -19,7 +19,7 @@ struct Options { lcc::Context::OptionPrintStats print_stats{false}; lcc::Context::OptionPrintAST ast{false}; - lcc::Context::OptionPrintMIR mir{false}; + lcc::Context::OptionPrintMachineIR mir{false}; lcc::Context::OptionStopatLex stopat_lex{false}; lcc::Context::OptionStopatSyntax stopat_syntax{false}; lcc::Context::OptionStopatSema stopat_sema{false}; diff --git a/tst/CMakeLists.txt b/tst/CMakeLists.txt index c7bc3e36d..8975f381b 100644 --- a/tst/CMakeLists.txt +++ b/tst/CMakeLists.txt @@ -53,6 +53,10 @@ if (USE_LTO) endif() endif() +if (LCC_TEST_NON_ZERO_EXIT_ON_FAILURE) + add_compile_definitions(LCC_TEST_NON_ZERO_EXIT_ON_FAILURE) +endif() + add_subdirectory("./vew/" "vew" EXCLUDE_FROM_ALL) # LangTest diff --git a/tst/codetest/x86_64/main.cpp b/tst/codetest/x86_64/main.cpp index d49d1a349..8f4c996db 100644 --- a/tst/codetest/x86_64/main.cpp +++ b/tst/codetest/x86_64/main.cpp @@ -281,7 +281,7 @@ bool run_test( lcc::Context::DoNotStopatLex, lcc::Context::DoNotStopatSyntax, lcc::Context::DoNotStopatSema, - lcc::Context::DoNotPrintMIR, + lcc::Context::DoNotPrintMachineIR, lcc::Context::DoNotStopatMIR, } }; @@ -1181,7 +1181,9 @@ int main(int argc, char** argv) { break; } - // if (any_failed) - // return 1; +#ifdef LCC_TEST_NON_ZERO_EXIT_ON_FAILURE + if (any_failed) + return 1; +#endif return 0; } diff --git a/tst/irtest/main.cpp b/tst/irtest/main.cpp index 2759e9d38..085e9d9be 100644 --- a/tst/irtest/main.cpp +++ b/tst/irtest/main.cpp @@ -453,7 +453,7 @@ int main(int argc, char** argv) { lcc::Context::DoNotStopatLex, lcc::Context::DoNotStopatSyntax, lcc::Context::DoNotStopatSema, - lcc::Context::DoNotPrintMIR, + lcc::Context::DoNotPrintMachineIR, lcc::Context::DoNotStopatMIR } }; @@ -485,7 +485,9 @@ int main(int argc, char** argv) { fmt::print("{}", print_test_passedfailed(result)); } - // if (any_failed) - // return 1; +#ifdef LCC_TEST_NON_ZERO_EXIT_ON_FAILURE + if (any_failed) + return 1; +#endif return 0; } diff --git a/tst/langtest/c/main.cpp b/tst/langtest/c/main.cpp index bd6041c95..5c5403df6 100644 --- a/tst/langtest/c/main.cpp +++ b/tst/langtest/c/main.cpp @@ -90,7 +90,7 @@ struct CLanguageTest : langtest::Test { lcc::Context::DoNotStopatLex, lcc::Context::DoNotStopatSyntax, lcc::Context::DoNotStopatSema, - lcc::Context::DoNotPrintMIR, + lcc::Context::DoNotPrintMachineIR, lcc::Context::DoNotStopatMIR } }; @@ -241,7 +241,7 @@ void output_ast(std::filesystem::path p) { lcc::Context::DoNotStopatLex, lcc::Context::DoNotStopatSyntax, lcc::Context::DoNotStopatSema, - lcc::Context::DoNotPrintMIR, + lcc::Context::DoNotPrintMachineIR, lcc::Context::DoNotStopatMIR // } // }; @@ -561,7 +561,9 @@ int main(int argc, const char** argv) { ); } - // if (out.count_failed()) - // return 1; +#ifdef LCC_TEST_NON_ZERO_EXIT_ON_FAILURE + if (out.count_failed()) + return 1; +#endif return 0; } diff --git a/tst/langtest/glint/main.cpp b/tst/langtest/glint/main.cpp index 8af722414..947fbc415 100644 --- a/tst/langtest/glint/main.cpp +++ b/tst/langtest/glint/main.cpp @@ -94,7 +94,7 @@ struct GlintTest : langtest::Test { lcc::Context::DoNotStopatLex, lcc::Context::DoNotStopatSyntax, lcc::Context::DoNotStopatSema, - lcc::Context::DoNotPrintMIR, + lcc::Context::DoNotPrintMachineIR, lcc::Context::DoNotStopatMIR } }; @@ -250,7 +250,7 @@ void output_ast(std::filesystem::path p) { lcc::Context::DoNotStopatLex, lcc::Context::DoNotStopatSyntax, lcc::Context::DoNotStopatSema, - lcc::Context::DoNotPrintMIR, + lcc::Context::DoNotPrintMachineIR, lcc::Context::DoNotStopatMIR // } // }; @@ -560,7 +560,9 @@ int main(int argc, const char** argv) { ); } - // if (out.count_failed()) - // return 1; +#ifdef LCC_TEST_NON_ZERO_EXIT_ON_FAILURE + if (out.count_failed()) + return 1; +#endif return 0; }