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,298 @@
|
|
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
|
+
#include "../core/api-build_p.h"
|
7
|
+
#ifndef ASMJIT_NO_LOGGING
|
8
|
+
|
9
|
+
#include "../core/misc_p.h"
|
10
|
+
#include "../core/support.h"
|
11
|
+
#include "../arm/a64formatter_p.h"
|
12
|
+
#include "../arm/a64instapi_p.h"
|
13
|
+
#include "../arm/a64instdb_p.h"
|
14
|
+
#include "../arm/a64operand.h"
|
15
|
+
|
16
|
+
#ifndef ASMJIT_NO_COMPILER
|
17
|
+
#include "../core/compiler.h"
|
18
|
+
#endif
|
19
|
+
|
20
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
|
21
|
+
|
22
|
+
// a64::FormatterInternal - Format Register
|
23
|
+
// ========================================
|
24
|
+
|
25
|
+
ASMJIT_FAVOR_SIZE Error FormatterInternal::formatRegister(
|
26
|
+
String& sb,
|
27
|
+
FormatFlags flags,
|
28
|
+
const BaseEmitter* emitter,
|
29
|
+
Arch arch,
|
30
|
+
RegType regType,
|
31
|
+
uint32_t rId,
|
32
|
+
uint32_t elementType,
|
33
|
+
uint32_t elementIndex) noexcept {
|
34
|
+
|
35
|
+
DebugUtils::unused(flags);
|
36
|
+
DebugUtils::unused(arch);
|
37
|
+
|
38
|
+
static const char bhsdq[] = "bhsdq";
|
39
|
+
|
40
|
+
bool virtRegFormatted = false;
|
41
|
+
|
42
|
+
#ifndef ASMJIT_NO_COMPILER
|
43
|
+
if (Operand::isVirtId(rId)) {
|
44
|
+
if (emitter && emitter->isCompiler()) {
|
45
|
+
const BaseCompiler* cc = static_cast<const BaseCompiler*>(emitter);
|
46
|
+
if (cc->isVirtIdValid(rId)) {
|
47
|
+
VirtReg* vReg = cc->virtRegById(rId);
|
48
|
+
ASMJIT_ASSERT(vReg != nullptr);
|
49
|
+
|
50
|
+
const char* name = vReg->name();
|
51
|
+
if (name && name[0] != '\0')
|
52
|
+
ASMJIT_PROPAGATE(sb.append(name));
|
53
|
+
else
|
54
|
+
ASMJIT_PROPAGATE(sb.appendFormat("%%%u", unsigned(Operand::virtIdToIndex(rId))));
|
55
|
+
|
56
|
+
virtRegFormatted = true;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
#else
|
61
|
+
DebugUtils::unused(emitter, flags);
|
62
|
+
#endif
|
63
|
+
|
64
|
+
if (!virtRegFormatted) {
|
65
|
+
char letter = '\0';
|
66
|
+
switch (regType) {
|
67
|
+
case RegType::kARM_GpW:
|
68
|
+
if (rId == Gp::kIdZr)
|
69
|
+
return sb.append("wzr");
|
70
|
+
if (rId == Gp::kIdSp)
|
71
|
+
return sb.append("wsp");
|
72
|
+
|
73
|
+
letter = 'w';
|
74
|
+
break;
|
75
|
+
|
76
|
+
case RegType::kARM_GpX:
|
77
|
+
if (rId == Gp::kIdZr)
|
78
|
+
return sb.append("xzr");
|
79
|
+
if (rId == Gp::kIdSp)
|
80
|
+
return sb.append("sp");
|
81
|
+
|
82
|
+
letter = 'x';
|
83
|
+
break;
|
84
|
+
|
85
|
+
case RegType::kARM_VecB:
|
86
|
+
case RegType::kARM_VecH:
|
87
|
+
case RegType::kARM_VecS:
|
88
|
+
case RegType::kARM_VecD:
|
89
|
+
case RegType::kARM_VecV:
|
90
|
+
letter = bhsdq[uint32_t(regType) - uint32_t(RegType::kARM_VecB)];
|
91
|
+
if (elementType)
|
92
|
+
letter = 'v';
|
93
|
+
break;
|
94
|
+
|
95
|
+
default:
|
96
|
+
ASMJIT_PROPAGATE(sb.appendFormat("<Reg-%u>?$u", uint32_t(regType), rId));
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
|
100
|
+
if (letter)
|
101
|
+
ASMJIT_PROPAGATE(sb.appendFormat("%c%u", letter, rId));
|
102
|
+
}
|
103
|
+
|
104
|
+
if (elementType) {
|
105
|
+
char elementLetter = '\0';
|
106
|
+
uint32_t elementCount = 0;
|
107
|
+
|
108
|
+
switch (elementType) {
|
109
|
+
case Vec::kElementTypeB:
|
110
|
+
elementLetter = 'b';
|
111
|
+
elementCount = 16;
|
112
|
+
break;
|
113
|
+
|
114
|
+
case Vec::kElementTypeH:
|
115
|
+
elementLetter = 'h';
|
116
|
+
elementCount = 8;
|
117
|
+
break;
|
118
|
+
|
119
|
+
case Vec::kElementTypeS:
|
120
|
+
elementLetter = 's';
|
121
|
+
elementCount = 4;
|
122
|
+
break;
|
123
|
+
|
124
|
+
case Vec::kElementTypeD:
|
125
|
+
elementLetter = 'd';
|
126
|
+
elementCount = 2;
|
127
|
+
break;
|
128
|
+
|
129
|
+
default:
|
130
|
+
return sb.append(".<Unknown>");
|
131
|
+
}
|
132
|
+
|
133
|
+
if (elementLetter) {
|
134
|
+
if (elementIndex == 0xFFFFFFFFu) {
|
135
|
+
if (regType == RegType::kARM_VecD)
|
136
|
+
elementCount /= 2u;
|
137
|
+
ASMJIT_PROPAGATE(sb.appendFormat(".%u%c", elementCount, elementLetter));
|
138
|
+
}
|
139
|
+
else {
|
140
|
+
ASMJIT_PROPAGATE(sb.appendFormat(".%c[%u]", elementLetter, elementIndex));
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
return kErrorOk;
|
146
|
+
}
|
147
|
+
|
148
|
+
// a64::FormatterInternal - Format Operand
|
149
|
+
// =======================================
|
150
|
+
|
151
|
+
ASMJIT_FAVOR_SIZE Error FormatterInternal::formatOperand(
|
152
|
+
String& sb,
|
153
|
+
FormatFlags flags,
|
154
|
+
const BaseEmitter* emitter,
|
155
|
+
Arch arch,
|
156
|
+
const Operand_& op) noexcept {
|
157
|
+
|
158
|
+
if (op.isReg()) {
|
159
|
+
const BaseReg& reg = op.as<BaseReg>();
|
160
|
+
|
161
|
+
uint32_t elementType = op.as<Vec>().elementType();
|
162
|
+
uint32_t elementIndex = op.as<Vec>().elementIndex();
|
163
|
+
|
164
|
+
if (!op.as<Vec>().hasElementIndex())
|
165
|
+
elementIndex = 0xFFFFFFFFu;
|
166
|
+
|
167
|
+
return formatRegister(sb, flags, emitter, arch, reg.type(), reg.id(), elementType, elementIndex);
|
168
|
+
}
|
169
|
+
|
170
|
+
if (op.isMem()) {
|
171
|
+
const Mem& m = op.as<Mem>();
|
172
|
+
ASMJIT_PROPAGATE(sb.append('['));
|
173
|
+
|
174
|
+
if (m.hasBase()) {
|
175
|
+
if (m.hasBaseLabel()) {
|
176
|
+
ASMJIT_PROPAGATE(Formatter::formatLabel(sb, flags, emitter, m.baseId()));
|
177
|
+
}
|
178
|
+
else {
|
179
|
+
FormatFlags modifiedFlags = flags;
|
180
|
+
if (m.isRegHome()) {
|
181
|
+
ASMJIT_PROPAGATE(sb.append('&'));
|
182
|
+
modifiedFlags &= ~FormatFlags::kRegCasts;
|
183
|
+
}
|
184
|
+
ASMJIT_PROPAGATE(formatRegister(sb, modifiedFlags, emitter, arch, m.baseType(), m.baseId()));
|
185
|
+
}
|
186
|
+
}
|
187
|
+
else {
|
188
|
+
// ARM really requires base.
|
189
|
+
if (m.hasIndex() || m.hasOffset()) {
|
190
|
+
ASMJIT_PROPAGATE(sb.append("<None>"));
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
// The post index makes it look like there was another operand, but it's
|
195
|
+
// still the part of AsmJit's `arm::Mem` operand so it's consistent with
|
196
|
+
// other architectures.
|
197
|
+
if (m.isPostIndex())
|
198
|
+
ASMJIT_PROPAGATE(sb.append(']'));
|
199
|
+
|
200
|
+
if (m.hasIndex()) {
|
201
|
+
ASMJIT_PROPAGATE(sb.append(", "));
|
202
|
+
ASMJIT_PROPAGATE(formatRegister(sb, flags, emitter, arch, m.indexType(), m.indexId()));
|
203
|
+
}
|
204
|
+
|
205
|
+
if (m.hasOffset()) {
|
206
|
+
ASMJIT_PROPAGATE(sb.append(", "));
|
207
|
+
|
208
|
+
int64_t off = int64_t(m.offset());
|
209
|
+
uint32_t base = 10;
|
210
|
+
|
211
|
+
if (Support::test(flags, FormatFlags::kHexOffsets) && uint64_t(off) > 9)
|
212
|
+
base = 16;
|
213
|
+
|
214
|
+
if (base == 10) {
|
215
|
+
ASMJIT_PROPAGATE(sb.appendInt(off, base));
|
216
|
+
}
|
217
|
+
else {
|
218
|
+
ASMJIT_PROPAGATE(sb.append("0x"));
|
219
|
+
ASMJIT_PROPAGATE(sb.appendUInt(uint64_t(off), base));
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
if (m.hasShift()) {
|
224
|
+
ASMJIT_PROPAGATE(sb.append(' '));
|
225
|
+
if (!m.isPreOrPost())
|
226
|
+
ASMJIT_PROPAGATE(formatShiftOp(sb, (ShiftOp)m.predicate()));
|
227
|
+
ASMJIT_PROPAGATE(sb.appendFormat(" %u", m.shift()));
|
228
|
+
}
|
229
|
+
|
230
|
+
if (!m.isPostIndex())
|
231
|
+
ASMJIT_PROPAGATE(sb.append(']'));
|
232
|
+
|
233
|
+
if (m.isPreIndex())
|
234
|
+
ASMJIT_PROPAGATE(sb.append('!'));
|
235
|
+
|
236
|
+
return kErrorOk;
|
237
|
+
}
|
238
|
+
|
239
|
+
if (op.isImm()) {
|
240
|
+
const Imm& i = op.as<Imm>();
|
241
|
+
int64_t val = i.value();
|
242
|
+
|
243
|
+
if (Support::test(flags, FormatFlags::kHexImms) && uint64_t(val) > 9) {
|
244
|
+
ASMJIT_PROPAGATE(sb.append("0x"));
|
245
|
+
return sb.appendUInt(uint64_t(val), 16);
|
246
|
+
}
|
247
|
+
else {
|
248
|
+
return sb.appendInt(val, 10);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
if (op.isLabel()) {
|
253
|
+
return Formatter::formatLabel(sb, flags, emitter, op.id());
|
254
|
+
}
|
255
|
+
|
256
|
+
return sb.append("<None>");
|
257
|
+
}
|
258
|
+
|
259
|
+
// a64::FormatterInternal - Format Instruction
|
260
|
+
// ===========================================
|
261
|
+
|
262
|
+
ASMJIT_FAVOR_SIZE Error FormatterInternal::formatInstruction(
|
263
|
+
String& sb,
|
264
|
+
FormatFlags flags,
|
265
|
+
const BaseEmitter* emitter,
|
266
|
+
Arch arch,
|
267
|
+
const BaseInst& inst, const Operand_* operands, size_t opCount) noexcept {
|
268
|
+
|
269
|
+
DebugUtils::unused(arch);
|
270
|
+
|
271
|
+
// Format instruction options and instruction mnemonic.
|
272
|
+
InstId instId = inst.realId();
|
273
|
+
if (instId < Inst::_kIdCount)
|
274
|
+
ASMJIT_PROPAGATE(InstInternal::instIdToString(arch, instId, sb));
|
275
|
+
else
|
276
|
+
ASMJIT_PROPAGATE(sb.appendFormat("[InstId=#%u]", unsigned(instId)));
|
277
|
+
|
278
|
+
CondCode cc = inst.armCondCode();
|
279
|
+
if (cc != CondCode::kAL) {
|
280
|
+
ASMJIT_PROPAGATE(sb.append('.'));
|
281
|
+
ASMJIT_PROPAGATE(formatCondCode(sb, cc));
|
282
|
+
}
|
283
|
+
|
284
|
+
for (uint32_t i = 0; i < opCount; i++) {
|
285
|
+
const Operand_& op = operands[i];
|
286
|
+
if (op.isNone())
|
287
|
+
break;
|
288
|
+
|
289
|
+
ASMJIT_PROPAGATE(sb.append(i == 0 ? " " : ", "));
|
290
|
+
ASMJIT_PROPAGATE(formatOperand(sb, flags, emitter, arch, op));
|
291
|
+
}
|
292
|
+
|
293
|
+
return kErrorOk;
|
294
|
+
}
|
295
|
+
|
296
|
+
ASMJIT_END_SUB_NAMESPACE
|
297
|
+
|
298
|
+
#endif // !ASMJIT_NO_LOGGING
|
@@ -0,0 +1,59 @@
|
|
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_ARM_A64FORMATTER_P_H_INCLUDED
|
7
|
+
#define ASMJIT_ARM_A64FORMATTER_P_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/api-config.h"
|
10
|
+
#ifndef ASMJIT_NO_LOGGING
|
11
|
+
|
12
|
+
#include "../core/formatter.h"
|
13
|
+
#include "../core/string.h"
|
14
|
+
#include "../arm/armformatter_p.h"
|
15
|
+
#include "../arm/a64globals.h"
|
16
|
+
|
17
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
|
18
|
+
|
19
|
+
//! \cond INTERNAL
|
20
|
+
//! \addtogroup asmjit_a64
|
21
|
+
//! \{
|
22
|
+
|
23
|
+
namespace FormatterInternal {
|
24
|
+
|
25
|
+
using namespace arm::FormatterInternal;
|
26
|
+
|
27
|
+
Error ASMJIT_CDECL formatRegister(
|
28
|
+
String& sb,
|
29
|
+
FormatFlags flags,
|
30
|
+
const BaseEmitter* emitter,
|
31
|
+
Arch arch,
|
32
|
+
RegType regType,
|
33
|
+
uint32_t regId,
|
34
|
+
uint32_t elementType = 0,
|
35
|
+
uint32_t elementIndex = 0xFFFFFFFFu) noexcept;
|
36
|
+
|
37
|
+
Error ASMJIT_CDECL formatOperand(
|
38
|
+
String& sb,
|
39
|
+
FormatFlags flags,
|
40
|
+
const BaseEmitter* emitter,
|
41
|
+
Arch arch,
|
42
|
+
const Operand_& op) noexcept;
|
43
|
+
|
44
|
+
Error ASMJIT_CDECL formatInstruction(
|
45
|
+
String& sb,
|
46
|
+
FormatFlags flags,
|
47
|
+
const BaseEmitter* emitter,
|
48
|
+
Arch arch,
|
49
|
+
const BaseInst& inst, const Operand_* operands, size_t opCount) noexcept;
|
50
|
+
|
51
|
+
} // {FormatterInternal}
|
52
|
+
|
53
|
+
//! \}
|
54
|
+
//! \endcond
|
55
|
+
|
56
|
+
ASMJIT_END_SUB_NAMESPACE
|
57
|
+
|
58
|
+
#endif // !ASMJIT_NO_LOGGING
|
59
|
+
#endif // ASMJIT_ARM_A64FORMATTER_P_H_INCLUDED
|
@@ -0,0 +1,189 @@
|
|
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
|
+
#include "../core/api-build_p.h"
|
7
|
+
#if !defined(ASMJIT_NO_AARCH64)
|
8
|
+
|
9
|
+
#include "../arm/a64func_p.h"
|
10
|
+
#include "../arm/a64operand.h"
|
11
|
+
|
12
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
|
13
|
+
|
14
|
+
namespace FuncInternal {
|
15
|
+
|
16
|
+
static inline bool shouldThreatAsCDecl(CallConvId ccId) noexcept {
|
17
|
+
return ccId == CallConvId::kCDecl ||
|
18
|
+
ccId == CallConvId::kStdCall ||
|
19
|
+
ccId == CallConvId::kFastCall ||
|
20
|
+
ccId == CallConvId::kVectorCall ||
|
21
|
+
ccId == CallConvId::kThisCall ||
|
22
|
+
ccId == CallConvId::kRegParm1 ||
|
23
|
+
ccId == CallConvId::kRegParm2 ||
|
24
|
+
ccId == CallConvId::kRegParm3;
|
25
|
+
}
|
26
|
+
|
27
|
+
static RegType regTypeFromFpOrVecTypeId(TypeId typeId) noexcept {
|
28
|
+
if (typeId == TypeId::kFloat32)
|
29
|
+
return RegType::kARM_VecS;
|
30
|
+
else if (typeId == TypeId::kFloat64)
|
31
|
+
return RegType::kARM_VecD;
|
32
|
+
else if (TypeUtils::isVec32(typeId))
|
33
|
+
return RegType::kARM_VecS;
|
34
|
+
else if (TypeUtils::isVec64(typeId))
|
35
|
+
return RegType::kARM_VecD;
|
36
|
+
else if (TypeUtils::isVec128(typeId))
|
37
|
+
return RegType::kARM_VecV;
|
38
|
+
else
|
39
|
+
return RegType::kNone;
|
40
|
+
}
|
41
|
+
|
42
|
+
ASMJIT_FAVOR_SIZE Error initCallConv(CallConv& cc, CallConvId ccId, const Environment& environment) noexcept {
|
43
|
+
cc.setArch(environment.arch());
|
44
|
+
|
45
|
+
cc.setSaveRestoreRegSize(RegGroup::kGp, 8);
|
46
|
+
cc.setSaveRestoreRegSize(RegGroup::kVec, 8);
|
47
|
+
cc.setSaveRestoreAlignment(RegGroup::kGp, 16);
|
48
|
+
cc.setSaveRestoreAlignment(RegGroup::kVec, 16);
|
49
|
+
cc.setSaveRestoreAlignment(RegGroup::kExtraVirt2, 1);
|
50
|
+
cc.setSaveRestoreAlignment(RegGroup::kExtraVirt3, 1);
|
51
|
+
cc.setPassedOrder(RegGroup::kGp, 0, 1, 2, 3, 4, 5, 6, 7);
|
52
|
+
cc.setPassedOrder(RegGroup::kVec, 0, 1, 2, 3, 4, 5, 6, 7);
|
53
|
+
cc.setNaturalStackAlignment(16);
|
54
|
+
|
55
|
+
if (shouldThreatAsCDecl(ccId)) {
|
56
|
+
// ARM doesn't have that many calling conventions as we can find in X86 world, treat most conventions as __cdecl.
|
57
|
+
cc.setId(CallConvId::kCDecl);
|
58
|
+
cc.setPreservedRegs(RegGroup::kGp, Support::bitMask(Gp::kIdOs, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30));
|
59
|
+
cc.setPreservedRegs(RegGroup::kVec, Support::bitMask(8, 9, 10, 11, 12, 13, 14, 15));
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
cc.setId(ccId);
|
63
|
+
cc.setSaveRestoreRegSize(RegGroup::kVec, 16);
|
64
|
+
cc.setPreservedRegs(RegGroup::kGp, Support::bitMask(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));
|
65
|
+
cc.setPreservedRegs(RegGroup::kVec, Support::bitMask(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));
|
66
|
+
}
|
67
|
+
|
68
|
+
return kErrorOk;
|
69
|
+
}
|
70
|
+
|
71
|
+
ASMJIT_FAVOR_SIZE Error initFuncDetail(FuncDetail& func, const FuncSignature& signature, uint32_t registerSize) noexcept {
|
72
|
+
DebugUtils::unused(signature);
|
73
|
+
|
74
|
+
const CallConv& cc = func.callConv();
|
75
|
+
uint32_t stackOffset = 0;
|
76
|
+
|
77
|
+
uint32_t i;
|
78
|
+
uint32_t argCount = func.argCount();
|
79
|
+
|
80
|
+
if (func.hasRet()) {
|
81
|
+
for (uint32_t valueIndex = 0; valueIndex < Globals::kMaxValuePack; valueIndex++) {
|
82
|
+
TypeId typeId = func._rets[valueIndex].typeId();
|
83
|
+
|
84
|
+
// Terminate at the first void type (end of the pack).
|
85
|
+
if (typeId == TypeId::kVoid)
|
86
|
+
break;
|
87
|
+
|
88
|
+
switch (typeId) {
|
89
|
+
case TypeId::kInt8:
|
90
|
+
case TypeId::kInt16:
|
91
|
+
case TypeId::kInt32: {
|
92
|
+
func._rets[valueIndex].initReg(RegType::kARM_GpW, valueIndex, TypeId::kInt32);
|
93
|
+
break;
|
94
|
+
}
|
95
|
+
|
96
|
+
case TypeId::kUInt8:
|
97
|
+
case TypeId::kUInt16:
|
98
|
+
case TypeId::kUInt32: {
|
99
|
+
func._rets[valueIndex].initReg(RegType::kARM_GpW, valueIndex, TypeId::kUInt32);
|
100
|
+
break;
|
101
|
+
}
|
102
|
+
|
103
|
+
case TypeId::kInt64:
|
104
|
+
case TypeId::kUInt64: {
|
105
|
+
func._rets[valueIndex].initReg(RegType::kARM_GpX, valueIndex, typeId);
|
106
|
+
break;
|
107
|
+
}
|
108
|
+
|
109
|
+
default: {
|
110
|
+
RegType regType = regTypeFromFpOrVecTypeId(typeId);
|
111
|
+
if (regType == RegType::kNone)
|
112
|
+
return DebugUtils::errored(kErrorInvalidRegType);
|
113
|
+
|
114
|
+
func._rets[valueIndex].initReg(regType, valueIndex, typeId);
|
115
|
+
break;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
switch (cc.strategy()) {
|
122
|
+
case CallConvStrategy::kDefault: {
|
123
|
+
uint32_t gpzPos = 0;
|
124
|
+
uint32_t vecPos = 0;
|
125
|
+
|
126
|
+
for (i = 0; i < argCount; i++) {
|
127
|
+
FuncValue& arg = func._args[i][0];
|
128
|
+
TypeId typeId = arg.typeId();
|
129
|
+
|
130
|
+
if (TypeUtils::isInt(typeId)) {
|
131
|
+
uint32_t regId = BaseReg::kIdBad;
|
132
|
+
|
133
|
+
if (gpzPos < CallConv::kMaxRegArgsPerGroup)
|
134
|
+
regId = cc._passedOrder[RegGroup::kGp].id[gpzPos];
|
135
|
+
|
136
|
+
if (regId != BaseReg::kIdBad) {
|
137
|
+
RegType regType = typeId <= TypeId::kUInt32 ? RegType::kARM_GpW : RegType::kARM_GpX;
|
138
|
+
arg.assignRegData(regType, regId);
|
139
|
+
func.addUsedRegs(RegGroup::kGp, Support::bitMask(regId));
|
140
|
+
gpzPos++;
|
141
|
+
}
|
142
|
+
else {
|
143
|
+
uint32_t size = Support::max<uint32_t>(TypeUtils::sizeOf(typeId), registerSize);
|
144
|
+
arg.assignStackOffset(int32_t(stackOffset));
|
145
|
+
stackOffset += size;
|
146
|
+
}
|
147
|
+
continue;
|
148
|
+
}
|
149
|
+
|
150
|
+
if (TypeUtils::isFloat(typeId) || TypeUtils::isVec(typeId)) {
|
151
|
+
uint32_t regId = BaseReg::kIdBad;
|
152
|
+
|
153
|
+
if (vecPos < CallConv::kMaxRegArgsPerGroup)
|
154
|
+
regId = cc._passedOrder[RegGroup::kVec].id[vecPos];
|
155
|
+
|
156
|
+
if (regId != BaseReg::kIdBad) {
|
157
|
+
RegType regType = regTypeFromFpOrVecTypeId(typeId);
|
158
|
+
if (regType == RegType::kNone)
|
159
|
+
return DebugUtils::errored(kErrorInvalidRegType);
|
160
|
+
|
161
|
+
arg.initTypeId(typeId);
|
162
|
+
arg.assignRegData(regType, regId);
|
163
|
+
func.addUsedRegs(RegGroup::kVec, Support::bitMask(regId));
|
164
|
+
vecPos++;
|
165
|
+
}
|
166
|
+
else {
|
167
|
+
uint32_t size = TypeUtils::sizeOf(typeId);
|
168
|
+
arg.assignStackOffset(int32_t(stackOffset));
|
169
|
+
stackOffset += size;
|
170
|
+
}
|
171
|
+
continue;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
break;
|
175
|
+
}
|
176
|
+
|
177
|
+
default:
|
178
|
+
return DebugUtils::errored(kErrorInvalidState);
|
179
|
+
}
|
180
|
+
|
181
|
+
func._argStackSize = stackOffset;
|
182
|
+
return kErrorOk;
|
183
|
+
}
|
184
|
+
|
185
|
+
} // {FuncInternal}
|
186
|
+
|
187
|
+
ASMJIT_END_SUB_NAMESPACE
|
188
|
+
|
189
|
+
#endif // !ASMJIT_NO_AARCH64
|
@@ -0,0 +1,33 @@
|
|
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_ARM_A64FUNC_P_H_INCLUDED
|
7
|
+
#define ASMJIT_ARM_A64FUNC_P_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/func.h"
|
10
|
+
|
11
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
|
12
|
+
|
13
|
+
//! \cond INTERNAL
|
14
|
+
//! \addtogroup asmjit_a64
|
15
|
+
//! \{
|
16
|
+
|
17
|
+
//! AArch64-specific function API (calling conventions and other utilities).
|
18
|
+
namespace FuncInternal {
|
19
|
+
|
20
|
+
//! Initialize `CallConv` structure (AArch64 specific).
|
21
|
+
Error initCallConv(CallConv& cc, CallConvId ccId, const Environment& environment) noexcept;
|
22
|
+
|
23
|
+
//! Initialize `FuncDetail` (AArch64 specific).
|
24
|
+
Error initFuncDetail(FuncDetail& func, const FuncSignature& signature, uint32_t registerSize) noexcept;
|
25
|
+
|
26
|
+
} // {FuncInternal}
|
27
|
+
|
28
|
+
//! \}
|
29
|
+
//! \endcond
|
30
|
+
|
31
|
+
ASMJIT_END_SUB_NAMESPACE
|
32
|
+
|
33
|
+
#endif // ASMJIT_ARM_A64FUNC_P_H_INCLUDED
|