MLIR
20.0.0git
|
#include "mlir/Interfaces/Utils/InferIntRangeCommon.h"
#include "mlir/Interfaces/InferIntRangeInterface.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include <iterator>
#include <optional>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "int-range-analysis" |
Typedefs | |
using | ConstArithFn = function_ref< std::optional< APInt >(const APInt &, const APInt &)> |
Function that evaluates the result of doing something on arithmetic constants and returns std::nullopt on overflow. More... | |
using | ConstArithStdFn = std::function< std::optional< APInt >(const APInt &, const APInt &)> |
using | DivisionFixupFn = function_ref< std::optional< APInt >(const APInt &lhs, const APInt &rhs, const APInt &result)> |
Fix up division results (ex. More... | |
Functions | |
static ConstantIntRanges | computeBoundsBy (ConstArithFn op, const APInt &minLeft, const APInt &minRight, const APInt &maxLeft, const APInt &maxRight, bool isSigned) |
Compute op(minLeft, minRight) and op(maxLeft, maxRight) if possible, If either computation overflows, make the result unbounded. More... | |
static ConstantIntRanges | minMaxBy (ConstArithFn op, ArrayRef< APInt > lhs, ArrayRef< APInt > rhs, bool isSigned) |
Compute the minimum and maximum of (op(l, r) for l in lhs for r in rhs) , ignoring unbounded values. More... | |
static ConstantIntRanges | inferDivURange (const ConstantIntRanges &lhs, const ConstantIntRanges &rhs, DivisionFixupFn fixup) |
static ConstantIntRanges | inferDivSRange (const ConstantIntRanges &lhs, const ConstantIntRanges &rhs, DivisionFixupFn fixup) |
static std::tuple< APInt, APInt > | widenBitwiseBounds (const ConstantIntRanges &bound) |
"Widen" bounds - if 0bvvvvv??? <= a <= 0bvvvvv???, relax the bounds to 0bvvvvv000 <= a <= 0bvvvvv111, where vvvvv are the bits that both bonuds have in common. More... | |
static APInt | getVaryingBitsMask (const ConstantIntRanges &bound) |
Get bitmask of all bits which can change while iterating in [bound.umin(), bound.umax()]. More... | |
static intrange::CmpPredicate | invertPredicate (intrange::CmpPredicate pred) |
static bool | isStaticallyTrue (intrange::CmpPredicate pred, const ConstantIntRanges &lhs, const ConstantIntRanges &rhs) |
#define DEBUG_TYPE "int-range-analysis" |
Definition at line 28 of file InferIntRangeCommon.cpp.
using ConstArithFn = function_ref<std::optional<APInt>(const APInt &, const APInt &)> |
Function that evaluates the result of doing something on arithmetic constants and returns std::nullopt on overflow.
Definition at line 36 of file InferIntRangeCommon.cpp.
using ConstArithStdFn = std::function<std::optional<APInt>(const APInt &, const APInt &)> |
Definition at line 38 of file InferIntRangeCommon.cpp.
using DivisionFixupFn = function_ref<std::optional<APInt>( const APInt &lhs, const APInt &rhs, const APInt &result)> |
Fix up division results (ex.
for ceiling and floor), returning an APInt if there has been no overflow
Definition at line 284 of file InferIntRangeCommon.cpp.
|
static |
Compute op(minLeft, minRight) and op(maxLeft, maxRight) if possible, If either computation overflows, make the result unbounded.
Definition at line 43 of file InferIntRangeCommon.cpp.
References mlir::ConstantIntRanges::maxRange(), and mlir::ConstantIntRanges::range().
Referenced by mlir::intrange::inferAdd(), and mlir::intrange::inferSub().
|
static |
Get bitmask of all bits which can change while iterating in [bound.umin(), bound.umax()].
Definition at line 561 of file InferIntRangeCommon.cpp.
References mlir::ConstantIntRanges::umax(), and mlir::ConstantIntRanges::umin().
Referenced by mlir::intrange::inferXor().
|
static |
Definition at line 339 of file InferIntRangeCommon.cpp.
References mlir::ConstantIntRanges::maxRange(), minMaxBy(), mlir::ConstantIntRanges::smax(), and mlir::ConstantIntRanges::smin().
Referenced by mlir::intrange::inferCeilDivS(), mlir::intrange::inferDivS(), and mlir::intrange::inferFloorDivS().
|
static |
Definition at line 287 of file InferIntRangeCommon.cpp.
References mlir::ConstantIntRanges::fromUnsigned(), getZero(), minMaxBy(), mlir::ConstantIntRanges::umax(), and mlir::ConstantIntRanges::umin().
Referenced by mlir::intrange::inferCeilDivU(), and mlir::intrange::inferDivU().
|
static |
Definition at line 645 of file InferIntRangeCommon.cpp.
References mlir::intrange::eq, mlir::intrange::ne, mlir::intrange::sge, mlir::intrange::sgt, mlir::intrange::sle, mlir::intrange::slt, mlir::intrange::uge, mlir::intrange::ugt, mlir::intrange::ule, and mlir::intrange::ult.
Referenced by mlir::intrange::evaluatePred().
|
static |
Definition at line 671 of file InferIntRangeCommon.cpp.
References mlir::intrange::eq, mlir::ConstantIntRanges::getConstantValue(), mlir::intrange::ne, mlir::intrange::sge, mlir::intrange::sgt, mlir::intrange::sle, mlir::intrange::slt, mlir::ConstantIntRanges::smax(), mlir::ConstantIntRanges::smin(), mlir::intrange::uge, mlir::intrange::ugt, mlir::intrange::ule, mlir::intrange::ult, mlir::ConstantIntRanges::umax(), and mlir::ConstantIntRanges::umin().
Referenced by mlir::intrange::evaluatePred().
|
static |
Compute the minimum and maximum of (op(l, r) for l in lhs for r in rhs)
, ignoring unbounded values.
Returns the maximal range if op
overflows.
Definition at line 56 of file InferIntRangeCommon.cpp.
References getZero(), max(), mlir::ConstantIntRanges::maxRange(), min(), and mlir::ConstantIntRanges::range().
Referenced by mlir::intrange::inferAnd(), inferDivSRange(), inferDivURange(), mlir::intrange::inferMul(), and mlir::intrange::inferOr().
|
static |
"Widen" bounds - if 0bvvvvv??? <= a <= 0bvvvvv???, relax the bounds to 0bvvvvv000 <= a <= 0bvvvvv111, where vvvvv are the bits that both bonuds have in common.
This gives us a consertive approximation for what values can be passed to bitwise operations.
Definition at line 528 of file InferIntRangeCommon.cpp.
References mlir::ConstantIntRanges::umax(), and mlir::ConstantIntRanges::umin().
Referenced by mlir::intrange::inferAnd(), and mlir::intrange::inferOr().