[a64] Implement FEAT_LSE optimizations

Adds `platform_arm64` similar to `platform_arm64` to populate a 64-bit feature-flag value and creates a `a64_extension_mask` configuration-mask for the detection and utilization of certain arm ISA features. The first feature being `FEAT_LSE` which maps to `XBYAK_AARCH64_HWCAP_ATOMIC`.

Just like the x64 backend, implements `IsFeatureEnabled` to the emitter for checking if the host processor supports a certain subset of feature flag(s) at once.

Optimizes `OPCODE_ATOMIC_EXCHANGE`, `OPCODE_ATOMIC_COMPARE_EXCHANGE`,
and `OPCODE_RESERVED_STORE` with `FEAT_LSE` instructions.
This commit is contained in:
Wunkolo
2026-03-24 06:46:24 -07:00
committed by Heel
parent bf83c4e9f5
commit dd3ffeb9cb
7 changed files with 150 additions and 2 deletions

View File

@@ -186,5 +186,7 @@ constexpr char kGuestPathSeparator = '\\';
} // namespace xe
#if XE_ARCH_AMD64 == 1
#include "platform_amd64.h"
#elif XE_ARCH_ARM64 == 1
#include "platform_arm64.h"
#endif
#endif // XENIA_BASE_PLATFORM_H_

View File

@@ -0,0 +1,50 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2026 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "xenia/base/cvar.h"
#include "xenia/base/platform.h"
#define XBYAK_NO_OP_NAMES
#include "third_party/xbyak_aarch64/xbyak_aarch64/xbyak_aarch64.h"
#include "third_party/xbyak_aarch64/xbyak_aarch64/xbyak_aarch64_util.h"
DEFINE_int64(a64_extension_mask, -1LL,
"Allow the detection and utilization of specific instruction set "
"features.\n"
" 0 = armv8.0\n"
" 1 = Large System Extensions(LSE) atomic operations\n"
" -1 = Detect and utilize all possible processor features\n",
"a64");
namespace xe {
namespace arm64 {
static uint64_t g_feature_flags = 0U;
static bool g_did_initialize_feature_flags = false;
uint64_t GetFeatureFlags() {
if (!g_did_initialize_feature_flags) {
InitFeatureFlags();
}
return g_feature_flags;
}
XE_COLD
XE_NOINLINE
void InitFeatureFlags() {
uint64_t feature_flags_ = 0U;
{
Xbyak_aarch64::util::Cpu cpu_;
#define TEST_EMIT_FEATURE(emit, ext) \
if ((cvars::a64_extension_mask & emit) == emit) { \
feature_flags_ |= (cpu_.has(ext) ? emit : 0); \
}
TEST_EMIT_FEATURE(kA64EmitLSE,
Xbyak_aarch64::util::XBYAK_AARCH64_HWCAP_ATOMIC);
#undef TEST_EMIT_FEATURE
}
g_feature_flags = feature_flags_;
g_did_initialize_feature_flags = true;
}
} // namespace arm64
} // namespace xe

View File

@@ -0,0 +1,29 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2026 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_BASE_PLATFORM_ARM64_H_
#define XENIA_BASE_PLATFORM_ARM64_H_
#include <cstdint>
namespace xe {
namespace arm64 {
enum A64FeatureFlags : uint64_t {
kA64EmitLSE = 1 << 0,
};
XE_NOALIAS
uint64_t GetFeatureFlags();
XE_COLD
void InitFeatureFlags();
} // namespace arm64
} // namespace xe
#endif // XENIA_BASE_PLATFORM_ARM64_H_