asmjit 0.2.0 → 0.2.1
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/asmjit.gemspec +1 -1
- 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 +18 -0
- data/lib/asmjit/version.rb +1 -1
- metadata +197 -2
@@ -0,0 +1,254 @@
|
|
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_RALOCAL_P_H_INCLUDED
|
7
|
+
#define ASMJIT_CORE_RALOCAL_P_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/api-config.h"
|
10
|
+
#ifndef ASMJIT_NO_COMPILER
|
11
|
+
|
12
|
+
#include "../core/raassignment_p.h"
|
13
|
+
#include "../core/radefs_p.h"
|
14
|
+
#include "../core/rapass_p.h"
|
15
|
+
#include "../core/support.h"
|
16
|
+
|
17
|
+
ASMJIT_BEGIN_NAMESPACE
|
18
|
+
|
19
|
+
//! \cond INTERNAL
|
20
|
+
//! \addtogroup asmjit_ra
|
21
|
+
//! \{
|
22
|
+
|
23
|
+
//! Local register allocator.
|
24
|
+
class RALocalAllocator {
|
25
|
+
public:
|
26
|
+
ASMJIT_NONCOPYABLE(RALocalAllocator)
|
27
|
+
|
28
|
+
typedef RAAssignment::PhysToWorkMap PhysToWorkMap;
|
29
|
+
typedef RAAssignment::WorkToPhysMap WorkToPhysMap;
|
30
|
+
|
31
|
+
//! Link to `BaseRAPass`.
|
32
|
+
BaseRAPass* _pass;
|
33
|
+
//! Link to `BaseCompiler`.
|
34
|
+
BaseCompiler* _cc;
|
35
|
+
|
36
|
+
//! Architecture traits.
|
37
|
+
const ArchTraits* _archTraits;
|
38
|
+
//! Registers available to the allocator.
|
39
|
+
RARegMask _availableRegs;
|
40
|
+
//! Registers clobbered by the allocator.
|
41
|
+
RARegMask _clobberedRegs;
|
42
|
+
|
43
|
+
//! Register assignment (current).
|
44
|
+
RAAssignment _curAssignment;
|
45
|
+
//! Register assignment used temporarily during assignment switches.
|
46
|
+
RAAssignment _tmpAssignment;
|
47
|
+
|
48
|
+
//! Link to the current `RABlock`.
|
49
|
+
RABlock* _block;
|
50
|
+
//! InstNode.
|
51
|
+
InstNode* _node;
|
52
|
+
//! RA instruction.
|
53
|
+
RAInst* _raInst;
|
54
|
+
|
55
|
+
//! Count of all TiedReg's.
|
56
|
+
uint32_t _tiedTotal;
|
57
|
+
//! TiedReg's total counter.
|
58
|
+
RARegCount _tiedCount;
|
59
|
+
|
60
|
+
//! Temporary workToPhysMap that can be used freely by the allocator.
|
61
|
+
WorkToPhysMap* _tmpWorkToPhysMap;
|
62
|
+
|
63
|
+
//! \name Construction & Destruction
|
64
|
+
//! \{
|
65
|
+
|
66
|
+
inline RALocalAllocator(BaseRAPass* pass) noexcept
|
67
|
+
: _pass(pass),
|
68
|
+
_cc(pass->cc()),
|
69
|
+
_archTraits(pass->_archTraits),
|
70
|
+
_availableRegs(pass->_availableRegs),
|
71
|
+
_clobberedRegs(),
|
72
|
+
_curAssignment(),
|
73
|
+
_block(nullptr),
|
74
|
+
_node(nullptr),
|
75
|
+
_raInst(nullptr),
|
76
|
+
_tiedTotal(),
|
77
|
+
_tiedCount() {}
|
78
|
+
|
79
|
+
Error init() noexcept;
|
80
|
+
|
81
|
+
//! \}
|
82
|
+
|
83
|
+
//! \name Accessors
|
84
|
+
//! \{
|
85
|
+
|
86
|
+
inline RAWorkReg* workRegById(uint32_t workId) const noexcept { return _pass->workRegById(workId); }
|
87
|
+
inline PhysToWorkMap* physToWorkMap() const noexcept { return _curAssignment.physToWorkMap(); }
|
88
|
+
inline WorkToPhysMap* workToPhysMap() const noexcept { return _curAssignment.workToPhysMap(); }
|
89
|
+
|
90
|
+
//! Returns the currently processed block.
|
91
|
+
inline RABlock* block() const noexcept { return _block; }
|
92
|
+
//! Sets the currently processed block.
|
93
|
+
inline void setBlock(RABlock* block) noexcept { _block = block; }
|
94
|
+
|
95
|
+
//! Returns the currently processed `InstNode`.
|
96
|
+
inline InstNode* node() const noexcept { return _node; }
|
97
|
+
//! Returns the currently processed `RAInst`.
|
98
|
+
inline RAInst* raInst() const noexcept { return _raInst; }
|
99
|
+
|
100
|
+
//! Returns all tied regs as `RATiedReg` array.
|
101
|
+
inline RATiedReg* tiedRegs() const noexcept { return _raInst->tiedRegs(); }
|
102
|
+
//! Returns tied registers grouped by the given `group`.
|
103
|
+
inline RATiedReg* tiedRegs(RegGroup group) const noexcept { return _raInst->tiedRegs(group); }
|
104
|
+
|
105
|
+
//! Returns count of all TiedRegs used by the instruction.
|
106
|
+
inline uint32_t tiedCount() const noexcept { return _tiedTotal; }
|
107
|
+
//! Returns count of TiedRegs used by the given register `group`.
|
108
|
+
inline uint32_t tiedCount(RegGroup group) const noexcept { return _tiedCount.get(group); }
|
109
|
+
|
110
|
+
inline bool isGroupUsed(RegGroup group) const noexcept { return _tiedCount[group] != 0; }
|
111
|
+
|
112
|
+
//! \}
|
113
|
+
|
114
|
+
//! \name Assignment
|
115
|
+
//! \{
|
116
|
+
|
117
|
+
Error makeInitialAssignment() noexcept;
|
118
|
+
|
119
|
+
Error replaceAssignment(const PhysToWorkMap* physToWorkMap) noexcept;
|
120
|
+
|
121
|
+
//! Switch to the given assignment by reassigning all register and emitting code that reassigns them.
|
122
|
+
//! This is always used to switch to a previously stored assignment.
|
123
|
+
//!
|
124
|
+
//! If `tryMode` is true then the final assignment doesn't have to be exactly same as specified by `dstPhysToWorkMap`
|
125
|
+
//! and `dstWorkToPhysMap`. This mode is only used before conditional jumps that already have assignment to generate
|
126
|
+
//! a code sequence that is always executed regardless of the flow.
|
127
|
+
Error switchToAssignment(PhysToWorkMap* dstPhysToWorkMap, const ZoneBitVector& liveIn, bool dstReadOnly, bool tryMode) noexcept;
|
128
|
+
|
129
|
+
inline Error spillRegsBeforeEntry(RABlock* block) noexcept {
|
130
|
+
return spillScratchGpRegsBeforeEntry(block->entryScratchGpRegs());
|
131
|
+
}
|
132
|
+
|
133
|
+
Error spillScratchGpRegsBeforeEntry(uint32_t scratchRegs) noexcept;
|
134
|
+
|
135
|
+
//! \}
|
136
|
+
|
137
|
+
//! \name Allocation
|
138
|
+
//! \{
|
139
|
+
|
140
|
+
Error allocInst(InstNode* node) noexcept;
|
141
|
+
Error spillAfterAllocation(InstNode* node) noexcept;
|
142
|
+
|
143
|
+
Error allocBranch(InstNode* node, RABlock* target, RABlock* cont) noexcept;
|
144
|
+
Error allocJumpTable(InstNode* node, const RABlocks& targets, RABlock* cont) noexcept;
|
145
|
+
|
146
|
+
//! \}
|
147
|
+
|
148
|
+
//! \name Decision Making
|
149
|
+
//! \{
|
150
|
+
|
151
|
+
enum CostModel : uint32_t {
|
152
|
+
kCostOfFrequency = 1048576,
|
153
|
+
kCostOfDirtyFlag = kCostOfFrequency / 4
|
154
|
+
};
|
155
|
+
|
156
|
+
inline uint32_t costByFrequency(float freq) const noexcept {
|
157
|
+
return uint32_t(int32_t(freq * float(kCostOfFrequency)));
|
158
|
+
}
|
159
|
+
|
160
|
+
inline uint32_t calculateSpillCost(RegGroup group, uint32_t workId, uint32_t assignedId) const noexcept {
|
161
|
+
RAWorkReg* workReg = workRegById(workId);
|
162
|
+
uint32_t cost = costByFrequency(workReg->liveStats().freq());
|
163
|
+
|
164
|
+
if (_curAssignment.isPhysDirty(group, assignedId))
|
165
|
+
cost += kCostOfDirtyFlag;
|
166
|
+
|
167
|
+
return cost;
|
168
|
+
}
|
169
|
+
|
170
|
+
//! Decides on register assignment.
|
171
|
+
uint32_t decideOnAssignment(RegGroup group, uint32_t workId, uint32_t assignedId, RegMask allocableRegs) const noexcept;
|
172
|
+
|
173
|
+
//! Decides on whether to MOVE or SPILL the given WorkReg, because it's allocated in a physical register that have
|
174
|
+
//! to be used by another WorkReg.
|
175
|
+
//!
|
176
|
+
//! The function must return either `RAAssignment::kPhysNone`, which means that the WorkReg of `workId` should be
|
177
|
+
//! spilled, or a valid physical register ID, which means that the register should be moved to that physical register
|
178
|
+
//! instead.
|
179
|
+
uint32_t decideOnReassignment(RegGroup group, uint32_t workId, uint32_t assignedId, RegMask allocableRegs) const noexcept;
|
180
|
+
|
181
|
+
//! Decides on best spill given a register mask `spillableRegs`
|
182
|
+
uint32_t decideOnSpillFor(RegGroup group, uint32_t workId, RegMask spillableRegs, uint32_t* spillWorkId) const noexcept;
|
183
|
+
|
184
|
+
//! \}
|
185
|
+
|
186
|
+
//! \name Emit
|
187
|
+
//! \{
|
188
|
+
|
189
|
+
//! Emits a move between a destination and source register, and fixes the
|
190
|
+
//! register assignment.
|
191
|
+
inline Error onMoveReg(RegGroup group, uint32_t workId, uint32_t dstPhysId, uint32_t srcPhysId) noexcept {
|
192
|
+
if (dstPhysId == srcPhysId) return kErrorOk;
|
193
|
+
_curAssignment.reassign(group, workId, dstPhysId, srcPhysId);
|
194
|
+
return _pass->emitMove(workId, dstPhysId, srcPhysId);
|
195
|
+
}
|
196
|
+
|
197
|
+
//! Emits a swap between two physical registers and fixes their assignment.
|
198
|
+
//!
|
199
|
+
//! \note Target must support this operation otherwise this would ASSERT.
|
200
|
+
inline Error onSwapReg(RegGroup group, uint32_t aWorkId, uint32_t aPhysId, uint32_t bWorkId, uint32_t bPhysId) noexcept {
|
201
|
+
_curAssignment.swap(group, aWorkId, aPhysId, bWorkId, bPhysId);
|
202
|
+
return _pass->emitSwap(aWorkId, aPhysId, bWorkId, bPhysId);
|
203
|
+
}
|
204
|
+
|
205
|
+
//! Emits a load from [VirtReg/WorkReg]'s spill slot to a physical register
|
206
|
+
//! and makes it assigned and clean.
|
207
|
+
inline Error onLoadReg(RegGroup group, uint32_t workId, uint32_t physId) noexcept {
|
208
|
+
_curAssignment.assign(group, workId, physId, RAAssignment::kClean);
|
209
|
+
return _pass->emitLoad(workId, physId);
|
210
|
+
}
|
211
|
+
|
212
|
+
//! Emits a save a physical register to a [VirtReg/WorkReg]'s spill slot,
|
213
|
+
//! keeps it assigned, and makes it clean.
|
214
|
+
inline Error onSaveReg(RegGroup group, uint32_t workId, uint32_t physId) noexcept {
|
215
|
+
ASMJIT_ASSERT(_curAssignment.workToPhysId(group, workId) == physId);
|
216
|
+
ASMJIT_ASSERT(_curAssignment.physToWorkId(group, physId) == workId);
|
217
|
+
|
218
|
+
_curAssignment.makeClean(group, workId, physId);
|
219
|
+
return _pass->emitSave(workId, physId);
|
220
|
+
}
|
221
|
+
|
222
|
+
//! Assigns a register, the content of it is undefined at this point.
|
223
|
+
inline Error onAssignReg(RegGroup group, uint32_t workId, uint32_t physId, bool dirty) noexcept {
|
224
|
+
_curAssignment.assign(group, workId, physId, dirty);
|
225
|
+
return kErrorOk;
|
226
|
+
}
|
227
|
+
|
228
|
+
//! Spills a variable/register, saves the content to the memory-home if modified.
|
229
|
+
inline Error onSpillReg(RegGroup group, uint32_t workId, uint32_t physId) noexcept {
|
230
|
+
if (_curAssignment.isPhysDirty(group, physId))
|
231
|
+
ASMJIT_PROPAGATE(onSaveReg(group, workId, physId));
|
232
|
+
return onKillReg(group, workId, physId);
|
233
|
+
}
|
234
|
+
|
235
|
+
inline Error onDirtyReg(RegGroup group, uint32_t workId, uint32_t physId) noexcept {
|
236
|
+
_curAssignment.makeDirty(group, workId, physId);
|
237
|
+
return kErrorOk;
|
238
|
+
}
|
239
|
+
|
240
|
+
inline Error onKillReg(RegGroup group, uint32_t workId, uint32_t physId) noexcept {
|
241
|
+
_curAssignment.unassign(group, workId, physId);
|
242
|
+
return kErrorOk;
|
243
|
+
}
|
244
|
+
|
245
|
+
//! \}
|
246
|
+
};
|
247
|
+
|
248
|
+
//! \}
|
249
|
+
//! \endcond
|
250
|
+
|
251
|
+
ASMJIT_END_NAMESPACE
|
252
|
+
|
253
|
+
#endif // !ASMJIT_NO_COMPILER
|
254
|
+
#endif // ASMJIT_CORE_RALOCAL_P_H_INCLUDED
|