This is an archive of the discontinued LLVM Phabricator instance.

Move value type list from TargetRegisterClass to TargetRegisterInfo
ClosedPublic

Authored by kparzysz on Apr 11 2017, 8:27 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

kparzysz created this revision.Apr 11 2017, 8:27 AM
kparzysz updated this revision to Diff 94829.Apr 11 2017, 8:37 AM

Nothing is new, but I forgot to add llvm-commits as a subscriber. Hopefully this update will cause an email to be sent to the list.

asb requested changes to this revision.Apr 19 2017, 8:59 AM

I had a couple of minor review comments. I know the use of pointers vs references is quite inconsistent across LLVM, but I do feel it would be an improvement if isLegalRC took a const TargetRegisterInfo& (though perhaps there's a reason not to do this that I'm missing?).

include/llvm/Target/TargetLowering.h
2265 ↗(On Diff #94829)

Given that TRI must be non-null in the isLegalRC implementation later on in this patch, perhaps this function should take a reference to TargetRegisterInfo?

include/llvm/Target/TargetRegisterInfo.h
335 ↗(On Diff #94829)

Nitpick: I know this is just copied from the old vt_end, but having ++I on the next line would be more usual LLVM coding style (and is what clang-format would produce).

lib/CodeGen/TargetLoweringBase.cpp
1189 ↗(On Diff #94829)

Even though it's slightly less typing, I can't help but feel that checking for MVT::Other is peeking under the iterator abstraction unnecessarily.

This revision now requires changes to proceed.Apr 19 2017, 8:59 AM
kparzysz marked 2 inline comments as done.Apr 19 2017, 10:16 AM
kparzysz added inline comments.
lib/CodeGen/TargetLoweringBase.cpp
1189 ↗(On Diff #94829)

The reason I did it was that the end iterator traverses the whole list, also unnecessarily. We could have a separate class for the VT iterator, and implement something like "isValid" in it, but

  1. The traversal only happens in a very few places, and it's not something that's expected to change, and
  2. The ending with MVT::Other is specific to the VT list for a register class, and not any other list of value types.

With that in mind, I'm not sure that it's worth it.

kparzysz updated this revision to Diff 95776.Apr 19 2017, 10:29 AM
kparzysz edited edge metadata.

Addressed most of Alex's comments.

asb accepted this revision.Apr 19 2017, 11:20 AM

Thanks, looks good to me.

lib/CodeGen/TargetLoweringBase.cpp
1189 ↗(On Diff #94829)

Yes, I figured that was why. I did wonder if LLVM's codegen would be smart enough to optimise the repeated traversal. It's not an important point one way or the other anyway.

This revision is now accepted and ready to land.Apr 19 2017, 11:20 AM
MatzeB edited edge metadata.Apr 24 2017, 11:18 AM

Looks generally good to me, but I think we should rename the function when moving to register info (see below).

include/llvm/Target/TargetRegisterInfo.h
320 ↗(On Diff #95776)

The name TargetRegisterInfo::hasType feels odd as this isn't a general property of TargetRegisterInfo. Maybe rename to regclassHasType()?

Similar with the next two functions (regclassTypes_begin() maybe?).

kparzysz added inline comments.Apr 24 2017, 11:23 AM
include/llvm/Target/TargetRegisterInfo.h
320 ↗(On Diff #95776)

How about isTypeLegalForClass and regclassvt_begin, regclassvt_end?

MatzeB added inline comments.Apr 24 2017, 11:32 AM
include/llvm/Target/TargetRegisterInfo.h
320 ↗(On Diff #95776)

I'd be fine with them independently. Though maybe there is a way to make the look more similar (as they are all about the same concept). isTypeLegalForClass(), legalClassTypesBegin(), legalClassTypesEnd()?

kparzysz added inline comments.Apr 24 2017, 11:50 AM
include/llvm/Target/TargetRegisterInfo.h
320 ↗(On Diff #95776)

From what I've seen elsewhere, the convention for iterators is "lowercase with _begin/_end". Do legalclasstypes_begin and legalclasstypes_end look ok to you?

MatzeB added inline comments.Apr 24 2017, 11:55 AM
include/llvm/Target/TargetRegisterInfo.h
320 ↗(On Diff #95776)

Guess it's llvm naming conventions clashing with STL ones, looks good.

This revision was automatically updated to reflect the committed changes.