asmjit 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/Rakefile +5 -3
  4. data/asmjit.gemspec +1 -3
  5. data/ext/asmjit/asmjit/.editorconfig +10 -0
  6. data/ext/asmjit/asmjit/.github/FUNDING.yml +1 -0
  7. data/ext/asmjit/asmjit/.github/workflows/build-config.json +47 -0
  8. data/ext/asmjit/asmjit/.github/workflows/build.yml +156 -0
  9. data/ext/asmjit/asmjit/.gitignore +6 -0
  10. data/ext/asmjit/asmjit/CMakeLists.txt +611 -0
  11. data/ext/asmjit/asmjit/LICENSE.md +17 -0
  12. data/ext/asmjit/asmjit/README.md +69 -0
  13. data/ext/asmjit/asmjit/src/asmjit/a64.h +62 -0
  14. data/ext/asmjit/asmjit/src/asmjit/arm/a64archtraits_p.h +81 -0
  15. data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.cpp +5115 -0
  16. data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.h +72 -0
  17. data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.cpp +51 -0
  18. data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.h +57 -0
  19. data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.cpp +60 -0
  20. data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.h +247 -0
  21. data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper.cpp +464 -0
  22. data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper_p.h +50 -0
  23. data/ext/asmjit/asmjit/src/asmjit/arm/a64emitter.h +1228 -0
  24. data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter.cpp +298 -0
  25. data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter_p.h +59 -0
  26. data/ext/asmjit/asmjit/src/asmjit/arm/a64func.cpp +189 -0
  27. data/ext/asmjit/asmjit/src/asmjit/arm/a64func_p.h +33 -0
  28. data/ext/asmjit/asmjit/src/asmjit/arm/a64globals.h +1894 -0
  29. data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi.cpp +278 -0
  30. data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi_p.h +41 -0
  31. data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.cpp +1957 -0
  32. data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.h +74 -0
  33. data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb_p.h +876 -0
  34. data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.cpp +85 -0
  35. data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.h +312 -0
  36. data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass.cpp +852 -0
  37. data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass_p.h +105 -0
  38. data/ext/asmjit/asmjit/src/asmjit/arm/a64utils.h +179 -0
  39. data/ext/asmjit/asmjit/src/asmjit/arm/armformatter.cpp +143 -0
  40. data/ext/asmjit/asmjit/src/asmjit/arm/armformatter_p.h +44 -0
  41. data/ext/asmjit/asmjit/src/asmjit/arm/armglobals.h +21 -0
  42. data/ext/asmjit/asmjit/src/asmjit/arm/armoperand.h +621 -0
  43. data/ext/asmjit/asmjit/src/asmjit/arm.h +62 -0
  44. data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-begin.h +17 -0
  45. data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-end.h +9 -0
  46. data/ext/asmjit/asmjit/src/asmjit/asmjit.h +33 -0
  47. data/ext/asmjit/asmjit/src/asmjit/core/api-build_p.h +55 -0
  48. data/ext/asmjit/asmjit/src/asmjit/core/api-config.h +613 -0
  49. data/ext/asmjit/asmjit/src/asmjit/core/archcommons.h +229 -0
  50. data/ext/asmjit/asmjit/src/asmjit/core/archtraits.cpp +160 -0
  51. data/ext/asmjit/asmjit/src/asmjit/core/archtraits.h +290 -0
  52. data/ext/asmjit/asmjit/src/asmjit/core/assembler.cpp +406 -0
  53. data/ext/asmjit/asmjit/src/asmjit/core/assembler.h +129 -0
  54. data/ext/asmjit/asmjit/src/asmjit/core/builder.cpp +889 -0
  55. data/ext/asmjit/asmjit/src/asmjit/core/builder.h +1391 -0
  56. data/ext/asmjit/asmjit/src/asmjit/core/codebuffer.h +113 -0
  57. data/ext/asmjit/asmjit/src/asmjit/core/codeholder.cpp +1149 -0
  58. data/ext/asmjit/asmjit/src/asmjit/core/codeholder.h +1035 -0
  59. data/ext/asmjit/asmjit/src/asmjit/core/codewriter.cpp +175 -0
  60. data/ext/asmjit/asmjit/src/asmjit/core/codewriter_p.h +179 -0
  61. data/ext/asmjit/asmjit/src/asmjit/core/compiler.cpp +582 -0
  62. data/ext/asmjit/asmjit/src/asmjit/core/compiler.h +737 -0
  63. data/ext/asmjit/asmjit/src/asmjit/core/compilerdefs.h +173 -0
  64. data/ext/asmjit/asmjit/src/asmjit/core/constpool.cpp +363 -0
  65. data/ext/asmjit/asmjit/src/asmjit/core/constpool.h +250 -0
  66. data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.cpp +1162 -0
  67. data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.h +813 -0
  68. data/ext/asmjit/asmjit/src/asmjit/core/emithelper.cpp +323 -0
  69. data/ext/asmjit/asmjit/src/asmjit/core/emithelper_p.h +58 -0
  70. data/ext/asmjit/asmjit/src/asmjit/core/emitter.cpp +333 -0
  71. data/ext/asmjit/asmjit/src/asmjit/core/emitter.h +741 -0
  72. data/ext/asmjit/asmjit/src/asmjit/core/emitterutils.cpp +129 -0
  73. data/ext/asmjit/asmjit/src/asmjit/core/emitterutils_p.h +89 -0
  74. data/ext/asmjit/asmjit/src/asmjit/core/environment.cpp +46 -0
  75. data/ext/asmjit/asmjit/src/asmjit/core/environment.h +508 -0
  76. data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.cpp +14 -0
  77. data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.h +228 -0
  78. data/ext/asmjit/asmjit/src/asmjit/core/formatter.cpp +584 -0
  79. data/ext/asmjit/asmjit/src/asmjit/core/formatter.h +247 -0
  80. data/ext/asmjit/asmjit/src/asmjit/core/formatter_p.h +34 -0
  81. data/ext/asmjit/asmjit/src/asmjit/core/func.cpp +286 -0
  82. data/ext/asmjit/asmjit/src/asmjit/core/func.h +1445 -0
  83. data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext.cpp +293 -0
  84. data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext_p.h +199 -0
  85. data/ext/asmjit/asmjit/src/asmjit/core/globals.cpp +133 -0
  86. data/ext/asmjit/asmjit/src/asmjit/core/globals.h +393 -0
  87. data/ext/asmjit/asmjit/src/asmjit/core/inst.cpp +113 -0
  88. data/ext/asmjit/asmjit/src/asmjit/core/inst.h +772 -0
  89. data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.cpp +1242 -0
  90. data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.h +261 -0
  91. data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.cpp +80 -0
  92. data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.h +89 -0
  93. data/ext/asmjit/asmjit/src/asmjit/core/logger.cpp +69 -0
  94. data/ext/asmjit/asmjit/src/asmjit/core/logger.h +198 -0
  95. data/ext/asmjit/asmjit/src/asmjit/core/misc_p.h +33 -0
  96. data/ext/asmjit/asmjit/src/asmjit/core/operand.cpp +132 -0
  97. data/ext/asmjit/asmjit/src/asmjit/core/operand.h +1611 -0
  98. data/ext/asmjit/asmjit/src/asmjit/core/osutils.cpp +84 -0
  99. data/ext/asmjit/asmjit/src/asmjit/core/osutils.h +61 -0
  100. data/ext/asmjit/asmjit/src/asmjit/core/osutils_p.h +68 -0
  101. data/ext/asmjit/asmjit/src/asmjit/core/raassignment_p.h +418 -0
  102. data/ext/asmjit/asmjit/src/asmjit/core/rabuilders_p.h +612 -0
  103. data/ext/asmjit/asmjit/src/asmjit/core/radefs_p.h +1204 -0
  104. data/ext/asmjit/asmjit/src/asmjit/core/ralocal.cpp +1166 -0
  105. data/ext/asmjit/asmjit/src/asmjit/core/ralocal_p.h +254 -0
  106. data/ext/asmjit/asmjit/src/asmjit/core/rapass.cpp +1969 -0
  107. data/ext/asmjit/asmjit/src/asmjit/core/rapass_p.h +1183 -0
  108. data/ext/asmjit/asmjit/src/asmjit/core/rastack.cpp +184 -0
  109. data/ext/asmjit/asmjit/src/asmjit/core/rastack_p.h +171 -0
  110. data/ext/asmjit/asmjit/src/asmjit/core/string.cpp +559 -0
  111. data/ext/asmjit/asmjit/src/asmjit/core/string.h +372 -0
  112. data/ext/asmjit/asmjit/src/asmjit/core/support.cpp +494 -0
  113. data/ext/asmjit/asmjit/src/asmjit/core/support.h +1773 -0
  114. data/ext/asmjit/asmjit/src/asmjit/core/target.cpp +14 -0
  115. data/ext/asmjit/asmjit/src/asmjit/core/target.h +53 -0
  116. data/ext/asmjit/asmjit/src/asmjit/core/type.cpp +74 -0
  117. data/ext/asmjit/asmjit/src/asmjit/core/type.h +419 -0
  118. data/ext/asmjit/asmjit/src/asmjit/core/virtmem.cpp +722 -0
  119. data/ext/asmjit/asmjit/src/asmjit/core/virtmem.h +242 -0
  120. data/ext/asmjit/asmjit/src/asmjit/core/zone.cpp +353 -0
  121. data/ext/asmjit/asmjit/src/asmjit/core/zone.h +615 -0
  122. data/ext/asmjit/asmjit/src/asmjit/core/zonehash.cpp +309 -0
  123. data/ext/asmjit/asmjit/src/asmjit/core/zonehash.h +186 -0
  124. data/ext/asmjit/asmjit/src/asmjit/core/zonelist.cpp +163 -0
  125. data/ext/asmjit/asmjit/src/asmjit/core/zonelist.h +209 -0
  126. data/ext/asmjit/asmjit/src/asmjit/core/zonestack.cpp +176 -0
  127. data/ext/asmjit/asmjit/src/asmjit/core/zonestack.h +239 -0
  128. data/ext/asmjit/asmjit/src/asmjit/core/zonestring.h +120 -0
  129. data/ext/asmjit/asmjit/src/asmjit/core/zonetree.cpp +99 -0
  130. data/ext/asmjit/asmjit/src/asmjit/core/zonetree.h +380 -0
  131. data/ext/asmjit/asmjit/src/asmjit/core/zonevector.cpp +356 -0
  132. data/ext/asmjit/asmjit/src/asmjit/core/zonevector.h +690 -0
  133. data/ext/asmjit/asmjit/src/asmjit/core.h +1861 -0
  134. data/ext/asmjit/asmjit/src/asmjit/x86/x86archtraits_p.h +148 -0
  135. data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.cpp +5110 -0
  136. data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.h +685 -0
  137. data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.cpp +52 -0
  138. data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.h +351 -0
  139. data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.cpp +61 -0
  140. data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.h +721 -0
  141. data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper.cpp +619 -0
  142. data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper_p.h +60 -0
  143. data/ext/asmjit/asmjit/src/asmjit/x86/x86emitter.h +4315 -0
  144. data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter.cpp +944 -0
  145. data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter_p.h +58 -0
  146. data/ext/asmjit/asmjit/src/asmjit/x86/x86func.cpp +503 -0
  147. data/ext/asmjit/asmjit/src/asmjit/x86/x86func_p.h +33 -0
  148. data/ext/asmjit/asmjit/src/asmjit/x86/x86globals.h +2169 -0
  149. data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi.cpp +1732 -0
  150. data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi_p.h +41 -0
  151. data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.cpp +4427 -0
  152. data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.h +563 -0
  153. data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb_p.h +311 -0
  154. data/ext/asmjit/asmjit/src/asmjit/x86/x86opcode_p.h +436 -0
  155. data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.cpp +231 -0
  156. data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.h +1085 -0
  157. data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass.cpp +1509 -0
  158. data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass_p.h +94 -0
  159. data/ext/asmjit/asmjit/src/asmjit/x86.h +93 -0
  160. data/ext/asmjit/asmjit/src/asmjit.natvis +245 -0
  161. data/ext/asmjit/asmjit/test/asmjit_test_assembler.cpp +84 -0
  162. data/ext/asmjit/asmjit/test/asmjit_test_assembler.h +85 -0
  163. data/ext/asmjit/asmjit/test/asmjit_test_assembler_a64.cpp +4006 -0
  164. data/ext/asmjit/asmjit/test/asmjit_test_assembler_x64.cpp +17833 -0
  165. data/ext/asmjit/asmjit/test/asmjit_test_assembler_x86.cpp +8300 -0
  166. data/ext/asmjit/asmjit/test/asmjit_test_compiler.cpp +253 -0
  167. data/ext/asmjit/asmjit/test/asmjit_test_compiler.h +73 -0
  168. data/ext/asmjit/asmjit/test/asmjit_test_compiler_a64.cpp +690 -0
  169. data/ext/asmjit/asmjit/test/asmjit_test_compiler_x86.cpp +4317 -0
  170. data/ext/asmjit/asmjit/test/asmjit_test_emitters.cpp +197 -0
  171. data/ext/asmjit/asmjit/test/asmjit_test_instinfo.cpp +181 -0
  172. data/ext/asmjit/asmjit/test/asmjit_test_misc.h +257 -0
  173. data/ext/asmjit/asmjit/test/asmjit_test_perf.cpp +62 -0
  174. data/ext/asmjit/asmjit/test/asmjit_test_perf.h +61 -0
  175. data/ext/asmjit/asmjit/test/asmjit_test_perf_a64.cpp +699 -0
  176. data/ext/asmjit/asmjit/test/asmjit_test_perf_x86.cpp +5032 -0
  177. data/ext/asmjit/asmjit/test/asmjit_test_unit.cpp +172 -0
  178. data/ext/asmjit/asmjit/test/asmjit_test_x86_sections.cpp +172 -0
  179. data/ext/asmjit/asmjit/test/asmjitutils.h +38 -0
  180. data/ext/asmjit/asmjit/test/broken.cpp +312 -0
  181. data/ext/asmjit/asmjit/test/broken.h +148 -0
  182. data/ext/asmjit/asmjit/test/cmdline.h +61 -0
  183. data/ext/asmjit/asmjit/test/performancetimer.h +41 -0
  184. data/ext/asmjit/asmjit/tools/configure-makefiles.sh +13 -0
  185. data/ext/asmjit/asmjit/tools/configure-ninja.sh +13 -0
  186. data/ext/asmjit/asmjit/tools/configure-sanitizers.sh +13 -0
  187. data/ext/asmjit/asmjit/tools/configure-vs2019-x64.bat +2 -0
  188. data/ext/asmjit/asmjit/tools/configure-vs2019-x86.bat +2 -0
  189. data/ext/asmjit/asmjit/tools/configure-vs2022-x64.bat +2 -0
  190. data/ext/asmjit/asmjit/tools/configure-vs2022-x86.bat +2 -0
  191. data/ext/asmjit/asmjit/tools/configure-xcode.sh +8 -0
  192. data/ext/asmjit/asmjit/tools/enumgen.js +417 -0
  193. data/ext/asmjit/asmjit/tools/enumgen.sh +3 -0
  194. data/ext/asmjit/asmjit/tools/tablegen-arm.js +365 -0
  195. data/ext/asmjit/asmjit/tools/tablegen-arm.sh +3 -0
  196. data/ext/asmjit/asmjit/tools/tablegen-x86.js +2638 -0
  197. data/ext/asmjit/asmjit/tools/tablegen-x86.sh +3 -0
  198. data/ext/asmjit/asmjit/tools/tablegen.js +947 -0
  199. data/ext/asmjit/asmjit/tools/tablegen.sh +4 -0
  200. data/ext/asmjit/asmjit.cc +167 -30
  201. data/ext/asmjit/extconf.rb +9 -9
  202. data/lib/asmjit/version.rb +1 -1
  203. data/lib/asmjit.rb +14 -4
  204. metadata +198 -17
