Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:17

0001 //===- llvm/Analysis/ScalarEvolutionDivision.h - See below ------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines the class that knows how to divide SCEV's.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
0014 #define LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
0015 
0016 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
0017 
0018 namespace llvm {
0019 
0020 class SCEV;
0021 
0022 class ScalarEvolution;
0023 
0024 struct SCEVCouldNotCompute;
0025 
0026 struct SCEVDivision : public SCEVVisitor<SCEVDivision, void> {
0027 public:
0028   // Computes the Quotient and Remainder of the division of Numerator by
0029   // Denominator.
0030   static void divide(ScalarEvolution &SE, const SCEV *Numerator,
0031                      const SCEV *Denominator, const SCEV **Quotient,
0032                      const SCEV **Remainder);
0033 
0034   // Except in the trivial case described above, we do not know how to divide
0035   // Expr by Denominator for the following functions with empty implementation.
0036   void visitPtrToIntExpr(const SCEVPtrToIntExpr *Numerator) {}
0037   void visitTruncateExpr(const SCEVTruncateExpr *Numerator) {}
0038   void visitZeroExtendExpr(const SCEVZeroExtendExpr *Numerator) {}
0039   void visitSignExtendExpr(const SCEVSignExtendExpr *Numerator) {}
0040   void visitUDivExpr(const SCEVUDivExpr *Numerator) {}
0041   void visitSMaxExpr(const SCEVSMaxExpr *Numerator) {}
0042   void visitUMaxExpr(const SCEVUMaxExpr *Numerator) {}
0043   void visitSMinExpr(const SCEVSMinExpr *Numerator) {}
0044   void visitUMinExpr(const SCEVUMinExpr *Numerator) {}
0045   void visitSequentialUMinExpr(const SCEVSequentialUMinExpr *Numerator) {}
0046   void visitUnknown(const SCEVUnknown *Numerator) {}
0047   void visitCouldNotCompute(const SCEVCouldNotCompute *Numerator) {}
0048 
0049   void visitConstant(const SCEVConstant *Numerator);
0050 
0051   void visitVScale(const SCEVVScale *Numerator);
0052 
0053   void visitAddRecExpr(const SCEVAddRecExpr *Numerator);
0054 
0055   void visitAddExpr(const SCEVAddExpr *Numerator);
0056 
0057   void visitMulExpr(const SCEVMulExpr *Numerator);
0058 
0059 private:
0060   SCEVDivision(ScalarEvolution &S, const SCEV *Numerator,
0061                const SCEV *Denominator);
0062 
0063   // Convenience function for giving up on the division. We set the quotient to
0064   // be equal to zero and the remainder to be equal to the numerator.
0065   void cannotDivide(const SCEV *Numerator);
0066 
0067   ScalarEvolution &SE;
0068   const SCEV *Denominator, *Quotient, *Remainder, *Zero, *One;
0069 };
0070 
0071 } // end namespace llvm
0072 
0073 #endif // LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H