Brak opisu
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.Wasm.cs 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #if UNITY_EDITOR || BURST_INTERNAL
  2. namespace Unity.Burst.Editor
  3. {
  4. internal partial class BurstDisassembler
  5. {
  6. private class WasmAsmTokenKindProvider : AsmTokenKindProvider
  7. {
  8. private static readonly string[] Registers = new[]
  9. {
  10. "memory.", // add . to avoid parsing instruction portion as directive
  11. "local.",
  12. "global.",
  13. "i32.",
  14. "i64.",
  15. "f32.",
  16. "f64."
  17. };
  18. private static readonly string[] Qualifiers = new[]
  19. {
  20. "offset",
  21. "align",
  22. "eqz",
  23. "eq",
  24. "ne",
  25. "lt_s",
  26. "lt_u",
  27. "gt_s",
  28. "gt_u",
  29. "le_s",
  30. "le_u",
  31. "ge_s",
  32. "ge_u",
  33. "lt",
  34. "gt",
  35. "le",
  36. "ge",
  37. };
  38. private static readonly string[] Instructions = new[]
  39. {
  40. "if",
  41. "end",
  42. "block",
  43. "end_block",
  44. "loop",
  45. "unreachable",
  46. "nop",
  47. "br",
  48. "br_if",
  49. "br_table",
  50. "return",
  51. "call",
  52. "call_indirect",
  53. "drop",
  54. "select",
  55. "get",
  56. "set",
  57. "tee",
  58. "load",
  59. "load8_s",
  60. "load8_u",
  61. "load16_s",
  62. "load16_u",
  63. "load32_s",
  64. "load32_u",
  65. "store",
  66. "store8",
  67. "store16",
  68. "store32",
  69. "size",
  70. "grow",
  71. "const",
  72. "clz",
  73. "ctz",
  74. "popcnt",
  75. "add",
  76. "sub",
  77. "mul",
  78. "div_s",
  79. "div_u",
  80. "rem_s",
  81. "rem_u",
  82. "and",
  83. "or",
  84. "xor",
  85. "shl",
  86. "shr_s",
  87. "shr_u",
  88. "rotl",
  89. "rotr",
  90. "abs",
  91. "neg",
  92. "ceil",
  93. "floor",
  94. "trunc",
  95. "sqrt",
  96. "div",
  97. "min",
  98. "max",
  99. "copysign",
  100. "wrap_i64",
  101. "trunc_f32_s",
  102. "trunc_f32_u",
  103. "trunc_f64_s",
  104. "trunc_f64_u",
  105. "extend_i32_s",
  106. "extend_i64_u",
  107. "convert_f32_s",
  108. "convert_f32_u",
  109. "convert_f64_s",
  110. "convert_f64_u",
  111. "demote_f64",
  112. "promote_f32",
  113. "reinterpret_f32",
  114. "reinterpret_f64",
  115. "reinterpret_i32",
  116. "reinterpret_i64",
  117. };
  118. private static readonly string[] SimdInstructions = new string[]
  119. {
  120. };
  121. private WasmAsmTokenKindProvider() : base(Registers.Length + Qualifiers.Length + Instructions.Length + SimdInstructions.Length)
  122. {
  123. foreach (var register in Registers)
  124. {
  125. AddTokenKind(register, AsmTokenKind.Register);
  126. }
  127. foreach (var instruction in Qualifiers)
  128. {
  129. AddTokenKind(instruction, AsmTokenKind.Qualifier);
  130. }
  131. foreach (var instruction in Instructions)
  132. {
  133. AddTokenKind(instruction, AsmTokenKind.Instruction);
  134. }
  135. foreach (var instruction in SimdInstructions)
  136. {
  137. AddTokenKind(instruction, AsmTokenKind.InstructionSIMD);
  138. }
  139. }
  140. public override bool AcceptsCharAsIdentifierOrRegisterEnd(char c)
  141. {
  142. return c == '.';
  143. }
  144. public static readonly WasmAsmTokenKindProvider Instance = new WasmAsmTokenKindProvider();
  145. }
  146. }
  147. }
  148. #endif