From 9f24076b633f0a0fb23b667099396c2322508ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 3 Apr 2015 23:50:51 +0200 Subject: [PATCH] Make the unittests build on mac --- CMakeLists.txt | 18 +++++++++++++++--- Common/Arm64Emitter.cpp | 9 ++++++--- b.sh | 3 +++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76765bd009..68184d9b0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,9 +314,14 @@ else() Common/FakeEmitter.h) endif() # ARMEmitter is here for the unit tests and don't really hurt otherwise. +if(UNITTEST) set(CommonExtra ${CommonExtra} + Common/Arm64Emitter.h + Common/Arm64Emitter.cpp Common/ArmEmitter.h - Common/ArmEmitter.cpp) + Common/ArmEmitter.cpp + Core/Util/DisArm64.cpp) +endif() if(WIN32) set(CommonExtra ${CommonExtra} @@ -1576,9 +1581,16 @@ endif() if(UNITTEST) add_executable(unitTest unittest/UnitTest.cpp + unittest/TestArmEmitter.cpp + unittest/TestArm64Emitter.cpp + unittest/TestX64Emitter.cpp + unittest/JitHarness.cpp + Core/MIPS/ARM/ArmRegCache.cpp + Core/MIPS/ARM/ArmRegCacheFPU.cpp + UI/OnScreenDisplay.cpp ) target_link_libraries(unitTest - ${COCOA_LIBRARY} ${LinkCommon}) + ${COCOA_LIBRARY} ${LinkCommon} Common) setup_target_project(unitTest unittest) endif() @@ -1603,7 +1615,7 @@ if (TargetBin) else() add_executable(${TargetBin} ${NativeAppSource}) endif() - target_link_libraries(${TargetBin} ${LinkCommon}) + target_link_libraries(${TargetBin} ${LinkCommon} Common) endif() # installs diff --git a/Common/Arm64Emitter.cpp b/Common/Arm64Emitter.cpp index 3de3ecf432..0c864298f9 100644 --- a/Common/Arm64Emitter.cpp +++ b/Common/Arm64Emitter.cpp @@ -4,8 +4,11 @@ #include #include +#include #include +#include + #include "base/basictypes.h" #include "Arm64Emitter.h" @@ -301,7 +304,7 @@ void ARM64XEmitter::FlushIcacheSection(u8* start, u8* end) // Header file says this is equivalent to: sys_icache_invalidate(start, end - start); sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start); #else -#ifdef __clang__ +#if defined(__clang__) && !defined(_M_IX86) && !defined(_M_X64) __clear_cache(start, end); #else #if !defined(_M_IX86) && !defined(_M_X64) @@ -1864,11 +1867,11 @@ void ARM64XEmitter::MOVI2R(ARM64Reg Rd, u64 imm, bool optimize) u64 aligned_pc = (u64)GetCodePtr() & ~0xFFF; s64 aligned_offset = (s64)imm - (s64)aligned_pc; - if (upload_part.Count() > 1 && std::abs(aligned_offset) < 0xFFFFFFFF) + if (upload_part.Count() > 1 && aligned_offset >= -0xFFFFFFFFLL && aligned_offset <= 0xFFFFFFFFLL) { // Immediate we are loading is within 4GB of our aligned range // Most likely a address that we can load in one or two instructions - if (!(std::abs(aligned_offset) & 0xFFF)) + if (aligned_offset >= -0xFFFLL && aligned_offset <= 0xFFFLL) { // Aligned ADR ADRP(Rd, (s32)aligned_offset); diff --git a/b.sh b/b.sh index c4ccf75d1a..9656570d59 100755 --- a/b.sh +++ b/b.sh @@ -50,6 +50,9 @@ do --headless) echo "Headless mode enabled" CMAKE_ARGS="-DHEADLESS=ON ${CMAKE_ARGS}" ;; + --unittest) echo "Build unittest" + CMAKE_ARGS="-DUNITTEST=ON ${CMAKE_ARGS}" + ;; --no-package) echo "Packaging disabled" PACKAGE=0 ;;