diff --git a/3rdparty/llvm.cmake b/3rdparty/llvm.cmake index 2f695f26f5..db748d8bd8 100644 --- a/3rdparty/llvm.cmake +++ b/3rdparty/llvm.cmake @@ -26,7 +26,7 @@ if(WITH_LLVM) set(CMAKE_CXX_FLAGS ${CXX_FLAGS_OLD}) # now tries to find LLVM again - find_package(LLVM 11.0 CONFIG) + find_package(LLVM 13.0 CONFIG) if(NOT LLVM_FOUND) message(FATAL_ERROR "Couldn't build LLVM from the submodule. You might need to run `git submodule update --init`") endif() @@ -39,7 +39,7 @@ if(WITH_LLVM) set(LLVM_DIR ${CMAKE_SOURCE_DIR}/${LLVM_DIR}) endif() - find_package(LLVM 11.0 CONFIG) + find_package(LLVM 13.0 CONFIG) if (NOT LLVM_FOUND) if (LLVM_VERSION AND LLVM_VERSION_MAJOR LESS 11) diff --git a/llvm b/llvm index 5836324d64..18f153b33b 160000 --- a/llvm +++ b/llvm @@ -1 +1 @@ -Subproject commit 5836324d6443a62ed09b84c125029e98324978c3 +Subproject commit 18f153b33bef2a4e29a0478ddd374b1f19316a46 diff --git a/rpcs3/Emu/CPU/CPUTranslator.cpp b/rpcs3/Emu/CPU/CPUTranslator.cpp index 52f67e7569..cf2c0e158a 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.cpp +++ b/rpcs3/Emu/CPU/CPUTranslator.cpp @@ -139,9 +139,9 @@ llvm::Value* cpu_translator::bitcast(llvm::Value* val, llvm::Type* type) const uint s2 = val->getType()->getScalarSizeInBits(); if (type->isVectorTy()) - s1 *= llvm::cast(type)->getNumElements(); + s1 *= llvm::cast(type)->getNumElements(); if (val->getType()->isVectorTy()) - s2 *= llvm::cast(val->getType())->getNumElements(); + s2 *= llvm::cast(val->getType())->getNumElements(); if (s1 != s2) { @@ -183,7 +183,7 @@ std::pair cpu_translator::get_const_vector(llvm::Value* c, u32 fmt::throw_exception("[0x%x, %u] Not a vector", _pos, _line); } - if (auto v = llvm::cast(t); v->getScalarSizeInBits() * v->getNumElements() != 128) + if (auto v = llvm::cast(t); v->getScalarSizeInBits() * v->getNumElements() != 128) { fmt::throw_exception("[0x%x, %u] Bad vector size: i%ux%u", _pos, _line, v->getScalarSizeInBits(), v->getNumElements()); } @@ -267,7 +267,7 @@ llvm::Constant* cpu_translator::make_const_vector(v128 v, llvm::Type* t, u } ensure(t->isVectorTy()); - ensure(128 == t->getScalarSizeInBits() * llvm::cast(t)->getNumElements()); + ensure(128 == t->getScalarSizeInBits() * llvm::cast(t)->getNumElements()); const auto sct = t->getScalarType(); diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index 904d52b530..aa49d2a21c 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -3493,10 +3493,10 @@ public: shuffle.value = m_ir->CreateZExt(shuffle.value, get_type()); intermediate.value = m_ir->CreateShuffleVector(data0, data1, shuffle.value); - // expand the shuffle index to 256 bits with zeroes + // expand the shuffle index to 256 bits with zeroes shuffleindex.value = m_ir->CreateShuffleVector(index, zeroes, shuffle.value); - // permute + // permute intermediate.value = m_ir->CreateCall(get_intrinsic(llvm::Intrinsic::x86_avx512_permvar_qi_256), {intermediate.value, shuffleindex.value}); // convert the 256 bit vector back to 128 bits diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index d55f16291c..a12f572b0a 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -21,7 +21,7 @@ const ppu_decoder s_ppu_iname; PPUTranslator::PPUTranslator(LLVMContext& context, Module* _module, const ppu_module& info, ExecutionEngine& engine) : cpu_translator(_module, false) , m_info(info) - , m_pure_attr(AttributeList::get(m_context, AttributeList::FunctionIndex, {Attribute::NoUnwind, Attribute::ReadNone})) + , m_pure_attr() { // Bind context cpu_translator::initialize(context, engine); @@ -189,7 +189,7 @@ Function* PPUTranslator::Translate(const ppu_function& info) if (need_check) { // Check status register in the entry block - const auto vstate = m_ir->CreateLoad(m_ir->CreateStructGEP(nullptr, m_thread, 1), true); + const auto vstate = m_ir->CreateLoad(m_ir->CreateStructGEP(m_thread, 1), true); const auto vcheck = BasicBlock::Create(m_context, "__test", m_function); m_ir->CreateCondBr(m_ir->CreateIsNull(vstate), body, vcheck, m_md_likely); @@ -236,7 +236,7 @@ Function* PPUTranslator::Translate(const ppu_function& info) if (ppu_get_far_jump(m_addr + base)) { - // Branch into an HLEd instruction using the jump table + // Branch into an HLEd instruction using the jump table FlushRegisters(); CallFunction(0, m_reloc ? m_ir->CreateAdd(m_ir->getInt64(m_addr), m_seg0) : m_ir->getInt64(m_addr)); continue; @@ -324,7 +324,7 @@ Type* PPUTranslator::ScaleType(Type* type, s32 pow2) ensure(scaled); const auto new_type = m_ir->getIntNTy(scaled); - const auto vec_type = dyn_cast(type); + const auto vec_type = dyn_cast(type); return vec_type ? VectorType::get(new_type, vec_type->getNumElements(), false) : cast(new_type); } @@ -375,7 +375,7 @@ void PPUTranslator::CallFunction(u64 target, Value* indirect) if (indirect) { - m_ir->CreateStore(Trunc(indirect, GetType()), m_ir->CreateStructGEP(nullptr, m_thread, static_cast(&m_cia - m_locals)), true); + m_ir->CreateStore(Trunc(indirect, GetType()), m_ir->CreateStructGEP(m_thread, static_cast(&m_cia - m_locals)), true); // Try to optimize if (auto inst = dyn_cast_or_null(indirect)) @@ -412,7 +412,7 @@ Value* PPUTranslator::RegInit(Value*& local) } // (Re)Initialize global, will be written in FlushRegisters - m_globals[index] = m_ir->CreateStructGEP(nullptr, m_thread, index); + m_globals[index] = m_ir->CreateStructGEP(m_thread, index); return m_globals[index]; } @@ -428,7 +428,7 @@ Value* PPUTranslator::RegLoad(Value*& local) } // Load from the global value - local = m_ir->CreateLoad(m_ir->CreateStructGEP(nullptr, m_thread, index)); + local = m_ir->CreateLoad(m_ir->CreateStructGEP(m_thread, index)); return local; } @@ -525,9 +525,9 @@ Value* PPUTranslator::Broadcast(Value* value, u32 count) std::pair PPUTranslator::Saturate(Value* value, CmpInst::Predicate inst, Value* extreme) { // Modify args - if (auto v = dyn_cast(value->getType()); v && !extreme->getType()->isVectorTy()) + if (auto v = dyn_cast(value->getType()); v && !extreme->getType()->isVectorTy()) extreme = Broadcast(extreme, v->getNumElements()); - if (auto e = dyn_cast(extreme->getType()); e && !value->getType()->isVectorTy()) + if (auto e = dyn_cast(extreme->getType()); e && !value->getType()->isVectorTy()) value = Broadcast(value, e->getNumElements()); // Compare args @@ -554,7 +554,7 @@ Value* PPUTranslator::Scale(Value* value, s32 scale) const auto type = value->getType(); const auto power = std::pow(2, scale); - if (auto v = dyn_cast(type)) + if (auto v = dyn_cast(type)) { return m_ir->CreateFMul(value, ConstantVector::getSplat({v->getNumElements(), false}, ConstantFP::get(v->getElementType(), power))); } @@ -580,7 +580,7 @@ Value* PPUTranslator::Shuffle(Value* left, Value* right, std::initializer_list data; data.reserve(indices.size()); - const u32 mask = cast(type)->getNumElements() - 1; + const u32 mask = cast(type)->getNumElements() - 1; // Transform indices (works for vectors with size 2^N) for (usz i = 0; i < indices.size(); i++) @@ -2003,7 +2003,7 @@ void PPUTranslator::BC(ppu_opcode_t op) if (op.lk) { - m_ir->CreateStore(GetAddr(+4), m_ir->CreateStructGEP(nullptr, m_thread, static_cast(&m_lr - m_locals))); + m_ir->CreateStore(GetAddr(+4), m_ir->CreateStructGEP(m_thread, static_cast(&m_lr - m_locals))); } UseCondition(CheckBranchProbability(op.bo), CheckBranchCondition(op.bo, op.bi)); @@ -2073,7 +2073,7 @@ void PPUTranslator::BCLR(ppu_opcode_t op) if (op.lk) { - m_ir->CreateStore(GetAddr(+4), m_ir->CreateStructGEP(nullptr, m_thread, static_cast(&m_lr - m_locals))); + m_ir->CreateStore(GetAddr(+4), m_ir->CreateStructGEP(m_thread, static_cast(&m_lr - m_locals))); } UseCondition(CheckBranchProbability(op.bo), CheckBranchCondition(op.bo, op.bi)); @@ -2136,7 +2136,7 @@ void PPUTranslator::BCCTR(ppu_opcode_t op) if (op.lk) { - m_ir->CreateStore(GetAddr(+4), m_ir->CreateStructGEP(nullptr, m_thread, static_cast(&m_lr - m_locals))); + m_ir->CreateStore(GetAddr(+4), m_ir->CreateStructGEP(m_thread, static_cast(&m_lr - m_locals))); } UseCondition(CheckBranchProbability(op.bo | 0x4), CheckBranchCondition(op.bo | 0x4, op.bi)); @@ -2551,8 +2551,8 @@ void PPUTranslator::MFOCRF(ppu_opcode_t op) else if (std::none_of(m_cr + 0, m_cr + 32, [](auto* p) { return p; })) { // MFCR (optimized) - Value* ln0 = m_ir->CreateIntToPtr(m_ir->CreatePtrToInt(m_ir->CreateStructGEP(nullptr, m_thread, 99), GetType()), GetType()->getPointerTo()); - Value* ln1 = m_ir->CreateIntToPtr(m_ir->CreatePtrToInt(m_ir->CreateStructGEP(nullptr, m_thread, 115), GetType()), GetType()->getPointerTo()); + Value* ln0 = m_ir->CreateIntToPtr(m_ir->CreatePtrToInt(m_ir->CreateStructGEP(m_thread, 99), GetType()), GetType()->getPointerTo()); + Value* ln1 = m_ir->CreateIntToPtr(m_ir->CreatePtrToInt(m_ir->CreateStructGEP(m_thread, 115), GetType()), GetType()->getPointerTo()); ln0 = m_ir->CreateLoad(ln0); ln1 = m_ir->CreateLoad(ln1); @@ -2868,7 +2868,7 @@ void PPUTranslator::MTOCRF(ppu_opcode_t op) const auto index = m_ir->CreateAnd(m_ir->CreateLShr(value, 28 - i * 4), 15); const auto src = m_ir->CreateGEP(m_mtocr_table, {m_ir->getInt32(0), m_ir->CreateShl(index, 2)}); - const auto dst = bitcast(m_ir->CreateStructGEP(nullptr, m_thread, static_cast(m_cr - m_locals) + i * 4), GetType()); + const auto dst = bitcast(m_ir->CreateStructGEP(m_thread, static_cast(m_cr - m_locals) + i * 4), GetType()); Call(GetType(), "llvm.memcpy.p0i8.p0i8.i32", dst, src, m_ir->getInt32(4), m_ir->getFalse()); } } diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 9a76d32971..4735d4384e 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -5600,7 +5600,7 @@ public: if (atomic) { - const auto val = m_ir->CreateAtomicRMW(llvm::AtomicRMWInst::Xchg, ptr, m_ir->getInt64(0), llvm::AtomicOrdering::Acquire); + const auto val = m_ir->CreateAtomicRMW(llvm::AtomicRMWInst::Xchg, ptr, m_ir->getInt64(0), llvm::MaybeAlign{8}, llvm::AtomicOrdering::Acquire); val0 = val; } else