summaryrefslogtreecommitdiff
path: root/Source/Core/Common/JitRegister.h
blob: b54a0c2df6ba252bb61cd82d3dffe6b9e130b823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2014 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <string>

#include <fmt/format.h>

#include "Common/CommonTypes.h"

namespace Common::JitRegister
{
void Init(const std::string& perf_dir);
void Shutdown();
void Register(const void* base_address, u32 code_size, const std::string& symbol_name);
bool IsEnabled();

template <typename... Args>
inline void Register(const void* base_address, u32 code_size, fmt::format_string<Args...> format,
                     Args&&... args)
{
  if (!IsEnabled())
    return;

  Register(base_address, code_size, fmt::format(format, std::forward<Args>(args)...));
}

template <typename... Args>
inline void Register(const void* start, const void* end, fmt::format_string<Args...> format,
                     Args&&... args)
{
  if (!IsEnabled())
    return;

  u32 code_size = (u32)((const char*)end - (const char*)start);
  Register(start, code_size, fmt::format(format, std::forward<Args>(args)...));
}
}  // namespace Common::JitRegister