Is it possibly to support OperationState constructor based on an operation, like below:
OperationState(const Operation operation);
The background is i want to insert an region to an operation object, but it seems i can’t do it with the already created operation object. So i create an OperationState object with the same location, name, operands, types, attributes, successors like the already created operation object, except that i create an region to the OperationState object.
Then I can insert block, and other operations into this new region. It seems a little complex to achieve this, so is there any other solution, or should OperationState/OpBuilder support create operation based on the other operation.
Thanks very much for every one.
Operation::clone in the
mlir/IR/Operation.h may help. It clones a new operation with
Hi Myriad-Dreamin, thanks for your reply. I don’t find the
OperationState Operation::clone(...) in the
mlir/IR/Operation.h, could you tell me the link located to this method(by using github link). thanks for your help.
The method is at llvm-project/Operation.h at main · llvm/llvm-project · GitHub
From reading the implementation, it copies the state here and the result is equivalent to calling the
Operation::create(const OperationState &).
llvm-project/Operation.cpp at main · llvm/llvm-project · GitHub
thanks for your reply. It seems not suitable for my problem, as i want to add a region for the operation. Currently the Operation class doesn’t have a method to clone with itself and create a new region at the same time. So to achieve it, now i use a tmp OperationState object, and add a region to it, then call OpBuilder’s create method.