From 366a8c5ce9ebd62e7f6748ee3afc9f5b4bc77ae1 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Wed, 6 Apr 2016 23:47:17 +0100 Subject: [PATCH] fixup! static -> inline in headers, moved instruction/helper/load_store.h function bodies into .cpp file --- src/core/CMakeLists.txt | 1 + src/core/arm/decoder/decoder.h | 2 +- src/core/arm/jit_x64/common.h | 2 +- .../instructions/helper/load_store.cpp | 73 ++++++++++++++++++ .../jit_x64/instructions/helper/load_store.h | 75 ++++--------------- .../arm/jit_x64/instructions/load_store.cpp | 1 + 6 files changed, 93 insertions(+), 61 deletions(-) create mode 100644 src/core/arm/jit_x64/instructions/helper/load_store.cpp diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 29275a926..ecc200938 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -287,6 +287,7 @@ if(ARCHITECTURE_x86_64) arm/jit_x64/instructions/synchronisation.cpp arm/jit_x64/instructions/status_register.cpp arm/jit_x64/instructions/thumb.cpp + arm/jit_x64/instructions/helper/load_store.cpp arm/jit_x64/interface.cpp arm/jit_x64/interpret.cpp arm/jit_x64/jit_x64.cpp diff --git a/src/core/arm/decoder/decoder.h b/src/core/arm/decoder/decoder.h index c7f65831f..212a9d0eb 100644 --- a/src/core/arm/decoder/decoder.h +++ b/src/core/arm/decoder/decoder.h @@ -122,7 +122,7 @@ enum class Register { INVALID_REG = 99 }; -static Register operator+ (Register arm_reg, int number) { +inline Register operator+ (Register arm_reg, int number) { ASSERT(arm_reg != Register::INVALID_REG); int value = static_cast(arm_reg) + number; diff --git a/src/core/arm/jit_x64/common.h b/src/core/arm/jit_x64/common.h index 97a4db067..97507dec9 100644 --- a/src/core/arm/jit_x64/common.h +++ b/src/core/arm/jit_x64/common.h @@ -43,7 +43,7 @@ constexpr bool IsValidArmReg(ArmReg arm_reg) { return static_cast(arm_reg) <= 15; } -static bool IsEvenArmReg(ArmReg arm_reg) { +inline bool IsEvenArmReg(ArmReg arm_reg) { ASSERT(IsValidArmReg(arm_reg)); return static_cast(arm_reg) % 2 == 0; } diff --git a/src/core/arm/jit_x64/instructions/helper/load_store.cpp b/src/core/arm/jit_x64/instructions/helper/load_store.cpp new file mode 100644 index 000000000..db17335ab --- /dev/null +++ b/src/core/arm/jit_x64/instructions/helper/load_store.cpp @@ -0,0 +1,73 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/common_types.h" +#include "common/swap.h" + +#include "core/arm/jit_x64/instructions/helper/load_store.h" +#include "core/memory.h" + +namespace JitX64 { + +u64 Load64LE(u32 addr) { + // TODO: Improve this. + return Memory::Read32(addr) | (static_cast(Memory::Read32(addr + 4)) << 32); +} + +u64 Load64BE(u32 addr) { + // TODO: Improve this. + return Common::swap32(Memory::Read32(addr)) | (static_cast(Common::swap32(Memory::Read32(addr + 4))) << 32); +} + +void Store64LE(u32 addr, u32 v1, u32 v2) { + Memory::Write32(addr, v1); + Memory::Write32(addr + 4, v2); +} + +void Store64BE(u32 addr, u32 v1, u32 v2) { + Memory::Write32(addr, Common::swap32(v2)); + Memory::Write32(addr + 4, Common::swap32(v1)); +} + +u32 Load32LE(u32 addr) { + return Memory::Read32(addr); +} + +u32 Load32BE(u32 addr) { + return Common::swap32(Memory::Read32(addr)); +} + +void Store32LE(u32 addr, u32 value) { + Memory::Write32(addr, value); +} + +void Store32BE(u32 addr, u32 value) { + Memory::Write32(addr, Common::swap32(value)); +} + +u16 Load16LE(u32 addr) { + return Memory::Read16(addr); +} + +u16 Load16BE(u32 addr) { + return Common::swap16(Memory::Read16(addr)); +} + +void Store16LE(u32 addr, u16 value) { + Memory::Write16(addr, value); +} + +void Store16BE(u32 addr, u16 value) { + Memory::Write16(addr, Common::swap16(value)); +} + +u32 Load8(u32 addr) { + return Memory::Read8(addr); +} + +void Store8(u32 addr, u8 value) { + Memory::Write8(addr, value); +} + +} \ No newline at end of file diff --git a/src/core/arm/jit_x64/instructions/helper/load_store.h b/src/core/arm/jit_x64/instructions/helper/load_store.h index 151a5d241..294871750 100644 --- a/src/core/arm/jit_x64/instructions/helper/load_store.h +++ b/src/core/arm/jit_x64/instructions/helper/load_store.h @@ -2,10 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/common_types.h" -#include "common/swap.h" +#pragma once -#include "core/memory.h" +#include "common/common_types.h" namespace JitX64 { @@ -13,64 +12,22 @@ namespace JitX64 { constexpr u32 RESERVATION_GRANULE_MASK = 0xFFFFFFF8; -static u64 Load64LE(u32 addr) { - // TODO: Improve this. - return Memory::Read32(addr) | (static_cast(Memory::Read32(addr + 4)) << 32); -} +u64 Load64LE(u32 addr); +u64 Load64BE(u32 addr); +void Store64LE(u32 addr, u32 v1, u32 v2); +void Store64BE(u32 addr, u32 v1, u32 v2); -static u64 Load64BE(u32 addr) { - // TODO: Improve this. - return Common::swap32(Memory::Read32(addr)) | (static_cast(Common::swap32(Memory::Read32(addr + 4))) << 32); -} +u32 Load32LE(u32 addr); +u32 Load32BE(u32 addr); +void Store32LE(u32 addr, u32 value); +void Store32BE(u32 addr, u32 value); -static void Store64LE(u32 addr, u32 v1, u32 v2) { - Memory::Write32(addr, v1); - Memory::Write32(addr + 4, v2); -} +u16 Load16LE(u32 addr); +u16 Load16BE(u32 addr); +void Store16LE(u32 addr, u16 value); +void Store16BE(u32 addr, u16 value); -static void Store64BE(u32 addr, u32 v1, u32 v2) { - Memory::Write32(addr, Common::swap32(v2)); - Memory::Write32(addr + 4, Common::swap32(v1)); -} - -static u32 Load32LE(u32 addr) { - return Memory::Read32(addr); -} - -static u32 Load32BE(u32 addr) { - return Common::swap32(Memory::Read32(addr)); -} - -static void Store32LE(u32 addr, u32 value) { - Memory::Write32(addr, value); -} - -static void Store32BE(u32 addr, u32 value) { - Memory::Write32(addr, Common::swap32(value)); -} - -static u16 Load16LE(u32 addr) { - return Memory::Read16(addr); -} - -static u16 Load16BE(u32 addr) { - return Common::swap16(Memory::Read16(addr)); -} - -static void Store16LE(u32 addr, u16 value) { - Memory::Write16(addr, value); -} - -static void Store16BE(u32 addr, u16 value) { - Memory::Write16(addr, Common::swap16(value)); -} - -static u32 Load8(u32 addr) { - return Memory::Read8(addr); -} - -static void Store8(u32 addr, u8 value) { - Memory::Write8(addr, value); -} +u32 Load8(u32 addr); +void Store8(u32 addr, u8 value); } // namespace JitX64 diff --git a/src/core/arm/jit_x64/instructions/load_store.cpp b/src/core/arm/jit_x64/instructions/load_store.cpp index a52630ab0..ade52e021 100644 --- a/src/core/arm/jit_x64/instructions/load_store.cpp +++ b/src/core/arm/jit_x64/instructions/load_store.cpp @@ -8,6 +8,7 @@ #include "core/arm/jit_x64/jit_x64.h" #include "core/arm/jit_x64/instructions/helper/load_store.h" +#include "core/memory.h" namespace JitX64 {