Skip to content

Commit

Permalink
Extend the AMDGPU lexer. (#2327)
Browse files Browse the repository at this point in the history
Add support for scratch_ instructions, the attr*.* argument  as well
as the off modifier. Without support for attr*.*, multiple v_interp
instructions are previously rendered incorrectly.
  • Loading branch information
tsymalla committed Jan 31, 2023
1 parent d4403f0 commit c8cf157
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pygments/lexers/amdgpu.py
Expand Up @@ -35,11 +35,12 @@ class AMDGPULexer(RegexLexer):
(r'(([a-z_0-9])*:([a-z_0-9])*)', Name.Attribute),
(r'(\[|\]|\(|\)|,|\:|\&)', Text),
(r'([;#]|//).*?\n', Comment.Single),
(r'((s_)?(ds|buffer|flat|image)_[a-z0-9_]+)', Keyword.Reserved),
(r'((s_)?(scratch|ds|buffer|flat|image)_[a-z0-9_]+)', Keyword.Reserved),
(r'(_lo|_hi)', Name.Variable),
(r'(vmcnt|lgkmcnt|expcnt)', Name.Attribute),
(r'(attr[0-9].[a-z])', Name.Attribute),
(words((
'op', 'vaddr', 'vdata', 'soffset', 'srsrc', 'format',
'op', 'vaddr', 'vdata', 'off', 'soffset', 'srsrc', 'format',
'offset', 'offen', 'idxen', 'glc', 'dlc', 'slc', 'tfe', 'lds',
'lit', 'unorm'), suffix=r'\b'), Name.Attribute),
(r'(label_[a-z0-9]+)', Keyword),
Expand Down
5 changes: 4 additions & 1 deletion tests/examplefiles/amdgpu/amdgpu.isa
@@ -1,5 +1,8 @@
s_load_dwordx2 s[4:5], s[0:1], 0x10
s_load_dwordx4 s[0:3], s[0:1], 0x00
scratch_load_dwordx3 v[2:5], v0, off
v_interp_p1_f32_e32 v2, v0, attr0.x
v_interp_p1_f32_e32 v3, v0, attr0.y
v_lshlrev_b32 v0, 2, v0
s_waitcnt lgkmcnt(0)
v_add_u32 v1, vcc, s2, v0
Expand All @@ -8,4 +11,4 @@ v_addc_u32 v2, vcc, v2, 0, vcc
v_add_u32 v3, vcc, s0, v0
v_mov_b32 v4, s1
v_addc_u32 v4, vcc, v4, 0, vcc
buffer_load_dword v4, v2, s[8:11], 0 offen
buffer_load_dword v4, v2, s[8:11], 0 offen
36 changes: 36 additions & 0 deletions tests/examplefiles/amdgpu/amdgpu.isa.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c8cf157

Please sign in to comment.