From ca9222a16b477869616b3938c374ed7a497802b4 Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sun, 28 Jul 2024 19:12:21 -0700 Subject: [PATCH] Move UICommon/Disassembler to Common/HostDisassembler A preliminary commit for a cleaner diff and an easier review --- Source/Core/Common/CMakeLists.txt | 29 +++++++++++++++++++ .../HostDisassembler.cpp} | 2 +- .../HostDisassembler.h} | 0 Source/Core/DolphinLib.props | 4 +-- Source/Core/DolphinQt/Debugger/JITWidget.cpp | 2 +- Source/Core/UICommon/CMakeLists.txt | 24 --------------- 6 files changed, 33 insertions(+), 28 deletions(-) rename Source/Core/{UICommon/Disassembler.cpp => Common/HostDisassembler.cpp} (99%) rename Source/Core/{UICommon/Disassembler.h => Common/HostDisassembler.h} (100%) diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 16c5121447..81431e564c 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -75,6 +75,8 @@ add_library(common Hash.cpp Hash.h HookableEvent.h + HostDisassembler.cpp + HostDisassembler.h HttpRequest.cpp HttpRequest.h Image.cpp @@ -180,6 +182,11 @@ PRIVATE ${VTUNE_LIBRARIES} ) +if ((DEFINED CMAKE_ANDROID_ARCH_ABI AND CMAKE_ANDROID_ARCH_ABI MATCHES "x86|x86_64") OR + (NOT DEFINED CMAKE_ANDROID_ARCH_ABI AND _M_X86_64)) + target_link_libraries(common PRIVATE bdisasm) +endif() + if (APPLE) target_link_libraries(common PRIVATE @@ -330,6 +337,28 @@ if(OPROFILE_FOUND) target_link_libraries(common PRIVATE OProfile::OProfile) endif() +if(ENABLE_LLVM) + find_package(LLVM CONFIG) + if(LLVM_FOUND) + message(STATUS "LLVM found, enabling LLVM support in disassembler") + target_compile_definitions(common PRIVATE HAVE_LLVM) + # Minimal documentation about LLVM's CMake functions is available here: + # https://releases.llvm.org/16.0.0/docs/CMake.html#embedding-llvm-in-your-project + # https://groups.google.com/g/llvm-dev/c/YeEVe7HTasQ?pli=1 + # + # However, you have to read the source code in any case. + # Look for LLVM-Config.cmake in your (Unix) system: + # $ find /usr -name LLVM-Config\\.cmake 2>/dev/null + llvm_expand_pseudo_components(LLVM_EXPAND_COMPONENTS + AllTargetsInfos AllTargetsDisassemblers AllTargetsCodeGens + ) + llvm_config(common USE_SHARED + mcdisassembler target ${LLVM_EXPAND_COMPONENTS} + ) + target_include_directories(common PRIVATE ${LLVM_INCLUDE_DIRS}) + endif() +endif() + if(UNIX) # Posix networking code needs to be fixed for Windows add_executable(traversal_server TraversalServer.cpp) diff --git a/Source/Core/UICommon/Disassembler.cpp b/Source/Core/Common/HostDisassembler.cpp similarity index 99% rename from Source/Core/UICommon/Disassembler.cpp rename to Source/Core/Common/HostDisassembler.cpp index 28857f6a6c..d21536ecc4 100644 --- a/Source/Core/UICommon/Disassembler.cpp +++ b/Source/Core/Common/HostDisassembler.cpp @@ -1,7 +1,7 @@ // Copyright 2008 Dolphin Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "UICommon/Disassembler.h" +#include "Common/HostDisassembler.h" #include diff --git a/Source/Core/UICommon/Disassembler.h b/Source/Core/Common/HostDisassembler.h similarity index 100% rename from Source/Core/UICommon/Disassembler.h rename to Source/Core/Common/HostDisassembler.h diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index 206901f7f0..a61f0d822a 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -117,6 +117,7 @@ + @@ -549,7 +550,6 @@ - @@ -809,6 +809,7 @@ + @@ -1207,7 +1208,6 @@ - diff --git a/Source/Core/DolphinQt/Debugger/JITWidget.cpp b/Source/Core/DolphinQt/Debugger/JITWidget.cpp index a6c84dbe08..ae9bf661b9 100644 --- a/Source/Core/DolphinQt/Debugger/JITWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/JITWidget.cpp @@ -12,10 +12,10 @@ #include #include "Common/GekkoDisassembler.h" +#include "Common/HostDisassembler.h" #include "Core/Core.h" #include "Core/PowerPC/PPCAnalyst.h" #include "Core/System.h" -#include "UICommon/Disassembler.h" #include "DolphinQt/Host.h" #include "DolphinQt/Settings.h" diff --git a/Source/Core/UICommon/CMakeLists.txt b/Source/Core/UICommon/CMakeLists.txt index fa247514e8..7200bd500f 100644 --- a/Source/Core/UICommon/CMakeLists.txt +++ b/Source/Core/UICommon/CMakeLists.txt @@ -3,8 +3,6 @@ add_library(uicommon AutoUpdate.h CommandLineParse.cpp CommandLineParse.h - Disassembler.cpp - Disassembler.h DiscordPresence.cpp DiscordPresence.h GameFile.cpp @@ -59,28 +57,6 @@ if(TARGET LibUSB::LibUSB) target_link_libraries(uicommon PRIVATE LibUSB::LibUSB) endif() -if(ENABLE_LLVM) - find_package(LLVM CONFIG) - if(LLVM_FOUND) - message(STATUS "LLVM found, enabling LLVM support in disassembler") - target_compile_definitions(uicommon PRIVATE HAVE_LLVM) - # Minimal documentation about LLVM's CMake functions is available here: - # https://releases.llvm.org/16.0.0/docs/CMake.html#embedding-llvm-in-your-project - # https://groups.google.com/g/llvm-dev/c/YeEVe7HTasQ?pli=1 - # - # However, you have to read the source code in any case. - # Look for LLVM-Config.cmake in your (Unix) system: - # $ find /usr -name LLVM-Config\\.cmake 2>/dev/null - llvm_expand_pseudo_components(LLVM_EXPAND_COMPONENTS - AllTargetsInfos AllTargetsDisassemblers AllTargetsCodeGens - ) - llvm_config(uicommon USE_SHARED - mcdisassembler target ${LLVM_EXPAND_COMPONENTS} - ) - target_include_directories(uicommon PRIVATE ${LLVM_INCLUDE_DIRS}) - endif() -endif() - if(USE_DISCORD_PRESENCE) target_compile_definitions(uicommon PRIVATE -DUSE_DISCORD_PRESENCE) target_link_libraries(uicommon PRIVATE discord-rpc)