This is an archive of the discontinued LLVM Phabricator instance.

[System Model] [TTI] Update cache and prefetch TTI interfaces
ClosedPublic

Authored by greened on Jun 20 2019, 10:16 AM.

Details

Summary

Rework the TTI cache and software prefetching APIs to prepare for the
introduction of a general system model. Changes include:

  • Marking existing interfaces const and/or override as appropriate
  • Adding comments
  • Adding BasicTTIImpl interfaces that delegate to a subtarget implementation
  • Adding a default "no information" subtarget implementation

Only a handful of targets use these interfaces currently: AArch64,
Hexagon, PPC and SystemZ. AArch64 already has a custom subtarget
implementation, so its custom TTI implementation is migrated to use
the new facilities in BasicTTIImpl to invoke its custom subtarget
implementation. The custom TTI implementations continue to exist for
the other targets with this change. They are not moved over to
subtarget-based implementations.

The end goal is to have the default subtarget implementation defer to
the system model defined by the target. With this change, the default
subtarget implementation essentially returns "no information" for
these interfaces. None of the existing users of TTI will hit that
implementation because they define their own custom TTI
implementations and won't use the BasicTTIImpl implementations.

Once system models are in place for the targets that use these
interfaces, their custom TTI implementations can be removed.

Diff Detail

Event Timeline

greened created this revision.Jun 20 2019, 10:16 AM

This is the subset of D58736 covering changes to TTI and related classes. It does not introduce any new functionality, only reorganizes things a bit to move implementations into subtargets in preparation for defining system models for targets.

hfinkel accepted this revision.Jul 3 2019, 11:04 PM

I'd prefer we remove the redundant comments in TTIImpl.h (see below), but otherwise, LGTM.

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
390

I don't see any value in repeating these interface comments here. They're already present on the declarations in TargetTransformInfo.h, and they'll get out of sync here.

This revision is now accepted and ready to land.Jul 3 2019, 11:04 PM
greened marked an inline comment as done.Jul 4 2019, 7:50 PM
greened added inline comments.
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
390

Ok. I wasn't sure what the policy is. Some implementations have them, others don't. I agree that less duplication is better.

greened updated this revision to Diff 208197.Jul 5 2019, 9:29 AM

Updated to latest master and removed comments on implementations

greened marked an inline comment as done.Jul 5 2019, 9:30 AM

I know this now says "ready to land" but is one review really sufficient?

rengolin accepted this revision.Jul 5 2019, 9:37 AM

As far as I can see this is an NFC refactoring with obvious benefits to readability and extensibility. LGTM too. :)

I know this now says "ready to land" but is one review really sufficient?

This is a refactoring of existing functionality (and, FWIW, functionality originally contributed by me, later generalized by @anemet, and others). If you're looking for particular feedback from others, please call that out explicitly. The patch has been online for a couple of weeks, and there's been time for feedback. In short, yes, you should feel free to proceed.

Also, it is useful to note that all code is subject to post-commit code review, even for patches that have received pre-commit review. You may yet get feedback after you commit the change.

This revision was automatically updated to reflect the committed changes.
beanz added a subscriber: beanz.Oct 9 2019, 1:22 PM

This patch causes lots of warning spews because it adds virtual methods to a class that doesn't have a virtual destructor.

This patch causes lots of warning spews because it adds virtual methods to a class that doesn't have a virtual destructor.

Vitaly fixed it before I could get to it. Thanks for the heads-up!

ychen added a subscriber: ychen.Apr 20 2020, 6:20 PM
ychen added inline comments.
llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h
509 ↗(On Diff #209023)

BasicTTIImplBase is a CRTP base. The virtual here seems odd. Why not just move the SystemZ & Hexagon implementation to be under the MCSubtarget hierarchy and get rid of the virtual here?