ScalarEvolutionDivision.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
  13. #define LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
  14. #include "llvm/Analysis/ScalarEvolutionExpressions.h"
  15. namespace llvm {
  16. class SCEV;
  17. class ScalarEvolution;
  18. struct SCEVCouldNotCompute;
  19. struct SCEVDivision : public SCEVVisitor<SCEVDivision, void> {
  20. public:
  21. // Computes the Quotient and Remainder of the division of Numerator by
  22. // Denominator.
  23. static void divide(ScalarEvolution &SE, const SCEV *Numerator,
  24. const SCEV *Denominator, const SCEV **Quotient,
  25. const SCEV **Remainder);
  26. // Except in the trivial case described above, we do not know how to divide
  27. // Expr by Denominator for the following functions with empty implementation.
  28. void visitPtrToIntExpr(const SCEVPtrToIntExpr *Numerator) {}
  29. void visitTruncateExpr(const SCEVTruncateExpr *Numerator) {}
  30. void visitZeroExtendExpr(const SCEVZeroExtendExpr *Numerator) {}
  31. void visitSignExtendExpr(const SCEVSignExtendExpr *Numerator) {}
  32. void visitUDivExpr(const SCEVUDivExpr *Numerator) {}
  33. void visitSMaxExpr(const SCEVSMaxExpr *Numerator) {}
  34. void visitUMaxExpr(const SCEVUMaxExpr *Numerator) {}
  35. void visitSMinExpr(const SCEVSMinExpr *Numerator) {}
  36. void visitUMinExpr(const SCEVUMinExpr *Numerator) {}
  37. void visitUnknown(const SCEVUnknown *Numerator) {}
  38. void visitCouldNotCompute(const SCEVCouldNotCompute *Numerator) {}
  39. void visitConstant(const SCEVConstant *Numerator);
  40. void visitAddRecExpr(const SCEVAddRecExpr *Numerator);
  41. void visitAddExpr(const SCEVAddExpr *Numerator);
  42. void visitMulExpr(const SCEVMulExpr *Numerator);
  43. private:
  44. SCEVDivision(ScalarEvolution &S, const SCEV *Numerator,
  45. const SCEV *Denominator);
  46. // Convenience function for giving up on the division. We set the quotient to
  47. // be equal to zero and the remainder to be equal to the numerator.
  48. void cannotDivide(const SCEV *Numerator);
  49. ScalarEvolution &SE;
  50. const SCEV *Denominator, *Quotient, *Remainder, *Zero, *One;
  51. };
  52. } // end namespace llvm
  53. #endif // LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H