amdgpu.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. """
  2. pygments.lexers.amdgpu
  3. ~~~~~~~~~~~~~~~~~~~~~~
  4. Lexers for the AMDGPU ISA assembly.
  5. :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
  6. :license: BSD, see LICENSE for details.
  7. """
  8. from pygments.lexer import RegexLexer, words
  9. from pygments.token import Name, Text, Keyword, Whitespace, Number, Comment
  10. import re
  11. __all__ = ['AMDGPULexer']
  12. class AMDGPULexer(RegexLexer):
  13. """
  14. For AMD GPU assembly.
  15. """
  16. name = 'AMDGPU'
  17. aliases = ['amdgpu']
  18. filenames = ['*.isa']
  19. url = 'https://gpuopen.com/amd-isa-documentation'
  20. version_added = '2.8'
  21. flags = re.IGNORECASE
  22. tokens = {
  23. 'root': [
  24. (r'\s+', Whitespace),
  25. (r'[\r\n]+', Text),
  26. (r'(([a-z_0-9])*:([a-z_0-9])*)', Name.Attribute),
  27. (r'(\[|\]|\(|\)|,|\:|\&)', Text),
  28. (r'([;#]|//).*?\n', Comment.Single),
  29. (r'((s_)?(scratch|ds|buffer|flat|image)_[a-z0-9_]+)', Keyword.Reserved),
  30. (r'(_lo|_hi)', Name.Variable),
  31. (r'(vmcnt|lgkmcnt|expcnt)', Name.Attribute),
  32. (r'(attr[0-9].[a-z])', Name.Attribute),
  33. (words((
  34. 'op', 'vaddr', 'vdata', 'off', 'soffset', 'srsrc', 'format',
  35. 'offset', 'offen', 'idxen', 'glc', 'dlc', 'slc', 'tfe', 'lds',
  36. 'lit', 'unorm'), suffix=r'\b'), Name.Attribute),
  37. (r'(label_[a-z0-9]+)', Keyword),
  38. (r'(_L[0-9]*)', Name.Variable),
  39. (r'(s|v)_[a-z0-9_]+', Keyword),
  40. (r'(v[0-9.]+|vcc|exec|v)', Name.Variable),
  41. (r's[0-9.]+|s', Name.Variable),
  42. (r'[0-9]+\.[^0-9]+', Number.Float),
  43. (r'(0[xX][a-z0-9]+)|([0-9]+)', Number.Integer)
  44. ]
  45. }