[+] Use hwinfo cacheline in Cache.cpp fallback asm impl of instruction flush

This commit is contained in:
Reece Wilson 2022-04-12 20:15:14 +01:00
parent 9fe22062f8
commit a1a46e5324

View File

@ -85,14 +85,18 @@ namespace Aurora::Memory::Cache
cacheflush(AuReinterpretCast<const void *>(base), length, ICACHE);
#elif (defined(AURORA_ARCH_X86) || defined(AURORA_ARCH_X64)) && (defined(AURORA_COMPILER_CLANG) || AURORA_COMPILER_GCC)
const size_t cacheLine = 64; // TODO: pull from Aurora::HWInfo
auto dwCacheLine = AuHwInfo::GetCPUInfo().dwCacheLine;
const auto kCacheLine = dwCacheLine ?
dwCacheLine :
64;
asm volatile("sfence\n\t"
:
:
: "memory");
for (AuUInt i = 0; i < length; i += cacheLine)
for (AuUInt i = 0; i < length; i += kCacheLine)
{
asm volatile("clflush (%0)\n\t"
: