Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
f101d3b
mir: Jettison
dcbaker Oct 8, 2025
b091ba0
meson: switch to meson based formatting
dcbaker Oct 8, 2025
a7e9c86
mir: re-introduce the MIR layer
dcbaker Oct 8, 2025
eb9fcf6
mir: start defining basic types
dcbaker Oct 8, 2025
d9cf298
mir: Start adding serialization code
dcbaker Oct 8, 2025
cb40f55
mir: Add a phi node
dcbaker Oct 8, 2025
611f1b3
mir: add support to basic block for serializing
dcbaker Oct 8, 2025
16c2cd2
mir: Add more graph related things
dcbaker Oct 9, 2025
b3e2045
mir: Do more with building blocks
dcbaker Oct 9, 2025
1255038
mir: move BFS search to Node Iterator
dcbaker Oct 10, 2025
e0ae23a
mir: Start implementing the message type
dcbaker Oct 10, 2025
16a294c
mir: Work out more of the types
dcbaker Oct 10, 2025
0973e47
mir: Move Instruction to it's own TU
dcbaker Oct 10, 2025
9fa00ce
mir: split target out into it's own TU
dcbaker Oct 10, 2025
0ad9cae
mir: Split operation code out into it's own TU
dcbaker Oct 10, 2025
7be8896
mir: Split State into its own TU
dcbaker Oct 10, 2025
66d8475
mir: split projectstate out
dcbaker Oct 10, 2025
f92d574
mir/ir: move the IR definitions into a subdir
dcbaker Oct 10, 2025
efde382
mir/ir: add an IR namespace
dcbaker Oct 10, 2025
353656c
mir/ir/state: Start implementing some of the state type
dcbaker Oct 10, 2025
f6c3dd3
mir/ir: Add serialize implementation
dcbaker Oct 13, 2025
94ecf16
mir/ir: Add a public header for ir
dcbaker Oct 13, 2025
0aa120e
mir/ir: Add instructions for elementary types
dcbaker Oct 13, 2025
bb71a45
mir: Add stubs for an AST -> MIR conversion pass
dcbaker Oct 13, 2025
c055995
mir/ir: Start adding deserialize support
dcbaker Oct 13, 2025
005c49e
frontend/driver: use node.hpp instead of parser.yy.hpp
dcbaker Oct 13, 2025
1426c9f
mir/ir/deserialize: Build as standalone library to avoid warning leaks
dcbaker Oct 13, 2025
aca40d0
mir/ir: Start writing some deserialization code
dcbaker Oct 14, 2025
c7f18b7
mir/ir: Add a File representation
dcbaker Oct 14, 2025
d40cf1e
mir/ir/operation: Start implementing some operation pieces
dcbaker Oct 14, 2025
ca5d476
mir: Add more basic building blocks
dcbaker Apr 7, 2026
c67183f
mir: Keyword arguments can have Instructions as keys
dcbaker Apr 7, 2026
068ac0b
mir: Each node may have a maximum of two successors
dcbaker Apr 8, 2026
7a344a5
mir: Move deserializer out of ir subdir
dcbaker Apr 8, 2026
0c551c5
mir/ir: Add representation for Phi node
dcbaker Apr 8, 2026
8e217c7
mir/ir: Add a name and ssa_id to the variable
dcbaker Apr 8, 2026
9d17b48
mir/ir: Add an undefined type
dcbaker Apr 8, 2026
2650486
mir: Add stubs for all AST -> MIR lowering functions
dcbaker Apr 8, 2026
3a29549
mir/ir: Rework operation to store InstructionTypes instead of
dcbaker Apr 8, 2026
9c6e762
mir/ir: Introduce the idea of 1 source and 2 source operations
dcbaker Apr 8, 2026
2cda422
mir/ir: Add representation of array
dcbaker Apr 8, 2026
52f8fc6
mir/ir: Map most of the operator types
dcbaker Apr 8, 2026
893d9be
mir/ir: Add dict representation
dcbaker Apr 8, 2026
4391f24
mir/ir: Add a ternary instruction
dcbaker Apr 8, 2026
4bc9cc7
mir: Convert AST expressions to MIR expressions
dcbaker Apr 8, 2026
45fb85c
mir/ir: Add a name field to the identifier
dcbaker Apr 8, 2026
5bee2e4
mir/ir: Add constructor for instruction that sets a variable
dcbaker Apr 8, 2026
2aa6de4
WIP: mir: convert AST statements to MIR
dcbaker Apr 8, 2026
e15ae62
mir/ir: Implement function calls
dcbaker Apr 8, 2026
148d95f
mir: Get a bunch of statement lowering from AST to MIR compiling
dcbaker Apr 9, 2026
e661477
mir: Add lowering for loops, including continue and break
dcbaker Apr 9, 2026
8f11330
mir: Start adding a builder class
dcbaker Apr 10, 2026
4b29fcb
mir: Convert basic block to list of unique_ptr
dcbaker Apr 10, 2026
6ec69c7
mir/builder: Start adding a builder helper
dcbaker Apr 10, 2026
ce88f6e
mir/builder: Add function call helpers
dcbaker Apr 10, 2026
7f27e00
mir: use the builder in ast_to_mir
dcbaker Apr 10, 2026
7a64dba
mir: No more operations
dcbaker Apr 10, 2026
e7f074d
mir/builder: Add another helper to simplify enable_if calls
dcbaker Apr 13, 2026
b263050
mir/builder: Use a helper function to create InstructionBuilders
dcbaker Apr 13, 2026
2f719bd
mir: Track that an Instruction is a block condition
dcbaker Apr 13, 2026
d032557
ast_to_mir: fill out more of the loop code
dcbaker Apr 13, 2026
3517e19
mir/builder: document that Builder is not copy safe
dcbaker Apr 13, 2026
531ddd6
mir/builder: convert Builder to use a cursor
dcbaker Apr 13, 2026
4ab597a
mir: pass Builders instead of raw nodes
dcbaker Apr 13, 2026
83a80d1
mir/builder: Allow InstructionBuilders to be implicitly converted to …
dcbaker Apr 13, 2026
ccdfa62
mir/builder: Allow InstructionBuilder to be implicitly converted to
dcbaker Apr 13, 2026
7017502
mir/ast_to_mir: change comment style to fix trailing `\`
dcbaker Apr 13, 2026
672baed
mir/ast_to_mir: Make more progress and translating the loop
dcbaker Apr 13, 2026
59f2637
mir: ast -> MIR first pass complete
dcbaker Apr 14, 2026
664344a
main: and a compile command to convert meson DSL into serialized form
dcbaker Apr 14, 2026
2ac3c4a
mir: Start fixing compilation issues
dcbaker Apr 14, 2026
5c78243
mir: Start adding test for ast_to_mir
dcbaker Apr 14, 2026
818ec57
mir/deserialize: fix output name of locations
dcbaker Apr 14, 2026
5a4cbe9
mir/ast_to_mir rewrite the if lowering code
dcbaker Apr 14, 2026
e63f970
mir/ir: Fix some uninitialized variables
dcbaker Apr 14, 2026
fdc7d77
mir/ir: Fix some whitespace issues with serialization code
dcbaker Apr 14, 2026
0e5a50e
mir/ast_to_mir: fix foreach loop lowering
dcbaker Apr 14, 2026
b891f6e
mir/ir: Fix Node's preventing their predecessors from being freed
dcbaker Apr 14, 2026
de22c72
mir: Fix potential invalid memory set on Builder
dcbaker Apr 14, 2026
eb885e7
mir: Split some gtest helpers out into their own files
dcbaker Apr 15, 2026
d256e98
mir/builder: Add some tests for the various builder constructors
dcbaker Apr 15, 2026
570b3bd
mir: use std::array::at
dcbaker Apr 15, 2026
273317d
mir: passed builders need to be in managed memory
dcbaker Apr 15, 2026
f0de037
mir: fix ownership issue for loop variables
dcbaker Apr 16, 2026
4951c10
mir: Fix iteration visiting a node before it's parent
dcbaker Apr 16, 2026
01a5815
mir: Fix swapped legs of foreach header
dcbaker Apr 16, 2026
7e79e00
mir/ir: Add atest for a more complex for loop
dcbaker Apr 16, 2026
d2dc876
mir/ir: Fix serialization of cfg
dcbaker Apr 16, 2026
b1d6f10
mir/ir: Add predecessors and successors to node serialization
dcbaker Apr 16, 2026
6a7a78b
subprojects: Update gtest wrap
dcbaker Apr 16, 2026
d9c3de7
mir/ir: Add helpers for printing serialized mir
dcbaker Apr 16, 2026
c5e8e05
mir/ir: Pass indentation level into serializer code
dcbaker Apr 17, 2026
9306bf8
mir/ir: delete ternary
dcbaker Apr 17, 2026
df76355
mir/ir: move comment to more logical place
dcbaker Apr 17, 2026
d116d17
mir/ir: Add a FunctionId enum to FunctionCall
dcbaker Apr 17, 2026
5656730
mir: remove opcodes for `not equal` and `not in`
dcbaker Apr 17, 2026
0c1d064
mir/ir: Use an unordered set to store node predecessors
dcbaker Apr 17, 2026
7ebe32d
mir/ir: Add a function to reparent nodes
dcbaker Apr 17, 2026
ebd3671
mir/passes: Add pass to replace ternary with blocks
dcbaker Apr 17, 2026
6ed9a61
mir/ir: Move some graph implementations from header to code
dcbaker Apr 17, 2026
0c2db9c
mir/ir: re-arrange graph.cpp to make more sense
dcbaker Apr 17, 2026
0ab3ae1
mir/ir: Add a custom iterator to the CFG
dcbaker Apr 17, 2026
26b08a9
mir: remove ternaries after lowering AST -> MIR
dcbaker Apr 17, 2026
58f4f06
mir: Move ownership of blocks from Nodes to CFG
dcbaker Apr 21, 2026
fa20f6c
mir: use a special tail node on the CFG graph
dcbaker Apr 21, 2026
db8db32
mir/ir: Store the depth of the node in the graph
dcbaker Apr 21, 2026
ac11cc8
mir/ir: iterate at the Node level
dcbaker Apr 22, 2026
81b2ff7
mir/ir: Add a reverse iterator to Node and CFG
dcbaker Apr 23, 2026
fdb3918
mir/ir/graph: Rework node walking, again
dcbaker Apr 23, 2026
4d25f9e
mir/ir: split CFG and Node implementations into separate TUs
dcbaker Apr 28, 2026
dc9a3fc
mir/ir: Merge BasicBlock and Node
dcbaker Apr 28, 2026
ea21d9f
mir/ir: Rename Node to BasicBlock
dcbaker Apr 28, 2026
73f655b
mir/ir: Store pointers to Instruction in the Phi node
dcbaker Apr 30, 2026
f208d5a
Add cli11
dcbaker May 1, 2026
79f430a
options: Use cli11
dcbaker May 1, 2026
c2c7f91
options: remove unused version header
dcbaker May 1, 2026
7130f13
mir/ir: Fix serialization of BasicBlocks
dcbaker May 1, 2026
26554bc
mir/ir: standardize string serialization
dcbaker May 1, 2026
5b6fdf6
mir/deserializer: fix compilation
dcbaker May 1, 2026
b16d41d
ci: update ci and devcontainer requirements
dcbaker Jun 2, 2026
da45684
mir: Add missing header
dcbaker Sep 20, 2026
5fe9cc1
CI: update meson version to 1.3
dcbaker Sep 20, 2026
24ac7ec
CI: only run codeql-analysis.yml on relevant paths
dcbaker Sep 20, 2026
6319512
CI: more fixing
dcbaker Sep 20, 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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers-extra/features/apt-packages:1": {
"packages": "meson,muon-meson,ninja-build,libfl-dev,libgtest-dev,libgtest-dev,libgmock-dev,clang-tidy,clang-format,flex,bison,ccache,python3,python-is-python3,clang"
"packages": "meson,muon-meson,ninja-build,libcli11-dev,libfl-dev,libgtest-dev,libgtest-dev,libgmock-dev,clang-tidy,clang-format,flex,bison,ccache,python3,python-is-python3,clang"
}
},

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
- name: apt
run: |
sudo apt update
sudo apt install libfl-dev ninja-build clang-format
sudo apt install libcli11-dev libfl-dev libgtest-dev ninja-build clang-format
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: install meson
run: pip install meson==0.60.3
run: pip install meson==1.3
- name: generate headers
run: |
meson setup builddir
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
- name: apt
run: |
sudo apt update
sudo apt install libfl-dev libgtest-dev ninja-build clang-tidy
sudo apt install libcli11-dev libfl-dev libgtest-dev ninja-build clang-tidy
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: install meson
run: pip install meson==0.60.3
run: pip install meson==1.3
- name: generate headers
run: |
meson setup builddir
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ name: "CodeQL"
on:
push:
branches: [ main ]
paths:
- 'src/**'
- 'meson.build'
- 'meson_options.txt'
- '.github/workflows/codeql-analysis.yml'
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
paths:
- 'src/**'
- 'meson.build'
- 'meson_options.txt'
- '.github/workflows/codeql-analysis.yml'
schedule:
- cron: '42 3 * * 4'

Expand Down Expand Up @@ -67,7 +77,7 @@ jobs:
key: gcc

- name: install meson
run: pip install meson==0.60.3
run: pip install meson==1.3

- name: Meson
run: |
Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ jobs:
- name: apt
run: |
sudo apt update
sudo apt install libfl-dev libgtest-dev ninja-build ccache clang
sudo apt install libfl-dev libgtest-dev libcli11-dev ninja-build ccache clang
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: install meson
run: pip install meson==0.60.3
run: pip install meson==1.3
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
Expand All @@ -65,3 +65,27 @@ jobs:
meson setup builddir ${{ matrix.cfg.setup_options }}
ninja -C builddir
ninja -C builddir test
<<<<<<< HEAD:.github/workflows/meson.yml
=======

clang-tidy:
runs-on: ubuntu-latest
steps:
- name: apt
run: |
sudo apt update
sudo apt install libfl-dev libcli11-dev libgtest-dev ninja-build clang-tidy
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: install meson
run: pip install meson==1.3
- name: generate headers
run: |
meson setup builddir
ninja -C builddir src/version.hpp src/frontend/parser.yy.hpp
- name: clang-tidy
run: |
ninja -C builddir clang-tidy
>>>>>>> 1c6639d (ci: update ci requirements):.github/workflows/ubuntu.yml
9 changes: 7 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2021-2024 Intel Corporation
# Copyright © 2021-2026 Intel Corporation

project(
'meson++',
Expand All @@ -12,6 +12,10 @@ project(

cpp = meson.get_compiler('cpp')

if get_option('debug')
add_project_arguments('-DMESONPP_DEBUG', language : 'cpp')
endif

add_project_arguments(
cpp.get_supported_arguments(
'-Werror=switch-enum',
Expand Down Expand Up @@ -39,5 +43,6 @@ dep_gtest = dependency(
fallback : ['gtest', 'gtest_main_dep'],
)

dep_cli11 = dependency('CLI11')

subdir('src')
subdir('tests')
2 changes: 2 additions & 0 deletions meson.format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
wide_colon = true
use_editor_config = true
1 change: 0 additions & 1 deletion muon_fmt.ini

This file was deleted.

6 changes: 3 additions & 3 deletions src/frontend/driver.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright © 2021-2024 Intel Corporation
// Copyright © 2021-2025 Intel Corporation

#pragma once

#include "node.hpp"

#include <istream>
#include <memory>
#include <string>
#include <vector>

#include "parser.yy.hpp"

namespace Frontend {

class Driver {
Expand Down
18 changes: 7 additions & 11 deletions src/frontend/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2021 Intel Corporation
# Copyright © 2021-2025 Intel Corporation

prog_bison = find_program('bison', version : '>= 3.2')
prog_flex = find_program('flex')
Expand All @@ -24,27 +24,25 @@ if not meson.get_compiler('cpp').has_header('FlexLexer.h')
error('FlexLexer.h header not found, maybe install flex-dev?')
endif

# Bison generates swtiches tahat don't handle all of their enum values
# Bison generates switches that don't handle all of their enum values
# We can't fix that, so we have to ignore it.
#
# Because of this we want to be sure that we don't propogate the parser header
# out of thehis bit of code
_frontend_args = cpp.get_supported_arguments(
'-Wno-switch-enum',
)

# out of this bit of code
libfrontend = static_library(
'frontend',
[parser, scanner, 'node.cpp', 'subdir_visitor.cpp', 'driver.cpp'],
cpp_args : [_frontend_args, '-Wno-implicit-fallthrough'],
cpp_args : cpp.get_supported_arguments(
'-Wno-switch-enum',
'-Wno-implicit-fallthrough',
),
dependencies : [dep_fs, idep_util],
)

inc_frontend = include_directories('.')

idep_frontend = declare_dependency(
link_with : libfrontend,
compile_args : _frontend_args,
include_directories : inc_frontend,
)

Expand All @@ -53,7 +51,6 @@ test(
executable(
'parser_test',
['parser_test.cpp', parser[1]],
cpp_args : _frontend_args,
link_with : libfrontend,
dependencies : dep_gtest,
),
Expand All @@ -64,5 +61,4 @@ executable(
'standalone_parser',
['standalone.cpp', parser[1]],
link_with : libfrontend,
cpp_args : _frontend_args,
)
64 changes: 3 additions & 61 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright © 2021-2025 Intel Corporation
// Copyright © 2021-2026 Intel Corporation

/**
* Main Meson++ entrypoint
*/

#include "ast_to_mir.hpp"
#include "backends/ninja/entry.hpp"
#include "driver.hpp"
#include "exceptions.hpp"
#include "log.hpp"
#include "lower.hpp"
#include "options.hpp"
#include "state/state.hpp"
#include "tools/compile.hpp"
#include "tools/test.hpp"
#include "tools/vcs_tag.hpp"
#include "version.hpp"
Expand All @@ -24,36 +21,6 @@ namespace fs = std::filesystem;

namespace {

bool emit_messages(MIR::CFGNode & block) {
static std::vector<MIR::MessageLevel> levels{MIR::MessageLevel::MESSAGE,
MIR::MessageLevel::WARN, MIR::MessageLevel::ERROR};
bool errors = false;

for (const auto & level : levels) {
if (level == MIR::MessageLevel::MESSAGE) {
std::cout << Util::Log::bold("User Messages:") << std::endl;
} else if (level == MIR::MessageLevel::WARN) {
std::cout << Util::Log::yellow("Warnings:") << std::endl;
} else if (level == MIR::MessageLevel::ERROR) {
std::cout << Util::Log::red("Errors:") << std::endl;
} else if (level == MIR::MessageLevel::DEBUG) {
std::cout << Util::Log::bold("Debug information:") << std::endl;
}
for (const auto & i : block.block->instructions) {
if (std::holds_alternative<MIR::MessagePtr>(i)) {
const auto & m = std::get<MIR::MessagePtr>(i);
if (m->level == level) {
std::cout << Util::Log::bold(" * ") << m->message << std::endl;
}
if (m->level == MIR::MessageLevel::ERROR) {
errors = true;
}
}
}
}
return errors;
}

int configure(const Options::ConfigureOptions & opts) {
std::cout << Util::Log::bold("The Meson++ build system") << std::endl
<< "Version: " << version::VERSION << std::endl
Expand All @@ -64,41 +31,16 @@ int configure(const Options::ConfigureOptions & opts) {
Frontend::Driver drv{};
auto block = drv.parse(opts.sourcedir / "meson.build");

MIR::State::Persistant pstate{opts.sourcedir, opts.builddir, opts.program};

// Create IR from the AST, then run our lowering passes on it
MIR::CFG irlist = MIR::lower_ast(block, pstate);
MIR::Passes::lower_project(irlist.root, pstate);
MIR::lower(irlist.root, pstate);

const bool errors = emit_messages(*irlist.root);
if (errors) {
throw Util::Exceptions::MesonException("Configure failed with errors.");
}

Backends::Ninja::generate(*irlist.root, pstate);

return 0;
};

int test(const Options::TestOptions & opts) {
auto && path = opts.builddir / "tests.serialized";
if (!fs::exists(path)) {
std::cout << "No tests defined" << std::endl;
return 0;
}

auto && tests = Backends::Common::load_tests(path);
return Tools::run_tests(tests, fs::absolute(opts.builddir));
}

struct OptionHandler {
int operator()(const Options::ConfigureOptions & opts) { return configure(opts); }
int operator()(const Options::TestOptions & opts) { return test(opts); }
int operator()(const Options::VCSTagOptions & opts) {
return Tools::generate_vcs_tag(opts.infile, opts.outfile, opts.version, opts.replacement,
opts.source_dir, opts.depfile);
}
int operator()(const Options::CompileOptions & opts) { return Tools::compile(opts.infile); }
};

} // namespace
Expand Down
20 changes: 6 additions & 14 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2021-2024 Intel Corporation
# Copyright © 2021-2026 Intel Corporation

subdir('util')
subdir('frontend')
subdir('mir')
subdir('backends')

version_hpp = vcs_tag(
input: 'version.hpp.in',
output: 'version.hpp',
)
version_hpp = vcs_tag(input : 'version.hpp.in', output : 'version.hpp')

mesonpp = executable(
'meson++',
[
'main.cpp',
'options.cpp',
'tools/compile.cpp',
'tools/test.cpp',
'tools/vcs_tag.cpp',
version_hpp,
locations_hpp,
],
cpp_args: [
cpp_args : [
'-D_GNU_SOURCE', # for getopt
],
dependencies: [
idep_frontend,
idep_mir,
idep_util,
idep_backend,
],
install: true,
dependencies : [idep_frontend, idep_util, idep_mir, dep_cli11],
install : true,
)
Loading
Loading