LLVM 20.0.0git
ScalarEvolutionDivision.h
Go to the documentation of this file.
1//===- llvm/Analysis/ScalarEvolutionDivision.h - See below ------*- 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 defines the class that knows how to divide SCEV's.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
14#define LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
15
17
18namespace llvm {
19
20class SCEV;
21
22class ScalarEvolution;
23
24struct SCEVCouldNotCompute;
25
26struct SCEVDivision : public SCEVVisitor<SCEVDivision, void> {
27public:
28 // Computes the Quotient and Remainder of the division of Numerator by
29 // Denominator.
30 static void divide(ScalarEvolution &SE, const SCEV *Numerator,
31 const SCEV *Denominator, const SCEV **Quotient,
32 const SCEV **Remainder);
33
34 // Except in the trivial case described above, we do not know how to divide
35 // Expr by Denominator for the following functions with empty implementation.
36 void visitPtrToIntExpr(const SCEVPtrToIntExpr *Numerator) {}
37 void visitTruncateExpr(const SCEVTruncateExpr *Numerator) {}
38 void visitZeroExtendExpr(const SCEVZeroExtendExpr *Numerator) {}
39 void visitSignExtendExpr(const SCEVSignExtendExpr *Numerator) {}
40 void visitUDivExpr(const SCEVUDivExpr *Numerator) {}
41 void visitSMaxExpr(const SCEVSMaxExpr *Numerator) {}
42 void visitUMaxExpr(const SCEVUMaxExpr *Numerator) {}
43 void visitSMinExpr(const SCEVSMinExpr *Numerator) {}
44 void visitUMinExpr(const SCEVUMinExpr *Numerator) {}
46 void visitUnknown(const SCEVUnknown *Numerator) {}
47 void visitCouldNotCompute(const SCEVCouldNotCompute *Numerator) {}
48
49 void visitConstant(const SCEVConstant *Numerator);
50
51 void visitVScale(const SCEVVScale *Numerator);
52
53 void visitAddRecExpr(const SCEVAddRecExpr *Numerator);
54
55 void visitAddExpr(const SCEVAddExpr *Numerator);
56
57 void visitMulExpr(const SCEVMulExpr *Numerator);
58
59private:
60 SCEVDivision(ScalarEvolution &S, const SCEV *Numerator,
61 const SCEV *Denominator);
62
63 // Convenience function for giving up on the division. We set the quotient to
64 // be equal to zero and the remainder to be equal to the numerator.
65 void cannotDivide(const SCEV *Numerator);
66
68 const SCEV *Denominator, *Quotient, *Remainder, *Zero, *One;
69};
70
71} // end namespace llvm
72
73#endif // LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
This node represents an addition of some number of SCEVs.
This node represents a polynomial recurrence on the trip count of the specified loop.
This class represents a constant integer value.
This node represents multiplication of some number of SCEVs.
This class represents a cast from a pointer to a pointer-sized integer value.
This class represents a signed maximum selection.
This class represents a signed minimum selection.
This class represents a sequential/in-order unsigned minimum selection.
This class represents a sign extension of a small integer value to a larger integer value.
This class represents a truncation of an integer value to a smaller integer value.
This class represents a binary unsigned division operation.
This class represents an unsigned maximum selection.
This class represents an unsigned minimum selection.
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
This class represents the value of vscale, as used when defining the length of a scalable vector or r...
This class represents a zero extension of a small integer value to a larger integer value.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
An object of this class is returned by queries that could not be answered.
void visitSequentialUMinExpr(const SCEVSequentialUMinExpr *Numerator)
static void divide(ScalarEvolution &SE, const SCEV *Numerator, const SCEV *Denominator, const SCEV **Quotient, const SCEV **Remainder)
void visitUMinExpr(const SCEVUMinExpr *Numerator)
void visitVScale(const SCEVVScale *Numerator)
void visitZeroExtendExpr(const SCEVZeroExtendExpr *Numerator)
void visitSignExtendExpr(const SCEVSignExtendExpr *Numerator)
void visitTruncateExpr(const SCEVTruncateExpr *Numerator)
void visitSMaxExpr(const SCEVSMaxExpr *Numerator)
void visitPtrToIntExpr(const SCEVPtrToIntExpr *Numerator)
void visitSMinExpr(const SCEVSMinExpr *Numerator)
void visitUMaxExpr(const SCEVUMaxExpr *Numerator)
void visitCouldNotCompute(const SCEVCouldNotCompute *Numerator)
void visitAddRecExpr(const SCEVAddRecExpr *Numerator)
void visitUnknown(const SCEVUnknown *Numerator)
void visitUDivExpr(const SCEVUDivExpr *Numerator)
void visitConstant(const SCEVConstant *Numerator)
void visitAddExpr(const SCEVAddExpr *Numerator)
void visitMulExpr(const SCEVMulExpr *Numerator)
This class defines a simple visitor class that may be used for various SCEV analysis purposes.