This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] AsmParser: Support for sext() modifier in SDWA. Some code cleaning in AMDGPUOperand.
ClosedPublic

Authored by SamWot on Jun 3 2016, 8:49 AM.

Details

Summary

sext() modifier is supported in SDWA instructions only for integer operands. Spec is unclear should integer operands support abs and neg modifiers with sext - for now they are not supported.
Renamed InputModsWithNoDefault to FloatInputMods. Added SextInputMods for operands that support sext() modifier.
Added AMDGPUOperand::Modifier struct to handle register and immediate modifiers.
Code cleaning in AMDGPUOperand class: organize method in groups (render-, predicate-methods...).

Diff Detail

Repository
rL LLVM

Event Timeline

SamWot updated this revision to Diff 59566.Jun 3 2016, 8:49 AM
SamWot retitled this revision from to [AMDGPU] AsmParser: Support for sext() modifier in SDWA. Some code cleaning in AMDGPUOperand..
SamWot updated this object.
SamWot added reviewers: vpykhtin, artem.tamazov.
artem.tamazov edited edge metadata.Jun 3 2016, 12:47 PM

The change introduces some new error messages. It would be good to create tests for those. You may discover (and then fix) something unexpected.

lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
73 ↗(On Diff #59566)

After 1st glance, I would replace has/getSext... by has/getInteger...
After second, recommend replacing "Float" by "Floating" or "Fp". "Float" may be misunderstood as 32-bit FP type only.

90–95 ↗(On Diff #59566)

Please comment out why floating modifiers take precedence over integer ones.

382 ↗(On Diff #59566)

This construct asserts cleaner. +Typo in the last word.

assert(... &&
  "float (abs, neg) and sext modifiers should not be used simultaneously");
2382 ↗(On Diff #59566)

floating-point

lib/Target/AMDGPU/SIDefines.h
86 ↗(On Diff #59566)

Suspicious. If this is correct, explain why.

arsenm added inline comments.Jun 6 2016, 1:49 PM
lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
91–93 ↗(On Diff #59566)

no return after else

169–170 ↗(On Diff #59566)

C++ style comments

SamWot updated this revision to Diff 59862.Jun 7 2016, 3:59 AM
SamWot marked 6 inline comments as done.
SamWot edited edge metadata.

Fixess for review. Renamed FloatInputMods to FPInputMods and SextInputMods to IntInputMods.

Fixess...

Fixess is a nice-looking girl which likes correcting problems in the code, right? ))

artem.tamazov added inline comments.Jun 7 2016, 4:45 AM
lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
73 ↗(On Diff #59862)

I would better use "Integer", not "Int".

83 ↗(On Diff #59862)

Still getSext..., not getInteger... Perhaps Sext is Ok but explain why, please.

90–95 ↗(On Diff #59862)

Not done, as far as I see.

lib/Target/AMDGPU/SIDefines.h
86 ↗(On Diff #59862)

Not done.

SamWot added a comment.Jun 7 2016, 5:26 AM

I forgot to submit my previous comments.

lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
73 ↗(On Diff #59862)

I prefer Int because it is not that long as Integer. Otherwise method names would be much longer. Also if we use FP for floating point then usage of Int as acronim for Integer looks better.

90–95 ↗(On Diff #59566)

Floating modifiers have precedence because they are used more often. FP and sext modifiers can't be set immediately so this doesn't affect correctness.

91–93 ↗(On Diff #59566)

I'm not sure that I understood your comment correctly. There is no need for return after this if-else construct because it covers all possible situations. If you are speaking about coding standatd (http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return) then I don't see what is better way to write this code fragment.

lib/Target/AMDGPU/SIDefines.h
86 ↗(On Diff #59566)

This is correct.
This just specifies that sext() modifier is defined by first bit in immedieate operand. Sext and abs/neg can't be set simultaneously so no problem arises.

SamWot updated this revision to Diff 59872.Jun 7 2016, 5:29 AM

Some fixess.

artem.tamazov accepted this revision.Jun 7 2016, 6:08 AM
artem.tamazov edited edge metadata.

Looks good enough, but I recommend addressing my comments prior committing this.

lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
73 ↗(On Diff #59872)

My point was that "int" might be misunderstood as 32-bit integer type (just like "float" above).
Making "code looks better" at the cost of semantical clarity may camouflage design flaws.
Finally, decide yourself.

90–95 ↗(On Diff #59872)

Did you mean "FP and sext modifiers can't be set simultaneously..."? If yes, then Ok.
However, add comment to the code. Or, assert if both modifiers set (better).

lib/Target/AMDGPU/SIDefines.h
86 ↗(On Diff #59872)

Please comment that in the code.

This revision is now accepted and ready to land.Jun 7 2016, 6:08 AM
This revision was automatically updated to reflect the committed changes.