[mlir] Execute all requested translations in MlirTranslateMain
authorFabian <fabian.tschopp@modular.com>
Sat, 18 Feb 2023 20:31:37 +0000 (21:31 +0100)
committerFabian <fabian.tschopp@modular.com>
Sat, 18 Feb 2023 20:31:59 +0000 (21:31 +0100)
commit09fd9ef4f4cb5c7b25bdb9f97d7e92445aec3417
tree95d0cb1d7cd590ac669318e70fc58b4bdc5cd73e
parent78f106a554b0c3ee8468ce291b5df5a730207490
[mlir] Execute all requested translations in MlirTranslateMain

Currently, MlirTranslateMain only executes one of the requested translations, and does not error if multiple are specified. This commit enables translations to be chained in the specified order.

This makes round-trip tests easier, since existing import/export passes can be reused and no combined round-trip passes have to be registered (example: mlir-translate  -serialize-spirv -deserialize-spirv).

Additionally, by leveraging TranslateRegistration with file-to-file TranslateFunctions, generic pre- and post-processing can be added before/after conversion to/from MLIR.

Reviewed By: lattner, Mogball

Differential Revision: https://reviews.llvm.org/D143719
mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
mlir/test/Target/SPIRV/array-two-step-roundtrip.mlir [new file with mode: 0644]