MLIR 23.0.0git
IntegerDivisibilityAnalysis.h
Go to the documentation of this file.
1//===- IntegerDivisibilityAnalysis.h - Integer divisibility -----*- C++ -*-===//
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//
9// This file declares the dataflow analysis class for integer divisibility
10// inference. Operations participate in the analysis by implementing
11// `InferIntDivisibilityOpInterface`.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef MLIR_ANALYSIS_DATAFLOW_INTEGERDIVISIBILITYANALYSIS_H
16#define MLIR_ANALYSIS_DATAFLOW_INTEGERDIVISIBILITYANALYSIS_H
17
20
21namespace mlir::dataflow {
22
23/// This lattice element represents the integer divisibility of an SSA value.
24class IntegerDivisibilityLattice : public Lattice<IntegerDivisibility> {
25public:
26 using Lattice::Lattice;
27};
28
29/// Integer divisibility analysis determines, for each integer-typed SSA
30/// value, a divisor that the value is guaranteed to be a multiple of. It
31/// uses operations that implement `InferIntDivisibilityOpInterface` and
32/// also sets the divisibility of induction variables of loops with known
33/// lower bounds and steps.
34///
35/// This analysis depends on DeadCodeAnalysis, and will be a silent no-op
36/// if DeadCodeAnalysis is not loaded in the same solver context.
38 : public SparseForwardDataFlowAnalysis<IntegerDivisibilityLattice> {
39public:
41
42 /// At an entry point, set the lattice to the most pessimistic state,
43 /// indicating that no further reasoning can be done.
44 void setToEntryState(IntegerDivisibilityLattice *lattice) override;
45
46 /// Visit an operation, invoking the transfer function.
47 LogicalResult
51
52 /// Visit block arguments or operation results of an operation with region
53 /// control-flow for which values are not defined by region control-flow. This
54 /// function tries to infer the divisibility of loop induction variables based
55 /// on known loop bounds and steps.
57 Operation *op, const RegionSuccessor &successor,
58 ValueRange successorInputs,
59 ArrayRef<IntegerDivisibilityLattice *> argLattices) override;
60};
61
62} // namespace mlir::dataflow
63
64#endif // MLIR_ANALYSIS_DATAFLOW_INTEGERDIVISIBILITYANALYSIS_H
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
This class represents a successor of a region.
This class provides an abstraction over the different types of ranges over Values.
Definition ValueRange.h:389
Integer divisibility analysis determines, for each integer-typed SSA value, a divisor that the value ...
void visitNonControlFlowArguments(Operation *op, const RegionSuccessor &successor, ValueRange successorInputs, ArrayRef< IntegerDivisibilityLattice * > argLattices) override
Visit block arguments or operation results of an operation with region control-flow for which values ...
void setToEntryState(IntegerDivisibilityLattice *lattice) override
At an entry point, set the lattice to the most pessimistic state, indicating that no further reasonin...
LogicalResult visitOperation(Operation *op, ArrayRef< const IntegerDivisibilityLattice * > operands, ArrayRef< IntegerDivisibilityLattice * > results) override
Visit an operation, invoking the transfer function.
SparseForwardDataFlowAnalysis(DataFlowSolver &solver)
This lattice element represents the integer divisibility of an SSA value.
This class represents a lattice holding a specific value of type ValueT.
SparseForwardDataFlowAnalysis(DataFlowSolver &solver)