ScalarEvolutionDivision.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/Analysis/ScalarEvolutionDivision.h - See below ------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines the class that knows how to divide SCEV's.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
  18. #define LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
  19. #include "llvm/Analysis/ScalarEvolutionExpressions.h"
  20. namespace llvm {
  21. class SCEV;
  22. class ScalarEvolution;
  23. struct SCEVCouldNotCompute;
  24. struct SCEVDivision : public SCEVVisitor<SCEVDivision, void> {
  25. public:
  26. // Computes the Quotient and Remainder of the division of Numerator by
  27. // Denominator.
  28. static void divide(ScalarEvolution &SE, const SCEV *Numerator,
  29. const SCEV *Denominator, const SCEV **Quotient,
  30. const SCEV **Remainder);
  31. // Except in the trivial case described above, we do not know how to divide
  32. // Expr by Denominator for the following functions with empty implementation.
  33. void visitPtrToIntExpr(const SCEVPtrToIntExpr *Numerator) {}
  34. void visitTruncateExpr(const SCEVTruncateExpr *Numerator) {}
  35. void visitZeroExtendExpr(const SCEVZeroExtendExpr *Numerator) {}
  36. void visitSignExtendExpr(const SCEVSignExtendExpr *Numerator) {}
  37. void visitUDivExpr(const SCEVUDivExpr *Numerator) {}
  38. void visitSMaxExpr(const SCEVSMaxExpr *Numerator) {}
  39. void visitUMaxExpr(const SCEVUMaxExpr *Numerator) {}
  40. void visitSMinExpr(const SCEVSMinExpr *Numerator) {}
  41. void visitUMinExpr(const SCEVUMinExpr *Numerator) {}
  42. void visitUnknown(const SCEVUnknown *Numerator) {}
  43. void visitCouldNotCompute(const SCEVCouldNotCompute *Numerator) {}
  44. void visitConstant(const SCEVConstant *Numerator);
  45. void visitAddRecExpr(const SCEVAddRecExpr *Numerator);
  46. void visitAddExpr(const SCEVAddExpr *Numerator);
  47. void visitMulExpr(const SCEVMulExpr *Numerator);
  48. private:
  49. SCEVDivision(ScalarEvolution &S, const SCEV *Numerator,
  50. const SCEV *Denominator);
  51. // Convenience function for giving up on the division. We set the quotient to
  52. // be equal to zero and the remainder to be equal to the numerator.
  53. void cannotDivide(const SCEV *Numerator);
  54. ScalarEvolution &SE;
  55. const SCEV *Denominator, *Quotient, *Remainder, *Zero, *One;
  56. };
  57. } // end namespace llvm
  58. #endif // LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
  59. #ifdef __GNUC__
  60. #pragma GCC diagnostic pop
  61. #endif