This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][llvm-mc] Support for 32-bit inline literals
ClosedPublic

Authored by artem.tamazov on Feb 12 2016, 9:55 AM.

Details

Summary

Note: Support for 64-bit inline literals TBD
Added: Support of abs/neg modifiers for literals (incomplete; parsing TBD).
Added: Some TODO comments.
Reworked/clarity: rename isInlineImm() to isInlinableImm()
Reworked/robustness: disallow BitsToFloat() with undefined value in isInlinableImm()
Reworked/reuse: isSSrc32/64(), isVSrc32/64()
Tests added.

Diff Detail

Repository
rL LLVM

Event Timeline

artem.tamazov retitled this revision from to [AMDGPU] Support for inline literals (32 bit).
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 subscribers: SamWot, nhaustov, vpykhtin.
artem.tamazov retitled this revision from [AMDGPU] Support for inline literals (32 bit) to [AMDGPU][llvm-mc] Support for 32-bit inline literals.Feb 12 2016, 11:36 AM
arsenm edited edge metadata.Feb 15 2016, 11:31 AM

Are source modifiers really allowed with immediates? The only case I can think of where that might be useful is for -0. There are a few assertions lying around that assume there are no modifiers for any immediate.

Does this happen to fix this bug? : http://lists.llvm.org/pipermail/llvm-dev/2015-October/091715.html

If so there should be some tests for it.

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

Why the name change?

154

Comments should be capitalized. Also this looks like it goes over the 80 character line limit

156

We should avoid using host float here. It would be better to check the float bit values which is what a few other places do. We've had bot failures before due to weird NaN support on mips hosts.

209

Indentation looks off

artem.tamazov added inline comments.Feb 15 2016, 11:55 AM
lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
153

If immediate is inline or not depends on how the actual instruction is encoded. The function only answers the question "is it possible to inline an immediate". I believe this name better reflects that.

156

That code was there before my change. I would prefer to fix it separately.

artem.tamazov edited edge metadata.

Comment capitalized. Indentation fixed.

artem.tamazov marked 2 inline comments as done.Feb 15 2016, 12:10 PM

Does this happen to fix this bug? : http://lists.llvm.org/pipermail/llvm-dev/2015-October/091715.html
If so there should be some tests for it.

I would prefer to do that separately. Please assign the bug to me, I will check, update the bug and submit regression tests. Is it OK?

Are source modifiers really allowed with immediates? The only case I can think of where that might be useful is for -0. There are a few assertions lying around that assume there are no modifiers for any immediate.

That's right, the only case which makes sense is -0.0. And it can be useful in some cases. I am going to double-check if modifiers are really allowed; that is the one of the reasons why I got pause in the middle of implementation and didn't implement parsing of modifiers for immediates.

Does this happen to fix this bug? : http://lists.llvm.org/pipermail/llvm-dev/2015-October/091715.html
If so there should be some tests for it.

I would prefer to do that separately. Please assign the bug to me, I will check, update the bug and submit regression tests. Is it OK?

Oops, this is not a bugzilla item)) Well, let me handle that separately, okay?

arsenm accepted this revision.Feb 16 2016, 5:22 PM
arsenm edited edge metadata.

LGTM

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

Single quotes for '<'

test/MC/AMDGPU/vop3.s
297–299

Maybe add a test with the FP value specified as a hex constant?

This revision is now accepted and ready to land.Feb 16 2016, 5:22 PM

Going to update diff with fresh llvm master and also to satisfy recent Matt's comments.

artem.tamazov edited edge metadata.

Added: Test for http://lists.llvm.org/pipermail/llvm-dev/2015-October/091715.html
Added: Test for FP value specified as a hex.
Added: Some TODO comments.
Updated/style: Some comments (80 chars line limit).
Updated/style: Single quotes for '<'.

artem.tamazov marked 2 inline comments as done.Feb 17 2016, 7:27 AM
artem.tamazov added inline comments.
lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
156

TODO comment added

Does this happen to fix this bug? : http://lists.llvm.org/pipermail/llvm-dev/2015-October/091715.html
If so there should be some tests for it.

Yes, that bug is fixed. A test added.

Are source modifiers really allowed with immediates? The only case I can think of where that might be useful is for -0. There are a few assertions lying around that assume there are no modifiers for any immediate.

BTW Another useful case is negation of 1/(2*PI) inline literal.

This revision was automatically updated to reflect the committed changes.