This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Change translation API to allow custom top-level operations.
Needs ReviewPublic

Authored by stellaraccident on Jun 27 2021, 6:00 PM.

Details

Summary
  • Changes hooks to operate on Operation* instead of ModuleOp.
  • Adds a TranslateFromMLIRRegistration optional parserFunction argument allowing the parser to be configured (i.e. to build a custom top-level operation).
  • This allowed the removal of some top-level op munging in the SPIRV translations (verified by tests that required no modification).
  • As discussed in https://llvm.discourse.group/t/de-privileging-moduleop-in-translation-apis/3733

Diff Detail

Event Timeline

stellaraccident requested review of this revision.Jun 27 2021, 6:00 PM
rriddle added inline comments.Jun 29 2021, 11:40 AM
mlir/include/mlir/Translation.h
80

It would be nice if users could pass in a translate function that took Op Foo, and have it automatically do the type checking.

mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp
29

nit: Drop trivial braces.

mlir/lib/Target/SPIRV/TranslateRegistration.cpp
131–132

Can you add a constructor for OwningOpRef<Operation *> that allows for taking in OwningOpRef<Foo> &&? (You should be able to write it just using std::is_convertible<OpTy, Foo>). That would remove all of these weird conversion dances.