[PATCH] D145390: [ADT] Introduce `map_to_vector` helper

Laszlo Kindrat via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 08:19:00 PST 2023


laszlokindrat created this revision.
laszlokindrat added reviewers: rriddle, bzcheeseman.
Herald added subscribers: hanchung, Moerafaat, zero9178, sdasgup3, wenzhicui, wrengr, armkevincheng, jsmolens, sjarus, eric-k256, cota, mravishankar, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, csigg, antiagainst, shauheen, mehdi_amini, thopre.
Herald added a reviewer: aartbik.
Herald added a reviewer: bondhugula.
Herald added a reviewer: ThomasRaoux.
Herald added a project: All.
laszlokindrat requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Herald added subscribers: llvm-commits, stephenneuendorffer, nicolasvasilache.
Herald added a reviewer: herhut.
Herald added a reviewer: dcaballe.
Herald added projects: MLIR, LLVM.

The following pattern is common in the llvm codebase, as well as in downstream projects:

  llvm::to_vector(llvm::map_range(container, lambda))

This patch introduces a shortcut for this called `map_to_vector`.

This template depends on both `llvm/ADT/SmallVector.h` and `llvm/ADT/STLExtras.h`, and since these are both relatively large and do not depend on each other, the `map_to_vector` helper is placed in a new header under `llvm/ADT/SmallVectorExtras.h`. I am happy to change this if reviewers can suggest a better location.

Only a handful of use cases have been updated to use the new helper, but I'm happy to update across the codebase (either in this patch, or in subsequent diffs) if this patch is accepted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145390

Files:
  llvm/include/llvm/ADT/SmallVectorExtras.h
  mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
  mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
  mlir/lib/Dialect/Affine/IR/AffineOps.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145390.502661.patch
Type: text/x-patch
Size: 5329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230306/d8378a11/attachment-0001.bin>


More information about the llvm-commits mailing list