[IR] Add an ImplicitLocOpBuilder helper class for building IR with the same loc.
authorChris Lattner <clattner@nondot.org>
Tue, 22 Dec 2020 18:35:15 +0000 (10:35 -0800)
committerChris Lattner <clattner@nondot.org>
Tue, 22 Dec 2020 22:47:33 +0000 (14:47 -0800)
commit75a3f326c3d874853031d8bedd1d00127c835103
tree1bad0256e6fbe43ac3574f06af9cfdea5efaa43e
parent1c19804ebf4c97666a5c7de86ca7432c6b020205
[IR] Add an ImplicitLocOpBuilder helper class for building IR with the same loc.

One common situation is to create a lot of IR at a well known location,
e.g. when doing a big rewrite from one dialect to another where you're expanding
ops out into lots of other ops.

For these sorts of situations, it is annoying to pass the location into
every create call.  As we discused in a few threads on the forum, a way to help
with this is to produce a new sort of builder that holds a location and provides
it to each of the create<> calls automatically.

This patch implements an ImplicitLocOpBuilder class that does this.  We've had
good experience with this in the CIRCT project, and it makes sense to upstream to
MLIR.

I picked a random pass to adopt it to show the impact, but I don't think there is
any particular need to force adopt it in the codebase.

Differential Revision: https://reviews.llvm.org/D93717
mlir/include/mlir/IR/ImplicitLocOpBuilder.h [new file with mode: 0644]
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp