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
2 changes: 2 additions & 0 deletions compiler/src/iree/compiler/API/api_exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ extern void mlirLinalgGetIndexingMapsAttribute();
extern void mlirLinalgInferContractionDimensions();
extern void mlirLinalgInferContractionDimensionsFromMaps();
extern void mlirLinalgInferConvolutionDimensions();
extern void mlirLinalgInferConvolutionDimensionsFromMaps();
extern void mlirLinalgIsAContractionOp();
extern void mlirLinalgIsAConvolutionOp();
extern void mlirLlvmRawFdOStreamCreate();
Expand Down Expand Up @@ -1887,6 +1888,7 @@ uintptr_t __iree_compiler_hidden_force_extern() {
x += (uintptr_t)&mlirLinalgInferContractionDimensions;
x += (uintptr_t)&mlirLinalgInferContractionDimensionsFromMaps;
x += (uintptr_t)&mlirLinalgInferConvolutionDimensions;
x += (uintptr_t)&mlirLinalgInferConvolutionDimensionsFromMaps;
x += (uintptr_t)&mlirLinalgIsAContractionOp;
x += (uintptr_t)&mlirLinalgIsAConvolutionOp;
x += (uintptr_t)&mlirLlvmRawFdOStreamCreate;
Expand Down
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/API/api_exports.def
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ EXPORTS
mlirLinalgInferContractionDimensions
mlirLinalgInferContractionDimensionsFromMaps
mlirLinalgInferConvolutionDimensions
mlirLinalgInferConvolutionDimensionsFromMaps
mlirLinalgIsAContractionOp
mlirLinalgIsAConvolutionOp
mlirLlvmRawFdOStreamCreate
Expand Down
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/API/api_exports.ld
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ VER_0 {
mlirLinalgInferContractionDimensions;
mlirLinalgInferContractionDimensionsFromMaps;
mlirLinalgInferConvolutionDimensions;
mlirLinalgInferConvolutionDimensionsFromMaps;
mlirLinalgIsAContractionOp;
mlirLinalgIsAConvolutionOp;
mlirLlvmRawFdOStreamCreate;
Expand Down
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/API/api_exports.macos.lst
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ _mlirLinalgGetIndexingMapsAttribute
_mlirLinalgInferContractionDimensions
_mlirLinalgInferContractionDimensionsFromMaps
_mlirLinalgInferConvolutionDimensions
_mlirLinalgInferConvolutionDimensionsFromMaps
_mlirLinalgIsAContractionOp
_mlirLinalgIsAConvolutionOp
_mlirLlvmRawFdOStreamCreate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ void LoopOp::build(mlir::OpBuilder &b, mlir::OperationState &result,
}

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

void LoopOp::getSuccessorRegions(RegionBranchPoint point,
Expand All @@ -668,7 +668,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()));
}

