This is an archive of the discontinued LLVM Phabricator instance.

[globalisel][aarch64] Fix unintended assumptions about PartialMappingIdx. NFC.
ClosedPublic

Authored by dsanders on Dec 2 2016, 4:17 AM.

Details

Summary

This is NFC but prevents assertions when PartialMappingIdx is tablegen-erated.
The assumptions were:

  1. FirstGPR is 0
  2. FirstGPR is the first of the First* enumerators.

GPR32 is changed to 1 to demonstrate that assumption #1 is fixed. #2 will
be covered by a subsequent patch that tablegen-erates information and swaps
the order of GPR and FPR as a side effect.

Depends on D27336

Event Timeline

dsanders updated this revision to Diff 80054.Dec 2 2016, 4:17 AM
dsanders retitled this revision from to [globalisel][aarch64] Fix unintended assumptions about PartialMappingIdx. NFC..
dsanders updated this object.
dsanders added reviewers: ab, qcolombet, t.p.northover.
dsanders added a subscriber: llvm-commits.
qcolombet accepted this revision.Dec 2 2016, 11:05 AM
qcolombet edited edge metadata.

LGTM.

Nitpicks below

lib/Target/AArch64/AArch64GenRegisterBankInfo.def
164

Use AArch64::PartialMappingIdx_Min in both places for consistency.

lib/Target/AArch64/AArch64RegisterBankInfo.cpp
117–118

I'd keep ::PartialMappingIdx::, I like being explicit about the type we use (and that shouldn't be redundant for the _Min part when you'd use a shorter name, see the other review).

135–136

Could we keep the PartialMappingIdx type instead of unsigned?

136

Ditto.

This revision is now accepted and ready to land.Dec 2 2016, 11:05 AM
dsanders added inline comments.Dec 5 2016, 3:54 AM
lib/Target/AArch64/AArch64RegisterBankInfo.cpp
117–118

Ok. Would you like me to make the explicit namespace mandatory by changing the type to an 'enum class'? This would also fix the prefix issue I mentioned on the other review.

135–136

The compiler warns about using PartialMappingIdx because it's not a PartialMappingIdx after the subtraction. The warning could be silenced with a cast like so:

PartialMappingIdx PartialMapBaseIdx = (PartialMappingIdx)(AArch64::PartialMappingIdx::RBName##Size - AArch64::PartialMappingIdx::PartialMappingIdx_Min);

but this is still misleading because the values don't match up with the enumerators.

dsanders updated this revision to Diff 80413.Dec 6 2016, 6:38 AM
dsanders edited edge metadata.

Rebase and fix nits about including the ::PartialMappingIdx::

dsanders closed this revision.Dec 6 2016, 6:50 AM