Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM Backend #23

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 7 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
build:
runs-on: ${{ matrix.os }}

name: "${{ matrix.cpp_compiler }}-${{ matrix.os }}-${{ matrix.build_type }}"
name: "${{ matrix.build_type }}; LLVM: ${{ matrix.llvm_backend }}"

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
Expand All @@ -30,7 +30,8 @@ jobs:
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest]
build_type: [RelWithDebInfo]
build_type: [Release,Debug]
llvm_backend: [ON,OFF]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -80,16 +81,17 @@ jobs:
run: clang++ --version

- name: Check clang version
run: clang++-17 --version
run: clang++-18 --version

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=clang++-17
-DCMAKE_C_COMPILER=clang-17
-DCMAKE_CXX_COMPILER=clang++-18
-DCMAKE_C_COMPILER=clang-18
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DENDO_USE_LLVM=${{ matrix.llvm_backend }}
-GNinja
-S ${{ github.workspace }}

Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.28 FATAL_ERROR)

project(endo VERSION "0.0.0" LANGUAGES CXX)
project(endo VERSION "0.0.0")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

Expand All @@ -11,6 +11,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(ENDO_USE_LLVM "Use llvm as a backend for the shell" ON)

if(NOT DEFINED ENDO_TRACE_VM)
option(ENDO_TRACE_VM "Enables debug output" OFF)
Expand Down
2 changes: 1 addition & 1 deletion src/CoreVM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ target_include_directories(CoreVM PUBLIC
$<INSTALL_INTERFACE:include>
)

target_link_libraries(CoreVM PUBLIC fmt::fmt-header-only range-v3::range-v3)
target_link_libraries(CoreVM PUBLIC fmt::fmt-header-only range-v3::range-v3 crispy::core)
2 changes: 2 additions & 0 deletions src/CoreVM/transform/MergeBlockPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
module;

#include <list>
#include <algorithm>


module CoreVM;
namespace CoreVM
Expand Down
6 changes: 3 additions & 3 deletions src/shell/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module;
#include <shell/Visitor.h>
#include <fmt/format.h>

#include <crispy/assert.h>
#include <crispy/utils.h>

import Lexer;

Expand Down Expand Up @@ -146,8 +146,8 @@ export class ASTPrinter: public Visitor
}

void visit(LiteralExpr const& node) override { _result += fmt::format("{}", node.value); }
void visit(SubstitutionExpr const& node) override { crispy::ignore_unused(node); }
void visit(CommandFileSubst const& node) override { crispy::ignore_unused(node); }
void visit(SubstitutionExpr const& node) override {}
void visit(CommandFileSubst const& node) override {}
};

} // namespace endo::ast
33 changes: 32 additions & 1 deletion src/shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,37 @@ find_package(Threads REQUIRED)
# see https://github.com/llvm/llvm-project/issues/75108
# and https://github.com/ericniebler/range-v3/blob/f013aef2ae81f3661a560e7922a968665bedebff/include/meta/meta_fwd.hpp#L37
target_compile_definitions(Shell PUBLIC META_WORKAROUND_LLVM_28385)
target_link_libraries(Shell PUBLIC fmt::fmt-header-only vtparser crispy::core CoreVM InputEditor Threads::Threads util)
target_compile_definitions(Shell PUBLIC ENDO_VERSION_STRING="0.0.1")
set(shell_libs
fmt::fmt-header-only
vtparser
CoreVM
crispy::core
InputEditor
Threads::Threads
util)


if(ENDO_USE_LLVM)
find_package(LLVM REQUIRED)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
include("${LLVM_DIR}/AddLLVM.cmake")

include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
llvm_map_components_to_libnames(llvm_libs analysis core executionengine instcombine object orcjit runtimedyld scalaropts support native)
# Link against LLVM libraries
set(shell_libs
${shell_libs}
${llvm_libs})

target_sources(Shell
PUBLIC
FILE_SET CXX_MODULES FILES
LLVMBackend.cpp)
target_compile_definitions(Shell PUBLIC ENDO_USE_LLVM)
endif()


if(ENDO_TRACE_VM)
Expand All @@ -36,6 +66,7 @@ if(ENDO_TRACE_LEXER)
target_compile_definitions(Shell PUBLIC ENDO_TRACE_LEXER)
endif()

target_link_libraries(Shell PUBLIC ${shell_libs})

add_executable(endo
main.cpp
Expand Down
Loading
Loading