This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][MC] Add detection of mandatory literals in parser
ClosedPublic

Authored by dp on Sep 9 2022, 12:49 PM.

Details

Summary

When asm parser detects an error, it attempts to show the location of an offending operand. Location of a mandatory literal (e.g. used by FMAAK/FMAMK) should not be reported as the error position, because this literal is an inherent part of the instruction. This is how it currently works.

GFX11 VOPD is a special case because an instruction may have two mandatory literals. And if they are different, the parser should show the location of a mandatory literal.

This change is required for VOPD validation which is WIP.

Diff Detail

Event Timeline

dp created this revision.Sep 9 2022, 12:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2022, 12:49 PM
dp requested review of this revision.Sep 9 2022, 12:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2022, 12:49 PM

I have previously used the name 'mandatory literals' to refer to these type of operands (in the disassembler). I think that's a slightly better term than hardcoded because to me hardcoded implies the value of the literal is constant. We should unify on one name in any case.

Is it possible to add a test with this? Something like assembling a VOPD with multiple literals and getting an error like "error: only one literal operand is allowed"? Or does that still require more functionality?

In the commit message, I think this statement is misleading "Hardcoded literals like those used by FMAAK/FMAMK should be ignored, because they are part of the instruction and cannot be changed." They are not ignored. Do you mean something like "Hardcoded literal locations like those used by FMAAK/FMAMK previously could not be reported as the error location"?

dp updated this revision to Diff 459466.Sep 12 2022, 9:04 AM
dp retitled this revision from [AMDGPU][MC] Add detection of hardcoded literals in parser to [AMDGPU][MC] Add detection of mandatory literals in parser.
dp edited the summary of this revision. (Show Details)

Thanks for your valuable comments! I corrected the wording and replaced "hardcoded" with "mandatory".

Is it possible to add a test with this? Something like assembling a VOPD with multiple literals and getting an error like "error: only one literal operand is allowed"? Or does that still require more functionality?

I do not think it is possible to test these changes without adding more functionality. If you prefer, I could merge this change with the next one which validates use of literals.

Joe_Nash accepted this revision.Sep 12 2022, 10:36 AM

Thanks. I have a slight preference for including the change when the new functionality is testable.

This revision is now accepted and ready to land.Sep 12 2022, 10:36 AM
This revision was automatically updated to reflect the committed changes.