Skip to content
Merged
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
21 changes: 18 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.14)
project(
Codon
VERSION "0.20.2"
VERSION "0.20.3"
HOMEPAGE_URL "https://github.com/exaloop/codon"
DESCRIPTION "high-performance, extensible Python compiler")
set(CODON_JIT_PYTHON_VERSION "0.5.2")
set(CODON_JIT_PYTHON_VERSION "0.5.3")
configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
"${PROJECT_SOURCE_DIR}/codon/config/config.h")
configure_file("${PROJECT_SOURCE_DIR}/cmake/config.py.in"
Expand Down Expand Up @@ -265,6 +265,7 @@ set(CODON_HPPFILES
codon/cir/transform/parallel/schedule.h
codon/cir/transform/pass.h
codon/cir/transform/pythonic/dict.h
codon/cir/transform/pythonic/enumerate.h
codon/cir/transform/pythonic/format.h
codon/cir/transform/pythonic/generator.h
codon/cir/transform/pythonic/io.h
Expand Down Expand Up @@ -375,6 +376,7 @@ set(CODON_CPPFILES
codon/cir/transform/parallel/schedule.cpp
codon/cir/transform/pass.cpp
codon/cir/transform/pythonic/dict.cpp
codon/cir/transform/pythonic/enumerate.cpp
codon/cir/transform/pythonic/format.cpp
codon/cir/transform/pythonic/generator.cpp
codon/cir/transform/pythonic/io.cpp
Expand Down Expand Up @@ -537,14 +539,24 @@ set(CODON_TEST_CPPFILES
test/cir/instr.cpp
test/cir/llvm/optimize.cpp
test/cir/module.cpp
test/cir/transform/enumerate.cpp
test/cir/transform/format.cpp
test/cir/transform/manager.cpp
test/cir/type.cpp
test/cir/util/matching.cpp
test/cir/value.cpp
test/cir/var.cpp
test/dsl/plugins.cpp
test/types.cpp)
add_library(codon_test_compiler_plugin SHARED EXCLUDE_FROM_ALL test/dsl/library.cpp)
target_compile_definitions(codon_test_compiler_plugin PRIVATE CODON_TEST_COMPILER_PLUGIN)
target_include_directories(codon_test_compiler_plugin PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}" ${LLVM_INCLUDE_DIRS}
"${peglib_SOURCE_DIR}")
target_link_libraries(codon_test_compiler_plugin PRIVATE codonc fmt)
add_library(codon_test_runtime_plugin SHARED EXCLUDE_FROM_ALL test/dsl/library.cpp)
add_executable(codon_test ${CODON_TEST_CPPFILES})
add_dependencies(codon_test codon codon_test_compiler_plugin codon_test_runtime_plugin)
target_include_directories(codon_test PRIVATE test/cir "${gc_SOURCE_DIR}/include")
target_link_libraries(codon_test PRIVATE fmt codonc codonrt gtest_main)
if(ASAN)
Expand All @@ -556,7 +568,10 @@ if(ASAN)
"-fsanitize-recover=address")
endif()
target_compile_definitions(codon_test
PRIVATE TEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test")
PRIVATE TEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}/test"
TEST_CODON="$<TARGET_FILE:codon>"
TEST_PLUGIN_COMPILER="$<TARGET_FILE:codon_test_compiler_plugin>"
TEST_PLUGIN_RUNTIME="$<TARGET_FILE:codon_test_runtime_plugin>")

