LLVM Discussion Forums

[MLIR] Op with multiple results

I’m trying to create an Op which returns two values.

def Standalone_FooOp : Standalone_Op<"foo", []> {
    let arguments = (ins I32:$input);
    let results = (outs I32:$res1, I32:$res2);

    let assemblyFormat = [{
        $input attr-dict `:` type($input) type($res1) type($res2)
    }];
}

But I get this error:

[build] include/Standalone/StandaloneOps.h.inc:31:142: error: no member named 'OpAsmOpInterface' in namespace 'mlir'
[build] class FooOp : public ::mlir::Op<FooOp, OpTrait::ZeroRegion, OpTrait::NResults<2>::Impl, OpTrait::ZeroSuccessor, OpTrait::OneOperand, ::mlir::OpAsmOpInterface::Trait> {

My understanding is that tablegen is inheriting from a default trait class, because it can’t figure out how to deal with multiple results. And I’m not sure what traits the Op has to implement to make this work.

How do I fix this?

I think you’re missing an include for mlir/IR/OpImplementation.h

1 Like

Oh. I had included it in the implementation file (lib/StandaloneOps.cpp) but not in the header (include/StandaloneOps.h).
Included in the header instead now, and it works. Thanks!