This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Execute all requested translations in MlirTranslateMain
ClosedPublic

Authored by naibaf7 on Feb 10 2023, 3:11 AM.

Details

Summary

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.

Diff Detail

Event Timeline

naibaf7 created this revision.Feb 10 2023, 3:11 AM
naibaf7 requested review of this revision.Feb 10 2023, 3:11 AM
naibaf7 edited the summary of this revision. (Show Details)Feb 10 2023, 5:49 AM
naibaf7 edited the summary of this revision. (Show Details)
lattner accepted this revision.Feb 10 2023, 6:08 AM
lattner added a reviewer: Mogball.

This makes sense to me, thank you Fabian. That said, please also wait for another person to take a look at this. Some folks have opposed expanding the API of mlir-translate before and I'm not sure exactly what the boundaries we want are.

This revision is now accepted and ready to land.Feb 10 2023, 6:08 AM
naibaf7 updated this revision to Diff 496450.Feb 10 2023, 6:11 AM

Add early-return on failure.

naibaf7 updated this revision to Diff 496452.Feb 10 2023, 6:16 AM

[mlir] Execute all requested translations in MlirTranslateMain

naibaf7 edited the summary of this revision. (Show Details)Feb 10 2023, 6:18 AM
Mogball accepted this revision.Feb 13 2023, 8:53 AM

LGTM. mlir-translate is intended first and foremost to be a testing tool. Making it easier to test with makes sense to me.

mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
70

is this list guaranteed to be non-empty?

93
97
105

please spell out this auto

127
naibaf7 marked an inline comment as done.Feb 13 2023, 9:26 AM
naibaf7 added inline comments.
mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
70

Yes, if it is empty (no option specified), then the ParseCommandLineOptions will error before this line is hit.

naibaf7 marked an inline comment as done.Feb 13 2023, 9:26 AM
naibaf7 marked 4 inline comments as done.Feb 13 2023, 9:32 AM
naibaf7 updated this revision to Diff 497040.Feb 13 2023, 10:22 AM

Address review.