mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-25 23:25:41 +00:00
Misc: Swap LIKELY/UNLIKELY macros for attributes
This commit is contained in:
parent
adc124c759
commit
60aca2fc4d
|
@ -484,7 +484,7 @@ u64 Threading::GetThreadTicksPerSecond()
|
||||||
// On x86, despite what the MS documentation says, this basically appears to be rdtsc.
|
// On x86, despite what the MS documentation says, this basically appears to be rdtsc.
|
||||||
// So, the frequency is our base clock speed (and stable regardless of power management).
|
// So, the frequency is our base clock speed (and stable regardless of power management).
|
||||||
static u64 frequency = 0;
|
static u64 frequency = 0;
|
||||||
if (UNLIKELY(frequency == 0))
|
if (frequency == 0) [[unlikely]]
|
||||||
{
|
{
|
||||||
frequency = 1000000;
|
frequency = 1000000;
|
||||||
|
|
||||||
|
|
|
@ -56,15 +56,6 @@ char (&__countof_ArraySizeHelper(T (&array)[N]))[N];
|
||||||
#define printflike(n,m)
|
#define printflike(n,m)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
// TODO: Use C++20 [[likely]] when available.
|
|
||||||
#define LIKELY(x) (!!(x))
|
|
||||||
#define UNLIKELY(x) (!!(x))
|
|
||||||
#else
|
|
||||||
#define LIKELY(x) __builtin_expect(!!(x), 1)
|
|
||||||
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// [[noreturn]] which can be used on function pointers.
|
// [[noreturn]] which can be used on function pointers.
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// __declspec(noreturn) produces error C3829.
|
// __declspec(noreturn) produces error C3829.
|
||||||
|
|
|
@ -2125,9 +2125,9 @@ template<PGXPMode pgxp_mode, bool debug>
|
||||||
if (s_trace_to_log)
|
if (s_trace_to_log)
|
||||||
LogInstruction(g_state.current_instruction.bits, g_state.current_instruction_pc, &g_state.regs);
|
LogInstruction(g_state.current_instruction.bits, g_state.current_instruction_pc, &g_state.regs);
|
||||||
|
|
||||||
if (UNLIKELY(g_state.current_instruction_pc == 0xA0))
|
if (g_state.current_instruction_pc == 0xA0) [[unlikely]]
|
||||||
HandleA0Syscall();
|
HandleA0Syscall();
|
||||||
else if (UNLIKELY(g_state.current_instruction_pc == 0xB0))
|
else if (g_state.current_instruction_pc == 0xB0) [[unlikely]]
|
||||||
HandleB0Syscall();
|
HandleB0Syscall();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -634,7 +634,7 @@ void MDEC::CopyOutBlock(void* param, TickCount ticks, TickCount ticks_late)
|
||||||
|
|
||||||
case DataOutputDepth_15Bit:
|
case DataOutputDepth_15Bit:
|
||||||
{
|
{
|
||||||
if (UNLIKELY(g_settings.use_old_mdec_routines))
|
if (g_settings.use_old_mdec_routines) [[unlikely]]
|
||||||
{
|
{
|
||||||
const u16 a = ZeroExtend16(s_status.data_output_bit15.GetValue()) << 15;
|
const u16 a = ZeroExtend16(s_status.data_output_bit15.GetValue()) << 15;
|
||||||
for (u32 i = 0; i < static_cast<u32>(s_block_rgb.size());)
|
for (u32 i = 0; i < static_cast<u32>(s_block_rgb.size());)
|
||||||
|
@ -769,7 +769,7 @@ bool MDEC::rl_decode_block(s16* blk, const u8* qt)
|
||||||
void MDEC::IDCT(s16* blk)
|
void MDEC::IDCT(s16* blk)
|
||||||
{
|
{
|
||||||
// people have made texture packs using the old conversion routines.. best to just leave them be.
|
// people have made texture packs using the old conversion routines.. best to just leave them be.
|
||||||
if (UNLIKELY(g_settings.use_old_mdec_routines))
|
if (g_settings.use_old_mdec_routines) [[unlikely]]
|
||||||
IDCT_Old(blk);
|
IDCT_Old(blk);
|
||||||
else
|
else
|
||||||
IDCT_New(blk);
|
IDCT_New(blk);
|
||||||
|
|
|
@ -114,7 +114,7 @@ void D3D11Framebuffer::SetDebugName(const std::string_view& name)
|
||||||
|
|
||||||
void D3D11Framebuffer::CommitClear(ID3D11DeviceContext1* context)
|
void D3D11Framebuffer::CommitClear(ID3D11DeviceContext1* context)
|
||||||
{
|
{
|
||||||
if (UNLIKELY(m_rt && m_rt->GetState() != GPUTexture::State::Dirty))
|
if (m_rt && m_rt->GetState() != GPUTexture::State::Dirty) [[unlikely]]
|
||||||
{
|
{
|
||||||
if (m_rt->GetState() == GPUTexture::State::Invalidated)
|
if (m_rt->GetState() == GPUTexture::State::Invalidated)
|
||||||
context->DiscardView(m_rtv.Get());
|
context->DiscardView(m_rtv.Get());
|
||||||
|
@ -124,7 +124,7 @@ void D3D11Framebuffer::CommitClear(ID3D11DeviceContext1* context)
|
||||||
m_rt->SetState(GPUTexture::State::Dirty);
|
m_rt->SetState(GPUTexture::State::Dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UNLIKELY(m_ds && m_ds->GetState() != GPUTexture::State::Dirty))
|
if (m_ds && m_ds->GetState() != GPUTexture::State::Dirty) [[unlikely]]
|
||||||
{
|
{
|
||||||
if (m_ds->GetState() == GPUTexture::State::Invalidated)
|
if (m_ds->GetState() == GPUTexture::State::Invalidated)
|
||||||
context->DiscardView(m_dsv.Get());
|
context->DiscardView(m_dsv.Get());
|
||||||
|
|
|
@ -1563,7 +1563,7 @@ void D3D12Device::BeginRenderPass()
|
||||||
|
|
||||||
ID3D12GraphicsCommandList4* cmdlist = GetCommandList();
|
ID3D12GraphicsCommandList4* cmdlist = GetCommandList();
|
||||||
|
|
||||||
if (LIKELY(m_current_framebuffer))
|
if (m_current_framebuffer) [[likely]]
|
||||||
{
|
{
|
||||||
D3D12Texture* rt = static_cast<D3D12Texture*>(m_current_framebuffer->GetRT());
|
D3D12Texture* rt = static_cast<D3D12Texture*>(m_current_framebuffer->GetRT());
|
||||||
if (rt)
|
if (rt)
|
||||||
|
|
|
@ -36,7 +36,7 @@ std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view
|
||||||
s32 len;
|
s32 len;
|
||||||
|
|
||||||
// Shouldn't happen, but just in case someone tries to translate an empty string.
|
// Shouldn't happen, but just in case someone tries to translate an empty string.
|
||||||
if (UNLIKELY(msg.empty()))
|
if (msg.empty()) [[unlikely]]
|
||||||
{
|
{
|
||||||
ret.first = &s_translation_string_cache[0];
|
ret.first = &s_translation_string_cache[0];
|
||||||
ret.second = 0;
|
ret.second = 0;
|
||||||
|
@ -46,11 +46,11 @@ std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view
|
||||||
s_translation_string_mutex.lock_shared();
|
s_translation_string_mutex.lock_shared();
|
||||||
ctx_it = s_translation_string_map.find(context);
|
ctx_it = s_translation_string_map.find(context);
|
||||||
|
|
||||||
if (UNLIKELY(ctx_it == s_translation_string_map.end()))
|
if (ctx_it == s_translation_string_map.end()) [[unlikely]]
|
||||||
goto add_string;
|
goto add_string;
|
||||||
|
|
||||||
msg_it = ctx_it->second.find(msg);
|
msg_it = ctx_it->second.find(msg);
|
||||||
if (UNLIKELY(msg_it == ctx_it->second.end()))
|
if (msg_it == ctx_it->second.end()) [[unlikely]]
|
||||||
goto add_string;
|
goto add_string;
|
||||||
|
|
||||||
ret.first = &s_translation_string_cache[msg_it->second.first];
|
ret.first = &s_translation_string_cache[msg_it->second.first];
|
||||||
|
@ -62,7 +62,7 @@ add_string:
|
||||||
s_translation_string_mutex.unlock_shared();
|
s_translation_string_mutex.unlock_shared();
|
||||||
s_translation_string_mutex.lock();
|
s_translation_string_mutex.lock();
|
||||||
|
|
||||||
if (UNLIKELY(s_translation_string_cache.empty()))
|
if (s_translation_string_cache.empty()) [[unlikely]]
|
||||||
{
|
{
|
||||||
// First element is always an empty string.
|
// First element is always an empty string.
|
||||||
s_translation_string_cache.resize(TRANSLATION_STRING_CACHE_SIZE);
|
s_translation_string_cache.resize(TRANSLATION_STRING_CACHE_SIZE);
|
||||||
|
|
|
@ -2686,7 +2686,7 @@ void VulkanDevice::BeginRenderPass()
|
||||||
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, VK_NULL_HANDLE, VK_NULL_HANDLE, {}, 0u, nullptr};
|
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, VK_NULL_HANDLE, VK_NULL_HANDLE, {}, 0u, nullptr};
|
||||||
std::array<VkClearValue, 2> clear_values;
|
std::array<VkClearValue, 2> clear_values;
|
||||||
|
|
||||||
if (LIKELY(m_current_framebuffer))
|
if (m_current_framebuffer) [[likely]]
|
||||||
{
|
{
|
||||||
VkFormat rt_format = VK_FORMAT_UNDEFINED;
|
VkFormat rt_format = VK_FORMAT_UNDEFINED;
|
||||||
VkFormat ds_format = VK_FORMAT_UNDEFINED;
|
VkFormat ds_format = VK_FORMAT_UNDEFINED;
|
||||||
|
|
Loading…
Reference in a new issue