LLVM Discussion Forums

Adding operations after an AffineForOp

Hello,

In a ConversionPattern I want to be able to create an AffineForOp and then get out of the loop body and continue adding operations after the end of the loop. Is this possible, and how can I do it? It seemed to me that a solution would be to get the Block of the AffineForOp and then call setInsertionPointToStart on that block. Is this correct? If yes, how can I get the block of the AffineForOp?

Regards,
Dumitru

To add operations after an AffineForOp or any op:

b.setInsertionPointAfter(op);

affineForOp.getBody() will give you the loop body of the AffineForOp which is a Block. But if you are referring to the block containing an AffineForOp, you’ll have to do affineForOp.getOperation().getBlock().

1 Like