Page MenuHomePhabricator

[NFC] Create a AllocLikeOpInterface and make memref::AllocOp, memref::AllocaOp and gpu::AllocOp implement it.
Needs RevisionPublic

Authored by arnab-oss on Sep 22 2022, 4:12 AM.


  • Create AllocLikeOpInterface and put the common methods used by memref.alloc, mermen.alloca and gpu.alloc there.
  • Instead of checking explicitly for alloc or alloca ops, use hasSingleEffect().

Event Timeline

arnab-oss created this revision.Sep 22 2022, 4:12 AM
arnab-oss requested review of this revision.Sep 22 2022, 4:13 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
arnab-oss updated this revision to Diff 462132.Sep 22 2022, 4:28 AM

Make gpu.alloc op implement AllocLikeOpInterface

arnab-oss updated this revision to Diff 462137.Sep 22 2022, 4:56 AM


arnab-oss retitled this revision from Create a AllocLikeOpInterface and make memref::AllocLikeOp and gpu::AllocOp implement it. to [NFC] Create a AllocLikeOpInterface and make memref::AllocOp, memref::AllocaOp and gpu::AllocOp implement it..Sep 22 2022, 5:00 AM
arnab-oss edited the summary of this revision. (Show Details)
bondhugula edited reviewers, added: csigg; removed: aartbik.Sep 22 2022, 7:34 PM

This is looking good to me. Please pull out changes unrelated to AllocLikeOpInterface into a separate revision (the ones just switching to hasSingleEffect).


This change isn't related to the AllocLikeOpInterface; this and other similar changes can go into another revision.


The change to include GetGlobalOp is unrelated to this PR (and not proper as well) - it should be dropped.

ftynse requested changes to this revision.Oct 5 2022, 1:31 AM
ftynse added a subscriber: ftynse.

I would expect a new top-level interface (in lib/Interfaces) to go through the RFC process.

I have concerns about the interface design. Specifically, it appears to be promoting details specific to operations from one dialect (memref.alloc(a)) such as the fact that the result of an allocation is a memref (it's not, we have allocations in LLVM and SPIR-V that produce different types), that it has alignment defined as integer, and that it has some symbol operands presumably related to memref's affine layouts. If this were to live in lib/Interfaces, it should make either cover wider range of allocation-like operations or make a clear case as to why this is not desired accompanied by a name change.


I suppose these are only necessary because the dialect doesn't emit accessor using the prefixed form? Make sure to rebase this commit because the GPU dialect must have been switched to the prefixed form -




Please use the correct header line.


Please follow the (implicit) convention from other files for this line: the file name is left aligned, the file type is right aligned, and the entire line fits into 80 cols.


This looks wrong.


Type is not mandatory for allocations, can be just bytes.


Memref is not a mandatory concept for allocating memory, I would rather not enshrine it in the top-level interface.


Does it have to be a vector (copy) of values? Can't it be an OperandRange, a ValueRange or something similar?


Nit: 80 cols.

This revision now requires changes to proceed.Oct 5 2022, 1:31 AM