-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
games-emulation/rpcs3: add patch for LLVM 17 and require it
Signed-off-by: Andrew Udvare <audvare@gmail.com>
- Loading branch information
Showing
4 changed files
with
143 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
games-emulation/rpcs3/files/rpcs3-9999-ittapi-remove-git-co.patch
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
From 50df01d00e8c80ede4e0928ee9ba6a822ef408d8 Mon Sep 17 00:00:00 2001 | ||
From: oltolm <oleg.tolmatcev@gmail.com> | ||
Date: Mon, 25 Sep 2023 17:04:48 +0200 | ||
Subject: [PATCH] llvm: add support for LLVM 17 | ||
|
||
--- | ||
3rdparty/llvm/CMakeLists.txt | 9 ++++++++- | ||
Utilities/JIT.cpp | 2 +- | ||
rpcs3/Emu/CPU/CPUTranslator.h | 10 +++++++++- | ||
rpcs3/Emu/Cell/PPUThread.cpp | 2 +- | ||
rpcs3/Emu/Cell/SPURecompiler.cpp | 12 +++++++++++- | ||
5 files changed, 30 insertions(+), 5 deletions(-) | ||
|
||
diff --git a/3rdparty/llvm/CMakeLists.txt b/3rdparty/llvm/CMakeLists.txt | ||
index 679cb23a613..fdadd8c5d3f 100644 | ||
--- a/3rdparty/llvm/CMakeLists.txt | ||
+++ b/3rdparty/llvm/CMakeLists.txt | ||
@@ -38,6 +38,10 @@ if(WITH_LLVM) | ||
|
||
# now tries to find LLVM again | ||
find_package(LLVM 16.0 CONFIG) | ||
+ if(NOT LLVM_FOUND) | ||
+ set(LLVM_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm_build/lib/cmake/llvm/") | ||
+ find_package(LLVM 17.0 CONFIG) | ||
+ endif() | ||
if(NOT LLVM_FOUND) | ||
message(FATAL_ERROR "Couldn't build LLVM from the submodule. You might need to run `git submodule update --init`") | ||
endif() | ||
@@ -50,10 +54,13 @@ if(WITH_LLVM) | ||
endif() | ||
|
||
find_package(LLVM 16.0 CONFIG) | ||
+ if(NOT LLVM_FOUND) | ||
+ find_package(LLVM 17.0 CONFIG) | ||
+ endif() | ||
|
||
if (NOT LLVM_FOUND) | ||
if (LLVM_VERSION AND LLVM_VERSION_MAJOR LESS 16) | ||
- message(FATAL_ERROR "Found LLVM version ${LLVM_VERSION}. Required version 16. \ | ||
+ message(FATAL_ERROR "Found LLVM version ${LLVM_VERSION}. Required versions 16...17. \ | ||
Enable BUILD_LLVM option to build LLVM from included as a git submodule.") | ||
endif() | ||
|
||
diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp | ||
index caec5a6b22a..b183f16f7d6 100644 | ||
--- a/Utilities/JIT.cpp | ||
+++ b/Utilities/JIT.cpp | ||
@@ -866,7 +866,7 @@ void asmjit::simd_builder::vec_extract_gpr(u32 esize, const x86::Gp& dst, const | ||
#endif | ||
#include "llvm/Support/TargetSelect.h" | ||
#include "llvm/Support/FormattedStream.h" | ||
-#include "llvm/Support/Host.h" | ||
+#include "llvm/TargetParser/Host.h" | ||
#include "llvm/ExecutionEngine/ExecutionEngine.h" | ||
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h" | ||
#include "llvm/ExecutionEngine/ObjectCache.h" | ||
diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h | ||
index edf6c92a65f..57948d2d1a3 100644 | ||
--- a/rpcs3/Emu/CPU/CPUTranslator.h | ||
+++ b/rpcs3/Emu/CPU/CPUTranslator.h | ||
@@ -922,6 +922,14 @@ inline llvm_div<T1, T2> operator /(T1&& a1, T2&& a2) | ||
return {a1, a2}; | ||
} | ||
|
||
+inline llvm::Constant* getZeroValueForNegation(llvm::Type* Ty) | ||
+{ | ||
+ if (Ty->isFPOrFPVectorTy()) | ||
+ return llvm::ConstantFP::getNegativeZero(Ty); | ||
+ | ||
+ return llvm::Constant::getNullValue(Ty); | ||
+} | ||
+ | ||
template <typename A1, typename T = llvm_common_t<A1>> | ||
struct llvm_neg | ||
{ | ||
@@ -971,7 +979,7 @@ struct llvm_neg | ||
{ | ||
v1 = i->getOperand(1); | ||
|
||
- if (i->getOperand(0) == llvm::ConstantFP::getZeroValueForNegation(v1->getType())) | ||
+ if (i->getOperand(0) == getZeroValueForNegation(v1->getType())) | ||
{ | ||
if (auto r1 = a1.match(v1, _m); v1) | ||
{ | ||
diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp | ||
index ee89bb46920..b69dca24053 100644 | ||
--- a/rpcs3/Emu/Cell/PPUThread.cpp | ||
+++ b/rpcs3/Emu/Cell/PPUThread.cpp | ||
@@ -41,7 +41,7 @@ | ||
#pragma GCC diagnostic ignored "-Wmissing-noreturn" | ||
#endif | ||
#include "llvm/Support/FormattedStream.h" | ||
-#include "llvm/Support/Host.h" | ||
+#include "llvm/TargetParser/Host.h" | ||
#include "llvm/Object/ObjectFile.h" | ||
#if LLVM_VERSION_MAJOR < 17 | ||
#include "llvm/ADT/Triple.h" | ||
diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp | ||
index e90133c93c9..f69e7924a88 100644 | ||
--- a/rpcs3/Emu/Cell/SPURecompiler.cpp | ||
+++ b/rpcs3/Emu/Cell/SPURecompiler.cpp | ||
@@ -4373,7 +4373,7 @@ void spu_recompiler_base::dump(const spu_program& result, std::string& out) | ||
#if LLVM_VERSION_MAJOR < 17 | ||
#include "llvm/ADT/Triple.h" | ||
#endif | ||
-#include "llvm/Support/Host.h" | ||
+#include "llvm/TargetParser/Host.h" | ||
#include "llvm/IR/LegacyPassManager.h" | ||
#include "llvm/IR/Verifier.h" | ||
#include "llvm/IR/InlineAsm.h" | ||
@@ -6304,9 +6304,15 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator | ||
pm.add(createEarlyCSEPass()); | ||
pm.add(createCFGSimplificationPass()); | ||
//pm.add(createNewGVNPass()); | ||
+#if LLVM_VERSION_MAJOR < 17 | ||
pm.add(createDeadStoreEliminationPass()); | ||
+#endif | ||
pm.add(createLICMPass()); | ||
+#if LLVM_VERSION_MAJOR < 17 | ||
pm.add(createAggressiveDCEPass()); | ||
+#else | ||
+ pm.add(createDeadCodeEliminationPass()); | ||
+#endif | ||
//pm.add(createLintPass()); // Check | ||
|
||
for (auto& f : *m_module) | ||
@@ -6772,8 +6778,12 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator | ||
// Basic optimizations | ||
pm.add(createEarlyCSEPass()); | ||
pm.add(createCFGSimplificationPass()); | ||
+#if LLVM_VERSION_MAJOR < 17 | ||
pm.add(createDeadStoreEliminationPass()); | ||
pm.add(createAggressiveDCEPass()); | ||
+#else | ||
+ pm.add(createDeadCodeEliminationPass()); | ||
+#endif | ||
//pm.add(createLintPass()); | ||
|
||
for (auto& f : *_module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters