This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][AsmParser] Unify code for parsing Neon/SVE vectors.
ClosedPublic

Authored by sdesmalen on Apr 9 2018, 2:34 AM.

Details

Summary

Merged 'tryMatchVectorRegister' (specific to Neon) and
'tryParseSVERegister' into a single 'tryParseVectorRegister' function, and
created a generic 'parseVectorKind()' function that returns the #Elements
and ElementWidth of a vector suffix. This reduces the duplication of
this functionality between two the vector implementations.

This is patch [1/6] in a series to add assembler/disassembler support for
SVE's contiguous ST1 (scalar+imm) instructions.

Diff Detail

Repository
rL LLVM

Event Timeline

sdesmalen created this revision.Apr 9 2018, 2:34 AM
fhahn added a comment.Apr 9 2018, 8:59 AM

nice cleanup, thanks. Just a few minor comments.

lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
1853 ↗(On Diff #141601)

Please keep those comments.

1859 ↗(On Diff #141601)

Can you add a brief comment to document what the values in the returned pair mean?

1866 ↗(On Diff #141601)

Why are we matching "" for neon here? Looks like we did not match that before (on a first look)?

2871 ↗(On Diff #141601)

Would it be enough to capture this here? Or just pass the location explicitly?

2877 ↗(On Diff #141601)

This will trigger an unused variable warning when assertions are enabled I think. Maybe just move parseVectorKind in the assert?

Indeed, nice cleanup. I think we discussed this earlier and it's a much welcome change, to merge NEON and SVE parsing.

Apart from the error message text, NFC. With Florian's comments, LGTM, thanks!

I'll let @fhahn approve when he's ready.

lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
1575 ↗(On Diff #141601)

Maybe an assert making sure the arguments are compatible with vector registers?

sdesmalen updated this revision to Diff 141805.Apr 10 2018, 1:42 AM
sdesmalen marked 6 inline comments as done.
  • Added a new comment describing what 'parseVectorKind' does.
  • Put back some of the original comments into 'parseVectorKind'.
  • Fixed assert in lambda function and updated the capture-list.
lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
1866 ↗(On Diff #141601)

That is because this function can also be called when the Suffix is an empty string, where previously 'isValidVectorKind()' was only called when Kind was non-empty. See for instance 'tryParseNeonVectorRegister()' which unconditionally calls 'parseVectorKind()' in order to pass ElementWidth to the CreateVectorReg() call.

2877 ↗(On Diff #141601)

If I put the 'parseVectorKind' itself in an assert, it might not get executed (which is needed for 'Kind' to be set, which is passed by reference). I'll rewrite it into a condition with the 'else' being a llvm_unreachable.

fhahn accepted this revision.Apr 10 2018, 2:07 AM

LGTM

lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
1876 ↗(On Diff #141805)

The indents here seem weird. Can you run clang-format-diff before committing?

1866 ↗(On Diff #141601)

Got it, thanks.

2877 ↗(On Diff #141601)

Got it, thanks.

This revision is now accepted and ready to land.Apr 10 2018, 2:07 AM
sdesmalen added inline comments.Apr 10 2018, 4:22 AM
lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
1876 ↗(On Diff #141805)

This is actually what clang-format gave me, but I see that I'm using the clang-format installed on my system which isn't very recent, where a newer version fixes this. I'll update it before committing.

This revision was automatically updated to reflect the committed changes.