Skip to content

Commit

Permalink
Add LLVM setup step to CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer committed Jul 14, 2021
1 parent 22ce128 commit 56b05c8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v2
with:
path: ../llvm
key: llvm-12-0-1

- name: Setup LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
mkdir -p ../llvm
cd ../llvm
curl -fsSL https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-12.0.1.tar.gz -o llvm.tar.gz
tar -zxf llvm.tar.gz
mkdir ./llvm-project-llvmorg-12.0.1/build
cd ./llvm-project-llvmorg-12.0.1/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELEASE="-O2" -G "Unix Makefiles" ../llvm
cmake --build .
export LLVM_DIR=/home/runner/work/spice/llvm/llvm-project-llvmorg-12.0.1/build/lib/cmake/llvm
- name: Download Libs
run: |
mkdir -p ./compiler/lib
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(BINARY ${CMAKE_PROJECT_NAME})
set(LLVM_DIR C:/Users/i516467/Documents/JustForFunGitHubClones/llvm-project/build-release/lib/cmake/llvm)
set(LLVM_DIR $ENV{LLVM_DIR})

LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

Expand Down
4 changes: 0 additions & 4 deletions compiler/src/ir/GeneratorVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ antlrcpp::Any GeneratorVisitor::visitFunctionCall(SpiceParser::FunctionCallConte
return builder->CreateCall(fct, argValues);
}

antlrcpp::Any GeneratorVisitor::visitImportStmt(SpiceParser::ImportStmtContext *ctx) {
return SpiceBaseVisitor::visitImportStmt(ctx);
}

antlrcpp::Any GeneratorVisitor::visitReturnStmt(SpiceParser::ReturnStmtContext *ctx) {
auto returnValue = visit(ctx->assignment()).as<llvm::Value*>();
// Build return value
Expand Down
1 change: 0 additions & 1 deletion compiler/src/ir/GeneratorVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class GeneratorVisitor : public SpiceBaseVisitor {
antlrcpp::Any visitIfStmt(SpiceParser::IfStmtContext *ctx) override;
antlrcpp::Any visitDeclStmt(SpiceParser::DeclStmtContext *ctx) override;
antlrcpp::Any visitFunctionCall(SpiceParser::FunctionCallContext *ctx) override;
antlrcpp::Any visitImportStmt(SpiceParser::ImportStmtContext *ctx) override;
antlrcpp::Any visitReturnStmt(SpiceParser::ReturnStmtContext *ctx) override;
antlrcpp::Any visitPrintfStmt(SpiceParser::PrintfStmtContext *ctx) override;
antlrcpp::Any visitAssignment(SpiceParser::AssignmentContext *ctx) override;
Expand Down
21 changes: 5 additions & 16 deletions media/test.spice
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
f<int> testFunc() {
printf("Hello from testFunc!\n");
return 1;
}

p testProcedure() {
double result = true || false ? 5.1 : 4.12;
printf("Computation result: %d", result);
}

f<int> main() {
for int j = 0; j < 5; j++ {
printf("For round: %d \n", j);
}
int testFuncResult = testFunc();
printf("Result of testFunc: %d \n", testFuncResult);
testProcedure();
int operand1 = 6;
int operand2 = 5;
int res = operand1 | operand2;
printf("Computation result is: %d", res);

return 0;
}

0 comments on commit 56b05c8

Please sign in to comment.