LLVM dialect: support for inline assembly expressions


I am new to the LLVM/MLIR space.

Recently, I’ve been struggling to figure out how to create inline-assembly expressions in the MLIR LLVM dialect. Haven’t found anything promising yet.

Would appreciate your help!


Would you want to preserve the order of instructions and the instructions in such a sequence or are you fine/prefer having the compiler reorder/optimize them? If it’s the latter, you could consider adding the necessary dialect ops (in LLVM or Vector) and use native MLIR instead.

There is no support for inline assembly in the LLVM dialect.

I am relatively open to having it in the dialect for completeness purposes, but a cleaner MLIR-based approach should introduce assembly instructions as another dialect and just mix the two.

Thank you!
What confuses me is that I would need to eventually “lower” any custom dialect ops to the LLVM dialect which I consider to be fixed, right ?
@bondhugula do you suggest that I can extend the LLVM dialect out-of-tree ?

That’s an interesting idea, but it should be an additive thing in my opinion. The main LLVM IR dialect should support inline asm … which isn’t just about instructions; you can also have directives and other weird things in them. Supporting target-specific dialects for machine instructions is interesting to consider - it seems related to target specific intrinsics the llvm dialect already has to support.

Also, just FYI, LLVM supports top level inline asm blobs, which are a bit different than inline asm instructions. They are much simpler too.

It should eventually have everything LLVM IR has.

Absolutely! I just want to make sure we do it for the right reason :slight_smile: