This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][MC] Corrected MTBUF parsing and decoding
ClosedPublic

Authored by dp on Jul 14 2020, 4:23 AM.

Details

Summary

MTBUF implementation has many issues and this change addresses most of these:

  • refactored duplicated code;
  • hardcoded constants moved out of high-level code;
  • fixed a decoding error when nfmt or dfmt are zero (bug 36932);
  • corrected parsing of operand separators (bug 46403);
  • corrected handling of missing operands (bug 46404);
  • corrected handling of out-of-range modifiers (bug 46421);
  • corrected default value (bug 46467).

MTBUF implementation was actually rewritten from scratch so I'm not sure if these changes should be submitted separately from each other.

There is one remaining issue: current MTBUF syntax is not compatible with SP3. SP3 syntax support will be added by a separate change.

Diff Detail

Event Timeline

dp created this revision.Jul 14 2020, 4:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2020, 4:23 AM
rampitec accepted this revision.Jul 14 2020, 12:33 PM
This revision is now accepted and ready to land.Jul 14 2020, 12:33 PM
This revision was automatically updated to reflect the committed changes.
uabelho added inline comments.
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
4929

gcc (7.4.0) warns here about

../lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp:4929:30: warning: enumeral and non-enumeral type in conditional expression [-Wextra]
   Dfmt = (Dfmt == DFMT_UNDEF)? DFMT_DEFAULT : Dfmt;
          ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

It can be silenced with e.g.

Dfmt = (Dfmt == DFMT_UNDEF)? (int64_t)DFMT_DEFAULT : Dfmt;
4930

Same kind of warning here as above.

4956

gcc (7.4.0) warns here about

../lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp:4956:30: warning: enumeral mismatch in conditional expression: 'llvm::AMDGPU::MTBUFFormat::UnifiedFormat' vs 'llvm::AMDGPU::MTBUFFormat::MergedFormat' [-Wenum-compare]
   int64_t Format = isGFX10() ? UFMT_DEFAULT : DFMT_NFMT_DEFAULT;
                    ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Can be silenced with e.g.

int64_t Format = isGFX10() ? (int64_t)UFMT_DEFAULT : (int64_t)DFMT_NFMT_DEFAULT;
dp added a comment.Jul 17 2020, 4:18 AM

Thanks Mikael. It will be fixed next week.