This is an archive of the discontinued LLVM Phabricator instance.

[mlir][PDL] Define a new PDLInterp::FuncOp operation and drop uses of FuncOp
ClosedPublic

Authored by rriddle on Mar 8 2022, 2:21 PM.

Details

Summary

Defining our own function operation allows for the PDL interpreter
to be more self contained, and also removes any dependency on FuncOp;
which is moving out of the Builtin dialect.

Diff Detail

Event Timeline

rriddle created this revision.Mar 8 2022, 2:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2022, 2:21 PM
rriddle requested review of this revision.Mar 8 2022, 2:21 PM
rriddle updated this revision to Diff 413978.Mar 8 2022, 5:22 PM
mehdi_amini added inline comments.Mar 14 2022, 8:40 PM
mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
666

Can you document this builder as creating the entry block.
Also does this remove the default generated builders? I'm concerned we'd have some builders generating a block but not all of them.
Does it really pulls it weight when the client just has to call funcOp.addEntryBlock(); post creation?

672

I think there was a TODO in the review of the FunctionOpInterface to rename this API from getType to getFunctionType?
I'm afraid that if we don't address it now as a preamble to adding more custom FuncOp, we'll never get to it.

677–682

Shouldn't these have a default implementation in the interface trait?

687–690

Isn't this included in the ODS generated verifier? Can you have a test hit this condition?

mehdi_amini added inline comments.Mar 14 2022, 8:45 PM
mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp
190–191

Why isn't the trait verifying equality as well? The interface intends to accept a mismatch?

193–201

This block of code will be repeated multiple times I think: could this be refactored as a helper in a central place?

rriddle updated this revision to Diff 415328.Mar 15 2022, 12:06 AM
rriddle marked 4 inline comments as done.
rriddle added inline comments.Mar 15 2022, 12:07 AM
mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
666

Yeah, given that we always want an entry block. These functions don't have an "external" equivalent, so we always have a non-empty region.

Lower down I marked skipDefaultBuilders, so this should be the only builder generated.

672

Do you have a strong preference of doing now or later in the current commit stack? I still need to flip PDL over to use the prefixed accessors.

677–682

No. FunctionOpInterface doesn't assume that you use FunctionType, though we might want to consider a helper trait that stubs everything out for the FunctionType case.

687–690

Good point, removed. This was copy over from FuncOp before I added TypeAttrOf to support providing the concrete type to ODS.

mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp
190–191

Thanks for pointing this out, I don't understand why it doesn't. Let me just move this to the interface.

mehdi_amini accepted this revision.Mar 15 2022, 1:24 PM
mehdi_amini added inline comments.
mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
666

Ah I missed the skipDefaultBuilders

672

I'm fine if you want to do it later, but this is already a left over todo from the interface creation, so I just wouldn't want it to split through the cracks again and get into limbo.

This revision is now accepted and ready to land.Mar 15 2022, 1:24 PM