[MLIR][GPU] Run generic LLVM optimizations when serializing (on AMD)
authorKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Thu, 18 Nov 2021 21:45:27 +0000 (21:45 +0000)
committerKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Fri, 19 Nov 2021 19:21:24 +0000 (19:21 +0000)
commitbd22554af06e1f16dc9ff12eac8987f0ceebe8c1
tree1b84b023f69cedc23383fbe1d20dacaf87f31349
parent47555d73f6538cf2c092a7314e3c82c631ce4ccb
[MLIR][GPU] Run generic LLVM optimizations when serializing (on AMD)

- Adds hooks that allow SerializeTo* passes to arbitrarily transform
the produced LLVM Module before it is passed to the code generation
passes.

- Uses these hooks within the SerializeToHsaco pass in order to run
LLVM optimizations and to set the optimization level on the
TargetMachine.

- Adds an optLevel parameter to SerializeToHsaco

Future work may include moving much of what's been added to
SerializeToHsaco to SerializeToBlob, but that would require
confirmation from the NVVM backend maintainers that it would be
appropriate to do so.

Depends on D114107

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D114113
mlir/include/mlir/Dialect/GPU/Passes.h
mlir/lib/Dialect/GPU/CMakeLists.txt
mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp
mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp