Common: Move CPU macros to types.h

This commit is contained in:
Stenzek
2023-10-01 13:57:25 +10:00
parent dd204d116e
commit b1bb33a566
18 changed files with 135 additions and 142 deletions

View File

@ -23,7 +23,6 @@
#include "common/log.h"
#include "common/md5_digest.h"
#include "common/path.h"
#include "common/platform.h"
#include "common/scoped_guard.h"
#include "common/small_string.h"
#include "common/string_util.h"
@ -231,7 +230,7 @@ std::unique_lock<std::recursive_mutex> Achievements::GetLock()
std::string Achievements::GetUserAgent()
{
return fmt::format("DuckStation for {} ({}) {}", SYSTEM_STR, CPU_ARCH_STR, g_scm_tag_str);
return fmt::format("DuckStation for {} ({}) {}", TARGET_OS_STR, CPU_ARCH_STR, g_scm_tag_str);
}
void Achievements::ReportError(const std::string_view& sv)

View File

@ -22,7 +22,6 @@
#include "common/file_system.h"
#include "common/heap_array.h"
#include "common/log.h"
#include "common/platform.h"
#include "imgui.h"
@ -30,7 +29,7 @@
#include <vector>
Log_SetChannel(CDROM);
#if defined(CPU_X64)
#if defined(CPU_ARCH_X64)
#include <emmintrin.h>
#endif
@ -3074,7 +3073,7 @@ static s16 GetPeakVolume(const u8* raw_sector, u8 channel)
{
static constexpr u32 NUM_SAMPLES = CDImage::RAW_SECTOR_SIZE / sizeof(s16);
#if defined(CPU_X64)
#if defined(CPU_ARCH_X64)
static_assert(Common::IsAlignedPow2(NUM_SAMPLES, 8));
const u8* current_ptr = raw_sector;
__m128i v_peak = _mm_set1_epi16(0);

View File

@ -36,7 +36,7 @@ static constexpr u32 INVALIDATE_THRESHOLD_TO_DISABLE_LINKING = 10;
#define USE_STATIC_CODE_BUFFER 1
#endif
#if defined(CPU_AARCH32)
#if defined(CPU_ARCH_ARM32)
// Use a smaller code buffer size on AArch32 to have a better chance of being in range.
static constexpr u32 RECOMPILER_CODE_CACHE_SIZE = 16 * 1024 * 1024;
static constexpr u32 RECOMPILER_FAR_CODE_CACHE_SIZE = 8 * 1024 * 1024;

View File

@ -993,7 +993,7 @@ void CodeGenerator::BlockPrologue()
void CodeGenerator::BlockEpilogue()
{
#if defined(_DEBUG) && defined(CPU_X64)
#if defined(_DEBUG) && defined(CPU_ARCH_X64)
m_emit->nop();
#endif
@ -1007,7 +1007,7 @@ void CodeGenerator::BlockEpilogue()
void CodeGenerator::InstructionPrologue(const CodeBlockInstruction& cbi, TickCount cycles,
bool force_sync /* = false */)
{
#if defined(_DEBUG) && defined(CPU_X64)
#if defined(_DEBUG) && defined(CPU_ARCH_X64)
m_emit->nop();
#endif

View File

@ -198,9 +198,9 @@ struct Value
static Value FromConstantU64(u64 value) { return FromConstant(value, RegSize_64); }
static Value FromConstantPtr(const void* pointer)
{
#if defined(CPU_AARCH64) || defined(CPU_X64)
#if defined(CPU_ARCH_ARM64) || defined(CPU_ARCH_X64)
return FromConstant(static_cast<u64>(reinterpret_cast<uintptr_t>(pointer)), RegSize_64);
#elif defined(CPU_AARCH32)
#elif defined(CPU_ARCH_ARM32)
return FromConstant(static_cast<u32>(reinterpret_cast<uintptr_t>(pointer)), RegSize_32);
#else
return FromConstant(0, RegSize_32);

View File

@ -2,10 +2,9 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
#include "common/platform.h"
#include "cpu_types.h"
#if defined(CPU_X64)
#if defined(CPU_ARCH_X64)
// We need to include windows.h before xbyak does..
#ifdef _WIN32
@ -15,13 +14,13 @@
#define XBYAK_NO_OP_NAMES 1
#include "xbyak.h"
#elif defined(CPU_AARCH32)
#elif defined(CPU_ARCH_ARM32)
#include "vixl/aarch32/constants-aarch32.h"
#include "vixl/aarch32/instructions-aarch32.h"
#include "vixl/aarch32/macro-assembler-aarch32.h"
#elif defined(CPU_AARCH64)
#elif defined(CPU_ARCH_ARM64)
#include "vixl/aarch64/constants-aarch64.h"
#include "vixl/aarch64/macro-assembler-aarch64.h"
@ -64,7 +63,7 @@ enum class Condition : u8
Zero
};
#if defined(CPU_X64)
#if defined(CPU_ARCH_X64)
using HostReg = unsigned;
using CodeEmitter = Xbyak::CodeGenerator;
@ -92,7 +91,7 @@ constexpr u32 CODE_STORAGE_ALIGNMENT = 4096;
#error Unknown ABI.
#endif
#elif defined(CPU_AARCH32)
#elif defined(CPU_ARCH_ARM32)
using HostReg = unsigned;
using CodeEmitter = vixl::aarch32::MacroAssembler;
@ -111,7 +110,7 @@ constexpr u32 MAX_FAR_HOST_BYTES_PER_INSTRUCTION = 128;
// Alignment of code stoarge.
constexpr u32 CODE_STORAGE_ALIGNMENT = 4096;
#elif defined(CPU_AARCH64)
#elif defined(CPU_ARCH_ARM64)
using HostReg = unsigned;
using CodeEmitter = vixl::aarch64::MacroAssembler;
@ -130,7 +129,7 @@ constexpr u32 MAX_FAR_HOST_BYTES_PER_INSTRUCTION = 128;
// Alignment of code stoarge.
constexpr u32 CODE_STORAGE_ALIGNMENT = 4096;
#elif defined(CPU_RISCV64)
#elif defined(CPU_ARCH_RISCV64)
using HostReg = unsigned;

View File

@ -10,15 +10,14 @@
#include "common/assert.h"
#include "common/log.h"
#include "common/make_array.h"
#include "common/platform.h"
#include <algorithm>
Log_SetChannel(GPU_SW);
#if defined(CPU_X64)
#if defined(CPU_ARCH_X64)
#include <emmintrin.h>
#elif defined(CPU_AARCH64)
#elif defined(CPU_ARCH_ARM64)
#ifdef _MSC_VER
#include <arm64_neon.h>
#else
@ -163,7 +162,7 @@ ALWAYS_INLINE void CopyOutRow16<GPUTexture::Format::RGBA5551, u16>(const u16* sr
{
u32 col = 0;
#if defined(CPU_X64)
#if defined(CPU_ARCH_X64)
const u32 aligned_width = Common::AlignDownPow2(width, 8);
for (; col < aligned_width; col += 8)
{
@ -177,7 +176,7 @@ ALWAYS_INLINE void CopyOutRow16<GPUTexture::Format::RGBA5551, u16>(const u16* sr
_mm_storeu_si128(reinterpret_cast<__m128i*>(dst_ptr), value);
dst_ptr += 8;
}
#elif defined(CPU_AARCH64)
#elif defined(CPU_ARCH_ARM64)
const u32 aligned_width = Common::AlignDownPow2(width, 8);
for (; col < aligned_width; col += 8)
{
@ -202,7 +201,7 @@ ALWAYS_INLINE void CopyOutRow16<GPUTexture::Format::RGB565, u16>(const u16* src_
{
u32 col = 0;
#if defined(CPU_X64)
#if defined(CPU_ARCH_X64)
const u32 aligned_width = Common::AlignDownPow2(width, 8);
for (; col < aligned_width; col += 8)
{
@ -217,7 +216,7 @@ ALWAYS_INLINE void CopyOutRow16<GPUTexture::Format::RGB565, u16>(const u16* src_
_mm_storeu_si128(reinterpret_cast<__m128i*>(dst_ptr), value);
dst_ptr += 8;
}
#elif defined(CPU_AARCH64)
#elif defined(CPU_ARCH_ARM64)
const u32 aligned_width = Common::AlignDownPow2(width, 8);
const uint16x8_t single_mask = vdupq_n_u16(0x1F);
for (; col < aligned_width; col += 8)

View File

@ -41,9 +41,9 @@
#include <span>
#include <unordered_map>
#if defined(CPU_X64)
#if defined(CPU_ARCH_X64)
#include <emmintrin.h>
#elif defined(CPU_AARCH64)
#elif defined(CPU_ARCH_ARM64)
#ifdef _MSC_VER
#include <arm64_neon.h>
#else
@ -66,7 +66,7 @@ static void Draw();
static std::tuple<float, float> GetMinMax(std::span<const float> values)
{
#if defined(CPU_X64)
#if defined(CPU_ARCH_X64)
__m128 vmin(_mm_loadu_ps(values.data()));
__m128 vmax(vmin);
@ -76,8 +76,8 @@ static std::tuple<float, float> GetMinMax(std::span<const float> values)
for (; i < aligned_count; i += 4)
{
const __m128 v(_mm_loadu_ps(&values[i]));
vmin = _mm_min_ps(v);
vmax = _mm_max_ps(v);
vmin = _mm_min_ps(vmin, v);
vmax = _mm_max_ps(vmax, v);
}
#ifdef _MSC_VER
@ -94,7 +94,7 @@ static std::tuple<float, float> GetMinMax(std::span<const float> values)
}
return std::tie(min, max);
#elif defined(CPU_AARCH64)
#elif defined(CPU_ARCH_ARM64)
float32x4_t vmin(vld1q_f32(values.data()));
float32x4_t vmax(vmin);
@ -104,8 +104,8 @@ static std::tuple<float, float> GetMinMax(std::span<const float> values)
for (; i < aligned_count; i += 4)
{
const float32x4_t v(vld1q_f32(&values[i]));
vmin = vminq_f32(v);
vmax = vmaxq_f32(v);
vmin = vminq_f32(vmin, v);
vmax = vmaxq_f32(vmax, v);
}
float min = vminvq_f32(vmin);

View File

@ -5,14 +5,13 @@
#include "common/file_system.h"
#include "common/log.h"
#include "common/path.h"
#include "common/platform.h"
#include "common/string_util.h"
#include "common/timer.h"
#include "fmt/format.h"
#include "host.h"
#include "settings.h"
#include "xxhash.h"
#if defined(CPU_X86) || defined(CPU_X64)
#if defined(CPU_ARCH_X86) || defined(CPU_ARCH_X64)
#include "xxh_x86dispatch.h"
#endif
#include <cinttypes>