SmallVector<int64_t> LoopOp::getInitTiedResultIndices() {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ void DeviceMemoizeOp::build(OpBuilder &builder, OperationState &state,
}

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

void DeviceMemoizeOp::getSuccessorRegions(
Expand All @@ -1032,7 +1032,7 @@ void DeviceMemoizeOp::getSuccessorRegions(
// 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()));
} else {
regions.push_back(RegionSuccessor(&getBody()));
}
Expand Down
26 changes: 13 additions & 13 deletions compiler/src/iree/compiler/Dialect/Stream/IR/StreamOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3524,8 +3524,8 @@ AsyncExecuteOp::getEntrySuccessorOperands(RegionSuccessor successor) {
}

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

void AsyncExecuteOp::getSuccessorRegions(
Expand All @@ -3534,7 +3534,7 @@ void AsyncExecuteOp::getSuccessorRegions(
// 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()));
} else {
regions.push_back(RegionSuccessor(&getBody()));
}
Expand Down Expand Up @@ -3686,8 +3686,8 @@ AsyncConcurrentOp::getEntrySuccessorOperands(RegionSuccessor successor) {
}

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

void AsyncConcurrentOp::getSuccessorRegions(
Expand All @@ -3696,7 +3696,7 @@ void AsyncConcurrentOp::getSuccessorRegions(
// 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()));
} else {
regions.push_back(RegionSuccessor(&getBody()));
}
Expand Down Expand Up @@ -4740,8 +4740,8 @@ CmdExecuteOp::getEntrySuccessorOperands(RegionSuccessor successor) {
}

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

void CmdExecuteOp::getSuccessorRegions(
Expand All @@ -4750,7 +4750,7 @@ void CmdExecuteOp::getSuccessorRegions(
// 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()));
} else {
regions.push_back(RegionSuccessor(&getBody()));
}
Expand Down Expand Up @@ -4817,7 +4817,7 @@ LogicalResult CmdSerialOp::verify() {
}

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

void CmdSerialOp::getSuccessorRegions(
Expand All @@ -4826,7 +4826,7 @@ void CmdSerialOp::getSuccessorRegions(
// 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()));
} else {
regions.push_back(RegionSuccessor(&getBody()));
}
Expand All @@ -4847,7 +4847,7 @@ LogicalResult CmdConcurrentOp::verify() {
}

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

void CmdConcurrentOp::getSuccessorRegions(
Expand All @@ -4856,7 +4856,7 @@ void CmdConcurrentOp::getSuccessorRegions(
// 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()));
} else {
regions.push_back(RegionSuccessor(&getBody()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static bool canReachRegion(RegionBranchOpInterface op, Region *from,
SmallVector<RegionSuccessor, 2> successors;
op.getSuccessorRegions(*current, successors);
for (auto &successor : successors) {
if (successor.isParent()) {
if (successor.isOperation()) {
continue;
}
Region *target = successor.getSuccessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ tryEliminateAwaitBeforeRegionBranchYield(IREE::Stream::TimepointAwaitOp awaitOp,
for (auto successor : successors) {
// Only handle yields to parent (region -> parent op results).
// Yields to other regions would require different analysis.
if (!successor.isParent()) {
if (!successor.isOperation()) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ static IREE::Stream::AffinityAttr findLocalValueAffinity(Value value) {
auto terminatorOp =
cast<RegionBranchTerminatorOpInterface>(block.getTerminator());
value = terminatorOp.getSuccessorOperands(
RegionSuccessor::parent())[resultIndex];
RegionSuccessor(regionOp.getOperation()))[resultIndex];
} else if (auto tiedOp =
dyn_cast<IREE::Util::TiedOpInterface>(definingOp)) {
// If the producer is tied then try to get the operand.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,10 @@
TraversalResult Explorer::walkReturnOperands(Operation *parentOp,
OperandRangeWalkFn fn) {
return walkReturnOps(parentOp, [&](Operation *returnOp) {
if (auto terminatorOp =

Check warning on line 624 in compiler/src/iree/compiler/Dialect/Util/Analysis/Explorer.cpp

View workflow job for this annotation

GitHub Actions / clang-tidy

compiler/src/iree/compiler/Dialect/Util/Analysis/Explorer.cpp:624:5 [bugprone-branch-clone]

if with identical then and else branches
dyn_cast<RegionBranchTerminatorOpInterface>(returnOp)) {
return fn(terminatorOp.getSuccessorOperands(RegionSuccessor::parent()));
return fn(terminatorOp.getSuccessorOperands(
RegionSuccessor(terminatorOp->getParentOp())));
} else {
return fn(returnOp->getOperands());
}
Expand Down Expand Up @@ -664,7 +665,7 @@
for (auto &entrySuccessor : entrySuccessors) {
// Skip parent-exit successors — they represent the region being
// skipped entirely, so no values flow into the entry block.
if (entrySuccessor.isParent()) {
if (entrySuccessor.isOperation()) {
continue;
}
if (fn(regionOp->getBlock(),
Expand Down Expand Up @@ -1014,7 +1015,7 @@
// the body entirely). The parent-exit path maps operands to op results,
// but the body path already covers this connection statically
// (init_arg → block_arg → yield → result).
if (entrySuccessor.isParent()) {
if (entrySuccessor.isOperation()) {
continue;
}
auto successorInputs = regionOp.getSuccessorInputs(entrySuccessor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SmallVector<Position> getReturnedValuePositions(Region &region) {
SmallVector<RegionSuccessor> successors;
regionOp.getSuccessorRegions(region, successors);
for (auto &successor : successors) {
if (successor.isParent()) {
if (successor.isOperation()) {
return llvm::to_vector(
getPositions(regionOp.getSuccessorInputs(successor)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,32 +99,33 @@ void asRValues(OpBuilder builder, Location location,
TypedValue<emitc::PointerType>
addressOf(OpBuilder builder, Location location,
TypedValue<emitc::LValueType> operand) {
auto ctx = builder.getContext();

auto result = emitc::ApplyOp::create(
auto result = emitc::AddressOfOp::create(
builder,
/*location=*/location,
/*result=*/
emitc::PointerType::get(operand.getType().getValueType()),
/*applicableOperator=*/StringAttr::get(ctx, "&"),
/*operand=*/operand)
/*reference=*/operand)
.getResult();

return cast<TypedValue<emitc::PointerType>>(result);
}

Value contentsOf(OpBuilder builder, Location location, Value operand) {
auto ctx = builder.getContext();
assert(isa<emitc::PointerType>(operand.getType()));

Type type = operand.getType();
assert(isa<emitc::PointerType>(type));

return emitc::ApplyOp::create(
builder,
/*location=*/location,
/*result=*/cast<emitc::PointerType>(type).getPointee(),
/*applicableOperator=*/StringAttr::get(ctx, "*"),
/*operand=*/operand)
// Dereference the pointer as `ptr[0]`, which is equivalent to `*ptr`. We use
// subscript + load rather than emitc.dereference because the latter produces
// an lvalue that cannot be emitted when declaring variables at the top of a
// function (the mode used for vm-c output).
Type indexType = emitc::OpaqueType::get(ctx, "iree_host_size_t");
Value indexValue =
emitc::LiteralOp::create(builder, location, indexType, "0");
TypedValue<emitc::LValueType> subscript = emitc::SubscriptOp::create(
builder, location, cast<TypedValue<emitc::PointerType>>(operand),
indexValue);
return emitc::LoadOp::create(builder, location,
subscript.getType().getValueType(), subscript)
.getResult();
}

Expand Down
Loading
Loading