asmjit 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +5 -3
- data/asmjit.gemspec +1 -3
- data/ext/asmjit/asmjit/.editorconfig +10 -0
- data/ext/asmjit/asmjit/.github/FUNDING.yml +1 -0
- data/ext/asmjit/asmjit/.github/workflows/build-config.json +47 -0
- data/ext/asmjit/asmjit/.github/workflows/build.yml +156 -0
- data/ext/asmjit/asmjit/.gitignore +6 -0
- data/ext/asmjit/asmjit/CMakeLists.txt +611 -0
- data/ext/asmjit/asmjit/LICENSE.md +17 -0
- data/ext/asmjit/asmjit/README.md +69 -0
- data/ext/asmjit/asmjit/src/asmjit/a64.h +62 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64archtraits_p.h +81 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.cpp +5115 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.h +72 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.cpp +51 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.h +57 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.cpp +60 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.h +247 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper.cpp +464 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper_p.h +50 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64emitter.h +1228 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter.cpp +298 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter_p.h +59 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64func.cpp +189 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64func_p.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64globals.h +1894 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi.cpp +278 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi_p.h +41 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.cpp +1957 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.h +74 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb_p.h +876 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.cpp +85 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.h +312 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass.cpp +852 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass_p.h +105 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64utils.h +179 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armformatter.cpp +143 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armformatter_p.h +44 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armglobals.h +21 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armoperand.h +621 -0
- data/ext/asmjit/asmjit/src/asmjit/arm.h +62 -0
- data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-begin.h +17 -0
- data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-end.h +9 -0
- data/ext/asmjit/asmjit/src/asmjit/asmjit.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/core/api-build_p.h +55 -0
- data/ext/asmjit/asmjit/src/asmjit/core/api-config.h +613 -0
- data/ext/asmjit/asmjit/src/asmjit/core/archcommons.h +229 -0
- data/ext/asmjit/asmjit/src/asmjit/core/archtraits.cpp +160 -0
- data/ext/asmjit/asmjit/src/asmjit/core/archtraits.h +290 -0
- data/ext/asmjit/asmjit/src/asmjit/core/assembler.cpp +406 -0
- data/ext/asmjit/asmjit/src/asmjit/core/assembler.h +129 -0
- data/ext/asmjit/asmjit/src/asmjit/core/builder.cpp +889 -0
- data/ext/asmjit/asmjit/src/asmjit/core/builder.h +1391 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codebuffer.h +113 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codeholder.cpp +1149 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codeholder.h +1035 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codewriter.cpp +175 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codewriter_p.h +179 -0
- data/ext/asmjit/asmjit/src/asmjit/core/compiler.cpp +582 -0
- data/ext/asmjit/asmjit/src/asmjit/core/compiler.h +737 -0
- data/ext/asmjit/asmjit/src/asmjit/core/compilerdefs.h +173 -0
- data/ext/asmjit/asmjit/src/asmjit/core/constpool.cpp +363 -0
- data/ext/asmjit/asmjit/src/asmjit/core/constpool.h +250 -0
- data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.cpp +1162 -0
- data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.h +813 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emithelper.cpp +323 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emithelper_p.h +58 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitter.cpp +333 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitter.h +741 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitterutils.cpp +129 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitterutils_p.h +89 -0
- data/ext/asmjit/asmjit/src/asmjit/core/environment.cpp +46 -0
- data/ext/asmjit/asmjit/src/asmjit/core/environment.h +508 -0
- data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.cpp +14 -0
- data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.h +228 -0
- data/ext/asmjit/asmjit/src/asmjit/core/formatter.cpp +584 -0
- data/ext/asmjit/asmjit/src/asmjit/core/formatter.h +247 -0
- data/ext/asmjit/asmjit/src/asmjit/core/formatter_p.h +34 -0
- data/ext/asmjit/asmjit/src/asmjit/core/func.cpp +286 -0
- data/ext/asmjit/asmjit/src/asmjit/core/func.h +1445 -0
- data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext.cpp +293 -0
- data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext_p.h +199 -0
- data/ext/asmjit/asmjit/src/asmjit/core/globals.cpp +133 -0
- data/ext/asmjit/asmjit/src/asmjit/core/globals.h +393 -0
- data/ext/asmjit/asmjit/src/asmjit/core/inst.cpp +113 -0
- data/ext/asmjit/asmjit/src/asmjit/core/inst.h +772 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.cpp +1242 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.h +261 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.cpp +80 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.h +89 -0
- data/ext/asmjit/asmjit/src/asmjit/core/logger.cpp +69 -0
- data/ext/asmjit/asmjit/src/asmjit/core/logger.h +198 -0
- data/ext/asmjit/asmjit/src/asmjit/core/misc_p.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/core/operand.cpp +132 -0
- data/ext/asmjit/asmjit/src/asmjit/core/operand.h +1611 -0
- data/ext/asmjit/asmjit/src/asmjit/core/osutils.cpp +84 -0
- data/ext/asmjit/asmjit/src/asmjit/core/osutils.h +61 -0
- data/ext/asmjit/asmjit/src/asmjit/core/osutils_p.h +68 -0
- data/ext/asmjit/asmjit/src/asmjit/core/raassignment_p.h +418 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rabuilders_p.h +612 -0
- data/ext/asmjit/asmjit/src/asmjit/core/radefs_p.h +1204 -0
- data/ext/asmjit/asmjit/src/asmjit/core/ralocal.cpp +1166 -0
- data/ext/asmjit/asmjit/src/asmjit/core/ralocal_p.h +254 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rapass.cpp +1969 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rapass_p.h +1183 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rastack.cpp +184 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rastack_p.h +171 -0
- data/ext/asmjit/asmjit/src/asmjit/core/string.cpp +559 -0
- data/ext/asmjit/asmjit/src/asmjit/core/string.h +372 -0
- data/ext/asmjit/asmjit/src/asmjit/core/support.cpp +494 -0
- data/ext/asmjit/asmjit/src/asmjit/core/support.h +1773 -0
- data/ext/asmjit/asmjit/src/asmjit/core/target.cpp +14 -0
- data/ext/asmjit/asmjit/src/asmjit/core/target.h +53 -0
- data/ext/asmjit/asmjit/src/asmjit/core/type.cpp +74 -0
- data/ext/asmjit/asmjit/src/asmjit/core/type.h +419 -0
- data/ext/asmjit/asmjit/src/asmjit/core/virtmem.cpp +722 -0
- data/ext/asmjit/asmjit/src/asmjit/core/virtmem.h +242 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zone.cpp +353 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zone.h +615 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonehash.cpp +309 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonehash.h +186 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonelist.cpp +163 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonelist.h +209 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonestack.cpp +176 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonestack.h +239 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonestring.h +120 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonetree.cpp +99 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonetree.h +380 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonevector.cpp +356 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonevector.h +690 -0
- data/ext/asmjit/asmjit/src/asmjit/core.h +1861 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86archtraits_p.h +148 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.cpp +5110 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.h +685 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.cpp +52 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.h +351 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.cpp +61 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.h +721 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper.cpp +619 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper_p.h +60 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86emitter.h +4315 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter.cpp +944 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter_p.h +58 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86func.cpp +503 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86func_p.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86globals.h +2169 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi.cpp +1732 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi_p.h +41 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.cpp +4427 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.h +563 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb_p.h +311 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86opcode_p.h +436 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.cpp +231 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.h +1085 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass.cpp +1509 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass_p.h +94 -0
- data/ext/asmjit/asmjit/src/asmjit/x86.h +93 -0
- data/ext/asmjit/asmjit/src/asmjit.natvis +245 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler.cpp +84 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler.h +85 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler_a64.cpp +4006 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler_x64.cpp +17833 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler_x86.cpp +8300 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler.cpp +253 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler.h +73 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler_a64.cpp +690 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler_x86.cpp +4317 -0
- data/ext/asmjit/asmjit/test/asmjit_test_emitters.cpp +197 -0
- data/ext/asmjit/asmjit/test/asmjit_test_instinfo.cpp +181 -0
- data/ext/asmjit/asmjit/test/asmjit_test_misc.h +257 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf.cpp +62 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf.h +61 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf_a64.cpp +699 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf_x86.cpp +5032 -0
- data/ext/asmjit/asmjit/test/asmjit_test_unit.cpp +172 -0
- data/ext/asmjit/asmjit/test/asmjit_test_x86_sections.cpp +172 -0
- data/ext/asmjit/asmjit/test/asmjitutils.h +38 -0
- data/ext/asmjit/asmjit/test/broken.cpp +312 -0
- data/ext/asmjit/asmjit/test/broken.h +148 -0
- data/ext/asmjit/asmjit/test/cmdline.h +61 -0
- data/ext/asmjit/asmjit/test/performancetimer.h +41 -0
- data/ext/asmjit/asmjit/tools/configure-makefiles.sh +13 -0
- data/ext/asmjit/asmjit/tools/configure-ninja.sh +13 -0
- data/ext/asmjit/asmjit/tools/configure-sanitizers.sh +13 -0
- data/ext/asmjit/asmjit/tools/configure-vs2019-x64.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-vs2019-x86.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-vs2022-x64.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-vs2022-x86.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-xcode.sh +8 -0
- data/ext/asmjit/asmjit/tools/enumgen.js +417 -0
- data/ext/asmjit/asmjit/tools/enumgen.sh +3 -0
- data/ext/asmjit/asmjit/tools/tablegen-arm.js +365 -0
- data/ext/asmjit/asmjit/tools/tablegen-arm.sh +3 -0
- data/ext/asmjit/asmjit/tools/tablegen-x86.js +2638 -0
- data/ext/asmjit/asmjit/tools/tablegen-x86.sh +3 -0
- data/ext/asmjit/asmjit/tools/tablegen.js +947 -0
- data/ext/asmjit/asmjit/tools/tablegen.sh +4 -0
- data/ext/asmjit/asmjit.cc +167 -30
- data/ext/asmjit/extconf.rb +9 -9
- data/lib/asmjit/version.rb +1 -1
- data/lib/asmjit.rb +14 -4
- metadata +198 -17
@@ -0,0 +1,813 @@
|
|
1
|
+
// This file is part of AsmJit project <https://asmjit.com>
|
2
|
+
//
|
3
|
+
// See asmjit.h or LICENSE.md for license and copyright information
|
4
|
+
// SPDX-License-Identifier: Zlib
|
5
|
+
|
6
|
+
#ifndef ASMJIT_CORE_CPUINFO_H_INCLUDED
|
7
|
+
#define ASMJIT_CORE_CPUINFO_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/archtraits.h"
|
10
|
+
#include "../core/environment.h"
|
11
|
+
#include "../core/globals.h"
|
12
|
+
#include "../core/string.h"
|
13
|
+
#include "../core/support.h"
|
14
|
+
|
15
|
+
ASMJIT_BEGIN_NAMESPACE
|
16
|
+
|
17
|
+
//! \addtogroup asmjit_core
|
18
|
+
//! \{
|
19
|
+
|
20
|
+
//! CPU features information.
|
21
|
+
//!
|
22
|
+
//! Each feature is represented by a single bit in an embedded bit array.
|
23
|
+
class CpuFeatures {
|
24
|
+
public:
|
25
|
+
//! A word that is used to represents feature bits.
|
26
|
+
typedef Support::BitWord BitWord;
|
27
|
+
//! Iterator that can iterate all CPU features set.
|
28
|
+
typedef Support::BitVectorIterator<BitWord> Iterator;
|
29
|
+
|
30
|
+
//! \name Constants
|
31
|
+
//! \{
|
32
|
+
|
33
|
+
//! \cond INTERNAL
|
34
|
+
enum : uint32_t {
|
35
|
+
kMaxFeatures = 256,
|
36
|
+
kNumBitWords = kMaxFeatures / Support::kBitWordSizeInBits
|
37
|
+
};
|
38
|
+
//! \endcond
|
39
|
+
|
40
|
+
//! \}
|
41
|
+
|
42
|
+
//! \name Data
|
43
|
+
//! \{
|
44
|
+
|
45
|
+
//! CPU features data.
|
46
|
+
struct Data {
|
47
|
+
//! \name Members
|
48
|
+
//! \{
|
49
|
+
|
50
|
+
//! Data bits.
|
51
|
+
Support::Array<BitWord, kNumBitWords> _bits;
|
52
|
+
|
53
|
+
//! \}
|
54
|
+
|
55
|
+
//! \name Overloaded Operators
|
56
|
+
//! \{
|
57
|
+
|
58
|
+
inline bool operator==(const Data& other) noexcept { return eq(other); }
|
59
|
+
inline bool operator!=(const Data& other) noexcept { return !eq(other); }
|
60
|
+
|
61
|
+
//! \}
|
62
|
+
|
63
|
+
//! \name Accessors
|
64
|
+
//! \{
|
65
|
+
|
66
|
+
//! Returns true if there are no features set.
|
67
|
+
inline bool empty() const noexcept { return _bits.aggregate<Support::Or>(0) == 0; }
|
68
|
+
|
69
|
+
//! Returns all features as array of bitwords (see \ref Support::BitWord).
|
70
|
+
inline BitWord* bits() noexcept { return _bits.data(); }
|
71
|
+
//! Returns all features as array of bitwords (const).
|
72
|
+
inline const BitWord* bits() const noexcept { return _bits.data(); }
|
73
|
+
|
74
|
+
//! Returns the number of BitWords returned by \ref bits().
|
75
|
+
inline size_t bitWordCount() const noexcept { return kNumBitWords; }
|
76
|
+
|
77
|
+
//! Returns \ref Support::BitVectorIterator, that can be used to iterate over all features efficiently.
|
78
|
+
inline Iterator iterator() const noexcept { return Iterator(_bits.data(), kNumBitWords); }
|
79
|
+
|
80
|
+
//! Tests whether the feature `featureId` is present.
|
81
|
+
template<typename FeatureId>
|
82
|
+
ASMJIT_FORCE_INLINE bool has(const FeatureId& featureId) const noexcept {
|
83
|
+
ASMJIT_ASSERT(uint32_t(featureId) < kMaxFeatures);
|
84
|
+
|
85
|
+
uint32_t idx = uint32_t(featureId) / Support::kBitWordSizeInBits;
|
86
|
+
uint32_t bit = uint32_t(featureId) % Support::kBitWordSizeInBits;
|
87
|
+
|
88
|
+
return bool((_bits[idx] >> bit) & 0x1);
|
89
|
+
}
|
90
|
+
|
91
|
+
//! Tests whether all features as defined by `other` are present.
|
92
|
+
ASMJIT_FORCE_INLINE bool hasAll(const Data& other) const noexcept {
|
93
|
+
for (uint32_t i = 0; i < kNumBitWords; i++)
|
94
|
+
if ((_bits[i] & other._bits[i]) != other._bits[i])
|
95
|
+
return false;
|
96
|
+
return true;
|
97
|
+
}
|
98
|
+
|
99
|
+
//! \}
|
100
|
+
|
101
|
+
//! \name Manipulation
|
102
|
+
//! \{
|
103
|
+
|
104
|
+
inline void reset() noexcept { _bits.fill(0); }
|
105
|
+
|
106
|
+
//! Adds the given CPU `featureId` to the list of features.
|
107
|
+
template<typename FeatureId>
|
108
|
+
ASMJIT_FORCE_INLINE void add(const FeatureId& featureId) noexcept {
|
109
|
+
ASMJIT_ASSERT(uint32_t(featureId) < kMaxFeatures);
|
110
|
+
|
111
|
+
uint32_t idx = uint32_t(featureId) / Support::kBitWordSizeInBits;
|
112
|
+
uint32_t bit = uint32_t(featureId) % Support::kBitWordSizeInBits;
|
113
|
+
|
114
|
+
_bits[idx] |= BitWord(1) << bit;
|
115
|
+
}
|
116
|
+
|
117
|
+
template<typename FeatureId, typename... Args>
|
118
|
+
ASMJIT_FORCE_INLINE void add(const FeatureId& featureId, Args&&... otherFeatureIds) noexcept {
|
119
|
+
add(featureId);
|
120
|
+
add(std::forward<Args>(otherFeatureIds)...);
|
121
|
+
}
|
122
|
+
|
123
|
+
template<typename FeatureId>
|
124
|
+
ASMJIT_FORCE_INLINE void addIf(bool condition, const FeatureId& featureId) noexcept {
|
125
|
+
ASMJIT_ASSERT(uint32_t(featureId) < kMaxFeatures);
|
126
|
+
|
127
|
+
uint32_t idx = uint32_t(featureId) / Support::kBitWordSizeInBits;
|
128
|
+
uint32_t bit = uint32_t(featureId) % Support::kBitWordSizeInBits;
|
129
|
+
|
130
|
+
_bits[idx] |= BitWord(condition) << bit;
|
131
|
+
}
|
132
|
+
|
133
|
+
template<typename FeatureId, typename... Args>
|
134
|
+
ASMJIT_FORCE_INLINE void addIf(bool condition, const FeatureId& featureId, Args&&... otherFeatureIds) noexcept {
|
135
|
+
addIf(condition, featureId);
|
136
|
+
addIf(condition, std::forward<Args>(otherFeatureIds)...);
|
137
|
+
}
|
138
|
+
|
139
|
+
//! Removes the given CPU `featureId` from the list of features.
|
140
|
+
template<typename FeatureId>
|
141
|
+
ASMJIT_FORCE_INLINE void remove(const FeatureId& featureId) noexcept {
|
142
|
+
ASMJIT_ASSERT(uint32_t(featureId) < kMaxFeatures);
|
143
|
+
|
144
|
+
uint32_t idx = uint32_t(featureId) / Support::kBitWordSizeInBits;
|
145
|
+
uint32_t bit = uint32_t(featureId) % Support::kBitWordSizeInBits;
|
146
|
+
|
147
|
+
_bits[idx] &= ~(BitWord(1) << bit);
|
148
|
+
}
|
149
|
+
|
150
|
+
template<typename FeatureId, typename... Args>
|
151
|
+
ASMJIT_FORCE_INLINE void remove(const FeatureId& featureId, Args&&... otherFeatureIds) noexcept {
|
152
|
+
remove(featureId);
|
153
|
+
remove(std::forward<Args>(otherFeatureIds)...);
|
154
|
+
}
|
155
|
+
|
156
|
+
//! Tests whether this CPU features data matches `other`.
|
157
|
+
ASMJIT_FORCE_INLINE bool eq(const Data& other) const noexcept { return _bits == other._bits; }
|
158
|
+
|
159
|
+
//! \}
|
160
|
+
|
161
|
+
};
|
162
|
+
|
163
|
+
//! X86 specific features data.
|
164
|
+
struct X86 : public Data {
|
165
|
+
//! X86 CPU feature identifiers.
|
166
|
+
enum Id : uint8_t {
|
167
|
+
// @EnumValuesBegin{"enum": "CpuFeatures::X86"}@
|
168
|
+
kNone, //!< No feature (never set, used internally).
|
169
|
+
|
170
|
+
kMT, //!< CPU has multi-threading capabilities.
|
171
|
+
kNX, //!< CPU has Not-Execute-Bit aka DEP (data-execution prevention).
|
172
|
+
k3DNOW, //!< CPU has 3DNOW (3DNOW base instructions) [AMD].
|
173
|
+
k3DNOW2, //!< CPU has 3DNOW2 (enhanced 3DNOW) [AMD].
|
174
|
+
kADX, //!< CPU has ADX (multi-precision add-carry instruction extensions).
|
175
|
+
kAESNI, //!< CPU has AESNI (AES encode/decode instructions).
|
176
|
+
kALTMOVCR8, //!< CPU has LOCK MOV R<->CR0 (supports `MOV R<->CR8` via `LOCK MOV R<->CR0` in 32-bit mode) [AMD].
|
177
|
+
kAMX_BF16, //!< CPU has AMX_BF16 (advanced matrix extensions - BF16 instructions).
|
178
|
+
kAMX_INT8, //!< CPU has AMX_INT8 (advanced matrix extensions - INT8 instructions).
|
179
|
+
kAMX_TILE, //!< CPU has AMX_TILE (advanced matrix extensions).
|
180
|
+
kAVX, //!< CPU has AVX (advanced vector extensions).
|
181
|
+
kAVX2, //!< CPU has AVX2 (advanced vector extensions 2).
|
182
|
+
kAVX512_4FMAPS, //!< CPU has AVX512_FMAPS (FMA packed single).
|
183
|
+
kAVX512_4VNNIW, //!< CPU has AVX512_VNNIW (vector NN instructions word variable precision).
|
184
|
+
kAVX512_BF16, //!< CPU has AVX512_BF16 (BFLOAT16 support instruction).
|
185
|
+
kAVX512_BITALG, //!< CPU has AVX512_BITALG (VPOPCNT[B|W], VPSHUFBITQMB).
|
186
|
+
kAVX512_BW, //!< CPU has AVX512_BW (packed BYTE|WORD).
|
187
|
+
kAVX512_CDI, //!< CPU has AVX512_CDI (conflict detection).
|
188
|
+
kAVX512_DQ, //!< CPU has AVX512_DQ (packed DWORD|QWORD).
|
189
|
+
kAVX512_ERI, //!< CPU has AVX512_ERI (exponential and reciprocal).
|
190
|
+
kAVX512_F, //!< CPU has AVX512_F (AVX512 foundation).
|
191
|
+
kAVX512_FP16, //!< CPU has AVX512_FP16 (FP16 extensions).
|
192
|
+
kAVX512_IFMA, //!< CPU has AVX512_IFMA (integer fused-multiply-add using 52-bit precision).
|
193
|
+
kAVX512_PFI, //!< CPU has AVX512_PFI (prefetch instructions).
|
194
|
+
kAVX512_VBMI, //!< CPU has AVX512_VBMI (vector byte manipulation).
|
195
|
+
kAVX512_VBMI2, //!< CPU has AVX512_VBMI2 (vector byte manipulation 2).
|
196
|
+
kAVX512_VL, //!< CPU has AVX512_VL (vector length extensions).
|
197
|
+
kAVX512_VNNI, //!< CPU has AVX512_VNNI (vector neural network instructions).
|
198
|
+
kAVX512_VP2INTERSECT, //!< CPU has AVX512_VP2INTERSECT
|
199
|
+
kAVX512_VPOPCNTDQ, //!< CPU has AVX512_VPOPCNTDQ (VPOPCNT[D|Q] instructions).
|
200
|
+
kAVX_VNNI, //!< CPU has AVX_VNNI (VEX encoding of vpdpbusd/vpdpbusds/vpdpwssd/vpdpwssds).
|
201
|
+
kBMI, //!< CPU has BMI (bit manipulation instructions #1).
|
202
|
+
kBMI2, //!< CPU has BMI2 (bit manipulation instructions #2).
|
203
|
+
kCET_IBT, //!< CPU has CET-IBT (indirect branch tracking).
|
204
|
+
kCET_SS, //!< CPU has CET-SS.
|
205
|
+
kCLDEMOTE, //!< CPU has CLDEMOTE (cache line demote).
|
206
|
+
kCLFLUSH, //!< CPU has CLFUSH (Cache Line flush).
|
207
|
+
kCLFLUSHOPT, //!< CPU has CLFUSHOPT (Cache Line flush - optimized).
|
208
|
+
kCLWB, //!< CPU has CLWB.
|
209
|
+
kCLZERO, //!< CPU has CLZERO.
|
210
|
+
kCMOV, //!< CPU has CMOV (CMOV and FCMOV instructions).
|
211
|
+
kCMPXCHG16B, //!< CPU has CMPXCHG16B (compare-exchange 16 bytes) [X86_64].
|
212
|
+
kCMPXCHG8B, //!< CPU has CMPXCHG8B (compare-exchange 8 bytes).
|
213
|
+
kENCLV, //!< CPU has ENCLV.
|
214
|
+
kENQCMD, //!< CPU has ENQCMD (enqueue stores).
|
215
|
+
kERMS, //!< CPU has ERMS (enhanced REP MOVSB/STOSB).
|
216
|
+
kF16C, //!< CPU has F16C.
|
217
|
+
kFMA, //!< CPU has FMA (fused-multiply-add 3 operand form).
|
218
|
+
kFMA4, //!< CPU has FMA4 (fused-multiply-add 4 operand form).
|
219
|
+
kFPU, //!< CPU has FPU (FPU support).
|
220
|
+
kFSGSBASE, //!< CPU has FSGSBASE.
|
221
|
+
kFXSR, //!< CPU has FXSR (FXSAVE/FXRSTOR instructions).
|
222
|
+
kFXSROPT, //!< CPU has FXSROTP (FXSAVE/FXRSTOR is optimized).
|
223
|
+
kGEODE, //!< CPU has GEODE extensions (3DNOW additions).
|
224
|
+
kGFNI, //!< CPU has GFNI (Galois field instructions).
|
225
|
+
kHLE, //!< CPU has HLE.
|
226
|
+
kHRESET, //!< CPU has HRESET.
|
227
|
+
kI486, //!< CPU has I486 features (I486+ support).
|
228
|
+
kLAHFSAHF, //!< CPU has LAHF/SAHF (LAHF/SAHF in 64-bit mode) [X86_64].
|
229
|
+
kLWP, //!< CPU has LWP (lightweight profiling) [AMD].
|
230
|
+
kLZCNT, //!< CPU has LZCNT (LZCNT instruction).
|
231
|
+
kMCOMMIT, //!< CPU has MCOMMIT (MCOMMIT instruction).
|
232
|
+
kMMX, //!< CPU has MMX (MMX base instructions).
|
233
|
+
kMMX2, //!< CPU has MMX2 (MMX extensions or MMX2).
|
234
|
+
kMONITOR, //!< CPU has MONITOR (MONITOR/MWAIT instructions).
|
235
|
+
kMONITORX, //!< CPU has MONITORX (MONITORX/MWAITX instructions).
|
236
|
+
kMOVBE, //!< CPU has MOVBE (move with byte-order swap).
|
237
|
+
kMOVDIR64B, //!< CPU has MOVDIR64B (move 64 bytes as direct store).
|
238
|
+
kMOVDIRI, //!< CPU has MOVDIRI (move dword/qword as direct store).
|
239
|
+
kMPX, //!< CPU has MPX (memory protection extensions).
|
240
|
+
kMSR, //!< CPU has MSR (RDMSR/WRMSR instructions).
|
241
|
+
kMSSE, //!< CPU has MSSE (misaligned SSE support).
|
242
|
+
kOSXSAVE, //!< CPU has OSXSAVE (XSAVE enabled by OS).
|
243
|
+
kOSPKE, //!< CPU has OSPKE (PKE enabled by OS).
|
244
|
+
kPCLMULQDQ, //!< CPU has PCLMULQDQ (packed carry-less multiplication).
|
245
|
+
kPCONFIG, //!< CPU has PCONFIG (PCONFIG instruction).
|
246
|
+
kPOPCNT, //!< CPU has POPCNT (POPCNT instruction).
|
247
|
+
kPREFETCHW, //!< CPU has PREFETCHW.
|
248
|
+
kPREFETCHWT1, //!< CPU has PREFETCHWT1.
|
249
|
+
kPTWRITE, //!< CPU has PTWRITE.
|
250
|
+
kRDPID, //!< CPU has RDPID.
|
251
|
+
kRDPRU, //!< CPU has RDPRU.
|
252
|
+
kRDRAND, //!< CPU has RDRAND.
|
253
|
+
kRDSEED, //!< CPU has RDSEED.
|
254
|
+
kRDTSC, //!< CPU has RDTSC.
|
255
|
+
kRDTSCP, //!< CPU has RDTSCP.
|
256
|
+
kRTM, //!< CPU has RTM.
|
257
|
+
kSERIALIZE, //!< CPU has SERIALIZE.
|
258
|
+
kSHA, //!< CPU has SHA (SHA-1 and SHA-256 instructions).
|
259
|
+
kSKINIT, //!< CPU has SKINIT (SKINIT/STGI instructions) [AMD].
|
260
|
+
kSMAP, //!< CPU has SMAP (supervisor-mode access prevention).
|
261
|
+
kSMEP, //!< CPU has SMEP (supervisor-mode execution prevention).
|
262
|
+
kSMX, //!< CPU has SMX (safer mode extensions).
|
263
|
+
kSNP, //!< CPU has SNP.
|
264
|
+
kSSE, //!< CPU has SSE.
|
265
|
+
kSSE2, //!< CPU has SSE2.
|
266
|
+
kSSE3, //!< CPU has SSE3.
|
267
|
+
kSSE4_1, //!< CPU has SSE4.1.
|
268
|
+
kSSE4_2, //!< CPU has SSE4.2.
|
269
|
+
kSSE4A, //!< CPU has SSE4A [AMD].
|
270
|
+
kSSSE3, //!< CPU has SSSE3.
|
271
|
+
kSVM, //!< CPU has SVM (virtualization) [AMD].
|
272
|
+
kTBM, //!< CPU has TBM (trailing bit manipulation) [AMD].
|
273
|
+
kTSX, //!< CPU has TSX.
|
274
|
+
kTSXLDTRK, //!< CPU has TSXLDTRK.
|
275
|
+
kUINTR, //!< CPU has UINTR (user interrupts).
|
276
|
+
kVAES, //!< CPU has VAES (vector AES 256|512 bit support).
|
277
|
+
kVMX, //!< CPU has VMX (virtualization) [INTEL].
|
278
|
+
kVPCLMULQDQ, //!< CPU has VPCLMULQDQ (vector PCLMULQDQ 256|512-bit support).
|
279
|
+
kWAITPKG, //!< CPU has WAITPKG (UMONITOR, UMWAIT, TPAUSE).
|
280
|
+
kWBNOINVD, //!< CPU has WBNOINVD.
|
281
|
+
kXOP, //!< CPU has XOP (XOP instructions) [AMD].
|
282
|
+
kXSAVE, //!< CPU has XSAVE.
|
283
|
+
kXSAVEC, //!< CPU has XSAVEC.
|
284
|
+
kXSAVEOPT, //!< CPU has XSAVEOPT.
|
285
|
+
kXSAVES, //!< CPU has XSAVES.
|
286
|
+
// @EnumValuesEnd@
|
287
|
+
|
288
|
+
kMaxValue = kXSAVES
|
289
|
+
};
|
290
|
+
|
291
|
+
#define ASMJIT_X86_FEATURE(FEATURE) \
|
292
|
+
inline bool has##FEATURE() const noexcept { return has(X86::k##FEATURE); }
|
293
|
+
|
294
|
+
ASMJIT_X86_FEATURE(MT)
|
295
|
+
ASMJIT_X86_FEATURE(NX)
|
296
|
+
ASMJIT_X86_FEATURE(3DNOW)
|
297
|
+
ASMJIT_X86_FEATURE(3DNOW2)
|
298
|
+
ASMJIT_X86_FEATURE(ADX)
|
299
|
+
ASMJIT_X86_FEATURE(AESNI)
|
300
|
+
ASMJIT_X86_FEATURE(ALTMOVCR8)
|
301
|
+
ASMJIT_X86_FEATURE(AMX_BF16)
|
302
|
+
ASMJIT_X86_FEATURE(AMX_INT8)
|
303
|
+
ASMJIT_X86_FEATURE(AMX_TILE)
|
304
|
+
ASMJIT_X86_FEATURE(AVX)
|
305
|
+
ASMJIT_X86_FEATURE(AVX2)
|
306
|
+
ASMJIT_X86_FEATURE(AVX512_4FMAPS)
|
307
|
+
ASMJIT_X86_FEATURE(AVX512_4VNNIW)
|
308
|
+
ASMJIT_X86_FEATURE(AVX512_BF16)
|
309
|
+
ASMJIT_X86_FEATURE(AVX512_BITALG)
|
310
|
+
ASMJIT_X86_FEATURE(AVX512_BW)
|
311
|
+
ASMJIT_X86_FEATURE(AVX512_CDI)
|
312
|
+
ASMJIT_X86_FEATURE(AVX512_DQ)
|
313
|
+
ASMJIT_X86_FEATURE(AVX512_ERI)
|
314
|
+
ASMJIT_X86_FEATURE(AVX512_F)
|
315
|
+
ASMJIT_X86_FEATURE(AVX512_FP16)
|
316
|
+
ASMJIT_X86_FEATURE(AVX512_IFMA)
|
317
|
+
ASMJIT_X86_FEATURE(AVX512_PFI)
|
318
|
+
ASMJIT_X86_FEATURE(AVX512_VBMI)
|
319
|
+
ASMJIT_X86_FEATURE(AVX512_VBMI2)
|
320
|
+
ASMJIT_X86_FEATURE(AVX512_VL)
|
321
|
+
ASMJIT_X86_FEATURE(AVX512_VNNI)
|
322
|
+
ASMJIT_X86_FEATURE(AVX512_VP2INTERSECT)
|
323
|
+
ASMJIT_X86_FEATURE(AVX512_VPOPCNTDQ)
|
324
|
+
ASMJIT_X86_FEATURE(AVX_VNNI)
|
325
|
+
ASMJIT_X86_FEATURE(BMI)
|
326
|
+
ASMJIT_X86_FEATURE(BMI2)
|
327
|
+
ASMJIT_X86_FEATURE(CET_IBT)
|
328
|
+
ASMJIT_X86_FEATURE(CET_SS)
|
329
|
+
ASMJIT_X86_FEATURE(CLDEMOTE)
|
330
|
+
ASMJIT_X86_FEATURE(CLFLUSH)
|
331
|
+
ASMJIT_X86_FEATURE(CLFLUSHOPT)
|
332
|
+
ASMJIT_X86_FEATURE(CLWB)
|
333
|
+
ASMJIT_X86_FEATURE(CLZERO)
|
334
|
+
ASMJIT_X86_FEATURE(CMOV)
|
335
|
+
ASMJIT_X86_FEATURE(CMPXCHG16B)
|
336
|
+
ASMJIT_X86_FEATURE(CMPXCHG8B)
|
337
|
+
ASMJIT_X86_FEATURE(ENCLV)
|
338
|
+
ASMJIT_X86_FEATURE(ENQCMD)
|
339
|
+
ASMJIT_X86_FEATURE(ERMS)
|
340
|
+
ASMJIT_X86_FEATURE(F16C)
|
341
|
+
ASMJIT_X86_FEATURE(FMA)
|
342
|
+
ASMJIT_X86_FEATURE(FMA4)
|
343
|
+
ASMJIT_X86_FEATURE(FPU)
|
344
|
+
ASMJIT_X86_FEATURE(FSGSBASE)
|
345
|
+
ASMJIT_X86_FEATURE(FXSR)
|
346
|
+
ASMJIT_X86_FEATURE(FXSROPT)
|
347
|
+
ASMJIT_X86_FEATURE(GEODE)
|
348
|
+
ASMJIT_X86_FEATURE(GFNI)
|
349
|
+
ASMJIT_X86_FEATURE(HLE)
|
350
|
+
ASMJIT_X86_FEATURE(HRESET)
|
351
|
+
ASMJIT_X86_FEATURE(I486)
|
352
|
+
ASMJIT_X86_FEATURE(LAHFSAHF)
|
353
|
+
ASMJIT_X86_FEATURE(LWP)
|
354
|
+
ASMJIT_X86_FEATURE(LZCNT)
|
355
|
+
ASMJIT_X86_FEATURE(MCOMMIT)
|
356
|
+
ASMJIT_X86_FEATURE(MMX)
|
357
|
+
ASMJIT_X86_FEATURE(MMX2)
|
358
|
+
ASMJIT_X86_FEATURE(MONITOR)
|
359
|
+
ASMJIT_X86_FEATURE(MONITORX)
|
360
|
+
ASMJIT_X86_FEATURE(MOVBE)
|
361
|
+
ASMJIT_X86_FEATURE(MOVDIR64B)
|
362
|
+
ASMJIT_X86_FEATURE(MOVDIRI)
|
363
|
+
ASMJIT_X86_FEATURE(MPX)
|
364
|
+
ASMJIT_X86_FEATURE(MSR)
|
365
|
+
ASMJIT_X86_FEATURE(MSSE)
|
366
|
+
ASMJIT_X86_FEATURE(OSXSAVE)
|
367
|
+
ASMJIT_X86_FEATURE(OSPKE)
|
368
|
+
ASMJIT_X86_FEATURE(PCLMULQDQ)
|
369
|
+
ASMJIT_X86_FEATURE(PCONFIG)
|
370
|
+
ASMJIT_X86_FEATURE(POPCNT)
|
371
|
+
ASMJIT_X86_FEATURE(PREFETCHW)
|
372
|
+
ASMJIT_X86_FEATURE(PREFETCHWT1)
|
373
|
+
ASMJIT_X86_FEATURE(PTWRITE)
|
374
|
+
ASMJIT_X86_FEATURE(RDPID)
|
375
|
+
ASMJIT_X86_FEATURE(RDPRU)
|
376
|
+
ASMJIT_X86_FEATURE(RDRAND)
|
377
|
+
ASMJIT_X86_FEATURE(RDSEED)
|
378
|
+
ASMJIT_X86_FEATURE(RDTSC)
|
379
|
+
ASMJIT_X86_FEATURE(RDTSCP)
|
380
|
+
ASMJIT_X86_FEATURE(RTM)
|
381
|
+
ASMJIT_X86_FEATURE(SERIALIZE)
|
382
|
+
ASMJIT_X86_FEATURE(SHA)
|
383
|
+
ASMJIT_X86_FEATURE(SKINIT)
|
384
|
+
ASMJIT_X86_FEATURE(SMAP)
|
385
|
+
ASMJIT_X86_FEATURE(SMEP)
|
386
|
+
ASMJIT_X86_FEATURE(SMX)
|
387
|
+
ASMJIT_X86_FEATURE(SNP)
|
388
|
+
ASMJIT_X86_FEATURE(SSE)
|
389
|
+
ASMJIT_X86_FEATURE(SSE2)
|
390
|
+
ASMJIT_X86_FEATURE(SSE3)
|
391
|
+
ASMJIT_X86_FEATURE(SSE4_1)
|
392
|
+
ASMJIT_X86_FEATURE(SSE4_2)
|
393
|
+
ASMJIT_X86_FEATURE(SSE4A)
|
394
|
+
ASMJIT_X86_FEATURE(SSSE3)
|
395
|
+
ASMJIT_X86_FEATURE(SVM)
|
396
|
+
ASMJIT_X86_FEATURE(TBM)
|
397
|
+
ASMJIT_X86_FEATURE(TSX)
|
398
|
+
ASMJIT_X86_FEATURE(TSXLDTRK)
|
399
|
+
ASMJIT_X86_FEATURE(UINTR)
|
400
|
+
ASMJIT_X86_FEATURE(VAES)
|
401
|
+
ASMJIT_X86_FEATURE(VMX)
|
402
|
+
ASMJIT_X86_FEATURE(VPCLMULQDQ)
|
403
|
+
ASMJIT_X86_FEATURE(WAITPKG)
|
404
|
+
ASMJIT_X86_FEATURE(WBNOINVD)
|
405
|
+
ASMJIT_X86_FEATURE(XOP)
|
406
|
+
ASMJIT_X86_FEATURE(XSAVE)
|
407
|
+
ASMJIT_X86_FEATURE(XSAVEC)
|
408
|
+
ASMJIT_X86_FEATURE(XSAVEOPT)
|
409
|
+
ASMJIT_X86_FEATURE(XSAVES)
|
410
|
+
|
411
|
+
#undef ASMJIT_X86_FEATURE
|
412
|
+
};
|
413
|
+
|
414
|
+
//! ARM specific features data.
|
415
|
+
struct ARM : public Data {
|
416
|
+
//! ARM CPU feature identifiers.
|
417
|
+
enum Id : uint8_t {
|
418
|
+
// @EnumValuesBegin{"enum": "CpuFeatures::ARM"}@
|
419
|
+
kNone = 0, //!< No feature (never set, used internally).
|
420
|
+
kTHUMB, //!< THUMB v1 ISA.
|
421
|
+
kTHUMBv2, //!< THUMB v2 ISA.
|
422
|
+
|
423
|
+
kARMv6, //!< ARMv6 ISA.
|
424
|
+
kARMv7, //!< ARMv7 ISA.
|
425
|
+
kARMv8a, //!< ARMv8-A ISA.
|
426
|
+
kARMv8_1a, //!< ARMv8.1-A ISA.
|
427
|
+
kARMv8_2a, //!< ARMv8.2-A ISA.
|
428
|
+
kARMv8_3a, //!< ARMv8.3-A ISA.
|
429
|
+
kARMv8_4a, //!< ARMv8.4-A ISA.
|
430
|
+
kARMv8_5a, //!< ARMv8.5-A ISA.
|
431
|
+
kARMv8_6a, //!< ARMv8.6-A ISA.
|
432
|
+
kARMv8_7a, //!< ARMv8.7-A ISA.
|
433
|
+
|
434
|
+
kVFPv2, //!< CPU has VFPv2 instruction set.
|
435
|
+
kVFPv3, //!< CPU has VFPv3 instruction set.
|
436
|
+
kVFPv4, //!< CPU has VFPv4 instruction set.
|
437
|
+
kVFP_D32, //!< CPU has 32 VFP-D (64-bit) registers.
|
438
|
+
|
439
|
+
kAES, //!< CPU has AES (AArch64 only).
|
440
|
+
kALTNZCV, //!< CPU has ALTNZCV (AArch64 only).
|
441
|
+
kASIMD, //!< CPU has Advanced SIMD (NEON on ARM/THUMB).
|
442
|
+
kBF16, //!< CPU has BF16 (AArch64 only).
|
443
|
+
kBTI, //!< CPU has BTI (branch target identification).
|
444
|
+
kCPUID, //!< CPU has accessible CPUID register (ID_AA64ZFR0_EL1).
|
445
|
+
kCRC32, //!< CPU has CRC32 .
|
446
|
+
kDGH, //!< CPU has DGH (AArch64 only).
|
447
|
+
kDIT, //!< CPU has data independent timing instructions (DIT).
|
448
|
+
kDOTPROD, //!< CPU has DOTPROD (SDOT/UDOT).
|
449
|
+
kEDSP, //!< CPU has EDSP (ARM/THUMB only).
|
450
|
+
kFCMA, //!< CPU has FCMA (FCADD/FCMLA).
|
451
|
+
kFJCVTZS, //!< CPU has FJCVTZS (AArch64 only).
|
452
|
+
kFLAGM, //!< CPU has FLAGM (AArch64 only).
|
453
|
+
kFP16CONV, //!< CPU has FP16 (half-float) conversion.
|
454
|
+
kFP16FML, //!< CPU has FMLAL{2}/FMLSL{2}
|
455
|
+
kFP16FULL, //!< CPU has full support for FP16.
|
456
|
+
kFRINT, //!< CPU has FRINT[32|64][X|Z] (AArch64 only).
|
457
|
+
kI8MM, //!< CPU has I8MM (AArch64 only).
|
458
|
+
kIDIVA, //!< CPU has hardware SDIV and UDIV (ARM mode).
|
459
|
+
kIDIVT, //!< CPU has hardware SDIV and UDIV (THUMB mode).
|
460
|
+
kLSE, //!< CPU has large system extensions (LSE) (AArch64 only).
|
461
|
+
kMTE, //!< CPU has MTE (AArch64 only).
|
462
|
+
kRCPC_IMMO, //!< CPU has RCPC_IMMO (AArch64 only).
|
463
|
+
kRDM, //!< CPU has RDM (AArch64 only).
|
464
|
+
kPMU, //!< CPU has PMU (AArch64 only).
|
465
|
+
kPMULL, //!< CPU has PMULL (AArch64 only).
|
466
|
+
kRNG, //!< CPU has random number generation (RNG).
|
467
|
+
kSB, //!< CPU has speculative barrier SB (AArch64 only).
|
468
|
+
kSHA1, //!< CPU has SHA1.
|
469
|
+
kSHA2, //!< CPU has SHA2.
|
470
|
+
kSHA3, //!< CPU has SHA3.
|
471
|
+
kSHA512, //!< CPU has SHA512.
|
472
|
+
kSM3, //!< CPU has SM3.
|
473
|
+
kSM4, //!< CPU has SM4.
|
474
|
+
kSSBS, //!< CPU has SSBS.
|
475
|
+
kSVE, //!< CPU has SVE (AArch64 only).
|
476
|
+
kSVE_BF16, //!< CPU has SVE-BF16 (AArch64 only).
|
477
|
+
kSVE_F32MM, //!< CPU has SVE-F32MM (AArch64 only).
|
478
|
+
kSVE_F64MM, //!< CPU has SVE-F64MM (AArch64 only).
|
479
|
+
kSVE_I8MM, //!< CPU has SVE-I8MM (AArch64 only).
|
480
|
+
kSVE_PMULL, //!< CPU has SVE-PMULL (AArch64 only).
|
481
|
+
kSVE2, //!< CPU has SVE2 (AArch64 only).
|
482
|
+
kSVE2_AES, //!< CPU has SVE2-AES (AArch64 only).
|
483
|
+
kSVE2_BITPERM, //!< CPU has SVE2-BITPERM (AArch64 only).
|
484
|
+
kSVE2_SHA3, //!< CPU has SVE2-SHA3 (AArch64 only).
|
485
|
+
kSVE2_SM4, //!< CPU has SVE2-SM4 (AArch64 only).
|
486
|
+
kTME, //!< CPU has transactional memory extensions (TME).
|
487
|
+
// @EnumValuesEnd@
|
488
|
+
|
489
|
+
kMaxValue = kTME
|
490
|
+
};
|
491
|
+
|
492
|
+
#define ASMJIT_ARM_FEATURE(FEATURE) \
|
493
|
+
inline bool has##FEATURE() const noexcept { return has(ARM::k##FEATURE); }
|
494
|
+
|
495
|
+
ASMJIT_ARM_FEATURE(THUMB)
|
496
|
+
ASMJIT_ARM_FEATURE(THUMBv2)
|
497
|
+
|
498
|
+
ASMJIT_ARM_FEATURE(ARMv6)
|
499
|
+
ASMJIT_ARM_FEATURE(ARMv7)
|
500
|
+
ASMJIT_ARM_FEATURE(ARMv8a)
|
501
|
+
ASMJIT_ARM_FEATURE(ARMv8_1a)
|
502
|
+
ASMJIT_ARM_FEATURE(ARMv8_2a)
|
503
|
+
ASMJIT_ARM_FEATURE(ARMv8_3a)
|
504
|
+
ASMJIT_ARM_FEATURE(ARMv8_4a)
|
505
|
+
ASMJIT_ARM_FEATURE(ARMv8_5a)
|
506
|
+
ASMJIT_ARM_FEATURE(ARMv8_6a)
|
507
|
+
ASMJIT_ARM_FEATURE(ARMv8_7a)
|
508
|
+
|
509
|
+
ASMJIT_ARM_FEATURE(VFPv2)
|
510
|
+
ASMJIT_ARM_FEATURE(VFPv3)
|
511
|
+
ASMJIT_ARM_FEATURE(VFPv4)
|
512
|
+
ASMJIT_ARM_FEATURE(VFP_D32)
|
513
|
+
|
514
|
+
ASMJIT_ARM_FEATURE(AES)
|
515
|
+
ASMJIT_ARM_FEATURE(ALTNZCV)
|
516
|
+
ASMJIT_ARM_FEATURE(ASIMD)
|
517
|
+
ASMJIT_ARM_FEATURE(BF16)
|
518
|
+
ASMJIT_ARM_FEATURE(BTI)
|
519
|
+
ASMJIT_ARM_FEATURE(CPUID)
|
520
|
+
ASMJIT_ARM_FEATURE(CRC32)
|
521
|
+
ASMJIT_ARM_FEATURE(DGH)
|
522
|
+
ASMJIT_ARM_FEATURE(DIT)
|
523
|
+
ASMJIT_ARM_FEATURE(DOTPROD)
|
524
|
+
ASMJIT_ARM_FEATURE(EDSP)
|
525
|
+
ASMJIT_ARM_FEATURE(FCMA)
|
526
|
+
ASMJIT_ARM_FEATURE(FLAGM)
|
527
|
+
ASMJIT_ARM_FEATURE(FP16CONV)
|
528
|
+
ASMJIT_ARM_FEATURE(FP16FML)
|
529
|
+
ASMJIT_ARM_FEATURE(FP16FULL)
|
530
|
+
ASMJIT_ARM_FEATURE(FRINT)
|
531
|
+
ASMJIT_ARM_FEATURE(IDIVA)
|
532
|
+
ASMJIT_ARM_FEATURE(IDIVT)
|
533
|
+
ASMJIT_ARM_FEATURE(LSE)
|
534
|
+
ASMJIT_ARM_FEATURE(MTE)
|
535
|
+
ASMJIT_ARM_FEATURE(FJCVTZS)
|
536
|
+
ASMJIT_ARM_FEATURE(I8MM)
|
537
|
+
ASMJIT_ARM_FEATURE(RCPC_IMMO)
|
538
|
+
ASMJIT_ARM_FEATURE(RDM)
|
539
|
+
ASMJIT_ARM_FEATURE(PMU)
|
540
|
+
ASMJIT_ARM_FEATURE(PMULL)
|
541
|
+
ASMJIT_ARM_FEATURE(RNG)
|
542
|
+
ASMJIT_ARM_FEATURE(SB)
|
543
|
+
ASMJIT_ARM_FEATURE(SHA1)
|
544
|
+
ASMJIT_ARM_FEATURE(SHA2)
|
545
|
+
ASMJIT_ARM_FEATURE(SHA3)
|
546
|
+
ASMJIT_ARM_FEATURE(SHA512)
|
547
|
+
ASMJIT_ARM_FEATURE(SM3)
|
548
|
+
ASMJIT_ARM_FEATURE(SM4)
|
549
|
+
ASMJIT_ARM_FEATURE(SSBS)
|
550
|
+
ASMJIT_ARM_FEATURE(SVE)
|
551
|
+
ASMJIT_ARM_FEATURE(SVE_BF16)
|
552
|
+
ASMJIT_ARM_FEATURE(SVE_F32MM)
|
553
|
+
ASMJIT_ARM_FEATURE(SVE_F64MM)
|
554
|
+
ASMJIT_ARM_FEATURE(SVE_I8MM)
|
555
|
+
ASMJIT_ARM_FEATURE(SVE_PMULL)
|
556
|
+
ASMJIT_ARM_FEATURE(SVE2)
|
557
|
+
ASMJIT_ARM_FEATURE(SVE2_AES)
|
558
|
+
ASMJIT_ARM_FEATURE(SVE2_BITPERM)
|
559
|
+
ASMJIT_ARM_FEATURE(SVE2_SHA3)
|
560
|
+
ASMJIT_ARM_FEATURE(SVE2_SM4)
|
561
|
+
ASMJIT_ARM_FEATURE(TME)
|
562
|
+
|
563
|
+
#undef ASMJIT_ARM_FEATURE
|
564
|
+
};
|
565
|
+
|
566
|
+
static_assert(uint32_t(X86::kMaxValue) < kMaxFeatures, "The number of X86 CPU features cannot exceed CpuFeatures::kMaxFeatures");
|
567
|
+
static_assert(uint32_t(ARM::kMaxValue) < kMaxFeatures, "The number of ARM CPU features cannot exceed CpuFeatures::kMaxFeatures");
|
568
|
+
|
569
|
+
//! \}
|
570
|
+
|
571
|
+
//! \name Members
|
572
|
+
//! \{
|
573
|
+
|
574
|
+
Data _data {};
|
575
|
+
|
576
|
+
//! \}
|
577
|
+
|
578
|
+
//! \name Construction & Destruction
|
579
|
+
//! \{
|
580
|
+
|
581
|
+
inline CpuFeatures() noexcept {}
|
582
|
+
inline CpuFeatures(const CpuFeatures& other) noexcept = default;
|
583
|
+
inline explicit CpuFeatures(Globals::NoInit_) noexcept {}
|
584
|
+
|
585
|
+
//! \}
|
586
|
+
|
587
|
+
//! \name Overloaded Operators
|
588
|
+
//! \{
|
589
|
+
|
590
|
+
inline CpuFeatures& operator=(const CpuFeatures& other) noexcept = default;
|
591
|
+
|
592
|
+
inline bool operator==(const CpuFeatures& other) noexcept { return eq(other); }
|
593
|
+
inline bool operator!=(const CpuFeatures& other) noexcept { return !eq(other); }
|
594
|
+
|
595
|
+
//! \}
|
596
|
+
|
597
|
+
//! \name Accessors
|
598
|
+
//! \{
|
599
|
+
|
600
|
+
//! Returns true if there are no features set.
|
601
|
+
inline bool empty() const noexcept { return _data.empty(); }
|
602
|
+
|
603
|
+
//! Casts this base class into a derived type `T`.
|
604
|
+
template<typename T = Data>
|
605
|
+
inline T& data() noexcept { return static_cast<T&>(_data); }
|
606
|
+
|
607
|
+
//! Casts this base class into a derived type `T` (const).
|
608
|
+
template<typename T = Data>
|
609
|
+
inline const T& data() const noexcept { return static_cast<const T&>(_data); }
|
610
|
+
|
611
|
+
//! Returns CpuFeatures::Data as \ref CpuFeatures::X86.
|
612
|
+
inline X86& x86() noexcept { return data<X86>(); }
|
613
|
+
//! Returns CpuFeatures::Data as \ref CpuFeatures::X86 (const).
|
614
|
+
inline const X86& x86() const noexcept { return data<X86>(); }
|
615
|
+
|
616
|
+
//! Returns CpuFeatures::Data as \ref CpuFeatures::ARM.
|
617
|
+
inline ARM& arm() noexcept { return data<ARM>(); }
|
618
|
+
//! Returns CpuFeatures::Data as \ref CpuFeatures::ARM (const).
|
619
|
+
inline const ARM& arm() const noexcept { return data<ARM>(); }
|
620
|
+
|
621
|
+
//! Returns all features as array of bitwords (see \ref Support::BitWord).
|
622
|
+
inline BitWord* bits() noexcept { return _data.bits(); }
|
623
|
+
//! Returns all features as array of bitwords (const).
|
624
|
+
inline const BitWord* bits() const noexcept { return _data.bits(); }
|
625
|
+
//! Returns the number of BitWords returned by \ref bits().
|
626
|
+
inline size_t bitWordCount() const noexcept { return _data.bitWordCount(); }
|
627
|
+
|
628
|
+
//! Returns \ref Support::BitVectorIterator, that can be used to iterate over all features efficiently.
|
629
|
+
inline Iterator iterator() const noexcept { return _data.iterator(); }
|
630
|
+
|
631
|
+
//! Tests whether the feature `featureId` is present.
|
632
|
+
template<typename FeatureId>
|
633
|
+
inline bool has(const FeatureId& featureId) const noexcept { return _data.has(featureId); }
|
634
|
+
|
635
|
+
//! Tests whether all features as defined by `other` are present.
|
636
|
+
inline bool hasAll(const CpuFeatures& other) const noexcept { return _data.hasAll(other._data); }
|
637
|
+
|
638
|
+
//! \}
|
639
|
+
|
640
|
+
//! \name Manipulation
|
641
|
+
//! \{
|
642
|
+
|
643
|
+
inline void reset() noexcept { _data.reset(); }
|
644
|
+
|
645
|
+
//! Adds the given CPU `featureId` to the list of features.
|
646
|
+
template<typename... Args>
|
647
|
+
inline void add(Args&&... args) noexcept { return _data.add(std::forward<Args>(args)...); }
|
648
|
+
|
649
|
+
//! Adds the given CPU `featureId` to the list of features if `condition` is true.
|
650
|
+
template<typename... Args>
|
651
|
+
inline void addIf(bool condition, Args&&... args) noexcept { return _data.addIf(condition, std::forward<Args>(args)...); }
|
652
|
+
|
653
|
+
//! Removes the given CPU `featureId` from the list of features.
|
654
|
+
template<typename... Args>
|
655
|
+
inline void remove(Args&&... args) noexcept { return _data.remove(std::forward<Args>(args)...); }
|
656
|
+
|
657
|
+
//! Tests whether this CPU features matches `other`.
|
658
|
+
inline bool eq(const CpuFeatures& other) const noexcept { return _data.eq(other._data); }
|
659
|
+
|
660
|
+
//! \}
|
661
|
+
};
|
662
|
+
|
663
|
+
//! CPU information.
|
664
|
+
class CpuInfo {
|
665
|
+
public:
|
666
|
+
//! \name Members
|
667
|
+
//! \{
|
668
|
+
|
669
|
+
//! Architecture.
|
670
|
+
Arch _arch;
|
671
|
+
//! Sub-architecture.
|
672
|
+
SubArch _subArch;
|
673
|
+
//! True if the CPU was detected, false if the detection failed or it's not available.
|
674
|
+
bool _wasDetected;
|
675
|
+
//! Reserved for future use.
|
676
|
+
uint8_t _reserved;
|
677
|
+
//! CPU family ID.
|
678
|
+
uint32_t _familyId;
|
679
|
+
//! CPU model ID.
|
680
|
+
uint32_t _modelId;
|
681
|
+
//! CPU brand ID.
|
682
|
+
uint32_t _brandId;
|
683
|
+
//! CPU stepping.
|
684
|
+
uint32_t _stepping;
|
685
|
+
//! Processor type.
|
686
|
+
uint32_t _processorType;
|
687
|
+
//! Maximum number of addressable IDs for logical processors.
|
688
|
+
uint32_t _maxLogicalProcessors;
|
689
|
+
//! Cache line size (in bytes).
|
690
|
+
uint32_t _cacheLineSize;
|
691
|
+
//! Number of hardware threads.
|
692
|
+
uint32_t _hwThreadCount;
|
693
|
+
|
694
|
+
//! CPU vendor string.
|
695
|
+
FixedString<16> _vendor;
|
696
|
+
//! CPU brand string.
|
697
|
+
FixedString<64> _brand;
|
698
|
+
//! CPU features.
|
699
|
+
CpuFeatures _features;
|
700
|
+
|
701
|
+
//! \}
|
702
|
+
|
703
|
+
//! \name Construction & Destruction
|
704
|
+
//! \{
|
705
|
+
|
706
|
+
inline CpuInfo() noexcept { reset(); }
|
707
|
+
inline CpuInfo(const CpuInfo& other) noexcept = default;
|
708
|
+
|
709
|
+
inline explicit CpuInfo(Globals::NoInit_) noexcept
|
710
|
+
: _features(Globals::NoInit) {};
|
711
|
+
|
712
|
+
//! Returns the host CPU information.
|
713
|
+
ASMJIT_API static const CpuInfo& host() noexcept;
|
714
|
+
|
715
|
+
//! Initializes CpuInfo architecture and sub-architecture members to `arch` and `subArch`, respectively.
|
716
|
+
inline void initArch(Arch arch, SubArch subArch = SubArch::kUnknown) noexcept {
|
717
|
+
_arch = arch;
|
718
|
+
_subArch = subArch;
|
719
|
+
}
|
720
|
+
|
721
|
+
inline void reset() noexcept { memset(this, 0, sizeof(*this)); }
|
722
|
+
|
723
|
+
//! \}
|
724
|
+
|
725
|
+
//! \name Overloaded Operators
|
726
|
+
//! \{
|
727
|
+
|
728
|
+
inline CpuInfo& operator=(const CpuInfo& other) noexcept = default;
|
729
|
+
|
730
|
+
//! \}
|
731
|
+
|
732
|
+
//! \name Accessors
|
733
|
+
//! \{
|
734
|
+
|
735
|
+
//! Returns the CPU architecture this information relates to.
|
736
|
+
inline Arch arch() const noexcept { return _arch; }
|
737
|
+
|
738
|
+
//! Returns the CPU sub-architecture this information relates to.
|
739
|
+
inline SubArch subArch() const noexcept { return _subArch; }
|
740
|
+
|
741
|
+
//! Returns whether the CPU was detected successfully.
|
742
|
+
//!
|
743
|
+
//! If the returned value is false it means that AsmJit either failed to detect the CPU or it doesn't have
|
744
|
+
//! implementation targeting the host architecture and operating system.
|
745
|
+
inline bool wasDetected() const noexcept { return _wasDetected; }
|
746
|
+
|
747
|
+
//! Returns the CPU family ID.
|
748
|
+
//!
|
749
|
+
//! Family identifier matches the FamilyId read by using CPUID on X86 architecture.
|
750
|
+
inline uint32_t familyId() const noexcept { return _familyId; }
|
751
|
+
|
752
|
+
//! Returns the CPU model ID.
|
753
|
+
//!
|
754
|
+
//! Family identifier matches the ModelId read by using CPUID on X86 architecture.
|
755
|
+
|
756
|
+
inline uint32_t modelId() const noexcept { return _modelId; }
|
757
|
+
//! Returns the CPU brand id.
|
758
|
+
//!
|
759
|
+
//! Family identifier matches the BrandId read by using CPUID on X86 architecture.
|
760
|
+
inline uint32_t brandId() const noexcept { return _brandId; }
|
761
|
+
|
762
|
+
//! Returns the CPU stepping.
|
763
|
+
//!
|
764
|
+
//! Family identifier matches the Stepping information read by using CPUID on X86 architecture.
|
765
|
+
inline uint32_t stepping() const noexcept { return _stepping; }
|
766
|
+
|
767
|
+
//! Returns the processor type.
|
768
|
+
//!
|
769
|
+
//! Family identifier matches the ProcessorType read by using CPUID on X86 architecture.
|
770
|
+
inline uint32_t processorType() const noexcept { return _processorType; }
|
771
|
+
|
772
|
+
//! Returns the maximum number of logical processors.
|
773
|
+
inline uint32_t maxLogicalProcessors() const noexcept { return _maxLogicalProcessors; }
|
774
|
+
|
775
|
+
//! Returns the size of a cache line flush.
|
776
|
+
inline uint32_t cacheLineSize() const noexcept { return _cacheLineSize; }
|
777
|
+
|
778
|
+
//! Returns number of hardware threads available.
|
779
|
+
inline uint32_t hwThreadCount() const noexcept { return _hwThreadCount; }
|
780
|
+
|
781
|
+
//! Returns a CPU vendor string.
|
782
|
+
inline const char* vendor() const noexcept { return _vendor.str; }
|
783
|
+
//! Tests whether the CPU vendor string is equal to `s`.
|
784
|
+
inline bool isVendor(const char* s) const noexcept { return _vendor.eq(s); }
|
785
|
+
|
786
|
+
//! Returns a CPU brand string.
|
787
|
+
inline const char* brand() const noexcept { return _brand.str; }
|
788
|
+
|
789
|
+
//! Returns CPU features.
|
790
|
+
inline CpuFeatures& features() noexcept { return _features; }
|
791
|
+
//! Returns CPU features (const).
|
792
|
+
inline const CpuFeatures& features() const noexcept { return _features; }
|
793
|
+
|
794
|
+
//! Tests whether the CPU has the given `feature`.
|
795
|
+
template<typename FeatureId>
|
796
|
+
inline bool hasFeature(const FeatureId& featureId) const noexcept { return _features.has(featureId); }
|
797
|
+
|
798
|
+
//! Adds the given CPU `featureId` to the list of features.
|
799
|
+
template<typename... Args>
|
800
|
+
inline void addFeature(Args&&... args) noexcept { return _features.add(std::forward<Args>(args)...); }
|
801
|
+
|
802
|
+
//! Removes the given CPU `featureId` from the list of features.
|
803
|
+
template<typename... Args>
|
804
|
+
inline void removeFeature(Args&&... args) noexcept { return _features.remove(std::forward<Args>(args)...); }
|
805
|
+
|
806
|
+
//! \}
|
807
|
+
};
|
808
|
+
|
809
|
+
//! \}
|
810
|
+
|
811
|
+
ASMJIT_END_NAMESPACE
|
812
|
+
|
813
|
+
#endif // ASMJIT_CORE_CPUINFO_H_INCLUDED
|