Alignment on memref.global

Hello,

While on memref.alloc it is possible to specify the alignment using an attribute, it appears from the documentation that this is not possible for memref.global objects. Is there any way of specifying it? If not, would it be possible to add this feature (an alignment attribute on mlir.global) which would be very useful in vectorized code?

Note that in LLVM IR, global variables allow the specification of an alignment, but this is not possible in the llvm dialect of MLIR. I therefore assume that the extension would have to touch the memref.global and llvm.mlir.globaloperations and the lowering passes of both mlir-opt and mlir-translate. But not in fundamental ways.

I could do it (it seems doable), but this would be my first contribution to the MLIR codebase, and therefore I’d need some supervision.

Dumitru

Nobody needed it so far, so nobody added it. You are welcome to add it, probably an attribute on llvm.mlir.global but I haven’t thought much about it. Just start a patch with what you think is the right approach and send it for review to me. Then we can iterate.

Excellent. Since this is my first time, can you check if the procedure I’ll follow is right:

  1. Check out the last version of llvm-project.
  2. Create a branch.
  3. Make my modifications.
  4. Create the patch using git.
  5. Send it to you through this forum as a direct message.

Is this right ?

Not really, reviews happen on Phabricator. See: How to Contribute - MLIR

Ok, I’ve done the first step, just to see how it works (it’s the first step, allowing specification of alignment on llvm.mlir.global objects in the LLVMIR MLIR dialect). The log message has been shortened for some reason.