This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][llvm-mc] s_getreg/setreg* - hwreg - factor out strings/literals etc.
ClosedPublic

Authored by artem.tamazov on May 18 2016, 12:53 PM.

Details

Summary

Hwreg(...) syntax implementation unified with sendmsg(...).
Common strings moved to Utils
MathExtras.h functionality utilized.
Added missing build dependency in Disassembler.

Diff Detail

Repository
rL LLVM

Event Timeline

artem.tamazov retitled this revision from to [AMDGPU][llvm-mc] s_getreg/setreg* - hwreg - factor out strings/literals, unify with sendmsg implementation..
artem.tamazov updated this object.
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 reviewers, added: vpykhtin; removed: nhaustov.May 20 2016, 7:57 AM

Going to commit in 24hrs if none comments arrive.

arsenm added inline comments.May 20 2016, 7:19 PM
lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
1729

Is this really a StringRef?

lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
919

Demorgan's law this

SamWot added inline comments.May 23 2016, 5:42 AM
lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
1727–1735

Why do you need to change this? Previous variant looks much more readable for me?

1801

You should return MatchOperand_ParseFail here.
parseHwregOperand could already eat some tokens, so this will damage later parsers.
I use this rule to decide where you should return NoMatch or ParseFail:

  • NoMatch - if this parser didn't yet eat any tokens and it is possible that current string can be parsed by any other parser.
  • ParseFail - we ate some tokens or current string should not be parsed by any other parser.
lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
906–920

Why do you need to change this? Previous variant looks much more readable for me?

artem.tamazov added inline comments.May 23 2016, 10:11 AM
lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
1727–1735

We want to define strings used in asmparser and instprinter in one place. Can't use stringswitch with externally defined symbols.

lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
906–920

Same reason.

Review fixes done.

artem.tamazov marked 5 inline comments as done.May 23 2016, 10:45 AM
arsenm added inline comments.May 24 2016, 12:51 PM
lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
28–32

Why not put this table in Utils and avoid repeating it?

test/MC/AMDGPU/sopp-err.s
39

Should the message say which operand?

BTW thanks for reviewing))

lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
28–32

That is planned to be done in separate change. For now, there is
// FIXME ODR: Move this to some common place for AsmParser and InstPrinter

test/MC/AMDGPU/sopp-err.s
39

Actually, there is a caret symbol which points to the operand:

C:\work-1\asm-git-1\playground\debugging.s:1:28: error: not a valid operand.
s_sendmsg sendmsg(2, 3, 0, 0)
                           ^

But normally we do not check everything. Shall we?

artem.tamazov added inline comments.May 24 2016, 1:42 PM
lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
28–32

Pls let me know if you think it is better to do that just in this patch.

arsenm added inline comments.May 24 2016, 6:38 PM
lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp
28–32

Probably best to just do it now

artem.tamazov updated this object.

Review fixes.

artem.tamazov marked 4 inline comments as done.May 25 2016, 7:46 AM

Ready for the next review round.

arsenm accepted this revision.May 25 2016, 10:11 AM
arsenm edited edge metadata.

LGTM

lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
1719

Can you use isMask_32 for this?

lib/Target/AMDGPU/Utils/AMDGPUAsmParserPrinter.h
1

Missing C++ mode comment

This revision is now accepted and ready to land.May 25 2016, 10:11 AM
artem.tamazov added inline comments.May 26 2016, 3:39 AM
lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
1719

Thanks for the tip. It seems that isShiftedUInt() can be also used in some places... Will try to use as much as possible stuff from MathExtras.h and update the review.

Note that current design (factored out enums and strings) does not look readable and easy to use. Perhaps it is worth to implement and use deeper abstractions, perhaps classes which clearly encapsulate sendmsg/hwreg functionality required for the parser/printer. For example, Hwreg::getIdSymbolic(enum Id id) or HwReg::getIdNumeric(StringRef& identifier) etc. Let's do that in the future, when time permits.

artem.tamazov updated this revision to Diff 58601.EditedMay 26 2016, 6:44 AM
artem.tamazov retitled this revision from [AMDGPU][llvm-mc] s_getreg/setreg* - hwreg - factor out strings/literals, unify with sendmsg implementation. to [AMDGPU][llvm-mc] s_getreg/setreg* - hwreg - factor out strings/literals etc..
artem.tamazov updated this object.
artem.tamazov edited edge metadata.

Review fixed done. Pre-submit testing started.

artem.tamazov marked 3 inline comments as done.May 26 2016, 6:45 AM

whitespace fixes

SamWot accepted this revision.May 26 2016, 6:56 AM
SamWot edited edge metadata.

LGTM

lib/Target/AMDGPU/Utils/AMDGPUAsmParserPrinter.h
2

Can you rename this file to something like AMDGPUAsmUtils? This name confuses me alot: there are AsmParser, AsmPrinter and InstPrinter.

artem.tamazov edited edge metadata.

New files in Utils renamed.

artem.tamazov marked an inline comment as done.May 26 2016, 8:10 AM
This revision was automatically updated to reflect the committed changes.