Skip to content

Commit

Permalink
Fix build without llvm support (#2)
Browse files Browse the repository at this point in the history
* Fixes to build taco without LLVM support

* Add ENABLE_TESTS cmake command
  • Loading branch information
guilhermeleobas authored May 26, 2021
1 parent d51ba6b commit 92f0a09
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 12 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ project(taco)
option(CUDA "Build for NVIDIA GPU (CUDA must be preinstalled)" OFF)
option(PYTHON "Build TACO for python environment" OFF)
option(OPENMP "Build with OpenMP execution support" OFF)
option(LLVM "Build with LLVM backend support")
option(LLVM "Build with LLVM backend support" OFF)
option(ENABLE_TESTS "Enable tests" ON)


if(CUDA)
Expand All @@ -30,6 +31,7 @@ if (LLVM)
llvm_map_components_to_libnames(llvm_libs support core irreader)
add_definitions(-DUSE_LLVM)
add_definitions(-DENABLE_TOSTRING_LLVM)
add_definitions(-DHAVE_LLVM)
endif(LLVM)

SET(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
Expand Down Expand Up @@ -101,15 +103,19 @@ set(TACO_TEST_DIR ${TACO_PROJECT_DIR}/test)
set(TACO_TOOLS_DIR ${TACO_PROJECT_DIR}/tools)
set(TACO_INCLUDE_DIR "${TACO_INCLUDE_DIR};${TACO_PROJECT_DIR}/include")

enable_testing()
include_directories(${TACO_INCLUDE_DIR})

set(TACO_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

install(DIRECTORY ${TACO_INCLUDE_DIR}/ DESTINATION include)

add_subdirectory(src)
add_subdirectory(test)

if (${ENABLE_TESTS})
enable_testing()
add_subdirectory(test)
endif()

add_subdirectory(tools)
add_subdirectory(apps)
string(REPLACE " -Wmissing-declarations" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
Expand Down
8 changes: 7 additions & 1 deletion src/codegen/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#include "taco/llvm.h"
#include "codegen_cuda.h"
#include "codegen_c.h"

#ifdef HAVE_LLVM
#include "codegen_llvm.h"
#endif

#include <algorithm>
#include <unordered_set>

Expand All @@ -28,9 +32,11 @@ shared_ptr<CodeGen> CodeGen::init_default(std::ostream &dest, OutputKind outputK
if (should_use_CUDA_codegen()) {
return make_shared<CodeGen_CUDA>(dest, outputKind);
}
if (should_use_LLVM_codegen()){
#ifdef HAVE_LLVM
else if (should_use_LLVM_codegen()){
return make_shared<CodeGen_LLVM>(dest, outputKind);
}
#endif
else {
return make_shared<CodeGen_C>(dest, outputKind);
}
Expand Down
4 changes: 3 additions & 1 deletion src/codegen/codegen_llvm.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef HAVE_LLVM
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"

Expand Down Expand Up @@ -673,4 +674,5 @@ void CodeGen_LLVM::visit(const GetProperty *op) {
}

} // namespace ir
} // namespace taco
} // namespace taco
#endif // HAVE_LLVM
4 changes: 3 additions & 1 deletion src/codegen/codegen_llvm.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef HAVE_LLVM
#ifndef TACO_BACKEND_LLVM_H
#define TACO_BACKEND_LLVM_H

Expand Down Expand Up @@ -137,4 +138,5 @@ namespace taco
} // namespace ir
} // namespace taco

#endif
#endif // TACO_BACKEND_LLVM_H
#endif // HAVE_LLVM
5 changes: 4 additions & 1 deletion src/codegen/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
#include "taco/util/env.h"
#include "codegen/codegen_c.h"
#include "codegen/codegen_cuda.h"
#include "codegen/codegen_llvm.h"
#include "taco/cuda.h"

#ifdef HAVE_LLVM
#include "codegen/codegen_llvm.h"
#endif

using namespace std;

namespace taco {
Expand Down
2 changes: 1 addition & 1 deletion src/llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace taco{

static bool LLVM_codegen_enabled = USE_LLVM;
bool should_use_LLVM_codegen(){
return LLVM_codegen_enabled;
return LLVM_codegen_enabled;
}

void set_LLVM_codegen_enabled(bool enabled) {
Expand Down
9 changes: 5 additions & 4 deletions tools/taco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "taco/codegen/module.h"
#include "codegen/codegen_c.h"
#include "codegen/codegen_cuda.h"
#include "codegen/codegen_llvm.h"
#include "codegen/codegen.h"
#include "taco/util/strings.h"
#include "taco/util/files.h"
Expand All @@ -29,11 +28,14 @@
#include "taco/util/collections.h"
#include "taco/cuda.h"
#include "taco/llvm.h"
#include "taco/llvm.h"
#include "taco/index_notation/transformations.h"
#include "taco/index_notation/index_notation_visitor.h"
#include "taco/index_notation/index_notation_nodes.h"

#ifdef HAVE_LLVM
#include "codegen/codegen_llvm.h"
#endif

using namespace std;
using namespace taco;

Expand Down Expand Up @@ -966,8 +968,7 @@ int main(int argc, char* argv[]) {
}
set_LLVM_codegen_enabled(true);
}
else
{
else {
set_LLVM_codegen_enabled(false);
}

Expand Down

0 comments on commit 92f0a09

Please sign in to comment.