Hi everyone, is there any way that I could extract the results of a FunctionType
as ValueRange
, so that I could use it to create another op? I’ve only found the method getResults()
, which can only return the types.
FunctionType
is a type, you cannot convert it to value range. You can only have a value range if you have values to start with.
Yes, exactly.
A bit details: I’m trying to do something like this: There is a mydialect.myop
, which is much like a FuncOP
except it’s not really, needed to be lowered into func.func
. The op now looks like:
mydialect.myop @test inputs() outputs()
{
// ops here
}
I’m using the NoTerminator
Trait now. But for func.func
we must create one return
, right? And this return creation needs a ValueRange
.
Is it possible or is there a way to do such a thing?
How does your op specify which values are “returned”? If there are no such values, you can create an empty ValueRange
. Otherwise you need to collect the corresponding values into, e.g., SmallVector<Value>
from which a ValueRange
can be constructed implicitly.
There are some arguments defined in the scope of outputs
. I’m trying to return those Values.
I’m thinking it as well, I should try this.
Another question, how could I insert this ReturnOp
at the end of the region? I’m using the method inlineRegionBefore
to copy everything in the new FuncOp
. But I kinda stuck at how to insert a new one in it.
I suppose your region has a single block (otherwise no-terminator wouldn’t work), something like
auto builder = OpBuilder::atBlockEnd(®ion.front())
builder.create<ReturnOp>(...);
would work.
Thx so much. I’ll close this thread