12#include "clang/CIR/Interfaces/CIRLoopOpInterface.cpp.inc"
13#include "llvm/Support/ErrorHandling.h"
17void LoopOpInterface::getLoopOpSuccessorRegions(
18 LoopOpInterface op, mlir::RegionBranchPoint point,
19 llvm::SmallVectorImpl<mlir::RegionSuccessor> ®ions) {
20 assert(point.isParent() || point.getTerminatorPredecessorOrNull());
23 if (point.isParent()) {
24 regions.emplace_back(&op.getEntry());
28 mlir::Region *parentRegion =
29 point.getTerminatorPredecessorOrNull()->getParentRegion();
32 if (&op.getCond() == parentRegion) {
33 regions.emplace_back(mlir::RegionSuccessor::parent());
34 regions.emplace_back(&op.getBody());
39 if (&op.getBody() == parentRegion) {
41 mlir::Region *afterBody =
42 (op.maybeGetStep() ? op.maybeGetStep() : &op.getCond());
43 regions.emplace_back(afterBody);
48 if (op.maybeGetStep() == parentRegion) {
49 regions.emplace_back(&op.getCond());
53 llvm_unreachable(
"unexpected branch origin");
57LoopOpInterface::getLoopOpSuccessorInputs(LoopOpInterface op,
58 mlir::RegionSuccessor successor) {
59 if (successor.isParent())
60 return op->getResults();
61 if (successor == &op.getEntry())
62 return op.getEntry().getArguments();
63 if (successor == &op.getBody())
64 return op.getBody().getArguments();
65 mlir::Region *afterBody =
66 (op.maybeGetStep() ? op.maybeGetStep() : &op.getCond());
67 if (successor == afterBody)
68 return afterBody->getArguments();
69 if (successor == &op.getCond())
70 return op.getCond().getArguments();
71 llvm_unreachable(
"invalid region successor");
81 return llvm::success();
mlir::LogicalResult verifyLoopOpInterface(::mlir::Operation *op)
Verify invariants of the LoopOpInterface.