Commit 6a6ae44f by Antonio Maiorano

Remove support for LLVM < 10

Delete all code that supported using LLVM version < 10. Bug: b/152339534 Change-Id: I997c478b0aca6940cdd3a121eec15827eae47574 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/46728 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 597c723e
......@@ -147,9 +147,9 @@ set(DEFAULT_REACTOR_BACKEND "LLVM")
set(REACTOR_BACKEND ${DEFAULT_REACTOR_BACKEND} CACHE STRING "JIT compiler back-end used by Reactor")
set_property(CACHE REACTOR_BACKEND PROPERTY STRINGS LLVM Subzero)
set(DEFAULT_SWIFTSHADER_LLVM_VERSION "7.0")
set(DEFAULT_SWIFTSHADER_LLVM_VERSION "10.0")
set(SWIFTSHADER_LLVM_VERSION ${DEFAULT_SWIFTSHADER_LLVM_VERSION} CACHE STRING "LLVM version to use")
set_property(CACHE SWIFTSHADER_LLVM_VERSION PROPERTY STRINGS "7.0" "10.0")
set_property(CACHE SWIFTSHADER_LLVM_VERSION PROPERTY STRINGS "10.0")
# If defined, overrides the default optimization level of the current reactor backend.
# Set to one of the rr::Optimization::Level enum values.
......@@ -722,7 +722,6 @@ if(SWIFTSHADER_BUILD_VULKAN)
add_subdirectory(src/Vulkan) # Add vk_swiftshader target
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND # turbo-cov is only useful for clang coverage info
SWIFTSHADER_LLVM_VERSION EQUAL "10.0" AND # turbo-cov does not build with earlier llvm versions
SWIFTSHADER_EMIT_COVERAGE)
add_subdirectory(${TESTS_DIR}/regres/cov/turbo-cov)
endif()
......
......@@ -254,11 +254,7 @@ public:
// Round down base address to align with a page boundary. This matches
// DefaultMMapper behavior.
void *addr = block.base();
#if LLVM_VERSION_MAJOR >= 9
size_t size = block.allocatedSize();
#else
size_t size = block.size();
#endif
size_t pageSize = rr::memoryPageSize();
addr = reinterpret_cast<void *>(
reinterpret_cast<uintptr_t>(addr) & ~(pageSize - 1));
......@@ -271,11 +267,7 @@ public:
std::error_code releaseMappedMemory(llvm::sys::MemoryBlock &block)
{
#if LLVM_VERSION_MAJOR >= 9
size_t size = block.allocatedSize();
#else
size_t size = block.size();
#endif
rr::deallocateMemoryPages(block.base(), size);
return std::error_code();
......@@ -540,13 +532,8 @@ void *resolveExternalSymbol(const char *name)
// settings and no Reactor routine directly links against another.
class JITRoutine : public rr::Routine
{
#if LLVM_VERSION_MAJOR >= 8
using ObjLayer = llvm::orc::LegacyRTDyldObjectLinkingLayer;
using CompileLayer = llvm::orc::LegacyIRCompileLayer<ObjLayer, llvm::orc::SimpleCompiler>;
#else
using ObjLayer = llvm::orc::RTDyldObjectLinkingLayer;
using CompileLayer = llvm::orc::IRCompileLayer<ObjLayer, llvm::orc::SimpleCompiler>;
#endif
public:
#if defined(__clang__)
......
......@@ -23,14 +23,10 @@
#include "x86.hpp"
#include "llvm/IR/Intrinsics.h"
#if LLVM_VERSION_MAJOR >= 9
# include "llvm/IR/IntrinsicsX86.h"
#endif
#if LLVM_VERSION_MAJOR >= 10
# include "llvm/Support/Alignment.h"
#endif
#include "llvm/IR/IntrinsicsX86.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Transforms/Coroutines.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
......@@ -171,43 +167,6 @@ llvm::Value *lowerTrunc(llvm::Value *x)
return jit->builder->CreateCall(trunc, ARGS(x));
}
# if LLVM_VERSION_MAJOR < 8
// Packed add/sub with saturation
llvm::Value *lowerPSAT(llvm::Value *x, llvm::Value *y, bool isAdd, bool isSigned)
{
llvm::VectorType *ty = llvm::cast<llvm::VectorType>(x->getType());
llvm::VectorType *extTy = llvm::VectorType::getExtendedElementVectorType(ty);
unsigned numBits = ty->getScalarSizeInBits();
llvm::Value *max, *min, *extX, *extY;
if(isSigned)
{
max = llvm::ConstantInt::get(extTy, (1LL << (numBits - 1)) - 1, true);
min = llvm::ConstantInt::get(extTy, (-1LL << (numBits - 1)), true);
extX = jit->builder->CreateSExt(x, extTy);
extY = jit->builder->CreateSExt(y, extTy);
}
else
{
ASSERT_MSG(numBits <= 64, "numBits: %d", int(numBits));
uint64_t maxVal = (numBits == 64) ? ~0ULL : (1ULL << numBits) - 1;
max = llvm::ConstantInt::get(extTy, maxVal, false);
min = llvm::ConstantInt::get(extTy, 0, false);
extX = jit->builder->CreateZExt(x, extTy);
extY = jit->builder->CreateZExt(y, extTy);
}
llvm::Value *res = isAdd ? jit->builder->CreateAdd(extX, extY)
: jit->builder->CreateSub(extX, extY);
res = lowerPMINMAX(res, min, llvm::ICmpInst::ICMP_SGT);
res = lowerPMINMAX(res, max, llvm::ICmpInst::ICMP_SLT);
return jit->builder->CreateTrunc(res, ty);
}
# endif // LLVM_VERSION_MAJOR < 8
llvm::Value *lowerSQRT(llvm::Value *x)
{
llvm::Function *sqrt = llvm::Intrinsic::getDeclaration(
......@@ -359,43 +318,25 @@ llvm::Value *lowerFPSignMask(llvm::Value *x, llvm::Type *retTy)
}
#endif // !defined(__i386__) && !defined(__x86_64__)
#if(LLVM_VERSION_MAJOR >= 8) || (!defined(__i386__) && !defined(__x86_64__))
llvm::Value *lowerPUADDSAT(llvm::Value *x, llvm::Value *y)
{
# if LLVM_VERSION_MAJOR >= 8
return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::uadd_sat, x, y);
# else
return lowerPSAT(x, y, true, false);
# endif
}
llvm::Value *lowerPSADDSAT(llvm::Value *x, llvm::Value *y)
{
# if LLVM_VERSION_MAJOR >= 8
return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::sadd_sat, x, y);
# else
return lowerPSAT(x, y, true, true);
# endif
}
llvm::Value *lowerPUSUBSAT(llvm::Value *x, llvm::Value *y)
{
# if LLVM_VERSION_MAJOR >= 8
return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::usub_sat, x, y);
# else
return lowerPSAT(x, y, false, false);
# endif
}
llvm::Value *lowerPSSUBSAT(llvm::Value *x, llvm::Value *y)
{
# if LLVM_VERSION_MAJOR >= 8
return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::ssub_sat, x, y);
# else
return lowerPSAT(x, y, false, true);
# endif
}
#endif // (LLVM_VERSION_MAJOR >= 8) || (!defined(__i386__) && !defined(__x86_64__))
llvm::Value *lowerMulHigh(llvm::Value *x, llvm::Value *y, bool sext)
{
......@@ -754,10 +695,8 @@ Value *Nucleus::allocateStackVariable(Type *type, int arraySize)
#if LLVM_VERSION_MAJOR >= 11
auto align = jit->module->getDataLayout().getPrefTypeAlign(T(type));
#elif LLVM_VERSION_MAJOR >= 10
auto align = llvm::MaybeAlign(jit->module->getDataLayout().getPrefTypeAlignment(T(type)));
#else
auto align = jit->module->getDataLayout().getPrefTypeAlignment(T(type));
auto align = llvm::MaybeAlign(jit->module->getDataLayout().getPrefTypeAlignment(T(type)));
#endif
if(arraySize)
......@@ -3632,90 +3571,42 @@ RValue<Int4> pabsd(RValue<Int4> x)
RValue<Short4> paddsw(RValue<Short4> x, RValue<Short4> y)
{
# if LLVM_VERSION_MAJOR >= 8
return As<Short4>(V(lowerPSADDSAT(V(x.value()), V(y.value()))));
# else
llvm::Function *paddsw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_padds_w);
return As<Short4>(V(jit->builder->CreateCall2(paddsw, ARGS(V(x.value()), V(y.value())))));
# endif
}
RValue<Short4> psubsw(RValue<Short4> x, RValue<Short4> y)
{
# if LLVM_VERSION_MAJOR >= 8
return As<Short4>(V(lowerPSSUBSAT(V(x.value()), V(y.value()))));
# else
llvm::Function *psubsw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubs_w);
return As<Short4>(V(jit->builder->CreateCall2(psubsw, ARGS(V(x.value()), V(y.value())))));
# endif
}
RValue<UShort4> paddusw(RValue<UShort4> x, RValue<UShort4> y)
{
# if LLVM_VERSION_MAJOR >= 8
return As<UShort4>(V(lowerPUADDSAT(V(x.value()), V(y.value()))));
# else
llvm::Function *paddusw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_paddus_w);
return As<UShort4>(V(jit->builder->CreateCall2(paddusw, ARGS(V(x.value()), V(y.value())))));
# endif
}
RValue<UShort4> psubusw(RValue<UShort4> x, RValue<UShort4> y)
{
# if LLVM_VERSION_MAJOR >= 8
return As<UShort4>(V(lowerPUSUBSAT(V(x.value()), V(y.value()))));
# else
llvm::Function *psubusw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubus_w);
return As<UShort4>(V(jit->builder->CreateCall2(psubusw, ARGS(V(x.value()), V(y.value())))));
# endif
}
RValue<SByte8> paddsb(RValue<SByte8> x, RValue<SByte8> y)
{
# if LLVM_VERSION_MAJOR >= 8
return As<SByte8>(V(lowerPSADDSAT(V(x.value()), V(y.value()))));
# else
llvm::Function *paddsb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_padds_b);
return As<SByte8>(V(jit->builder->CreateCall2(paddsb, ARGS(V(x.value()), V(y.value())))));
# endif
}
RValue<SByte8> psubsb(RValue<SByte8> x, RValue<SByte8> y)
{
# if LLVM_VERSION_MAJOR >= 8
return As<SByte8>(V(lowerPSSUBSAT(V(x.value()), V(y.value()))));
# else
llvm::Function *psubsb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubs_b);
return As<SByte8>(V(jit->builder->CreateCall2(psubsb, ARGS(V(x.value()), V(y.value())))));
# endif
}
RValue<Byte8> paddusb(RValue<Byte8> x, RValue<Byte8> y)
{
# if LLVM_VERSION_MAJOR >= 8
return As<Byte8>(V(lowerPUADDSAT(V(x.value()), V(y.value()))));
# else
llvm::Function *paddusb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_paddus_b);
return As<Byte8>(V(jit->builder->CreateCall2(paddusb, ARGS(V(x.value()), V(y.value())))));
# endif
}
RValue<Byte8> psubusb(RValue<Byte8> x, RValue<Byte8> y)
{
# if LLVM_VERSION_MAJOR >= 8
return As<Byte8>(V(lowerPUSUBSAT(V(x.value()), V(y.value()))));
# else
llvm::Function *psubusb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubus_b);
return As<Byte8>(V(jit->builder->CreateCall2(psubusb, ARGS(V(x.value()), V(y.value())))));
# endif
}
RValue<UShort4> pavgw(RValue<UShort4> x, RValue<UShort4> y)
......@@ -4326,19 +4217,11 @@ std::shared_ptr<Routine> Nucleus::acquireCoroutine(const char *name, const Confi
// Run manadory coroutine transforms.
llvm::legacy::PassManager pm;
#if LLVM_VERSION_MAJOR >= 9
pm.add(llvm::createCoroEarlyLegacyPass());
pm.add(llvm::createCoroSplitLegacyPass());
pm.add(llvm::createCoroElideLegacyPass());
pm.add(llvm::createBarrierNoopPass());
pm.add(llvm::createCoroCleanupLegacyPass());
#else
pm.add(llvm::createCoroEarlyPass());
pm.add(llvm::createCoroSplitPass());
pm.add(llvm::createCoroElidePass());
pm.add(llvm::createBarrierNoopPass());
pm.add(llvm::createCoroCleanupPass());
#endif
pm.run(*jit->module);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment