18#include "llvm/ADT/StringExtras.h"
19#include "llvm/IR/ConstantRange.h"
36 llvm::ConstantRange valueRange(range->getLower(), range->getUpper());
37 if (!valueRange.isEmptySet()) {
39 {valueRange.getUnsignedMin(), valueRange.getUnsignedMax(),
40 valueRange.getSignedMin(), valueRange.getSignedMax()});
53 std::optional<LLVM::ConstantRangeAttr> rangeAttr) {
57 const llvm::APInt &lower = rangeAttr->getLower();
58 const llvm::APInt &upper = rangeAttr->getUpper();
61 if (lower == upper && !lower.isMaxValue() && !lower.isMinValue()) {
62 unsigned bitWidth = lower.getBitWidth();
63 llvm::APInt minVal = llvm::APInt::getMinValue(bitWidth);
64 llvm::APInt maxVal = llvm::APInt::getMaxValue(bitWidth);
66 "invalid range attribute: Lower == Upper, but they aren't min (")
67 << llvm::toString(minVal, 10,
false) <<
") or max ("
68 << llvm::toString(maxVal, 10,
false)
69 <<
") value! This is an invalid constant range.";
76#include "mlir/Dialect/LLVMIR/NVVMIndexSRegOps.cpp.inc"
static void nvvmInferResultRanges(std::optional< LLVM::ConstantRangeAttr > range, Value result, ArrayRef<::mlir::ConstantIntRanges > argRanges, SetIntRangeFn setResultRanges)
Infer the result ranges for the NVVM SpecialRangeableRegisterOp that might have ConstantRangeAttr.
static LogicalResult verifyConstantRangeAttr(Operation *op, std::optional< LLVM::ConstantRangeAttr > rangeAttr)
Verify the range attribute satisfies LLVM ConstantRange constructor requirements for NVVM SpecialRang...
static IntegerValueRange getMaxRange(Value value)
Create a maximal range ([0, uint_max(t)] / [int_min(t), int_max(t)]) range that is used to mark the v...
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Include the generated interface declarations.
llvm::function_ref< void(Value, const ConstantIntRanges &)> SetIntRangeFn
The type of the setResultRanges callback provided to ops implementing InferIntRangeInterface.