Skip to content

Commit 8e5b726

Browse files
committed
feat: implement initial LLVM compiler backend and add multi-platform release workflow via GitHub Actions
1 parent 36b2d9d commit 8e5b726

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ jobs:
3737
3838
- name: Install LLVM (Windows)
3939
if: matrix.os == 'windows-latest'
40-
run: choco install llvm -y
40+
run: |
41+
choco install llvm -y
42+
echo "C:/Program Files/LLVM/bin" >> $GITHUB_PATH
43+
echo "LLVM_DIR=C:/Program Files/LLVM/lib/cmake/llvm" >> $GITHUB_ENV
4144
4245
- name: Configure
4346
shell: bash
@@ -46,7 +49,6 @@ jobs:
4649
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
4750
-DBUILD_TESTS=OFF \
4851
-DBUILD_BENCH=OFF \
49-
-DLLVM_DIR="C:/Program Files/LLVM/lib/cmake/llvm" \
5052
-DCMAKE_PREFIX_PATH="C:/Program Files/LLVM"
5153
5254
- name: Build (verbose)

.github/workflows/release.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ jobs:
4848
4949
- name: Install LLVM (Windows)
5050
if: matrix.os == 'windows-latest'
51-
run: choco install llvm -y
51+
run: |
52+
choco install llvm -y
53+
echo "C:/Program Files/LLVM/bin" >> $GITHUB_PATH
54+
echo "LLVM_DIR=C:/Program Files/LLVM/lib/cmake/llvm" >> $GITHUB_ENV
5255
5356
- name: Configure CMake
5457
shell: bash
5558
run: |
56-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
57-
-DLLVM_DIR="C:/Program Files/LLVM/lib/cmake/llvm" \
58-
-DCMAKE_PREFIX_PATH="C:/Program Files/LLVM"
59+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="C:/Program Files/LLVM"
5960
6061
- name: Build
6162
shell: bash

src/compiler/backend_llvm.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
#include "../../include/backend_llvm.h"
12
#include "../../include/object.h"
3+
#include <llvm/IR/IRBuilder.h>
4+
#include <llvm/IR/LLVMContext.h>
5+
#include <llvm/IR/Module.h>
6+
#include <llvm/IR/Verifier.h>
7+
#include <llvm/Support/raw_ostream.h>
28
#include <vector>
39
#include <map>
410
#include <iostream>
11+
#include <memory>
512

613
// Do NOT use 'using namespace llvm;' due to clash with our 'Value' type.
714

8-
915
class LLVMEmitter {
1016
std::unique_ptr<llvm::LLVMContext> Context;
1117
std::unique_ptr<llvm::Module> ModuleOb;
@@ -218,3 +224,4 @@ extern "C" void emitLLVM(IRModule* module) {
218224
LLVMEmitter emitter;
219225
emitter.emitModule(module);
220226
}
227+

0 commit comments

Comments
 (0)