ScalarEvolutionDivision.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 visitSequentialUMinExpr(const SCEVSequentialUMinExpr *Numerator) {}
  43. void visitUnknown(const SCEVUnknown *Numerator) {}
  44. void visitCouldNotCompute(const SCEVCouldNotCompute *Numerator) {}
  45. void visitConstant(const SCEVConstant *Numerator);
  46. void visitAddRecExpr(const SCEVAddRecExpr *Numerator);
  47. void visitAddExpr(const SCEVAddExpr *Numerator);
  48. void visitMulExpr(const SCEVMulExpr *Numerator);
  49. private:
  50. SCEVDivision(ScalarEvolution &S, const SCEV *Numerator,
  51. const SCEV *Denominator);
  52. // Convenience function for giving up on the division. We set the quotient to
  53. // be equal to zero and the remainder to be equal to the numerator.
  54. void cannotDivide(const SCEV *Numerator);
  55. ScalarEvolution &SE;
  56. const SCEV *Denominator, *Quotient, *Remainder, *Zero, *One;
  57. };
  58. } // end namespace llvm
  59. #endif // LLVM_ANALYSIS_SCALAREVOLUTIONDIVISION_H
  60. #ifdef __GNUC__
  61. #pragma GCC diagnostic pop
  62. #endif