llvm.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Language: LLVM IR
  3. Author: Michael Rodler <contact@f0rki.at>
  4. Description: language used as intermediate representation in the LLVM compiler framework
  5. Website: https://llvm.org/docs/LangRef.html
  6. Category: assembler
  7. */
  8. function llvm(hljs) {
  9. var identifier = '([-a-zA-Z$._][\\w\\-$.]*)';
  10. return {
  11. name: 'LLVM IR',
  12. keywords:
  13. 'begin end true false declare define global ' +
  14. 'constant private linker_private internal ' +
  15. 'available_externally linkonce linkonce_odr weak ' +
  16. 'weak_odr appending dllimport dllexport common ' +
  17. 'default hidden protected extern_weak external ' +
  18. 'thread_local zeroinitializer undef null to tail ' +
  19. 'target triple datalayout volatile nuw nsw nnan ' +
  20. 'ninf nsz arcp fast exact inbounds align ' +
  21. 'addrspace section alias module asm sideeffect ' +
  22. 'gc dbg linker_private_weak attributes blockaddress ' +
  23. 'initialexec localdynamic localexec prefix unnamed_addr ' +
  24. 'ccc fastcc coldcc x86_stdcallcc x86_fastcallcc ' +
  25. 'arm_apcscc arm_aapcscc arm_aapcs_vfpcc ptx_device ' +
  26. 'ptx_kernel intel_ocl_bicc msp430_intrcc spir_func ' +
  27. 'spir_kernel x86_64_sysvcc x86_64_win64cc x86_thiscallcc ' +
  28. 'cc c signext zeroext inreg sret nounwind ' +
  29. 'noreturn noalias nocapture byval nest readnone ' +
  30. 'readonly inlinehint noinline alwaysinline optsize ssp ' +
  31. 'sspreq noredzone noimplicitfloat naked builtin cold ' +
  32. 'nobuiltin noduplicate nonlazybind optnone returns_twice ' +
  33. 'sanitize_address sanitize_memory sanitize_thread sspstrong ' +
  34. 'uwtable returned type opaque eq ne slt sgt ' +
  35. 'sle sge ult ugt ule uge oeq one olt ogt ' +
  36. 'ole oge ord uno ueq une x acq_rel acquire ' +
  37. 'alignstack atomic catch cleanup filter inteldialect ' +
  38. 'max min monotonic nand personality release seq_cst ' +
  39. 'singlethread umax umin unordered xchg add fadd ' +
  40. 'sub fsub mul fmul udiv sdiv fdiv urem srem ' +
  41. 'frem shl lshr ashr and or xor icmp fcmp ' +
  42. 'phi call trunc zext sext fptrunc fpext uitofp ' +
  43. 'sitofp fptoui fptosi inttoptr ptrtoint bitcast ' +
  44. 'addrspacecast select va_arg ret br switch invoke ' +
  45. 'unwind unreachable indirectbr landingpad resume ' +
  46. 'malloc alloca free load store getelementptr ' +
  47. 'extractelement insertelement shufflevector getresult ' +
  48. 'extractvalue insertvalue atomicrmw cmpxchg fence ' +
  49. 'argmemonly double',
  50. contains: [
  51. {
  52. className: 'keyword',
  53. begin: 'i\\d+'
  54. },
  55. hljs.COMMENT(
  56. ';', '\\n', {relevance: 0}
  57. ),
  58. // Double quote string
  59. hljs.QUOTE_STRING_MODE,
  60. {
  61. className: 'string',
  62. variants: [
  63. // Double-quoted string
  64. { begin: '"', end: '[^\\\\]"' },
  65. ],
  66. relevance: 0
  67. },
  68. {
  69. className: 'title',
  70. variants: [
  71. { begin: '@' + identifier },
  72. { begin: '@\\d+' },
  73. { begin: '!' + identifier },
  74. { begin: '!\\d+' + identifier }
  75. ]
  76. },
  77. {
  78. className: 'symbol',
  79. variants: [
  80. { begin: '%' + identifier },
  81. { begin: '%\\d+' },
  82. { begin: '#\\d+' },
  83. ]
  84. },
  85. {
  86. className: 'number',
  87. variants: [
  88. { begin: '0[xX][a-fA-F0-9]+' },
  89. { begin: '-?\\d+(?:[.]\\d+)?(?:[eE][-+]?\\d+(?:[.]\\d+)?)?' }
  90. ],
  91. relevance: 0
  92. },
  93. ]
  94. };
  95. }
  96. module.exports = llvm;