This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][llvm-mc] Square-braced-syntax for registers: make ":expr2" optional.
ClosedPublic

Authored by artem.tamazov on May 24 2016, 12:15 PM.

Details

Summary

Register numbers may be specified as assembly-time expressions. This feature can be useful in macros and alike. However, expressions are supported within sqare braces only.

Sqare braces were initially intended to support specifying of multiple (pairs/quads...) registers. Syntax like v[8:8] which specifies single register is also supported. That allows expressions but looks a bit unnatural.

This change supports syntax REG[EXPR].
Tests added.

Diff Detail

Repository
rL LLVM

Event Timeline

artem.tamazov retitled this revision from to [AMDGPU][llvm-mc] Square-braced-syntax for registers: make ":expr2" optional..
artem.tamazov updated this object.
artem.tamazov added reviewers: arsen, vpykhtin, SamWot.
artem.tamazov set the repository for this revision to rL LLVM.
artem.tamazov added a project: Restricted Project.
artem.tamazov added a subscriber: Restricted Project.
artem.tamazov edited edge metadata.
artem.tamazov added a subscriber: nhaustov.
artem.tamazov added a comment.EditedMay 25 2016, 7:50 AM

Ping. That ball will be in flight for a day))

SamWot accepted this revision.May 25 2016, 7:59 AM
SamWot edited edge metadata.
This revision is now accepted and ready to land.May 25 2016, 7:59 AM
arsen accepted this revision.May 25 2016, 2:56 PM
arsen edited edge metadata.

Can you add a test that's an example of the macro use you are talking about? I'm not sure I see the point. Does sp3 support this?

artem.tamazov added a comment.EditedMay 26 2016, 11:27 AM

Can you add a test that's an example of the macro use you are talking about? I'm not sure I see the point.

This change just supports expressions in register numbers, so it looks to me test with macro out of the scope.
As far as I understand, support for macros is a part of core llvm-mc, and there are tests.
An example from Jay C.:

.set kCopyAlignedVecWidth, 4
.set kCopyAlignedUnroll, 1
...
.macro mCopyAlignedPhase2Load iter iter_end
    .if kCopyAlignedVecWidth == 4
      flat_load_dwordx4    v[8 + (\iter * 4):8 + (\iter * 4) + 3], v[2:3]
    .else
      flat_load_dword      v[8 + \iter], v[2:3]
    .endif

    v_add_u32              v2, vcc, v2, s25
    v_addc_u32             v3, vcc, v3, 0x0, vcc

    .if (\iter_end - \iter)
      mCopyAlignedPhase2Load (\iter + 1), \iter_end
    .endif
  .endm

  mCopyAlignedPhase2Load 0, (kCopyAlignedUnroll - 1)

Does sp3 support this?

I do not know if it supports expressions as register numbers.

This revision was automatically updated to reflect the committed changes.

Can you add a test that's an example of the macro use you are talking about? I'm not sure I see the point.

This change just supports expressions in register numbers, so it looks to me test with macro out of the scope.
As far as I understand, support for macros is a part of core llvm-mc, and there are tests.
An example from Jay C.:

.set kCopyAlignedVecWidth, 4
.set kCopyAlignedUnroll, 1
...
.macro mCopyAlignedPhase2Load iter iter_end
    .if kCopyAlignedVecWidth == 4
      flat_load_dwordx4    v[8 + (\iter * 4):8 + (\iter * 4) + 3], v[2:3]
    .else
      flat_load_dword      v[8 + \iter], v[2:3]
    .endif

    v_add_u32              v2, vcc, v2, s25
    v_addc_u32             v3, vcc, v3, 0x0, vcc

    .if (\iter_end - \iter)
      mCopyAlignedPhase2Load (\iter + 1), \iter_end
    .endif
  .endm

  mCopyAlignedPhase2Load 0, (kCopyAlignedUnroll - 1)

It's still a good idea to add tests to make sure this feature actually works here, and with this feature in particular even if nothing was done here to implement that specifically

Can you add a test that's an example of the macro use you are talking about? I'm not sure I see the point.

This change just supports expressions in register numbers, so it looks to me test with macro out of the scope.
As far as I understand, support for macros is a part of core llvm-mc, and there are tests.

It's still a good idea to add tests to make sure this feature actually works here, and with this feature in particular even if nothing was done here to implement that specifically

Okay, I will add a test with macro soon. In a new "test/MC/AMDGPU/macro-examples.s", I think.

arsenm added inline comments.Jun 1 2016, 2:13 PM
llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
774

return on next line

artem.tamazov added inline comments.Jun 2 2016, 5:23 AM
llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
774

I just followed existing style)) Anyway, this patch is already committed, so I will put the fix into http://reviews.llvm.org/D20797. Would you like me to fix all the stuff like this (scattered here and there)?

artem.tamazov marked 2 inline comments as done.Jun 2 2016, 6:48 AM
arsenm added inline comments.Jun 2 2016, 11:42 AM
llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
774

Sure