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,698 @@
1
+ //===-- ARMAddressingModes.h - ARM 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 ARM addressing mode implementation stuff.
11
+ //
12
+ //===----------------------------------------------------------------------===//
13
+
14
+ /* Capstone Disassembly Engine */
15
+ /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
16
+
17
+ #ifndef CS_LLVM_TARGET_ARM_ARMADDRESSINGMODES_H
18
+ #define CS_LLVM_TARGET_ARM_ARMADDRESSINGMODES_H
19
+
20
+ #include "capstone/platform.h"
21
+ #include "../../MathExtras.h"
22
+
23
+ /// ARM_AM - ARM Addressing Mode Stuff
24
+ typedef enum ARM_AM_ShiftOpc {
25
+ ARM_AM_no_shift = 0,
26
+ ARM_AM_asr,
27
+ ARM_AM_lsl,
28
+ ARM_AM_lsr,
29
+ ARM_AM_ror,
30
+ ARM_AM_rrx
31
+ } ARM_AM_ShiftOpc;
32
+
33
+ typedef enum ARM_AM_AddrOpc {
34
+ ARM_AM_sub = 0,
35
+ ARM_AM_add
36
+ } ARM_AM_AddrOpc;
37
+
38
+ static inline const char *ARM_AM_getAddrOpcStr(ARM_AM_AddrOpc Op)
39
+ {
40
+ return Op == ARM_AM_sub ? "-" : "";
41
+ }
42
+
43
+ static inline const char *ARM_AM_getShiftOpcStr(ARM_AM_ShiftOpc Op)
44
+ {
45
+ switch (Op) {
46
+ default: return ""; //llvm_unreachable("Unknown shift opc!");
47
+ case ARM_AM_asr: return "asr";
48
+ case ARM_AM_lsl: return "lsl";
49
+ case ARM_AM_lsr: return "lsr";
50
+ case ARM_AM_ror: return "ror";
51
+ case ARM_AM_rrx: return "rrx";
52
+ }
53
+ }
54
+
55
+ static inline unsigned ARM_AM_getShiftOpcEncoding(ARM_AM_ShiftOpc Op)
56
+ {
57
+ switch (Op) {
58
+ default: return (unsigned int)-1; //llvm_unreachable("Unknown shift opc!");
59
+ case ARM_AM_asr: return 2;
60
+ case ARM_AM_lsl: return 0;
61
+ case ARM_AM_lsr: return 1;
62
+ case ARM_AM_ror: return 3;
63
+ }
64
+ }
65
+
66
+ typedef enum ARM_AM_AMSubMode {
67
+ ARM_AM_bad_am_submode = 0,
68
+ ARM_AM_ia,
69
+ ARM_AM_ib,
70
+ ARM_AM_da,
71
+ ARM_AM_db
72
+ } ARM_AM_AMSubMode;
73
+
74
+ static inline const char *ARM_AM_getAMSubModeStr(ARM_AM_AMSubMode Mode)
75
+ {
76
+ switch (Mode) {
77
+ default: return "";
78
+ case ARM_AM_ia: return "ia";
79
+ case ARM_AM_ib: return "ib";
80
+ case ARM_AM_da: return "da";
81
+ case ARM_AM_db: return "db";
82
+ }
83
+ }
84
+
85
+ /// rotr32 - Rotate a 32-bit unsigned value right by a specified # bits.
86
+ ///
87
+ static inline unsigned rotr32(unsigned Val, unsigned Amt)
88
+ {
89
+ //assert(Amt < 32 && "Invalid rotate amount");
90
+ return (Val >> Amt) | (Val << ((32-Amt)&31));
91
+ }
92
+
93
+ /// rotl32 - Rotate a 32-bit unsigned value left by a specified # bits.
94
+ ///
95
+ static inline unsigned rotl32(unsigned Val, unsigned Amt)
96
+ {
97
+ //assert(Amt < 32 && "Invalid rotate amount");
98
+ return (Val << Amt) | (Val >> ((32-Amt)&31));
99
+ }
100
+
101
+ //===--------------------------------------------------------------------===//
102
+ // Addressing Mode #1: shift_operand with registers
103
+ //===--------------------------------------------------------------------===//
104
+ //
105
+ // This 'addressing mode' is used for arithmetic instructions. It can
106
+ // represent things like:
107
+ // reg
108
+ // reg [asr|lsl|lsr|ror|rrx] reg
109
+ // reg [asr|lsl|lsr|ror|rrx] imm
110
+ //
111
+ // This is stored three operands [rega, regb, opc]. The first is the base
112
+ // reg, the second is the shift amount (or reg0 if not present or imm). The
113
+ // third operand encodes the shift opcode and the imm if a reg isn't present.
114
+ //
115
+ static inline unsigned getSORegOpc(ARM_AM_ShiftOpc ShOp, unsigned Imm)
116
+ {
117
+ return ShOp | (Imm << 3);
118
+ }
119
+
120
+ static inline unsigned getSORegOffset(unsigned Op)
121
+ {
122
+ return Op >> 3;
123
+ }
124
+
125
+ static inline ARM_AM_ShiftOpc ARM_AM_getSORegShOp(unsigned Op)
126
+ {
127
+ return (ARM_AM_ShiftOpc)(Op & 7);
128
+ }
129
+
130
+ /// getSOImmValImm - Given an encoded imm field for the reg/imm form, return
131
+ /// the 8-bit imm value.
132
+ static inline unsigned getSOImmValImm(unsigned Imm)
133
+ {
134
+ return Imm & 0xFF;
135
+ }
136
+
137
+ /// getSOImmValRot - Given an encoded imm field for the reg/imm form, return
138
+ /// the rotate amount.
139
+ static inline unsigned getSOImmValRot(unsigned Imm)
140
+ {
141
+ return (Imm >> 8) * 2;
142
+ }
143
+
144
+ /// getSOImmValRotate - Try to handle Imm with an immediate shifter operand,
145
+ /// computing the rotate amount to use. If this immediate value cannot be
146
+ /// handled with a single shifter-op, determine a good rotate amount that will
147
+ /// take a maximal chunk of bits out of the immediate.
148
+ static inline unsigned getSOImmValRotate(unsigned Imm)
149
+ {
150
+ unsigned TZ, RotAmt;
151
+ // 8-bit (or less) immediates are trivially shifter_operands with a rotate
152
+ // of zero.
153
+ if ((Imm & ~255U) == 0) return 0;
154
+
155
+ // Use CTZ to compute the rotate amount.
156
+ TZ = CountTrailingZeros_32(Imm);
157
+
158
+ // Rotate amount must be even. Something like 0x200 must be rotated 8 bits,
159
+ // not 9.
160
+ RotAmt = TZ & ~1;
161
+
162
+ // If we can handle this spread, return it.
163
+ if ((rotr32(Imm, RotAmt) & ~255U) == 0)
164
+ return (32-RotAmt)&31; // HW rotates right, not left.
165
+
166
+ // For values like 0xF000000F, we should ignore the low 6 bits, then
167
+ // retry the hunt.
168
+ if (Imm & 63U) {
169
+ unsigned TZ2 = CountTrailingZeros_32(Imm & ~63U);
170
+ unsigned RotAmt2 = TZ2 & ~1;
171
+ if ((rotr32(Imm, RotAmt2) & ~255U) == 0)
172
+ return (32-RotAmt2)&31; // HW rotates right, not left.
173
+ }
174
+
175
+ // Otherwise, we have no way to cover this span of bits with a single
176
+ // shifter_op immediate. Return a chunk of bits that will be useful to
177
+ // handle.
178
+ return (32-RotAmt)&31; // HW rotates right, not left.
179
+ }
180
+
181
+ /// getSOImmVal - Given a 32-bit immediate, if it is something that can fit
182
+ /// into an shifter_operand immediate operand, return the 12-bit encoding for
183
+ /// it. If not, return -1.
184
+ static inline int getSOImmVal(unsigned Arg)
185
+ {
186
+ unsigned RotAmt;
187
+ // 8-bit (or less) immediates are trivially shifter_operands with a rotate
188
+ // of zero.
189
+ if ((Arg & ~255U) == 0) return Arg;
190
+
191
+ RotAmt = getSOImmValRotate(Arg);
192
+
193
+ // If this cannot be handled with a single shifter_op, bail out.
194
+ if (rotr32(~255U, RotAmt) & Arg)
195
+ return -1;
196
+
197
+ // Encode this correctly.
198
+ return rotl32(Arg, RotAmt) | ((RotAmt>>1) << 8);
199
+ }
200
+
201
+ /// isSOImmTwoPartVal - Return true if the specified value can be obtained by
202
+ /// or'ing together two SOImmVal's.
203
+ static inline bool isSOImmTwoPartVal(unsigned V)
204
+ {
205
+ // If this can be handled with a single shifter_op, bail out.
206
+ V = rotr32(~255U, getSOImmValRotate(V)) & V;
207
+ if (V == 0)
208
+ return false;
209
+
210
+ // If this can be handled with two shifter_op's, accept.
211
+ V = rotr32(~255U, getSOImmValRotate(V)) & V;
212
+ return V == 0;
213
+ }
214
+
215
+ /// getSOImmTwoPartFirst - If V is a value that satisfies isSOImmTwoPartVal,
216
+ /// return the first chunk of it.
217
+ static inline unsigned getSOImmTwoPartFirst(unsigned V)
218
+ {
219
+ return rotr32(255U, getSOImmValRotate(V)) & V;
220
+ }
221
+
222
+ /// getSOImmTwoPartSecond - If V is a value that satisfies isSOImmTwoPartVal,
223
+ /// return the second chunk of it.
224
+ static inline unsigned getSOImmTwoPartSecond(unsigned V)
225
+ {
226
+ // Mask out the first hunk.
227
+ V = rotr32(~255U, getSOImmValRotate(V)) & V;
228
+
229
+ // Take what's left.
230
+ //assert(V == (rotr32(255U, getSOImmValRotate(V)) & V));
231
+ return V;
232
+ }
233
+
234
+ /// getThumbImmValShift - Try to handle Imm with a 8-bit immediate followed
235
+ /// by a left shift. Returns the shift amount to use.
236
+ static inline unsigned getThumbImmValShift(unsigned Imm)
237
+ {
238
+ // 8-bit (or less) immediates are trivially immediate operand with a shift
239
+ // of zero.
240
+ if ((Imm & ~255U) == 0) return 0;
241
+
242
+ // Use CTZ to compute the shift amount.
243
+ return CountTrailingZeros_32(Imm);
244
+ }
245
+
246
+ /// isThumbImmShiftedVal - Return true if the specified value can be obtained
247
+ /// by left shifting a 8-bit immediate.
248
+ static inline bool isThumbImmShiftedVal(unsigned V)
249
+ {
250
+ // If this can be handled with
251
+ V = (~255U << getThumbImmValShift(V)) & V;
252
+ return V == 0;
253
+ }
254
+
255
+ /// getThumbImm16ValShift - Try to handle Imm with a 16-bit immediate followed
256
+ /// by a left shift. Returns the shift amount to use.
257
+ static inline unsigned getThumbImm16ValShift(unsigned Imm)
258
+ {
259
+ // 16-bit (or less) immediates are trivially immediate operand with a shift
260
+ // of zero.
261
+ if ((Imm & ~65535U) == 0) return 0;
262
+
263
+ // Use CTZ to compute the shift amount.
264
+ return CountTrailingZeros_32(Imm);
265
+ }
266
+
267
+ /// isThumbImm16ShiftedVal - Return true if the specified value can be
268
+ /// obtained by left shifting a 16-bit immediate.
269
+ static inline bool isThumbImm16ShiftedVal(unsigned V)
270
+ {
271
+ // If this can be handled with
272
+ V = (~65535U << getThumbImm16ValShift(V)) & V;
273
+ return V == 0;
274
+ }
275
+
276
+ /// getThumbImmNonShiftedVal - If V is a value that satisfies
277
+ /// isThumbImmShiftedVal, return the non-shiftd value.
278
+ static inline unsigned getThumbImmNonShiftedVal(unsigned V)
279
+ {
280
+ return V >> getThumbImmValShift(V);
281
+ }
282
+
283
+
284
+ /// getT2SOImmValSplat - Return the 12-bit encoded representation
285
+ /// if the specified value can be obtained by splatting the low 8 bits
286
+ /// into every other byte or every byte of a 32-bit value. i.e.,
287
+ /// 00000000 00000000 00000000 abcdefgh control = 0
288
+ /// 00000000 abcdefgh 00000000 abcdefgh control = 1
289
+ /// abcdefgh 00000000 abcdefgh 00000000 control = 2
290
+ /// abcdefgh abcdefgh abcdefgh abcdefgh control = 3
291
+ /// Return -1 if none of the above apply.
292
+ /// See ARM Reference Manual A6.3.2.
293
+ static inline int getT2SOImmValSplatVal(unsigned V)
294
+ {
295
+ unsigned u, Vs, Imm;
296
+ // control = 0
297
+ if ((V & 0xffffff00) == 0)
298
+ return V;
299
+
300
+ // If the value is zeroes in the first byte, just shift those off
301
+ Vs = ((V & 0xff) == 0) ? V >> 8 : V;
302
+ // Any passing value only has 8 bits of payload, splatted across the word
303
+ Imm = Vs & 0xff;
304
+ // Likewise, any passing values have the payload splatted into the 3rd byte
305
+ u = Imm | (Imm << 16);
306
+
307
+ // control = 1 or 2
308
+ if (Vs == u)
309
+ return (((Vs == V) ? 1 : 2) << 8) | Imm;
310
+
311
+ // control = 3
312
+ if (Vs == (u | (u << 8)))
313
+ return (3 << 8) | Imm;
314
+
315
+ return -1;
316
+ }
317
+
318
+ /// getT2SOImmValRotateVal - Return the 12-bit encoded representation if the
319
+ /// specified value is a rotated 8-bit value. Return -1 if no rotation
320
+ /// encoding is possible.
321
+ /// See ARM Reference Manual A6.3.2.
322
+ static inline int getT2SOImmValRotateVal(unsigned V)
323
+ {
324
+ unsigned RotAmt = CountLeadingZeros_32(V);
325
+ if (RotAmt >= 24)
326
+ return -1;
327
+
328
+ // If 'Arg' can be handled with a single shifter_op return the value.
329
+ if ((rotr32(0xff000000U, RotAmt) & V) == V)
330
+ return (rotr32(V, 24 - RotAmt) & 0x7f) | ((RotAmt + 8) << 7);
331
+
332
+ return -1;
333
+ }
334
+
335
+ /// getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit
336
+ /// into a Thumb-2 shifter_operand immediate operand, return the 12-bit
337
+ /// encoding for it. If not, return -1.
338
+ /// See ARM Reference Manual A6.3.2.
339
+ static inline int getT2SOImmVal(unsigned Arg)
340
+ {
341
+ int Rot;
342
+ // If 'Arg' is an 8-bit splat, then get the encoded value.
343
+ int Splat = getT2SOImmValSplatVal(Arg);
344
+ if (Splat != -1)
345
+ return Splat;
346
+
347
+ // If 'Arg' can be handled with a single shifter_op return the value.
348
+ Rot = getT2SOImmValRotateVal(Arg);
349
+ if (Rot != -1)
350
+ return Rot;
351
+
352
+ return -1;
353
+ }
354
+
355
+ static inline unsigned getT2SOImmValRotate(unsigned V)
356
+ {
357
+ unsigned RotAmt;
358
+
359
+ if ((V & ~255U) == 0)
360
+ return 0;
361
+
362
+ // Use CTZ to compute the rotate amount.
363
+ RotAmt = CountTrailingZeros_32(V);
364
+ return (32 - RotAmt) & 31;
365
+ }
366
+
367
+ static inline bool isT2SOImmTwoPartVal (unsigned Imm)
368
+ {
369
+ unsigned V = Imm;
370
+ // Passing values can be any combination of splat values and shifter
371
+ // values. If this can be handled with a single shifter or splat, bail
372
+ // out. Those should be handled directly, not with a two-part val.
373
+ if (getT2SOImmValSplatVal(V) != -1)
374
+ return false;
375
+ V = rotr32 (~255U, getT2SOImmValRotate(V)) & V;
376
+ if (V == 0)
377
+ return false;
378
+
379
+ // If this can be handled as an immediate, accept.
380
+ if (getT2SOImmVal(V) != -1) return true;
381
+
382
+ // Likewise, try masking out a splat value first.
383
+ V = Imm;
384
+ if (getT2SOImmValSplatVal(V & 0xff00ff00U) != -1)
385
+ V &= ~0xff00ff00U;
386
+ else if (getT2SOImmValSplatVal(V & 0x00ff00ffU) != -1)
387
+ V &= ~0x00ff00ffU;
388
+ // If what's left can be handled as an immediate, accept.
389
+ if (getT2SOImmVal(V) != -1) return true;
390
+
391
+ // Otherwise, do not accept.
392
+ return false;
393
+ }
394
+
395
+ static inline unsigned getT2SOImmTwoPartFirst(unsigned Imm)
396
+ {
397
+ //assert (isT2SOImmTwoPartVal(Imm) &&
398
+ // "Immedate cannot be encoded as two part immediate!");
399
+ // Try a shifter operand as one part
400
+ unsigned V = rotr32 (~(unsigned int)255, getT2SOImmValRotate(Imm)) & Imm;
401
+ // If the rest is encodable as an immediate, then return it.
402
+ if (getT2SOImmVal(V) != -1) return V;
403
+
404
+ // Try masking out a splat value first.
405
+ if (getT2SOImmValSplatVal(Imm & 0xff00ff00U) != -1)
406
+ return Imm & 0xff00ff00U;
407
+
408
+ // The other splat is all that's left as an option.
409
+ //assert (getT2SOImmValSplatVal(Imm & 0x00ff00ffU) != -1);
410
+ return Imm & 0x00ff00ffU;
411
+ }
412
+
413
+ static inline unsigned getT2SOImmTwoPartSecond(unsigned Imm)
414
+ {
415
+ // Mask out the first hunk
416
+ Imm ^= getT2SOImmTwoPartFirst(Imm);
417
+ // Return what's left
418
+ //assert (getT2SOImmVal(Imm) != -1 &&
419
+ // "Unable to encode second part of T2 two part SO immediate");
420
+ return Imm;
421
+ }
422
+
423
+
424
+ //===--------------------------------------------------------------------===//
425
+ // Addressing Mode #2
426
+ //===--------------------------------------------------------------------===//
427
+ //
428
+ // This is used for most simple load/store instructions.
429
+ //
430
+ // addrmode2 := reg +/- reg shop imm
431
+ // addrmode2 := reg +/- imm12
432
+ //
433
+ // The first operand is always a Reg. The second operand is a reg if in
434
+ // reg/reg form, otherwise it's reg#0. The third field encodes the operation
435
+ // in bit 12, the immediate in bits 0-11, and the shift op in 13-15. The
436
+ // fourth operand 16-17 encodes the index mode.
437
+ //
438
+ // If this addressing mode is a frame index (before prolog/epilog insertion
439
+ // and code rewriting), this operand will have the form: FI#, reg0, <offs>
440
+ // with no shift amount for the frame offset.
441
+ //
442
+ static inline unsigned ARM_AM_getAM2Opc(ARM_AM_AddrOpc Opc, unsigned Imm12, ARM_AM_ShiftOpc SO,
443
+ unsigned IdxMode)
444
+ {
445
+ //assert(Imm12 < (1 << 12) && "Imm too large!");
446
+ bool isSub = Opc == ARM_AM_sub;
447
+ return Imm12 | ((int)isSub << 12) | (SO << 13) | (IdxMode << 16) ;
448
+ }
449
+
450
+ static inline unsigned getAM2Offset(unsigned AM2Opc)
451
+ {
452
+ return AM2Opc & ((1 << 12)-1);
453
+ }
454
+
455
+ static inline ARM_AM_AddrOpc getAM2Op(unsigned AM2Opc)
456
+ {
457
+ return ((AM2Opc >> 12) & 1) ? ARM_AM_sub : ARM_AM_add;
458
+ }
459
+
460
+ static inline ARM_AM_ShiftOpc getAM2ShiftOpc(unsigned AM2Opc)
461
+ {
462
+ return (ARM_AM_ShiftOpc)((AM2Opc >> 13) & 7);
463
+ }
464
+
465
+ static inline unsigned getAM2IdxMode(unsigned AM2Opc)
466
+ {
467
+ return (AM2Opc >> 16);
468
+ }
469
+
470
+ //===--------------------------------------------------------------------===//
471
+ // Addressing Mode #3
472
+ //===--------------------------------------------------------------------===//
473
+ //
474
+ // This is used for sign-extending loads, and load/store-pair instructions.
475
+ //
476
+ // addrmode3 := reg +/- reg
477
+ // addrmode3 := reg +/- imm8
478
+ //
479
+ // The first operand is always a Reg. The second operand is a reg if in
480
+ // reg/reg form, otherwise it's reg#0. The third field encodes the operation
481
+ // in bit 8, the immediate in bits 0-7. The fourth operand 9-10 encodes the
482
+ // index mode.
483
+
484
+ /// getAM3Opc - This function encodes the addrmode3 opc field.
485
+ static inline unsigned getAM3Opc(ARM_AM_AddrOpc Opc, unsigned char Offset,
486
+ unsigned IdxMode)
487
+ {
488
+ bool isSub = Opc == ARM_AM_sub;
489
+ return ((int)isSub << 8) | Offset | (IdxMode << 9);
490
+ }
491
+
492
+ static inline unsigned char getAM3Offset(unsigned AM3Opc)
493
+ {
494
+ return AM3Opc & 0xFF;
495
+ }
496
+
497
+ static inline ARM_AM_AddrOpc getAM3Op(unsigned AM3Opc)
498
+ {
499
+ return ((AM3Opc >> 8) & 1) ? ARM_AM_sub : ARM_AM_add;
500
+ }
501
+
502
+ static inline unsigned getAM3IdxMode(unsigned AM3Opc)
503
+ {
504
+ return (AM3Opc >> 9);
505
+ }
506
+
507
+ //===--------------------------------------------------------------------===//
508
+ // Addressing Mode #4
509
+ //===--------------------------------------------------------------------===//
510
+ //
511
+ // This is used for load / store multiple instructions.
512
+ //
513
+ // addrmode4 := reg, <mode>
514
+ //
515
+ // The four modes are:
516
+ // IA - Increment after
517
+ // IB - Increment before
518
+ // DA - Decrement after
519
+ // DB - Decrement before
520
+ // For VFP instructions, only the IA and DB modes are valid.
521
+
522
+ static inline ARM_AM_AMSubMode getAM4SubMode(unsigned Mode)
523
+ {
524
+ return (ARM_AM_AMSubMode)(Mode & 0x7);
525
+ }
526
+
527
+ static inline unsigned getAM4ModeImm(ARM_AM_AMSubMode SubMode)
528
+ {
529
+ return (int)SubMode;
530
+ }
531
+
532
+ //===--------------------------------------------------------------------===//
533
+ // Addressing Mode #5
534
+ //===--------------------------------------------------------------------===//
535
+ //
536
+ // This is used for coprocessor instructions, such as FP load/stores.
537
+ //
538
+ // addrmode5 := reg +/- imm8*4
539
+ //
540
+ // The first operand is always a Reg. The second operand encodes the
541
+ // operation in bit 8 and the immediate in bits 0-7.
542
+
543
+ /// getAM5Opc - This function encodes the addrmode5 opc field.
544
+ static inline unsigned ARM_AM_getAM5Opc(ARM_AM_AddrOpc Opc, unsigned char Offset)
545
+ {
546
+ bool isSub = Opc == ARM_AM_sub;
547
+ return ((int)isSub << 8) | Offset;
548
+ }
549
+ static inline unsigned char ARM_AM_getAM5Offset(unsigned AM5Opc)
550
+ {
551
+ return AM5Opc & 0xFF;
552
+ }
553
+ static inline ARM_AM_AddrOpc ARM_AM_getAM5Op(unsigned AM5Opc)
554
+ {
555
+ return ((AM5Opc >> 8) & 1) ? ARM_AM_sub : ARM_AM_add;
556
+ }
557
+
558
+ //===--------------------------------------------------------------------===//
559
+ // Addressing Mode #5 FP16
560
+ //===--------------------------------------------------------------------===//
561
+ //
562
+ // This is used for coprocessor instructions, such as 16-bit FP load/stores.
563
+ //
564
+ // addrmode5fp16 := reg +/- imm8*2
565
+ //
566
+ // The first operand is always a Reg. The second operand encodes the
567
+ // operation (add or subtract) in bit 8 and the immediate in bits 0-7.
568
+
569
+ /// getAM5FP16Opc - This function encodes the addrmode5fp16 opc field.
570
+ static inline unsigned getAM5FP16Opc(ARM_AM_AddrOpc Opc, unsigned char Offset)
571
+ {
572
+ bool isSub = Opc == ARM_AM_sub;
573
+ return ((int)isSub << 8) | Offset;
574
+ }
575
+
576
+ static inline unsigned char getAM5FP16Offset(unsigned AM5Opc)
577
+ {
578
+ return AM5Opc & 0xFF;
579
+ }
580
+
581
+ static inline ARM_AM_AddrOpc getAM5FP16Op(unsigned AM5Opc)
582
+ {
583
+ return ((AM5Opc >> 8) & 1) ? ARM_AM_sub : ARM_AM_add;
584
+ }
585
+
586
+ //===--------------------------------------------------------------------===//
587
+ // Addressing Mode #6
588
+ //===--------------------------------------------------------------------===//
589
+ //
590
+ // This is used for NEON load / store instructions.
591
+ //
592
+ // addrmode6 := reg with optional alignment
593
+ //
594
+ // This is stored in two operands [regaddr, align]. The first is the
595
+ // address register. The second operand is the value of the alignment
596
+ // specifier in bytes or zero if no explicit alignment.
597
+ // Valid alignments depend on the specific instruction.
598
+
599
+ //===--------------------------------------------------------------------===//
600
+ // NEON Modified Immediates
601
+ //===--------------------------------------------------------------------===//
602
+ //
603
+ // Several NEON instructions (e.g., VMOV) take a "modified immediate"
604
+ // vector operand, where a small immediate encoded in the instruction
605
+ // specifies a full NEON vector value. These modified immediates are
606
+ // represented here as encoded integers. The low 8 bits hold the immediate
607
+ // value; bit 12 holds the "Op" field of the instruction, and bits 11-8 hold
608
+ // the "Cmode" field of the instruction. The interfaces below treat the
609
+ // Op and Cmode values as a single 5-bit value.
610
+
611
+ static inline unsigned createNEONModImm(unsigned OpCmode, unsigned Val)
612
+ {
613
+ return (OpCmode << 8) | Val;
614
+ }
615
+ static inline unsigned getNEONModImmOpCmode(unsigned ModImm)
616
+ {
617
+ return (ModImm >> 8) & 0x1f;
618
+ }
619
+ static inline unsigned getNEONModImmVal(unsigned ModImm)
620
+ {
621
+ return ModImm & 0xff;
622
+ }
623
+
624
+ /// decodeNEONModImm - Decode a NEON modified immediate value into the
625
+ /// element value and the element size in bits. (If the element size is
626
+ /// smaller than the vector, it is splatted into all the elements.)
627
+ static inline uint64_t ARM_AM_decodeNEONModImm(unsigned ModImm, unsigned *EltBits)
628
+ {
629
+ unsigned OpCmode = getNEONModImmOpCmode(ModImm);
630
+ unsigned Imm8 = getNEONModImmVal(ModImm);
631
+ uint64_t Val = 0;
632
+ unsigned ByteNum;
633
+
634
+ if (OpCmode == 0xe) {
635
+ // 8-bit vector elements
636
+ Val = Imm8;
637
+ *EltBits = 8;
638
+ } else if ((OpCmode & 0xc) == 0x8) {
639
+ // 16-bit vector elements
640
+ ByteNum = (OpCmode & 0x6) >> 1;
641
+ Val = (uint64_t)Imm8 << (8 * ByteNum);
642
+ *EltBits = 16;
643
+ } else if ((OpCmode & 0x8) == 0) {
644
+ // 32-bit vector elements, zero with one byte set
645
+ ByteNum = (OpCmode & 0x6) >> 1;
646
+ Val = (uint64_t)Imm8 << (8 * ByteNum);
647
+ *EltBits = 32;
648
+ } else if ((OpCmode & 0xe) == 0xc) {
649
+ // 32-bit vector elements, one byte with low bits set
650
+ ByteNum = 1 + (OpCmode & 0x1);
651
+ Val = (Imm8 << (8 * ByteNum)) | (0xffff >> (8 * (2 - ByteNum)));
652
+ *EltBits = 32;
653
+ } else if (OpCmode == 0x1e) {
654
+ // 64-bit vector elements
655
+ for (ByteNum = 0; ByteNum < 8; ++ByteNum) {
656
+ if ((ModImm >> ByteNum) & 1)
657
+ Val |= (uint64_t)0xff << (8 * ByteNum);
658
+ }
659
+ *EltBits = 64;
660
+ } else {
661
+ //llvm_unreachable("Unsupported NEON immediate");
662
+ }
663
+ return Val;
664
+ }
665
+
666
+ ARM_AM_AMSubMode getLoadStoreMultipleSubMode(int Opcode);
667
+
668
+ //===--------------------------------------------------------------------===//
669
+ // Floating-point Immediates
670
+ //
671
+ static inline float getFPImmFloat(unsigned Imm)
672
+ {
673
+ // We expect an 8-bit binary encoding of a floating-point number here.
674
+ union {
675
+ uint32_t I;
676
+ float F;
677
+ } FPUnion;
678
+
679
+ uint8_t Sign = (Imm >> 7) & 0x1;
680
+ uint8_t Exp = (Imm >> 4) & 0x7;
681
+ uint8_t Mantissa = Imm & 0xf;
682
+
683
+ // 8-bit FP iEEEE Float Encoding
684
+ // abcd efgh aBbbbbbc defgh000 00000000 00000000
685
+ //
686
+ // where B = NOT(b);
687
+
688
+ FPUnion.I = 0;
689
+ FPUnion.I |= ((uint32_t) Sign) << 31;
690
+ FPUnion.I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
691
+ FPUnion.I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
692
+ FPUnion.I |= (Exp & 0x3) << 23;
693
+ FPUnion.I |= Mantissa << 19;
694
+ return FPUnion.F;
695
+ }
696
+
697
+ #endif
698
+