@@ -0,0 +1,105 @@
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_A64RAPASS_P_H_INCLUDED
7
+ #define ASMJIT_ARM_A64RAPASS_P_H_INCLUDED
8
+
9
+ #include "../core/api-config.h"
10
+ #ifndef ASMJIT_NO_COMPILER
11
+
12
+ #include "../core/compiler.h"
13
+ #include "../core/rabuilders_p.h"
14
+ #include "../core/rapass_p.h"
15
+ #include "../arm/a64assembler.h"
16
+ #include "../arm/a64compiler.h"
17
+ #include "../arm/a64emithelper_p.h"
18
+
19
+ ASMJIT_BEGIN_SUB_NAMESPACE(a64)
20
+
21
+ //! \cond INTERNAL
22
+ //! \addtogroup asmjit_a64
23
+ //! \{
24
+
25
+ //! ARM register allocation pass.
26
+ //!
27
+ //! Takes care of generating function prologs and epilogs, and also performs
28
+ //! register allocation.
29
+ class ARMRAPass : public BaseRAPass {
30
+ public:
31
+ ASMJIT_NONCOPYABLE(ARMRAPass)
32
+ typedef BaseRAPass Base;
33
+
34
+ EmitHelper _emitHelper;
35
+
36
+ //! \name Construction & Destruction
37
+ //! \{
38
+
39
+ ARMRAPass() noexcept;
40
+ virtual ~ARMRAPass() noexcept;
41
+
42
+ //! \}
43
+
44
+ //! \name Accessors
45
+ //! \{
46
+
47
+ //! Returns the compiler casted to `arm::Compiler`.
48
+ inline Compiler* cc() const noexcept { return static_cast<Compiler*>(_cb); }
49
+
50
+ //! Returns emit helper.
51
+ inline EmitHelper* emitHelper() noexcept { return &_emitHelper; }
52
+
53
+ //! \}
54
+
55
+ //! \name Events
56
+ //! \{
57
+
58
+ void onInit() noexcept override;
59
+ void onDone() noexcept override;
60
+
61
+ //! \}
62
+
63
+ //! \name CFG
64
+ //! \{
65
+
66
+ Error buildCFG() noexcept override;
67
+
68
+ //! \}
69
+
70
+ //! \name Rewrite
71
+ //! \{
72
+
73
+ Error _rewrite(BaseNode* first, BaseNode* stop) noexcept override;
74
+
75
+ //! \}
76
+
77
+ //! \name Prolog & Epilog
78
+ //! \{
79
+
80
+ Error updateStackFrame() noexcept override;
81
+
82
+ //! \}
83
+
84
+ //! \name Emit Helpers
85
+ //! \{
86
+
87
+ Error emitMove(uint32_t workId, uint32_t dstPhysId, uint32_t srcPhysId) noexcept override;
88
+ Error emitSwap(uint32_t aWorkId, uint32_t aPhysId, uint32_t bWorkId, uint32_t bPhysId) noexcept override;
89
+
90
+ Error emitLoad(uint32_t workId, uint32_t dstPhysId) noexcept override;
91
+ Error emitSave(uint32_t workId, uint32_t srcPhysId) noexcept override;
92
+
93
+ Error emitJump(const Label& label) noexcept override;
94
+ Error emitPreCall(InvokeNode* invokeNode) noexcept override;
95
+
96
+ //! \}
97
+ };
98
+
99
+ //! \}
100
+ //! \endcond
101
+
102
+ ASMJIT_END_SUB_NAMESPACE
103
+
104
+ #endif // !ASMJIT_NO_COMPILER
105
+ #endif // ASMJIT_ARM_A64RAPASS_P_H_INCLUDED
@@ -0,0 +1,179 @@
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_A64UTILS_H_INCLUDED
7
+ #define ASMJIT_ARM_A64UTILS_H_INCLUDED
8
+
9
+ #include "../arm/a64globals.h"
10
+
11
+ ASMJIT_BEGIN_SUB_NAMESPACE(a64)
12
+
13
+ //! \addtogroup asmjit_a64
14
+ //! \{
15
+
16
+ //! Public utilities and helpers for targeting AArch64 architecture.
17
+ namespace Utils {
18
+
19
+ //! Decomposed fields of a logical immediate value (AArch64).
20
+ struct LogicalImm {
21
+ uint32_t n;
22
+ uint32_t s;
23
+ uint32_t r;
24
+ };
25
+
26
+ //! Encodes the given `imm` value of the given `width` to a logical immediate value represented as N, S, and R fields
27
+ //! and writes these fields to `out`.
28
+ //!
29
+ //! Encoding Table:
30
+ //!
31
+ //! ```
32
+ //! +---+--------+--------+------+
33
+ //! | N | ImmS | ImmR | Size |
34
+ //! +---+--------+--------+------+
35
+ //! | 1 | ssssss | rrrrrr | 64 |
36
+ //! | 0 | 0sssss | .rrrrr | 32 |
37
+ //! | 0 | 10ssss | ..rrrr | 16 |
38
+ //! | 0 | 110sss | ...rrr | 8 |
39
+ //! | 0 | 1110ss | ....rr | 4 |
40
+ //! | 0 | 11110s | .....r | 2 |
41
+ //! +---+--------+--------+------+
42
+ //! ```
43
+ ASMJIT_MAYBE_UNUSED
44
+ static bool encodeLogicalImm(uint64_t imm, uint32_t width, a64::Utils::LogicalImm* out) noexcept {
45
+ // Determine the element width, which must be 2, 4, 8, 16, 32, or 64 bits.
46
+ do {
47
+ width /= 2;
48
+ uint64_t mask = (uint64_t(1) << width) - 1u;
49
+ if ((imm & mask) != ((imm >> width) & mask)) {
50
+ width *= 2;
51
+ break;
52
+ }
53
+ } while (width > 2);
54
+
55
+ // Patterns of all zeros and all ones are not encodable.
56
+ uint64_t lsbMask = Support::lsbMask<uint64_t>(width);
57
+ imm &= lsbMask;
58
+
59
+ if (imm == 0 || imm == lsbMask)
60
+ return false;
61
+
62
+ // Inspect the pattern and get the most important bit indexes.
63
+ //
64
+ // oIndex <-+ +-> zIndex
65
+ // | |
66
+ // |..zeros..|oCount|zCount|..ones..|
67
+ // |000000000|111111|000000|11111111|
68
+
69
+ uint32_t zIndex = Support::ctz(~imm);
70
+ uint64_t zImm = imm ^ ((uint64_t(1) << zIndex) - 1);
71
+ uint32_t zCount = (zImm ? Support::ctz(zImm) : width) - zIndex;
72
+
73
+ uint32_t oIndex = zIndex + zCount;
74
+ uint64_t oImm = ~(zImm ^ Support::lsbMask<uint64_t>(oIndex));
75
+ uint32_t oCount = (oImm ? Support::ctz(oImm) : width) - (oIndex);
76
+
77
+ // Verify whether the bit-pattern is encodable.
78
+ uint64_t mustBeZero = oImm ^ ~Support::lsbMask<uint64_t>(oIndex + oCount);
79
+ if (mustBeZero != 0 || (zIndex > 0 && width - (oIndex + oCount) != 0))
80
+ return false;
81
+
82
+ out->n = width == 64;
83
+ out->s = (oCount + zIndex - 1) | (Support::neg(width * 2) & 0x3F);
84
+ out->r = width - oIndex;
85
+ return true;
86
+ }
87
+
88
+ //! Returns true if the given `imm` value is encodable as a logical immediate. The `width` argument describes the
89
+ //! width of the operation, and must be either 32 or 64. This function can be used to test whether an immediate
90
+ //! value can be used with AND, ANDS, BIC, BICS, EON, EOR, ORN, and ORR instruction.
91
+ ASMJIT_MAYBE_UNUSED
92
+ static inline bool isLogicalImm(uint64_t imm, uint32_t width) noexcept {
93
+ LogicalImm dummy;
94
+ return encodeLogicalImm(imm, width, &dummy);
95
+ }
96
+
97
+ //! Returns true if the given `imm` value is a byte mask. Byte mask has each byte part of the value set to either
98
+ //! 0x00 or 0xFF. Some ARM instructions accept immediates that form a byte-mask and this function can be used to
99
+ //! verify that the immediate is encodable before using the value.
100
+ template<typename T>
101
+ static inline bool isByteMaskImm8(const T& imm) noexcept {
102
+ constexpr T kMask = T(0x0101010101010101 & Support::allOnes<T>());
103
+ return imm == (imm & kMask) * T(255);
104
+ }
105
+
106
+ //! \cond
107
+ //! A generic implementation that checjs whether a floating point value can be converted to ARM Imm8.
108
+ template<typename T, uint32_t kNumBBits, uint32_t kNumCDEFGHBits, uint32_t kNumZeroBits>
109
+ static inline bool isFPImm8Generic(T val) noexcept {
110
+ constexpr uint32_t kAllBsMask = Support::lsbMask<uint32_t>(kNumBBits);
111
+ constexpr uint32_t kB0Pattern = Support::bitMask(kNumBBits - 1);
112
+ constexpr uint32_t kB1Pattern = kAllBsMask ^ kB0Pattern;
113
+
114
+ T immZ = val & Support::lsbMask<T>(kNumZeroBits);
115
+ uint32_t immB = uint32_t(val >> (kNumZeroBits + kNumCDEFGHBits)) & kAllBsMask;
116
+
117
+ // ImmZ must be all zeros and ImmB must either be B0 or B1 pattern.
118
+ return immZ == 0 && (immB == kB0Pattern || immB == kB1Pattern);
119
+ }
120
+ //! \endcond
121
+
122
+ //! Returns true if the given half precision floating point `val` can be encoded as ARM IMM8 value, which represents
123
+ //! a limited set of floating point immediate values, which can be used with FMOV instruction.
124
+ //!
125
+ //! The floating point must have bits distributed in the following way:
126
+ //!
127
+ //! ```
128
+ //! [aBbbcdef|gh000000]
129
+ //! ```
130
+ static inline bool isFP16Imm8(uint32_t val) noexcept { return isFPImm8Generic<uint32_t, 3, 6, 6>(val); }
131
+
132
+ //! Returns true if the given single precision floating point `val` can be encoded as ARM IMM8 value, which represents
133
+ //! a limited set of floating point immediate values, which can be used with FMOV instruction.
134
+ //!
135
+ //! The floating point must have bits distributed in the following way:
136
+ //!
137
+ //! ```
138
+ //! [aBbbbbbc|defgh000|00000000|00000000]
139
+ //! ```
140
+ static inline bool isFP32Imm8(uint32_t val) noexcept { return isFPImm8Generic<uint32_t, 6, 6, 19>(val); }
141
+ //! \overload
142
+ static inline bool isFP32Imm8(float val) noexcept { return isFP32Imm8(Support::bitCast<uint32_t>(val)); }
143
+
144
+ //! Returns true if the given double precision floating point `val` can be encoded as ARM IMM8 value, which represents
145
+ //! a limited set of floating point immediate values, which can be used with FMOV instruction.
146
+ //!
147
+ //! The floating point must have bits distributed in the following way:
148
+ //!
149
+ //! ```
150
+ //! [aBbbbbbb|bbcdefgh|00000000|00000000|00000000|00000000|00000000|00000000]
151
+ //! ```
152
+ static inline bool isFP64Imm8(uint64_t val) noexcept { return isFPImm8Generic<uint64_t, 9, 6, 48>(val); }
153
+ //! \overload
154
+ static inline bool isFP64Imm8(double val) noexcept { return isFP64Imm8(Support::bitCast<uint64_t>(val)); }
155
+
156
+ //! \cond
157
+ template<typename T, uint32_t kNumBBits, uint32_t kNumCDEFGHBits, uint32_t kNumZeroBits>
158
+ static inline uint32_t encodeFPToImm8Generic(T val) noexcept {
159
+ uint32_t bits = uint32_t(val >> kNumZeroBits);
160
+ return ((bits >> (kNumBBits + kNumCDEFGHBits - 7)) & 0x80u) | (bits & 0x7F);
161
+ }
162
+ //! \endcond
163
+
164
+ //! Encodes a double precision floating point value into IMM8 format.
165
+ //!
166
+ //! \note This function expects that `isFP64Imm8(val) == true` so it doesn't perform any checks of the value and just
167
+ //! rearranges some bits into Imm8 order.
168
+ static inline uint32_t encodeFP64ToImm8(uint64_t val) noexcept { return encodeFPToImm8Generic<uint64_t, 9, 6, 48>(val); }
169
+ //! \overload
170
+ static inline uint32_t encodeFP64ToImm8(double val) noexcept { return encodeFP64ToImm8(Support::bitCast<uint64_t>(val)); }
171
+
172
+ } // {Utils}
173
+
174
+ //! \}
175
+
176
+ ASMJIT_END_SUB_NAMESPACE
177
+
178
+ #endif // ASMJIT_ARM_A64UTILS_H_INCLUDED
179
+
@@ -0,0 +1,143 @@
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/armformatter_p.h"
12
+ #include "../arm/armoperand.h"
13
+ #include "../arm/a64instapi_p.h"
14
+ #include "../arm/a64instdb_p.h"
15
+
16
+ #ifndef ASMJIT_NO_COMPILER
17
+ #include "../core/compiler.h"
18
+ #endif
19
+
20
+ ASMJIT_BEGIN_SUB_NAMESPACE(arm)
21
+
22
+ // arm::FormatterInternal - Format Feature
23
+ // =======================================
24
+
25
+ Error FormatterInternal::formatFeature(String& sb, uint32_t featureId) noexcept {
26
+ // @EnumStringBegin{"enum": "CpuFeatures::ARM", "output": "sFeature", "strip": "k"}@
27
+ static const char sFeatureString[] =
28
+ "None\0"
29
+ "THUMB\0"
30
+ "THUMBv2\0"
31
+ "ARMv6\0"
32
+ "ARMv7\0"
33
+ "ARMv8a\0"
34
+ "ARMv8_1a\0"
35
+ "ARMv8_2a\0"
36
+ "ARMv8_3a\0"
37
+ "ARMv8_4a\0"
38
+ "ARMv8_5a\0"
39
+ "ARMv8_6a\0"
40
+ "ARMv8_7a\0"
41
+ "VFPv2\0"
42
+ "VFPv3\0"
43
+ "VFPv4\0"
44
+ "VFP_D32\0"
45
+ "AES\0"
46
+ "ALTNZCV\0"
47
+ "ASIMD\0"
48
+ "BF16\0"
49
+ "BTI\0"
50
+ "CPUID\0"
51
+ "CRC32\0"
52
+ "DGH\0"
53
+ "DIT\0"
54
+ "DOTPROD\0"
55
+ "EDSP\0"
56
+ "FCMA\0"
57
+ "FJCVTZS\0"
58
+ "FLAGM\0"
59
+ "FP16CONV\0"
60
+ "FP16FML\0"
61
+ "FP16FULL\0"
62
+ "FRINT\0"
63
+ "I8MM\0"
64
+ "IDIVA\0"
65
+ "IDIVT\0"
66
+ "LSE\0"
67
+ "MTE\0"
68
+ "RCPC_IMMO\0"
69
+ "RDM\0"
70
+ "PMU\0"
71
+ "PMULL\0"
72
+ "RNG\0"
73
+ "SB\0"
74
+ "SHA1\0"
75
+ "SHA2\0"
76
+ "SHA3\0"
77
+ "SHA512\0"
78
+ "SM3\0"
79
+ "SM4\0"
80
+ "SSBS\0"
81
+ "SVE\0"
82
+ "SVE_BF16\0"
83
+ "SVE_F32MM\0"
84
+ "SVE_F64MM\0"
85
+ "SVE_I8MM\0"
86
+ "SVE_PMULL\0"
87
+ "SVE2\0"
88
+ "SVE2_AES\0"
89
+ "SVE2_BITPERM\0"
90
+ "SVE2_SHA3\0"
91
+ "SVE2_SM4\0"
92
+ "TME\0"
93
+ "<Unknown>\0";
94
+
95
+ static const uint16_t sFeatureIndex[] = {
96
+ 0, 5, 11, 19, 25, 31, 38, 47, 56, 65, 74, 83, 92, 101, 107, 113, 119, 127,
97
+ 131, 139, 145, 150, 154, 160, 166, 170, 174, 182, 187, 192, 200, 206, 215,
98
+ 223, 232, 238, 243, 249, 255, 259, 263, 273, 277, 281, 287, 291, 294, 299,
99
+ 304, 309, 316, 320, 324, 329, 333, 342, 352, 362, 371, 381, 386, 395, 408,
100
+ 418, 427, 431
101
+ };
102
+ // @EnumStringEnd@
103
+
104
+ return sb.append(sFeatureString + sFeatureIndex[Support::min<uint32_t>(featureId, uint32_t(CpuFeatures::ARM::kMaxValue) + 1)]);
105
+ }
106
+
107
+ // arm::FormatterInternal - Format Constants
108
+ // =========================================
109
+
110
+ ASMJIT_FAVOR_SIZE Error FormatterInternal::formatCondCode(String& sb, CondCode cc) noexcept {
111
+ static const char condCodeData[] =
112
+ "al\0" "na\0"
113
+ "eq\0" "ne\0"
114
+ "cs\0" "cc\0" "mi\0" "pl\0" "vs\0" "vc\0"
115
+ "hi\0" "ls\0" "ge\0" "lt\0" "gt\0" "le\0"
116
+ "<Unknown>";
117
+ return sb.append(condCodeData + Support::min<uint32_t>(uint32_t(cc), 16u) * 3);
118
+ }
119
+
120
+ ASMJIT_FAVOR_SIZE Error FormatterInternal::formatShiftOp(String& sb, ShiftOp shiftOp) noexcept {
121
+ const char* str = "<Unknown>";
122
+ switch (shiftOp) {
123
+ case ShiftOp::kLSL: str = "lsl"; break;
124
+ case ShiftOp::kLSR: str = "lsr"; break;
125
+ case ShiftOp::kASR: str = "asr"; break;
126
+ case ShiftOp::kROR: str = "ror"; break;
127
+ case ShiftOp::kRRX: str = "rrx"; break;
128
+ case ShiftOp::kMSL: str = "msl"; break;
129
+ case ShiftOp::kUXTB: str = "uxtb"; break;
130
+ case ShiftOp::kUXTH: str = "uxth"; break;
131
+ case ShiftOp::kUXTW: str = "uxtw"; break;
132
+ case ShiftOp::kUXTX: str = "uxtx"; break;
133
+ case ShiftOp::kSXTB: str = "sxtb"; break;
134
+ case ShiftOp::kSXTH: str = "sxth"; break;
135
+ case ShiftOp::kSXTW: str = "sxtw"; break;
136
+ case ShiftOp::kSXTX: str = "sxtx"; break;
137
+ }
138
+ return sb.append(str);
139
+ }
140
+
141
+ ASMJIT_END_SUB_NAMESPACE
142
+
143
+ #endif // !ASMJIT_NO_LOGGING
@@ -0,0 +1,44 @@
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_ARMFORMATTER_P_H_INCLUDED
7
+ #define ASMJIT_ARM_ARMFORMATTER_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/armglobals.h"
15
+
16
+ ASMJIT_BEGIN_SUB_NAMESPACE(arm)
17
+
18
+ //! \cond INTERNAL
19
+ //! \addtogroup asmjit_arm
20
+ //! \{
21
+
22
+ namespace FormatterInternal {
23
+
24
+ Error ASMJIT_CDECL formatFeature(
25
+ String& sb,
26
+ uint32_t featureId) noexcept;
27
+
28
+ Error ASMJIT_CDECL formatCondCode(
29
+ String& sb,
30
+ CondCode cc) noexcept;
31
+
32
+ Error ASMJIT_CDECL formatShiftOp(
33
+ String& sb,
34
+ ShiftOp shiftOp) noexcept;
35
+
36
+ } // {FormatterInternal}
37
+
38
+ //! \}
39
+ //! \endcond
40
+
41
+ ASMJIT_END_SUB_NAMESPACE
42
+
43
+ #endif // !ASMJIT_NO_LOGGING
44
+ #endif // ASMJIT_ARM_ARMFORMATTER_P_H_INCLUDED
@@ -0,0 +1,21 @@
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_ARMGLOBALS_H_INCLUDED
7
+ #define ASMJIT_ARM_ARMGLOBALS_H_INCLUDED
8
+
9
+ #include "../core/archcommons.h"
10
+ #include "../core/inst.h"
11
+
12
+ //! \namespace asmjit::arm
13
+ //! \ingroup asmjit_arm
14
+ //!
15
+ //! API shared between AArch32 & AArch64 backends.
16
+
17
+ ASMJIT_BEGIN_SUB_NAMESPACE(arm)
18
+
19
+ ASMJIT_END_SUB_NAMESPACE
20
+
21
+ #endif // ASMJIT_ARM_ARMGLOBALS_H_INCLUDED