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

MIR Backend #94

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8080760
Removed LLVM backend
muit Sep 2, 2023
221fc7f
Updated Pipe
muit Sep 3, 2023
fa66fda
Added initial C generation for MIR
muit Sep 10, 2023
23b7886
Added compile settings
muit Oct 18, 2023
fcc52b4
Updated Pipe 1/2
muit Oct 20, 2023
c98d9f9
Pipe format fixes
muit Dec 2, 2023
705f3c7
Fix mir compilation issue
muit Dec 6, 2023
45a44ed
C2MIR Changes
muit Dec 6, 2023
bbb3a4f
Updated Imgui to 1.90
muit Dec 8, 2023
9144b90
Debug tool fixes
muit Dec 9, 2023
8199bea
Improved entity inspectors
muit Dec 9, 2023
d782aa8
AST debugger improvements
muit Dec 10, 2023
5b7bcaf
Fixes for Ubuntu/GCC/Clang
muit Jan 6, 2024
ed216c8
[CICD] Use GCC 13
muit Jan 6, 2024
0454395
Implemented dumping basic pool info
muit Jan 14, 2024
28273b5
Fixed two build crashes
muit Jan 17, 2024
c7aa0ca
Simplified component declarations
muit Jan 31, 2024
d712491
AST namespace is now ast
muit Jan 31, 2024
022acca
Elements panel improvements
muit Feb 1, 2024
f9df66a
Multiple UI and AST fixes
muit Feb 2, 2024
327d898
Watch for changes in project folder
muit Feb 3, 2024
ddd2311
Stop watching project folder on close
muit Feb 3, 2024
369a3ca
Added icons for file types
muit Feb 3, 2024
7924ed5
Many IR generation fixes
muit Feb 4, 2024
af62f96
Fixes to MIR JIT. JIT executes now 🎊
muit Feb 5, 2024
5e96ff3
Added icon to editor window, use new logo in exe files
muit Feb 6, 2024
21d15f7
Added multiple resolution window icons
muit Feb 6, 2024
8beebf1
Improved project manager
muit Feb 7, 2024
0cc63e3
Updated Pipe
muit Feb 24, 2024
a4d6e5d
Small change
muit Feb 24, 2024
99c3517
Updated Pipe
muit Feb 25, 2024
6b5c0da
Fix pipe namespaces
muit Feb 28, 2024
9c6d455
Load User Settings
muit Feb 29, 2024
c7818be
Implemented saving settings
muit Mar 1, 2024
a6c8949
Updated Pipe
muit Apr 28, 2024
34f0fd9
Updated Pipe
muit May 4, 2024
15efa02
Fix IO warning
muit May 5, 2024
bcba573
Updated Pipe
muit May 15, 2024
21f8419
Added ECS & reflection debugging from Pipe
muit May 21, 2024
610c18d
Improved Pipe ECS & Refelction debug
muit May 22, 2024
2940711
Updated Pipe
muit May 22, 2024
114b174
Updated Pipe
muit Jun 30, 2024
910f38d
Updated Pipe
muit Jul 3, 2024
8a4cf1e
Updated Pipe
muit Jul 8, 2024
bb4722e
Updated Pipe
muit Oct 5, 2024
4a0c0e4
Updated Pipe
muit Oct 5, 2024
9d2315e
Renamed modules & updated Pipe
muit Nov 30, 2024
018123b
Updated Pipe
muit Dec 1, 2024
be5ab77
Updated Pipe
muit Dec 1, 2024
241789a
Updated Pipe
muit Dec 5, 2024
cc8bb14
Updated Pipe
muit Dec 6, 2024
d4daf85
Fixed Backend reflection
muit Dec 13, 2024
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
7 changes: 4 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: None
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: false
BreakBeforeConceptDeclarations: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: AfterComma
BreakStringLiterals: true
Expand Down Expand Up @@ -58,10 +57,11 @@ IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentPPDirectives: BeforeHash
IndentRequires: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: OuterScope
MaxEmptyLinesToKeep: 2
Expand All @@ -78,6 +78,7 @@ PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReferenceAlignment: Left
ReflowComments: true
RequiresClausePosition: WithPreceding
SortIncludes: CaseInsensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
Expand Down
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: '-*, readability-identifier-naming, clang-analyzer-*, clang-analyzer-cplusplus*, performance-*, bugprone-*, modernize-*, misc-unused-*,-bugprone-macro-parentheses, -modernize-use-trailing-return-type, -modernize-use-nodiscard, -modernize-use-default-member-init, -modernize-use-equals-default, -performance-unnecessary-value-param, -misc-unused-parameters, -bugprone-branch-clone, -modernize-avoid-c-arrays, -bugprone-easily-swappable-parameters'
Checks: '-*, readability-identifier-naming, clang-analyzer-*, clang-analyzer-cplusplus*, performance-*, bugprone-*, modernize-*, misc-unused-*,-bugprone-macro-parentheses, -modernize-use-trailing-return-type, -modernize-use-nodiscard, -modernize-use-default-member-init, -modernize-use-equals-default, -modernize-raw-string-literal -performance-unnecessary-value-param, -misc-unused-parameters, -bugprone-branch-clone, -modernize-avoid-c-arrays, -bugprone-easily-swappable-parameters'
WarningsAsErrors: ''
HeaderFilterRegex: 'Corresponding Header'
FormatStyle: file
Expand Down
64 changes: 20 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:
pull_request:
workflow_call:

