This is an archive of the discontinued LLVM Phabricator instance.

[llvm][STLExtras] Move various iterator/range utilities from MLIR to LLVM
ClosedPublic

Authored by rriddle on Apr 13 2020, 4:31 PM.

Details

Summary

This revision moves the various range utilities present in MLIR to LLVM to enable greater reuse. This revision moves the following utilities:

  • indexed_accessor_*

This is set of utility iterator/range base classes that allow for building a range class where the iterators are represented by an object+index pair.

  • make_second_range

Given a range of pairs, returns a range iterating over the second elements.

  • has_single_element

Returns if the given range has 1 element. size() == 1 checks end up being very common, but size() is not always O(1) (e.g., ilist). This method provides O(1) checks for those cases.

Depends On D78059

Diff Detail

Event Timeline

rriddle created this revision.Apr 13 2020, 4:31 PM
lattner accepted this revision.Apr 13 2020, 5:01 PM
lattner added inline comments.
llvm/include/llvm/ADT/STLExtras.h
267

STLExtras.h is hugely conflicted here, but I'd recommend naming this hasSingleElement.

This revision is now accepted and ready to land.Apr 13 2020, 5:01 PM
rriddle updated this revision to Diff 257193.Apr 13 2020, 9:57 PM

Resolve comments

This revision was automatically updated to reflect the committed changes.
mlir/lib/Transforms/Utils/LoopUtils.cpp