This is an archive of the discontinued LLVM Phabricator instance.

[APInt.h] Reduce the APInt header file interface a bit. NFC
ClosedPublic

Authored by lattner on Sep 8 2021, 5:37 PM.

Details

Summary

This moves one mid-size function out of line, inlines the
trivial tcAnd/tcOr/tcXor/tcComplement methods into their only
caller, and moves the magic/umagic functions into SelectionDAG
since they are implementation details of its algorithm. This
also removes the unit tests for magic, but these are already
tested in the divide lowering logic for various targets.

This also upgrades some C style comments to C++.

Diff Detail

Event Timeline

lattner created this revision.Sep 8 2021, 5:37 PM
lattner requested review of this revision.Sep 8 2021, 5:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2021, 5:37 PM
lattner accepted this revision.Sep 8 2021, 5:37 PM

Self approving as obvious, but will wait for pre submit tests to grind on this before submitting.

This revision is now accepted and ready to land.Sep 8 2021, 5:38 PM

Yes, clang tidy, I agree the naming is inconsistent. This change is a step forward, but there are many left to go :-)

This revision was landed with ongoing or failed builds.Sep 8 2021, 6:17 PM
This revision was automatically updated to reflect the committed changes.
craig.topper added inline comments.
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
5135

Will this end up being needed by GlobalISel? Is there a better place we could share?

lattner added inline comments.Sep 8 2021, 9:21 PM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
5135

Good question. If so, it should go in lib/CodeGen somewhere. I haven't been following GlobalISel, so I'm not sure where they are putting shared utilities between the two frameworks.

dsanders added inline comments.
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
5135

I don't think GlobalISel is using it at the moment but we were using it downstream in our targets GlobalISel legalizer. DAGISel and GlobalISel don't really share much so I'm not currently aware of a suitable home for it. Would it make sense in MathExtras.h?

lattner added inline comments.Sep 15 2021, 1:30 PM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
5135

Yeah, that could make sense, or it could even be moved up to lib/Codegen. It is a *really* specific algorithm for APInt.h.

This patch actually broke my downstream as well. I uploaded a patch to move this to a new file in Support: https://reviews.llvm.org/D110747