summaryrefslogtreecommitdiff
path: root/src/common/x64/cpu_detect.h
blob: 0af3a8adbd8c3f45465f58d931e1fe80b6de1b79 (plain) (blame)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2013 Dolphin Emulator Project / 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <string>

namespace Common {

/// x86/x64 CPU vendors that may be detected by this module
enum class CPUVendor {
    INTEL,
    AMD,
    OTHER,
};

/// x86/x64 CPU capabilities that may be detected by this module
struct CPUCaps {
    CPUVendor vendor;
    char cpu_string[0x21];
    char brand_string[0x41];
    int num_cores;
    bool sse;
    bool sse2;
    bool sse3;
    bool ssse3;
    bool sse4_1;
    bool sse4_2;
    bool lzcnt;
    bool avx;
    bool avx2;
    bool bmi1;
    bool bmi2;
    bool fma;
    bool fma4;
    bool aes;

    // Support for the FXSAVE and FXRSTOR instructions
    bool fxsave_fxrstor;

    bool movbe;

    // This flag indicates that the hardware supports some mode in which denormal inputs and outputs
    // are automatically set to (signed) zero.
    bool flush_to_zero;

    // Support for LAHF and SAHF instructions in 64-bit mode
    bool lahf_sahf_64;

    bool long_mode;
};

/**
 * Gets the supported capabilities of the host CPU
 * @return Reference to a CPUCaps struct with the detected host CPU capabilities
 */
const CPUCaps& GetCPUCaps();

/**
 * Gets a string summary of the name and supported capabilities of the host CPU
 * @return String summary
 */
std::string GetCPUCapsString();

} // namespace Common