This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][AsmParser] NFC: Generalize LogicalImm[Not](32|64) code
ClosedPublic

Authored by sdesmalen on Jan 19 2018, 5:40 AM.

Details

Summary

All variants of isLogicalImm[Not](32|64) can be combined into a single templated function, same for printLogicalImm(32|64).
By making it use a template instead, further SVE patches can use it for other data types as well (e.g. 8, 16 bits).

Diff Detail

Repository
rL LLVM

Event Timeline

sdesmalen created this revision.Jan 19 2018, 5:40 AM
samparker added inline comments.Jan 19 2018, 6:05 AM
lib/Target/AArch64/InstPrinter/AArch64InstPrinter.cpp
916 ↗(On Diff #130593)

Shouldn't '64' be dependent on T?

sdesmalen added inline comments.Jan 19 2018, 7:32 AM
lib/Target/AArch64/InstPrinter/AArch64InstPrinter.cpp
916 ↗(On Diff #130593)

I think you're right... In practice it won't really matter since the cast to PrintVal truncates the pattern to the size of T (otherwise a pattern is repeated until the whole 64bit value is filled with that pattern), but by always passing '64' we also skip an assert that checks the value to be decoded is sensible.

sdesmalen updated this revision to Diff 130619.Jan 19 2018, 7:43 AM

Changed the second (regSize) operand to decodeLogicalImmediate() to use the sizeof(T)
(In function template<typename T> void printLogicalImm())

samparker accepted this revision.Jan 19 2018, 8:08 AM

Cheers, nice cleanup. LGTM.

This revision is now accepted and ready to land.Jan 19 2018, 8:08 AM
This revision was automatically updated to reflect the committed changes.