return isTopLevelValue(dimOp.getOperand());
return false;
}
- // This value is a block argument (which also includes 'affine.for' loop IVs).
- return true;
+ // This value has to be a block argument for a FuncOp or an affine.for.
+ auto *parentOp = cast<BlockArgument>(value)->getOwner()->getParentOp();
+ return isa<FuncOp>(parentOp) || isa<AffineForOp>(parentOp);
}
/// Returns true if the 'index' dimension of the `memref` defined by
return success();
}
-// The result of the affine apply operation can be used as a dimension id if it
-// is a CFG value or if it is an Value, and all the operands are valid
-// dimension ids.
+// The result of the affine apply operation can be used as a dimension id if all
+// its operands are valid dimension ids.
bool AffineApplyOp::isValidDim() {
return llvm::all_of(getOperands(),
[](Value *op) { return mlir::isValidDim(op); });
}
-// The result of the affine apply operation can be used as a symbol if it is
-// a CFG value or if it is an Value, and all the operands are symbols.
+// The result of the affine apply operation can be used as a symbol if all its
+// operands are symbols.
bool AffineApplyOp::isValidSymbol() {
return llvm::all_of(getOperands(),
[](Value *op) { return mlir::isValidSymbol(op); });
}
// -----
+func @affine_load_invalid_dim(%M : memref<10xi32>) {
+ "unknown"() ({
+ ^bb0(%arg: index):
+ affine.load %M[%arg] : memref<10xi32>
+ // expected-error@-1 {{index must be a dimension or symbol identifier}}
+ br ^bb1
+ ^bb1:
+ br ^bb1
+ }) : () -> ()
+ return
+}
+
+// -----
#map0 = (d0)[s0] -> (d0 + s0)
// FWDBWD-LABEL: slicing_test_2
func @slicing_test_2() {
%c0 = constant 0 : index
- %c1 = constant 1 : index
%c2 = constant 2 : index
%c16 = constant 16 : index
- loop.for %i0 = %c0 to %c16 step %c1 {
+ affine.for %i0 = %c0 to %c16 {
affine.for %i1 = (i)[] -> (i)(%i0) to 10 {
// BWD: matched: %[[b:.*]] {{.*}} backward static slice:
- // BWD: loop.for {{.*}}
+ // BWD: affine.for {{.*}}
// affine.for appears in the body of loop.for
// BWD: affine.for {{.*}}
%b = "slicing-test-op"(%i1): (index) -> index
// BWD: matched: %[[c:.*]] {{.*}} backward static slice:
- // BWD: loop.for {{.*}}
+ // BWD: affine.for {{.*}}
// affine.for appears in the body of loop.for
// BWD-NEXT: affine.for {{.*}}