From 10a35c5341c110b7dcdd5310f46bb357605420d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sun, 22 Dec 2019 00:42:23 +0100 Subject: [PATCH] Support for LLVM 10 --- build/CMakeLists.txt | 6 +++++- compiler/generator/llvm/llvm_code_container.cpp | 4 ++-- .../generator/llvm/llvm_dynamic_dsp_aux.cpp | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index eaa04e2970..5f934b3e08 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -80,7 +80,7 @@ if (INCLUDE_LLVM ) llvm_cmake() endif() - string (REGEX REPLACE "([0-9])\\.([0-9]).*" "LLVM_\\1\\2" LLVM_VERSION ${LLVM_PACKAGE_VERSION}) + string (REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "LLVM_\\1\\2" LLVM_VERSION ${LLVM_PACKAGE_VERSION}) # the declarations below are redundant but necessary to cope with different cmake behaviors on different platforms set (TMP ${SRCDIR}/generator/llvm) @@ -91,6 +91,10 @@ endif() set (FAUST_LIBS ${FAUST_LIBS} ${LLVM_LD_FLAGS} ${LLVM_LIBS}) set (FAUST_DEFINITIONS ${FAUST_DEFINITIONS} -DLLVM_VERSION="${LLVM_PACKAGE_VERSION}") + + if("${LLVM_PACKAGE_VERSION}" VERSION_GREATER_EQUAL 10) + set (CMAKE_CXX_STANDARD 14) + endif() endif() #################################### diff --git a/compiler/generator/llvm/llvm_code_container.cpp b/compiler/generator/llvm/llvm_code_container.cpp index 932f17dc2c..bda74b346c 100644 --- a/compiler/generator/llvm/llvm_code_container.cpp +++ b/compiler/generator/llvm/llvm_code_container.cpp @@ -71,7 +71,7 @@ LLVMCodeContainer::LLVMCodeContainer(const string& name, int numInputs, int numO // Set "-fast-math" FastMathFlags FMF; -#if defined(LLVM_60) || defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) +#if defined(LLVM_60) || defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) || defined(LLVM_100) FMF.setFast(); // has replaced the below function #else FMF.setUnsafeAlgebra(); @@ -91,7 +91,7 @@ LLVMCodeContainer::LLVMCodeContainer(const string& name, int numInputs, int numO // Set "-fast-math" FastMathFlags FMF; -#if defined(LLVM_60) || defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) +#if defined(LLVM_60) || defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) || defined(LLVM_100) FMF.setFast(); // has replaced the below function #else FMF.setUnsafeAlgebra(); diff --git a/compiler/generator/llvm/llvm_dynamic_dsp_aux.cpp b/compiler/generator/llvm/llvm_dynamic_dsp_aux.cpp index 1a7a22681d..a4e46ea430 100644 --- a/compiler/generator/llvm/llvm_dynamic_dsp_aux.cpp +++ b/compiler/generator/llvm/llvm_dynamic_dsp_aux.cpp @@ -64,6 +64,11 @@ #include #include +#if defined(LLVM_100) +#include +#include +#endif + using namespace llvm; using namespace std; @@ -109,7 +114,7 @@ void llvm_dynamic_dsp_factory_aux::write(ostream* out, bool binary, bool small) string res; raw_string_ostream out_str(res); if (binary) { -#if defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) +#if defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) || defined(LLVM_100) WriteBitcodeToFile(*fModule, out_str); #else WriteBitcodeToFile(fModule, out_str); @@ -126,7 +131,7 @@ string llvm_dynamic_dsp_factory_aux::writeDSPFactoryToBitcode() string res; raw_string_ostream out(res); -#if defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) +#if defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) || defined(LLVM_100) WriteBitcodeToFile(*fModule, out); #else WriteBitcodeToFile(fModule, out); @@ -143,7 +148,7 @@ bool llvm_dynamic_dsp_factory_aux::writeDSPFactoryToBitcodeFile(const string& bi cerr << "ERROR : writeDSPFactoryToBitcodeFile could not open file : " << err.message(); return false; } -#if defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) +#if defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) || defined(LLVM_100) WriteBitcodeToFile(*fModule, out); #else WriteBitcodeToFile(fModule, out); @@ -280,7 +285,7 @@ bool llvm_dynamic_dsp_factory_aux::initJIT(string& error_msg) targetOptions.NoNaNsFPMath = true; targetOptions.GuaranteedTailCallOpt = true; targetOptions.NoTrappingFPMath = true; -#if defined(LLVM_90) +#if defined(LLVM_90) || defined(LLVM_100) targetOptions.NoSignedZerosFPMath = true; #endif targetOptions.FPDenormalMode = FPDenormal::IEEE; @@ -513,7 +518,9 @@ bool llvm_dynamic_dsp_factory_aux::writeDSPFactoryToObjectcodeFileAux(const stri legacy::PassManager pass; -#if defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) +#if defined(LLVM_100) + if (TheTargetMachine->addPassesToEmitFile(pass, dest, nullptr, CGFT_ObjectFile)) { +#elif defined(LLVM_70) || defined(LLVM_80) || defined(LLVM_90) if (TheTargetMachine->addPassesToEmitFile(pass, dest, nullptr, TargetMachine::CGFT_ObjectFile)) { #else if (TheTargetMachine->addPassesToEmitFile(pass, dest, TargetMachine::CGFT_ObjectFile, true)) {