if(APPLE)
set_target_properties(
Expand Down
26 changes: 19 additions & 7 deletions codon/cir/llvm/llvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void LLVMVisitor::writeToExecutable(const std::string &filename,

if (plugins) {
for (auto *plugin : *plugins) {
auto dylibPath = plugin->info.dylibPath;
const auto &dylibPath = plugin->info.getRuntimeDylibPath();
if (dylibPath.empty())
continue;

Expand All @@ -556,7 +556,7 @@ void LLVMVisitor::writeToExecutable(const std::string &filename,
if (plugins) {
for (auto *plugin : *plugins) {
if (plugin->info.linkArgs.empty()) {
auto dylibPath = plugin->info.dylibPath;
const auto &dylibPath = plugin->info.getRuntimeDylibPath();
if (dylibPath.empty())
continue;

Expand Down Expand Up @@ -1203,6 +1203,10 @@ void LLVMVisitor::run(const std::vector<std::string> &args,
runLLVMPipeline();

Timer t1("llvm/jitlink");
if (plugins) {
if (auto error = plugins->loadRuntimeLibraries())
compilationError(llvm::toString(std::move(error)));
}
for (auto &lib : libs) {
std::string err;
if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(lib.c_str(), &err)) {
Expand Down Expand Up @@ -2616,6 +2620,7 @@ void LLVMVisitor::visit(const ForFlow *x) {

auto *condBlock = llvm::BasicBlock::Create(*context, "for.cond", func);
auto *bodyBlock = llvm::BasicBlock::Create(*context, "for.body", func);
auto *checkBlock = llvm::BasicBlock::Create(*context, "for.check", func);
auto *cleanupBlock = llvm::BasicBlock::Create(*context, "for.cleanup", func);
auto *exitBlock = llvm::BasicBlock::Create(*context, "for.exit", func);

Expand All @@ -2633,7 +2638,10 @@ void LLVMVisitor::visit(const ForFlow *x) {
process(x->getIter());
auto *iter = value;
B->SetInsertPoint(block);
B->CreateBr(condBlock);
B->CreateCondBr(B->CreateCall(coroDone, iter), exitBlock, condBlock);

B->SetInsertPoint(checkBlock);
B->CreateCondBr(B->CreateCall(coroDone, iter), exitBlock, condBlock);

block = condBlock;
call(coroResume, {iter});
Expand All @@ -2653,11 +2661,11 @@ void LLVMVisitor::visit(const ForFlow *x) {

block = bodyBlock;
enterLoop(
{/*breakBlock=*/exitBlock, /*continueBlock=*/condBlock, /*loopId=*/x->getId()});
{/*breakBlock=*/exitBlock, /*continueBlock=*/checkBlock, /*loopId=*/x->getId()});
process(x->getBody());
exitLoop();
B->SetInsertPoint(block);
B->CreateBr(condBlock);
B->CreateBr(checkBlock);

B->SetInsertPoint(cleanupBlock);
B->CreateCall(coroDestroy, iter);
Expand Down Expand Up @@ -3139,6 +3147,7 @@ void LLVMVisitor::codegenPipeline(

auto *condBlock = llvm::BasicBlock::Create(*context, "pipeline.cond", func);
auto *bodyBlock = llvm::BasicBlock::Create(*context, "pipeline.body", func);
auto *checkBlock = llvm::BasicBlock::Create(*context, "pipeline.check", func);
auto *cleanupBlock = llvm::BasicBlock::Create(*context, "pipeline.cleanup", func);
auto *exitBlock = llvm::BasicBlock::Create(*context, "pipeline.exit", func);

Expand All @@ -3155,7 +3164,10 @@ void LLVMVisitor::codegenPipeline(

auto *iter = value;
B->SetInsertPoint(block);
B->CreateBr(condBlock);
B->CreateCondBr(B->CreateCall(coroDone, iter), exitBlock, condBlock);

B->SetInsertPoint(checkBlock);
B->CreateCondBr(B->CreateCall(coroDone, iter), exitBlock, condBlock);

block = condBlock;
call(coroResume, {iter});
Expand All @@ -3175,7 +3187,7 @@ void LLVMVisitor::codegenPipeline(
codegenPipeline(stages, where + 1);

B->SetInsertPoint(block);
B->CreateBr(condBlock);
B->CreateBr(checkBlock);

B->SetInsertPoint(cleanupBlock);
B->CreateCall(coroDestroy, iter);
Expand Down
1 change: 1 addition & 0 deletions codon/cir/llvm/llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/Analysis/RegionPass.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/CodeGen/CommandFlags.h"
Expand Down
Loading
Loading