LLVM  14.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 
18 namespace llvm {
19 
20 class SCEV;
21 
22 class ScalarEvolution;
23 
24 struct SCEVCouldNotCompute;
25 
26 struct SCEVDivision : public SCEVVisitor<SCEVDivision, void> {
27 public:
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) {}
45  void visitUnknown(const SCEVUnknown *Numerator) {}
46  void visitCouldNotCompute(const SCEVCouldNotCompute *Numerator) {}
47 
48  void visitConstant(const SCEVConstant *Numerator);
49 
50  void visitAddRecExpr(const SCEVAddRecExpr *Numerator);
51 
52  void visitAddExpr(const SCEVAddExpr *Numerator);
53 
54  void visitMulExpr(const SCEVMulExpr *Numerator);
55 
56 private:
57  SCEVDivision(ScalarEvolution &S, const SCEV *Numerator,
58  const SCEV *Denominator);
59 
60  // Convenience function for giving up on the division. We set the quotient to
61  // be equal to zero and the remainder to be equal to the numerator.
62  void cannotDivide(const SCEV *Numerator);
63 
64  ScalarEvolution &SE;
65  const SCEV *Denominator, *Quotient, *Remainder, *Zero, *One;
66 };
67 
68 } // end namespace llvm
69 
70 #endif // LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
llvm::SCEVDivision::visitConstant
void visitConstant(const SCEVConstant *Numerator)
Definition: ScalarEvolutionDivision.cpp:110
llvm::SCEVUDivExpr
This class represents a binary unsigned division operation.
Definition: ScalarEvolutionExpressions.h:303
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::SCEVUMinExpr
This class represents an unsigned minimum selection.
Definition: ScalarEvolutionExpressions.h:514
llvm::SCEVDivision::visitMulExpr
void visitMulExpr(const SCEVMulExpr *Numerator)
Definition: ScalarEvolutionDivision.cpp:174
llvm::SCEVDivision::visitCouldNotCompute
void visitCouldNotCompute(const SCEVCouldNotCompute *Numerator)
Definition: ScalarEvolutionDivision.h:46
llvm::SCEVSMaxExpr
This class represents a signed maximum selection.
Definition: ScalarEvolutionExpressions.h:472
llvm::SCEVPtrToIntExpr
This class represents a cast from a pointer to a pointer-sized integer value.
Definition: ScalarEvolutionExpressions.h:108
llvm::SCEVDivision::visitUMaxExpr
void visitUMaxExpr(const SCEVUMaxExpr *Numerator)
Definition: ScalarEvolutionDivision.h:42
llvm::ScalarEvolution
The main scalar evolution driver.
Definition: ScalarEvolution.h:460
llvm::SCEVSignExtendExpr
This class represents a sign extension of a small integer value to a larger integer value.
Definition: ScalarEvolutionExpressions.h:167
llvm::SCEVDivision::visitUMinExpr
void visitUMinExpr(const SCEVUMinExpr *Numerator)
Definition: ScalarEvolutionDivision.h:44
llvm::SCEVDivision::visitZeroExtendExpr
void visitZeroExtendExpr(const SCEVZeroExtendExpr *Numerator)
Definition: ScalarEvolutionDivision.h:38
llvm::SCEVZeroExtendExpr
This class represents a zero extension of a small integer value to a larger integer value.
Definition: ScalarEvolutionExpressions.h:152
llvm::SCEVVisitor
This class defines a simple visitor class that may be used for various SCEV analysis purposes.
Definition: ScalarEvolutionExpressions.h:576
llvm::SCEVDivision::visitTruncateExpr
void visitTruncateExpr(const SCEVTruncateExpr *Numerator)
Definition: ScalarEvolutionDivision.h:37
llvm::SCEVTruncateExpr
This class represents a truncation of an integer value to a smaller integer value.
Definition: ScalarEvolutionExpressions.h:137
llvm::SCEVMulExpr
This node represents multiplication of some number of SCEVs.
Definition: ScalarEvolutionExpressions.h:286
llvm::SCEVUMaxExpr
This class represents an unsigned maximum selection.
Definition: ScalarEvolutionExpressions.h:486
llvm::SCEVDivision::visitSMinExpr
void visitSMinExpr(const SCEVSMinExpr *Numerator)
Definition: ScalarEvolutionDivision.h:43
llvm::SCEVDivision
Definition: ScalarEvolutionDivision.h:26
llvm::SCEVDivision::visitAddExpr
void visitAddExpr(const SCEVAddExpr *Numerator)
Definition: ScalarEvolutionDivision.cpp:148
llvm::SCEVDivision::visitUnknown
void visitUnknown(const SCEVUnknown *Numerator)
Definition: ScalarEvolutionDivision.h:45
llvm::SCEV
This class represents an analyzed expression in the program.
Definition: ScalarEvolution.h:77
llvm::SCEVConstant
This class represents a constant integer value.
Definition: ScalarEvolutionExpressions.h:47
llvm::SCEVCouldNotCompute
An object of this class is returned by queries that could not be answered.
Definition: ScalarEvolution.h:208
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::SCEVDivision::divide
static void divide(ScalarEvolution &SE, const SCEV *Numerator, const SCEV *Denominator, const SCEV **Quotient, const SCEV **Remainder)
Definition: ScalarEvolutionDivision.cpp:57
llvm::SCEVSMinExpr
This class represents a signed minimum selection.
Definition: ScalarEvolutionExpressions.h:500
llvm::SCEVDivision::visitSignExtendExpr
void visitSignExtendExpr(const SCEVSignExtendExpr *Numerator)
Definition: ScalarEvolutionDivision.h:39
llvm::SCEVAddRecExpr
This node represents a polynomial recurrence on the trip count of the specified loop.
Definition: ScalarEvolutionExpressions.h:352
llvm::SCEVUnknown
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
Definition: ScalarEvolutionExpressions.h:530
llvm::SCEVDivision::visitAddRecExpr
void visitAddRecExpr(const SCEVAddRecExpr *Numerator)
Definition: ScalarEvolutionDivision.cpp:131
ScalarEvolutionExpressions.h
llvm::SCEVAddExpr
This node represents an addition of some number of SCEVs.
Definition: ScalarEvolutionExpressions.h:260
llvm::SCEVDivision::visitPtrToIntExpr
void visitPtrToIntExpr(const SCEVPtrToIntExpr *Numerator)
Definition: ScalarEvolutionDivision.h:36
llvm::SCEVDivision::visitUDivExpr
void visitUDivExpr(const SCEVUDivExpr *Numerator)
Definition: ScalarEvolutionDivision.h:40
llvm::SCEVDivision::visitSMaxExpr
void visitSMaxExpr(const SCEVSMaxExpr *Numerator)
Definition: ScalarEvolutionDivision.h:41