env:
cache-version: 0

jobs:
Build:
name: ${{ matrix.os-name }} (${{ matrix.compiler }}, ${{ matrix.config }})
Expand All @@ -32,84 +29,63 @@ jobs:
- name: windows-clang
os: windows-latest
os-name: windows
compiler: clang
compiler: clang-16
cxx: clang-cl
cc: clang-cl
- name: linux-clang
os: ubuntu-latest
os-name: linux
compiler: clang
compiler: clang-16
cxx: clang++
cc: clang
- name: linux-gcc
os: ubuntu-latest
os-name: linux
compiler: gcc
cxx: g++-10
cc: gcc-10
compiler: gcc-13
cxx: g++
cc: gcc
- name: macos-clang
os: macos-latest
os: macos-14
os-name: macos
compiler: clang
compiler: clang-16
cxx: clang++
cc: clang

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Init Submodules
uses: snickerbockers/submodules-init@v4
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install dependencies
if: ${{ matrix.os-name == 'linux'}}
run: |
sudo apt-get update
sudo apt-get install -y build-essential xz-utils curl libx11-dev xorg-dev libglu1-mesa-dev

- uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.compiler == 'msvc' }}

- name: Cache LLVM
if: ${{ matrix.compiler == 'clang' }}
id: cache-llvm
uses: actions/cache@v2
with:
path: ${{ runner.temp }}/llvm
key: llvm-15.0-${{ matrix.os-name }}
- name: Install LLVM
if: ${{ matrix.compiler == 'clang' }}
uses: KyleMayes/install-llvm-action@v1
- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
version: "15.0"
directory: ${{ runner.temp }}/llvm
cached: ${{ steps.cache-llvm.outputs.cache-hit }}


- name: Download pre-built development LLVM for Rift
run: |
curl -L -o "${{ runner.temp }}/rift-llvm.zip" https://github.com/piperift/rift-llvm/releases/download/v14.0.5/llvm-${{ matrix.os-name }}-${{ matrix.config }}.zip
7z x -o"${{ runner.temp }}/rift" "${{ runner.temp }}/rift-llvm.zip"

- name: Get CMake
uses: lukka/get-cmake@latest

compiler: ${{ matrix.compiler }}
vcvarsall: ${{ matrix.os-name == 'windows' }}
cmake: true
ninja: true

- name: Cache Build
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: Build
key: ${{ matrix.os-name }}-${{ matrix.compiler }}-${{ matrix.config }}-build-${{ secrets.VCACHE}}

