Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,6 @@ void LoopOp::build(mlir::OpBuilder &b, mlir::OperationState &result,
}
}

ValueRange LoopOp::getSuccessorInputs(RegionSuccessor successor) {
return successor.isParent() ? getOperation()->getResults() : ValueRange();
}

void LoopOp::getSuccessorRegions(RegionBranchPoint point,
SmallVectorImpl<RegionSuccessor> &regions) {
// If the predecessor is the GenericOp, branch into the body.
Expand All @@ -668,7 +664,7 @@ void LoopOp::getSuccessorRegions(RegionBranchPoint point,
}

// Otherwise, the region branches back to the parent operation.
regions.push_back(RegionSuccessor::parent());
regions.push_back(RegionSuccessor(getOperation(), getResults()));
}

SmallVector<int64_t> LoopOp::getInitTiedResultIndices() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def LoopOp : PCF_Op<"loop", [
AutomaticAllocationScope,
RecursiveMemoryEffects,
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmBlockArgumentNames"]>,
DeclareOpInterfaceMethods<RegionBranchOpInterface, ["getSuccessorInputs"]>,
DeclareOpInterfaceMethods<RegionBranchOpInterface>,
SingleBlockImplicitTerminator<"mlir::iree_compiler::IREE::PCF::ReturnOp">
]> {
let summary = [{
Expand Down
8 changes: 2 additions & 6 deletions compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,19 +1013,15 @@ void DeviceMemoizeOp::build(OpBuilder &builder, OperationState &state,
state.addRegion();
}

ValueRange DeviceMemoizeOp::getSuccessorInputs(RegionSuccessor successor) {
return successor.isParent() ? getOperation()->getResults() : ValueRange();
}

void DeviceMemoizeOp::getSuccessorRegions(
RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> &regions) {
// Unconditional control flow into the region and back to the parent, so
// return the correct RegionSuccessor purely based on the index being None or
// 0.
if (!point.isParent()) {
regions.push_back(RegionSuccessor::parent());
regions.push_back(RegionSuccessor({}));
} else {
regions.push_back(RegionSuccessor(&getBody()));
regions.push_back(RegionSuccessor(&getBody(), getBody().getArguments()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def HAL_DispatchExternOp : HAL_PureOp<"dispatch.extern", [

def HAL_DeviceMemoizeOp : HAL_Op<"device.memoize", [
RecursiveMemoryEffects,
DeclareOpInterfaceMethods<RegionBranchOpInterface, ["getSuccessorInputs"]>,
DeclareOpInterfaceMethods<RegionBranchOpInterface>,
SingleBlockImplicitTerminator<"IREE::HAL::ReturnOp">,
]> {
let summary = [{Memoizes resources for a particular device and queue affinity.}];
Expand Down
46 changes: 13 additions & 33 deletions compiler/src/iree/compiler/Dialect/Stream/IR/StreamOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3413,20 +3413,15 @@ AsyncExecuteOp::getEntrySuccessorOperands(RegionSuccessor successor) {
return getResourceOperands();
}

ValueRange AsyncExecuteOp::getSuccessorInputs(RegionSuccessor successor) {
return successor.isParent() ? ValueRange(getResults())
: ValueRange(getBodyRegion().getArguments());
}

void AsyncExecuteOp::getSuccessorRegions(
RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> &regions) {
// Unconditional control flow into the region and back to the parent, so
// return the correct RegionSuccessor purely based on the index being None or
// 0.
if (!point.isParent()) {
regions.push_back(RegionSuccessor::parent());
regions.push_back(RegionSuccessor(getOperation(), getResults()));
} else {
regions.push_back(RegionSuccessor(&getBody()));
regions.push_back(RegionSuccessor(&getBody(), getBody().getArguments()));
}
}

Expand Down Expand Up @@ -3575,20 +3570,15 @@ AsyncConcurrentOp::getEntrySuccessorOperands(RegionSuccessor successor) {
return getResourceOperands();
}

ValueRange AsyncConcurrentOp::getSuccessorInputs(RegionSuccessor successor) {
return successor.isParent() ? ValueRange(getResults())
: ValueRange(getBodyRegion().getArguments());
}

void AsyncConcurrentOp::getSuccessorRegions(
RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> &regions) {
// Unconditional control flow into the region and back to the parent, so
// return the correct RegionSuccessor purely based on the index being None or
// 0.
if (!point.isParent()) {
regions.push_back(RegionSuccessor::parent());
regions.push_back(RegionSuccessor(getOperation(), getResults()));
} else {
regions.push_back(RegionSuccessor(&getBody()));
regions.push_back(RegionSuccessor(&getBody(), getBody().getArguments()));
}
}

Expand Down Expand Up @@ -4629,20 +4619,16 @@ CmdExecuteOp::getEntrySuccessorOperands(RegionSuccessor successor) {
return getResourceOperands();
}

ValueRange CmdExecuteOp::getSuccessorInputs(RegionSuccessor successor) {
return successor.isParent() ? ValueRange()
: ValueRange(getBodyRegion().getArguments());
}

void CmdExecuteOp::getSuccessorRegions(
RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> &regions) {
// Unconditional control flow into the region and back to the parent, so
// return the correct RegionSuccessor purely based on the index being None or
// 0.
if (!point.isParent()) {
regions.push_back(RegionSuccessor::parent());
regions.push_back(
RegionSuccessor(getOperation(), Operation::result_range(nullptr, 0)));
} else {
regions.push_back(RegionSuccessor(&getBody()));
regions.push_back(RegionSuccessor(&getBody(), getBody().getArguments()));
}
}

Expand Down Expand Up @@ -4706,19 +4692,16 @@ LogicalResult CmdSerialOp::verify() {
return success();
}

ValueRange CmdSerialOp::getSuccessorInputs(RegionSuccessor successor) {
return successor.isParent() ? getOperation()->getResults() : ValueRange();
}

void CmdSerialOp::getSuccessorRegions(
RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> &regions) {
// Unconditional control flow into the region and back to the parent, so
// return the correct RegionSuccessor purely based on the index being None or
// 0.
if (!point.isParent()) {
regions.push_back(RegionSuccessor::parent());
regions.push_back(
RegionSuccessor(getOperation(), Operation::result_range(nullptr, 0)));
} else {
regions.push_back(RegionSuccessor(&getBody()));
regions.push_back(RegionSuccessor(&getBody(), {}));
}
}

Expand All @@ -4736,19 +4719,16 @@ LogicalResult CmdConcurrentOp::verify() {
return success();
}

ValueRange CmdConcurrentOp::getSuccessorInputs(RegionSuccessor successor) {
return successor.isParent() ? getOperation()->getResults() : ValueRange();
}

void CmdConcurrentOp::getSuccessorRegions(
RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> &regions) {
// Unconditional control flow into the region and back to the parent, so
// return the correct RegionSuccessor purely based on the index being None or
// 0.
if (!point.isParent()) {
regions.push_back(RegionSuccessor::parent());
regions.push_back(
RegionSuccessor(getOperation(), Operation::result_range(nullptr, 0)));
} else {
regions.push_back(RegionSuccessor(&getBody()));
regions.push_back(RegionSuccessor(&getBody(), {}));
}
}

Expand Down
7 changes: 2 additions & 5 deletions compiler/src/iree/compiler/Dialect/Stream/IR/StreamOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2797,7 +2797,6 @@ def Stream_AsyncExecuteOp : Stream_Op<"async.execute", [
RecursiveMemoryEffects,
DeclareOpInterfaceMethods<RegionBranchOpInterface, [
"getEntrySuccessorOperands",
"getSuccessorInputs",
]>,
SingleBlockImplicitTerminator<"IREE::Stream::YieldOp">,
Stream_AffinityOp,
Expand Down Expand Up @@ -2893,7 +2892,6 @@ def Stream_AsyncConcurrentOp : Stream_Op<"async.concurrent", [
RecursiveMemoryEffects,
DeclareOpInterfaceMethods<RegionBranchOpInterface, [
"getEntrySuccessorOperands",
"getSuccessorInputs",
]>,
SingleBlockImplicitTerminator<"IREE::Stream::YieldOp">,
Stream_AffinityOp,
Expand Down Expand Up @@ -3865,7 +3863,6 @@ def Stream_CmdExecuteOp : Stream_Op<"cmd.execute", [
RecursiveMemoryEffects,
DeclareOpInterfaceMethods<RegionBranchOpInterface, [
"getEntrySuccessorOperands",
"getSuccessorInputs",
]>,
SingleBlockImplicitTerminator<"IREE::Stream::YieldOp">,
Stream_AffinityOp,
Expand Down Expand Up @@ -3946,7 +3943,7 @@ def Stream_CmdSerialOp : Stream_Op<"cmd.serial", [
"IREE::Stream::CmdConcurrentOp",
]>,
RecursiveMemoryEffects,
DeclareOpInterfaceMethods<RegionBranchOpInterface, ["getSuccessorInputs"]>,
DeclareOpInterfaceMethods<RegionBranchOpInterface>,
SingleBlockImplicitTerminator<"IREE::Stream::YieldOp">,
Stream_CmdPhaseOp,
Stream_StreamableOp,
Expand Down Expand Up @@ -4012,7 +4009,7 @@ def Stream_CmdConcurrentOp : Stream_Op<"cmd.concurrent", [
"IREE::Stream::CmdConcurrentOp",
]>,
RecursiveMemoryEffects,
DeclareOpInterfaceMethods<RegionBranchOpInterface, ["getSuccessorInputs"]>,
DeclareOpInterfaceMethods<RegionBranchOpInterface>,
SingleBlockImplicitTerminator<"IREE::Stream::YieldOp">,
Stream_CmdPhaseOp,
Stream_StreamableOp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ static IREE::Stream::AffinityAttr findLocalValueAffinity(Value value) {
auto terminatorOp =
cast<RegionBranchTerminatorOpInterface>(block.getTerminator());
value = terminatorOp.getSuccessorOperands(
RegionSuccessor::parent())[resultIndex];
RegionSuccessor(definingOp, definingOp->getResults()))[resultIndex];
} else if (auto tiedOp =
dyn_cast<IREE::Util::TiedOpInterface>(definingOp)) {
// If the producer is tied then try to get the operand.
Expand Down Expand Up @@ -1540,7 +1540,7 @@ static Value findTiedYieldResult(Value seedValue) {
cast<RegionBranchOpInterface>(seedValue.getParentRegion()->getParentOp());
SmallVector<RegionSuccessor> regions;
regionOp.getSuccessorRegions(regionOp->getRegion(0), regions);
auto results = regionOp.getSuccessorInputs(regions.front());
auto results = regions.front().getSuccessorInputs();
SmallVector<Value> worklist;
worklist.push_back(seedValue);
while (!worklist.empty()) {
Expand Down
10 changes: 6 additions & 4 deletions compiler/src/iree/compiler/Dialect/Util/Analysis/Explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ TraversalResult Explorer::walkReturnOperands(Operation *parentOp,
return walkReturnOps(parentOp, [&](Operation *returnOp) {
if (auto terminatorOp =
dyn_cast<RegionBranchTerminatorOpInterface>(returnOp)) {
return fn(terminatorOp.getSuccessorOperands(RegionSuccessor::parent()));
return fn(terminatorOp.getSuccessorOperands(
RegionSuccessor(parentOp, parentOp->getResults())));
} else {
return fn(returnOp->getOperands());
}
Expand Down Expand Up @@ -1007,7 +1008,7 @@ TraversalResult Explorer::walkTransitiveUses(Value value, UseWalkFn fn,
SmallVector<RegionSuccessor, 2> entrySuccessors;
regionOp.getSuccessorRegions(RegionBranchPoint::parent(), entrySuccessors);
for (auto &entrySuccessor : entrySuccessors) {
auto successorInputs = regionOp.getSuccessorInputs(entrySuccessor);
auto successorInputs = entrySuccessor.getSuccessorInputs();
if (operandIdx >= successorInputs.size()) {
// Implicit capture; argument has the same SSA value on the inside of
// the region. Uses show up as normal so we ignore here.
Expand All @@ -1029,8 +1030,9 @@ TraversalResult Explorer::walkTransitiveUses(Value value, UseWalkFn fn,
// Move within/out-of a region.
auto traverseRegionBranchOp = [&](RegionBranchTerminatorOpInterface branchOp,
unsigned operandIdx) {
auto successorOperands =
branchOp.getSuccessorOperands(RegionSuccessor::parent());
Operation *parentOp = branchOp.getOperation()->getParentOp();
auto successorOperands = branchOp.getSuccessorOperands(
RegionSuccessor(parentOp, parentOp->getResults()));
unsigned beginIdx = successorOperands.getBeginOperandIndex();
if (operandIdx < beginIdx ||
operandIdx >= beginIdx + successorOperands.size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ SmallVector<Position> getReturnedValuePositions(Region &region) {
regionOp.getSuccessorRegions(region, successors);
for (auto &successor : successors) {
if (successor.isParent()) {
return llvm::to_vector(
getPositions(regionOp.getSuccessorInputs(successor)));
return llvm::to_vector(getPositions(successor.getSuccessorInputs()));
}
}
assert(false && "should have found a parent successor");
Expand Down
2 changes: 1 addition & 1 deletion third_party/llvm-project
Submodule llvm-project updated 866 files
Loading