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,72 @@
|
|
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_A64ASSEMBLER_H_INCLUDED
|
7
|
+
#define ASMJIT_ARM_A64ASSEMBLER_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/assembler.h"
|
10
|
+
#include "../arm/a64emitter.h"
|
11
|
+
#include "../arm/a64operand.h"
|
12
|
+
|
13
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
|
14
|
+
|
15
|
+
//! \addtogroup asmjit_a64
|
16
|
+
//! \{
|
17
|
+
|
18
|
+
//! AArch64 assembler implementation.
|
19
|
+
class ASMJIT_VIRTAPI Assembler
|
20
|
+
: public BaseAssembler,
|
21
|
+
public EmitterExplicitT<Assembler> {
|
22
|
+
|
23
|
+
public:
|
24
|
+
typedef BaseAssembler Base;
|
25
|
+
|
26
|
+
//! \name Construction / Destruction
|
27
|
+
//! \{
|
28
|
+
|
29
|
+
ASMJIT_API Assembler(CodeHolder* code = nullptr) noexcept;
|
30
|
+
ASMJIT_API virtual ~Assembler() noexcept;
|
31
|
+
|
32
|
+
//! \}
|
33
|
+
|
34
|
+
//! \name Accessors
|
35
|
+
//! \{
|
36
|
+
|
37
|
+
//! Gets whether the current ARM mode is THUMB (alternative to 32-bit ARM encoding).
|
38
|
+
inline bool isInThumbMode() const noexcept { return _environment.isArchThumb(); }
|
39
|
+
|
40
|
+
//! Gets the current code alignment of the current mode (ARM vs THUMB).
|
41
|
+
inline uint32_t codeAlignment() const noexcept { return isInThumbMode() ? 2 : 4; }
|
42
|
+
|
43
|
+
//! \}
|
44
|
+
|
45
|
+
//! \name Emit
|
46
|
+
//! \{
|
47
|
+
|
48
|
+
ASMJIT_API Error _emit(InstId instId, const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_* opExt) override;
|
49
|
+
|
50
|
+
//! \}
|
51
|
+
|
52
|
+
//! \name Align
|
53
|
+
//! \{
|
54
|
+
|
55
|
+
ASMJIT_API Error align(AlignMode alignMode, uint32_t alignment) override;
|
56
|
+
|
57
|
+
//! \}
|
58
|
+
|
59
|
+
//! \name Events
|
60
|
+
//! \{
|
61
|
+
|
62
|
+
ASMJIT_API Error onAttach(CodeHolder* code) noexcept override;
|
63
|
+
ASMJIT_API Error onDetach(CodeHolder* code) noexcept override;
|
64
|
+
|
65
|
+
//! \}
|
66
|
+
};
|
67
|
+
|
68
|
+
//! \}
|
69
|
+
|
70
|
+
ASMJIT_END_SUB_NAMESPACE
|
71
|
+
|
72
|
+
#endif // ASMJIT_ARM_A64ASSEMBLER_H_INCLUDED
|
@@ -0,0 +1,51 @@
|
|
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) && !defined(ASMJIT_NO_BUILDER)
|
8
|
+
|
9
|
+
#include "../arm/a64assembler.h"
|
10
|
+
#include "../arm/a64builder.h"
|
11
|
+
#include "../arm/a64emithelper_p.h"
|
12
|
+
|
13
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
|
14
|
+
|
15
|
+
// a64::Builder - Construction & Destruction
|
16
|
+
// =========================================
|
17
|
+
|
18
|
+
Builder::Builder(CodeHolder* code) noexcept : BaseBuilder() {
|
19
|
+
_archMask = uint64_t(1) << uint32_t(Arch::kAArch64);
|
20
|
+
assignEmitterFuncs(this);
|
21
|
+
|
22
|
+
if (code)
|
23
|
+
code->attach(this);
|
24
|
+
}
|
25
|
+
Builder::~Builder() noexcept {}
|
26
|
+
|
27
|
+
// a64::Builder - Events
|
28
|
+
// =====================
|
29
|
+
|
30
|
+
Error Builder::onAttach(CodeHolder* code) noexcept {
|
31
|
+
return Base::onAttach(code);
|
32
|
+
}
|
33
|
+
|
34
|
+
Error Builder::onDetach(CodeHolder* code) noexcept {
|
35
|
+
return Base::onDetach(code);
|
36
|
+
}
|
37
|
+
|
38
|
+
// a64::Builder - Finalize
|
39
|
+
// =======================
|
40
|
+
|
41
|
+
Error Builder::finalize() {
|
42
|
+
ASMJIT_PROPAGATE(runPasses());
|
43
|
+
Assembler a(_code);
|
44
|
+
a.addEncodingOptions(encodingOptions());
|
45
|
+
a.addDiagnosticOptions(diagnosticOptions());
|
46
|
+
return serializeTo(&a);
|
47
|
+
}
|
48
|
+
|
49
|
+
ASMJIT_END_SUB_NAMESPACE
|
50
|
+
|
51
|
+
#endif // !ASMJIT_NO_AARCH64 && !ASMJIT_NO_BUILDER
|
@@ -0,0 +1,57 @@
|
|
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_A64BUILDER_H_INCLUDED
|
7
|
+
#define ASMJIT_ARM_A64BUILDER_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/api-config.h"
|
10
|
+
#ifndef ASMJIT_NO_BUILDER
|
11
|
+
|
12
|
+
#include "../core/builder.h"
|
13
|
+
#include "../arm/a64emitter.h"
|
14
|
+
|
15
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
|
16
|
+
|
17
|
+
//! \addtogroup asmjit_a64
|
18
|
+
//! \{
|
19
|
+
|
20
|
+
//! AArch64 builder implementation.
|
21
|
+
class ASMJIT_VIRTAPI Builder
|
22
|
+
: public BaseBuilder,
|
23
|
+
public EmitterExplicitT<Builder> {
|
24
|
+
public:
|
25
|
+
ASMJIT_NONCOPYABLE(Builder)
|
26
|
+
typedef BaseBuilder Base;
|
27
|
+
|
28
|
+
//! \name Construction & Destruction
|
29
|
+
//! \{
|
30
|
+
|
31
|
+
ASMJIT_API explicit Builder(CodeHolder* code = nullptr) noexcept;
|
32
|
+
ASMJIT_API virtual ~Builder() noexcept;
|
33
|
+
|
34
|
+
//! \}
|
35
|
+
|
36
|
+
//! \name Events
|
37
|
+
//! \{
|
38
|
+
|
39
|
+
ASMJIT_API Error onAttach(CodeHolder* code) noexcept override;
|
40
|
+
ASMJIT_API Error onDetach(CodeHolder* code) noexcept override;
|
41
|
+
|
42
|
+
//! \}
|
43
|
+
|
44
|
+
//! \name Finalize
|
45
|
+
//! \{
|
46
|
+
|
47
|
+
ASMJIT_API Error finalize() override;
|
48
|
+
|
49
|
+
//! \}
|
50
|
+
};
|
51
|
+
|
52
|
+
//! \}
|
53
|
+
|
54
|
+
ASMJIT_END_SUB_NAMESPACE
|
55
|
+
|
56
|
+
#endif // !ASMJIT_NO_BUILDER
|
57
|
+
#endif // ASMJIT_ARM_A64BUILDER_H_INCLUDED
|
@@ -0,0 +1,60 @@
|
|
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) && !defined(ASMJIT_NO_COMPILER)
|
8
|
+
|
9
|
+
#include "../arm/a64assembler.h"
|
10
|
+
#include "../arm/a64compiler.h"
|
11
|
+
#include "../arm/a64emithelper_p.h"
|
12
|
+
#include "../arm/a64rapass_p.h"
|
13
|
+
|
14
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
|
15
|
+
|
16
|
+
// a64::Compiler - Construction & Destruction
|
17
|
+
// ==========================================
|
18
|
+
|
19
|
+
Compiler::Compiler(CodeHolder* code) noexcept : BaseCompiler() {
|
20
|
+
_archMask = uint64_t(1) << uint32_t(Arch::kAArch64);
|
21
|
+
assignEmitterFuncs(this);
|
22
|
+
|
23
|
+
if (code)
|
24
|
+
code->attach(this);
|
25
|
+
}
|
26
|
+
Compiler::~Compiler() noexcept {}
|
27
|
+
|
28
|
+
// a64::Compiler - Events
|
29
|
+
// ======================
|
30
|
+
|
31
|
+
Error Compiler::onAttach(CodeHolder* code) noexcept {
|
32
|
+
ASMJIT_PROPAGATE(Base::onAttach(code));
|
33
|
+
Error err = addPassT<ARMRAPass>();
|
34
|
+
|
35
|
+
if (ASMJIT_UNLIKELY(err)) {
|
36
|
+
onDetach(code);
|
37
|
+
return err;
|
38
|
+
}
|
39
|
+
|
40
|
+
return kErrorOk;
|
41
|
+
}
|
42
|
+
|
43
|
+
Error Compiler::onDetach(CodeHolder* code) noexcept {
|
44
|
+
return Base::onDetach(code);
|
45
|
+
}
|
46
|
+
|
47
|
+
// a64::Compiler - Finalize
|
48
|
+
// ========================
|
49
|
+
|
50
|
+
Error Compiler::finalize() {
|
51
|
+
ASMJIT_PROPAGATE(runPasses());
|
52
|
+
Assembler a(_code);
|
53
|
+
a.addEncodingOptions(encodingOptions());
|
54
|
+
a.addDiagnosticOptions(diagnosticOptions());
|
55
|
+
return serializeTo(&a);
|
56
|
+
}
|
57
|
+
|
58
|
+
ASMJIT_END_SUB_NAMESPACE
|
59
|
+
|
60
|
+
#endif // !ASMJIT_NO_AARCH64 && !ASMJIT_NO_COMPILER
|
@@ -0,0 +1,247 @@
|
|
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_ARMCOMPILER_H_INCLUDED
|
7
|
+
#define ASMJIT_ARM_ARMCOMPILER_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/api-config.h"
|
10
|
+
#ifndef ASMJIT_NO_COMPILER
|
11
|
+
|
12
|
+
#include "../core/compiler.h"
|
13
|
+
#include "../core/type.h"
|
14
|
+
#include "../arm/a64emitter.h"
|
15
|
+
|
16
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(a64)
|
17
|
+
|
18
|
+
//! \addtogroup asmjit_a64
|
19
|
+
//! \{
|
20
|
+
|
21
|
+
//! AArch64 compiler implementation.
|
22
|
+
class ASMJIT_VIRTAPI Compiler
|
23
|
+
: public BaseCompiler,
|
24
|
+
public EmitterExplicitT<Compiler> {
|
25
|
+
public:
|
26
|
+
ASMJIT_NONCOPYABLE(Compiler)
|
27
|
+
typedef BaseCompiler Base;
|
28
|
+
|
29
|
+
//! \name Construction & Destruction
|
30
|
+
//! \{
|
31
|
+
|
32
|
+
ASMJIT_API explicit Compiler(CodeHolder* code = nullptr) noexcept;
|
33
|
+
ASMJIT_API virtual ~Compiler() noexcept;
|
34
|
+
|
35
|
+
//! \}
|
36
|
+
|
37
|
+
//! \name Virtual Registers
|
38
|
+
//! \{
|
39
|
+
|
40
|
+
//! \cond INTERNAL
|
41
|
+
template<typename RegT, typename Type>
|
42
|
+
inline RegT _newRegInternal(const Type& type) {
|
43
|
+
RegT reg(Globals::NoInit);
|
44
|
+
_newReg(®, type, nullptr);
|
45
|
+
return reg;
|
46
|
+
}
|
47
|
+
|
48
|
+
template<typename RegT, typename Type, typename... Args>
|
49
|
+
inline RegT _newRegInternal(const Type& type, const char* s, Args&&... args) {
|
50
|
+
#ifndef ASMJIT_NO_LOGGING
|
51
|
+
RegT reg(Globals::NoInit);
|
52
|
+
if (sizeof...(Args) == 0)
|
53
|
+
_newReg(®, type, s);
|
54
|
+
else
|
55
|
+
_newRegFmt(®, type, s, std::forward<Args>(args)...);
|
56
|
+
return reg;
|
57
|
+
#else
|
58
|
+
DebugUtils::unused(std::forward<Args>(args)...);
|
59
|
+
RegT reg(Globals::NoInit);
|
60
|
+
_newReg(®, type, nullptr);
|
61
|
+
return reg;
|
62
|
+
#endif
|
63
|
+
}
|
64
|
+
//! \endcond
|
65
|
+
|
66
|
+
template<typename RegT, typename... Args>
|
67
|
+
inline RegT newSimilarReg(const RegT& ref, Args&&... args) {
|
68
|
+
return _newRegInternal<RegT>(ref, std::forward<Args>(args)...);
|
69
|
+
}
|
70
|
+
|
71
|
+
template<typename... Args>
|
72
|
+
inline Reg newReg(TypeId typeId, Args&&... args) { return _newRegInternal<Reg>(typeId, std::forward<Args>(args)...); }
|
73
|
+
|
74
|
+
template<typename... Args>
|
75
|
+
inline Gp newGp(TypeId typeId, Args&&... args) { return _newRegInternal<Gp>(typeId, std::forward<Args>(args)...); }
|
76
|
+
|
77
|
+
template<typename... Args>
|
78
|
+
inline Vec newVec(TypeId typeId, Args&&... args) { return _newRegInternal<Vec>(typeId, std::forward<Args>(args)...); }
|
79
|
+
|
80
|
+
template<typename... Args>
|
81
|
+
inline Gp newInt32(Args&&... args) { return _newRegInternal<Gp>(TypeId::kInt32, std::forward<Args>(args)...); }
|
82
|
+
template<typename... Args>
|
83
|
+
inline Gp newUInt32(Args&&... args) { return _newRegInternal<Gp>(TypeId::kUInt32, std::forward<Args>(args)...); }
|
84
|
+
|
85
|
+
template<typename... Args>
|
86
|
+
inline Gp newInt64(Args&&... args) { return _newRegInternal<Gp>(TypeId::kInt64, std::forward<Args>(args)...); }
|
87
|
+
template<typename... Args>
|
88
|
+
inline Gp newUInt64(Args&&... args) { return _newRegInternal<Gp>(TypeId::kUInt64, std::forward<Args>(args)...); }
|
89
|
+
|
90
|
+
template<typename... Args>
|
91
|
+
inline Gp newIntPtr(Args&&... args) { return _newRegInternal<Gp>(TypeId::kIntPtr, std::forward<Args>(args)...); }
|
92
|
+
template<typename... Args>
|
93
|
+
inline Gp newUIntPtr(Args&&... args) { return _newRegInternal<Gp>(TypeId::kUIntPtr, std::forward<Args>(args)...); }
|
94
|
+
|
95
|
+
template<typename... Args>
|
96
|
+
inline Gp newGpw(Args&&... args) { return _newRegInternal<Gp>(TypeId::kUInt32, std::forward<Args>(args)...); }
|
97
|
+
template<typename... Args>
|
98
|
+
inline Gp newGpx(Args&&... args) { return _newRegInternal<Gp>(TypeId::kUInt64, std::forward<Args>(args)...); }
|
99
|
+
template<typename... Args>
|
100
|
+
inline Gp newGpz(Args&&... args) { return _newRegInternal<Gp>(TypeId::kUIntPtr, std::forward<Args>(args)...); }
|
101
|
+
|
102
|
+
template<typename... Args>
|
103
|
+
inline Vec newVecS(Args&&... args) { return _newRegInternal<Vec>(TypeId::kFloat32, std::forward<Args>(args)...); }
|
104
|
+
|
105
|
+
template<typename... Args>
|
106
|
+
inline Vec newVecD(Args&&... args) { return _newRegInternal<Vec>(TypeId::kFloat64, std::forward<Args>(args)...); }
|
107
|
+
|
108
|
+
template<typename... Args>
|
109
|
+
inline Vec newVecQ(Args&&... args) { return _newRegInternal<Vec>(TypeId::kUInt8x16, std::forward<Args>(args)...); }
|
110
|
+
|
111
|
+
//! \}
|
112
|
+
|
113
|
+
//! \name Stack
|
114
|
+
//! \{
|
115
|
+
|
116
|
+
//! Creates a new memory chunk allocated on the current function's stack.
|
117
|
+
inline Mem newStack(uint32_t size, uint32_t alignment, const char* name = nullptr) {
|
118
|
+
Mem m(Globals::NoInit);
|
119
|
+
_newStack(&m, size, alignment, name);
|
120
|
+
return m;
|
121
|
+
}
|
122
|
+
|
123
|
+
//! \}
|
124
|
+
|
125
|
+
//! \name Constants
|
126
|
+
//! \{
|
127
|
+
|
128
|
+
//! Put data to a constant-pool and get a memory reference to it.
|
129
|
+
inline Mem newConst(ConstPoolScope scope, const void* data, size_t size) {
|
130
|
+
Mem m(Globals::NoInit);
|
131
|
+
_newConst(&m, scope, data, size);
|
132
|
+
return m;
|
133
|
+
}
|
134
|
+
|
135
|
+
//! Put a BYTE `val` to a constant-pool (8 bits).
|
136
|
+
inline Mem newByteConst(ConstPoolScope scope, uint8_t val) noexcept { return newConst(scope, &val, 1); }
|
137
|
+
//! Put a HWORD `val` to a constant-pool (16 bits).
|
138
|
+
inline Mem newHWordConst(ConstPoolScope scope, uint16_t val) noexcept { return newConst(scope, &val, 2); }
|
139
|
+
//! Put a WORD `val` to a constant-pool (32 bits).
|
140
|
+
inline Mem newWordConst(ConstPoolScope scope, uint32_t val) noexcept { return newConst(scope, &val, 4); }
|
141
|
+
//! Put a DWORD `val` to a constant-pool (64 bits).
|
142
|
+
inline Mem newDWordConst(ConstPoolScope scope, uint64_t val) noexcept { return newConst(scope, &val, 8); }
|
143
|
+
|
144
|
+
//! Put a WORD `val` to a constant-pool.
|
145
|
+
inline Mem newInt16Const(ConstPoolScope scope, int16_t val) noexcept { return newConst(scope, &val, 2); }
|
146
|
+
//! Put a WORD `val` to a constant-pool.
|
147
|
+
inline Mem newUInt16Const(ConstPoolScope scope, uint16_t val) noexcept { return newConst(scope, &val, 2); }
|
148
|
+
//! Put a DWORD `val` to a constant-pool.
|
149
|
+
inline Mem newInt32Const(ConstPoolScope scope, int32_t val) noexcept { return newConst(scope, &val, 4); }
|
150
|
+
//! Put a DWORD `val` to a constant-pool.
|
151
|
+
inline Mem newUInt32Const(ConstPoolScope scope, uint32_t val) noexcept { return newConst(scope, &val, 4); }
|
152
|
+
//! Put a QWORD `val` to a constant-pool.
|
153
|
+
inline Mem newInt64Const(ConstPoolScope scope, int64_t val) noexcept { return newConst(scope, &val, 8); }
|
154
|
+
//! Put a QWORD `val` to a constant-pool.
|
155
|
+
inline Mem newUInt64Const(ConstPoolScope scope, uint64_t val) noexcept { return newConst(scope, &val, 8); }
|
156
|
+
|
157
|
+
//! Put a SP-FP `val` to a constant-pool.
|
158
|
+
inline Mem newFloatConst(ConstPoolScope scope, float val) noexcept { return newConst(scope, &val, 4); }
|
159
|
+
//! Put a DP-FP `val` to a constant-pool.
|
160
|
+
inline Mem newDoubleConst(ConstPoolScope scope, double val) noexcept { return newConst(scope, &val, 8); }
|
161
|
+
|
162
|
+
//! \}
|
163
|
+
|
164
|
+
//! \name Instruction Options
|
165
|
+
//! \{
|
166
|
+
|
167
|
+
//! Force the compiler to not follow the conditional or unconditional jump.
|
168
|
+
inline Compiler& unfollow() noexcept { _instOptions |= InstOptions::kUnfollow; return *this; }
|
169
|
+
|
170
|
+
//! \}
|
171
|
+
|
172
|
+
//! \name Compiler specific
|
173
|
+
//! \{
|
174
|
+
|
175
|
+
//! Special pseudo-instruction that can be used to load a memory address into `o0` GP register.
|
176
|
+
//!
|
177
|
+
//! \note At the moment this instruction is only useful to load a stack allocated address into a GP register
|
178
|
+
//! for further use. It makes very little sense to use it for anything else. The semantics of this instruction
|
179
|
+
//! is the same as X86 `LEA` (load effective address) instruction.
|
180
|
+
inline Error loadAddressOf(const Gp& o0, const Mem& o1) { return _emitter()->_emitI(Inst::kIdAdr, o0, o1); }
|
181
|
+
|
182
|
+
//! \}
|
183
|
+
|
184
|
+
//! \name Function Call & Ret Intrinsics
|
185
|
+
//! \{
|
186
|
+
|
187
|
+
//! Invoke a function call without `target` type enforcement.
|
188
|
+
inline Error invoke_(InvokeNode** out, const Operand_& target, const FuncSignature& signature) {
|
189
|
+
return addInvokeNode(out, Inst::kIdBlr, target, signature);
|
190
|
+
}
|
191
|
+
|
192
|
+
//! Invoke a function call of the given `target` and `signature` and store the added node to `out`.
|
193
|
+
//!
|
194
|
+
//! Creates a new \ref InvokeNode, initializes all the necessary members to match the given function `signature`,
|
195
|
+
//! adds the node to the compiler, and stores its pointer to `out`. The operation is atomic, if anything fails
|
196
|
+
//! nullptr is stored in `out` and error code is returned.
|
197
|
+
inline Error invoke(InvokeNode** out, const Gp& target, const FuncSignature& signature) { return invoke_(out, target, signature); }
|
198
|
+
//! \overload
|
199
|
+
inline Error invoke(InvokeNode** out, const Mem& target, const FuncSignature& signature) { return invoke_(out, target, signature); }
|
200
|
+
//! \overload
|
201
|
+
inline Error invoke(InvokeNode** out, const Label& target, const FuncSignature& signature) { return invoke_(out, target, signature); }
|
202
|
+
//! \overload
|
203
|
+
inline Error invoke(InvokeNode** out, const Imm& target, const FuncSignature& signature) { return invoke_(out, target, signature); }
|
204
|
+
//! \overload
|
205
|
+
inline Error invoke(InvokeNode** out, uint64_t target, const FuncSignature& signature) { return invoke_(out, Imm(int64_t(target)), signature); }
|
206
|
+
|
207
|
+
//! Return.
|
208
|
+
inline Error ret() { return addRet(Operand(), Operand()); }
|
209
|
+
//! \overload
|
210
|
+
inline Error ret(const BaseReg& o0) { return addRet(o0, Operand()); }
|
211
|
+
//! \overload
|
212
|
+
inline Error ret(const BaseReg& o0, const BaseReg& o1) { return addRet(o0, o1); }
|
213
|
+
|
214
|
+
//! \}
|
215
|
+
|
216
|
+
//! \name Jump Tables Support
|
217
|
+
//! \{
|
218
|
+
|
219
|
+
using EmitterExplicitT<Compiler>::br;
|
220
|
+
|
221
|
+
//! Adds a jump to the given `target` with the provided jump `annotation`.
|
222
|
+
inline Error br(const BaseReg& target, JumpAnnotation* annotation) { return emitAnnotatedJump(Inst::kIdBr, target, annotation); }
|
223
|
+
|
224
|
+
//! \}
|
225
|
+
|
226
|
+
//! \name Events
|
227
|
+
//! \{
|
228
|
+
|
229
|
+
ASMJIT_API Error onAttach(CodeHolder* code) noexcept override;
|
230
|
+
ASMJIT_API Error onDetach(CodeHolder* code) noexcept override;
|
231
|
+
|
232
|
+
//! \}
|
233
|
+
|
234
|
+
//! \name Finalize
|
235
|
+
//! \{
|
236
|
+
|
237
|
+
ASMJIT_API Error finalize() override;
|
238
|
+
|
239
|
+
//! \}
|
240
|
+
};
|
241
|
+
|
242
|
+
//! \}
|
243
|
+
|
244
|
+
ASMJIT_END_SUB_NAMESPACE
|
245
|
+
|
246
|
+
#endif // !ASMJIT_NO_COMPILER
|
247
|
+
#endif // ASMJIT_ARM_ARMCOMPILER_H_INCLUDED
|