- name: Configure
run: cmake -S . -B Build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DRIFT_LLVM_PATH='${{ runner.temp }}/rift/llvm'
run: cmake -GNinja -S . -B Build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DRIFT_LLVM_PATH='${{ runner.temp }}/rift/llvm'

- name: Build
run: cmake --build Build --config ${{ matrix.config }}

- name: Upload binaries as artifacts
uses: actions/upload-artifact@v2
if: ${{ matrix.config == 'Release' && matrix.compiler == 'clang' }} # Only clang artifacts are stored
uses: actions/upload-artifact@v3
if: ${{ matrix.config == 'Release' && contains(matrix.compiler, 'clang') }} # Only clang artifacts are stored
with:
name: rift-${{ matrix.os-name }}
path: Build/Bin
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Build
Saved
Testing
Extern/rift-llvm

.vscode/c_cpp_properties.json
/compile_commands.json
Expand Down
11 changes: 9 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"cmake.configureOnOpen": true,
"cmake.buildDirectory": "${workspaceFolder}/Build",
"files.associations": {
"*.tmpl": "html",
"cmath": "cpp",
"algorithm": "cpp",
"any": "cpp",
Expand Down Expand Up @@ -155,7 +156,10 @@
"splines": "cpp",
"typeindex": "cpp",
"qtalignedmalloc": "cpp",
"*.traits": "cpp"
"*.traits": "cpp",
"span": "cpp",
"stdfloat": "cpp",
"cuchar": "cpp"
},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"banditTestExplorer.testsuites": [
Expand Down Expand Up @@ -232,5 +236,8 @@
"LLVM"
]
},
"dotnet.defaultSolution": "disable"
"dotnet.defaultSolution": "disable",
"search.exclude": {
"**/.git": true
}
}
16 changes: 8 additions & 8 deletions Apps/CLI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Copyright 2015-2023 Piperift - All rights reserved

add_executable(RiftCLIExe Src/main.cpp)
add_executable(RiftCLI Src/main.cpp)

