暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BurstDisassembler.Core.ARM64.cs 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. #if UNITY_EDITOR || BURST_INTERNAL
  2. namespace Unity.Burst.Editor
  3. {
  4. internal partial class BurstDisassembler
  5. {
  6. private class ARM64AsmTokenKindProvider : AsmTokenKindProvider
  7. {
  8. private static readonly string[] Registers = new[]
  9. {
  10. "nzcv",
  11. "wsp",
  12. "sp",
  13. "r0",
  14. "r1",
  15. "r2",
  16. "r3",
  17. "r4",
  18. "r5",
  19. "r6",
  20. "r7",
  21. "r8",
  22. "r9",
  23. "r10",
  24. "r11",
  25. "r12",
  26. "r13",
  27. "r14",
  28. "r15",
  29. "b0",
  30. "b1",
  31. "b2",
  32. "b3",
  33. "b4",
  34. "b5",
  35. "b6",
  36. "b7",
  37. "b8",
  38. "b9",
  39. "b10",
  40. "b11",
  41. "b12",
  42. "b13",
  43. "b14",
  44. "b15",
  45. "b16",
  46. "b17",
  47. "b18",
  48. "b19",
  49. "b20",
  50. "b21",
  51. "b22",
  52. "b23",
  53. "b24",
  54. "b25",
  55. "b26",
  56. "b27",
  57. "b28",
  58. "b29",
  59. "b30",
  60. "b31",
  61. "d0",
  62. "d1",
  63. "d2",
  64. "d3",
  65. "d4",
  66. "d5",
  67. "d6",
  68. "d7",
  69. "d8",
  70. "d9",
  71. "d10",
  72. "d11",
  73. "d12",
  74. "d13",
  75. "d14",
  76. "d15",
  77. "d16",
  78. "d17",
  79. "d18",
  80. "d19",
  81. "d20",
  82. "d21",
  83. "d22",
  84. "d23",
  85. "d24",
  86. "d25",
  87. "d26",
  88. "d27",
  89. "d28",
  90. "d29",
  91. "d30",
  92. "d31",
  93. "h0",
  94. "h1",
  95. "h2",
  96. "h3",
  97. "h4",
  98. "h5",
  99. "h6",
  100. "h7",
  101. "h8",
  102. "h9",
  103. "h10",
  104. "h11",
  105. "h12",
  106. "h13",
  107. "h14",
  108. "h15",
  109. "h16",
  110. "h17",
  111. "h18",
  112. "h19",
  113. "h20",
  114. "h21",
  115. "h22",
  116. "h23",
  117. "h24",
  118. "h25",
  119. "h26",
  120. "h27",
  121. "h28",
  122. "h29",
  123. "h30",
  124. "h31",
  125. "q0",
  126. "q1",
  127. "q2",
  128. "q3",
  129. "q4",
  130. "q5",
  131. "q6",
  132. "q7",
  133. "q8",
  134. "q9",
  135. "q10",
  136. "q11",
  137. "q12",
  138. "q13",
  139. "q14",
  140. "q15",
  141. "q16",
  142. "q17",
  143. "q18",
  144. "q19",
  145. "q20",
  146. "q21",
  147. "q22",
  148. "q23",
  149. "q24",
  150. "q25",
  151. "q26",
  152. "q27",
  153. "q28",
  154. "q29",
  155. "q30",
  156. "q31",
  157. "s0",
  158. "s1",
  159. "s2",
  160. "s3",
  161. "s4",
  162. "s5",
  163. "s6",
  164. "s7",
  165. "s8",
  166. "s9",
  167. "s10",
  168. "s11",
  169. "s12",
  170. "s13",
  171. "s14",
  172. "s15",
  173. "s16",
  174. "s17",
  175. "s18",
  176. "s19",
  177. "s20",
  178. "s21",
  179. "s22",
  180. "s23",
  181. "s24",
  182. "s25",
  183. "s26",
  184. "s27",
  185. "s28",
  186. "s29",
  187. "s30",
  188. "s31",
  189. "w0",
  190. "w1",
  191. "w2",
  192. "w3",
  193. "w4",
  194. "w5",
  195. "w6",
  196. "w7",
  197. "w8",
  198. "w9",
  199. "w10",
  200. "w11",
  201. "w12",
  202. "w13",
  203. "w14",
  204. "w15",
  205. "w16",
  206. "w17",
  207. "w18",
  208. "w19",
  209. "w20",
  210. "w21",
  211. "w22",
  212. "w23",
  213. "w24",
  214. "w25",
  215. "w26",
  216. "w27",
  217. "w28",
  218. "w29",
  219. "w30",
  220. "wzr",
  221. "x0",
  222. "x1",
  223. "x2",
  224. "x3",
  225. "x4",
  226. "x5",
  227. "x6",
  228. "x7",
  229. "x8",
  230. "x9",
  231. "x10",
  232. "x11",
  233. "x12",
  234. "x13",
  235. "x14",
  236. "x15",
  237. "x16",
  238. "x17",
  239. "x18",
  240. "x19",
  241. "x20",
  242. "x21",
  243. "x22",
  244. "x23",
  245. "x24",
  246. "x25",
  247. "x26",
  248. "x27",
  249. "x28",
  250. "x29",
  251. "x30",
  252. };
  253. private static readonly string[] Qualifiers = new[]
  254. {
  255. // Comparison qualifiers
  256. "eq",
  257. "ne",
  258. "hs",
  259. "lo",
  260. "mi",
  261. "pl",
  262. "vs",
  263. "vc",
  264. "hi",
  265. "ls",
  266. "ge",
  267. "lt",
  268. "gt",
  269. "le",
  270. "al",
  271. "nv",
  272. };
  273. private static readonly string[] Instructions = new[]
  274. {
  275. "abs",
  276. "adc",
  277. "add",
  278. "addhn",
  279. "addhn2",
  280. "addp",
  281. "addv",
  282. "adr",
  283. "adrp",
  284. "aesd",
  285. "aese",
  286. "aesimc",
  287. "aesmc",
  288. "and",
  289. "asr",
  290. "at",
  291. "b",
  292. "beq",
  293. "bfi",
  294. "bfm",
  295. "bfxil",
  296. "bge",
  297. "bgt",
  298. "bic",
  299. "bif",
  300. "bit",
  301. "bl",
  302. "ble",
  303. "blr",
  304. "blx",
  305. "bne",
  306. "br",
  307. "brk",
  308. "bsl",
  309. "cbnz",
  310. "cbz",
  311. "ccmn",
  312. "ccmp",
  313. "clrex",
  314. "cls",
  315. "clz",
  316. "cmeq",
  317. "cmge",
  318. "cmgt",
  319. "cmhi",
  320. "cmhs",
  321. "cmle",
  322. "cmlt",
  323. "cmn",
  324. "cmp",
  325. "cmtst",
  326. "cnt",
  327. "crc32b",
  328. "crc32cb",
  329. "crc32ch",
  330. "crc32cw",
  331. "crc32cx",
  332. "crc32h",
  333. "crc32w",
  334. "crc32x",
  335. "csel",
  336. "csinc",
  337. "csinv",
  338. "csneg",
  339. "dc",
  340. "dcps1",
  341. "dcps2",
  342. "dcps3",
  343. "dmb",
  344. "drps",
  345. "dsb",
  346. "dup",
  347. "eon",
  348. "eor",
  349. "eret",
  350. "ext",
  351. "extr",
  352. "fabd",
  353. "fabs",
  354. "facge",
  355. "facgt",
  356. "fadd",
  357. "faddp",
  358. "fccmp",
  359. "fccmpe",
  360. "fcmeq",
  361. "fcmge",
  362. "fcmgt",
  363. "fcmle",
  364. "fcmlt",
  365. "fcmp",
  366. "fcmpe",
  367. "fcsel",
  368. "fcvt",
  369. "fcvtas",
  370. "fcvtau",
  371. "fcvtl",
  372. "fcvtl2",
  373. "fcvtms",
  374. "fcvtmu",
  375. "fcvtn",
  376. "fcvtn2",
  377. "fcvtns",
  378. "fcvtnu",
  379. "fcvtps",
  380. "fcvtpu",
  381. "fcvtxn",
  382. "fcvtxn2",
  383. "fcvtzs",
  384. "fcvtzu",
  385. "fdiv",
  386. "fmadd",
  387. "fmax",
  388. "fmaxnm",
  389. "fmaxnmp",
  390. "fmaxnmv",
  391. "fmaxp",
  392. "fmaxv",
  393. "fmin",
  394. "fminnm",
  395. "fminnmp",
  396. "fminnmv",
  397. "fminp",
  398. "fminv",
  399. "fmla",
  400. "fmls",
  401. "fmov",
  402. "fmsub",
  403. "fmul",
  404. "fmulx",
  405. "fneg",
  406. "fnmadd",
  407. "fnmsub",
  408. "fnmul",
  409. "frecpe",
  410. "frecps",
  411. "frecpx",
  412. "frinta",
  413. "frinti",
  414. "frintm",
  415. "frintn",
  416. "frintp",
  417. "frintx",
  418. "frintz",
  419. "frsqrte",
  420. "frsqrts",
  421. "fsqrt",
  422. "fsub",
  423. "hint",
  424. "hlt",
  425. "hvc",
  426. "ic",
  427. "ins",
  428. "isb",
  429. "ld1",
  430. "ld1r",
  431. "ld2",
  432. "ld2r",
  433. "ld3",
  434. "ld3r",
  435. "ld4",
  436. "ld4r",
  437. "ldar",
  438. "ldarb",
  439. "ldarh",
  440. "ldaxp",
  441. "ldaxr",
  442. "ldaxrb",
  443. "ldaxrh",
  444. "ldnp",
  445. "ldp",
  446. "ldpsw",
  447. "ldr",
  448. "ldrb",
  449. "ldrd",
  450. "ldrh",
  451. "ldrsb",
  452. "ldrsh",
  453. "ldrsw",
  454. "ldtr",
  455. "ldtrb",
  456. "ldtrh",
  457. "ldtrsb",
  458. "ldtrsh",
  459. "ldtrsw",
  460. "ldur",
  461. "ldurb",
  462. "ldurh",
  463. "ldursb",
  464. "ldursh",
  465. "ldursw",
  466. "ldxp",
  467. "ldxr",
  468. "ldxrb",
  469. "ldxrh",
  470. "lsl",
  471. "lsls",
  472. "lsr",
  473. "madd",
  474. "mla",
  475. "mls",
  476. "mneg",
  477. "mov",
  478. "movi",
  479. "movk",
  480. "movn",
  481. "movt",
  482. "movz",
  483. "movw",
  484. "mrs",
  485. "msr",
  486. "msub",
  487. "mul",
  488. "mvn",
  489. "mvni",
  490. "neg",
  491. "ngc",
  492. "nop",
  493. "not",
  494. "orn",
  495. "orr",
  496. "pmul",
  497. "pmull",
  498. "pmull2",
  499. "prfm",
  500. "prfum",
  501. "raddhn",
  502. "raddhn2",
  503. "rbit",
  504. "ret",
  505. "rev",
  506. "rev16",
  507. "rev32",
  508. "rev64",
  509. "ror",
  510. "rshrn",
  511. "rshrn2",
  512. "rsubhn",
  513. "rsubhn2",
  514. "saba",
  515. "sabal",
  516. "sabal2",
  517. "sabd",
  518. "sabdl",
  519. "sabdl2",
  520. "sadalp",
  521. "saddl",
  522. "saddl2",
  523. "saddlp",
  524. "saddlv",
  525. "saddw",
  526. "saddw2",
  527. "sbc",
  528. "sbfiz",
  529. "sbfm",
  530. "sbfx",
  531. "scvtf",
  532. "sdiv",
  533. "sev",
  534. "sevl",
  535. "sha1c",
  536. "sha1h",
  537. "sha1m",
  538. "sha1p",
  539. "sha1su0",
  540. "sha1su1",
  541. "sha256h",
  542. "sha256h2",
  543. "sha256su0",
  544. "sha256su1",
  545. "shadd",
  546. "shl",
  547. "shll",
  548. "shll2",
  549. "shrn",
  550. "shrn2",
  551. "shsub",
  552. "sli",
  553. "smaddl",
  554. "smax",
  555. "smaxp",
  556. "smaxv",
  557. "smc",
  558. "smin",
  559. "sminp",
  560. "sminv",
  561. "smlal",
  562. "smlal2",
  563. "smlsl",
  564. "smlsl2",
  565. "smnegl",
  566. "smov",
  567. "smsubl",
  568. "smulh",
  569. "smull",
  570. "smull2",
  571. "sqabs",
  572. "sqadd",
  573. "sqdmlal",
  574. "sqdmlal2",
  575. "sqdmlsl",
  576. "sqdmlsl2",
  577. "sqdmulh",
  578. "sqdmull",
  579. "sqdmull2",
  580. "sqneg",
  581. "sqrdmulh",
  582. "sqrshl",
  583. "sqrshrn",
  584. "sqrshrn2",
  585. "sqrshrun",
  586. "sqrshrun2",
  587. "sqshl",
  588. "sqshlu",
  589. "sqshrn",
  590. "sqshrn2",
  591. "sqshrun",
  592. "sqshrun2",
  593. "sqsub",
  594. "sqxtn",
  595. "sqxtn2",
  596. "sqxtun",
  597. "sqxtun2",
  598. "srhadd",
  599. "sri",
  600. "srshl",
  601. "srshr",
  602. "srsra",
  603. "sshl",
  604. "sshll",
  605. "sshll2",
  606. "sshr",
  607. "ssra",
  608. "ssubl",
  609. "ssubl2",
  610. "ssubw",
  611. "ssubw2",
  612. "st1",
  613. "st2",
  614. "st3",
  615. "st4",
  616. "stlr",
  617. "stlrb",
  618. "stlrh",
  619. "stlxp",
  620. "stlxr",
  621. "stlxrb",
  622. "stlxrh",
  623. "stnp",
  624. "stp",
  625. "str",
  626. "strb",
  627. "strh",
  628. "sttr",
  629. "sttrb",
  630. "sttrh",
  631. "stur",
  632. "sturb",
  633. "sturh",
  634. "stxp",
  635. "stxr",
  636. "stxrb",
  637. "stxrh",
  638. "sub",
  639. "subs",
  640. "subhn",
  641. "subhn2",
  642. "suqadd",
  643. "svc",
  644. "sxtb",
  645. "sxth",
  646. "sxtw",
  647. "sys",
  648. "sysl",
  649. "tbl",
  650. "tbnz",
  651. "tbx",
  652. "tbz",
  653. "tlbi",
  654. "trn1",
  655. "trn2",
  656. "tst",
  657. "uaba",
  658. "uabal",
  659. "uabal2",
  660. "uabd",
  661. "uabdl",
  662. "uabdl2",
  663. "uadalp",
  664. "uaddl",
  665. "uaddl2",
  666. "uaddlp",
  667. "uaddlv",
  668. "uaddw",
  669. "uaddw2",
  670. "ubfiz",
  671. "ubfm",
  672. "ubfx",
  673. "ucvtf",
  674. "udiv",
  675. "uhadd",
  676. "uhsub",
  677. "umaddl",
  678. "umax",
  679. "umaxp",
  680. "umaxv",
  681. "umin",
  682. "uminp",
  683. "uminv",
  684. "umlal",
  685. "umlal2",
  686. "umlsl",
  687. "umlsl2",
  688. "umnegl",
  689. "umov",
  690. "umsubl",
  691. "umulh",
  692. "umull",
  693. "umull2",
  694. "uqadd",
  695. "uqrshl",
  696. "uqrshrn",
  697. "uqrshrn2",
  698. "uqshl",
  699. "uqshrn",
  700. "uqshrn2",
  701. "uqsub",
  702. "uqxtn",
  703. "uqxtn2",
  704. "urecpe",
  705. "urhadd",
  706. "urshl",
  707. "urshr",
  708. "ursqrte",
  709. "ursra",
  710. "ushl",
  711. "ushll",
  712. "ushll2",
  713. "ushr",
  714. "usqadd",
  715. "usra",
  716. "usubl",
  717. "usubl2",
  718. "usubw",
  719. "usubw2",
  720. "uxtb",
  721. "uxth",
  722. "uzp1",
  723. "uzp2",
  724. "wfe",
  725. "wfi",
  726. "xtn",
  727. "xtn2",
  728. "yield",
  729. "zip1",
  730. "zip2",
  731. };
  732. private static readonly string[] SimdInstructions = new string[]
  733. {
  734. // TODO: add missing instructions
  735. "vabs",
  736. "vadd",
  737. "vmov",
  738. "vmul",
  739. "vsub",
  740. };
  741. private ARM64AsmTokenKindProvider() : base(Registers.Length + Qualifiers.Length + Instructions.Length + SimdInstructions.Length)
  742. {
  743. foreach (var register in Registers)
  744. {
  745. AddTokenKind(register, AsmTokenKind.Register);
  746. }
  747. foreach (var instruction in Qualifiers)
  748. {
  749. AddTokenKind(instruction, AsmTokenKind.Qualifier);
  750. }
  751. foreach (var instruction in Instructions)
  752. {
  753. AddTokenKind(instruction, AsmTokenKind.Instruction);
  754. }
  755. foreach (var instruction in SimdInstructions)
  756. {
  757. AddTokenKind(instruction, AsmTokenKind.InstructionSIMD);
  758. }
  759. }
  760. public static readonly ARM64AsmTokenKindProvider Instance = new ARM64AsmTokenKindProvider();
  761. }
  762. }
  763. }
  764. #endif