//===-IntegerRangeAnalysis.h - Integer range analysis -----------*- 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 declares the dataflow analysis class for integer range inference // so that it can be used in transformations over the `arith` dialect such as // branch elimination or signed->unsigned rewriting. // // One can also implement InferIntRangeInterface on ops in custom dialects, // and then use this analysis to propagate ranges with custom semantics. // //===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_DATAFLOW_INTEGERANGEANALYSIS_H #define MLIR_ANALYSIS_DATAFLOW_INTEGERANGEANALYSIS_H #include "mlir/Analysis/DataFlow/SparseAnalysis.h" #include "mlir/Interfaces/InferIntRangeInterface.h" namespace mlir { namespace dataflow { /// This lattice element represents the integer value range of an SSA value. /// When this lattice is updated, it automatically updates the constant value /// of the SSA value (if the range can be narrowed to one). class IntegerValueRangeLattice : public Lattice<IntegerValueRange> { … }; /// Integer range analysis determines the integer value range of SSA values /// using operations that define `InferIntRangeInterface` and also sets the /// range of iteration indices of loops with known bounds. /// /// This analysis depends on DeadCodeAnalysis, and will be a silent no-op /// if DeadCodeAnalysis is not loaded in the same solver context. class IntegerRangeAnalysis : public SparseForwardDataFlowAnalysis<IntegerValueRangeLattice> { … }; } // end namespace dataflow } // end namespace mlir #endif // MLIR_ANALYSIS_DATAFLOW_INTEGERANGEANALYSIS_H