target_include_directories(RiftCLIExe PUBLIC Include)
target_include_directories(RiftCLI PUBLIC Include)
file(GLOB_RECURSE CLI_SOURCE_FILES CONFIGURE_DEPENDS Src/*.cpp Src/*.h)
target_sources(RiftCLIExe PRIVATE ${CLI_SOURCE_FILES})
target_sources(RiftCLI PRIVATE ${CLI_SOURCE_FILES})

target_link_libraries(RiftCLIExe PUBLIC
target_link_libraries(RiftCLI PUBLIC
CLI11
RiftAST
RiftASTLib
RiftCompilerModules
)

rift_module(RiftCLIExe)
set_target_properties(RiftCLIExe PROPERTIES OUTPUT_NAME "Rift")
set_icon(RiftCLIExe ../../Resources/Icon.ico)
rift_module(RiftCLI)
set_target_properties(RiftCLI PROPERTIES OUTPUT_NAME "Rift")
set_icon(RiftCLI Icon.ico)
Binary file modified Apps/CLI/Icon.ico
Binary file not shown.
52 changes: 37 additions & 15 deletions Apps/CLI/Src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Copyright 2015-2023 Piperift - All rights reserved
// Copyright 2015-2024 Piperift - All rights reserved

#include <Pipe/Memory/NewDelete.h>
#include <PipeNewDelete.h>
// Override as first include

#include <AST/Utils/ModuleUtils.h>
#include <ASTModule.h>
#include <Compiler/Compiler.h>
#include <Compiler/Utils/BackendUtils.h>
#include <GraphViewModule.h>
#include <LLVMBackendModule.h>
#include <MIRBackendModule.h>
#include <Pipe/Core/Profiler.h>
#include <Pipe.h>
#include <Pipe/Files/Paths.h>
#include <Pipe/Pipe.h>
#include <Pipe/Files/PlatformPaths.h>
#include <PipeTime.h>
#include <Rift.h>

#include <chrono>
#include <CLI/CLI.hpp>

#include <thread>


using namespace rift;
Expand Down Expand Up @@ -45,7 +45,7 @@ namespace rift
const Tag def = backends.IsEmpty() ? Tag::None() : backends[0]->GetName();
selected = def.AsString();

auto stdDesc = Strings::Convert<std::string, TChar>(desc);
auto stdDesc = Strings::Convert<std::string, char>(desc);
app.add_option("-b,--backend", selected, stdDesc, true);
}

Expand All @@ -65,15 +65,40 @@ namespace rift

int main(int argc, char** argv)
{
p::Initialize("Saved/Logs");
p::Logger logger = p::Logger{.infoCallback = [](StringView msg) {
String text;
auto now = p::DateTime::Now();
now.ToString("[%Y/%m/%d %H:%M:%S]", text);
p::Strings::FormatTo(text, "[Info] {}\n", msg);
std::cout << text;
}, .warningCallback = [](StringView msg) {
String text;
auto now = p::DateTime::Now();
now.ToString("[%Y/%m/%d %H:%M:%S]", text);
p::Strings::FormatTo(text, "[Warning] {}\n", msg);
std::cout << text;
}, .errorCallback = [](StringView msg) {
String text;
auto now = p::DateTime::Now();
now.ToString("[%Y/%m/%d %H:%M:%S]", text);
p::Strings::FormatTo(text, "[Error] {}\n", msg);
std::cout << text;
}};

p::Initialize(&logger);
p::Info(p::PlatformPaths::GetUserSettingsPath());
EnableModule<ASTModule>();
EnableModule<LLVMBackendModule>();
EnableModule<MIRBackendModule>();
EnableModule<GraphViewModule>();

CompilerConfig config;

CLI::App app{"Rift compiler"};
String path;
app.add_option("-p,--project", path, "Project path")->required();
app.add_option("-v,--verbose", config.verbose, "Verbose")->required();
app.add_flag("-O0{0},-O1{1},-O2{2},-O3{3}", config.optimization, "Optimization")
->expected(0, 3);


String selectedBackendStr;
Expand All @@ -84,18 +109,15 @@ int main(int argc, char** argv)

TPtr<Backend> backend = FindBackendByName(availableBackends, Tag(selectedBackendStr));

ZoneScopedNC("CLI Execution", 0x459bd1);
ast::Tree ast;
ast::OpenProject(ast, path);

AST::Tree ast;
AST::OpenProject(ast, path);

if (!AST::HasProject(ast))
if (!ast::HasProject(ast))
{
p::Error("Couldn't open project '{}'", p::ToString(path));
return 1;
}

CompilerConfig config;
Build(ast, config, backend);

while (true)
Expand Down
17 changes: 8 additions & 9 deletions Apps/Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Copyright 2015-2023 Piperift - All rights reserved

add_executable(RiftEditorExe Src/main.cpp)
add_executable(RiftEditor Src/main.cpp)

target_include_directories(RiftEditorExe PUBLIC Include)
target_include_directories(RiftEditor PUBLIC Include)
file(GLOB_RECURSE RiftEditor_SOURCE_FILES CONFIGURE_DEPENDS Src/*.cpp Src/*.h)
target_sources(RiftEditorExe PRIVATE ${RiftEditor_SOURCE_FILES})
target_sources(RiftEditor PRIVATE ${RiftEditor_SOURCE_FILES})

target_link_libraries(RiftEditorExe PUBLIC
target_link_libraries(RiftEditor PUBLIC
RiftCompilerModules
RiftEditor
RiftEditorLib
RiftEditorModules
)
target_compile_definitions(RiftEditorExe PUBLIC RIFT_EDITOR=1)
target_compile_definitions(RiftEditor PUBLIC RIFT_EDITOR=1)

rift_module(RiftEditorExe)
set_target_properties(RiftEditorExe PROPERTIES OUTPUT_NAME "RiftEditor")
set_icon(RiftEditorExe Icon.ico)
rift_module(RiftEditor)
set_icon(RiftEditor Icon.ico)
Binary file modified Apps/Editor/Icon.ico
Binary file not shown.
Loading
Loading