asmjit 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/asmjit.gemspec +1 -1
  4. data/ext/asmjit/asmjit/.editorconfig +10 -0
  5. data/ext/asmjit/asmjit/.github/FUNDING.yml +1 -0
  6. data/ext/asmjit/asmjit/.github/workflows/build-config.json +47 -0
  7. data/ext/asmjit/asmjit/.github/workflows/build.yml +156 -0
  8. data/ext/asmjit/asmjit/.gitignore +6 -0
  9. data/ext/asmjit/asmjit/CMakeLists.txt +611 -0
  10. data/ext/asmjit/asmjit/LICENSE.md +17 -0
  11. data/ext/asmjit/asmjit/README.md +69 -0
  12. data/ext/asmjit/asmjit/src/asmjit/a64.h +62 -0
  13. data/ext/asmjit/asmjit/src/asmjit/arm/a64archtraits_p.h +81 -0
  14. data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.cpp +5115 -0
  15. data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.h +72 -0
  16. data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.cpp +51 -0
  17. data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.h +57 -0
  18. data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.cpp +60 -0
  19. data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.h +247 -0
  20. data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper.cpp +464 -0
  21. data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper_p.h +50 -0
  22. data/ext/asmjit/asmjit/src/asmjit/arm/a64emitter.h +1228 -0
  23. data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter.cpp +298 -0
  24. data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter_p.h +59 -0
  25. data/ext/asmjit/asmjit/src/asmjit/arm/a64func.cpp +189 -0
  26. data/ext/asmjit/asmjit/src/asmjit/arm/a64func_p.h +33 -0
  27. data/ext/asmjit/asmjit/src/asmjit/arm/a64globals.h +1894 -0
  28. data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi.cpp +278 -0
  29. data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi_p.h +41 -0
  30. data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.cpp +1957 -0
  31. data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.h +74 -0
  32. data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb_p.h +876 -0
  33. data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.cpp +85 -0
  34. data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.h +312 -0
  35. data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass.cpp +852 -0
  36. data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass_p.h +105 -0
  37. data/ext/asmjit/asmjit/src/asmjit/arm/a64utils.h +179 -0
  38. data/ext/asmjit/asmjit/src/asmjit/arm/armformatter.cpp +143 -0
  39. data/ext/asmjit/asmjit/src/asmjit/arm/armformatter_p.h +44 -0
  40. data/ext/asmjit/asmjit/src/asmjit/arm/armglobals.h +21 -0
  41. data/ext/asmjit/asmjit/src/asmjit/arm/armoperand.h +621 -0
  42. data/ext/asmjit/asmjit/src/asmjit/arm.h +62 -0
  43. data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-begin.h +17 -0
  44. data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-end.h +9 -0
  45. data/ext/asmjit/asmjit/src/asmjit/asmjit.h +33 -0
  46. data/ext/asmjit/asmjit/src/asmjit/core/api-build_p.h +55 -0
  47. data/ext/asmjit/asmjit/src/asmjit/core/api-config.h +613 -0
  48. data/ext/asmjit/asmjit/src/asmjit/core/archcommons.h +229 -0
  49. data/ext/asmjit/asmjit/src/asmjit/core/archtraits.cpp +160 -0
  50. data/ext/asmjit/asmjit/src/asmjit/core/archtraits.h +290 -0
  51. data/ext/asmjit/asmjit/src/asmjit/core/assembler.cpp +406 -0
  52. data/ext/asmjit/asmjit/src/asmjit/core/assembler.h +129 -0
  53. data/ext/asmjit/asmjit/src/asmjit/core/builder.cpp +889 -0
  54. data/ext/asmjit/asmjit/src/asmjit/core/builder.h +1391 -0
  55. data/ext/asmjit/asmjit/src/asmjit/core/codebuffer.h +113 -0
  56. data/ext/asmjit/asmjit/src/asmjit/core/codeholder.cpp +1149 -0
  57. data/ext/asmjit/asmjit/src/asmjit/core/codeholder.h +1035 -0
  58. data/ext/asmjit/asmjit/src/asmjit/core/codewriter.cpp +175 -0
  59. data/ext/asmjit/asmjit/src/asmjit/core/codewriter_p.h +179 -0
  60. data/ext/asmjit/asmjit/src/asmjit/core/compiler.cpp +582 -0
  61. data/ext/asmjit/asmjit/src/asmjit/core/compiler.h +737 -0
  62. data/ext/asmjit/asmjit/src/asmjit/core/compilerdefs.h +173 -0
  63. data/ext/asmjit/asmjit/src/asmjit/core/constpool.cpp +363 -0
  64. data/ext/asmjit/asmjit/src/asmjit/core/constpool.h +250 -0
  65. data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.cpp +1162 -0
  66. data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.h +813 -0
  67. data/ext/asmjit/asmjit/src/asmjit/core/emithelper.cpp +323 -0
  68. data/ext/asmjit/asmjit/src/asmjit/core/emithelper_p.h +58 -0
  69. data/ext/asmjit/asmjit/src/asmjit/core/emitter.cpp +333 -0
  70. data/ext/asmjit/asmjit/src/asmjit/core/emitter.h +741 -0
  71. data/ext/asmjit/asmjit/src/asmjit/core/emitterutils.cpp +129 -0
  72. data/ext/asmjit/asmjit/src/asmjit/core/emitterutils_p.h +89 -0
  73. data/ext/asmjit/asmjit/src/asmjit/core/environment.cpp +46 -0
  74. data/ext/asmjit/asmjit/src/asmjit/core/environment.h +508 -0
  75. data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.cpp +14 -0
  76. data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.h +228 -0
  77. data/ext/asmjit/asmjit/src/asmjit/core/formatter.cpp +584 -0
  78. data/ext/asmjit/asmjit/src/asmjit/core/formatter.h +247 -0
  79. data/ext/asmjit/asmjit/src/asmjit/core/formatter_p.h +34 -0
  80. data/ext/asmjit/asmjit/src/asmjit/core/func.cpp +286 -0
  81. data/ext/asmjit/asmjit/src/asmjit/core/func.h +1445 -0
  82. data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext.cpp +293 -0
  83. data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext_p.h +199 -0
  84. data/ext/asmjit/asmjit/src/asmjit/core/globals.cpp +133 -0
  85. data/ext/asmjit/asmjit/src/asmjit/core/globals.h +393 -0
  86. data/ext/asmjit/asmjit/src/asmjit/core/inst.cpp +113 -0
  87. data/ext/asmjit/asmjit/src/asmjit/core/inst.h +772 -0
  88. data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.cpp +1242 -0
  89. data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.h +261 -0
  90. data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.cpp +80 -0
  91. data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.h +89 -0
  92. data/ext/asmjit/asmjit/src/asmjit/core/logger.cpp +69 -0
  93. data/ext/asmjit/asmjit/src/asmjit/core/logger.h +198 -0
  94. data/ext/asmjit/asmjit/src/asmjit/core/misc_p.h +33 -0
  95. data/ext/asmjit/asmjit/src/asmjit/core/operand.cpp +132 -0
  96. data/ext/asmjit/asmjit/src/asmjit/core/operand.h +1611 -0
  97. data/ext/asmjit/asmjit/src/asmjit/core/osutils.cpp +84 -0
  98. data/ext/asmjit/asmjit/src/asmjit/core/osutils.h +61 -0
  99. data/ext/asmjit/asmjit/src/asmjit/core/osutils_p.h +68 -0
  100. data/ext/asmjit/asmjit/src/asmjit/core/raassignment_p.h +418 -0
  101. data/ext/asmjit/asmjit/src/asmjit/core/rabuilders_p.h +612 -0
  102. data/ext/asmjit/asmjit/src/asmjit/core/radefs_p.h +1204 -0
  103. data/ext/asmjit/asmjit/src/asmjit/core/ralocal.cpp +1166 -0
  104. data/ext/asmjit/asmjit/src/asmjit/core/ralocal_p.h +254 -0
  105. data/ext/asmjit/asmjit/src/asmjit/core/rapass.cpp +1969 -0
  106. data/ext/asmjit/asmjit/src/asmjit/core/rapass_p.h +1183 -0
  107. data/ext/asmjit/asmjit/src/asmjit/core/rastack.cpp +184 -0
  108. data/ext/asmjit/asmjit/src/asmjit/core/rastack_p.h +171 -0
  109. data/ext/asmjit/asmjit/src/asmjit/core/string.cpp +559 -0
  110. data/ext/asmjit/asmjit/src/asmjit/core/string.h +372 -0
  111. data/ext/asmjit/asmjit/src/asmjit/core/support.cpp +494 -0
  112. data/ext/asmjit/asmjit/src/asmjit/core/support.h +1773 -0
  113. data/ext/asmjit/asmjit/src/asmjit/core/target.cpp +14 -0
  114. data/ext/asmjit/asmjit/src/asmjit/core/target.h +53 -0
  115. data/ext/asmjit/asmjit/src/asmjit/core/type.cpp +74 -0
  116. data/ext/asmjit/asmjit/src/asmjit/core/type.h +419 -0
  117. data/ext/asmjit/asmjit/src/asmjit/core/virtmem.cpp +722 -0
  118. data/ext/asmjit/asmjit/src/asmjit/core/virtmem.h +242 -0
  119. data/ext/asmjit/asmjit/src/asmjit/core/zone.cpp +353 -0
  120. data/ext/asmjit/asmjit/src/asmjit/core/zone.h +615 -0
  121. data/ext/asmjit/asmjit/src/asmjit/core/zonehash.cpp +309 -0
  122. data/ext/asmjit/asmjit/src/asmjit/core/zonehash.h +186 -0
  123. data/ext/asmjit/asmjit/src/asmjit/core/zonelist.cpp +163 -0
  124. data/ext/asmjit/asmjit/src/asmjit/core/zonelist.h +209 -0
  125. data/ext/asmjit/asmjit/src/asmjit/core/zonestack.cpp +176 -0
  126. data/ext/asmjit/asmjit/src/asmjit/core/zonestack.h +239 -0
  127. data/ext/asmjit/asmjit/src/asmjit/core/zonestring.h +120 -0
  128. data/ext/asmjit/asmjit/src/asmjit/core/zonetree.cpp +99 -0
  129. data/ext/asmjit/asmjit/src/asmjit/core/zonetree.h +380 -0
  130. data/ext/asmjit/asmjit/src/asmjit/core/zonevector.cpp +356 -0
  131. data/ext/asmjit/asmjit/src/asmjit/core/zonevector.h +690 -0
  132. data/ext/asmjit/asmjit/src/asmjit/core.h +1861 -0
  133. data/ext/asmjit/asmjit/src/asmjit/x86/x86archtraits_p.h +148 -0
  134. data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.cpp +5110 -0
  135. data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.h +685 -0
  136. data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.cpp +52 -0
  137. data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.h +351 -0
  138. data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.cpp +61 -0
  139. data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.h +721 -0
  140. data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper.cpp +619 -0
  141. data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper_p.h +60 -0
  142. data/ext/asmjit/asmjit/src/asmjit/x86/x86emitter.h +4315 -0
  143. data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter.cpp +944 -0
  144. data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter_p.h +58 -0
  145. data/ext/asmjit/asmjit/src/asmjit/x86/x86func.cpp +503 -0
  146. data/ext/asmjit/asmjit/src/asmjit/x86/x86func_p.h +33 -0
  147. data/ext/asmjit/asmjit/src/asmjit/x86/x86globals.h +2169 -0
  148. data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi.cpp +1732 -0
  149. data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi_p.h +41 -0
  150. data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.cpp +4427 -0
  151. data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.h +563 -0
  152. data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb_p.h +311 -0
  153. data/ext/asmjit/asmjit/src/asmjit/x86/x86opcode_p.h +436 -0
  154. data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.cpp +231 -0
  155. data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.h +1085 -0
  156. data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass.cpp +1509 -0
  157. data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass_p.h +94 -0
  158. data/ext/asmjit/asmjit/src/asmjit/x86.h +93 -0
  159. data/ext/asmjit/asmjit/src/asmjit.natvis +245 -0
  160. data/ext/asmjit/asmjit/test/asmjit_test_assembler.cpp +84 -0
  161. data/ext/asmjit/asmjit/test/asmjit_test_assembler.h +85 -0
  162. data/ext/asmjit/asmjit/test/asmjit_test_assembler_a64.cpp +4006 -0
  163. data/ext/asmjit/asmjit/test/asmjit_test_assembler_x64.cpp +17833 -0
  164. data/ext/asmjit/asmjit/test/asmjit_test_assembler_x86.cpp +8300 -0
  165. data/ext/asmjit/asmjit/test/asmjit_test_compiler.cpp +253 -0
  166. data/ext/asmjit/asmjit/test/asmjit_test_compiler.h +73 -0
  167. data/ext/asmjit/asmjit/test/asmjit_test_compiler_a64.cpp +690 -0
  168. data/ext/asmjit/asmjit/test/asmjit_test_compiler_x86.cpp +4317 -0
  169. data/ext/asmjit/asmjit/test/asmjit_test_emitters.cpp +197 -0
  170. data/ext/asmjit/asmjit/test/asmjit_test_instinfo.cpp +181 -0
  171. data/ext/asmjit/asmjit/test/asmjit_test_misc.h +257 -0
  172. data/ext/asmjit/asmjit/test/asmjit_test_perf.cpp +62 -0
  173. data/ext/asmjit/asmjit/test/asmjit_test_perf.h +61 -0
  174. data/ext/asmjit/asmjit/test/asmjit_test_perf_a64.cpp +699 -0
  175. data/ext/asmjit/asmjit/test/asmjit_test_perf_x86.cpp +5032 -0
  176. data/ext/asmjit/asmjit/test/asmjit_test_unit.cpp +172 -0
  177. data/ext/asmjit/asmjit/test/asmjit_test_x86_sections.cpp +172 -0
  178. data/ext/asmjit/asmjit/test/asmjitutils.h +38 -0
  179. data/ext/asmjit/asmjit/test/broken.cpp +312 -0
  180. data/ext/asmjit/asmjit/test/broken.h +148 -0
  181. data/ext/asmjit/asmjit/test/cmdline.h +61 -0
  182. data/ext/asmjit/asmjit/test/performancetimer.h +41 -0
  183. data/ext/asmjit/asmjit/tools/configure-makefiles.sh +13 -0
  184. data/ext/asmjit/asmjit/tools/configure-ninja.sh +13 -0
  185. data/ext/asmjit/asmjit/tools/configure-sanitizers.sh +13 -0
  186. data/ext/asmjit/asmjit/tools/configure-vs2019-x64.bat +2 -0
  187. data/ext/asmjit/asmjit/tools/configure-vs2019-x86.bat +2 -0
  188. data/ext/asmjit/asmjit/tools/configure-vs2022-x64.bat +2 -0
  189. data/ext/asmjit/asmjit/tools/configure-vs2022-x86.bat +2 -0
  190. data/ext/asmjit/asmjit/tools/configure-xcode.sh +8 -0
  191. data/ext/asmjit/asmjit/tools/enumgen.js +417 -0
  192. data/ext/asmjit/asmjit/tools/enumgen.sh +3 -0
  193. data/ext/asmjit/asmjit/tools/tablegen-arm.js +365 -0
  194. data/ext/asmjit/asmjit/tools/tablegen-arm.sh +3 -0
  195. data/ext/asmjit/asmjit/tools/tablegen-x86.js +2638 -0
  196. data/ext/asmjit/asmjit/tools/tablegen-x86.sh +3 -0
  197. data/ext/asmjit/asmjit/tools/tablegen.js +947 -0
  198. data/ext/asmjit/asmjit/tools/tablegen.sh +4 -0
  199. data/ext/asmjit/asmjit.cc +18 -0
  200. data/lib/asmjit/version.rb +1 -1
  201. 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(&reg, 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(&reg, type, s);
54
+ else
55
+ _newRegFmt(&reg, 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(&reg, 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