Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
19431a8
[CI] Implement basic CI
EndeyshentLabs Jul 9, 2026
4bcf377
[CI] Fix parallel jobs
EndeyshentLabs Jul 9, 2026
41ed028
[CI] Add basic windows build
EndeyshentLabs Jul 9, 2026
8d9ff26
[CI] Fix strategy matrix
EndeyshentLabs Jul 9, 2026
0ca3c63
[CI] Remove redundant `shell` in setup Windows env vars
EndeyshentLabs Jul 9, 2026
2d412e9
[CI] Simplify workflow file. Use Clang on Windows build
EndeyshentLabs Jul 9, 2026
1f03ddb
[CI] Add jobs.build-windows.steps label
EndeyshentLabs Jul 9, 2026
6f9264f
[CI] Use CMake Ninja generator. ClangCL on windows
EndeyshentLabs Jul 9, 2026
d733de7
[CI] Windows fixes
EndeyshentLabs Jul 9, 2026
072d7ab
[CI/Windows] Disable C++ modules scanning
EndeyshentLabs Jul 9, 2026
4e30d62
[CI/Windows] Do not build libfmt module library
EndeyshentLabs Jul 9, 2026
276d236
[CI] Testing
EndeyshentLabs Jul 9, 2026
7a66650
[CI/Linux] Install LLVM v22 toolchain instead of v18
EndeyshentLabs Jul 9, 2026
7389163
[CI/Linux] EXPERIMENT: use fedora:latest image
EndeyshentLabs Jul 9, 2026
36a5acf
[CI/Linux] `-y` in `dnf install`s
EndeyshentLabs Jul 9, 2026
3372290
[CI/Linux] install `Ninja`
EndeyshentLabs Jul 9, 2026
50cb568
[CI/Linux/Test/Deps] `emacs` -> `emacs-nw`
EndeyshentLabs Jul 9, 2026
81c7977
[CI] Disable LTO when compiling
EndeyshentLabs Jul 9, 2026
eef9415
[LCCJson] Missing Include
LensPlaysGames Jul 10, 2026
dbcd162
[Meta/Build] Fix `clang-cl` `CMAKE_CXX_COMPILER_ID` issues
LensPlaysGames Jul 10, 2026
5c66e71
[Testing] ABILITY TO Return Non-zero on Test Failure
LensPlaysGames Jul 10, 2026
5cd1544
[Minor] Reorder definitions in inc/lcc/ir/core.hh
EndeyshentLabs Jul 10, 2026
f7bda6e
[Minor] `OptionPrintMIR` -> `OptionPrintMachineIR`
EndeyshentLabs Jul 10, 2026
fbab32d
[Minor/LCCJson] Missing include
EndeyshentLabs Jul 10, 2026
4cd2f89
[Minor] Rename `PrintMIR` -> `PrintMachineIR` in tests
EndeyshentLabs Jul 10, 2026
41b8517
[Test, CI] Add LCC_TEST_NON_ZERO_EXIT_ON_FAILURE CMake option
EndeyshentLabs Jul 10, 2026
29d8024
Merge branch 'main' into github-ci
EndeyshentLabs Jul 10, 2026
dfc53db
Merge remote-tracking branch 'upstream/main' into github-ci
EndeyshentLabs Jul 11, 2026
f8dd350
[CI] Add ability to skip CI or/and CI tests
EndeyshentLabs Jul 11, 2026
a33e825
[CI] Use single quotes
EndeyshentLabs Jul 11, 2026
bb271b9
[CI] Do not run tests if we did not build the test driver
EndeyshentLabs Jul 11, 2026
434a064
[CI] Make running the test opt-in
EndeyshentLabs Jul 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI build and test

on: [push, pull_request]

defaults:
run:
shell: bash

jobs:
build-linux:
if: ${{ !contains(github.event.head_commit.message, '[skip-ci]') }}
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
if: ${{ !contains(github.event.head_commit.message, '[ci-skip-test-driver]') }}
working-directory: ./tst
run: cmake -G Ninja -B bld -DUSE_LTO=OFF -DLCC_TEST_NON_ZERO_EXIT_ON_FAILURE=ON
- name: Build Test suite
if: ${{ !contains(github.event.head_commit.message, '[ci-skip-test-driver]') }}
working-directory: ./tst
run: cmake --build bld
- name: Test
if: ${{ !contains(github.event.head_commit.message, '[ci-skip-test-driver]') && contains(github.event.head_commit.message, '[ci-run-tests]') }}
working-directory: ./tst
run: cmake --build bld -t test
build-windows:
if: ${{ !contains(github.event.head_commit.message, '[skip-ci]') }}
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)
58 changes: 29 additions & 29 deletions inc/lcc/ir/core.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <vector>

namespace lcc {
class Parameter;
class Function;
class PhiInst;

namespace parser {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
/// ============================================================================
Expand Down
8 changes: 4 additions & 4 deletions inc/lccbase/context.hh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public:
StopatSema = true,
};

enum OptionPrintMIR : bool {
DoNotPrintMIR,
PrintMIR = true,
enum OptionPrintMachineIR : bool {
DoNotPrintMachineIR,
PrintMachineIR = true,
};
enum OptionStopatMIR : bool {
DoNotStopatMIR,
Expand All @@ -74,7 +74,7 @@ public:
OptionStopatSyntax _stopat_syntax{};
OptionStopatSema _stopat_sema{};

OptionPrintMIR _should_print_mir{};
OptionPrintMachineIR _should_print_mir{};
OptionStopatMIR _stopat_mir{};
};

Expand Down
2 changes: 1 addition & 1 deletion lib/lcc/lcc-c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
}
});
Expand Down
1 change: 1 addition & 0 deletions lib/lccjson/lccjson.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <fmt/ranges.h>

#include <cctype>
#include <optional>
#include <ranges>
#include <string>
#include <string_view>
Expand Down
2 changes: 1 addition & 1 deletion src/cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/cli.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 4 additions & 0 deletions tst/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions tst/codetest/x86_64/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
};
Expand Down Expand Up @@ -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;
}
8 changes: 5 additions & 3 deletions tst/irtest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
};
Expand Down Expand Up @@ -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;
}
10 changes: 6 additions & 4 deletions tst/langtest/c/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
};
Expand Down Expand Up @@ -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 //
} //
};
Expand Down Expand Up @@ -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;
}
10 changes: 6 additions & 4 deletions tst/langtest/glint/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
};
Expand Down Expand Up @@ -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 //
} //
};
Expand Down Expand Up @@ -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;
}