aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/Interfaces')
-rw-r--r--mlir/lib/Interfaces/AlignmentAttrInterface.cpp13
-rw-r--r--mlir/lib/Interfaces/CMakeLists.txt2
-rw-r--r--mlir/lib/Interfaces/ControlFlowInterfaces.cpp1
-rw-r--r--mlir/lib/Interfaces/InferTypeOpInterface.cpp16
-rw-r--r--mlir/lib/Interfaces/ValueBoundsOpInterface.cpp44
5 files changed, 50 insertions, 26 deletions
diff --git a/mlir/lib/Interfaces/AlignmentAttrInterface.cpp b/mlir/lib/Interfaces/AlignmentAttrInterface.cpp
new file mode 100644
index 0000000..fe985ad
--- /dev/null
+++ b/mlir/lib/Interfaces/AlignmentAttrInterface.cpp
@@ -0,0 +1,13 @@
+//===- AlignmentAttrInterface.cpp -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Interfaces/AlignmentAttrInterface.h"
+
+using namespace mlir;
+
+#include "mlir/Interfaces/AlignmentAttrInterface.cpp.inc"
diff --git a/mlir/lib/Interfaces/CMakeLists.txt b/mlir/lib/Interfaces/CMakeLists.txt
index f96af02..ad3e2b6 100644
--- a/mlir/lib/Interfaces/CMakeLists.txt
+++ b/mlir/lib/Interfaces/CMakeLists.txt
@@ -1,4 +1,5 @@
set(LLVM_OPTIONAL_SOURCES
+ AlignmentAttrInterface.cpp
CallInterfaces.cpp
CastInterfaces.cpp
ControlFlowInterfaces.cpp
@@ -41,6 +42,7 @@ function(add_mlir_interface_library name)
endfunction(add_mlir_interface_library)
+add_mlir_interface_library(AlignmentAttrInterface)
add_mlir_interface_library(CallInterfaces)
add_mlir_interface_library(CastInterfaces)
add_mlir_interface_library(ControlFlowInterfaces)
diff --git a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
index 1e56810..7420412 100644
--- a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
+++ b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp
@@ -328,7 +328,6 @@ static bool traverseRegionGraph(Region *begin,
<< nextRegion->getRegionNumber() << ", returning true";
return true;
}
- llvm::dbgs() << "Region: " << nextRegion << "\n";
if (!nextRegion->getParentOp()) {
llvm::errs() << "Region " << *nextRegion << " has no parent op\n";
return false;
diff --git a/mlir/lib/Interfaces/InferTypeOpInterface.cpp b/mlir/lib/Interfaces/InferTypeOpInterface.cpp
index 9f4f672..c31e0ae7 100644
--- a/mlir/lib/Interfaces/InferTypeOpInterface.cpp
+++ b/mlir/lib/Interfaces/InferTypeOpInterface.cpp
@@ -58,6 +58,22 @@ mlir::reifyResultShapes(OpBuilder &b, Operation *op,
return status;
}
+FailureOr<SmallVector<OpFoldResult>>
+mlir::reifyShapeOfResult(OpBuilder &b, Operation *op, int resultIndex) {
+ auto reifiableOp = dyn_cast<ReifyRankedShapedTypeOpInterface>(op);
+ if (!reifiableOp)
+ return failure();
+ return reifiableOp.reifyShapeOfResult(b, resultIndex);
+}
+
+FailureOr<OpFoldResult> mlir::reifyDimOfResult(OpBuilder &b, Operation *op,
+ int resultIndex, int dim) {
+ auto reifiableOp = dyn_cast<ReifyRankedShapedTypeOpInterface>(op);
+ if (!reifiableOp)
+ return failure();
+ return reifiableOp.reifyDimOfResult(b, resultIndex, dim);
+}
+
bool ShapeAdaptor::hasRank() const {
if (val.isNull())
return false;
diff --git a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
index d2bafb7..cfe808b 100644
--- a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
+++ b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
@@ -16,6 +16,7 @@
#include "mlir/Interfaces/ViewLikeInterface.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/DebugLog.h"
#define DEBUG_TYPE "value-bounds-op-interface"
@@ -128,7 +129,7 @@ ValueBoundsConstraintSet::Variable::Variable(AffineMap map,
assert(var.map.getNumDims() == 0 && "expected only symbols");
SmallVector<AffineExpr> symReplacements;
for (auto valueDim : var.mapOperands) {
- auto it = llvm::find(this->mapOperands, valueDim);
+ auto *it = llvm::find(this->mapOperands, valueDim);
if (it != this->mapOperands.end()) {
// There is already a symbol for this operand.
symReplacements.push_back(b.getAffineSymbolExpr(
@@ -195,7 +196,7 @@ void ValueBoundsConstraintSet::addBound(BoundType type, int64_t pos,
// Even without this bound, there may be enough information in the
// constraint system to compute the requested bound. In case this bound is
// actually needed, `computeBound` will return `failure`.
- LLVM_DEBUG(llvm::dbgs() << "Failed to add bound: " << expr << "\n");
+ LDBG() << "Failed to add bound: " << expr << "\n";
}
}
@@ -271,11 +272,9 @@ int64_t ValueBoundsConstraintSet::insert(Value value,
assert(!valueDimToPosition.contains(valueDim) && "already mapped");
int64_t pos = isSymbol ? cstr.appendVar(VarKind::Symbol)
: cstr.appendVar(VarKind::SetDim);
- LLVM_DEBUG(llvm::dbgs() << "Inserting constraint set column " << pos
- << " for: " << value
- << " (dim: " << dim.value_or(kIndexValue)
- << ", owner: " << getOwnerOfValue(value)->getName()
- << ")\n");
+ LDBG() << "Inserting constraint set column " << pos << " for: " << value
+ << " (dim: " << dim.value_or(kIndexValue)
+ << ", owner: " << getOwnerOfValue(value)->getName() << ")";
positionToValueDim.insert(positionToValueDim.begin() + pos, valueDim);
// Update reverse mapping.
for (int64_t i = pos, e = positionToValueDim.size(); i < e; ++i)
@@ -283,8 +282,8 @@ int64_t ValueBoundsConstraintSet::insert(Value value,
valueDimToPosition[*positionToValueDim[i]] = i;
if (addToWorklist) {
- LLVM_DEBUG(llvm::dbgs() << "Push to worklist: " << value
- << " (dim: " << dim.value_or(kIndexValue) << ")\n");
+ LDBG() << "Push to worklist: " << value
+ << " (dim: " << dim.value_or(kIndexValue) << ")";
worklist.push(pos);
}
@@ -294,8 +293,7 @@ int64_t ValueBoundsConstraintSet::insert(Value value,
int64_t ValueBoundsConstraintSet::insert(bool isSymbol) {
int64_t pos = isSymbol ? cstr.appendVar(VarKind::Symbol)
: cstr.appendVar(VarKind::SetDim);
- LLVM_DEBUG(llvm::dbgs() << "Inserting anonymous constraint set column " << pos
- << "\n");
+ LDBG() << "Inserting anonymous constraint set column " << pos;
positionToValueDim.insert(positionToValueDim.begin() + pos, std::nullopt);
// Update reverse mapping.
for (int64_t i = pos, e = positionToValueDim.size(); i < e; ++i)
@@ -339,10 +337,9 @@ int64_t ValueBoundsConstraintSet::getPos(Value value,
cast<BlockArgument>(value).getOwner()->isEntryBlock()) &&
"unstructured control flow is not supported");
#endif // NDEBUG
- LLVM_DEBUG(llvm::dbgs() << "Getting pos for: " << value
- << " (dim: " << dim.value_or(kIndexValue)
- << ", owner: " << getOwnerOfValue(value)->getName()
- << ")\n");
+ LDBG() << "Getting pos for: " << value
+ << " (dim: " << dim.value_or(kIndexValue)
+ << ", owner: " << getOwnerOfValue(value)->getName() << ")";
auto it =
valueDimToPosition.find(std::make_pair(value, dim.value_or(kIndexValue)));
assert(it != valueDimToPosition.end() && "expected mapped entry");
@@ -364,7 +361,7 @@ bool ValueBoundsConstraintSet::isMapped(Value value,
}
void ValueBoundsConstraintSet::processWorklist() {
- LLVM_DEBUG(llvm::dbgs() << "Processing value bounds worklist...\n");
+ LDBG() << "Processing value bounds worklist...";
while (!worklist.empty()) {
int64_t pos = worklist.front();
worklist.pop();
@@ -386,8 +383,8 @@ void ValueBoundsConstraintSet::processWorklist() {
// Do not process any further if the stop condition is met.
auto maybeDim = dim == kIndexValue ? std::nullopt : std::make_optional(dim);
if (stopCondition(value, maybeDim, *this)) {
- LLVM_DEBUG(llvm::dbgs() << "Stop condition met for: " << value
- << " (dim: " << maybeDim << ")\n");
+ LDBG() << "Stop condition met for: " << value << " (dim: " << maybeDim
+ << ")";
continue;
}
@@ -395,9 +392,8 @@ void ValueBoundsConstraintSet::processWorklist() {
// the worklist.
auto valueBoundsOp =
dyn_cast<ValueBoundsOpInterface>(getOwnerOfValue(value));
- LLVM_DEBUG(llvm::dbgs()
- << "Query value bounds for: " << value
- << " (owner: " << getOwnerOfValue(value)->getName() << ")\n");
+ LDBG() << "Query value bounds for: " << value
+ << " (owner: " << getOwnerOfValue(value)->getName() << ")";
if (valueBoundsOp) {
if (dim == kIndexValue) {
valueBoundsOp.populateBoundsForIndexValue(value, *this);
@@ -406,7 +402,7 @@ void ValueBoundsConstraintSet::processWorklist() {
}
continue;
}
- LLVM_DEBUG(llvm::dbgs() << "--> ValueBoundsOpInterface not implemented\n");
+ LDBG() << "--> ValueBoundsOpInterface not implemented";
// If the op does not implement `ValueBoundsOpInterface`, check if it
// implements the `DestinationStyleOpInterface`. OpResults of such ops are
@@ -705,9 +701,7 @@ bool ValueBoundsConstraintSet::comparePos(int64_t lhsPos,
// We cannot prove anything if the constraint set is already empty.
if (cstr.isEmpty()) {
- LLVM_DEBUG(
- llvm::dbgs()
- << "cannot compare value/dims: constraint system is already empty");
+ LDBG() << "cannot compare value/dims: constraint system is already empty";
return false;
}