Some questions about mlir lower

I made some extensions to the backend of llvm and added some intrinsics.Should I extend the llvm dialect?How should I extend the llvm dialect if I need to do so?What way should I use to get my dialect lower to the llvm dialect?I am not quite sure what is the best way to use.If anyone can help me, I would be grateful.Thanks!

I want to lower my dialect directly to the llvm dialect.

Hi there. I think you need to find a dilect level to replace the op in your dialect with a call to the intrinsics you mentioned.

Thank you for your reply.I have found the solution.

From your other posts, it looks like you are adding a different target architecture. We create new dialects for each group of target-specific intrinsics, e.g., NVVM llvm-project/ at main · llvm/llvm-project · GitHub. This is no different from creating any other dialect, follow the documentation Defining Dialects - MLIR. This dialect will not lower to the LLVM dialect because the latter doesn’t need to know about your extensions. It can be translated directly to LLVM IR by implementing LLVMTranslationDialectInterface. Some of the boilerplate translation can be generated from ODS definition of the dialect. The best approach is look at what is done for similar intrinsic sets, here’s an example for NVVM llvm-project/NVVMToLLVMIRTranslation.cpp at main · llvm/llvm-project · GitHub.