HomePhabricator

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

Authored by rriddle on Apr 14 2020, 2:53 PM.

Description

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

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.

  • hasSingleElement

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.

Differential Revision: https://reviews.llvm.org/D78064