[Mlir-commits] [mlir] [MLIR] Add callback functions for ModuleToObject (PR #116007)

Zichen Lu llvmlistbot at llvm.org
Thu Nov 14 05:59:39 PST 2024


MikaOvO wrote:

Hi all. Thanks for your comments! Please let me answer your questions based on my understanding.

> How is this going to be used?

We can use like this:
```c++
auto callback = [](llvm::Module &module) {
  // do something like module.dump();
}
auto callback2 = [](llvm::StringRef isa) {
  // do something like llvm::outs() << isa;
}

gpu::TargetOptions options(..., callback, {}, {}, callback2)

```

> Why is this needed?

In `ModuleToObject::run()`, there is a continuous process of translating Module into LLVM IR. If we want to dump LLVM IR to debug without callback functions, we may need to subclass `ModuleToObject` and override `run`, then we may have code duplication.

https://github.com/llvm/llvm-project/pull/116007


More information about the Mlir-commits mailing list