MLIR 22.0.0git
InferIntRangeInterfaceImpls.cpp
Go to the documentation of this file.
1//===- InferIntRangeInterfaceImpls.cpp - Integer range impls for affine --===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
12
13using namespace mlir;
14using namespace mlir::affine;
15using namespace mlir::intrange;
16
17//===----------------------------------------------------------------------===//
18// AffineApplyOp
19//===----------------------------------------------------------------------===//
20
21void AffineApplyOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
22 SetIntRangeFn setResultRange) {
23 AffineMap map = getAffineMap();
24
25 // Split operand ranges into dimensions and symbols.
26 unsigned numDims = map.getNumDims();
27 ArrayRef<ConstantIntRanges> dimRanges = argRanges.take_front(numDims);
28 ArrayRef<ConstantIntRanges> symbolRanges = argRanges.drop_front(numDims);
29
30 // Affine maps should have exactly one result for affine.apply.
31 assert(map.getNumResults() == 1 && "affine.apply must have single result");
32
33 // Infer the range for the affine expression.
34 ConstantIntRanges resultRange =
35 inferAffineExpr(map.getResult(0), dimRanges, symbolRanges);
36
37 setResultRange(getResult(), resultRange);
38}
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
Definition AffineMap.h:46
unsigned getNumDims() const
unsigned getNumResults() const
AffineExpr getResult(unsigned idx) const
A set of arbitrary-precision integers representing bounds on a given integer value.
ConstantIntRanges inferAffineExpr(AffineExpr expr, ArrayRef< ConstantIntRanges > dimRanges, ArrayRef< ConstantIntRanges > symbolRanges)
Infer the integer range for an affine expression given ranges for its dimensions and symbols.
Include the generated interface declarations.
llvm::function_ref< void(Value, const ConstantIntRanges &)> SetIntRangeFn
The type of the setResultRanges callback provided to ops implementing InferIntRangeInterface.