No Description
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.LLVMIR.cs 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #if UNITY_EDITOR || BURST_INTERNAL
  2. namespace Unity.Burst.Editor
  3. {
  4. internal partial class BurstDisassembler
  5. {
  6. /// <summary>
  7. /// <see cref="AsmTokenKind"/> provider for LLVM IR - intrinsics are not covered at this time
  8. /// </summary>
  9. private class LLVMIRAsmTokenKindProvider : AsmTokenKindProvider
  10. {
  11. private static readonly string[] Qualifiers = new[]
  12. {
  13. "to",
  14. "new",
  15. "float",
  16. "double",
  17. "i1",
  18. "i32",
  19. "i16",
  20. "i64",
  21. "eq",
  22. "ne",
  23. "ugt",
  24. "uge",
  25. "ult",
  26. "ule",
  27. "sgt",
  28. "sge",
  29. "slt",
  30. "sle",
  31. "false",
  32. "true",
  33. "oeq",
  34. "ogt",
  35. "oge",
  36. "olt",
  37. "ole",
  38. "one",
  39. "ord",
  40. "ueq",
  41. "une",
  42. "uno",
  43. };
  44. private static readonly string[] Instructions = new[]
  45. {
  46. "ret",
  47. "br",
  48. "switch",
  49. "indirectbr",
  50. "invoke",
  51. "callbr",
  52. "resume",
  53. "catchswitch",
  54. "catchret",
  55. "cleanupret",
  56. "unreachable",
  57. "add",
  58. "sub",
  59. "mul",
  60. "udiv",
  61. "sdiv",
  62. "urem",
  63. "srem",
  64. "shl",
  65. "lshr",
  66. "ashr",
  67. "and",
  68. "or",
  69. "xor",
  70. "extractvalue",
  71. "insertvalue",
  72. "alloca",
  73. "load",
  74. "store",
  75. "fence",
  76. "cmpxchg",
  77. "atomicrmw",
  78. "getelementptr",
  79. "trunc",
  80. "zext",
  81. "sext",
  82. "ptrtoint",
  83. "inttoptr",
  84. "bitcast",
  85. "addrspacecast",
  86. "icmp",
  87. "phi",
  88. "select",
  89. "freeze",
  90. "call",
  91. "va_arg",
  92. "landingpad",
  93. "catchpad",
  94. "cleanuppad",
  95. };
  96. private static readonly string[] FpuInstructions = new[]
  97. {
  98. "fneg",
  99. "fadd",
  100. "fsub",
  101. "fmul",
  102. "fdiv",
  103. "frem",
  104. "fptrunc",
  105. "fpext",
  106. "fptoui",
  107. "fptosi",
  108. "uitofp",
  109. "sitofp",
  110. "fcmp",
  111. };
  112. private static readonly string[] SimdInstructions = new[]
  113. {
  114. "extractelement",
  115. "insertelement",
  116. "shufflevector",
  117. };
  118. private LLVMIRAsmTokenKindProvider() : base(Qualifiers.Length + Instructions.Length + FpuInstructions.Length + SimdInstructions.Length)
  119. {
  120. foreach (var instruction in Qualifiers)
  121. {
  122. AddTokenKind(instruction, AsmTokenKind.Qualifier);
  123. }
  124. foreach (var instruction in Instructions)
  125. {
  126. AddTokenKind(instruction, AsmTokenKind.Instruction);
  127. }
  128. foreach (var instruction in FpuInstructions)
  129. {
  130. AddTokenKind(instruction, AsmTokenKind.Instruction);
  131. }
  132. foreach (var instruction in SimdInstructions)
  133. {
  134. AddTokenKind(instruction, AsmTokenKind.InstructionSIMD);
  135. }
  136. }
  137. public override SIMDkind SimdKind(StringSlice instruction)
  138. {
  139. throw new System.NotImplementedException("Syntax Highlighting is not implemented for LLVM IR.");
  140. }
  141. public static readonly LLVMIRAsmTokenKindProvider Instance = new LLVMIRAsmTokenKindProvider();
  142. }
  143. }
  144. }
  145. #endif