hexcore-capstone 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +191 -0
  3. package/binding.gyp +168 -0
  4. package/deps/capstone/LEB128.h +38 -0
  5. package/deps/capstone/MCDisassembler.h +14 -0
  6. package/deps/capstone/MCFixedLenDisassembler.h +32 -0
  7. package/deps/capstone/MCInst.c +270 -0
  8. package/deps/capstone/MCInst.h +165 -0
  9. package/deps/capstone/MCInstrDesc.c +41 -0
  10. package/deps/capstone/MCInstrDesc.h +167 -0
  11. package/deps/capstone/MCRegisterInfo.c +151 -0
  12. package/deps/capstone/MCRegisterInfo.h +116 -0
  13. package/deps/capstone/Mapping.c +254 -0
  14. package/deps/capstone/Mapping.h +174 -0
  15. package/deps/capstone/MathExtras.h +442 -0
  16. package/deps/capstone/SStream.c +181 -0
  17. package/deps/capstone/SStream.h +40 -0
  18. package/deps/capstone/arch/AArch64/AArch64AddressingModes.h +945 -0
  19. package/deps/capstone/arch/AArch64/AArch64BaseInfo.c +77 -0
  20. package/deps/capstone/arch/AArch64/AArch64BaseInfo.h +585 -0
  21. package/deps/capstone/arch/AArch64/AArch64Disassembler.c +2280 -0
  22. package/deps/capstone/arch/AArch64/AArch64Disassembler.h +18 -0
  23. package/deps/capstone/arch/AArch64/AArch64GenAsmWriter.inc +26589 -0
  24. package/deps/capstone/arch/AArch64/AArch64GenDisassemblerTables.inc +27322 -0
  25. package/deps/capstone/arch/AArch64/AArch64GenInstrInfo.inc +13194 -0
  26. package/deps/capstone/arch/AArch64/AArch64GenRegisterInfo.inc +3814 -0
  27. package/deps/capstone/arch/AArch64/AArch64GenRegisterName.inc +714 -0
  28. package/deps/capstone/arch/AArch64/AArch64GenRegisterV.inc +673 -0
  29. package/deps/capstone/arch/AArch64/AArch64GenSubtargetInfo.inc +229 -0
  30. package/deps/capstone/arch/AArch64/AArch64GenSystemOperands.inc +2863 -0
  31. package/deps/capstone/arch/AArch64/AArch64GenSystemOperands_enum.inc +21 -0
  32. package/deps/capstone/arch/AArch64/AArch64InstPrinter.c +3029 -0
  33. package/deps/capstone/arch/AArch64/AArch64InstPrinter.h +28 -0
  34. package/deps/capstone/arch/AArch64/AArch64Mapping.c +883 -0
  35. package/deps/capstone/arch/AArch64/AArch64Mapping.h +43 -0
  36. package/deps/capstone/arch/AArch64/AArch64MappingInsn.inc +37790 -0
  37. package/deps/capstone/arch/AArch64/AArch64MappingInsnName.inc +1282 -0
  38. package/deps/capstone/arch/AArch64/AArch64MappingInsnOp.inc +26994 -0
  39. package/deps/capstone/arch/AArch64/AArch64Module.c +44 -0
  40. package/deps/capstone/arch/AArch64/AArch64Module.h +12 -0
  41. package/deps/capstone/arch/ARM/ARMAddressingModes.h +698 -0
  42. package/deps/capstone/arch/ARM/ARMBaseInfo.h +486 -0
  43. package/deps/capstone/arch/ARM/ARMDisassembler.c +5763 -0
  44. package/deps/capstone/arch/ARM/ARMDisassembler.h +18 -0
  45. package/deps/capstone/arch/ARM/ARMGenAsmWriter.inc +9545 -0
  46. package/deps/capstone/arch/ARM/ARMGenDisassemblerTables.inc +15185 -0
  47. package/deps/capstone/arch/ARM/ARMGenInstrInfo.inc +6632 -0
  48. package/deps/capstone/arch/ARM/ARMGenRegisterInfo.inc +2102 -0
  49. package/deps/capstone/arch/ARM/ARMGenRegisterName.inc +231 -0
  50. package/deps/capstone/arch/ARM/ARMGenRegisterName_digit.inc +231 -0
  51. package/deps/capstone/arch/ARM/ARMGenSubtargetInfo.inc +162 -0
  52. package/deps/capstone/arch/ARM/ARMGenSystemRegister.inc +270 -0
  53. package/deps/capstone/arch/ARM/ARMInstPrinter.c +3364 -0
  54. package/deps/capstone/arch/ARM/ARMInstPrinter.h +43 -0
  55. package/deps/capstone/arch/ARM/ARMMapping.c +551 -0
  56. package/deps/capstone/arch/ARM/ARMMapping.h +40 -0
  57. package/deps/capstone/arch/ARM/ARMMappingInsn.inc +18772 -0
  58. package/deps/capstone/arch/ARM/ARMMappingInsnName.inc +475 -0
  59. package/deps/capstone/arch/ARM/ARMMappingInsnOp.inc +10729 -0
  60. package/deps/capstone/arch/ARM/ARMModule.c +63 -0
  61. package/deps/capstone/arch/ARM/ARMModule.h +12 -0
  62. package/deps/capstone/arch/BPF/BPFConstants.h +88 -0
  63. package/deps/capstone/arch/BPF/BPFDisassembler.c +464 -0
  64. package/deps/capstone/arch/BPF/BPFDisassembler.h +27 -0
  65. package/deps/capstone/arch/BPF/BPFInstPrinter.c +285 -0
  66. package/deps/capstone/arch/BPF/BPFInstPrinter.h +16 -0
  67. package/deps/capstone/arch/BPF/BPFMapping.c +513 -0
  68. package/deps/capstone/arch/BPF/BPFMapping.h +21 -0
  69. package/deps/capstone/arch/BPF/BPFModule.c +34 -0
  70. package/deps/capstone/arch/BPF/BPFModule.h +12 -0
  71. package/deps/capstone/arch/EVM/EVMDisassembler.c +379 -0
  72. package/deps/capstone/arch/EVM/EVMDisassembler.h +12 -0
  73. package/deps/capstone/arch/EVM/EVMInstPrinter.c +20 -0
  74. package/deps/capstone/arch/EVM/EVMInstPrinter.h +17 -0
  75. package/deps/capstone/arch/EVM/EVMMapping.c +344 -0
  76. package/deps/capstone/arch/EVM/EVMMapping.h +8 -0
  77. package/deps/capstone/arch/EVM/EVMMappingInsn.inc +259 -0
  78. package/deps/capstone/arch/EVM/EVMModule.c +33 -0
  79. package/deps/capstone/arch/EVM/EVMModule.h +12 -0
  80. package/deps/capstone/arch/M680X/M680XDisassembler.c +2307 -0
  81. package/deps/capstone/arch/M680X/M680XDisassembler.h +17 -0
  82. package/deps/capstone/arch/M680X/M680XDisassemblerInternals.h +57 -0
  83. package/deps/capstone/arch/M680X/M680XInstPrinter.c +360 -0
  84. package/deps/capstone/arch/M680X/M680XInstPrinter.h +25 -0
  85. package/deps/capstone/arch/M680X/M680XModule.c +77 -0
  86. package/deps/capstone/arch/M680X/M680XModule.h +12 -0
  87. package/deps/capstone/arch/M680X/cpu12.inc +335 -0
  88. package/deps/capstone/arch/M680X/hcs08.inc +60 -0
  89. package/deps/capstone/arch/M680X/hd6301.inc +15 -0
  90. package/deps/capstone/arch/M680X/hd6309.inc +259 -0
  91. package/deps/capstone/arch/M680X/insn_props.inc +367 -0
  92. package/deps/capstone/arch/M680X/m6800.inc +277 -0
  93. package/deps/capstone/arch/M680X/m6801.inc +39 -0
  94. package/deps/capstone/arch/M680X/m6805.inc +277 -0
  95. package/deps/capstone/arch/M680X/m6808.inc +91 -0
  96. package/deps/capstone/arch/M680X/m6809.inc +352 -0
  97. package/deps/capstone/arch/M680X/m6811.inc +105 -0
  98. package/deps/capstone/arch/M68K/M68KDisassembler.c +3668 -0
  99. package/deps/capstone/arch/M68K/M68KDisassembler.h +30 -0
  100. package/deps/capstone/arch/M68K/M68KInstPrinter.c +387 -0
  101. package/deps/capstone/arch/M68K/M68KInstPrinter.h +21 -0
  102. package/deps/capstone/arch/M68K/M68KInstructionTable.inc +65540 -0
  103. package/deps/capstone/arch/M68K/M68KModule.c +42 -0
  104. package/deps/capstone/arch/M68K/M68KModule.h +12 -0
  105. package/deps/capstone/arch/MOS65XX/MOS65XXDisassembler.c +544 -0
  106. package/deps/capstone/arch/MOS65XX/MOS65XXDisassembler.h +22 -0
  107. package/deps/capstone/arch/MOS65XX/MOS65XXDisassemblerInternals.h +23 -0
  108. package/deps/capstone/arch/MOS65XX/MOS65XXModule.c +79 -0
  109. package/deps/capstone/arch/MOS65XX/MOS65XXModule.h +12 -0
  110. package/deps/capstone/arch/MOS65XX/instruction_info.inc +106 -0
  111. package/deps/capstone/arch/MOS65XX/m6502.inc +256 -0
  112. package/deps/capstone/arch/MOS65XX/m65816.inc +256 -0
  113. package/deps/capstone/arch/MOS65XX/m65c02.inc +256 -0
  114. package/deps/capstone/arch/MOS65XX/mw65c02.inc +256 -0
  115. package/deps/capstone/arch/Mips/MipsDisassembler.c +1794 -0
  116. package/deps/capstone/arch/Mips/MipsDisassembler.h +16 -0
  117. package/deps/capstone/arch/Mips/MipsGenAsmWriter.inc +5725 -0
  118. package/deps/capstone/arch/Mips/MipsGenDisassemblerTables.inc +6942 -0
  119. package/deps/capstone/arch/Mips/MipsGenInstrInfo.inc +1805 -0
  120. package/deps/capstone/arch/Mips/MipsGenRegisterInfo.inc +1679 -0
  121. package/deps/capstone/arch/Mips/MipsGenSubtargetInfo.inc +52 -0
  122. package/deps/capstone/arch/Mips/MipsInstPrinter.c +424 -0
  123. package/deps/capstone/arch/Mips/MipsInstPrinter.h +25 -0
  124. package/deps/capstone/arch/Mips/MipsMapping.c +1070 -0
  125. package/deps/capstone/arch/Mips/MipsMapping.h +25 -0
  126. package/deps/capstone/arch/Mips/MipsMappingInsn.inc +9315 -0
  127. package/deps/capstone/arch/Mips/MipsModule.c +52 -0
  128. package/deps/capstone/arch/Mips/MipsModule.h +12 -0
  129. package/deps/capstone/arch/PowerPC/PPCDisassembler.c +627 -0
  130. package/deps/capstone/arch/PowerPC/PPCDisassembler.h +17 -0
  131. package/deps/capstone/arch/PowerPC/PPCGenAsmWriter.inc +11451 -0
  132. package/deps/capstone/arch/PowerPC/PPCGenDisassemblerTables.inc +6886 -0
  133. package/deps/capstone/arch/PowerPC/PPCGenInstrInfo.inc +4772 -0
  134. package/deps/capstone/arch/PowerPC/PPCGenRegisterInfo.inc +1122 -0
  135. package/deps/capstone/arch/PowerPC/PPCGenRegisterName.inc +278 -0
  136. package/deps/capstone/arch/PowerPC/PPCGenSubtargetInfo.inc +90 -0
  137. package/deps/capstone/arch/PowerPC/PPCInstPrinter.c +1238 -0
  138. package/deps/capstone/arch/PowerPC/PPCInstPrinter.h +15 -0
  139. package/deps/capstone/arch/PowerPC/PPCMapping.c +570 -0
  140. package/deps/capstone/arch/PowerPC/PPCMapping.h +40 -0
  141. package/deps/capstone/arch/PowerPC/PPCMappingInsn.inc +13220 -0
  142. package/deps/capstone/arch/PowerPC/PPCMappingInsnName.inc +1731 -0
  143. package/deps/capstone/arch/PowerPC/PPCModule.c +45 -0
  144. package/deps/capstone/arch/PowerPC/PPCModule.h +12 -0
  145. package/deps/capstone/arch/PowerPC/PPCPredicates.h +62 -0
  146. package/deps/capstone/arch/RISCV/RISCVBaseInfo.h +106 -0
  147. package/deps/capstone/arch/RISCV/RISCVDisassembler.c +433 -0
  148. package/deps/capstone/arch/RISCV/RISCVDisassembler.h +18 -0
  149. package/deps/capstone/arch/RISCV/RISCVGenAsmWriter.inc +2651 -0
  150. package/deps/capstone/arch/RISCV/RISCVGenDisassemblerTables.inc +1776 -0
  151. package/deps/capstone/arch/RISCV/RISCVGenInsnNameMaps.inc +275 -0
  152. package/deps/capstone/arch/RISCV/RISCVGenInstrInfo.inc +470 -0
  153. package/deps/capstone/arch/RISCV/RISCVGenRegisterInfo.inc +426 -0
  154. package/deps/capstone/arch/RISCV/RISCVGenSubtargetInfo.inc +33 -0
  155. package/deps/capstone/arch/RISCV/RISCVInstPrinter.c +447 -0
  156. package/deps/capstone/arch/RISCV/RISCVInstPrinter.h +24 -0
  157. package/deps/capstone/arch/RISCV/RISCVMapping.c +366 -0
  158. package/deps/capstone/arch/RISCV/RISCVMapping.h +22 -0
  159. package/deps/capstone/arch/RISCV/RISCVMappingInsn.inc +1635 -0
  160. package/deps/capstone/arch/RISCV/RISCVModule.c +42 -0
  161. package/deps/capstone/arch/RISCV/RISCVModule.h +12 -0
  162. package/deps/capstone/arch/SH/SHDisassembler.c +2221 -0
  163. package/deps/capstone/arch/SH/SHDisassembler.h +19 -0
  164. package/deps/capstone/arch/SH/SHInsnTable.inc +66 -0
  165. package/deps/capstone/arch/SH/SHInstPrinter.c +438 -0
  166. package/deps/capstone/arch/SH/SHInstPrinter.h +23 -0
  167. package/deps/capstone/arch/SH/SHModule.c +39 -0
  168. package/deps/capstone/arch/SH/SHModule.h +12 -0
  169. package/deps/capstone/arch/SH/mktable.rb +390 -0
  170. package/deps/capstone/arch/Sparc/Sparc.h +63 -0
  171. package/deps/capstone/arch/Sparc/SparcDisassembler.c +500 -0
  172. package/deps/capstone/arch/Sparc/SparcDisassembler.h +17 -0
  173. package/deps/capstone/arch/Sparc/SparcGenAsmWriter.inc +5709 -0
  174. package/deps/capstone/arch/Sparc/SparcGenDisassemblerTables.inc +2028 -0
  175. package/deps/capstone/arch/Sparc/SparcGenInstrInfo.inc +514 -0
  176. package/deps/capstone/arch/Sparc/SparcGenRegisterInfo.inc +451 -0
  177. package/deps/capstone/arch/Sparc/SparcGenSubtargetInfo.inc +27 -0
  178. package/deps/capstone/arch/Sparc/SparcInstPrinter.c +446 -0
  179. package/deps/capstone/arch/Sparc/SparcInstPrinter.h +17 -0
  180. package/deps/capstone/arch/Sparc/SparcMapping.c +665 -0
  181. package/deps/capstone/arch/Sparc/SparcMapping.h +34 -0
  182. package/deps/capstone/arch/Sparc/SparcMappingInsn.inc +2643 -0
  183. package/deps/capstone/arch/Sparc/SparcModule.c +45 -0
  184. package/deps/capstone/arch/Sparc/SparcModule.h +12 -0
  185. package/deps/capstone/arch/SystemZ/SystemZDisassembler.c +484 -0
  186. package/deps/capstone/arch/SystemZ/SystemZDisassembler.h +17 -0
  187. package/deps/capstone/arch/SystemZ/SystemZGenAsmWriter.inc +11575 -0
  188. package/deps/capstone/arch/SystemZ/SystemZGenDisassemblerTables.inc +10262 -0
  189. package/deps/capstone/arch/SystemZ/SystemZGenInsnNameMaps.inc +2348 -0
  190. package/deps/capstone/arch/SystemZ/SystemZGenInstrInfo.inc +2820 -0
  191. package/deps/capstone/arch/SystemZ/SystemZGenRegisterInfo.inc +741 -0
  192. package/deps/capstone/arch/SystemZ/SystemZGenSubtargetInfo.inc +49 -0
  193. package/deps/capstone/arch/SystemZ/SystemZInstPrinter.c +433 -0
  194. package/deps/capstone/arch/SystemZ/SystemZInstPrinter.h +15 -0
  195. package/deps/capstone/arch/SystemZ/SystemZMCTargetDesc.c +195 -0
  196. package/deps/capstone/arch/SystemZ/SystemZMCTargetDesc.h +51 -0
  197. package/deps/capstone/arch/SystemZ/SystemZMapping.c +479 -0
  198. package/deps/capstone/arch/SystemZ/SystemZMapping.h +23 -0
  199. package/deps/capstone/arch/SystemZ/SystemZMappingInsn.inc +14175 -0
  200. package/deps/capstone/arch/SystemZ/SystemZModule.c +44 -0
  201. package/deps/capstone/arch/SystemZ/SystemZModule.h +12 -0
  202. package/deps/capstone/arch/TMS320C64x/TMS320C64xDisassembler.c +628 -0
  203. package/deps/capstone/arch/TMS320C64x/TMS320C64xDisassembler.h +19 -0
  204. package/deps/capstone/arch/TMS320C64x/TMS320C64xGenAsmWriter.inc +684 -0
  205. package/deps/capstone/arch/TMS320C64x/TMS320C64xGenDisassemblerTables.inc +1352 -0
  206. package/deps/capstone/arch/TMS320C64x/TMS320C64xGenInstrInfo.inc +298 -0
  207. package/deps/capstone/arch/TMS320C64x/TMS320C64xGenRegisterInfo.inc +277 -0
  208. package/deps/capstone/arch/TMS320C64x/TMS320C64xInstPrinter.c +572 -0
  209. package/deps/capstone/arch/TMS320C64x/TMS320C64xInstPrinter.h +15 -0
  210. package/deps/capstone/arch/TMS320C64x/TMS320C64xMapping.c +1926 -0
  211. package/deps/capstone/arch/TMS320C64x/TMS320C64xMapping.h +26 -0
  212. package/deps/capstone/arch/TMS320C64x/TMS320C64xModule.c +39 -0
  213. package/deps/capstone/arch/TMS320C64x/TMS320C64xModule.h +12 -0
  214. package/deps/capstone/arch/TriCore/TriCore.td +134 -0
  215. package/deps/capstone/arch/TriCore/TriCoreCallingConv.td +61 -0
  216. package/deps/capstone/arch/TriCore/TriCoreDisassembler.c +1655 -0
  217. package/deps/capstone/arch/TriCore/TriCoreDisassembler.h +18 -0
  218. package/deps/capstone/arch/TriCore/TriCoreGenAsmWriter.inc +3691 -0
  219. package/deps/capstone/arch/TriCore/TriCoreGenCSFeatureName.inc +22 -0
  220. package/deps/capstone/arch/TriCore/TriCoreGenCSMappingInsn.inc +8938 -0
  221. package/deps/capstone/arch/TriCore/TriCoreGenCSMappingInsnName.inc +404 -0
  222. package/deps/capstone/arch/TriCore/TriCoreGenCSMappingInsnOp.inc +7994 -0
  223. package/deps/capstone/arch/TriCore/TriCoreGenCSOpGroup.inc +32 -0
  224. package/deps/capstone/arch/TriCore/TriCoreGenDisassemblerTables.inc +4044 -0
  225. package/deps/capstone/arch/TriCore/TriCoreGenInstrInfo.inc +2693 -0
  226. package/deps/capstone/arch/TriCore/TriCoreGenRegisterInfo.inc +295 -0
  227. package/deps/capstone/arch/TriCore/TriCoreGenSubtargetInfo.inc +40 -0
  228. package/deps/capstone/arch/TriCore/TriCoreInstPrinter.c +488 -0
  229. package/deps/capstone/arch/TriCore/TriCoreInstrFormats.td +773 -0
  230. package/deps/capstone/arch/TriCore/TriCoreInstrInfo.td +1873 -0
  231. package/deps/capstone/arch/TriCore/TriCoreLinkage.h +21 -0
  232. package/deps/capstone/arch/TriCore/TriCoreMapping.c +241 -0
  233. package/deps/capstone/arch/TriCore/TriCoreMapping.h +32 -0
  234. package/deps/capstone/arch/TriCore/TriCoreModule.c +44 -0
  235. package/deps/capstone/arch/TriCore/TriCoreModule.h +11 -0
  236. package/deps/capstone/arch/TriCore/TriCoreRegisterInfo.td +153 -0
  237. package/deps/capstone/arch/WASM/WASMDisassembler.c +1009 -0
  238. package/deps/capstone/arch/WASM/WASMDisassembler.h +12 -0
  239. package/deps/capstone/arch/WASM/WASMInstPrinter.c +47 -0
  240. package/deps/capstone/arch/WASM/WASMInstPrinter.h +18 -0
  241. package/deps/capstone/arch/WASM/WASMMapping.c +333 -0
  242. package/deps/capstone/arch/WASM/WASMMapping.h +9 -0
  243. package/deps/capstone/arch/WASM/WASMModule.c +33 -0
  244. package/deps/capstone/arch/WASM/WASMModule.h +12 -0
  245. package/deps/capstone/arch/X86/X86ATTInstPrinter.c +997 -0
  246. package/deps/capstone/arch/X86/X86BaseInfo.h +50 -0
  247. package/deps/capstone/arch/X86/X86Disassembler.c +1033 -0
  248. package/deps/capstone/arch/X86/X86Disassembler.h +28 -0
  249. package/deps/capstone/arch/X86/X86DisassemblerDecoder.c +2358 -0
  250. package/deps/capstone/arch/X86/X86DisassemblerDecoder.h +725 -0
  251. package/deps/capstone/arch/X86/X86DisassemblerDecoderCommon.h +483 -0
  252. package/deps/capstone/arch/X86/X86GenAsmWriter.inc +49199 -0
  253. package/deps/capstone/arch/X86/X86GenAsmWriter1.inc +33196 -0
  254. package/deps/capstone/arch/X86/X86GenAsmWriter1_reduce.inc +2531 -0
  255. package/deps/capstone/arch/X86/X86GenAsmWriter_reduce.inc +2855 -0
  256. package/deps/capstone/arch/X86/X86GenDisassemblerTables.inc +112961 -0
  257. package/deps/capstone/arch/X86/X86GenDisassemblerTables2.inc +102151 -0
  258. package/deps/capstone/arch/X86/X86GenDisassemblerTables_reduce.inc +28047 -0
  259. package/deps/capstone/arch/X86/X86GenDisassemblerTables_reduce2.inc +18827 -0
  260. package/deps/capstone/arch/X86/X86GenInstrInfo.inc +15158 -0
  261. package/deps/capstone/arch/X86/X86GenInstrInfo_reduce.inc +1564 -0
  262. package/deps/capstone/arch/X86/X86GenRegisterInfo.inc +1549 -0
  263. package/deps/capstone/arch/X86/X86GenRegisterName.inc +292 -0
  264. package/deps/capstone/arch/X86/X86GenRegisterName1.inc +291 -0
  265. package/deps/capstone/arch/X86/X86ImmSize.inc +335 -0
  266. package/deps/capstone/arch/X86/X86InstPrinter.h +26 -0
  267. package/deps/capstone/arch/X86/X86InstPrinterCommon.c +116 -0
  268. package/deps/capstone/arch/X86/X86InstPrinterCommon.h +16 -0
  269. package/deps/capstone/arch/X86/X86IntelInstPrinter.c +1061 -0
  270. package/deps/capstone/arch/X86/X86Lookup16.inc +16874 -0
  271. package/deps/capstone/arch/X86/X86Lookup16_reduce.inc +2308 -0
  272. package/deps/capstone/arch/X86/X86Mapping.c +2266 -0
  273. package/deps/capstone/arch/X86/X86Mapping.h +96 -0
  274. package/deps/capstone/arch/X86/X86MappingInsn.inc +105977 -0
  275. package/deps/capstone/arch/X86/X86MappingInsnName.inc +1527 -0
  276. package/deps/capstone/arch/X86/X86MappingInsnName_reduce.inc +348 -0
  277. package/deps/capstone/arch/X86/X86MappingInsnOp.inc +75700 -0
  278. package/deps/capstone/arch/X86/X86MappingInsnOp_reduce.inc +7729 -0
  279. package/deps/capstone/arch/X86/X86MappingInsn_reduce.inc +10819 -0
  280. package/deps/capstone/arch/X86/X86MappingReg.inc +280 -0
  281. package/deps/capstone/arch/X86/X86Module.c +94 -0
  282. package/deps/capstone/arch/X86/X86Module.h +12 -0
  283. package/deps/capstone/arch/XCore/XCoreDisassembler.c +794 -0
  284. package/deps/capstone/arch/XCore/XCoreDisassembler.h +17 -0
  285. package/deps/capstone/arch/XCore/XCoreGenAsmWriter.inc +772 -0
  286. package/deps/capstone/arch/XCore/XCoreGenDisassemblerTables.inc +853 -0
  287. package/deps/capstone/arch/XCore/XCoreGenInstrInfo.inc +267 -0
  288. package/deps/capstone/arch/XCore/XCoreGenRegisterInfo.inc +110 -0
  289. package/deps/capstone/arch/XCore/XCoreInstPrinter.c +250 -0
  290. package/deps/capstone/arch/XCore/XCoreInstPrinter.h +18 -0
  291. package/deps/capstone/arch/XCore/XCoreMapping.c +297 -0
  292. package/deps/capstone/arch/XCore/XCoreMapping.h +26 -0
  293. package/deps/capstone/arch/XCore/XCoreMappingInsn.inc +1287 -0
  294. package/deps/capstone/arch/XCore/XCoreModule.c +41 -0
  295. package/deps/capstone/arch/XCore/XCoreModule.h +12 -0
  296. package/deps/capstone/cs.c +1664 -0
  297. package/deps/capstone/cs_priv.h +101 -0
  298. package/deps/capstone/cs_simple_types.h +886 -0
  299. package/deps/capstone/include/capstone/arm.h +991 -0
  300. package/deps/capstone/include/capstone/arm64.h +3159 -0
  301. package/deps/capstone/include/capstone/bpf.h +209 -0
  302. package/deps/capstone/include/capstone/capstone.h +875 -0
  303. package/deps/capstone/include/capstone/evm.h +188 -0
  304. package/deps/capstone/include/capstone/m680x.h +537 -0
  305. package/deps/capstone/include/capstone/m68k.h +613 -0
  306. package/deps/capstone/include/capstone/mips.h +956 -0
  307. package/deps/capstone/include/capstone/mos65xx.h +204 -0
  308. package/deps/capstone/include/capstone/platform.h +122 -0
  309. package/deps/capstone/include/capstone/ppc.h +2108 -0
  310. package/deps/capstone/include/capstone/riscv.h +531 -0
  311. package/deps/capstone/include/capstone/sh.h +465 -0
  312. package/deps/capstone/include/capstone/sparc.h +520 -0
  313. package/deps/capstone/include/capstone/systemz.h +2601 -0
  314. package/deps/capstone/include/capstone/tms320c64x.h +359 -0
  315. package/deps/capstone/include/capstone/tricore.h +567 -0
  316. package/deps/capstone/include/capstone/wasm.h +250 -0
  317. package/deps/capstone/include/capstone/x86.h +1986 -0
  318. package/deps/capstone/include/capstone/xcore.h +235 -0
  319. package/deps/capstone/include/platform.h +110 -0
  320. package/deps/capstone/include/windowsce/intrin.h +12 -0
  321. package/deps/capstone/include/windowsce/stdint.h +133 -0
  322. package/deps/capstone/utils.c +140 -0
  323. package/deps/capstone/utils.h +54 -0
  324. package/index.d.ts +448 -0
  325. package/index.js +64 -0
  326. package/index.mjs +25 -0
  327. package/package.json +82 -0
  328. package/prebuilds/win32-x64/hexcore-capstone.node +0 -0
  329. package/src/capstone_wrapper.cpp +910 -0
  330. package/src/capstone_wrapper.h +147 -0
  331. package/src/disasm_async_worker.h +215 -0
  332. package/src/main.cpp +145 -0
