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,1655 @@
1
+ //===------ TriCoreDisassembler.cpp - Disassembler for TriCore --*- 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
+ /* Capstone Disassembly Engine */
11
+ /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 */
12
+
13
+ #ifdef CAPSTONE_HAS_TRICORE
14
+
15
+ #include <stdio.h> // DEBUG
16
+ #include <stdlib.h>
17
+ #include <string.h>
18
+
19
+ #include "../../cs_priv.h"
20
+ #include "../../utils.h"
21
+
22
+ #include "../../MCInst.h"
23
+ #include "../../MCInstrDesc.h"
24
+ #include "../../MCFixedLenDisassembler.h"
25
+ #include "../../MCRegisterInfo.h"
26
+ #include "../../MCDisassembler.h"
27
+ #include "../../MathExtras.h"
28
+
29
+ #include "TriCoreDisassembler.h"
30
+ #include "TriCoreMapping.h"
31
+ #include "TriCoreLinkage.h"
32
+
33
+ static unsigned getReg(MCRegisterInfo *MRI, unsigned RC, unsigned RegNo)
34
+ {
35
+ const MCRegisterClass *rc = MCRegisterInfo_getRegClass(MRI, RC);
36
+ return rc->RegsBegin[RegNo];
37
+ }
38
+
39
+ #define tryDecodeReg(i, x) \
40
+ status = DecodeRegisterClass(Inst, (x), &desc->OpInfo[(i)], Decoder); \
41
+ if (status != MCDisassembler_Success) \
42
+ return status;
43
+
44
+ #define decodeImm(x) MCOperand_CreateImm0(Inst, (x));
45
+
46
+ static DecodeStatus DecodeSBInstruction(MCInst *Inst, unsigned Insn,
47
+ uint64_t Address, void *Decoder);
48
+
49
+ static DecodeStatus DecodeSBRInstruction(MCInst *Inst, unsigned Insn,
50
+ uint64_t Address, void *Decoder);
51
+
52
+ static DecodeStatus DecodeSCInstruction(MCInst *Inst, unsigned Insn,
53
+ uint64_t Address, void *Decoder);
54
+
55
+ static DecodeStatus DecodeSRInstruction(MCInst *Inst, unsigned Insn,
56
+ uint64_t Address, void *Decoder);
57
+
58
+ static DecodeStatus DecodeSRCInstruction(MCInst *Inst, unsigned Insn,
59
+ uint64_t Address, void *Decoder);
60
+
61
+ static DecodeStatus DecodeSRRInstruction(MCInst *Inst, unsigned Insn,
62
+ uint64_t Address, void *Decoder);
63
+
64
+ static DecodeStatus DecodeABSInstruction(MCInst *Inst, unsigned Insn,
65
+ uint64_t Address, void *Decoder);
66
+
67
+ static DecodeStatus DecodeBInstruction(MCInst *Inst, unsigned Insn,
68
+ uint64_t Address, void *Decoder);
69
+
70
+ static DecodeStatus DecodeBOInstruction(MCInst *Inst, unsigned Insn,
71
+ uint64_t Address, void *Decoder);
72
+
73
+ static DecodeStatus DecodeBOLInstruction(MCInst *Inst, unsigned Insn,
74
+ uint64_t Address, void *Decoder);
75
+
76
+ static DecodeStatus DecodeRCInstruction(MCInst *Inst, unsigned Insn,
77
+ uint64_t Address, void *Decoder);
78
+
79
+ static DecodeStatus DecodeRCPWInstruction(MCInst *Inst, unsigned Insn,
80
+ uint64_t Address, void *Decoder);
81
+
82
+ static DecodeStatus DecodeRLCInstruction(MCInst *Inst, unsigned Insn,
83
+ uint64_t Address, void *Decoder);
84
+
85
+ static DecodeStatus DecodeRRInstruction(MCInst *Inst, unsigned Insn,
86
+ uint64_t Address, void *Decoder);
87
+
88
+ static DecodeStatus DecodeRR2Instruction(MCInst *Inst, unsigned Insn,
89
+ uint64_t Address, void *Decoder);
90
+
91
+ static DecodeStatus DecodeRRPWInstruction(MCInst *Inst, unsigned Insn,
92
+ uint64_t Address, void *Decoder);
93
+
94
+ static DecodeStatus DecodeSLRInstruction(MCInst *Inst, unsigned Insn,
95
+ uint64_t Address, void *Decoder);
96
+
97
+ static DecodeStatus DecodeSLROInstruction(MCInst *Inst, unsigned Insn,
98
+ uint64_t Address, void *Decoder);
99
+
100
+ static DecodeStatus DecodeSROInstruction(MCInst *Inst, unsigned Insn,
101
+ uint64_t Address, void *Decoder);
102
+
103
+ static DecodeStatus DecodeSRRSInstruction(MCInst *Inst, unsigned Insn,
104
+ uint64_t Address, void *Decoder);
105
+
106
+ static DecodeStatus DecodeSBCInstruction(MCInst *Inst, unsigned Insn,
107
+ uint64_t Address, void *Decoder);
108
+
109
+ static DecodeStatus DecodeSBRNInstruction(MCInst *Inst, unsigned Insn,
110
+ uint64_t Address, void *Decoder);
111
+
112
+ static DecodeStatus DecodeSSRInstruction(MCInst *Inst, unsigned Insn,
113
+ uint64_t Address, void *Decoder);
114
+
115
+ static DecodeStatus DecodeSSROInstruction(MCInst *Inst, unsigned Insn,
116
+ uint64_t Address, void *Decoder);
117
+
118
+ static DecodeStatus DecodeSYSInstruction(MCInst *Inst, unsigned Insn,
119
+ uint64_t Address, void *Decoder);
120
+
121
+ static DecodeStatus DecodeRRR2Instruction(MCInst *Inst, unsigned Insn,
122
+ uint64_t Address, void *Decoder);
123
+
124
+ static DecodeStatus DecodeRRR1Instruction(MCInst *Inst, unsigned Insn,
125
+ uint64_t Address, void *Decoder);
126
+
127
+ static DecodeStatus DecodeBITInstruction(MCInst *Inst, unsigned Insn,
128
+ uint64_t Address, void *Decoder);
129
+
130
+ static DecodeStatus DecodeRR1Instruction(MCInst *Inst, unsigned Insn,
131
+ uint64_t Address, void *Decoder);
132
+
133
+ static DecodeStatus DecodeRCRInstruction(MCInst *Inst, unsigned Insn,
134
+ uint64_t Address, void *Decoder);
135
+
136
+ static DecodeStatus DecodeRRRWInstruction(MCInst *Inst, unsigned Insn,
137
+ uint64_t Address, void *Decoder);
138
+
139
+ static DecodeStatus DecodeRCRRInstruction(MCInst *Inst, unsigned Insn,
140
+ uint64_t Address, void *Decoder);
141
+
142
+ static DecodeStatus DecodeRRRRInstruction(MCInst *Inst, unsigned Insn,
143
+ uint64_t Address, void *Decoder);
144
+
145
+ static DecodeStatus DecodeBRRInstruction(MCInst *Inst, unsigned Insn,
146
+ uint64_t Address, void *Decoder);
147
+
148
+ static DecodeStatus DecodeBRCInstruction(MCInst *Inst, unsigned Insn,
149
+ uint64_t Address, void *Decoder);
150
+
151
+ static DecodeStatus DecodeRRRInstruction(MCInst *Inst, unsigned Insn,
152
+ uint64_t Address, void *Decoder);
153
+
154
+ static DecodeStatus DecodeABSBInstruction(MCInst *Inst, unsigned Insn,
155
+ uint64_t Address, void *Decoder);
156
+
157
+ static DecodeStatus DecodeRCRWInstruction(MCInst *Inst, unsigned Insn,
158
+ uint64_t Address, void *Decoder);
159
+
160
+ static DecodeStatus DecodeBRNInstruction(MCInst *Inst, unsigned Insn,
161
+ uint64_t Address, void *Decoder);
162
+
163
+ #define GET_SUBTARGETINFO_ENUM
164
+
165
+ #include "TriCoreGenSubtargetInfo.inc"
166
+
167
+ bool TriCore_getFeatureBits(unsigned int mode, unsigned int feature)
168
+ {
169
+ switch (mode) {
170
+ case CS_MODE_TRICORE_110: {
171
+ return feature == TRICORE_HasV110Ops;
172
+ }
173
+ case CS_MODE_TRICORE_120: {
174
+ return feature == TRICORE_HasV120Ops;
175
+ }
176
+ case CS_MODE_TRICORE_130: {
177
+ return feature == TRICORE_HasV130Ops;
178
+ }
179
+ case CS_MODE_TRICORE_131: {
180
+ return feature == TRICORE_HasV131Ops;
181
+ }
182
+ case CS_MODE_TRICORE_160: {
183
+ return feature == TRICORE_HasV160Ops;
184
+ }
185
+ case CS_MODE_TRICORE_161: {
186
+ return feature == TRICORE_HasV161Ops;
187
+ }
188
+ case CS_MODE_TRICORE_162: {
189
+ return feature == TRICORE_HasV162Ops;
190
+ }
191
+ default:
192
+ return false;
193
+ }
194
+ }
195
+
196
+ #include "TriCoreGenDisassemblerTables.inc"
197
+
198
+ #define GET_REGINFO_ENUM
199
+ #define GET_REGINFO_MC_DESC
200
+
201
+ #include "TriCoreGenRegisterInfo.inc"
202
+
203
+ static DecodeStatus DecodeRegisterClass(MCInst *Inst, unsigned RegNo,
204
+ const MCOperandInfo *MCOI,
205
+ void *Decoder)
206
+ {
207
+ unsigned Reg;
208
+ unsigned RegHalfNo = RegNo / 2;
209
+
210
+ if (!MCOI || MCOI->OperandType != MCOI_OPERAND_REGISTER) {
211
+ return MCDisassembler_Fail;
212
+ }
213
+
214
+ if (RegHalfNo > 15)
215
+ return MCDisassembler_Fail;
216
+
217
+ if (MCOI->RegClass < 3) {
218
+ Reg = getReg(Decoder, MCOI->RegClass, RegNo);
219
+ } else {
220
+ Reg = getReg(Decoder, MCOI->RegClass, RegHalfNo);
221
+ }
222
+
223
+ MCOperand_CreateReg0(Inst, Reg);
224
+
225
+ return MCDisassembler_Success;
226
+ }
227
+
228
+ #define GET_INSTRINFO_ENUM
229
+ #define GET_INSTRINFO_MC_DESC
230
+
231
+ #include "TriCoreGenInstrInfo.inc"
232
+
233
+ static DecodeStatus DecodeSBInstruction(MCInst *Inst, unsigned Insn,
234
+ uint64_t Address, void *Decoder)
235
+ {
236
+ unsigned disp8 = fieldFromInstruction_2(Insn, 8, 8);
237
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
238
+
239
+ if (is32Bit) // This instruction is 16-bit
240
+ return MCDisassembler_Fail;
241
+
242
+ // Decode disp8.
243
+ MCOperand_CreateImm0(Inst, disp8);
244
+
245
+ return MCDisassembler_Success;
246
+ }
247
+
248
+ static DecodeStatus DecodeSBRInstruction(MCInst *Inst, unsigned Insn,
249
+ uint64_t Address, void *Decoder)
250
+ {
251
+ DecodeStatus status;
252
+ unsigned s2 = fieldFromInstruction_2(Insn, 12, 4);
253
+ unsigned disp4 = fieldFromInstruction_2(Insn, 8, 4);
254
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
255
+
256
+ if (is32Bit) // This instruction is 16-bit
257
+ return MCDisassembler_Fail;
258
+
259
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
260
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[0], Decoder);
261
+ if (status != MCDisassembler_Success)
262
+ return status;
263
+
264
+ // Decode disp4.
265
+ MCOperand_CreateImm0(Inst, disp4);
266
+
267
+ return MCDisassembler_Success;
268
+ }
269
+
270
+ static DecodeStatus DecodeSCInstruction(MCInst *Inst, unsigned Insn,
271
+ uint64_t Address, void *Decoder)
272
+ {
273
+ unsigned const8 = fieldFromInstruction_2(Insn, 8, 8);
274
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
275
+
276
+ if (is32Bit) // This instruction is 16-bit
277
+ return MCDisassembler_Fail;
278
+
279
+ // Decode const8.
280
+ MCOperand_CreateImm0(Inst, const8);
281
+
282
+ return MCDisassembler_Success;
283
+ }
284
+
285
+ static DecodeStatus DecodeSRInstruction(MCInst *Inst, unsigned Insn,
286
+ uint64_t Address, void *Decoder)
287
+ {
288
+ DecodeStatus status;
289
+ unsigned s1_d = fieldFromInstruction_2(Insn, 8, 4);
290
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
291
+
292
+ if (is32Bit) // This instruction is 16-bit
293
+ return MCDisassembler_Fail;
294
+
295
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
296
+ if (desc->NumOperands > 0) {
297
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[0],
298
+ Decoder);
299
+ if (status != MCDisassembler_Success)
300
+ return status;
301
+ }
302
+
303
+ if (desc->NumOperands > 1) {
304
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[1],
305
+ Decoder);
306
+ if (status != MCDisassembler_Success)
307
+ return status;
308
+ }
309
+
310
+ return MCDisassembler_Success;
311
+ }
312
+
313
+ static DecodeStatus DecodeSRCInstruction(MCInst *Inst, unsigned Insn,
314
+ uint64_t Address, void *Decoder)
315
+ {
316
+ DecodeStatus status;
317
+ unsigned const4 = fieldFromInstruction_2(Insn, 12, 4);
318
+ unsigned s1_d = fieldFromInstruction_2(Insn, 8, 4);
319
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
320
+
321
+ if (is32Bit) // This instruction is 16-bit
322
+ return MCDisassembler_Fail;
323
+
324
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
325
+
326
+ // Decode s1/d.
327
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[0], Decoder);
328
+ if (status != MCDisassembler_Success)
329
+ return status;
330
+
331
+ // Decode const4.
332
+ MCOperand_CreateImm0(Inst, const4);
333
+
334
+ return MCDisassembler_Success;
335
+ }
336
+
337
+ static DecodeStatus DecodeSRRInstruction(MCInst *Inst, unsigned Insn,
338
+ uint64_t Address, void *Decoder)
339
+ {
340
+ DecodeStatus status;
341
+ unsigned s2 = fieldFromInstruction_2(Insn, 12, 4);
342
+ unsigned s1_d = fieldFromInstruction_2(Insn, 8, 4);
343
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
344
+
345
+ if (is32Bit) // This instruction is 16-bit
346
+ return MCDisassembler_Fail;
347
+
348
+ // Decode s1/d.
349
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
350
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[0], Decoder);
351
+ if (status != MCDisassembler_Success)
352
+ return status;
353
+
354
+ // Decode s2.
355
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[1], Decoder);
356
+ if (status != MCDisassembler_Success)
357
+ return status;
358
+
359
+ return MCDisassembler_Success;
360
+ }
361
+
362
+ static DecodeStatus DecodeABSInstruction(MCInst *Inst, unsigned Insn,
363
+ uint64_t Address, void *Decoder)
364
+ {
365
+ DecodeStatus status;
366
+ unsigned off18_0 = fieldFromInstruction_4(Insn, 16, 6);
367
+ unsigned off18_1 = fieldFromInstruction_4(Insn, 28, 4);
368
+ unsigned off18_2 = fieldFromInstruction_4(Insn, 22, 4);
369
+ unsigned off18_3 = fieldFromInstruction_4(Insn, 12, 4);
370
+ unsigned off18 = (off18_0 << 0) | (off18_1 << 6) | (off18_2 << 10) |
371
+ (off18_3 << 14);
372
+
373
+ unsigned s1_d = fieldFromInstruction_4(Insn, 8, 4);
374
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
375
+
376
+ if (!is32Bit) // This instruction is 32-bit
377
+ return MCDisassembler_Fail;
378
+
379
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
380
+
381
+ if (desc->NumOperands > 1) {
382
+ if (desc->OpInfo[0].OperandType == MCOI_OPERAND_REGISTER) {
383
+ status = DecodeRegisterClass(Inst, s1_d,
384
+ &desc->OpInfo[0], Decoder);
385
+ if (status != MCDisassembler_Success)
386
+ return status;
387
+
388
+ MCOperand_CreateImm0(Inst, off18);
389
+ } else {
390
+ MCOperand_CreateImm0(Inst, off18);
391
+ status = DecodeRegisterClass(Inst, s1_d,
392
+ &desc->OpInfo[0], Decoder);
393
+ if (status != MCDisassembler_Success)
394
+ return status;
395
+ }
396
+ } else {
397
+ MCOperand_CreateImm0(Inst, off18);
398
+ }
399
+
400
+ return MCDisassembler_Success;
401
+ }
402
+
403
+ static DecodeStatus DecodeBInstruction(MCInst *Inst, unsigned Insn,
404
+ uint64_t Address, void *Decoder)
405
+ {
406
+ unsigned disp24_0 = fieldFromInstruction_4(Insn, 16, 16);
407
+ unsigned disp24_1 = fieldFromInstruction_4(Insn, 8, 8);
408
+ unsigned disp24 = (disp24_0 << 0) | (disp24_1 << 16);
409
+
410
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
411
+
412
+ if (!is32Bit) // This instruction is 32-bit
413
+ return MCDisassembler_Fail;
414
+
415
+ // Decode disp24.
416
+ MCOperand_CreateImm0(Inst, disp24);
417
+
418
+ return MCDisassembler_Success;
419
+ }
420
+
421
+ static DecodeStatus DecodeBOInstruction(MCInst *Inst, unsigned Insn,
422
+ uint64_t Address, void *Decoder)
423
+ {
424
+ DecodeStatus status;
425
+ unsigned off10_0 = fieldFromInstruction_4(Insn, 16, 6);
426
+ unsigned off10_1 = fieldFromInstruction_4(Insn, 28, 4);
427
+ unsigned off10 = (off10_0 << 0) | (off10_1 << 6);
428
+ bool is_store = false;
429
+
430
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
431
+ unsigned s1_d = fieldFromInstruction_4(Insn, 8, 4);
432
+
433
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
434
+
435
+ if (!is32Bit) // This instruction is 32-bit
436
+ return MCDisassembler_Fail;
437
+
438
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
439
+
440
+ if (desc->NumOperands == 1) {
441
+ return DecodeRegisterClass(Inst, s2, &desc->OpInfo[0], Decoder);
442
+ }
443
+
444
+ switch (MCInst_getOpcode(Inst)) {
445
+ case TRICORE_ST_A_bo_r:
446
+ case TRICORE_ST_A_bo_c:
447
+ case TRICORE_ST_B_bo_r:
448
+ case TRICORE_ST_B_bo_c:
449
+ case TRICORE_ST_D_bo_r:
450
+ case TRICORE_ST_D_bo_c:
451
+ case TRICORE_ST_DA_bo_r:
452
+ case TRICORE_ST_DA_bo_c:
453
+ case TRICORE_ST_H_bo_r:
454
+ case TRICORE_ST_H_bo_c:
455
+ case TRICORE_ST_Q_bo_r:
456
+ case TRICORE_ST_Q_bo_c:
457
+ case TRICORE_ST_W_bo_r:
458
+ case TRICORE_ST_W_bo_c:
459
+ case TRICORE_SWAP_W_bo_r:
460
+ case TRICORE_SWAP_W_bo_c:
461
+ case TRICORE_SWAPMSK_W_bo_c:
462
+ case TRICORE_SWAPMSK_W_bo_r: {
463
+ is_store = true;
464
+ break;
465
+ }
466
+ }
467
+
468
+ if (desc->NumOperands == 2) {
469
+ if (desc->OpInfo[1].OperandType == MCOI_OPERAND_REGISTER) {
470
+ // we have [reg+r] instruction
471
+ if (is_store) {
472
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[0],
473
+ Decoder);
474
+ if (status != MCDisassembler_Success)
475
+ return status;
476
+ return DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[1],
477
+ Decoder);
478
+ } else {
479
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[0],
480
+ Decoder);
481
+ if (status != MCDisassembler_Success)
482
+ return status;
483
+ return DecodeRegisterClass(Inst, s2, &desc->OpInfo[1],
484
+ Decoder);
485
+ }
486
+ } else {
487
+ // we have one of the CACHE instructions without destination reg
488
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[0],
489
+ Decoder);
490
+ if (status != MCDisassembler_Success)
491
+ return status;
492
+
493
+ MCOperand_CreateImm0(Inst, off10);
494
+ }
495
+ return MCDisassembler_Success;
496
+ }
497
+
498
+ if (desc->NumOperands > 2) {
499
+ if (is_store) {
500
+ // we have [reg+c] instruction
501
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[0],
502
+ Decoder);
503
+ if (status != MCDisassembler_Success)
504
+ return status;
505
+
506
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[1],
507
+ Decoder);
508
+ if (status != MCDisassembler_Success)
509
+ return status;
510
+ } else {
511
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[0],
512
+ Decoder);
513
+ if (status != MCDisassembler_Success)
514
+ return status;
515
+
516
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[1],
517
+ Decoder);
518
+ if (status != MCDisassembler_Success)
519
+ return status;
520
+ }
521
+ MCOperand_CreateImm0(Inst, off10);
522
+ }
523
+
524
+ return MCDisassembler_Success;
525
+ }
526
+
527
+ static DecodeStatus DecodeBOLInstruction(MCInst *Inst, unsigned Insn,
528
+ uint64_t Address, void *Decoder)
529
+ {
530
+ DecodeStatus status;
531
+ unsigned off16_0 = fieldFromInstruction_4(Insn, 16, 6);
532
+ unsigned off16_1 = fieldFromInstruction_4(Insn, 22, 6);
533
+ unsigned off16_2 = fieldFromInstruction_4(Insn, 28, 4);
534
+ unsigned off16 = (off16_0 << 0) | (off16_1 << 10) | (off16_2 << 6);
535
+
536
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
537
+ unsigned s1_d = fieldFromInstruction_4(Insn, 8, 4);
538
+
539
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
540
+ if (!is32Bit) // This instruction is 32-bit
541
+ return MCDisassembler_Fail;
542
+
543
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
544
+
545
+ switch (MCInst_getOpcode(Inst)) {
546
+ case TRICORE_LD_A_bol:
547
+ case TRICORE_LD_B_bol:
548
+ case TRICORE_LD_BU_bol:
549
+ case TRICORE_LD_H_bol:
550
+ case TRICORE_LD_HU_bol:
551
+ case TRICORE_LD_W_bol:
552
+ case TRICORE_LEA_bol: {
553
+ // Decode s1_d.
554
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[0],
555
+ Decoder);
556
+ if (status != MCDisassembler_Success)
557
+ return status;
558
+
559
+ // Decode s2.
560
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[1],
561
+ Decoder);
562
+ if (status != MCDisassembler_Success)
563
+ return status;
564
+ break;
565
+ }
566
+ case TRICORE_ST_A_bol:
567
+ case TRICORE_ST_B_bol:
568
+ case TRICORE_ST_H_bol:
569
+ case TRICORE_ST_W_bol: {
570
+ // Decode s2.
571
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[0],
572
+ Decoder);
573
+ if (status != MCDisassembler_Success)
574
+ return status;
575
+
576
+ // Decode s1_d.
577
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[1],
578
+ Decoder);
579
+ if (status != MCDisassembler_Success)
580
+ return status;
581
+ break;
582
+ }
583
+ default:
584
+ return MCDisassembler_Fail;
585
+ }
586
+
587
+ // Decode off16.
588
+ MCOperand_CreateImm0(Inst, off16);
589
+
590
+ return MCDisassembler_Success;
591
+ }
592
+
593
+ static DecodeStatus DecodeRCInstruction(MCInst *Inst, unsigned Insn,
594
+ uint64_t Address, void *Decoder)
595
+ {
596
+ DecodeStatus status;
597
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
598
+ unsigned const9 = fieldFromInstruction_4(Insn, 12, 9);
599
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
600
+
601
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
602
+
603
+ if (!is32Bit) // This instruction is 32-bit
604
+ return MCDisassembler_Fail;
605
+
606
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
607
+ if (desc->NumOperands > 1) {
608
+ // Decode d.
609
+ status =
610
+ DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
611
+ if (status != MCDisassembler_Success)
612
+ return status;
613
+
614
+ // Decode s1.
615
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1],
616
+ Decoder);
617
+ if (status != MCDisassembler_Success)
618
+ return status;
619
+ }
620
+
621
+ // Decode const9.
622
+ MCOperand_CreateImm0(Inst, const9);
623
+
624
+ return MCDisassembler_Success;
625
+ }
626
+
627
+ static DecodeStatus DecodeRCPWInstruction(MCInst *Inst, unsigned Insn,
628
+ uint64_t Address, void *Decoder)
629
+ {
630
+ DecodeStatus status;
631
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
632
+ unsigned pos = fieldFromInstruction_4(Insn, 23, 5);
633
+ unsigned width = fieldFromInstruction_4(Insn, 16, 5);
634
+ unsigned const4 = fieldFromInstruction_4(Insn, 12, 4);
635
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
636
+
637
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
638
+
639
+ if (!is32Bit) // This instruction is 32-bit
640
+ return MCDisassembler_Fail;
641
+
642
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
643
+ // Decode d.
644
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
645
+ if (status != MCDisassembler_Success)
646
+ return status;
647
+
648
+ // Decode s1.
649
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
650
+ if (status != MCDisassembler_Success)
651
+ return status;
652
+
653
+ // Decode const4.
654
+ MCOperand_CreateImm0(Inst, const4);
655
+
656
+ // Decode pos.
657
+ MCOperand_CreateImm0(Inst, pos);
658
+
659
+ // Decode width.
660
+ MCOperand_CreateImm0(Inst, width);
661
+
662
+ return MCDisassembler_Success;
663
+ }
664
+
665
+ static DecodeStatus DecodeRLCInstruction(MCInst *Inst, unsigned Insn,
666
+ uint64_t Address, void *Decoder)
667
+ {
668
+ DecodeStatus status;
669
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
670
+ unsigned const16 = fieldFromInstruction_4(Insn, 12, 16);
671
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
672
+
673
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
674
+
675
+ if (!is32Bit) // This instruction is 32-bit
676
+ return MCDisassembler_Fail;
677
+
678
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
679
+ if (desc->NumOperands == 3) {
680
+ status =
681
+ DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
682
+ if (status != MCDisassembler_Success)
683
+ return status;
684
+
685
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1],
686
+ Decoder);
687
+ if (status != MCDisassembler_Success)
688
+ return status;
689
+
690
+ MCOperand_CreateImm0(Inst, const16);
691
+
692
+ return MCDisassembler_Success;
693
+ }
694
+
695
+ if (desc->OpInfo[0].OperandType == MCOI_OPERAND_REGISTER) {
696
+ status =
697
+ DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
698
+ if (status != MCDisassembler_Success)
699
+ return status;
700
+
701
+ MCOperand_CreateImm0(Inst, const16);
702
+ } else {
703
+ MCOperand_CreateImm0(Inst, const16);
704
+ if (MCInst_getOpcode(Inst) == TRICORE_MTCR_rlc) {
705
+ status =
706
+ DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
707
+ } else {
708
+ status =
709
+ DecodeRegisterClass(Inst, d, &desc->OpInfo[1], Decoder);
710
+ }
711
+ if (status != MCDisassembler_Success)
712
+ return status;
713
+ }
714
+ return MCDisassembler_Success;
715
+ }
716
+
717
+ static DecodeStatus DecodeRRInstruction(MCInst *Inst, unsigned Insn,
718
+ uint64_t Address, void *Decoder)
719
+ {
720
+ DecodeStatus status;
721
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
722
+ unsigned n = fieldFromInstruction_4(Insn, 16, 2);
723
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
724
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
725
+
726
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
727
+
728
+ if (!is32Bit) // This instruction is 32-bit
729
+ return MCDisassembler_Fail;
730
+
731
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
732
+ /// But even if the instruction is in RR format and has only one operand,
733
+ /// we cannot be sure whether the operand is s1 or s2
734
+ if (desc->NumOperands == 1) {
735
+ if (desc->OpInfo[0].OperandType == MCOI_OPERAND_REGISTER) {
736
+ switch (MCInst_getOpcode(Inst)) {
737
+ case TRICORE_CALLI_rr_v110: {
738
+ return DecodeRegisterClass(
739
+ Inst, s2, &desc->OpInfo[0], Decoder);
740
+ }
741
+ default: {
742
+ return DecodeRegisterClass(
743
+ Inst, s1, &desc->OpInfo[0], Decoder);
744
+ }
745
+ }
746
+ }
747
+ return MCDisassembler_Fail;
748
+ }
749
+
750
+ if (desc->NumOperands > 0) {
751
+ // Decode d.
752
+ status =
753
+ DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
754
+ if (status != MCDisassembler_Success)
755
+ return status;
756
+ }
757
+
758
+ if (desc->NumOperands > 1) {
759
+ if (desc->OpInfo[0].OperandType == MCOI_OPERAND_REGISTER) {
760
+ switch (MCInst_getOpcode(Inst)) {
761
+ case TRICORE_ABSS_rr:
762
+ case TRICORE_ABSS_H_rr:
763
+ case TRICORE_ABS_H_rr:
764
+ case TRICORE_ABS_B_rr:
765
+ case TRICORE_ABS_rr: {
766
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[1],
767
+ Decoder);
768
+ break;
769
+ default:
770
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1],
771
+ Decoder);
772
+ }
773
+ if (status != MCDisassembler_Success)
774
+ return status;
775
+ }
776
+ }
777
+ }
778
+
779
+ if (desc->NumOperands > 2) {
780
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[2],
781
+ Decoder);
782
+ if (status != MCDisassembler_Success)
783
+ return status;
784
+ }
785
+
786
+ if (desc->NumOperands > 3) {
787
+ MCOperand_CreateImm0(Inst, n);
788
+ }
789
+
790
+ return MCDisassembler_Success;
791
+ }
792
+
793
+ static DecodeStatus DecodeRR2Instruction(MCInst *Inst, unsigned Insn,
794
+ uint64_t Address, void *Decoder)
795
+ {
796
+ DecodeStatus status;
797
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
798
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
799
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
800
+
801
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
802
+
803
+ if (!is32Bit) // This instruction is 32-bit
804
+ return MCDisassembler_Fail;
805
+
806
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
807
+ // Decode d.
808
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
809
+ if (status != MCDisassembler_Success)
810
+ return status;
811
+
812
+ // Decode s1.
813
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
814
+ if (status != MCDisassembler_Success)
815
+ return status;
816
+
817
+ // Decode s2.
818
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[2], Decoder);
819
+ if (status != MCDisassembler_Success)
820
+ return status;
821
+
822
+ return MCDisassembler_Success;
823
+ }
824
+
825
+ static DecodeStatus DecodeRRPWInstruction(MCInst *Inst, unsigned Insn,
826
+ uint64_t Address, void *Decoder)
827
+ {
828
+ DecodeStatus status;
829
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
830
+ unsigned pos = fieldFromInstruction_4(Insn, 23, 5);
831
+ unsigned width = fieldFromInstruction_4(Insn, 16, 5);
832
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
833
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
834
+
835
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
836
+
837
+ if (!is32Bit) // This instruction is 32-bit
838
+ return MCDisassembler_Fail;
839
+
840
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
841
+ tryDecodeReg(0, d) tryDecodeReg(1, s1) tryDecodeReg(2, s2)
842
+ decodeImm(pos) decodeImm(width)
843
+
844
+ return MCDisassembler_Success;
845
+ }
846
+
847
+ static DecodeStatus DecodeSLRInstruction(MCInst *Inst, unsigned Insn,
848
+ uint64_t Address, void *Decoder)
849
+ {
850
+ DecodeStatus status = MCDisassembler_Fail;
851
+ unsigned d = fieldFromInstruction_2(Insn, 8, 4);
852
+ unsigned s2 = fieldFromInstruction_2(Insn, 12, 4);
853
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
854
+ if (is32Bit) // This instruction is 16-bit
855
+ return MCDisassembler_Fail;
856
+
857
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
858
+ // Decode d.
859
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
860
+ if (status != MCDisassembler_Success)
861
+ return status;
862
+
863
+ // Decode s2.
864
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[1], Decoder);
865
+ if (status != MCDisassembler_Success)
866
+ return status;
867
+
868
+ return MCDisassembler_Success;
869
+ }
870
+
871
+ static DecodeStatus DecodeSLROInstruction(MCInst *Inst, unsigned Insn,
872
+ uint64_t Address, void *Decoder)
873
+ {
874
+ DecodeStatus status = MCDisassembler_Fail;
875
+ unsigned d = fieldFromInstruction_2(Insn, 8, 4);
876
+ unsigned off4 = fieldFromInstruction_2(Insn, 12, 4);
877
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
878
+ if (is32Bit) // This instruction is 16-bit
879
+ return MCDisassembler_Fail;
880
+
881
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
882
+ // Decode d.
883
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
884
+ if (status != MCDisassembler_Success)
885
+ return status;
886
+
887
+ // Decode off4.
888
+ MCOperand_CreateImm0(Inst, off4);
889
+
890
+ return MCDisassembler_Success;
891
+ }
892
+
893
+ static DecodeStatus DecodeSROInstruction(MCInst *Inst, unsigned Insn,
894
+ uint64_t Address, void *Decoder)
895
+ {
896
+ DecodeStatus status = MCDisassembler_Fail;
897
+ unsigned off4 = fieldFromInstruction_2(Insn, 8, 4);
898
+ unsigned s2 = fieldFromInstruction_2(Insn, 12, 4);
899
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
900
+ if (is32Bit) // This instruction is 16-bit
901
+ return MCDisassembler_Fail;
902
+
903
+ // Decode s2.
904
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
905
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[0], Decoder);
906
+ if (status != MCDisassembler_Success)
907
+ return status;
908
+
909
+ // Decode off4.
910
+ MCOperand_CreateImm0(Inst, off4);
911
+
912
+ return MCDisassembler_Success;
913
+ }
914
+
915
+ static DecodeStatus DecodeSRRSInstruction(MCInst *Inst, unsigned Insn,
916
+ uint64_t Address, void *Decoder)
917
+ {
918
+ DecodeStatus status = MCDisassembler_Fail;
919
+ unsigned n = fieldFromInstruction_2(Insn, 6, 2);
920
+ unsigned s1_d = fieldFromInstruction_2(Insn, 8, 4);
921
+ unsigned s2 = fieldFromInstruction_2(Insn, 12, 4);
922
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
923
+ if (is32Bit) // This instruction is 16-bit
924
+ return MCDisassembler_Fail;
925
+
926
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
927
+
928
+ // Decode s1_d.
929
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[0], Decoder);
930
+ if (status != MCDisassembler_Success)
931
+ return status;
932
+
933
+ // Decode s2.
934
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[1], Decoder);
935
+ if (status != MCDisassembler_Success)
936
+ return status;
937
+
938
+ // Decode n.
939
+ MCOperand_CreateImm0(Inst, n);
940
+
941
+ return MCDisassembler_Success;
942
+ }
943
+
944
+ static DecodeStatus DecodeSBCInstruction(MCInst *Inst, unsigned Insn,
945
+ uint64_t Address, void *Decoder)
946
+ {
947
+ unsigned disp4 = fieldFromInstruction_2(Insn, 8, 4);
948
+ unsigned const4 = fieldFromInstruction_2(Insn, 12, 4);
949
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
950
+ if (is32Bit) // This instruction is 16-bit
951
+ return MCDisassembler_Fail;
952
+
953
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
954
+ if (desc->NumOperands != 2) {
955
+ return MCDisassembler_Fail;
956
+ }
957
+
958
+ // Decode disp4.
959
+ MCOperand_CreateImm0(Inst, disp4);
960
+
961
+ // Decode const4.
962
+ MCOperand_CreateImm0(Inst, const4);
963
+
964
+ return MCDisassembler_Success;
965
+ }
966
+
967
+ static DecodeStatus DecodeSBRNInstruction(MCInst *Inst, unsigned Insn,
968
+ uint64_t Address, void *Decoder)
969
+ {
970
+ unsigned disp4 = fieldFromInstruction_2(Insn, 8, 4);
971
+ unsigned n = fieldFromInstruction_2(Insn, 12, 4);
972
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
973
+ if (is32Bit) // This instruction is 16-bit
974
+ return MCDisassembler_Fail;
975
+
976
+ // Decode n.
977
+ MCOperand_CreateImm0(Inst, n);
978
+ // Decode disp4.
979
+ MCOperand_CreateImm0(Inst, disp4);
980
+
981
+ return MCDisassembler_Success;
982
+ }
983
+
984
+ static DecodeStatus DecodeSSRInstruction(MCInst *Inst, unsigned Insn,
985
+ uint64_t Address, void *Decoder)
986
+ {
987
+ DecodeStatus status = MCDisassembler_Fail;
988
+ unsigned s1 = fieldFromInstruction_2(Insn, 8, 4);
989
+ unsigned s2 = fieldFromInstruction_2(Insn, 12, 4);
990
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
991
+ if (is32Bit) // This instruction is 16-bit
992
+ return MCDisassembler_Fail;
993
+
994
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
995
+
996
+ // Decode s2.
997
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[0], Decoder);
998
+ if (status != MCDisassembler_Success)
999
+ return status;
1000
+
1001
+ // Decode s1.
1002
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1003
+ if (status != MCDisassembler_Success)
1004
+ return status;
1005
+
1006
+ return MCDisassembler_Success;
1007
+ }
1008
+
1009
+ static DecodeStatus DecodeSSROInstruction(MCInst *Inst, unsigned Insn,
1010
+ uint64_t Address, void *Decoder)
1011
+ {
1012
+ DecodeStatus status = MCDisassembler_Fail;
1013
+ unsigned s1 = fieldFromInstruction_2(Insn, 8, 4);
1014
+ unsigned off4 = fieldFromInstruction_2(Insn, 12, 4);
1015
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1016
+ if (is32Bit) // This instruction is 16-bit
1017
+ return MCDisassembler_Fail;
1018
+
1019
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1020
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[0], Decoder);
1021
+ if (status != MCDisassembler_Success)
1022
+ return status;
1023
+
1024
+ // Decode off4.
1025
+ MCOperand_CreateImm0(Inst, off4);
1026
+
1027
+ return MCDisassembler_Success;
1028
+ }
1029
+
1030
+ /// 32-bit Opcode Format
1031
+
1032
+ static DecodeStatus DecodeSYSInstruction(MCInst *Inst, unsigned Insn,
1033
+ uint64_t Address, void *Decoder)
1034
+ {
1035
+ DecodeStatus status = MCDisassembler_Fail;
1036
+ unsigned s1_d = fieldFromInstruction_4(Insn, 8, 4);
1037
+
1038
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1039
+ if (!is32Bit) // This instruction is 32-bit
1040
+ return MCDisassembler_Fail;
1041
+
1042
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1043
+ if (desc->NumOperands > 0) {
1044
+ status = DecodeRegisterClass(Inst, s1_d, &desc->OpInfo[0],
1045
+ Decoder);
1046
+ if (status != MCDisassembler_Success)
1047
+ return status;
1048
+ }
1049
+
1050
+ return MCDisassembler_Success;
1051
+ }
1052
+
1053
+ static DecodeStatus DecodeRRR2Instruction(MCInst *Inst, unsigned Insn,
1054
+ uint64_t Address, void *Decoder)
1055
+ {
1056
+ DecodeStatus status = MCDisassembler_Fail;
1057
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1058
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
1059
+ unsigned s3 = fieldFromInstruction_4(Insn, 24, 4);
1060
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1061
+
1062
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1063
+ if (!is32Bit) // This instruction is 32-bit
1064
+ return MCDisassembler_Fail;
1065
+
1066
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1067
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
1068
+ if (status != MCDisassembler_Success)
1069
+ return status;
1070
+
1071
+ // Decode s1.
1072
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1073
+ if (status != MCDisassembler_Success)
1074
+ return status;
1075
+
1076
+ // Decode s2.
1077
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[2], Decoder);
1078
+ if (status != MCDisassembler_Success)
1079
+ return status;
1080
+
1081
+ // Decode s3.
1082
+ status = DecodeRegisterClass(Inst, s3, &desc->OpInfo[3], Decoder);
1083
+ if (status != MCDisassembler_Success)
1084
+ return status;
1085
+
1086
+ return MCDisassembler_Success;
1087
+ }
1088
+
1089
+ static DecodeStatus DecodeRRR1Instruction(MCInst *Inst, unsigned Insn,
1090
+ uint64_t Address, void *Decoder)
1091
+ {
1092
+ DecodeStatus status = MCDisassembler_Fail;
1093
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1094
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
1095
+ unsigned n = fieldFromInstruction_4(Insn, 16, 2);
1096
+ unsigned s3 = fieldFromInstruction_4(Insn, 24, 4);
1097
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1098
+
1099
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1100
+ if (!is32Bit) // This instruction is 32-bit
1101
+ return MCDisassembler_Fail;
1102
+
1103
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1104
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
1105
+ if (status != MCDisassembler_Success)
1106
+ return status;
1107
+
1108
+ // Decode s1.
1109
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1110
+ if (status != MCDisassembler_Success)
1111
+ return status;
1112
+
1113
+ // Decode s2.
1114
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[2], Decoder);
1115
+ if (status != MCDisassembler_Success)
1116
+ return status;
1117
+
1118
+ // Decode s3.
1119
+ status = DecodeRegisterClass(Inst, s3, &desc->OpInfo[3], Decoder);
1120
+ if (status != MCDisassembler_Success)
1121
+ return status;
1122
+
1123
+ // Decode n.
1124
+ MCOperand_CreateImm0(Inst, n);
1125
+
1126
+ return MCDisassembler_Success;
1127
+ }
1128
+
1129
+ static DecodeStatus DecodeBITInstruction(MCInst *Inst, unsigned Insn,
1130
+ uint64_t Address, void *Decoder)
1131
+ {
1132
+ DecodeStatus status = MCDisassembler_Fail;
1133
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1134
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
1135
+ unsigned pos1 = fieldFromInstruction_4(Insn, 16, 5);
1136
+ unsigned pos2 = fieldFromInstruction_4(Insn, 23, 5);
1137
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1138
+
1139
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1140
+ if (!is32Bit) // This instruction is 32-bit
1141
+ return MCDisassembler_Fail;
1142
+
1143
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1144
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
1145
+ if (status != MCDisassembler_Success)
1146
+ return status;
1147
+
1148
+ // Decode s1.
1149
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1150
+ if (status != MCDisassembler_Success)
1151
+ return status;
1152
+
1153
+ // Decode s2.
1154
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[2], Decoder);
1155
+ if (status != MCDisassembler_Success)
1156
+ return status;
1157
+
1158
+ // Decode pos1.
1159
+ MCOperand_CreateImm0(Inst, pos1);
1160
+
1161
+ // Decode pos2.
1162
+ MCOperand_CreateImm0(Inst, pos2);
1163
+
1164
+ return MCDisassembler_Success;
1165
+ }
1166
+
1167
+ static DecodeStatus DecodeRR1Instruction(MCInst *Inst, unsigned Insn,
1168
+ uint64_t Address, void *Decoder)
1169
+ {
1170
+ DecodeStatus status = MCDisassembler_Fail;
1171
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1172
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
1173
+ unsigned n = fieldFromInstruction_4(Insn, 16, 2);
1174
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1175
+
1176
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1177
+ if (!is32Bit) // This instruction is 32-bit
1178
+ return MCDisassembler_Fail;
1179
+
1180
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1181
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
1182
+ if (status != MCDisassembler_Success)
1183
+ return status;
1184
+
1185
+ // Decode s1.
1186
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1187
+ if (status != MCDisassembler_Success)
1188
+ return status;
1189
+
1190
+ // Decode s2.
1191
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[2], Decoder);
1192
+ if (status != MCDisassembler_Success)
1193
+ return status;
1194
+
1195
+ // Decode n.
1196
+ MCOperand_CreateImm0(Inst, n);
1197
+
1198
+ return MCDisassembler_Success;
1199
+ }
1200
+
1201
+ static DecodeStatus DecodeRCRInstruction(MCInst *Inst, unsigned Insn,
1202
+ uint64_t Address, void *Decoder)
1203
+ {
1204
+ DecodeStatus status = MCDisassembler_Fail;
1205
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1206
+ unsigned const9 = fieldFromInstruction_4(Insn, 12, 9);
1207
+ unsigned s3 = fieldFromInstruction_4(Insn, 24, 4);
1208
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1209
+
1210
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1211
+ if (!is32Bit) // This instruction is 32-bit
1212
+ return MCDisassembler_Fail;
1213
+
1214
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1215
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
1216
+ if (status != MCDisassembler_Success)
1217
+ return status;
1218
+
1219
+ // Decode s1.
1220
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1221
+ if (status != MCDisassembler_Success)
1222
+ return status;
1223
+
1224
+ // Decode s3.
1225
+ status = DecodeRegisterClass(Inst, s3, &desc->OpInfo[2], Decoder);
1226
+ if (status != MCDisassembler_Success)
1227
+ return status;
1228
+
1229
+ // Decode const9.
1230
+ MCOperand_CreateImm0(Inst, const9);
1231
+
1232
+ return MCDisassembler_Success;
1233
+ }
1234
+
1235
+ static DecodeStatus DecodeRRRWInstruction(MCInst *Inst, unsigned Insn,
1236
+ uint64_t Address, void *Decoder)
1237
+ {
1238
+ DecodeStatus status = MCDisassembler_Fail;
1239
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1240
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
1241
+ unsigned width = fieldFromInstruction_4(Insn, 16, 5);
1242
+ unsigned s3 = fieldFromInstruction_4(Insn, 24, 4);
1243
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1244
+
1245
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1246
+ if (!is32Bit) // This instruction is 32-bit
1247
+ return MCDisassembler_Fail;
1248
+
1249
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1250
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
1251
+ if (status != MCDisassembler_Success)
1252
+ return status;
1253
+
1254
+ // Decode s1.
1255
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1256
+ if (status != MCDisassembler_Success)
1257
+ return status;
1258
+
1259
+ // Decode s2.
1260
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[2], Decoder);
1261
+ if (status != MCDisassembler_Success)
1262
+ return status;
1263
+
1264
+ // Decode s3.
1265
+ status = DecodeRegisterClass(Inst, s3, &desc->OpInfo[3], Decoder);
1266
+ if (status != MCDisassembler_Success)
1267
+ return status;
1268
+
1269
+ // Decode width.
1270
+ MCOperand_CreateImm0(Inst, width);
1271
+
1272
+ return MCDisassembler_Success;
1273
+ }
1274
+
1275
+ static DecodeStatus DecodeRCRRInstruction(MCInst *Inst, unsigned Insn,
1276
+ uint64_t Address, void *Decoder)
1277
+ {
1278
+ DecodeStatus status = MCDisassembler_Fail;
1279
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1280
+ unsigned const4 = fieldFromInstruction_4(Insn, 12, 4);
1281
+ unsigned s3 = fieldFromInstruction_4(Insn, 24, 4);
1282
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1283
+
1284
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1285
+ if (!is32Bit) // This instruction is 32-bit
1286
+ return MCDisassembler_Fail;
1287
+
1288
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1289
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
1290
+ if (status != MCDisassembler_Success)
1291
+ return status;
1292
+
1293
+ // Decode s1.
1294
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1295
+ if (status != MCDisassembler_Success)
1296
+ return status;
1297
+
1298
+ // Decode const4.
1299
+ MCOperand_CreateImm0(Inst, const4);
1300
+
1301
+ // Decode s3.
1302
+ status = DecodeRegisterClass(Inst, s3, &desc->OpInfo[3], Decoder);
1303
+ if (status != MCDisassembler_Success)
1304
+ return status;
1305
+
1306
+ return MCDisassembler_Success;
1307
+ }
1308
+
1309
+ static DecodeStatus DecodeRRRRInstruction(MCInst *Inst, unsigned Insn,
1310
+ uint64_t Address, void *Decoder)
1311
+ {
1312
+ DecodeStatus status = MCDisassembler_Fail;
1313
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1314
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
1315
+ unsigned s3 = fieldFromInstruction_4(Insn, 24, 4);
1316
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1317
+
1318
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1319
+ if (!is32Bit) // This instruction is 32-bit
1320
+ return MCDisassembler_Fail;
1321
+
1322
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1323
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
1324
+ if (status != MCDisassembler_Success)
1325
+ return status;
1326
+
1327
+ // Decode s1.
1328
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1329
+ if (status != MCDisassembler_Success)
1330
+ return status;
1331
+
1332
+ if (desc->NumOperands == 3) {
1333
+ switch (MCInst_getOpcode(Inst)) {
1334
+ case TRICORE_EXTR_rrrr:
1335
+ case TRICORE_EXTR_U_rrrr:
1336
+ return DecodeRegisterClass(Inst, s3, &desc->OpInfo[2], Decoder);
1337
+ default:
1338
+ return DecodeRegisterClass(Inst, s2, &desc->OpInfo[2], Decoder);
1339
+ }
1340
+ }
1341
+
1342
+ // Decode s2.
1343
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[2], Decoder);
1344
+ if (status != MCDisassembler_Success)
1345
+ return status;
1346
+ // Decode s3.
1347
+ status = DecodeRegisterClass(Inst, s3, &desc->OpInfo[3], Decoder);
1348
+ if (status != MCDisassembler_Success)
1349
+ return status;
1350
+
1351
+ return MCDisassembler_Success;
1352
+ }
1353
+
1354
+ static DecodeStatus DecodeBRRInstruction(MCInst *Inst, unsigned Insn,
1355
+ uint64_t Address, void *Decoder)
1356
+ {
1357
+ DecodeStatus status = MCDisassembler_Fail;
1358
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1359
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
1360
+ unsigned disp15 = fieldFromInstruction_4(Insn, 16, 15);
1361
+
1362
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1363
+ if (!is32Bit) // This instruction is 32-bit
1364
+ return MCDisassembler_Fail;
1365
+
1366
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1367
+ if (MCInst_getOpcode(Inst) == TRICORE_LOOP_brr) {
1368
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[0],
1369
+ Decoder);
1370
+ if (status != MCDisassembler_Success)
1371
+ return status;
1372
+
1373
+ MCOperand_CreateImm0(Inst, disp15);
1374
+ return MCDisassembler_Success;
1375
+ }
1376
+
1377
+ if (desc->NumOperands >= 2) {
1378
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[0],
1379
+ Decoder);
1380
+ if (status != MCDisassembler_Success)
1381
+ return status;
1382
+
1383
+ if (desc->NumOperands >= 3) {
1384
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[1],
1385
+ Decoder);
1386
+ if (status != MCDisassembler_Success)
1387
+ return status;
1388
+ }
1389
+ }
1390
+
1391
+ // Decode disp15.
1392
+ MCOperand_CreateImm0(Inst, disp15);
1393
+
1394
+ return MCDisassembler_Success;
1395
+ }
1396
+
1397
+ static DecodeStatus DecodeBRCInstruction(MCInst *Inst, unsigned Insn,
1398
+ uint64_t Address, void *Decoder)
1399
+ {
1400
+ DecodeStatus status = MCDisassembler_Fail;
1401
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1402
+ unsigned const4 = fieldFromInstruction_4(Insn, 12, 4);
1403
+ unsigned disp15 = fieldFromInstruction_4(Insn, 16, 15);
1404
+
1405
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1406
+ if (!is32Bit) // This instruction is 32-bit
1407
+ return MCDisassembler_Fail;
1408
+
1409
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1410
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[0], Decoder);
1411
+ if (status != MCDisassembler_Success)
1412
+ return status;
1413
+
1414
+ // Decode const4.
1415
+ MCOperand_CreateImm0(Inst, const4);
1416
+
1417
+ // Decode disp15.
1418
+ MCOperand_CreateImm0(Inst, disp15);
1419
+
1420
+ return MCDisassembler_Success;
1421
+ }
1422
+
1423
+ static DecodeStatus DecodeRRRInstruction(MCInst *Inst, unsigned Insn,
1424
+ uint64_t Address, void *Decoder)
1425
+ {
1426
+ DecodeStatus status = MCDisassembler_Fail;
1427
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1428
+ unsigned s2 = fieldFromInstruction_4(Insn, 12, 4);
1429
+ // unsigned n = fieldFromInstruction_4(Insn, 16, 2);
1430
+ unsigned s3 = fieldFromInstruction_4(Insn, 24, 4);
1431
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1432
+
1433
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1434
+ if (!is32Bit) // This instruction is 32-bit
1435
+ return MCDisassembler_Fail;
1436
+
1437
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1438
+ status = DecodeRegisterClass(Inst, d, &desc->OpInfo[0], Decoder);
1439
+ if (status != MCDisassembler_Success)
1440
+ return status;
1441
+
1442
+ // Decode s1.
1443
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[1], Decoder);
1444
+ if (status != MCDisassembler_Success)
1445
+ return status;
1446
+
1447
+ // Decode s2.
1448
+ status = DecodeRegisterClass(Inst, s2, &desc->OpInfo[2], Decoder);
1449
+ if (status != MCDisassembler_Success)
1450
+ return status;
1451
+
1452
+ // Decode s3.
1453
+ status = DecodeRegisterClass(Inst, s3, &desc->OpInfo[3], Decoder);
1454
+ if (status != MCDisassembler_Success)
1455
+ return status;
1456
+
1457
+ return MCDisassembler_Success;
1458
+ }
1459
+
1460
+ static DecodeStatus DecodeABSBInstruction(MCInst *Inst, unsigned Insn,
1461
+ uint64_t Address, void *Decoder)
1462
+ {
1463
+ unsigned bpos3 = fieldFromInstruction_4(Insn, 8, 3);
1464
+ unsigned b = fieldFromInstruction_4(Insn, 12, 1);
1465
+
1466
+ unsigned off18_0_5 = fieldFromInstruction_4(Insn, 16, 6);
1467
+ unsigned off18_6_9 = fieldFromInstruction_4(Insn, 28, 4);
1468
+ unsigned off18_10_13 = fieldFromInstruction_4(Insn, 22, 4);
1469
+ unsigned off18_14_17 = fieldFromInstruction_4(Insn, 12, 4);
1470
+ unsigned off18 = (off18_0_5 << 0) | (off18_6_9 << 6) |
1471
+ (off18_10_13 << 10) | (off18_14_17 << 14);
1472
+
1473
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1474
+ if (!is32Bit) // This instruction is 32-bit
1475
+ return MCDisassembler_Fail;
1476
+
1477
+ decodeImm(off18) decodeImm(bpos3) decodeImm(b)
1478
+
1479
+ return MCDisassembler_Success;
1480
+ }
1481
+
1482
+ static DecodeStatus DecodeRCRWInstruction(MCInst *Inst, unsigned Insn,
1483
+ uint64_t Address, void *Decoder)
1484
+ {
1485
+ DecodeStatus status = MCDisassembler_Fail;
1486
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1487
+ unsigned const4 = fieldFromInstruction_4(Insn, 12, 4);
1488
+ unsigned width = fieldFromInstruction_4(Insn, 16, 5);
1489
+ unsigned s3 = fieldFromInstruction_4(Insn, 24, 4);
1490
+ unsigned d = fieldFromInstruction_4(Insn, 28, 4);
1491
+
1492
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1493
+ if (!is32Bit) // This instruction is 32-bit
1494
+ return MCDisassembler_Fail;
1495
+
1496
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1497
+ tryDecodeReg(0, d) tryDecodeReg(1, s1) tryDecodeReg(2, s3)
1498
+ decodeImm(const4) decodeImm(width)
1499
+
1500
+ return MCDisassembler_Success;
1501
+ }
1502
+
1503
+ static DecodeStatus DecodeBRNInstruction(MCInst *Inst, unsigned Insn,
1504
+ uint64_t Address, void *Decoder)
1505
+ {
1506
+ DecodeStatus status = MCDisassembler_Fail;
1507
+ unsigned s1 = fieldFromInstruction_4(Insn, 8, 4);
1508
+
1509
+ unsigned n_0_3 = fieldFromInstruction_4(Insn, 12, 4);
1510
+ unsigned n_4 = fieldFromInstruction_4(Insn, 7, 1);
1511
+ unsigned n = (n_0_3 << 0) | (n_4 << 4);
1512
+
1513
+ unsigned disp15 = fieldFromInstruction_4(Insn, 16, 15);
1514
+
1515
+ unsigned is32Bit = fieldFromInstruction_4(Insn, 0, 1);
1516
+ if (!is32Bit) // This instruction is 32-bit
1517
+ return MCDisassembler_Fail;
1518
+
1519
+ const MCInstrDesc *desc = &TriCoreInsts[MCInst_getOpcode(Inst)];
1520
+ status = DecodeRegisterClass(Inst, s1, &desc->OpInfo[0], Decoder);
1521
+ if (status != MCDisassembler_Success)
1522
+ return status;
1523
+
1524
+ // Decode n.
1525
+ MCOperand_CreateImm0(Inst, n);
1526
+
1527
+ // Decode disp15.
1528
+ MCOperand_CreateImm0(Inst, disp15);
1529
+
1530
+ return MCDisassembler_Success;
1531
+ }
1532
+
1533
+ #define GET_SUBTARGETINFO_ENUM
1534
+
1535
+ #include "TriCoreGenInstrInfo.inc"
1536
+
1537
+ static inline bool tryGetInstruction16(const uint8_t *code, size_t code_len,
1538
+ MCInst *MI, uint16_t *size,
1539
+ uint64_t address, void *info,
1540
+ const uint8_t *decoderTable16)
1541
+ {
1542
+ if (code_len < 2) {
1543
+ return false;
1544
+ }
1545
+ uint16_t insn16 = readBytes16(MI, code);
1546
+ DecodeStatus Result = decodeInstruction_2(decoderTable16, MI, insn16,
1547
+ address, info, 0);
1548
+ if (Result != MCDisassembler_Fail) {
1549
+ *size = 2;
1550
+ return true;
1551
+ }
1552
+ return false;
1553
+ }
1554
+
1555
+ static inline bool tryGetInstruction32(const uint8_t *code, size_t code_len,
1556
+ MCInst *MI, uint16_t *size,
1557
+ uint64_t address, void *info,
1558
+ const uint8_t *decoderTable32)
1559
+ {
1560
+ if (code_len < 4) {
1561
+ return false;
1562
+ }
1563
+ uint32_t insn32 = readBytes32(MI, code);
1564
+ DecodeStatus Result = decodeInstruction_4(decoderTable32, MI, insn32,
1565
+ address, info, 0);
1566
+ if (Result != MCDisassembler_Fail) {
1567
+ *size = 4;
1568
+ return true;
1569
+ }
1570
+ return false;
1571
+ }
1572
+
1573
+ static bool getInstruction(csh ud, const uint8_t *code, size_t code_len,
1574
+ MCInst *MI, uint16_t *size, uint64_t address,
1575
+ void *info)
1576
+ {
1577
+ if (!ud) {
1578
+ return false;
1579
+ }
1580
+
1581
+ struct cs_struct *cs = (struct cs_struct *)ud;
1582
+ if (MI->flat_insn->detail) {
1583
+ memset(MI->flat_insn->detail, 0, sizeof(cs_detail));
1584
+ }
1585
+
1586
+ switch (cs->mode) {
1587
+ case CS_MODE_TRICORE_110: {
1588
+ if (tryGetInstruction16(code, code_len, MI, size, address, info,
1589
+ DecoderTablev11016) ||
1590
+ tryGetInstruction32(code, code_len, MI, size, address, info,
1591
+ DecoderTablev11032)) {
1592
+ return true;
1593
+ }
1594
+ break;
1595
+ }
1596
+ case CS_MODE_TRICORE_161: {
1597
+ if (tryGetInstruction32(code, code_len, MI, size, address, info,
1598
+ DecoderTablev16132)) {
1599
+ return true;
1600
+ }
1601
+ break;
1602
+ }
1603
+ case CS_MODE_TRICORE_162: {
1604
+ if (tryGetInstruction16(code, code_len, MI, size, address, info,
1605
+ DecoderTablev16216) ||
1606
+ tryGetInstruction32(code, code_len, MI, size, address, info,
1607
+ DecoderTablev16232)) {
1608
+ return true;
1609
+ }
1610
+ break;
1611
+ }
1612
+ default:
1613
+ break;
1614
+ }
1615
+
1616
+ return tryGetInstruction16(code, code_len, MI, size, address, info,
1617
+ DecoderTable16) ||
1618
+ tryGetInstruction32(code, code_len, MI, size, address, info,
1619
+ DecoderTable32);
1620
+ }
1621
+
1622
+ bool TriCore_LLVM_getInstruction(csh handle, const uint8_t *Bytes,
1623
+ size_t ByteLen, MCInst *MI, uint16_t *Size,
1624
+ uint64_t Address, void *Info)
1625
+ {
1626
+ bool Result =
1627
+ getInstruction(handle, Bytes, ByteLen, MI, Size, Address, Info);
1628
+ if (Result) {
1629
+ TriCore_set_instr_map_data(MI);
1630
+ }
1631
+ return Result;
1632
+ }
1633
+
1634
+ void TriCore_init_mri(MCRegisterInfo *MRI)
1635
+ {
1636
+ /*
1637
+ InitMCRegisterInfo(TriCoreRegDesc, 45, RA, PC,
1638
+ TriCoreMCRegisterClasses, 4,
1639
+ TriCoreRegUnitRoots,
1640
+ 16,
1641
+ TriCoreRegDiffLists,
1642
+ TriCoreRegStrings,
1643
+ TriCoreSubRegIdxLists,
1644
+ 1,
1645
+ TriCoreSubRegIdxRanges,
1646
+ TriCoreRegEncodingTable);
1647
+ */
1648
+
1649
+ MCRegisterInfo_InitMCRegisterInfo(
1650
+ MRI, TriCoreRegDesc, ARR_SIZE(TriCoreRegDesc), 0, 0,
1651
+ TriCoreMCRegisterClasses, ARR_SIZE(TriCoreMCRegisterClasses), 0,
1652
+ 0, TriCoreRegDiffLists, 0, TriCoreSubRegIdxLists, 1, 0);
1653
+ }
1654
+
1655
+ #endif