Merge pull request #10456 from merryhime/rm-StringFromFormatV

JitRegister: Use fmt
This commit is contained in:
JosJuice 2022-02-17 00:02:12 +01:00 committed by GitHub
commit d9e0bf72dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 24 deletions

View File

@ -81,15 +81,13 @@ bool IsEnabled()
return s_is_enabled;
}
void RegisterV(const void* base_address, u32 code_size, const char* format, va_list args)
void Register(const void* base_address, u32 code_size, const std::string& symbol_name)
{
#if !(defined USE_OPROFILE && USE_OPROFILE) && !defined(USE_VTUNE)
if (!s_perf_map_file.IsOpen())
return;
#endif
std::string symbol_name = StringFromFormatV(format, args);
#if defined USE_OPROFILE && USE_OPROFILE
op_write_native_code(s_agent, symbol_name.c_str(), (u64)base_address, base_address, code_size);
#endif

View File

@ -2,31 +2,32 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <stdarg.h>
#include <string>
#include <fmt/format.h>
#include "Common/CommonTypes.h"
namespace JitRegister
{
void Init(const std::string& perf_dir);
void Shutdown();
void RegisterV(const void* base_address, u32 code_size, const char* format, va_list args);
void Register(const void* base_address, u32 code_size, const std::string& symbol_name);
bool IsEnabled();
inline void Register(const void* base_address, u32 code_size, const char* format, ...)
template <typename... Args>
inline void Register(const void* base_address, u32 code_size, fmt::format_string<Args...> format,
Args&&... args)
{
va_list args;
va_start(args, format);
RegisterV(base_address, code_size, format, args);
va_end(args);
Register(base_address, code_size, fmt::format(format, std::forward<Args>(args)...));
}
inline void Register(const void* start, const void* end, const char* format, ...)
template <typename... Args>
inline void Register(const void* start, const void* end, fmt::format_string<Args...> format,
Args&&... args)
{
va_list args;
va_start(args, format);
u32 code_size = (u32)((const char*)end - (const char*)start);
RegisterV(start, code_size, format, args);
va_end(args);
Register(start, code_size, fmt::format(format, std::forward<Args>(args)...));
}
} // namespace JitRegister

View File

@ -369,7 +369,7 @@ const u8* CommonAsmRoutines::GenQuantizedStoreRuntime(bool single, EQuantizeType
const u8* load = AlignCode4();
GenQuantizedStore(single, type, -1);
RET();
JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedStore_%i_%i", type, single);
JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedStore_{}_{}", type, single);
return load;
}
@ -400,7 +400,7 @@ const u8* CommonAsmRoutines::GenQuantizedLoadRuntime(bool single, EQuantizeType
const u8* load = AlignCode4();
GenQuantizedLoad(single, type, -1);
RET();
JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedLoad_%i_%i", type, single);
JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedLoad_{}_{}", type, single);
return load;
}

View File

@ -48,7 +48,7 @@ const u8* TrampolineCache::GenerateReadTrampoline(const TrampolineInfo& info)
JMP(info.start + info.len, true);
JitRegister::Register(trampoline, GetCodePtr(), "JIT_ReadTrampoline_%x", info.pc);
JitRegister::Register(trampoline, GetCodePtr(), "JIT_ReadTrampoline_{:x}", info.pc);
return trampoline;
}
@ -67,6 +67,6 @@ const u8* TrampolineCache::GenerateWriteTrampoline(const TrampolineInfo& info)
JMP(info.start + info.len, true);
JitRegister::Register(trampoline, GetCodePtr(), "JIT_WriteTrampoline_%x", info.pc);
JitRegister::Register(trampoline, GetCodePtr(), "JIT_WriteTrampoline_{:x}", info.pc);
return trampoline;
}

View File

@ -131,12 +131,12 @@ void JitBaseBlockCache::FinalizeBlock(JitBlock& block, bool block_link,
if (JitRegister::IsEnabled() &&
(symbol = g_symbolDB.GetSymbolFromAddr(block.effectiveAddress)) != nullptr)
{
JitRegister::Register(block.checkedEntry, block.codeSize, "JIT_PPC_%s_%08x",
JitRegister::Register(block.checkedEntry, block.codeSize, "JIT_PPC_{}_{:08x}",
symbol->function_name.c_str(), block.physicalAddress);
}
else
{
JitRegister::Register(block.checkedEntry, block.codeSize, "JIT_PPC_%08x",
JitRegister::Register(block.checkedEntry, block.codeSize, "JIT_PPC_{:08x}",
block.physicalAddress);
}
}

View File

@ -50,9 +50,8 @@ VertexLoaderX64::VertexLoaderX64(const TVtxDesc& vtx_desc, const VAT& vtx_att)
GenerateVertexLoader();
WriteProtect();
const std::string name =
fmt::format("VertexLoaderX64\nVtx desc: \n{}\nVAT:\n{}", vtx_desc, vtx_att);
JitRegister::Register(region, GetCodePtr(), name.c_str());
JitRegister::Register(region, GetCodePtr(), "VertexLoaderX64\nVtx desc: \n{}\nVAT:\n{}", vtx_desc,
vtx_att);
}
OpArg VertexLoaderX64::GetVertexAddr(CPArray array, VertexComponentFormat attribute)