@@ -0,0 +1,945 @@
1
+ //===- AArch64AddressingModes.h - AArch64 Addressing Modes ------*- C++ -*-===//
2
+ //
3
+ // The LLVM Compiler Infrastructure
4
+ //
5
+ // This file is distributed under the University of Illinois Open Source
6
+ // License. See LICENSE.TXT for details.
7
+ //
8
+ //===----------------------------------------------------------------------===//
9
+ //
10
+ // This file contains the AArch64 addressing mode implementation stuff.
11
+ //
12
+ //===----------------------------------------------------------------------===//
13
+
14
+ #ifndef CS_AARCH64_ADDRESSINGMODES_H
15
+ #define CS_AARCH64_ADDRESSINGMODES_H
16
+
17
+ /* Capstone Disassembly Engine */
18
+ /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
19
+
20
+ #include "../../MathExtras.h"
21
+
22
+ /// AArch64_AM - AArch64 Addressing Mode Stuff
23
+
24
+ //===----------------------------------------------------------------------===//
25
+ // Shifts
26
+ //
27
+ typedef enum AArch64_AM_ShiftExtendType {
28
+ AArch64_AM_InvalidShiftExtend = -1,
29
+ AArch64_AM_LSL = 0,
30
+ AArch64_AM_LSR,
31
+ AArch64_AM_ASR,
32
+ AArch64_AM_ROR,
33
+ AArch64_AM_MSL,
34
+
35
+ AArch64_AM_UXTB,
36
+ AArch64_AM_UXTH,
37
+ AArch64_AM_UXTW,
38
+ AArch64_AM_UXTX,
39
+
40
+ AArch64_AM_SXTB,
41
+ AArch64_AM_SXTH,
42
+ AArch64_AM_SXTW,
43
+ AArch64_AM_SXTX,
44
+ } AArch64_AM_ShiftExtendType;
45
+
46
+ /// getShiftName - Get the string encoding for the shift type.
47
+ static inline const char *AArch64_AM_getShiftExtendName(AArch64_AM_ShiftExtendType ST)
48
+ {
49
+ switch (ST) {
50
+ default: return NULL; // never reach
51
+ case AArch64_AM_LSL: return "lsl";
52
+ case AArch64_AM_LSR: return "lsr";
53
+ case AArch64_AM_ASR: return "asr";
54
+ case AArch64_AM_ROR: return "ror";
55
+ case AArch64_AM_MSL: return "msl";
56
+ case AArch64_AM_UXTB: return "uxtb";
57
+ case AArch64_AM_UXTH: return "uxth";
58
+ case AArch64_AM_UXTW: return "uxtw";
59
+ case AArch64_AM_UXTX: return "uxtx";
60
+ case AArch64_AM_SXTB: return "sxtb";
61
+ case AArch64_AM_SXTH: return "sxth";
62
+ case AArch64_AM_SXTW: return "sxtw";
63
+ case AArch64_AM_SXTX: return "sxtx";
64
+ }
65
+ }
66
+
67
+ /// getShiftType - Extract the shift type.
68
+ static inline AArch64_AM_ShiftExtendType AArch64_AM_getShiftType(unsigned Imm)
69
+ {
70
+ switch ((Imm >> 6) & 0x7) {
71
+ default: return AArch64_AM_InvalidShiftExtend;
72
+ case 0: return AArch64_AM_LSL;
73
+ case 1: return AArch64_AM_LSR;
74
+ case 2: return AArch64_AM_ASR;
75
+ case 3: return AArch64_AM_ROR;
76
+ case 4: return AArch64_AM_MSL;
77
+ }
78
+ }
79
+
80
+ /// getShiftValue - Extract the shift value.
81
+ static inline unsigned AArch64_AM_getShiftValue(unsigned Imm)
82
+ {
83
+ return Imm & 0x3f;
84
+ }
85
+
86
+ static inline unsigned AArch64_AM_getShifterImm(AArch64_AM_ShiftExtendType ST, unsigned Imm)
87
+ {
88
+ // assert((Imm & 0x3f) == Imm && "Illegal shifted immedate value!");
89
+ unsigned STEnc = 0;
90
+
91
+ switch (ST) {
92
+ default: // llvm_unreachable("Invalid shift requested");
93
+ case AArch64_AM_LSL: STEnc = 0; break;
94
+ case AArch64_AM_LSR: STEnc = 1; break;
95
+ case AArch64_AM_ASR: STEnc = 2; break;
96
+ case AArch64_AM_ROR: STEnc = 3; break;
97
+ case AArch64_AM_MSL: STEnc = 4; break;
98
+ }
99
+
100
+ return (STEnc << 6) | (Imm & 0x3f);
101
+ }
102
+
103
+ //===----------------------------------------------------------------------===//
104
+ // Extends
105
+ //
106
+
107
+ /// getArithShiftValue - get the arithmetic shift value.
108
+ static inline unsigned AArch64_AM_getArithShiftValue(unsigned Imm)
109
+ {
110
+ return Imm & 0x7;
111
+ }
112
+
113
+ /// getExtendType - Extract the extend type for operands of arithmetic ops.
114
+ static inline AArch64_AM_ShiftExtendType AArch64_AM_getExtendType(unsigned Imm)
115
+ {
116
+ // assert((Imm & 0x7) == Imm && "invalid immediate!");
117
+ switch (Imm) {
118
+ default: // llvm_unreachable("Compiler bug!");
119
+ case 0: return AArch64_AM_UXTB;
120
+ case 1: return AArch64_AM_UXTH;
121
+ case 2: return AArch64_AM_UXTW;
122
+ case 3: return AArch64_AM_UXTX;
123
+ case 4: return AArch64_AM_SXTB;
124
+ case 5: return AArch64_AM_SXTH;
125
+ case 6: return AArch64_AM_SXTW;
126
+ case 7: return AArch64_AM_SXTX;
127
+ }
128
+ }
129
+
130
+ static inline AArch64_AM_ShiftExtendType AArch64_AM_getArithExtendType(unsigned Imm)
131
+ {
132
+ return AArch64_AM_getExtendType((Imm >> 3) & 0x7);
133
+ }
134
+
135
+ /// Mapping from extend bits to required operation:
136
+ /// shifter: 000 ==> uxtb
137
+ /// 001 ==> uxth
138
+ /// 010 ==> uxtw
139
+ /// 011 ==> uxtx
140
+ /// 100 ==> sxtb
141
+ /// 101 ==> sxth
142
+ /// 110 ==> sxtw
143
+ /// 111 ==> sxtx
144
+ static inline unsigned AArch64_AM_getExtendEncoding(AArch64_AM_ShiftExtendType ET)
145
+ {
146
+ switch (ET) {
147
+ default: // llvm_unreachable("Invalid extend type requested");
148
+ case AArch64_AM_UXTB: return 0; break;
149
+ case AArch64_AM_UXTH: return 1; break;
150
+ case AArch64_AM_UXTW: return 2; break;
151
+ case AArch64_AM_UXTX: return 3; break;
152
+ case AArch64_AM_SXTB: return 4; break;
153
+ case AArch64_AM_SXTH: return 5; break;
154
+ case AArch64_AM_SXTW: return 6; break;
155
+ case AArch64_AM_SXTX: return 7; break;
156
+ }
157
+ }
158
+
159
+ /// getArithExtendImm - Encode the extend type and shift amount for an
160
+ /// arithmetic instruction:
161
+ /// imm: 3-bit extend amount
162
+ /// {5-3} = shifter
163
+ /// {2-0} = imm3
164
+ static inline unsigned AArch64_AM_getArithExtendImm(AArch64_AM_ShiftExtendType ET, unsigned Imm)
165
+ {
166
+ // assert((Imm & 0x7) == Imm && "Illegal shifted immedate value!");
167
+ return (AArch64_AM_getExtendEncoding(ET) << 3) | (Imm & 0x7);
168
+ }
169
+
170
+ /// getMemDoShift - Extract the "do shift" flag value for load/store
171
+ /// instructions.
172
+ static inline bool AArch64_AM_getMemDoShift(unsigned Imm)
173
+ {
174
+ return (Imm & 0x1) != 0;
175
+ }
176
+
177
+ /// getExtendType - Extract the extend type for the offset operand of
178
+ /// loads/stores.
179
+ static inline AArch64_AM_ShiftExtendType AArch64_AM_getMemExtendType(unsigned Imm)
180
+ {
181
+ return AArch64_AM_getExtendType((Imm >> 1) & 0x7);
182
+ }
183
+
184
+ static inline uint64_t ror(uint64_t elt, unsigned size)
185
+ {
186
+ return ((elt & 1) << (size-1)) | (elt >> 1);
187
+ }
188
+
189
+ /// processLogicalImmediate - Determine if an immediate value can be encoded
190
+ /// as the immediate operand of a logical instruction for the given register
191
+ /// size. If so, return true with "encoding" set to the encoded value in
192
+ /// the form N:immr:imms.
193
+ static inline bool AArch64_AM_processLogicalImmediate(uint64_t Imm, unsigned RegSize, uint64_t *Encoding)
194
+ {
195
+ unsigned Size, Immr, N;
196
+ uint32_t CTO, I;
197
+ uint64_t Mask, NImms;
198
+
199
+ if (Imm == 0ULL || Imm == ~0ULL ||
200
+ (RegSize != 64 && (Imm >> RegSize != 0 || Imm == (~0ULL >> (64 - RegSize))))) {
201
+ return false;
202
+ }
203
+
204
+ // First, determine the element size.
205
+ Size = RegSize;
206
+ do {
207
+ uint64_t Mask;
208
+
209
+ Size /= 2;
210
+ Mask = (1ULL << Size) - 1;
211
+ if ((Imm & Mask) != ((Imm >> Size) & Mask)) {
212
+ Size *= 2;
213
+ break;
214
+ }
215
+ } while (Size > 2);
216
+
217
+ // Second, determine the rotation to make the element be: 0^m 1^n.
218
+ Mask = ((uint64_t)-1LL) >> (64 - Size);
219
+ Imm &= Mask;
220
+
221
+ if (isShiftedMask_64(Imm)) {
222
+ I = CountTrailingZeros_32(Imm);
223
+ // assert(I < 64 && "undefined behavior");
224
+ CTO = CountTrailingOnes_32(Imm >> I);
225
+ } else {
226
+ unsigned CLO;
227
+
228
+ Imm |= ~Mask;
229
+ if (!isShiftedMask_64(~Imm))
230
+ return false;
231
+
232
+ CLO = CountLeadingOnes_32(Imm);
233
+ I = 64 - CLO;
234
+ CTO = CLO + CountTrailingOnes_32(Imm) - (64 - Size);
235
+ }
236
+
237
+ // Encode in Immr the number of RORs it would take to get *from* 0^m 1^n
238
+ // to our target value, where I is the number of RORs to go the opposite
239
+ // direction.
240
+ // assert(Size > I && "I should be smaller than element size");
241
+ Immr = (Size - I) & (Size - 1);
242
+
243
+ // If size has a 1 in the n'th bit, create a value that has zeroes in
244
+ // bits [0, n] and ones above that.
245
+ NImms = ~(Size-1) << 1;
246
+
247
+ // Or the CTO value into the low bits, which must be below the Nth bit
248
+ // bit mentioned above.
249
+ NImms |= (CTO-1);
250
+
251
+ // Extract the seventh bit and toggle it to create the N field.
252
+ N = ((NImms >> 6) & 1) ^ 1;
253
+
254
+ *Encoding = (N << 12) | (Immr << 6) | (NImms & 0x3f);
255
+
256
+ return true;
257
+ }
258
+
259
+ /// isLogicalImmediate - Return true if the immediate is valid for a logical
260
+ /// immediate instruction of the given register size. Return false otherwise.
261
+ static inline bool isLogicalImmediate(uint64_t imm, unsigned regSize)
262
+ {
263
+ uint64_t encoding;
264
+ return AArch64_AM_processLogicalImmediate(imm, regSize, &encoding);
265
+ }
266
+
267
+ /// encodeLogicalImmediate - Return the encoded immediate value for a logical
268
+ /// immediate instruction of the given register size.
269
+ static inline uint64_t AArch64_AM_encodeLogicalImmediate(uint64_t imm, unsigned regSize)
270
+ {
271
+ uint64_t encoding = 0;
272
+
273
+ bool res = AArch64_AM_processLogicalImmediate(imm, regSize, &encoding);
274
+ // assert(res && "invalid logical immediate");
275
+ (void)res;
276
+
277
+ return encoding;
278
+ }
279
+
280
+ /// decodeLogicalImmediate - Decode a logical immediate value in the form
281
+ /// "N:immr:imms" (where the immr and imms fields are each 6 bits) into the
282
+ /// integer value it represents with regSize bits.
283
+ static inline uint64_t AArch64_AM_decodeLogicalImmediate(uint64_t val, unsigned regSize)
284
+ {
285
+ // Extract the N, imms, and immr fields.
286
+ unsigned N = (val >> 12) & 1;
287
+ unsigned immr = (val >> 6) & 0x3f;
288
+ unsigned imms = val & 0x3f;
289
+ unsigned i, size, R, S;
290
+ uint64_t pattern;
291
+
292
+ // assert((regSize == 64 || N == 0) && "undefined logical immediate encoding");
293
+ int len = 31 - CountLeadingZeros_32((N << 6) | (~imms & 0x3f));
294
+
295
+ // assert(len >= 0 && "undefined logical immediate encoding");
296
+ size = (1 << len);
297
+ R = immr & (size - 1);
298
+ S = imms & (size - 1);
299
+
300
+ // assert(S != size - 1 && "undefined logical immediate encoding");
301
+ pattern = (1ULL << (S + 1)) - 1;
302
+
303
+ for (i = 0; i < R; ++i)
304
+ pattern = ror(pattern, size);
305
+
306
+ // Replicate the pattern to fill the regSize.
307
+ while (size != regSize) {
308
+ pattern |= (pattern << size);
309
+ size *= 2;
310
+ }
311
+
312
+ return pattern;
313
+ }
314
+
315
+ /// isValidDecodeLogicalImmediate - Check to see if the logical immediate value
316
+ /// in the form "N:immr:imms" (where the immr and imms fields are each 6 bits)
317
+ /// is a valid encoding for an integer value with regSize bits.
318
+ static inline bool AArch64_AM_isValidDecodeLogicalImmediate(uint64_t val, unsigned regSize)
319
+ {
320
+ unsigned size, S;
321
+ int len;
322
+ // Extract the N and imms fields needed for checking.
323
+ unsigned N = (val >> 12) & 1;
324
+ unsigned imms = val & 0x3f;
325
+
326
+ if (regSize == 32 && N != 0) // undefined logical immediate encoding
327
+ return false;
328
+ len = 31 - CountLeadingZeros_32((N << 6) | (~imms & 0x3f));
329
+ if (len < 0) // undefined logical immediate encoding
330
+ return false;
331
+ size = (1 << len);
332
+ S = imms & (size - 1);
333
+ if (S == size - 1) // undefined logical immediate encoding
334
+ return false;
335
+
336
+ return true;
337
+ }
338
+
339
+ //===----------------------------------------------------------------------===//
340
+ // Floating-point Immediates
341
+ //
342
+ static inline float AArch64_AM_getFPImmFloat(unsigned Imm)
343
+ {
344
+ // We expect an 8-bit binary encoding of a floating-point number here.
345
+ union {
346
+ uint32_t I;
347
+ float F;
348
+ } FPUnion;
349
+
350
+ uint8_t Sign = (Imm >> 7) & 0x1;
351
+ uint8_t Exp = (Imm >> 4) & 0x7;
352
+ uint8_t Mantissa = Imm & 0xf;
353
+
354
+ // 8-bit FP iEEEE Float Encoding
355
+ // abcd efgh aBbbbbbc defgh000 00000000 00000000
356
+ //
357
+ // where B = NOT(b);
358
+
359
+ FPUnion.I = 0;
360
+ FPUnion.I |= ((uint32_t)Sign) << 31;
361
+ FPUnion.I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
362
+ FPUnion.I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
363
+ FPUnion.I |= (Exp & 0x3) << 23;
364
+ FPUnion.I |= Mantissa << 19;
365
+
366
+ return FPUnion.F;
367
+ }
368
+
369
+ //===--------------------------------------------------------------------===//
370
+ // AdvSIMD Modified Immediates
371
+ //===--------------------------------------------------------------------===//
372
+
373
+ // 0x00 0x00 0x00 abcdefgh 0x00 0x00 0x00 abcdefgh
374
+ static inline bool AArch64_AM_isAdvSIMDModImmType1(uint64_t Imm)
375
+ {
376
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
377
+ ((Imm & 0xffffff00ffffff00ULL) == 0);
378
+ }
379
+
380
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType1(uint64_t Imm)
381
+ {
382
+ return (Imm & 0xffULL);
383
+ }
384
+
385
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType1(uint8_t Imm)
386
+ {
387
+ uint64_t EncVal = Imm;
388
+
389
+ return (EncVal << 32) | EncVal;
390
+ }
391
+
392
+ // 0x00 0x00 abcdefgh 0x00 0x00 0x00 abcdefgh 0x00
393
+ static inline bool AArch64_AM_isAdvSIMDModImmType2(uint64_t Imm)
394
+ {
395
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
396
+ ((Imm & 0xffff00ffffff00ffULL) == 0);
397
+ }
398
+
399
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType2(uint64_t Imm)
400
+ {
401
+ return (Imm & 0xff00ULL) >> 8;
402
+ }
403
+
404
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType2(uint8_t Imm)
405
+ {
406
+ uint64_t EncVal = Imm;
407
+ return (EncVal << 40) | (EncVal << 8);
408
+ }
409
+
410
+ // 0x00 abcdefgh 0x00 0x00 0x00 abcdefgh 0x00 0x00
411
+ static inline bool AArch64_AM_isAdvSIMDModImmType3(uint64_t Imm)
412
+ {
413
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
414
+ ((Imm & 0xff00ffffff00ffffULL) == 0);
415
+ }
416
+
417
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType3(uint64_t Imm)
418
+ {
419
+ return (Imm & 0xff0000ULL) >> 16;
420
+ }
421
+
422
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType3(uint8_t Imm)
423
+ {
424
+ uint64_t EncVal = Imm;
425
+ return (EncVal << 48) | (EncVal << 16);
426
+ }
427
+
428
+ // abcdefgh 0x00 0x00 0x00 abcdefgh 0x00 0x00 0x00
429
+ static inline bool AArch64_AM_isAdvSIMDModImmType4(uint64_t Imm)
430
+ {
431
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
432
+ ((Imm & 0x00ffffff00ffffffULL) == 0);
433
+ }
434
+
435
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType4(uint64_t Imm)
436
+ {
437
+ return (Imm & 0xff000000ULL) >> 24;
438
+ }
439
+
440
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType4(uint8_t Imm)
441
+ {
442
+ uint64_t EncVal = Imm;
443
+ return (EncVal << 56) | (EncVal << 24);
444
+ }
445
+
446
+ // 0x00 abcdefgh 0x00 abcdefgh 0x00 abcdefgh 0x00 abcdefgh
447
+ static inline bool AArch64_AM_isAdvSIMDModImmType5(uint64_t Imm)
448
+ {
449
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
450
+ (((Imm & 0x00ff0000ULL) >> 16) == (Imm & 0x000000ffULL)) &&
451
+ ((Imm & 0xff00ff00ff00ff00ULL) == 0);
452
+ }
453
+
454
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType5(uint64_t Imm)
455
+ {
456
+ return (Imm & 0xffULL);
457
+ }
458
+
459
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType5(uint8_t Imm)
460
+ {
461
+ uint64_t EncVal = Imm;
462
+ return (EncVal << 48) | (EncVal << 32) | (EncVal << 16) | EncVal;
463
+ }
464
+
465
+ // abcdefgh 0x00 abcdefgh 0x00 abcdefgh 0x00 abcdefgh 0x00
466
+ static inline bool AArch64_AM_isAdvSIMDModImmType6(uint64_t Imm)
467
+ {
468
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
469
+ (((Imm & 0xff000000ULL) >> 16) == (Imm & 0x0000ff00ULL)) &&
470
+ ((Imm & 0x00ff00ff00ff00ffULL) == 0);
471
+ }
472
+
473
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType6(uint64_t Imm)
474
+ {
475
+ return (Imm & 0xff00ULL) >> 8;
476
+ }
477
+
478
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType6(uint8_t Imm)
479
+ {
480
+ uint64_t EncVal = Imm;
481
+ return (EncVal << 56) | (EncVal << 40) | (EncVal << 24) | (EncVal << 8);
482
+ }
483
+
484
+ // 0x00 0x00 abcdefgh 0xFF 0x00 0x00 abcdefgh 0xFF
485
+ static inline bool AArch64_AM_isAdvSIMDModImmType7(uint64_t Imm)
486
+ {
487
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
488
+ ((Imm & 0xffff00ffffff00ffULL) == 0x000000ff000000ffULL);
489
+ }
490
+
491
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType7(uint64_t Imm)
492
+ {
493
+ return (Imm & 0xff00ULL) >> 8;
494
+ }
495
+
496
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType7(uint8_t Imm)
497
+ {
498
+ uint64_t EncVal = Imm;
499
+ return (EncVal << 40) | (EncVal << 8) | 0x000000ff000000ffULL;
500
+ }
501
+
502
+ // 0x00 abcdefgh 0xFF 0xFF 0x00 abcdefgh 0xFF 0xFF
503
+ static inline bool AArch64_AM_isAdvSIMDModImmType8(uint64_t Imm)
504
+ {
505
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
506
+ ((Imm & 0xff00ffffff00ffffULL) == 0x0000ffff0000ffffULL);
507
+ }
508
+
509
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType8(uint8_t Imm)
510
+ {
511
+ uint64_t EncVal = Imm;
512
+ return (EncVal << 48) | (EncVal << 16) | 0x0000ffff0000ffffULL;
513
+ }
514
+
515
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType8(uint64_t Imm)
516
+ {
517
+ return (Imm & 0x00ff0000ULL) >> 16;
518
+ }
519
+
520
+ // abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh
521
+ static inline bool AArch64_AM_isAdvSIMDModImmType9(uint64_t Imm)
522
+ {
523
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
524
+ ((Imm >> 48) == (Imm & 0x0000ffffULL)) &&
525
+ ((Imm >> 56) == (Imm & 0x000000ffULL));
526
+ }
527
+
528
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType9(uint64_t Imm)
529
+ {
530
+ return (Imm & 0xffULL);
531
+ }
532
+
533
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType9(uint8_t Imm)
534
+ {
535
+ uint64_t EncVal = Imm;
536
+ EncVal |= (EncVal << 8);
537
+ EncVal |= (EncVal << 16);
538
+ EncVal |= (EncVal << 32);
539
+
540
+ return EncVal;
541
+ }
542
+
543
+ // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh
544
+ // cmode: 1110, op: 1
545
+ static inline bool AArch64_AM_isAdvSIMDModImmType10(uint64_t Imm)
546
+ {
547
+ uint64_t ByteA = Imm & 0xff00000000000000ULL;
548
+ uint64_t ByteB = Imm & 0x00ff000000000000ULL;
549
+ uint64_t ByteC = Imm & 0x0000ff0000000000ULL;
550
+ uint64_t ByteD = Imm & 0x000000ff00000000ULL;
551
+ uint64_t ByteE = Imm & 0x00000000ff000000ULL;
552
+ uint64_t ByteF = Imm & 0x0000000000ff0000ULL;
553
+ uint64_t ByteG = Imm & 0x000000000000ff00ULL;
554
+ uint64_t ByteH = Imm & 0x00000000000000ffULL;
555
+
556
+ return (ByteA == 0ULL || ByteA == 0xff00000000000000ULL) &&
557
+ (ByteB == 0ULL || ByteB == 0x00ff000000000000ULL) &&
558
+ (ByteC == 0ULL || ByteC == 0x0000ff0000000000ULL) &&
559
+ (ByteD == 0ULL || ByteD == 0x000000ff00000000ULL) &&
560
+ (ByteE == 0ULL || ByteE == 0x00000000ff000000ULL) &&
561
+ (ByteF == 0ULL || ByteF == 0x0000000000ff0000ULL) &&
562
+ (ByteG == 0ULL || ByteG == 0x000000000000ff00ULL) &&
563
+ (ByteH == 0ULL || ByteH == 0x00000000000000ffULL);
564
+ }
565
+
566
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType10(uint64_t Imm)
567
+ {
568
+ uint8_t BitA = (Imm & 0xff00000000000000ULL) != 0;
569
+ uint8_t BitB = (Imm & 0x00ff000000000000ULL) != 0;
570
+ uint8_t BitC = (Imm & 0x0000ff0000000000ULL) != 0;
571
+ uint8_t BitD = (Imm & 0x000000ff00000000ULL) != 0;
572
+ uint8_t BitE = (Imm & 0x00000000ff000000ULL) != 0;
573
+ uint8_t BitF = (Imm & 0x0000000000ff0000ULL) != 0;
574
+ uint8_t BitG = (Imm & 0x000000000000ff00ULL) != 0;
575
+ uint8_t BitH = (Imm & 0x00000000000000ffULL) != 0;
576
+
577
+ uint8_t EncVal = BitA;
578
+
579
+ EncVal <<= 1;
580
+ EncVal |= BitB;
581
+ EncVal <<= 1;
582
+ EncVal |= BitC;
583
+ EncVal <<= 1;
584
+ EncVal |= BitD;
585
+ EncVal <<= 1;
586
+ EncVal |= BitE;
587
+ EncVal <<= 1;
588
+ EncVal |= BitF;
589
+ EncVal <<= 1;
590
+ EncVal |= BitG;
591
+ EncVal <<= 1;
592
+ EncVal |= BitH;
593
+
594
+ return EncVal;
595
+ }
596
+
597
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType10(uint8_t Imm)
598
+ {
599
+ uint64_t EncVal = 0;
600
+
601
+ if (Imm & 0x80)
602
+ EncVal |= 0xff00000000000000ULL;
603
+
604
+ if (Imm & 0x40)
605
+ EncVal |= 0x00ff000000000000ULL;
606
+
607
+ if (Imm & 0x20)
608
+ EncVal |= 0x0000ff0000000000ULL;
609
+
610
+ if (Imm & 0x10)
611
+ EncVal |= 0x000000ff00000000ULL;
612
+
613
+ if (Imm & 0x08)
614
+ EncVal |= 0x00000000ff000000ULL;
615
+
616
+ if (Imm & 0x04)
617
+ EncVal |= 0x0000000000ff0000ULL;
618
+
619
+ if (Imm & 0x02)
620
+ EncVal |= 0x000000000000ff00ULL;
621
+
622
+ if (Imm & 0x01)
623
+ EncVal |= 0x00000000000000ffULL;
624
+
625
+ return EncVal;
626
+ }
627
+
628
+ // aBbbbbbc defgh000 0x00 0x00 aBbbbbbc defgh000 0x00 0x00
629
+ static inline bool AArch64_AM_isAdvSIMDModImmType11(uint64_t Imm)
630
+ {
631
+ uint64_t BString = (Imm & 0x7E000000ULL) >> 25;
632
+
633
+ return ((Imm >> 32) == (Imm & 0xffffffffULL)) &&
634
+ (BString == 0x1f || BString == 0x20) &&
635
+ ((Imm & 0x0007ffff0007ffffULL) == 0);
636
+ }
637
+
638
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType11(uint64_t Imm)
639
+ {
640
+ uint8_t BitA = (Imm & 0x80000000ULL) != 0;
641
+ uint8_t BitB = (Imm & 0x20000000ULL) != 0;
642
+ uint8_t BitC = (Imm & 0x01000000ULL) != 0;
643
+ uint8_t BitD = (Imm & 0x00800000ULL) != 0;
644
+ uint8_t BitE = (Imm & 0x00400000ULL) != 0;
645
+ uint8_t BitF = (Imm & 0x00200000ULL) != 0;
646
+ uint8_t BitG = (Imm & 0x00100000ULL) != 0;
647
+ uint8_t BitH = (Imm & 0x00080000ULL) != 0;
648
+
649
+ uint8_t EncVal = BitA;
650
+ EncVal <<= 1;
651
+ EncVal |= BitB;
652
+ EncVal <<= 1;
653
+ EncVal |= BitC;
654
+ EncVal <<= 1;
655
+ EncVal |= BitD;
656
+ EncVal <<= 1;
657
+ EncVal |= BitE;
658
+ EncVal <<= 1;
659
+ EncVal |= BitF;
660
+ EncVal <<= 1;
661
+ EncVal |= BitG;
662
+ EncVal <<= 1;
663
+ EncVal |= BitH;
664
+
665
+ return EncVal;
666
+ }
667
+
668
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType11(uint8_t Imm)
669
+ {
670
+ uint64_t EncVal = 0;
671
+
672
+ if (Imm & 0x80)
673
+ EncVal |= 0x80000000ULL;
674
+
675
+ if (Imm & 0x40)
676
+ EncVal |= 0x3e000000ULL;
677
+ else
678
+ EncVal |= 0x40000000ULL;
679
+
680
+ if (Imm & 0x20)
681
+ EncVal |= 0x01000000ULL;
682
+
683
+ if (Imm & 0x10)
684
+ EncVal |= 0x00800000ULL;
685
+
686
+ if (Imm & 0x08)
687
+ EncVal |= 0x00400000ULL;
688
+
689
+ if (Imm & 0x04)
690
+ EncVal |= 0x00200000ULL;
691
+
692
+ if (Imm & 0x02)
693
+ EncVal |= 0x00100000ULL;
694
+
695
+ if (Imm & 0x01)
696
+ EncVal |= 0x00080000ULL;
697
+
698
+ return (EncVal << 32) | EncVal;
699
+ }
700
+
701
+ // aBbbbbbb bbcdefgh 0x00 0x00 0x00 0x00 0x00 0x00
702
+ static inline bool AArch64_AM_isAdvSIMDModImmType12(uint64_t Imm)
703
+ {
704
+ uint64_t BString = (Imm & 0x7fc0000000000000ULL) >> 54;
705
+ return ((BString == 0xff || BString == 0x100) &&
706
+ ((Imm & 0x0000ffffffffffffULL) == 0));
707
+ }
708
+
709
+ static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType12(uint64_t Imm)
710
+ {
711
+ uint8_t BitA = (Imm & 0x8000000000000000ULL) != 0;
712
+ uint8_t BitB = (Imm & 0x0040000000000000ULL) != 0;
713
+ uint8_t BitC = (Imm & 0x0020000000000000ULL) != 0;
714
+ uint8_t BitD = (Imm & 0x0010000000000000ULL) != 0;
715
+ uint8_t BitE = (Imm & 0x0008000000000000ULL) != 0;
716
+ uint8_t BitF = (Imm & 0x0004000000000000ULL) != 0;
717
+ uint8_t BitG = (Imm & 0x0002000000000000ULL) != 0;
718
+ uint8_t BitH = (Imm & 0x0001000000000000ULL) != 0;
719
+
720
+ uint8_t EncVal = BitA;
721
+ EncVal <<= 1;
722
+ EncVal |= BitB;
723
+ EncVal <<= 1;
724
+ EncVal |= BitC;
725
+ EncVal <<= 1;
726
+ EncVal |= BitD;
727
+ EncVal <<= 1;
728
+ EncVal |= BitE;
729
+ EncVal <<= 1;
730
+ EncVal |= BitF;
731
+ EncVal <<= 1;
732
+ EncVal |= BitG;
733
+ EncVal <<= 1;
734
+ EncVal |= BitH;
735
+
736
+ return EncVal;
737
+ }
738
+
739
+ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType12(uint8_t Imm)
740
+ {
741
+ uint64_t EncVal = 0;
742
+ if (Imm & 0x80)
743
+ EncVal |= 0x8000000000000000ULL;
744
+
745
+ if (Imm & 0x40)
746
+ EncVal |= 0x3fc0000000000000ULL;
747
+ else
748
+ EncVal |= 0x4000000000000000ULL;
749
+
750
+ if (Imm & 0x20)
751
+ EncVal |= 0x0020000000000000ULL;
752
+
753
+ if (Imm & 0x10)
754
+ EncVal |= 0x0010000000000000ULL;
755
+
756
+ if (Imm & 0x08)
757
+ EncVal |= 0x0008000000000000ULL;
758
+
759
+ if (Imm & 0x04)
760
+ EncVal |= 0x0004000000000000ULL;
761
+
762
+ if (Imm & 0x02)
763
+ EncVal |= 0x0002000000000000ULL;
764
+
765
+ if (Imm & 0x01)
766
+ EncVal |= 0x0001000000000000ULL;
767
+
768
+ return (EncVal << 32) | EncVal;
769
+ }
770
+
771
+ /// Returns true if Imm is the concatenation of a repeating pattern of type T.
772
+ static inline bool AArch64_AM_isSVEMaskOfIdenticalElements8(int64_t Imm)
773
+ {
774
+ #define _VECSIZE (sizeof(int64_t)/sizeof(int8_t))
775
+ unsigned int i;
776
+ union {
777
+ int64_t Whole;
778
+ int8_t Parts[_VECSIZE];
779
+ } Vec;
780
+
781
+ Vec.Whole = Imm;
782
+
783
+ for(i = 1; i < _VECSIZE; i++) {
784
+ if (Vec.Parts[i] != Vec.Parts[0])
785
+ return false;
786
+ }
787
+ #undef _VECSIZE
788
+
789
+ return true;
790
+ }
791
+
792
+ static inline bool AArch64_AM_isSVEMaskOfIdenticalElements16(int64_t Imm)
793
+ {
794
+ #define _VECSIZE (sizeof(int64_t)/sizeof(int16_t))
795
+ unsigned int i;
796
+ union {
797
+ int64_t Whole;
798
+ int16_t Parts[_VECSIZE];
799
+ } Vec;
800
+
801
+ Vec.Whole = Imm;
802
+
803
+ for(i = 1; i < _VECSIZE; i++) {
804
+ if (Vec.Parts[i] != Vec.Parts[0])
805
+ return false;
806
+ }
807
+ #undef _VECSIZE
808
+
809
+ return true;
810
+ }
811
+
812
+ static inline bool AArch64_AM_isSVEMaskOfIdenticalElements32(int64_t Imm)
813
+ {
814
+ #define _VECSIZE (sizeof(int64_t)/sizeof(int32_t))
815
+ unsigned int i;
816
+ union {
817
+ int64_t Whole;
818
+ int32_t Parts[_VECSIZE];
819
+ } Vec;
820
+
821
+ Vec.Whole = Imm;
822
+
823
+ for(i = 1; i < _VECSIZE; i++) {
824
+ if (Vec.Parts[i] != Vec.Parts[0])
825
+ return false;
826
+ }
827
+ #undef _VECSIZE
828
+
829
+ return true;
830
+ }
831
+
832
+ static inline bool AArch64_AM_isSVEMaskOfIdenticalElements64(int64_t Imm)
833
+ {
834
+ return true;
835
+ }
836
+
837
+ static inline bool isSVECpyImm8(int64_t Imm)
838
+ {
839
+ bool IsImm8 = (int8_t)Imm == Imm;
840
+
841
+ return IsImm8 || (uint8_t)Imm == Imm;
842
+ }
843
+
844
+ static inline bool isSVECpyImm16(int64_t Imm)
845
+ {
846
+ bool IsImm8 = (int8_t)Imm == Imm;
847
+ bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm;
848
+
849
+ return IsImm8 || IsImm16 || (uint16_t)(Imm & ~0xff) == Imm;
850
+ }
851
+
852
+ static inline bool isSVECpyImm32(int64_t Imm)
853
+ {
854
+ bool IsImm8 = (int8_t)Imm == Imm;
855
+ bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm;
856
+
857
+ return IsImm8 || IsImm16;
858
+ }
859
+
860
+ static inline bool isSVECpyImm64(int64_t Imm)
861
+ {
862
+ bool IsImm8 = (int8_t)Imm == Imm;
863
+ bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm;
864
+
865
+ return IsImm8 || IsImm16;
866
+ }
867
+
868
+ /// Return true if Imm is valid for DUPM and has no single CPY/DUP equivalent.
869
+ static inline bool AArch64_AM_isSVEMoveMaskPreferredLogicalImmediate(int64_t Imm)
870
+ {
871
+ union {
872
+ int64_t D;
873
+ int32_t S[2];
874
+ int16_t H[4];
875
+ int8_t B[8];
876
+ } Vec = {Imm};
877
+
878
+ if (isSVECpyImm64(Vec.D))
879
+ return false;
880
+
881
+ if (AArch64_AM_isSVEMaskOfIdenticalElements32(Imm) &&
882
+ isSVECpyImm32(Vec.S[0]))
883
+ return false;
884
+
885
+ if (AArch64_AM_isSVEMaskOfIdenticalElements16(Imm) &&
886
+ isSVECpyImm16(Vec.H[0]))
887
+ return false;
888
+
889
+ if (AArch64_AM_isSVEMaskOfIdenticalElements8(Imm) &&
890
+ isSVECpyImm8(Vec.B[0]))
891
+ return false;
892
+
893
+ return isLogicalImmediate(Vec.D, 64);
894
+ }
895
+
896
+ inline static bool isAnyMOVZMovAlias(uint64_t Value, int RegWidth)
897
+ {
898
+ int Shift;
899
+
900
+ for (Shift = 0; Shift <= RegWidth - 16; Shift += 16)
901
+ if ((Value & ~(0xffffULL << Shift)) == 0)
902
+ return true;
903
+
904
+ return false;
905
+ }
906
+
907
+ inline static bool isMOVZMovAlias(uint64_t Value, int Shift, int RegWidth)
908
+ {
909
+ if (RegWidth == 32)
910
+ Value &= 0xffffffffULL;
911
+
912
+ // "lsl #0" takes precedence: in practice this only affects "#0, lsl #0".
913
+ if (Value == 0 && Shift != 0)
914
+ return false;
915
+
916
+ return (Value & ~(0xffffULL << Shift)) == 0;
917
+ }
918
+
919
+ inline static bool AArch64_AM_isMOVNMovAlias(uint64_t Value, int Shift, int RegWidth)
920
+ {
921
+ // MOVZ takes precedence over MOVN.
922
+ if (isAnyMOVZMovAlias(Value, RegWidth))
923
+ return false;
924
+
925
+ Value = ~Value;
926
+ if (RegWidth == 32)
927
+ Value &= 0xffffffffULL;
928
+
929
+ return isMOVZMovAlias(Value, Shift, RegWidth);
930
+ }
931
+
932
+ inline static bool AArch64_AM_isAnyMOVWMovAlias(uint64_t Value, int RegWidth)
933
+ {
934
+ if (isAnyMOVZMovAlias(Value, RegWidth))
935
+ return true;
936
+
937
+ // It's not a MOVZ, but it might be a MOVN.
938
+ Value = ~Value;
939
+ if (RegWidth == 32)
940
+ Value &= 0xffffffffULL;
941
+
942
+ return isAnyMOVZMovAlias(Value, RegWidth);
943
+ }
944
+
945
+ #endif