This is an archive of the discontinued LLVM Phabricator instance.

[M68k][AsmParser] Support parsing register masks & fix printing them
ClosedPublic

Authored by ricky26 on Aug 23 2021, 4:14 PM.

Details

Summary

Fixes PR51580.

Register masks will now be printed as 'movem.l (%sp), %a0-%a5/%d5'
for example and can now be parsed in the same format.

Previously the printed syntax was 'movem.l (%sp), %a0-%a5,%d', which
didn't match prior art and was too ambiguous to easily parse.

Diff Detail

Event Timeline

ricky26 created this revision.Aug 23 2021, 4:14 PM
ricky26 requested review of this revision.Aug 23 2021, 4:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2021, 4:14 PM
myhsu added a comment.Aug 23 2021, 9:22 PM

Thanks for your swift response on adding move mask support!
overall LGTM. Please address the inline feedbacks.

llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp
240

I think A0 ~ A7 as well as D0 ~ D7 are always contiguous (see M68kGenRegisterInfo.inc). So maybe this can be replaced with something like

if (Register >= M68k::D0 && Register <= M68k::D7)
  return Register - M68k::D0;
if (Register >= M68k::A0 && Register <= M68k::A7)
  return Register - M68k::A0 + 8;
// Here: handle SP, PC, CCR...
279
379

(formatting) remove surrounding braces for single-line if-statement

383

ditto remove braces and other places below

myhsu added a comment.Aug 23 2021, 9:39 PM

I just found that bits in the move mask will be inverted if the destination operand is predecrement mode address (i.e. -(An)). But we're not even supporting that addressing mode for MOVEM yet so I think it's fine for now.

I just found that bits in the move mask will be inverted if the destination operand is predecrement mode address (i.e. -(An)). But we're not even supporting that addressing mode for MOVEM yet so I think it's fine for now.

I guess I should've called this out in the commit message, but yes. I did have a quick look and I didn't see anything for the other side of the flip (i.e. during codegen / printing) so it seems unlikely to not get caught at the point that gets implemented.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 24 2021, 2:40 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
ricky26 marked 4 inline comments as done.