//===- InferIntRangeInterface.h - Integer Range Inference --*- C++ -*-===// // // 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 // //===----------------------------------------------------------------------===// // // This file contains definitions of the integer range inference interface // defined in `InferIntRange.td` // //===----------------------------------------------------------------------===// #ifndef MLIR_INTERFACES_INFERINTRANGEINTERFACE_H #define MLIR_INTERFACES_INFERINTRANGEINTERFACE_H #include "mlir/IR/OpDefinition.h" #include <optional> namespace mlir { /// A set of arbitrary-precision integers representing bounds on a given integer /// value. These bounds are inclusive on both ends, so /// bounds of [4, 5] mean 4 <= x <= 5. Separate bounds are tracked for /// the unsigned and signed interpretations of values in order to enable more /// precice inference of the interplay between operations with signed and /// unsigned semantics. class ConstantIntRanges { … }; raw_ostream &operator<<(raw_ostream &, const ConstantIntRanges &); /// This lattice value represents the integer range of an SSA value. class IntegerValueRange { … }; raw_ostream &operator<<(raw_ostream &, const IntegerValueRange &); /// The type of the `setResultRanges` callback provided to ops implementing /// InferIntRangeInterface. It should be called once for each integer result /// value and be passed the ConstantIntRanges corresponding to that value. SetIntRangeFn; /// Similar to SetIntRangeFn, but operating on IntegerValueRange lattice values. /// This is the `setResultRanges` callback for the IntegerValueRange based /// interface method. SetIntLatticeFn; class InferIntRangeInterface; namespace intrange::detail { /// Default implementation of `inferResultRanges` which dispatches to the /// `inferResultRangesFromOptional`. void defaultInferResultRanges(InferIntRangeInterface interface, ArrayRef<IntegerValueRange> argRanges, SetIntLatticeFn setResultRanges); /// Default implementation of `inferResultRangesFromOptional` which dispatches /// to the `inferResultRanges`. void defaultInferResultRangesFromOptional(InferIntRangeInterface interface, ArrayRef<ConstantIntRanges> argRanges, SetIntRangeFn setResultRanges); } // end namespace intrange::detail } // end namespace mlir #include "mlir/Interfaces/InferIntRangeInterface.h.inc" #endif // MLIR_INTERFACES_INFERINTRANGEINTERFACE_H