18 #include "llvm/Support/LogicalResult.h"
21 #include "mlir/Dialect/WasmSSA/IR/WasmSSAInterfaces.cpp.inc"
25 auto branchInterface = dyn_cast<LabelBranchingOpInterface>(op);
26 llvm::FailureOr<LabelLevelOpInterface> res =
27 LabelBranchingOpInterface::getTargetOpFromBlock(
28 op->
getBlock(), branchInterface.getExitLevel());
36 if (isa<ReturnOp>(currentOp) ||
39 op->
emitError(
"expected a constant initializer for this operator, got ")
47 Block *target = cast<LabelLevelOpInterface>(op).getLabelTarget();
51 return op->
emitError(
"target should be a block defined in same level than "
52 "operation or in its region.");
57 llvm::FailureOr<LabelLevelOpInterface>
58 LabelBranchingOpInterface::getTargetOpFromBlock(::
mlir::Block *block,
59 uint32_t breakLevel) {
60 LabelLevelOpInterface res{};
61 for (
size_t curLevel{0}; curLevel <= breakLevel; curLevel++) {
62 res = dyn_cast_or_null<LabelLevelOpInterface>(block->
getParentOp());
65 block = res->getBlock();
Block represents an ordered list of Operations.
Region * getParent() const
Provide a 'getParent' method for ilist_node_with_parent methods.
Operation * getParentOp()
Returns the closest surrounding operation that contains this block.
Operation is the basic unit of execution within MLIR.
bool hasTrait()
Returns true if the operation was registered with a particular trait, e.g.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
Block * getBlock()
Returns the operation block that contains this operation.
Region & getRegion(unsigned index)
Returns the region held by this operation at position 'index'.
Region * getParentRegion()
Returns the region to which the instruction belongs.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Operation * getParentOp()
Return the parent operation this region is attached to.
RetT walk(FnT &&callback)
Walk all nested operations, blocks or regions (including this region), depending on the type of callb...
A utility result that is used to signal how to proceed with an ongoing walk:
static WalkResult advance()
bool wasInterrupted() const
Returns true if the walk was interrupted.
static WalkResult interrupt()
LogicalResult verifyConstantExpressionInterface(Operation *op)
Verify that op conforms to the ConstantExpressionInterface.
LogicalResult verifyLabelBranchingOpInterface(Operation *op)
Verify that op conforms to the LabelBranchingOpInterface Checks that the branching is targetting some...
LogicalResult verifyLabelLevelInterface(Operation *op)
Verify that op conforms to the LabelLevelInterface op's target should defined at the same scope level...
Operations implementing this trait are considered as valid constant expressions in any context (In co...