amdgpu.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. """
  2. pygments.lexers.amdgpu
  3. ~~~~~~~~~~~~~~~~~~~~~~
  4. Lexers for the AMDGPU ISA assembly.
  5. :copyright: Copyright 2006-2021 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. .. versionadded:: 2.8
  16. """
  17. name = 'AMDGPU'
  18. aliases = ['amdgpu']
  19. filenames = ['*.isa']
  20. flags = re.IGNORECASE
  21. tokens = {
  22. 'root': [
  23. (r'\s+', Whitespace),
  24. (r'[\r\n]+', Text),
  25. (r'(([a-z_0-9])*:([a-z_0-9])*)', Name.Attribute),
  26. (r'(\[|\]|\(|\)|,|\:|\&)', Text),
  27. (r'([;#]|//).*?\n', Comment.Single),
  28. (r'((s_)?(ds|buffer|flat|image)_[a-z0-9_]+)', Keyword.Reserved),
  29. (r'(_lo|_hi)', Name.Variable),
  30. (r'(vmcnt|lgkmcnt|expcnt)', Name.Attribute),
  31. (words((
  32. 'op', 'vaddr', 'vdata', 'soffset', 'srsrc', 'format',
  33. 'offset', 'offen', 'idxen', 'glc', 'dlc', 'slc', 'tfe', 'lds',
  34. 'lit', 'unorm'), suffix=r'\b'), Name.Attribute),
  35. (r'(label_[a-z0-9]+)', Keyword),
  36. (r'(_L[0-9]*)', Name.Variable),
  37. (r'(s|v)_[a-z0-9_]+', Keyword),
  38. (r'(v[0-9.]+|vcc|exec|v)', Name.Variable),
  39. (r's[0-9.]+|s', Name.Variable),
  40. (r'[0-9]+\.[^0-9]+', Number.Float),
  41. (r'(0[xX][a-z0-9]+)|([0-9]+)', Number.Integer)
  42. ]
  43. }